xref: /illumos-gate/usr/src/uts/Makefile.targ (revision 9a9ae70f)
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 2008 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25#
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.
30#
31
32#
33#	Default rule for building the lint library directory:
34#
35$(LINT_LIB_DIR):
36	-@mkdir -p $@ 2> /dev/null
37
38#
39#	All C objects depend on inline files. However, cc(1) doesn't generate
40#	the correct dependency info. Also, these Makefiles don't contain a
41#	separate list of C-derived object files (but it is light weight to
42#	let the assembler files think they depend upon this when they don't).
43#	Fortunately, the inline files won't change very often. So, for now,
44#	all objects depend on the inline files. Remove this when the inliner
45#	is fixed to drop correct dependency information.
46#
47$(OBJECTS): $(INLINES)
48
49#
50#	Partially link .o files to generate the kmod. The fake dependency
51#	on modstubs simplifies things...
52#	ELFSIGN_MOD is defined in the individual KCF plug-in modules Makefiles,
53#	and will sign the ELF objects using elfsign(1).
54#
55$(BINARY):		$(OBJECTS)
56	$(LD) -r $(LDFLAGS) -o $@ $(OBJECTS)
57	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
58	$(POST_PROCESS)
59	$(ELFSIGN_MOD)
60
61#
62#	This target checks each kmod for undefined entry points. It does not
63#	modify the kmod in any way.
64#
65$(MODULE).check:	FRC
66	@BUILD_TYPE=DBG32 $(MAKE) $(MODULE).check.targ
67
68$(MODULE).check.targ:	$(BINARY) $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
69	$(LD) -o /dev/null $(OBJECTS) $(EXTRA_CHECK_OBJS) $(UNIX_O) $(MODSTUBS_O) $(GENLIB)
70
71#
72#	Module lint library construction targets.
73#
74MOD_LINT_LIB	= $(LINT_LIB_DIR)/llib-l$(LINT_MODULE).ln
75
76$(MOD_LINT_LIB):	$(LINT_LIB_DIR) $(LINTS)
77	@-$(ECHO) "\n$(OBJS_DIR)/$(MODULE): (library construction):"
78	@$(LINT) -o $(LINT_MODULE)-$(OBJS_DIR) $(LINTFLAGS) $(LINTS)
79	@$(MV) llib-l$(LINT_MODULE)-$(OBJS_DIR).ln $@
80
81$(LINT_MODULE).lint:	$(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB)
82	@-$(ECHO) "\n$(OBJS_DIR)/$(LINT_MODULE): global crosschecks:"
83	@$(LINT) $(LINTFLAGS) $(MOD_LINT_LIB) $(LINT_LIB) $(GEN_LINT_LIB)
84
85#
86# Since assym.h is a derived file, the dependency must be explicit for
87# all files including this file. (This is only actually required in the
88# instance when the .nse_depinfo file does not exist.) It may seem that
89# the lint targets should also have a similar dependency, but they don't
90# since only C headers are included when #defined(lint) is true. The
91# actual lists are defined in */Makefile.files.
92#
93$(ASSYM_DEPS:%=$(OBJS_DIR)/%):	$(DSF_DIR)/$(OBJS_DIR)/assym.h
94
95#
96#	Everybody need to know how to create a modstubs.o built with the
97#	appropriate flags and located in the appropriate location.
98#
99$(MODSTUBS_O):	$(MODSTUBS)
100	$(COMPILE.s) -o $@ $(MODSTUBS)
101
102$(LINTS_DIR)/modstubs.ln:	$(MODSTUBS)
103	@($(LHEAD) $(LINT.s) $(MODSTUBS) $(LTAIL))
104
105#
106# Build the source file which contains the kernel's utsname,
107# with release, version and machine set as follows:
108#
109#	release: contents of $(RELEASE) (Spaces replaced by '_')
110#	version: contents of $(PATCHID) (Spaces replaced by '_')
111#	machine: contents of $(UNAME_M)
112#
113# Build environment information is only contained in the comment section.
114#
115# The version string, normally the variable VERSION, is set to display
116# environmental information temporarily while in development because
117# it provides a little more useful information.
118#
119VERSION_STRING	= ($(ECHO) $$LOGNAME [\`basename $$CODEMGR_WS\`] \\\c; date +%D)
120$(INTERNAL_RELEASE_BUILD)VERSION_STRING = $(ECHO) $(PATCHID)
121
122$(OBJS_DIR)/vers.o: $(OBJECTS)
123	$(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \
124	    -DUTS_VERSION=\"`$(VERSION_STRING) | sed -e 's/ /_/g'`\" \
125	    -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c
126	$(CTFCONVERT_O)
127	$(POST_PROCESS_O)
128
129$(LINTS_DIR)/vers.ln: $(SRC)/uts/common/os/vers.c
130	@($(LHEAD) $(LINT.c) -DUTS_RELEASE=\"\" -DUTS_VERSION=\"\" \
131	    -DUTS_PLATFORM=\"\" $(SRC)/uts/common/os/vers.c $(LTAIL))
132
133#
134#	Installation targets and rules:
135#
136$(ROOT_MOD_DIR) $(USR_MOD_DIR):
137	-$(INS.dir.root.sys)
138
139$(ROOT_MOD_DIRS_32):	$(ROOT_MOD_DIR)
140	-$(INS.dir.root.sys)
141
142$(USR_MOD_DIRS_32):	$(USR_MOD_DIR)
143	-$(INS.dir.root.sys)
144
145$(ROOT_MOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
146	$(INS.file)
147
148$(ROOT_CPU_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
149	$(INS.file)
150
151$(ROOT_DRV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
152	$(INS.file)
153
154$(ROOT_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
155	$(INS.file)
156
157$(ROOT_EXEC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
158	$(INS.file)
159
160$(ROOT_FS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
161	$(INS.file)
162
163$(ROOT_SCHED_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
164	$(INS.file)
165
166$(ROOT_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
167	$(INS.file)
168
169$(ROOT_IPP_DIR)/%:	$(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
170	$(INS.file)
171
172$(ROOT_SYS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
173	$(INS.file)
174
175$(ROOT_MISC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
176	$(INS.file)
177
178$(ROOT_DACF_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
179	$(INS.file)
180
181$(ROOT_BRAND_DIR)/%:	$(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
182	$(INS.file)
183
184$(ROOT_CRYPTO_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
185	$(INS.file)
186
187$(ROOT_KGSS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
188	$(INS.file)
189
190$(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
191	$(INS.file)
192
193$(ROOT_QLC_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
194	$(INS.file)
195
196$(ROOT_MACH_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
197	$(INS.file)
198
199$(ROOT_FONT_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
200	$(INS.file)
201
202$(ROOT_MAC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
203	$(INS.file)
204
205$(ROOT_DEVNAME_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DEVNAME_DIR) FRC
206	$(INS.file)
207
208$(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
209	$(INS.file)
210
211$(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
212	$(INS.file)
213
214$(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
215	$(INS.file)
216
217$(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
218	$(INS.file)
219
220$(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
221	$(INS.file)
222
223$(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
224	$(INS.file)
225
226$(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
227	$(INS.file)
228
229$(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
230	$(INS.file)
231
232$(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
233	$(INS.file)
234
235$(USR_DEVNAME_DIR)/%:	$(OBJS_DIR)/% $(USR_DEVNAME_DIR) FRC
236	$(INS.file)
237
238$(USR_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
239	$(INS.file)
240
241$(USR_BRAND_DIR)/%:	$(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
242	$(INS.file)
243
244$(ROOT_KICONV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
245	$(INS.file)
246
247include $(SRC)/Makefile.psm.targ
248
249#
250#	Target for 64b modules
251#
252$(ROOT_KERN_DIR_64):
253	-$(INS.dir.root.sys)
254
255$(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
256	$(INS.file)
257
258%/$(SUBDIR64):		%
259	-$(INS.dir.root.sys)
260
261#
262#	Targets for '.conf' file installation.
263#
264$(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
265	$(INS.conffile)
266
267#
268#	Targets for '.esa' (activation) file installation.
269#
270$(ROOT_ACTFILE):
271	$(INS.actfile)
272
273#
274#	Targets for creating links between common platforms. ROOT_PLAT_LINKS
275#	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
276#	down (/platform/`uname -i`/{lib|sbin|kernel}.
277#
278$(ROOT_PLAT_LINKS):
279	$(INS.slink1)
280
281$(ROOT_PLAT_LINKS_2):
282	$(INS.slink2)
283
284$(USR_PLAT_LINKS):
285	$(INS.slink1)
286
287$(USR_PLAT_LINKS_2):
288	$(INS.slink2)
289
290#
291# multiple builds support
292#
293def $(DEF_DEPS)			:= TARGET = def
294all $(ALL_DEPS)			:= TARGET = all
295clean $(CLEAN_DEPS)		:= TARGET = clean
296clobber $(CLOBBER_DEPS)		:= TARGET = clobber
297lint $(LINT_DEPS)		:= TARGET = lint
298modlintlib $(MODLINTLIB_DEPS)	:= TARGET = modlintlib
299modlist	$(MODLIST_DEPS)		:= TARGET = modlist
300modlist	$(MODLIST_DEPS)		:= NO_STATE= -K $$MODSTATE$$$$
301clean.lint $(CLEAN_LINT_DEPS)	:= TARGET = clean.lint
302install $(INSTALL_DEPS)		:= TARGET = install
303symcheck $(SYM_DEPS)		:= TARGET = symcheck
304
305ALL_TARGS	= def all clean clobber lint modlintlib \
306		  clean.lint lintlib install symcheck
307
308ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)
309
310$(ALL_OBJ32):	FRC
311	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
312
313ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)
314
315$(ALL_DEBUG32):	FRC
316	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
317
318ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)
319
320$(ALL_OBJ64):	FRC
321	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
322
323ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)
324
325$(ALL_DEBUG64):	FRC
326	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
327
328#
329#	Currently only the IP module needs symbol checking on obj64.
330#	Other modules have the same global-objs nm output for debug64 and obj64.
331#
332$(SISCHECK_DEPS):	$(DEF_DEPS)
333	@TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
334	MODSYMS=$(MODULE).symbols.$$TARG; \
335	if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
336		$(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
337		    $(SORT) -u > $$MODSYMS.tmp; \
338		$(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
339		    $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
340		    $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
341		    > $$MODSYMS.tmp.new; \
342		$(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
343		    ($(ECHO) "warning: $(MODULE) symbol checking:" \
344		    "global variable(s) introduced and/or removed."; \
345		    $(CAT) $$MODSYMS.diff; exit 1) \
346	fi
347
348$(SISCLEAN_DEPS):
349	-TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
350	MODSYMS=$(MODULE).symbols.$$TARG; \
351	$(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
352
353
354$(OBJS_DIR):
355	-@mkdir -p $@ 2> /dev/null
356
357def.targ:		$(OBJS_DIR) $(ALL_TARGET)
358
359all.targ:		$(OBJS_DIR) $(ALL_TARGET)
360
361lint.targ:		$(OBJS_DIR) $(LINT_TARGET)
362
363modlintlib.targ:	$(OBJS_DIR) $(MOD_LINT_LIB)
364
365install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)
366
367#
368# Support for Install.sh.
369#
370
371modlist:	$(MODLIST_DEPS)
372
373# paths relative to $(ROOT).
374RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
375RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
376RELLINK = $(ROOTLINK:$(ROOT)/%=%)
377RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
378RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
379
380MODSRC:sh=		pwd
381
382#
383# Changes to this target may require corresponding changes to
384# Install.sh.
385# Don't issue a MOD entry if it's not in the install list.
386#
387$(MODLIST_DEPS): FRC
388	@case $@ in \
389	*32) \
390		class=32; \
391		relmodule=`dirname $(RELMODULE)`; \
392		rellink=`dirname $(RELLINK)`;; \
393	*64) \
394		class=64; \
395		relmodule=`dirname $(RELMODULE)`/$(SUBDIR64); \
396		rellink=`dirname $(RELLINK)`/$(SUBDIR64);; \
397	esac; \
398	if [ -z "$(THISIMPL)" ]; then \
399		impl=all; \
400	else \
401		impl=$(THISIMPL); \
402	fi; \
403	if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
404		if [ -z "$(MODULE)" ]; then \
405			module=`basename $(ROOTMODULE)`; \
406		else \
407			module=$(MODULE); \
408		fi; \
409		tinstall="$(INSTALL_TARGET)"; \
410		for t in $$tinstall; do \
411			if [ "$(ROOTMODULE)" = $$t ]; then \
412				echo MOD $$module $$relmodule \
413				    $$class $$impl $(MODSRC); \
414				break; \
415			fi \
416		done \
417	fi; \
418	if [ -n "$(CONF_SRCDIR)" ]; then \
419		tinstall="$(INSTALL_TARGET)"; \
420		for t in $$tinstall; do \
421			if [ $(ROOT_CONFFILE) = $$t ]; then \
422				echo CONF $(RELCONF) \
423				    $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
424				break; \
425			fi \
426		done \
427	fi; \
428	if [ -n "$(ROOTLINK)" ]; then \
429		echo LINK $$relmodule $$module \
430		    $$rellink `basename $(RELLINK)` $$impl; \
431	fi; \
432	if [ -n "$(UNIX32_LINK)" ]; then \
433		echo SYMLINK $(SUBDIR64)/$(UNIX) \
434		    `dirname $(RELUNIX)` unix $$impl $$module; \
435	fi; \
436	trelsoftlinks="$(RELSOFTLINKS)"; \
437	for t in $$trelsoftlinks; do \
438		if [ $$class = 32 ]; then \
439			linkdir=`dirname $$t`; \
440		else \
441			linkdir=`dirname $$t`/$(SUBDIR64); \
442		fi; \
443		linkname=`basename $$t`; \
444		echo SYMLINK $(MODULE) $$linkdir $$linkname \
445		    $$impl $$module; \
446	done
447
448#
449#	Cleanliness is next to ...
450#
451clean.targ:
452	-$(RM) $(CLEANFILES) Nothing_to_remove
453
454clobber.targ:
455	-$(RM) $(CLOBBERFILES) Nothing_to_remove
456
457clean.lint.targ:
458	-$(RM) $(CLEANLINTFILES) Nothing_to_remove
459
460#
461#	Create fake lintlibs in the 64b dirs so
462#	global linting works
463#
464lint64:
465	@$(ECHO) $(MODULE) fake lints
466	@for dir in $(LINT64_DIRS); do \
467		if [ ! -d $$dir ]; then mkdir $$dir; fi \
468	done
469	@for file in $(LINT64_FILES); do \
470		if [ ! -f $$file ]; then touch $$file; fi \
471	done
472
473#
474#	In some places we also need to create fake lintlibs for 32b
475#	dirs so global linting works
476#
477lint32:
478	@$(ECHO) $(MODULE) fake lints
479	@for dir in $(LINT32_DIRS); do \
480		if [ ! -d $$dir ]; then mkdir $$dir; fi \
481	done
482	@for file in $(LINT32_FILES); do \
483		if [ ! -f $$file ]; then touch $$file; fi \
484	done
485
486FRC:
487