summaryrefslogtreecommitdiffstats
path: root/rules/rootfs.make
blob: 027f7d09b3af5664002c565c99b4e4259b717ebd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
# -*-makefile-*-
# $Id$
#
# Copyright (C) 2002, 2003 by Pengutronix e.K., Hildesheim, Germany
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
PACKAGES-$(PTXCONF_ROOTFS) += rootfs

# dummy to make ipkg happy
ROOTFS_VERSION	= 1.0.0
ROOTFS_DIR	= $(BUILDDIR)/rootfs

# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

rootfs_get: $(STATEDIR)/rootfs.get

$(STATEDIR)/rootfs.get: $(rootfs_get_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

rootfs_extract: $(STATEDIR)/rootfs.extract

$(STATEDIR)/rootfs.extract: $(rootfs_extract_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

rootfs_prepare: $(STATEDIR)/rootfs.prepare

$(STATEDIR)/rootfs.prepare: $(rootfs_prepare_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

rootfs_compile: $(STATEDIR)/rootfs.compile

$(STATEDIR)/rootfs.compile: $(rootfs_compile_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

rootfs_install: $(STATEDIR)/rootfs.install

$(STATEDIR)/rootfs.install: $(rootfs_install_deps_default)
	@$(call targetinfo, $@)
	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

rootfs_targetinstall: $(STATEDIR)/rootfs.targetinstall

$(STATEDIR)/rootfs.targetinstall: $(rootfs_targetinstall_deps_default)
	@$(call targetinfo, $@)

	@$(call install_init,  rootfs)
	@$(call install_fixup, rootfs,PACKAGE,rootfs)
	@$(call install_fixup, rootfs,PRIORITY,optional)
	@$(call install_fixup, rootfs,VERSION,$(ROOTFS_VERSION))
	@$(call install_fixup, rootfs,SECTION,base)
	@$(call install_fixup, rootfs,AUTHOR,"Robert Schwebel <r.schwebel\@pengutronix.de>")
	@$(call install_fixup, rootfs,DEPENDS,)
	@$(call install_fixup, rootfs,DESCRIPTION,missing)

# -----------------------------------------------------------------------------
# This part generates root filesystem's structure
# -----------------------------------------------------------------------------

ifdef PTXCONF_ROOTFS_DEV
	@$(call install_copy, rootfs, 0, 0, 0755, /dev)
endif
ifdef PTXCONF_ROOTFS_DEV_INITIAL
	@$(call install_node, rootfs, 0, 0, 0644, c, 1, 3, /dev/null)
	@$(call install_node, rootfs, 0, 0, 0644, c, 1, 5, /dev/zero)
	@$(call install_node, rootfs, 0, 0, 0600, c, 5, 1, /dev/console)
endif
ifdef PTXCONF_ROOTFS_HOME
	@$(call install_copy, rootfs, 0, 0, 2775, /home)
endif
ifdef PTXCONF_ROOTFS_MEDIA
ifneq ($(PTXCONF_ROOTFS_MEDIA1),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA1))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA2),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA2))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA3),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA3))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA4),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA4))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA5),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA5))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA6),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA6))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA7),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA7))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA8),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA8))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA9),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA9))
endif
ifneq ($(PTXCONF_ROOTFS_MEDIA10),"")
	@$(call install_copy, rootfs, 0, 0, 0777, /media/$(PTXCONF_ROOTFS_MEDIA10))
endif
endif
ifdef PTXCONF_ROOTFS_MNT
	@$(call install_copy, rootfs, 0, 0, 0755, /mnt)
endif
ifdef PTXCONF_ROOTFS_PROC
	@$(call install_copy, rootfs, 0, 0, 0555, /proc)
endif
ifdef PTXCONF_ROOTFS_SYS
	@$(call install_copy, rootfs, 0, 0, 0755, /sys)
endif
ifdef PTXCONF_ROOTFS_TMP
	@$(call install_copy, rootfs, 0, 0, 1777, /tmp)
endif
ifdef PTXCONF_ROOTFS_VAR
	@$(call install_copy, rootfs, 0, 0, 0755, /var)
endif
ifdef PTXCONF_ROOTFS_VAR_LOG
	@$(call install_copy, rootfs, 0, 0, 0755, /var/log)
endif
ifdef PTXCONF_ROOTFS_VAR_RUN
	@$(call install_copy, rootfs, 0, 0, 0755, /var/run)
