Merge commit 'cb41b9c565d4eec9e1f06e24d429696f59f2f07d'
[unleashed.git] / usr / src / uts / Makefile.targ
blobd5e6377f82357ea71daf8abe94c8f5f78456e80b
2 # CDDL HEADER START
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.
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.
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]
19 # CDDL HEADER END
22 # Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 # Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
26 #       This Makefiles contains the common targets and definitions for
27 #       all kernels. It is to be included in the Makefiles for specific
28 #       implementation architectures and processor architecture dependent
29 #       modules: i.e.: all driving kernel Makefiles.
33 #       Partially link .o files to generate the kmod. The fake dependency
34 #       on modstubs simplifies things...
36 $(BINARY):              $(OBJECTS)
37         $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS)
38         $(CTFMERGE_MODULE)
39         $(POST_PROCESS)
42 #       This target checks each kmod for undefined entry points. It does not
43 #       modify the kmod in any way.
45 $(MODULE).check:        FRC
46         @BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ
48 $(MODULE).check.targ:   $(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
49         $(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
52 # Since assym.h is a derived file, the dependency must be explicit for
53 # all files including this file. (This is only actually required in the
54 # instance when the .nse_depinfo file does not exist.) The actual lists are
55 # defined in */Makefile.files.
57 $(ASSYM_DEPS:%=$(OBJS_DIR)/%):  $(DSF_DIR)/$(OBJS_DIR)/assym.h
60 #       Everybody need to know how to create a modstubs.o built with the
61 #       appropriate flags and located in the appropriate location.
63 $(MODSTUBS_O):  $(MODSTUBS)
64         $(COMPILE.s) -o $@ $(MODSTUBS)
67 # Build the source file which contains the kernel's utsname,
68 # with release, version and machine set as follows:
70 #       version: contents of $(PATCHID) (Spaces replaced by '_')
71 #       machine: contents of $(UNAME_M)
73 # Build environment information is only contained in the comment section.
76 $(OBJS_DIR)/vers.o: $(OBJECTS)
77         $(COMPILE.c) \
78             -DUTS_VERSION=\"`$(ECHO) $(PATCHID) | sed -e 's/ /_/g'`\" \
79             -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRCTOP)/kernel/os/vers.c
80         $(CTFCONVERT_O)
81         $(POST_PROCESS_O)
84 #       Installation targets and rules:
86 $(ROOT_MOD_DIR) $(USR_MOD_DIR):
87         -$(INS.dir)
89 $(ROOT_MOD_DIRS):       $(ROOT_MOD_DIR)
90         -$(INS.dir)
92 $(USR_MOD_DIRS):        $(USR_MOD_DIR)
93         -$(INS.dir)
95 $(ROOT_MOD_DIR)/%:      $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
96         $(INS.file)
98 $(ROOT_CPU_DIR)/%:      $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
99         $(INS.file)
101 $(ROOT_DRV_DIR)/%:      $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
102         $(INS.file)
104 $(ROOT_DTRACE_DIR)/%:   $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
105         $(INS.file)
107 $(ROOT_EXEC_DIR)/%:     $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
108         $(INS.file)
110 $(ROOT_FS_DIR)/%:       $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
111         $(INS.file)
113 $(ROOT_SCHED_DIR)/%:    $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
114         $(INS.file)
116 $(ROOT_SOCK_DIR)/%:     $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
117         $(INS.file)
119 $(ROOT_STRMOD_DIR)/%:   $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
120         $(INS.file)
122 $(ROOT_IPP_DIR)/%:      $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
123         $(INS.file)
125 $(ROOT_SYS_DIR)/%:      $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
126         $(INS.file)
128 $(ROOT_MISC_DIR)/%:     $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
129         $(INS.file)
131 $(ROOT_DACF_DIR)/%:     $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
132         $(INS.file)
134 $(ROOT_BRAND_DIR)/%:    $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
135         $(INS.file)
137 $(ROOT_CRYPTO_DIR)/%:   $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
138         $(INS.file)
140 $(ROOT_KGSS_DIR)/%:     $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
141         $(INS.file)
143 $(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
144         $(INS.file)
146 $(ROOT_PMCS_FW_DIR)/%:  $(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
147         $(INS.file)
149 $(ROOT_QLC_FW_DIR)/%:   $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
150         $(INS.file)
152 $(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
153         $(INS.file)
155 $(ROOT_MACH_DIR)/%:     $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
156         $(INS.file)
158 $(ROOT_FONT_DIR)/%:     $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
159         $(INS.file)
161 $(ROOT_MAC_DIR)/%:      $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
162         $(INS.file)
164 $(USR_DRV_DIR)/%:       $(OBJS_DIR)/% $(USR_DRV_DIR) FRC
165         $(INS.file)
167 $(USR_EXEC_DIR)/%:      $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
168         $(INS.file)
170 $(USR_FS_DIR)/%:        $(OBJS_DIR)/% $(USR_FS_DIR) FRC
171         $(INS.file)
173 $(USR_SCHED_DIR)/%:     $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
174         $(INS.file)
176 $(USR_SOCK_DIR)/%:      $(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
177         $(INS.file)
179 $(USR_STRMOD_DIR)/%:    $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
180         $(INS.file)
182 $(USR_SYS_DIR)/%:       $(OBJS_DIR)/% $(USR_SYS_DIR) FRC
183         $(INS.file)
185 $(USR_MISC_DIR)/%:      $(OBJS_DIR)/% $(USR_MISC_DIR) FRC
186         $(INS.file)
188 $(USR_DACF_DIR)/%:      $(OBJS_DIR)/% $(USR_DACF_DIR) FRC
189         $(INS.file)
191 $(USR_PCBE_DIR)/%:      $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
192         $(INS.file)
194 $(USR_DTRACE_DIR)/%:    $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
195         $(INS.file)
197 $(USR_BRAND_DIR)/%:     $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
198         $(INS.file)
200 $(ROOT_KICONV_DIR)/%:   $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
201         $(INS.file)
203 $(ROOT_FIRMWARE_DIR)/$(MODULE):
204         $(INS.dir)
206 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)
208 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
209         $(INS.file)
211 include $(SRC)/Makefile.psm.targ
214 #       Target for 64b modules
216 $(ROOT_KERN_DIR_64):
217         -$(INS.dir)
219 $(ROOT_KERN_DIR_64)/%:  $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
220         $(INS.file)
222 %/$(SUBDIR64):          %
223         -$(INS.dir)
226 #       Targets for '.conf' file installation.
228 $(ROOT_CONFFILE):       $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%)
229         $(INS.conffile)
232 #       Targets for creating links between common platforms. ROOT_PLAT_LINKS
233 #       are are the /platform level while ROOT_PLAT_LINKS_2 are one level
234 #       down (/platform/`uname -i`/{lib|sbin|kernel}.
236 $(ROOT_PLAT_LINKS):
237         $(INS.slink1)
239 $(ROOT_PLAT_LINKS_2):
240         $(INS.slink2)
242 $(USR_PLAT_LINKS):
243         $(INS.slink1)
245 $(USR_PLAT_LINKS_2):
246         $(INS.slink2)
249 # multiple builds support
251 def $(DEF_DEPS)                 := TARGET = def
252 all $(ALL_DEPS)                 := TARGET = all
253 clean $(CLEAN_DEPS)             := TARGET = clean
254 clobber $(CLOBBER_DEPS)         := TARGET = clobber
255 modlist $(MODLIST_DEPS)         := TARGET = modlist
256 modlist $(MODLIST_DEPS)         := NO_STATE= -K $$MODSTATE$$$$
257 install $(INSTALL_DEPS)         := TARGET = install
258 symcheck $(SYM_DEPS)            := TARGET = symcheck
260 ALL_TARGS       = def all clean clobber install symcheck
262 ALL_OBJ32       = $(ALL_TARGS:%=%.obj32)
264 $(ALL_OBJ32):   FRC
265         @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
267 ALL_DEBUG32     = $(ALL_TARGS:%=%.debug32)
269 $(ALL_DEBUG32): FRC
270         @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
272 ALL_OBJ64       = $(ALL_TARGS:%=%.obj64)
274 $(ALL_OBJ64):   FRC
275         @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
277 ALL_DEBUG64     = $(ALL_TARGS:%=%.debug64)
279 $(ALL_DEBUG64): FRC
280         @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
283 #       Currently only the IP module needs symbol checking on obj64.
284 #       Other modules have the same global-objs nm output for debug64 and obj64.
286 $(SISCHECK_DEPS):       $(DEF_DEPS)
287         @TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
288         MODSYMS=$(MODULE).symbols.$$TARG; \
289         if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
290                 $(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
291                     $(SORT) -u > $$MODSYMS.tmp; \
292                 $(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
293                     $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
294                     $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
295                     > $$MODSYMS.tmp.new; \
296                 $(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
297                     ($(ECHO) "warning: $(MODULE) symbol checking:" \
298                     "global variable(s) introduced and/or removed."; \
299                     $(CAT) $$MODSYMS.diff; exit 1) \
300         fi
302 $(SISCLEAN_DEPS):
303         -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
304         MODSYMS=$(MODULE).symbols.$$TARG; \
305         $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
308 $(OBJS_DIR):
309         -@mkdir -p $@ 2> /dev/null
311 def.targ:               $(OBJS_DIR) $(ALL_TARGET)
313 all.targ:               $(OBJS_DIR) $(ALL_TARGET)
315 install.targ:           $(OBJS_DIR) $(INSTALL_TARGET)
318 # Support for Install.sh.
321 modlist:        $(MODLIST_DEPS)
323 # paths relative to $(ROOT).
324 RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
325 RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
326 RELLINK = $(ROOTLINK:$(ROOT)/%=%)
327 RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
328 RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
330 MODSRC:sh=              pwd
333 # Generate module information for Install.sh, i.e., specify what files
334 # Install.sh should include.  Each line looks like
335 #   <tag> <srcdir> <arg1> <arg2> ...
336 # where <tag> specifies the type of file, <srcdir> gives the source
337 # path (useful if there is an error), and <argN> is one or more
338 # additional bits of information that Install.sh needs (e.g., source
339 # directory, install directory, filtering tags).  See Install.sh for
340 # details on the arguments for each tag type, especially the functions
341 # copymod, filtmod, and filtimpl.
343 # Changes to this target may require corresponding changes to
344 # Install.sh.
346 # Don't issue a MOD entry if it's not in the install list.
349 $(MODLIST_DEPS): FRC
350         @case $@ in \
351         *32) \
352                 class=32; \
353                 [ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
354         *64) \
355                 class=64; \
356                 [ -n "$(RELMODULE)" ] && \
357                     relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
358         esac; \
359         if [ -z "$(THISIMPL)" ]; then \
360                 impl=all; \
361         else \
362                 impl=$(THISIMPL); \
363         fi; \
364         if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
365                 if [ -z "$(MODULE)" ]; then \
366                         module=`basename $(ROOTMODULE)`; \
367                 else \
368                         module=$(MODULE); \
369                 fi; \
370                 tinstall="$(INSTALL_TARGET)"; \
371                 for t in $$tinstall; do \
372                         if [ "$(ROOTMODULE)" = $$t ]; then \
373                                 echo MOD $(MODSRC) $$module $$relmodule \
374                                     $$class $$impl; \
375                                 break; \
376                         fi \
377                 done \
378         fi; \
379         if [ -n "$(CONF_SRCDIR)" ]; then \
380                 tinstall="$(INSTALL_TARGET)"; \
381                 for t in $$tinstall; do \
382                         if [ $(ROOT_CONFFILE) = $$t ]; then \
383                                 echo CONF $(MODSRC) $(RELCONF) \
384                                     $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
385                                 break; \
386                         fi \
387                 done \
388         fi; \
389         if [ -n "$(ROOTLINK)" ]; then \
390                 rellinks="$(RELLINK)"; \
391                 for r in $$rellinks; do \
392                         if [ $$class = 32 ]; then \
393                                 linkdir=`dirname $$r`; \
394                         else \
395                                 linkdir=`dirname $$r`/$(SUBDIR64); \
396                         fi; \
397                         echo LINK $(MODSRC) $$relmodule $$module \
398                                 $$linkdir `basename $$r` $$impl; \
399                 done \
400         fi; \
401         if [ -n "$(UNIX32_LINK)" ]; then \
402                 echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
403                     `dirname $(RELUNIX)` unix $$impl $$module; \
404         fi; \
405         trelsoftlinks="$(RELSOFTLINKS)"; \
406         for t in $$trelsoftlinks; do \
407                 if [ $$class = 32 ]; then \
408                         linkdir=`dirname $$t`; \
409                 else \
410                         linkdir=`dirname $$t`/$(SUBDIR64); \
411                 fi; \
412                 linkname=`basename $$t`; \
413                 echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
414                     $$impl $$module; \
415         done
418 #       Cleanliness is next to ...
420 clean.targ:
421         -$(RM) $(CLEANFILES) Nothing_to_remove
423 clobber.targ:
424         -$(RM) $(CLOBBERFILES) Nothing_to_remove
426 FRC: