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