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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  23 # Copyright 2012 Nexenta Systems, Inc. All rights reserved.
  24 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
  25 #
  26 # include global definitions
  27 include ../Makefile.master
  28 
  29 #
  30 # List of architectures to build as part of the standard build.
  31 #
  32 # Some of these architectures are built in parallel (see i386_PARALLEL and
  33 # sparc_PARALLEL). This requires building some parts first before parallel build
  34 # can start. Platform make files know what should be built as a prerequisite for
  35 # the parallel build to work. The i386_PREREQ and sparc_PREREQ variables tell
  36 # which platform directory to enter to start making prerequisite dependencies.
  37 #
  38 sparc_ARCHITECTURES = sun4v sun4u sparc
  39 
  40 i386_ARCHITECTURES = i86pc i86xpv intel
  41 
  42 #
  43 # For i386 all architectures can be compiled in parallel.
  44 #
  45 # intel/Makefile knows how to build prerequisites needed for parallel build.
  46 #
  47 i386_PREREQ = intel
  48 i386_PARALLEL = $(i386_ARCHITECTURES)
  49 
  50 #
  51 # For sparc all architectures can be compiled in parallel.
  52 #
  53 # sun4/Makefile knows how to build prerequisites needed for parallel build.
  54 # can start.
  55 #
  56 sparc_PREREQ = sun4
  57 sparc_PARALLEL = $(sparc_ARCHITECTURES)
  58 
  59 #
  60 # Platforms defined in $(MACH)_PARALLEL are built in parallel. DUMMY is placed
  61 # at the end in case $(MACH)_PARALLEL is empty to prevent everything going in
  62 # parallel.
  63 #
  64 .PARALLEL: $($(MACH)_PARALLEL) DUMMY
  65 
  66 #
  67 # For build prerequisites we use a special target which is constructed by adding
  68 # '.prereq' suffix to the $(MACH)_PREREQ.
  69 #
  70 PREREQ_TARGET = $($(MACH)_PREREQ:%=%.prereq)
  71 
  72 
  73 def             :=      TARGET= def
  74 all             :=      TARGET= all
  75 install         :=      TARGET= install
  76 install_h       :=      TARGET= install_h
  77 clean           :=      TARGET= clean
  78 clobber         :=      TARGET= clobber
  79 clobber_h       :=      TARGET= clobber
  80 lint            :=      TARGET= lint
  81 clean.lint      :=      TARGET= clean.lint
  82 check           :=      TARGET= check
  83 modlist         :=      TARGET= modlist
  84 modlist         :=      NO_STATE= -K $$MODSTATE$$$$
  85 
  86 .KEEP_STATE:
  87 
  88 def all lint: all_h $(PMTMO_FILE) $($(MACH)_ARCHITECTURES)
  89 
  90 install: all_h install_dirs $(PMTMO_FILE) $($(MACH)_ARCHITECTURES)
  91 
  92 install_dirs:
  93         @cd ..; pwd; $(MAKE) rootdirs
  94         @pwd
  95 
  96 #
  97 # Rule to build prerequisites. The left part of the pattern will match
  98 # PREREQ_TARGET.
  99 #
 100 # The location of the Makefile is determined by strippinng '.prereq' suffix from
 101 # the target name. We add '.prereq' suffix to the target passed to the child
 102 # Makefile so that it can distinguish prerequisite build from the regular one.
 103 #
 104 #
 105 %.prereq:
 106         @cd $(@:%.prereq=%); pwd; $(MAKE) $(NO_STATE) $(TARGET).prereq
 107 
 108 #
 109 # Rule to build architecture files. Build all required prerequisites and then
 110 # build the rest (potentially in parallel).
 111 #
 112 $($(MACH)_ARCHITECTURES): $(PREREQ_TARGET) FRC
 113         @cd $@; pwd; $(MAKE) $(NO_STATE) $(TARGET)
 114 
 115 $(PMTMO_FILE) pmtmo_file: $(PATCH_MAKEUP_TABLE)
 116         @if [ -z "$(PATCH_MAKEUP_TABLE)" ] ; then \
 117                 echo 'ERROR: $$(PATCH_MAKEUP_TABLE) not set' \
 118                     'in environment' >&2 ; \
 119                 exit 1 ; \
 120         fi
 121         RELEASE="$(RELEASE)" MACH="$(MACH)" \
 122             $(CTFCVTPTBL) -o $(PMTMO_FILE) $(PATCH_MAKEUP_TABLE)
 123 
 124 #
 125 # The following is the list of directories which contain Makefiles with
 126 # targets to install header file. The machine independent headers are
 127 # installed by invoking the Makefile in the directory containing the
 128 # header files. Machine and architecture dependent headers are installed
 129 # by invoking the main makefile for that architecture/machine which,
 130 # in turn, is responsible for invoking the Makefiles which install headers.
 131 # It is done this way so as not to assume that all of the header files in
 132 # the architecture/machine dependent subdirectories are in completely
 133 # isomorphic locations.
 134 #
 135 COMMON_HDRDIRS= common/avs \
 136                 common/c2 \
 137                 common/des \
 138                 common/fs \
 139                 common/gssapi \
 140                 common/idmap \
 141                 common/klm \
 142                 common/inet \
 143                 common/inet/ipf/netinet \
 144                 common/inet/kssl \
 145                 common/inet/nca \
 146                 common/inet/sockmods/netpacket \
 147                 common/io/bpf/net \
 148                 common/io/fibre-channel/fca/qlc \
 149                 common/io/lvm/md \
 150                 common/ipp \
 151                 common/net \
 152                 common/netinet \
 153                 common/nfs \
 154                 common/rpc \
 155                 common/rpcsvc \
 156                 common/sharefs \
 157                 common/smb \
 158                 common/smbsrv \
 159                 common/sys \
 160                 common/vm
 161 
 162 
 163 #
 164 # Subset of COMMON_HDRDIRS in which at least one header is generated
 165 # at runtime (e.g., rpcgen), and in which "make clean" should run.
 166 # Other directories should be included here, but do not yet have the
 167 # necessary Makefile support (make clean).  See 6414855.
 168 #
 169 DYNHDRDIRS =    common/avs \
 170                 common/gssapi \
 171                 common/idmap \
 172                 common/io/fibre-channel/fca/qlc \
 173                 common/io/lvm/md \
 174                 common/klm \
 175                 common/rpc \
 176                 common/rpcsvc \
 177                 common/sys
 178 
 179 sparc_HDRDIRS= sun/sys
 180 i386_HDRDIRS= i86pc/vm i86xpv/vm
 181 
 182 HDRDIRS= $(COMMON_HDRDIRS) $($(MACH)_HDRDIRS)
 183 install_h check: $(HDRDIRS) $($(MACH)_ARCHITECTURES)
 184 
 185 $(HDRDIRS): FRC
 186         @cd $@; pwd; $(MAKE) $(TARGET)
 187 
 188 # ensures that headers made by rpcgen and others are available in uts source
 189 # for kernel builds to reference without building install_h
 190 #
 191 all_h: FRC
 192         @cd common/sys; pwd; $(MAKE) $@
 193         @cd common/rpc; pwd; $(MAKE) $@
 194         @cd common/rpcsvc; pwd; $(MAKE) $@
 195         @cd common/gssapi; pwd; $(MAKE) $@
 196         @cd common/idmap; pwd; $(MAKE) $@
 197         @cd common/klm; pwd; $(MAKE) $@
 198 
 199 clean clobber: $($(MACH)_ARCHITECTURES) $(DYNHDRDIRS)
 200         @if [ '$(PATCH_BUILD)' != '#' ] ; then \
 201                 echo $(RM) $(PMTMO_FILE) ; \
 202                 $(RM) $(PMTMO_FILE) ; \
 203         fi
 204 
 205 # testing convenience
 206 clobber_h: $(DYNHDRDIRS)
 207 
 208 clean.lint modlist: $($(MACH)_ARCHITECTURES)
 209 
 210 #
 211 # Cross-reference customization: build a cross-reference over all of
 212 # the supported architectures.  Although there's no correct way to set
 213 # the include path (since we don't know what architecture is the one
 214 # the user will be interested in), it's historically been set to
 215 # mirror the $(XRDIRS) list, and that works kinda sorta okay.
 216 #
 217 XRDIRS = $(sparc_ARCHITECTURES) $(i386_ARCHITECTURES) sun4 sfmmu        \
 218         sun common
 219 
 220 XRINCDIRS = $(XRDIRS)
 221 
 222 cscope.out tags: FRC
 223         $(XREF) -x $@
 224 
 225 FRC: