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]
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...
37 $(LD) -r $(LDFLAGS) -o $@ $(OBJECTS)
42 # This target checks each kmod for undefined entry points. It does not
43 # modify the kmod in any way.
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)
78 -DUTS_VERSION=\"`$(ECHO) $(PATCHID) | sed -e 's/ /_/g'`\" \
79 -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRCTOP)/kernel/os/vers.c
84 # Installation targets and rules:
86 $(ROOT_MOD_DIR) $(USR_MOD_DIR):
89 $(ROOT_MOD_DIRS): $(ROOT_MOD_DIR)
92 $(USR_MOD_DIRS): $(USR_MOD_DIR)
95 $(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
98 $(ROOT_CPU_DIR)/%: $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
101 $(ROOT_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
104 $(ROOT_DTRACE_DIR)/%: $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
107 $(ROOT_EXEC_DIR)/%: $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
110 $(ROOT_FS_DIR)/%: $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
113 $(ROOT_SCHED_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
116 $(ROOT_SOCK_DIR)/%: $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
119 $(ROOT_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
122 $(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
125 $(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
128 $(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
131 $(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
134 $(ROOT_BRAND_DIR)/%: $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
137 $(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
140 $(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
143 $(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
146 $(ROOT_PMCS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
149 $(ROOT_QLC_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
152 $(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
155 $(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
158 $(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
161 $(ROOT_MAC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
164 $(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC
167 $(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
170 $(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC
173 $(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
176 $(USR_SOCK_DIR)/%: $(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
179 $(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
182 $(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC
185 $(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC
188 $(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC
191 $(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
194 $(USR_DTRACE_DIR)/%: $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
197 $(USR_BRAND_DIR)/%: $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
200 $(ROOT_KICONV_DIR)/%: $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
203 $(ROOT_FIRMWARE_DIR)/$(MODULE):
206 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)
208 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
211 include $(SRC)/Makefile.psm.targ
214 # Target for 64b modules
219 $(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
226 # Targets for '.conf' file installation.
228 $(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(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}.
239 $(ROOT_PLAT_LINKS_2):
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)
265 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
267 ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32)
270 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
272 ALL_OBJ64 = $(ALL_TARGS:%=%.obj64)
275 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
277 ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64)
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) \
303 -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
304 MODSYMS=$(MODULE).symbols.$$TARG; \
305 $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
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)/%=%)
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
346 # Don't issue a MOD entry if it's not in the install list.
353 [ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
356 [ -n "$(RELMODULE)" ] && \
357 relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
359 if [ -z "$(THISIMPL)" ]; then \
364 if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
365 if [ -z "$(MODULE)" ]; then \
366 module=`basename $(ROOTMODULE)`; \
370 tinstall="$(INSTALL_TARGET)"; \
371 for t in $$tinstall; do \
372 if [ "$(ROOTMODULE)" = $$t ]; then \
373 echo MOD $(MODSRC) $$module $$relmodule \
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; \
389 if [ -n "$(ROOTLINK)" ]; then \
390 rellinks="$(RELLINK)"; \
391 for r in $$rellinks; do \
392 if [ $$class = 32 ]; then \
393 linkdir=`dirname $$r`; \
395 linkdir=`dirname $$r`/$(SUBDIR64); \
397 echo LINK $(MODSRC) $$relmodule $$module \
398 $$linkdir `basename $$r` $$impl; \
401 if [ -n "$(UNIX32_LINK)" ]; then \
402 echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
403 `dirname $(RELUNIX)` unix $$impl $$module; \
405 trelsoftlinks="$(RELSOFTLINKS)"; \
406 for t in $$trelsoftlinks; do \
407 if [ $$class = 32 ]; then \
408 linkdir=`dirname $$t`; \
410 linkdir=`dirname $$t`/$(SUBDIR64); \
412 linkname=`basename $$t`; \
413 echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
418 # Cleanliness is next to ...
421 -$(RM) $(CLEANFILES) Nothing_to_remove
424 -$(RM) $(CLOBBERFILES) Nothing_to_remove