endif
ifdef PTXCONF_ROOTFS_VAR_LOCK
	@$(call install_copy, rootfs, 0, 0, 0755, /var/lock)
endif
ifdef PTXCONF_ROOTFS_VAR_LIB
	@$(call install_copy, rootfs, 0, 0, 0755, /var/lib)
endif
# -----------------------------------------------------------------------------
# This part installs startscrips into /etc/init.d and links into /etc/rc.d
# -----------------------------------------------------------------------------

# First of all: generate the required directories

	@$(call install_copy, rootfs, 0, 0, 0755, /etc/init.d)
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/rc.d)

# -----------------------------------------------------------------------------
# FIXME provide also a user defined file!
ifdef PTXCONF_ROOTFS_ETC_INITD_RCS
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/rcS, \
		/etc/init.d/rcS, n)
endif

# -----------------------------------------------------------------------------
# FIXME provide also a user defined file!
ifdef PTXCONF_ROOTFS_ETC_INITD_LOGROTATE
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/logrotate, \
		/etc/init.d/logrotate, n)
endif

# -----------------------------------------------------------------------------
# initd's script is here, because the busybox entry does not provide it
# initd from inetutils package uses its own startscript
#
ifdef PTXCONF_ROOTFS_ETC_INITD_INETD
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/inetd, \
		/etc/init.d/inetd, n)
ifneq ($(PTXCONF_ROOTFS_ETC_INITD_INETD_LINK),"")
	@$(call install_link, rootfs, ../init.d/inetd, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_INETD_LINK))
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_ETC_INITD_MODULES
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/modules, \
		/etc/init.d/modules, n)
ifneq ($(PTXCONF_ROOTFS_ETC_INITD_MODULES_LINK),"")
	@$(call install_link, rootfs, ../init.d/modules, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_MODULES_LINK))
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_ETC_INITD_NETWORKING
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/networking, \
		/etc/init.d/networking, n)
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/network/if-down.d)
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/network/if-up.d)
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/network/if-post-down.d)
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/network/if-pre-up.d)
ifneq ($(PTXCONF_ROOTFS_ETC_INITD_NETWORKING_LINK),"")
	@$(call install_link, rootfs, ../init.d/networking, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_NETWORKING_LINK))
endif
ifneq ($(PTXCONF_ROOTFS_ETC_INITD_NETWORKING_INTERFACES),"")
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXCONF_ROOTFS_ETC_INITD_NETWORKING_INTERFACES), \
		/etc/network/interfaces, n)
endif
endif

# -----------------------------------------------------------------------------
# telnetd's script is here, because the busybox entry does not provide it
# telnetd from other packets are useing their own startscript
#
ifdef PTXCONF_ROOTFS_ETC_INITD_TELNETD
# provide everything for standalone mode
ifdef PTXCONF_ROOTFS_ETC_INITD_TELNETD_DEFAULT
# use the generic one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/telnetd, \
		/etc/init.d/telnetd, n)
endif
ifdef PTXCONF_ROOTFS_ETC_INITD_TELNETD_USER
# user defined one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/init.d/telnetd, \
		/etc/init.d/telnetd, n)
endif

ifneq ($(PTXCONF_ROOTFS_ETC_INITD_TELNETD_LINK),"")
	@$(call install_link, rootfs, ../init.d/telnetd, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_TELNETD_LINK))
endif
endif

# -----------------------------------------------------------------------------
# syslogd/klogd's script is here, because the busybox entry does not provide it
# syslogd/klogd from other packets are useing their own startscript
#
ifdef PTXCONF_ROOTFS_ETC_INITD_SYSLOGD_KLOGD
# provide everything for standalone mode
ifdef PTXCONF_ROOTFS_ETC_INITD_SYSLOGD_KLOGD_DEFAULT
# use the generic one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/syslogd, \
		/etc/init.d/syslogd, n)
endif
ifdef PTXCONF_ROOTFS_ETC_INITD_SYSLOGD_KLOGD_USER
# user defined one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/init.d/syslogd, \
		/etc/init.d/syslogd, n)
endif

ifneq ($(PTXCONF_ROOTFS_ETC_INITD_SYSLOGD_KLOGD_LINK),"")
	@$(call install_link, rootfs, ../init.d/syslogd, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_SYSLOGD_KLOGD_LINK))
endif
endif

