xref: /illumos-gate/usr/src/cmd/fs.d/Makefile (revision 0e42dee69ed771bf604dd1789fca9d77b5bbe302)
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 2006 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= fd pcfs nfs hsfs proc ctfs udfs ufs tmpfs cachefs autofs mntfs objfs
49i386_SUBDIRS= xmemfs
50i386_I18NDIRS= xmemfs
51SUBDIRS= $(SUBDIR1) $(SUBDIR2) $($(MACH)_SUBDIRS)
52ALL_SUBDIRS= $(SUBDIR1) $(SUBDIR2) $(i386_SUBDIRS)
53I18NDIRS= $(SUBDIR2) $(i386_I18NDIRS)
54
55CLOBBERFILES += $(POFILES_XPG4)
56
57all:=		TARGET= all
58install:=	TARGET= install
59clean:=		TARGET= clean
60clobber:=	TARGET= clobber
61lint:=		TARGET= lint
62_msg:=          TARGET= catalog
63
64USRSBINF=	df clri fsck volcopy ff
65USRSBINCLRI=	dcopy fsdb fssnap labelit mkfs
66USRSBINFF=	ncheck
67
68ETC2SBIN=	mount umount
69ETC2USRSBIN=	clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
70USRBIN2USRSBIN=	df
71
72FSLIB=		fslib.o
73
74ROOTSBINPROG = $(ROOTFS_PROG:%=$(ROOTSBIN)/%)
75ROOTUSRSBINLINKS = $(ROOTFS_PROG:%=$(ROOTUSRSBIN)/%)
76
77ROOTUSRSBINF=		$(USRSBINF:%=$(ROOTUSRSBIN)/%)
78ROOTUSRSBINCLRI=	$(USRSBINCLRI:%=$(ROOTUSRSBIN)/%)
79ROOTUSRSBINFF=		$(USRSBINFF:%=$(ROOTUSRSBIN)/%)
80ROOTETCMNTTAB=		$(MNTTAB:%=$(ROOTETC)/%)
81SYMETC2SBIN	=	$(ETC2SBIN:%=$(ROOTETC)/%)
82SYMETC2USRSBIN	=	$(ETC2USRSBIN:%=$(ROOTETC)/%)
83SYMUSRBIN2USRSBIN=	$(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
84SYMDEVNM=		$(ROOTUSRSBIN)/devnm
85
86# This flag is being added only for SCO (x86) compatibility
87df.o := CFLAGS += $(iBCS2FLAG)
88
89CPPFLAGS += -D_LARGEFILE64_SOURCE
90%.xpg4.o := CPPFLAGS += -DXPG4
91$(XPG4) df ff fsck mount volcopy := LDLIBS += -lcmd
92$(SPPROG) :=	LDLIBS += -lcmd -lkstat
93
94$(ROOTETCMNTTAB) := FILEMODE = 444
95$(ROOTETCMNTTAB) := OWNER = root
96$(ROOTETCMNTTAB) := GROUP = root
97
98# for messaging catalog
99#
100POFILE= fs.d.po
101POFILES1= $(PROG:%=%.po) $(ROOTFS_PROG:%=%.po) switchout.po fssnapsup.po
102POFILES2= $(I18NDIRS:%=%/%.po)
103POFILES_XPG4 = df.po.xpg4
104POFILES=  $(POFILES1) $(POFILES2) $(POFILES_XPG4)
105$(POFILES_XPG4) := CFLAGS += -DXPG4
106volcopy.po :=   XGETFLAGS += -a -x volcopy.xcl
107$(POFILES_XPG4) :=	XGETFLAGS += -a -x df.xcl
108$(DFPROG).po := XGETFLAGS += -a -x df.xcl
109
110%.po.xpg4:	%.c
111	$(COMPILE.cpp) $< > $<.i
112	$(BUILD.po)
113
114# build rule for xpg4 objects
115%.xpg4.o: %.c
116	$(COMPILE.c) -o $@ $<
117
118.KEEP_STATE:
119
120# This is too intense when building the whole world.
121# .PARALLEL:	$(SUBDIRS)
122
123all:		$(FSLIB) .WAIT $(SUBDIRS) .WAIT all_local
124
125_msg: $(I18NDIRS) $(POFILES1) $(POFILES_XPG4)
126	$(RM) $(POFILE)
127	cat $(POFILES) > $(POFILE)
128	$(RM) $(MSGDOMAIN)/$(POFILE)
129	cp $(POFILE) $(MSGDOMAIN)
130
131all_local:	$(PROG) $(ROOTFS_PROG) $(XPG4PROG) $(SPPROG) $(MNTTAB) \
132		$(DEFAULTFILES)
133
134ff volcopy: deffs.o $$(@F).o
135		$(LINK.c) -o $@ $@.o deffs.o $(LDLIBS)
136		$(POST_PROCESS)
137
138df df.xpg4: deffs.o $(FSLIB) $$(@F).o
139		$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
140		$(POST_PROCESS)
141
142fsck: fsck.o deffs.o preenlib.o
143	$(LINK.c) -o $@ fsck.o deffs.o preenlib.o $(LDLIBS)
144	$(POST_PROCESS)
145
146mount: deffs.o mount.o $(FSLIB)
147	$(LINK.c) -o $@ mount.o deffs.o $(FSLIB) $(LDLIBS)
148	$(POST_PROCESS)
149
150umount: umount.o $(FSLIB)
151	$(LINK.c) -o $@ umount.o $(FSLIB) $(LDLIBS)
152	$(POST_PROCESS)
153
154$(SPPROG):	switchout.o deffs.o fssnapsup.o
155	$(LINK.c) -o $@ switchout.o deffs.o fssnapsup.o $(LDLIBS) -ldiskmgt
156	$(POST_PROCESS)
157
158install: $(FSLIB) .WAIT $(SUBDIRS) .WAIT install_local
159
160install_local:	all_local $(ROOTSBINPROG) $(ROOTUSRSBINF) $(ROOTUSRSBINCLRI) \
161		$(ROOTUSRSBINFF) $(ROOTETCMNTTAB) $(ROOTETCDEFAULTFILES) \
162		$(ROOTXPG4PROG) $(SYMETC2SBIN) $(SYMETC2USRSBIN) \
163		$(SYMUSRBIN2USRSBIN) $(SYMDEVNM) $(ROOTUSRSBINLINKS)
164
165# Links from /etc to /sbin such as /etc/mount -> ../sbin/mount
166$(SYMETC2SBIN):
167	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
168
169# Links from /etc to /usr/sbin such as /etc/clri -> ../usr/sbin/clri
170$(SYMETC2USRSBIN):
171	-$(RM) $@; $(SYMLINK) ../usr/sbin/$(@F) $@
172
173# Links from /usr/bin to /usr/sbin such as /usr/bin/df -> ../sbin/df
174$(SYMUSRBIN2USRSBIN):
175	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
176
177# Links from /usr/sbin to /sbin such as /usr/sbin/mount -> ../../sbin/mount
178$(ROOTUSRSBINLINKS):
179	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
180
181# Symlink from devnm to df in /usr/sbin
182$(SYMDEVNM):
183	-$(RM) $@; $(SYMLINK) ./df $@
184
185# Multiple names for switchout (clri, dcopy, fsdb, labelit, mkfs)
186$(ROOTUSRSBINCLRI):	$(ROOTUSRSBIN)/clri
187	-$(RM) $@; $(SYMLINK) ./clri $@
188
189$(MNTTAB):
190	touch $(MNTTAB)
191
192fs.dfl:
193	$(RM) $@; $(ECHO) "LOCAL=ufs" >$@
194
195# Multiple names for ff (ncheck)
196$(ROOTUSRSBINFF):	$(ROOTUSRSBIN)/ff
197	-$(RM) $@; $(SYMLINK) ./ff $@
198
199clean: $(ALL_SUBDIRS) .WAIT clean_local
200
201clean_local:
202
203clobber: $(ALL_SUBDIRS) .WAIT clobber_local
204
205clobber_local:	clean_local
206	$(RM) $(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) $(DEFAULTFILES) \
207	$(CLOBBERFILES)
208
209lint:
210
211$(ALL_SUBDIRS): FRC
212	@cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
213
214FRC:
215