17c478bdstevel@tonic-gate#
27c478bdstevel@tonic-gate# CDDL HEADER START
37c478bdstevel@tonic-gate#
47c478bdstevel@tonic-gate# The contents of this file are subject to the terms of the
50e42deeartem# Common Development and Distribution License (the "License").
60e42deeartem# You may not use this file except in compliance with the License.
77c478bdstevel@tonic-gate#
87c478bdstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bdstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
107c478bdstevel@tonic-gate# See the License for the specific language governing permissions
117c478bdstevel@tonic-gate# and limitations under the License.
127c478bdstevel@tonic-gate#
137c478bdstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
147c478bdstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bdstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
167c478bdstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
177c478bdstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
187c478bdstevel@tonic-gate#
197c478bdstevel@tonic-gate# CDDL HEADER END
207c478bdstevel@tonic-gate#
21cc22b13Rich Burridge# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
225661bb7John Levon# Copyright (c) 2018, Joyent, Inc.
23bd93c05Alexander Eremin# Copyright 2015 Nexenta Systems, Inc. All rights reserved.
247c478bdstevel@tonic-gate#
257c478bdstevel@tonic-gate
267c478bdstevel@tonic-gate# The filesystem independent utilities clri, fsdb, dcopy, labelit, and mkfs
277c478bdstevel@tonic-gate# are all built from the source file switchout.c. They are all then links
287c478bdstevel@tonic-gate# to the same object. This is accomplished by:
297c478bdstevel@tonic-gate#	1) building clri from switchout.c (had to choose one)
307c478bdstevel@tonic-gate#	2) installing it in the target directory
317c478bdstevel@tonic-gate#	3) linking the others to clri.
327c478bdstevel@tonic-gate# In a similar manner, ncheck is linked to ff.
337c478bdstevel@tonic-gate
347c478bdstevel@tonic-gateDFPROG=		df
357c478bdstevel@tonic-gatePROG=		$(DFPROG) fsck volcopy ff
367c478bdstevel@tonic-gateROOTFS_PROG=	mount umount
377c478bdstevel@tonic-gateSPPROG=		clri
387c478bdstevel@tonic-gateMNTTAB=		mnttab
39a787240meemDEFAULTFILES=	fs.dfl
407c478bdstevel@tonic-gate
417c478bdstevel@tonic-gateinclude ../Makefile.cmd
427c478bdstevel@tonic-gate
4376ca3cbRobert MustacchiSUBDIR1= bootfs lofs zfs
44bd93c05Alexander EreminSUBDIR2= dev fd pcfs nfs hsfs proc ctfs udfs ufs tmpfs \
457a286c4Dai Ngo		autofs mntfs objfs sharefs smbclnt reparsed
464fceebdblakejSUBDIRS= $(SUBDIR1) $(SUBDIR2)
474fceebdblakejI18NDIRS= $(SUBDIR2)
487c478bdstevel@tonic-gate
49b6805bfGordon RossCLEANFILES +=	deffs.o df.o ff.o fsck.o fssnapsup.o \
50b6805bfGordon Ross		mount.o preenlib.o switchout.o umount.o volcopy.o
517c478bdstevel@tonic-gate
527c478bdstevel@tonic-gateall:=		TARGET= all
537c478bdstevel@tonic-gateinstall:=	TARGET= install
547c478bdstevel@tonic-gateclean:=		TARGET= clean
557c478bdstevel@tonic-gateclobber:=	TARGET= clobber
567c478bdstevel@tonic-gatelint:=		TARGET= lint
577c478bdstevel@tonic-gate_msg:=          TARGET= catalog
587c478bdstevel@tonic-gate
597c478bdstevel@tonic-gateUSRSBINF=	df clri fsck volcopy ff
607c478bdstevel@tonic-gateUSRSBINCLRI=	dcopy fsdb fssnap labelit mkfs
617c478bdstevel@tonic-gateUSRSBINFF=	ncheck
627c478bdstevel@tonic-gate
637c478bdstevel@tonic-gateETC2SBIN=	mount umount
647c478bdstevel@tonic-gateETC2USRSBIN=	clri fsdb mkfs fsck labelit dcopy volcopy ff ncheck
657c478bdstevel@tonic-gateUSRBIN2USRSBIN=	df
6690a1a13Paul B. HensonUSRXPG4BIN2USRSBIN= df
677c478bdstevel@tonic-gate
687c478bdstevel@tonic-gateFSLIB=		fslib.o
697c478bdstevel@tonic-gate
707c478bdstevel@tonic-gateROOTSBINPROG = $(ROOTFS_PROG:%=$(ROOTSBIN)/%)
717c478bdstevel@tonic-gateROOTUSRSBINLINKS = $(ROOTFS_PROG:%=$(ROOTUSRSBIN)/%)
727c478bdstevel@tonic-gate
737c478bdstevel@tonic-gateROOTUSRSBINF=		$(USRSBINF:%=$(ROOTUSRSBIN)/%)
747c478bdstevel@tonic-gateROOTUSRSBINCLRI=	$(USRSBINCLRI:%=$(ROOTUSRSBIN)/%)
757c478bdstevel@tonic-gateROOTUSRSBINFF=		$(USRSBINFF:%=$(ROOTUSRSBIN)/%)
767c478bdstevel@tonic-gateROOTETCMNTTAB=		$(MNTTAB:%=$(ROOTETC)/%)
777c478bdstevel@tonic-gateSYMETC2SBIN	=	$(ETC2SBIN:%=$(ROOTETC)/%)
787c478bdstevel@tonic-gateSYMETC2USRSBIN	=	$(ETC2USRSBIN:%=$(ROOTETC)/%)
797c478bdstevel@tonic-gateSYMUSRBIN2USRSBIN=	$(USRBIN2USRSBIN:%=$(ROOTBIN)/%)
8090a1a13Paul B. HensonSYMUSRXPG4BIN2USRSBIN=	$(USRXPG4BIN2USRSBIN:%=$(ROOTXPG4BIN)/%)
817c478bdstevel@tonic-gateSYMDEVNM=		$(ROOTUSRSBIN)/devnm
827c478bdstevel@tonic-gate
837c478bdstevel@tonic-gateCPPFLAGS += -D_LARGEFILE64_SOURCE
847014882Richard Lowe
857014882Richard LoweCERRWARN += -_gcc=-Wno-implicit-function-declaration
867014882Richard LoweCERRWARN += -_gcc=-Wno-parentheses
877014882Richard LoweCERRWARN += -_gcc=-Wno-unused-variable
88d3b5f56John LevonCERRWARN += $(CNOWARN_UNINIT)
897014882Richard LoweCERRWARN += -_gcc=-Wno-unused-function
907014882Richard Lowe
915661bb7John Levon# not linted
925661bb7John LevonSMATCH=off
935661bb7John Levon
940a05512Jason King$(DFPROG) :=	LDLIBS += -lcmdutils
9506e1a71raf$(SPPROG) :=	LDLIBS += -lkstat
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gate$(ROOTETCMNTTAB) := FILEMODE = 444
987c478bdstevel@tonic-gate
997c478bdstevel@tonic-gate# for messaging catalog
1007c478bdstevel@tonic-gate#
1017c478bdstevel@tonic-gatePOFILE= fs.d.po
1027c478bdstevel@tonic-gatePOFILES1= $(PROG:%=%.po) $(ROOTFS_PROG:%=%.po) switchout.po fssnapsup.po
1037c478bdstevel@tonic-gatePOFILES2= $(I18NDIRS:%=%/%.po)
10490a1a13Paul B. HensonPOFILES=  $(POFILES1) $(POFILES2)
1057c478bdstevel@tonic-gatevolcopy.po :=   XGETFLAGS += -a -x volcopy.xcl
1067c478bdstevel@tonic-gate$(DFPROG).po := XGETFLAGS += -a -x df.xcl
1077c478bdstevel@tonic-gate
1087c478bdstevel@tonic-gate.KEEP_STATE:
1097c478bdstevel@tonic-gate
1107c478bdstevel@tonic-gate# This is too intense when building the whole world.
1117c478bdstevel@tonic-gate# .PARALLEL:	$(SUBDIRS)
1127c478bdstevel@tonic-gate
1137c478bdstevel@tonic-gateall:		$(FSLIB) .WAIT $(SUBDIRS) .WAIT all_local
1147c478bdstevel@tonic-gate
11590a1a13Paul B. Henson_msg: $(I18NDIRS) $(POFILES1)
1167c478bdstevel@tonic-gate	$(RM) $(POFILE)
1177c478bdstevel@tonic-gate	cat $(POFILES) > $(POFILE)
1187c478bdstevel@tonic-gate	$(RM) $(MSGDOMAIN)/$(POFILE)
1197c478bdstevel@tonic-gate	cp $(POFILE) $(MSGDOMAIN)
1207c478bdstevel@tonic-gate
12190a1a13Paul B. Hensonall_local:	$(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) \
122a787240meem		$(DEFAULTFILES)
1237c478bdstevel@tonic-gate
1247c478bdstevel@tonic-gateff volcopy: deffs.o $$(@F).o
1257c478bdstevel@tonic-gate		$(LINK.c) -o $@ $@.o deffs.o $(LDLIBS)
1267c478bdstevel@tonic-gate		$(POST_PROCESS)
1277c478bdstevel@tonic-gate
12890a1a13Paul B. Hensondf: deffs.o $(FSLIB) $$(@F).o
12990a1a13Paul B. Henson	$(LINK.c) -o $@ $@.o deffs.o $(FSLIB) $(LDLIBS)
13090a1a13Paul B. Henson	$(POST_PROCESS)
1317c478bdstevel@tonic-gate
1327c478bdstevel@tonic-gatefsck: fsck.o deffs.o preenlib.o
1337c478bdstevel@tonic-gate	$(LINK.c) -o $@ fsck.o deffs.o preenlib.o $(LDLIBS)
1347c478bdstevel@tonic-gate	$(POST_PROCESS)
1357c478bdstevel@tonic-gate
1367c478bdstevel@tonic-gatemount: deffs.o mount.o $(FSLIB)
1377c478bdstevel@tonic-gate	$(LINK.c) -o $@ mount.o deffs.o $(FSLIB) $(LDLIBS)
1387c478bdstevel@tonic-gate	$(POST_PROCESS)
1397c478bdstevel@tonic-gate
1407c478bdstevel@tonic-gateumount: umount.o $(FSLIB)
1417c478bdstevel@tonic-gate	$(LINK.c) -o $@ umount.o $(FSLIB) $(LDLIBS)
1427c478bdstevel@tonic-gate	$(POST_PROCESS)
1437c478bdstevel@tonic-gate
1447c478bdstevel@tonic-gate$(SPPROG):	switchout.o deffs.o fssnapsup.o
1453e1bd7asjelinek	$(LINK.c) -o $@ switchout.o deffs.o fssnapsup.o $(LDLIBS) -ldiskmgt
1467c478bdstevel@tonic-gate	$(POST_PROCESS)
1477c478bdstevel@tonic-gate
1487c478bdstevel@tonic-gateinstall: $(FSLIB) .WAIT $(SUBDIRS) .WAIT install_local
1497c478bdstevel@tonic-gate
1507c478bdstevel@tonic-gateinstall_local:	all_local $(ROOTSBINPROG) $(ROOTUSRSBINF) $(ROOTUSRSBINCLRI) \
151a787240meem		$(ROOTUSRSBINFF) $(ROOTETCMNTTAB) $(ROOTETCDEFAULTFILES) \
15290a1a13Paul B. Henson		$(SYMETC2SBIN) $(SYMETC2USRSBIN) \
15390a1a13Paul B. Henson		$(SYMUSRBIN2USRSBIN) $(SYMUSRXPG4BIN2USRSBIN) $(SYMDEVNM) \
15490a1a13Paul B. Henson		$(ROOTUSRSBINLINKS)
1557c478bdstevel@tonic-gate
1567c478bdstevel@tonic-gate# Links from /etc to /sbin such as /etc/mount -> ../sbin/mount
1577c478bdstevel@tonic-gate$(SYMETC2SBIN):
1587c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
1597c478bdstevel@tonic-gate
1607c478bdstevel@tonic-gate# Links from /etc to /usr/sbin such as /etc/clri -> ../usr/sbin/clri
1617c478bdstevel@tonic-gate$(SYMETC2USRSBIN):
1627c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ../usr/sbin/$(@F) $@
1637c478bdstevel@tonic-gate
1647c478bdstevel@tonic-gate# Links from /usr/bin to /usr/sbin such as /usr/bin/df -> ../sbin/df
1657c478bdstevel@tonic-gate$(SYMUSRBIN2USRSBIN):
1667c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ../sbin/$(@F) $@
1677c478bdstevel@tonic-gate
16890a1a13Paul B. Henson# Links from /usr/xpg4/bin to /usr/sbin such as /usr/xpg4/bin/df -> ../sbin/df
16990a1a13Paul B. Henson$(SYMUSRXPG4BIN2USRSBIN):
17090a1a13Paul B. Henson	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
17190a1a13Paul B. Henson
1727c478bdstevel@tonic-gate# Links from /usr/sbin to /sbin such as /usr/sbin/mount -> ../../sbin/mount
1737c478bdstevel@tonic-gate$(ROOTUSRSBINLINKS):
1747c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ../../sbin/$(@F) $@
1757c478bdstevel@tonic-gate
1767c478bdstevel@tonic-gate# Symlink from devnm to df in /usr/sbin
1777c478bdstevel@tonic-gate$(SYMDEVNM):
1787c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ./df $@
1797c478bdstevel@tonic-gate
1807c478bdstevel@tonic-gate# Multiple names for switchout (clri, dcopy, fsdb, labelit, mkfs)
1817c478bdstevel@tonic-gate$(ROOTUSRSBINCLRI):	$(ROOTUSRSBIN)/clri
1827c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ./clri $@
1837c478bdstevel@tonic-gate
1847c478bdstevel@tonic-gate$(MNTTAB):
1857c478bdstevel@tonic-gate	touch $(MNTTAB)
1867c478bdstevel@tonic-gate
187a787240meemfs.dfl:
188a787240meem	$(RM) $@; $(ECHO) "LOCAL=ufs" >$@
1897c478bdstevel@tonic-gate
1907c478bdstevel@tonic-gate# Multiple names for ff (ncheck)
1917c478bdstevel@tonic-gate$(ROOTUSRSBINFF):	$(ROOTUSRSBIN)/ff
1927c478bdstevel@tonic-gate	-$(RM) $@; $(SYMLINK) ./ff $@
1937c478bdstevel@tonic-gate
1944fceebdblakejclean: $(SUBDIRS) .WAIT clean_local
1957c478bdstevel@tonic-gateclean_local:
196b6805bfGordon Ross	$(RM) $(CLEANFILES)
1977c478bdstevel@tonic-gate
1984fceebdblakejclobber: $(SUBDIRS) .WAIT clobber_local
1997c478bdstevel@tonic-gateclobber_local:	clean_local
200a787240meem	$(RM) $(PROG) $(ROOTFS_PROG) $(SPPROG) $(MNTTAB) $(DEFAULTFILES) \
201a787240meem	$(CLOBBERFILES)
2027c478bdstevel@tonic-gate
2037c478bdstevel@tonic-gatelint:
2047c478bdstevel@tonic-gate
2054fceebdblakej$(SUBDIRS): FRC
2067c478bdstevel@tonic-gate	@cd $@; pwd; $(MAKE) $(MFLAGS) $(TARGET)
2077c478bdstevel@tonic-gate
2087c478bdstevel@tonic-gateFRC:
209