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