xref: /illumos-gate/usr/src/cmd/fs.d/Makefile (revision 5de85994e399d09203c0a0ac1c559f968f1a21a7)
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 (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
22# Copyright (c) 2018, Joyent, Inc.
23# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
24#
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
37SPPROG=		clri
38MNTTAB=		mnttab
39DEFAULTFILES=	fs.dfl
40
41include ../Makefile.cmd
42
43SUBDIR1= bootfs lofs zfs
44SUBDIR2= dev fd pcfs nfs hsfs proc ctfs udfs ufs tmpfs \
45		autofs mntfs objfs sharefs smbclnt reparsed
46SUBDIRS= $(SUBDIR1) $(SUBDIR2)
47I18NDIRS= $(SUBDIR2)
48
49CLEANFILES +=	deffs.o df.o ff.o fsck.o fssnapsup.o \
50		mount.o preenlib.o switchout.o umount.o volcopy.o
51
52all:=		TARGET= all
53install:=	TARGET= install
54clean:=		TARGET= clean
55clobber:=	TARGET= clobber
56_msg:=          TARGET= catalog
57
58USRSBINF=	df clri fsck volcopy ff
59USRSBINCLRI=	dcopy fsdb fssnap labelit mkfs
60USRSBINFF=	ncheck
61
62ETC2SBIN=	mount umount
63ETC2USRSBIN=	clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
64USRBIN2USRSBIN=	df
65USRXPG4BIN2USRSBIN= df
66
67FSLIB=		fslib.o
68CLEANFILES +=	$(FSLIB)
69
70ROOTSBINPROG = $(ROOTFS_PROG:%=$(ROOTSBIN)/%)
71ROOTUSRSBINLINKS = $(ROOTFS_PROG:%=$(ROOTUSRSBIN)/%)
72
73ROOTUSRSBINF=		$(USRSBINF:%=$(ROOTUSRSBIN)/%)
74ROOTUSRSBINCLRI=	$(USRSBINCLRI:%=$(ROOTUSRSBIN)/%)
75ROOTUSRSBINFF=		$(USRSBINFF:%=$(ROOTUSRSBIN)/%)
76ROOTETCMNTTAB=		$(MNTTAB:%=$(ROOTETC)/%)
77SYMETC2SBIN	=	$(ETC2SBIN:%=$(ROOTETC)/%)
78SYMETC2USRSBIN	=	$(ETC2USRSBIN:%=$(ROOTETC)/%)
79SYMUSRBIN2USRSBIN=	$(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
80SYMUSRXPG4BIN2USRSBIN=	$(USRXPG4BIN2USRSBIN:%=$(ROOTXPG4BIN)/%)
81SYMDEVNM=		$(ROOTUSRSBIN)/devnm
82
83CSTD=	$(CSTD_GNU99)
84CPPFLAGS += -D_LARGEFILE64_SOURCE
85
86CERRWARN += -_gcc=-Wno-implicit-function-declaration
87CERRWARN += -_gcc=-Wno-parentheses
88CERRWARN += -_gcc=-Wno-unused-variable
89CERRWARN += $(CNOWARN_UNINIT)
90CERRWARN += -_gcc=-Wno-unused-function
91
92# not linted
93SMATCH=off
94
95$(DFPROG) :=	LDLIBS += -lcmdutils
96$(SPPROG) :=	LDLIBS += -lkstat
97
98$(ROOTETCMNTTAB) := FILEMODE = 444
99
100# for messaging catalog
101#
102POFILE= fs.d.po
103POFILES1= $(PROG:%=%.po) $(ROOTFS_PROG:%=%.po) switchout.po fssnapsup.po
104POFILES2= $(I18NDIRS:%=%/%.po)
105POFILES=  $(POFILES1) $(POFILES2)
106volcopy.po :=   XGETFLAGS += -a -x volcopy.xcl
107$(DFPROG).po := XGETFLAGS += -a -x df.xcl
108
109.KEEP_STATE:
110
111# This is too intense when building the whole world.
112# .PARALLEL:	$(SUBDIRS)
113
114all:		$(FSLIB) .WAIT $(SUBDIRS) .WAIT all_local
115
116_msg: $(I18NDIRS) $(POFILES1)
117	$(RM) $(POFILE)
118	cat $(POFILES) > $(POFILE)
119	$(RM) $(MSGDOMAIN)/$(POFILE)
120	cp $(POFILE) $(MSGDOMAIN)
121
122all_local:	$(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) \
123		$(DEFAULTFILES)
124
125ff volcopy: deffs.o $$(@F).o
126		$(LINK.c) -o $@ $@.o deffs.o $(LDLIBS)
127		$(POST_PROCESS)
128
129df: deffs.o $(FSLIB) $$(@F).o
130	$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
131	$(POST_PROCESS)
132
133fsck: fsck.o deffs.o preenlib.o
134	$(LINK.c) -o $@ fsck.o deffs.o preenlib.o $(LDLIBS)
135	$(POST_PROCESS)
136
137mount: deffs.o mount.o $(FSLIB)
138	$(LINK.c) -o $@ mount.o deffs.o $(FSLIB) $(LDLIBS)
139	$(POST_PROCESS)
140
141umount: umount.o $(FSLIB)
142	$(LINK.c) -o $@ umount.o $(FSLIB) $(LDLIBS)
143	$(POST_PROCESS)
144
145$(SPPROG):	switchout.o deffs.o fssnapsup.o
146	$(LINK.c) -o $@ switchout.o deffs.o fssnapsup.o $(LDLIBS) -ldiskmgt
147	$(POST_PROCESS)
148
149install: $(FSLIB) .WAIT $(SUBDIRS) .WAIT install_local
150
151install_local:	all_local $(ROOTSBINPROG) $(ROOTUSRSBINF) $(ROOTUSRSBINCLRI) \
152		$(ROOTUSRSBINFF) $(ROOTETCMNTTAB) $(ROOTETCDEFAULTFILES) \
153		$(SYMETC2SBIN) $(SYMETC2USRSBIN) \
154		$(SYMUSRBIN2USRSBIN) $(SYMUSRXPG4BIN2USRSBIN) $(SYMDEVNM) \
155		$(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/xpg4/bin to /usr/sbin such as /usr/xpg4/bin/df -> ../sbin/df
170$(SYMUSRXPG4BIN2USRSBIN):
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
196clean_local:
197	$(RM) $(CLEANFILES)
198
199clobber: $(SUBDIRS) .WAIT clobber_local
200clobber_local:	clean_local
201	$(RM) $(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) $(DEFAULTFILES) \
202	$(CLOBBERFILES)
203
204$(SUBDIRS): FRC
205	@cd $@; pwd; $(MAKE) $(TARGET)
206
207FRC:
208