# -----------------------------------------------------------------------------
# crond's script is here, because the busybox entry does not provide it
#
ifdef PTXCONF_ROOTFS_ETC_INITD_CROND
# provide everything for standalone mode
ifdef PTXCONF_ROOTFS_ETC_INITD_CROND_DEFAULT
# use the generic one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/crond, \
		/etc/init.d/crond, n)
endif
ifdef PTXCONF_ROOTFS_ETC_INITD_CROND_USER
# user defined one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/init.d/crond, \
		/etc/init.d/crond, n)
endif

ifneq ($(PTXCONF_ROOTFS_ETC_INITD_CROND_LINK),"")
	@$(call install_link, rootfs, ../init.d/crond, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_CROND_LINK))
endif
endif

# -----------------------------------------------------------------------------
# timekeepers script is here, because the busybox entry does not provide it
#
ifdef PTXCONF_ROOTFS_ETC_INITD_HWCLOCK
ifdef PTXCONF_ROOTFS_ETC_INITD_HWCLOCK_DEFAULT
# use the generic one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/timekeeping, \
		/etc/init.d/timekeeping, n)
endif
ifdef PTXCONF_ROOTFS_ETC_INITD_HWCLOCK_USER
# user defined one
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/init.d/timekeeping, \
		/etc/init.d/timekeeping, n)
endif

ifneq ($(PTXCONF_ROOTFS_ETC_INITD_TIMEKEEPER_LINK),"")
	@$(call install_link, rootfs, ../init.d/timekeeping, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_TIMEKEEPER_LINK))
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_ETC_INITD_STARTUP
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/startup, \
		/etc/init.d/startup, n)
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_ETC_INITD_BANNER
	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_TOPDIR)/generic/etc/init.d/banner, \
		/etc/init.d/banner, n)

	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@VENDOR@,  $(PTXCONF_ROOTFS_ETC_VENDOR) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@PROJECT@,  $(PTXCONF_PROJECT) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@PRJVERSION@,  $(PTXCONF_PROJECT_VERSION) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@VERSION@,  $(VERSION) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@PTXDIST@,  $(PROJECT) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@PATCHLEVEL@,  $(PATCHLEVEL) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@SUBLEVEL@,  $(SUBLEVEL) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@EXTRAVERSION@,  $(EXTRAVERSION) )
	@$(call install_replace, rootfs, /etc/init.d/banner, \
		@DATE@, $(shell date -Iseconds) )

ifneq ($(PTXCONF_ROOTFS_ETC_INITD_BANNER_LINK),"")
	@$(call install_link, rootfs, ../init.d/banner, \
		/etc/rc.d/$(PTXCONF_ROOTFS_ETC_INITD_BANNER_LINK))
endif
endif

# -----------------------------------------------------------------------------
# This part installs configuration files into /etc
# -----------------------------------------------------------------------------

ifdef PTXCONF_ROOTFS_PASSWD
# /etc/passwd
ifdef PTXCONF_ROOTFS_GENERIC_PASSWD
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/passwd, \
		/etc/passwd, n)
endif
ifdef PTXCONF_ROOTFS_USER_PASSWD
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/passwd, \
		/etc/passwd, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_SHADOW
# /etc/shadow, /etc/shadow-
ifdef PTXCONF_ROOTFS_GENERIC_SHADOW
	@$(call install_copy, rootfs, 0, 0, 0640, \
		$(PTXDIST_TOPDIR)/generic/etc/shadow, \
		/etc/shadow, n)
	@$(call install_copy, rootfs, 0, 0, 0600, \
		$(PTXDIST_TOPDIR)/generic/etc/shadow-, \
		/etc/shadow-, n)
endif
ifdef PTXCONF_ROOTFS_USER_SHADOW
	@$(call install_copy, rootfs, 0, 0, 0640, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/shadow, \
		/etc/shadow, n)
	@$(call install_copy, rootfs, 0, 0, 0600, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/shadow-, \
		/etc/shadow-, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_GROUP
# /etc/group, /etc/gshadow
ifdef PTXCONF_ROOTFS_GENERIC_GROUP
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/group, \
		/etc/group, n)
	@$(call install_copy, rootfs, 0, 0, 0640, \
		$(PTXDIST_TOPDIR)/generic/etc/gshadow, \
		/etc/gshadow, n)
