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