xref: /illumos-gate/usr/src/cmd/fs.d/Makefile (revision 09f67678c27dda8a89f87f1f408a87dd49ceb0e1)
1#
2# CDDL HEADER START
3#
4# The contents of this file are subject to the terms of the
5# Common Development and Distribution License, Version 1.0 only
6# (the "License").  You may not use this file except in compliance
7# with the License.
8#
9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10# or http://www.opensolaris.org/os/licensing.
11# See the License for the specific language governing permissions
12# and limitations under the License.
13#
14# When distributing Covered Code, include this CDDL HEADER in each
15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16# If applicable, add the following below this CDDL HEADER, with the
17# fields enclosed by brackets "[]" replaced with your own identifying
18# information: Portions Copyright [yyyy] [name of copyright owner]
19#
20# CDDL HEADER END
21#
22#
23# Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26# ident	"%Z%%M%	%I%	%E% SMI"
27#
28# cmd/fs.d/Makefile
29
30# The filesystem independent utilities clri, fsdb, dcopy, labelit, and mkfs
31# are all built from the source file switchout.c. They are all then links
32# to the same object. This is accomplished by:
33#	1) building clri from switchout.c (had to choose one)
34#	2) installing it in the target directory
35#	3) linking the others to clri.
36# In a similar manner, ncheck is linked to ff.
37
38DFPROG=		df
39PROG=		$(DFPROG) fsck volcopy ff
40ROOTFS_PROG=	mount umount
41XPG4PROG=	df
42SPPROG=		clri
43MNTTAB=		mnttab
44FSTYPE=		fs
45
46include ../Makefile.cmd
47
48SUBDIR1= lofs
49SUBDIR2= fd pcfs nfs hsfs proc ctfs udfs ufs tmpfs cachefs autofs mntfs objfs
50i386_SUBDIRS= xmemfs
51i386_I18NDIRS= xmemfs
52SUBDIRS= $(SUBDIR1) $(SUBDIR2) $($(MACH)_SUBDIRS)
53ALL_SUBDIRS= $(SUBDIR1) $(SUBDIR2) $(i386_SUBDIRS)
54I18NDIRS= $(SUBDIR2) $(i386_I18NDIRS)
55
56CLOBBERFILES += $(POFILES_XPG4)
57
58all:=		TARGET= all
59install:=	TARGET= install
60clean:=		TARGET= clean
61clobber:=	TARGET= clobber
62lint:=		TARGET= lint
63_msg:=          TARGET= catalog
64
65USRSBINF=	df clri fsck volcopy ff
66USRSBINCLRI=	dcopy fsdb fssnap labelit mkfs
67USRSBINFF=	ncheck
68
69ETC2SBIN=	mount umount
70ETC2USRSBIN=	clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
71USRBIN2USRSBIN=	df
72
73FSLIB=		fslib.o
74
75ROOTSBINPROG = $(ROOTFS_PROG:%=$(ROOTSBIN)/%)
76ROOTUSRSBINLINKS = $(ROOTFS_PROG:%=$(ROOTUSRSBIN)/%)
77
78ROOTUSRSBINF=		$(USRSBINF:%=$(ROOTUSRSBIN)/%)
79ROOTUSRSBINCLRI=	$(USRSBINCLRI:%=$(ROOTUSRSBIN)/%)
80ROOTUSRSBINFF=		$(USRSBINFF:%=$(ROOTUSRSBIN)/%)
81ROOTETCMNTTAB=		$(MNTTAB:%=$(ROOTETC)/%)
82ROOTFSTYPE=		$(ROOTETC)/default/$(FSTYPE)
83SYMETC2SBIN	=	$(ETC2SBIN:%=$(ROOTETC)/%)
84SYMETC2USRSBIN	=	$(ETC2USRSBIN:%=$(ROOTETC)/%)
85SYMUSRBIN2USRSBIN=	$(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
86SYMDEVNM=		$(ROOTUSRSBIN)/devnm
87
88# This flag is being added only for SCO (x86) compatibility
89df.o := CFLAGS += $(iBCS2FLAG)
90
91CPPFLAGS += -D_LARGEFILE64_SOURCE
92%.xpg4.o := CPPFLAGS += -DXPG4
93$(XPG4) df ff fsck mount volcopy := LDLIBS += -lcmd
94$(SPPROG) :=	LDLIBS += -lcmd -lkstat
95
96$(ROOTETCMNTTAB) := FILEMODE = 444
97$(ROOTETCMNTTAB) := OWNER = root
98$(ROOTETCMNTTAB) := GROUP = root
99$(ROOTFSTYPE)	 := FILEMODE = 444
100
101# for messaging catalog
102#
103POFILE= fs.d.po
104POFILES1= $(PROG:%=%.po) $(ROOTFS_PROG:%=%.po) switchout.po fssnapsup.po
105POFILES2= $(I18NDIRS:%=%/%.po)
106POFILES_XPG4 = df.po.xpg4
107POFILES=  $(POFILES1) $(POFILES2) $(POFILES_XPG4)
108$(POFILES_XPG4) := CFLAGS += -DXPG4
109volcopy.po :=   XGETFLAGS += -a -x volcopy.xcl
110$(POFILES_XPG4) :=	XGETFLAGS += -a -x df.xcl
111$(DFPROG).po := XGETFLAGS += -a -x df.xcl
112
113%.po.xpg4:	%.c
114	$(COMPILE.cpp) $< > $<.i
115	$(BUILD.po)
116
117# build rule for xpg4 objects
118%.xpg4.o: %.c
119	$(COMPILE.c) -o $@ $<
120
121.KEEP_STATE:
122
123# This is too intense when building the whole world.
124# .PARALLEL:	$(SUBDIRS)
125
126all:		$(FSLIB) .WAIT $(SUBDIRS) .WAIT all_local
127
128_msg: $(I18NDIRS) $(POFILES1) $(POFILES_XPG4)
129	$(RM) $(POFILE)
130	cat $(POFILES) > $(POFILE)
131	$(RM) $(MSGDOMAIN)/$(POFILE)
132	cp $(POFILE) $(MSGDOMAIN)
133
134all_local:	$(PROG) $(ROOTFS_PROG) $(XPG4PROG) $(SPPROG) $(MNTTAB) $(FSTYPE)
135
136ff volcopy: deffs.o $$(@F).o
137		$(LINK.c) -o $@ $@.o deffs.o $(LDLIBS)
138		$(POST_PROCESS)
139
140df df.xpg4: deffs.o $(FSLIB) $$(@F).o
141		$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
142		$(POST_PROCESS)
143
144fsck: fsck.o deffs.o preenlib.o
145	$(LINK.c) -o $@ fsck.o deffs.o preenlib.o $(LDLIBS)
146	$(POST_PROCESS)
147
148mount: deffs.o mount.o $(FSLIB)
149	$(LINK.c) -o $@ mount.o deffs.o $(FSLIB) $(LDLIBS)
150	$(POST_PROCESS)
151
152umount: umount.o $(FSLIB)
153	$(LINK.c) -o $@ umount.o $(FSLIB) $(LDLIBS)
154	$(POST_PROCESS)
155
156$(SPPROG):	switchout.o deffs.o fssnapsup.o
157	$(LINK.c) -o $@ switchout.o deffs.o fssnapsup.o $(LDLIBS)
158	$(POST_PROCESS)
159
160install: $(FSLIB) .WAIT $(SUBDIRS) .WAIT install_local
161
162install_local:	all_local $(ROOTSBINPROG) $(ROOTUSRSBINF) $(ROOTUSRSBINCLRI) \
163		$(ROOTUSRSBINFF) $(ROOTETCMNTTAB) $(ROOTFSTYPE) \
164		$(ROOTXPG4PROG) $(SYMETC2SBIN) $(SYMETC2USRSBIN) \
165		$(SYMUSRBIN2USRSBIN) $(SYMDEVNM) $(ROOTUSRSBINLINKS)
166
167$(ROOTETC)/default/%:%
168		$(INS.file)
169
170# Links from /etc to /sbin such as /etc/mount -> ../sbin/mount
171$(SYMETC2SBIN):
172	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
173
174# Links from /etc to /usr/sbin such as /etc/clri -> ../usr/sbin/clri
175$(SYMETC2USRSBIN):
176	-$(RM) $@; $(SYMLINK) ../usr/sbin/$(@F) $@
177
178# Links from /usr/bin to /usr/sbin such as /usr/bin/df -> ../sbin/df
179$(SYMUSRBIN2USRSBIN):
180	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
181
182# Links from /usr/sbin to /sbin such as /usr/sbin/mount -> ../../sbin/mount
183$(ROOTUSRSBINLINKS):
184	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
185
186# Symlink from devnm to df in /usr/sbin
187$(SYMDEVNM):
188	-$(RM) $@; $(SYMLINK) ./df $@
189
190# Multiple names for switchout (clri, dcopy, fsdb, labelit, mkfs)
191$(ROOTUSRSBINCLRI):	$(ROOTUSRSBIN)/clri
192	-$(RM) $@; $(SYMLINK) ./clri $@
193
194$(MNTTAB):
195	touch $(MNTTAB)
196
197$(FSTYPE):
198	@$(RM) $@; $(ECHO) "LOCAL=ufs" >$@
199
200# Multiple names for ff (ncheck)
201$(ROOTUSRSBINFF):	$(ROOTUSRSBIN)/ff
202	-$(RM) $@; $(SYMLINK) ./ff $@
203
204clean: $(ALL_SUBDIRS) .WAIT clean_local
205
206clean_local:
207
208clobber: $(ALL_SUBDIRS) .WAIT clobber_local
209
210clobber_local:	clean_local
211	$(RM) $(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) $(FSTYPE) $(CLOBBERFILES)
212
213lint:
214
215$(ALL_SUBDIRS): FRC
216	@cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
217
218FRC:
219