endif
ifdef PTXCONF_ROOTFS_USER_GROUP
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/group, \
		/etc/group, n)
	@$(call install_copy, rootfs, 0, 0, 0640, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/gshadow, \
		/etc/gshadow, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_FSTAB
# /etc/fstab
ifdef PTXCONF_ROOTFS_GENERIC_FSTAB
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/fstab, \
		/etc/fstab, n)
endif
ifdef PTXCONF_ROOTFS_USER_FSTAB
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/fstab, \
		/etc/fstab, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_MTAB
# /etc/mtab
ifdef PTXCONF_ROOTFS_GENERIC_MTAB
	@$(call install_link, rootfs, /proc/mounts, /etc/mtab)
endif
ifdef PTXCONF_ROOTFS_USER_MTAB
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/mtab, \
		/etc/mtab, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_HOSTNAME
# /etc/hostname
ifdef PTXCONF_ROOTFS_GENERIC_HOSTNAME
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/hostname, \
		/etc/hostname, n)
	@$(call install_replace, rootfs, /etc/hostname, \
		@HOSTNAME@, \
		$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_HOSTNAME)))
endif
ifdef PTXCONF_ROOTFS_USER_HOSTNAME
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/hostname, \
		/etc/hostname, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_HOSTS
# /etc/hosts
ifdef PTXCONF_ROOTFS_GENERIC_HOSTS
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/hosts, \
		/etc/hosts, n)
endif
ifdef PTXCONF_ROOTFS_USER_HOSTS
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/hosts, \
		/etc/hosts, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_INITTAB
# /etc/inittab
ifdef PTXCONF_ROOTFS_GENERIC_INITTAB
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/inittab, \
		/etc/inittab, n)
endif
ifdef PTXCONF_ROOTFS_USER_INITTAB
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/inittab, \
		/etc/inittab, n)
endif
	@$(call install_replace, rootfs, /etc/inittab, \
		@CONSOLE@, \
		$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_CONSOLE)))
	@$(call install_replace, rootfs, /etc/inittab, \
		@SPEED@, \
		$(call remove_quotes,$(PTXCONF_ROOTFS_ETC_CONSOLE_SPEED)))
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_NSSWITCH
# /etc/nsswitch
ifdef PTXCONF_ROOTFS_GENERIC_NSSWITCH
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/nsswitch.conf, \
		/etc/nsswitch.conf, n)
endif
ifdef PTXCONF_ROOTFS_USER_NSSWITCH
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/nsswitch.conf, \
		/etc/nsswitch.conf, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_PROFILE
# /etc/profile
ifdef PTXCONF_ROOTFS_GENERIC_PROFILE
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/profile, \
		/etc/profile, n)
endif
ifdef PTXCONF_ROOTFS_USER_PROFILE
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/profile, \
		/etc/profile, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_PROTOCOLS
# /etc/protocols
ifdef PTXCONF_ROOTFS_GENERIC_PROTOCOLS
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/protocols, \
		/etc/protocols, n)
endif
ifdef PTXCONF_ROOTFS_USER_PROTOCOLS
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/protocols, \
		/etc/protocols, n)
endif
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_RESOLV
# /etc/resolv
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/resolv.conf, \
		/etc/resolv.conf, n)
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_ETC_MODULES
# /etc/modules
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/modules, \
		/etc/modules, n)
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_GENERIC_IPKG_CONF
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/ipkg.conf, /etc/ipkg.conf, n)
	@$(call install_replace, rootfs, /etc/ipkg.conf, @SRC@, \
		$(PTXCONF_ROOTFS_GENERIC_IPKG_CONF_URL))
	@$(call install_replace, rootfs, /etc/ipkg.conf, @ARCH@, \
  		$(PTXCONF_ARCH))
endif

# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_UDHCPC

ifdef PTXCONF_ROOTFS_GENERIC_UDHCPC
	@$(call install_copy, rootfs, 0, 0, 0754, \
		$(PTXDIST_TOPDIR)/generic/etc/udhcpc.script, \
		/etc/udhcpc.script, n)
endif

ifdef PTXCONF_ROOTFS_USER_UDHCPC
	@$(call install_copy, rootfs, 0, 0, 0754, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/udhcpc.script, \
		/etc/udhcpc.script, n)
endif

# udhcp expects the script to be called /usr/share/udhcpc/default.script,
# so we make a link
	@$(call install_link, rootfs, /etc/udhcpc.script, \
		/usr/share/udhcpc/default.script)

