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 $(COMPILE64.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 $(VERSION)
72 # Build environment information is only contained in the comment section.
75 $(OBJS_DIR)/vers.o: $(OBJECTS)
77 -DUTS_VERSION=\"$(VERSION)\" -o $@ $(SRCTOP)/kernel/os/vers.c
82 # Installation targets and rules:
84 $(ROOT_MOD_DIR) $(USR_MOD_DIR):
87 $(ROOT_MOD_DIRS): $(ROOT_MOD_DIR)
90 $(USR_MOD_DIRS): $(USR_MOD_DIR)
93 $(ROOT_MOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
96 $(ROOT_CPU_DIR)/%: $(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
99 $(ROOT_DRV_DIR)/%: $(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
102 $(ROOT_DTRACE_DIR)/%: $(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
105 $(ROOT_EXEC_DIR)/%: $(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
108 $(ROOT_FS_DIR)/%: $(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
111 $(ROOT_SCHED_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
114 $(ROOT_SOCK_DIR)/%: $(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
117 $(ROOT_STRMOD_DIR)/%: $(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
120 $(ROOT_IPP_DIR)/%: $(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
123 $(ROOT_SYS_DIR)/%: $(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
126 $(ROOT_MISC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
129 $(ROOT_DACF_DIR)/%: $(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
132 $(ROOT_BRAND_DIR)/%: $(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
135 $(ROOT_CRYPTO_DIR)/%: $(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
138 $(ROOT_KGSS_DIR)/%: $(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
141 $(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
144 $(ROOT_PMCS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
147 $(ROOT_QLC_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
150 $(ROOT_EMLXS_FW_DIR)/%: $(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
153 $(ROOT_MACH_DIR)/%: $(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
156 $(ROOT_FONT_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
159 $(ROOT_MAC_DIR)/%: $(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
162 $(USR_DRV_DIR)/%: $(OBJS_DIR)/% $(USR_DRV_DIR) FRC
165 $(USR_EXEC_DIR)/%: $(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
168 $(USR_FS_DIR)/%: $(OBJS_DIR)/% $(USR_FS_DIR) FRC
171 $(USR_SCHED_DIR)/%: $(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
174 $(USR_SOCK_DIR)/%: $(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
177 $(USR_STRMOD_DIR)/%: $(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
180 $(USR_SYS_DIR)/%: $(OBJS_DIR)/% $(USR_SYS_DIR) FRC
183 $(USR_MISC_DIR)/%: $(OBJS_DIR)/% $(USR_MISC_DIR) FRC
186 $(USR_DACF_DIR)/%: $(OBJS_DIR)/% $(USR_DACF_DIR) FRC
189 $(USR_PCBE_DIR)/%: $(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
192 $(USR_DTRACE_DIR)/%: $(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
195 $(USR_BRAND_DIR)/%: $(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
198 $(ROOT_KICONV_DIR)/%: $(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
201 $(ROOT_FIRMWARE_DIR)/$(MODULE):
204 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)
206 $(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
209 include $(SRC)/Makefile.psm.targ
212 # Target for 64b modules
217 $(ROOT_KERN_DIR_64)/%: $(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
224 # Targets for '.conf' file installation.
226 $(ROOT_CONFFILE): $(SRC_CONFFILE) $(ROOT_CONFFILE:%/$(CONFFILE)=%)
230 # multiple builds support
232 def $(DEF_DEPS) := TARGET = def
233 all $(ALL_DEPS) := TARGET = all
234 clean $(CLEAN_DEPS) := TARGET = clean
235 clobber $(CLOBBER_DEPS) := TARGET = clobber
236 modlist $(MODLIST_DEPS) := TARGET = modlist
237 modlist $(MODLIST_DEPS) := NO_STATE= -K $$MODSTATE$$$$
238 install $(INSTALL_DEPS) := TARGET = install
239 symcheck $(SYM_DEPS) := TARGET = symcheck
241 ALL_TARGS = def all clean clobber install symcheck
243 ALL_OBJ32 = $(ALL_TARGS:%=%.obj32)
246 @BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
248 ALL_DEBUG32 = $(ALL_TARGS:%=%.debug32)
251 @BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
253 ALL_OBJ64 = $(ALL_TARGS:%=%.obj64)
256 @BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
258 ALL_DEBUG64 = $(ALL_TARGS:%=%.debug64)
261 @BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
264 # Currently only the IP module needs symbol checking on obj64.
265 # Other modules have the same global-objs nm output for debug64 and obj64.
267 $(SISCHECK_DEPS): $(DEF_DEPS)
268 @TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
269 MODSYMS=$(MODULE).symbols.$$TARG; \
270 if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
271 $(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
272 $(SORT) -u > $$MODSYMS.tmp; \
273 $(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
274 $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
275 $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
276 > $$MODSYMS.tmp.new; \
277 $(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
278 ($(ECHO) "warning: $(MODULE) symbol checking:" \
279 "global variable(s) introduced and/or removed."; \
280 $(CAT) $$MODSYMS.diff; exit 1) \
284 -TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
285 MODSYMS=$(MODULE).symbols.$$TARG; \
286 $(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
290 -@mkdir -p $@ 2> /dev/null
292 def.targ: $(OBJS_DIR) $(ALL_TARGET)
294 all.targ: $(OBJS_DIR) $(ALL_TARGET)
296 install.targ: $(OBJS_DIR) $(INSTALL_TARGET)
299 # Support for Install.sh.
302 modlist: $(MODLIST_DEPS)
304 # paths relative to $(ROOT).
305 RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
306 RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
307 RELLINK = $(ROOTLINK:$(ROOT)/%=%)
308 RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
309 RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
314 # Generate module information for Install.sh, i.e., specify what files
315 # Install.sh should include. Each line looks like
316 # <tag> <srcdir> <arg1> <arg2> ...
317 # where <tag> specifies the type of file, <srcdir> gives the source
318 # path (useful if there is an error), and <argN> is one or more
319 # additional bits of information that Install.sh needs (e.g., source
320 # directory, install directory, filtering tags). See Install.sh for
321 # details on the arguments for each tag type, especially the functions
322 # copymod, filtmod, and filtimpl.
324 # Changes to this target may require corresponding changes to
327 # Don't issue a MOD entry if it's not in the install list.
334 [ -n "$(RELMODULE)" ] && relmodule=`dirname $(RELMODULE)`;; \
337 [ -n "$(RELMODULE)" ] && \
338 relmodule=`dirname $(RELMODULE)`/$(SUBDIR64);; \
340 if [ -z "$(THISIMPL)" ]; then \
345 if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
346 if [ -z "$(MODULE)" ]; then \
347 module=`basename $(ROOTMODULE)`; \
351 tinstall="$(INSTALL_TARGET)"; \
352 for t in $$tinstall; do \
353 if [ "$(ROOTMODULE)" = $$t ]; then \
354 echo MOD $(MODSRC) $$module $$relmodule \
360 if [ -n "$(CONF_SRCDIR)" ]; then \
361 tinstall="$(INSTALL_TARGET)"; \
362 for t in $$tinstall; do \
363 if [ $(ROOT_CONFFILE) = $$t ]; then \
364 echo CONF $(MODSRC) $(RELCONF) \
365 $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
370 if [ -n "$(ROOTLINK)" ]; then \
371 rellinks="$(RELLINK)"; \
372 for r in $$rellinks; do \
373 if [ $$class = 32 ]; then \
374 linkdir=`dirname $$r`; \
376 linkdir=`dirname $$r`/$(SUBDIR64); \
378 echo LINK $(MODSRC) $$relmodule $$module \
379 $$linkdir `basename $$r` $$impl; \
382 if [ -n "$(UNIX32_LINK)" ]; then \
383 echo SYMLINK $(MODSRC) $(SUBDIR64)/$(UNIX) \
384 `dirname $(RELUNIX)` unix $$impl $$module; \
386 trelsoftlinks="$(RELSOFTLINKS)"; \
387 for t in $$trelsoftlinks; do \
388 if [ $$class = 32 ]; then \
389 linkdir=`dirname $$t`; \
391 linkdir=`dirname $$t`/$(SUBDIR64); \
393 linkname=`basename $$t`; \
394 echo SYMLINK $(MODSRC) $(MODULE) $$linkdir $$linkname \
399 # Cleanliness is next to ...
402 -$(RM) $(CLEANFILES) Nothing_to_remove
405 -$(RM) $(CLOBBERFILES) Nothing_to_remove