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