endif
# -----------------------------------------------------------------------------
ifdef PTXCONF_ROOTFS_USER_CROND_CONF
	@$(call install_copy, rootfs, 0, 0, 0755, /etc/cron)
	@$(call install_copy, rootfs, 0, 0, 0755, /var/spool/cron/crontabs/)

	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/crond/root, \
		/var/spool/cron/crontabs/root, n)

	@$(call install_copy, rootfs, 0, 0, 0755, \
		$(PTXDIST_WORKSPACE)/projectroot/crond/daily, \
		/etc/cron/daily, n)
endif

# -----------------------------------------------------------------------------
# This part creates /etc/inetd.conf and /etc/services on demand
# -----------------------------------------------------------------------------

ifdef PTXCONF_ROOTFS_INETD
# /etc/inetd.conf
ifdef PTXCONF_ROOTFS_GENERIC_INETD
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/inetd.conf, \
		/etc/inetd.conf, n )
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_TOPDIR)/generic/etc/services, \
		/etc/services, n )
endif
ifdef PTXCONF_ROOTFS_USER_INETD
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/inetd.conf, \
		/etc/inetd.conf, n )
	@$(call install_copy, rootfs, 0, 0, 0644, \
		$(PTXDIST_WORKSPACE)/projectroot/etc/services, \
		/etc/services, n )
endif

#
# Replace all markers if service is enabled
# or delete markers if service is disabled
# -----------------------------------------------------------------------------
# add rshd if enabled
#
ifdef PTXCONF_INETUTILS_RSHD
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@RSHD@, "shell stream tcp nowait root /usr/sbin/rshd" )
	@$(call install_replace, rootfs, /etc/services, \
		@RSHD@, \
		"shell 514/tcp cmd" )
else
	@$(call install_replace, rootfs, /etc/inetd.conf, @RSHD@, )
	@$(call install_replace, rootfs, /etc/services, @RSHD@, )
endif

# -----------------------------------------------------------------------------
# add NTP if enabled
#
ifdef PTXCONF_INETUTILS_NTP
# FIXME: Whats needed to start ntpd with inted?
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@NTP@, "" )
	@$(call install_replace, rootfs, /etc/services, \
		@NTP@, \
		"ntp 123/tcp\nntp 123/udp" )
else
	@$(call install_replace, rootfs, /etc/inetd.conf, @NTP@, )
	@$(call install_replace, rootfs, /etc/services, @NTP@, )
endif

# -----------------------------------------------------------------------------
# add cvs if enabled
#
ifdef PTXCONF_CVS_INETD_SERVER
ifneq ($(PTXCONF_CVS_INETD_STRING),"")
# add user defined string to start the cvs server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@CVSD@, $(PTXCONF_CVS_INETD_STRING) )
else
# add default string to start the cvs server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@CVSD@, \
		"cvspserver stream tcp nowait root /usr/bin/cvs cvsd -f @ROOT@ pserver" )
endif
ifneq ($(PTXCONF_CVS_SERVER_REPOSITORY),"")
# add info about repository's root
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@ROOT@, \
		"--allow-root=$(PTXCONF_CVS_SERVER_REPOSITORY)" )
else
# use cvs' default if not otherwise specified
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@ROOT@, )
endif
# add cvs service
	@$(call install_replace, rootfs, \
		/etc/services, \
		@CVSD@, \
		"cvspserver 2401/tcp\ncvspserver 2401/udp")
else
# remove all cvs entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @CVSD@, )
	@$(call install_replace, rootfs, /etc/services, @CVSD@, )
endif

# -----------------------------------------------------------------------------
# add rsync if enabled
#
ifdef PTXCONF_RSYNC_INETD_SERVER
ifneq ($(PTXCONF_RSYNC_INETD_STRING),"")
# add user defined string to start rsync server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@RSYNCD@, $(PTXCONF_RSYNC_INETD_STRING) )
else
# add default string to start the rsync server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@RSYNCD@, \
		"rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon @CONFIG@" )
endif
ifneq ($(PTXCONF_RSYNC_CONFIG_FILE),"")
# add path and name of config file
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@CONFIG@, "--config=$(PTXCONF_RSYNC_CONFIG_FILE)" )
else
# use rpath' default if not otherwise specified
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@CONFIG@, )
endif
# add rsync service
	@$(call install_replace, rootfs, \
		/etc/services, \
		@RSYNCD@, \
		"rsync 873/tcp\nrsync 873/udp" )
else
# remove all cvs entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @RSYNCD@, )
	@$(call install_replace, rootfs, /etc/services, @RSYNCD@, )
endif

# -----------------------------------------------------------------------------
# add famd if enabled
#
ifdef PTXCONF_FAM_INETD_SERVER
ifneq ($(PTXCONF_FAM_INETD_STRING),"")
# add user defined string to start famd server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@FAMD@, $(PTXCONF_FAM_INETD_STRING) )
else
# add default string to start the rsync server into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@FAMD@, \
		"sgi_fam/1-2 stream  rpc/tcp wait root /usr/sbin/famd famd -c /etc/fam.conf" )
endif
else
# remove all famd entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @FAMD@, )
endif

# -----------------------------------------------------------------------------
# add telnetd if enabled
#
ifdef PTXCONF_BB_CONFIG_FEATURE_TELNETD_INETD
# for busybox only!
# add default string to start the telnetd from busybox into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@TELNETD@, \
		"telnet stream tcp nowait root /usr/sbin/telnetd telnetd" )

	@$(call install_replace, rootfs, \
		/etc/services, \
		@TELNETD@, \
		"telnet 23/tcp\ntelnet 23/udp" )
else
# remove all telnetd entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @TELNETD@, )
	@$(call install_replace, rootfs, /etc/services, @TELNETD@, )
endif

# -----------------------------------------------------------------------------
# add portmap if enabled
#
ifdef PTXCONF_PORTMAP_INETD_SERVER
ifneq ($(PTXCONF_PORTMAP_INETD_STRING),"")
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@PORTMAPD@, $(PTXCONF_PORTMAP_INETD_STRING) )
else
# add default string to start the portmap into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@PORTMAPD@, \
		"sunrpc stream tcp nowait root /sbin/portmap portmap" )
endif
	@$(call install_replace, rootfs, \
		/etc/services, \
		@PORTMAPD@, \
		"sunrpc 111/tcp\nsunrpc 111/udp" )
else
# remove all portmapd entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @PORTMAPD@, )
	@$(call install_replace, rootfs, /etc/services, @PORTMAPD@, )

endif

# -----------------------------------------------------------------------------
# add dnsmasq if enabled
#
ifdef PTXCONF_DNSMASQ_INETD_SERVER
ifneq ($(PTXCONF_DNSMASQ_INETD_STRING),"")
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@DNSD@, \
		$(PTXCONF_DNSMASQ_INETD_STRING) )
else
# add default string to start the dnsmasq into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@DNSD@, \
		"domain stream tcp nowait root /sbin/dnsmasq domain" )
endif
# add dns service
	@$(call install_replace, rootfs, \
		/etc/services, \
		@DNSD@, \
		"domain 53/tcp\ndomain 53/udp" )
else
# remove all dnsmasq entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @DNSD@, )
	@$(call install_replace, rootfs, /etc/services, @DNSD@, )
endif
# -----------------------------------------------------------------------------
# add tftpd if enabled
#
ifdef PTXCONF_INETUTILS_TFTPD
ifneq ($(PTXCONF_INETUTILS_TFTPD_STRING),"")
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@TFTPD@, \
		$(PTXCONF_INETUTILS_TFTPD_STRING) )
else
# add default string to start the tftpd into inetd.conf
	@$(call install_replace, rootfs, /etc/inetd.conf, \
		@TFTPD@, \
		"tftp dgram udp wait nobody /sbin/tftpd tftpd -l @ROOT@" )
endif
# replace the base dir on demand
ifneq ($(PTXCONF_INETUTILS_TFTPD_BASE_DIR),"")
	@$(call install_replace, rootfs, \
		/etc/inetd.conf, \
		@ROOT@, \
		$(PTXCONF_INETUTILS_TFTPD_BASE_DIR) )
endif
# add tftp service
	@$(call install_replace, rootfs, \
		/etc/services, \
		@TFTPD@, \
		"tftp 69/udp" )
else
# remove all tftp entries if this service is not enabled
	@$(call install_replace, rootfs, /etc/inetd.conf, @TFTPD@, )
	@$(call install_replace, rootfs, /etc/services, @TFTPD@, )
endif
endif
# -----------------------------------------------------------------------------
	@$(call install_finish, rootfs)

	@$(call touch, $@)

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

rootfs_clean:
	rm -rf $(STATEDIR)/rootfs.* $(ROOTFS_DIR)
	rm -rf $(IMAGEDIR)/rootfs_*

# vim: syntax=make