xref: /titanic_44/usr/src/uts/Makefile.targ (revision 4ac67f0276a8313b5cefec38af347b94b7bfb526)
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#	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_MACH_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
199	$(INS.file)
200
201$(ROOT_FONT_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
202	$(INS.file)
203
204$(ROOT_MAC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
205	$(INS.file)
206
207$(ROOT_DEVNAME_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DEVNAME_DIR) FRC
208	$(INS.file)
209
210$(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
211	$(INS.file)
212
213$(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
214	$(INS.file)
215
216$(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
217	$(INS.file)
218
219$(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
220	$(INS.file)
221
222$(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
223	$(INS.file)
224
225$(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
226	$(INS.file)
227
228$(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
229	$(INS.file)
230
231$(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
232	$(INS.file)
233
234$(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
235	$(INS.file)
236
237$(USR_DEVNAME_DIR)/%:	$(OBJS_DIR)/% $(USR_DEVNAME_DIR) FRC
238	$(INS.file)
239
240$(USR_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
241	$(INS.file)
242
243$(USR_BRAND_DIR)/%:	$(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
244	$(INS.file)
245
246$(ROOT_KICONV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
247	$(INS.file)
248
249include $(SRC)/Makefile.psm.targ
250
251#
252#	Target for 64b modules
253#
254$(ROOT_KERN_DIR_64):
255	-$(INS.dir.root.sys)
256
257$(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
258	$(INS.file)
259
260%/$(SUBDIR64):		%
261	-$(INS.dir.root.sys)
262
263#
264#	Targets for '.conf' file installation.
265#
266$(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
267	$(INS.conffile)
268
269#
270#	Targets for '.esa' (activation) file installation.
271#
272$(ROOT_ACTFILE):
273	$(INS.actfile)
274
275#
276#	Targets for creating links between common platforms. ROOT_PLAT_LINKS
277#	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
278#	down (/platform/`uname -i`/{lib|sbin|kernel}.
279#
280$(ROOT_PLAT_LINKS):
281	$(INS.slink1)
282
283$(ROOT_PLAT_LINKS_2):
284	$(INS.slink2)
285
286$(USR_PLAT_LINKS):
287	$(INS.slink1)
288
289$(USR_PLAT_LINKS_2):
290	$(INS.slink2)
291
292#
293# multiple builds support
294#
295def $(DEF_DEPS)			:= TARGET = def
296all $(ALL_DEPS)			:= TARGET = all
297clean $(CLEAN_DEPS)		:= TARGET = clean
298clobber $(CLOBBER_DEPS)		:= TARGET = clobber
299lint $(LINT_DEPS)		:= TARGET = lint
300modlintlib $(MODLINTLIB_DEPS)	:= TARGET = modlintlib
301modlist	$(MODLIST_DEPS)		:= TARGET = modlist
302modlist	$(MODLIST_DEPS)		:= NO_STATE= -K $$MODSTATE$$$$
303clean.lint $(CLEAN_LINT_DEPS)	:= TARGET = clean.lint
304install $(INSTALL_DEPS)		:= TARGET = install
305symcheck $(SYM_DEPS)		:= TARGET = symcheck
306
307ALL_TARGS	= def all clean clobber lint modlintlib \
308		  clean.lint lintlib install symcheck
309
310ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)
311
312$(ALL_OBJ32):	FRC
313	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
314
315ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)
316
317$(ALL_DEBUG32):	FRC
318	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
319
320ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)
321
322$(ALL_OBJ64):	FRC
323	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
324
325ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)
326
327$(ALL_DEBUG64):	FRC
328	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
329
330#
331#	Currently only the IP module needs symbol checking on obj64.
332#	Other modules have the same global-objs nm output for debug64 and obj64.
333#
334$(SISCHECK_DEPS):	$(DEF_DEPS)
335	@TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
336	MODSYMS=$(MODULE).symbols.$$TARG; \
337	if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
338		$(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
339		    $(SORT) -u > $$MODSYMS.tmp; \
340		$(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
341		    $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
342		    $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
343		    > $$MODSYMS.tmp.new; \
344		$(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
345		    ($(ECHO) "warning: $(MODULE) symbol checking:" \
346		    "global variable(s) introduced and/or removed."; \
347		    $(CAT) $$MODSYMS.diff; exit 1) \
348	fi
349
350$(SISCLEAN_DEPS):
351	-TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
352	MODSYMS=$(MODULE).symbols.$$TARG; \
353	$(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
354
355
356$(OBJS_DIR):
357	-@mkdir -p $@ 2> /dev/null
358
359def.targ:		$(OBJS_DIR) $(ALL_TARGET)
360
361all.targ:		$(OBJS_DIR) $(ALL_TARGET)
362
363lint.targ:		$(OBJS_DIR) $(LINT_TARGET)
364
365modlintlib.targ:	$(OBJS_DIR) $(MOD_LINT_LIB)
366
367install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)
368
369#
370# Support for Install.sh.
371#
372
373modlist:	$(MODLIST_DEPS)
374
375# paths relative to $(ROOT).
376RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
377RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
378RELLINK = $(ROOTLINK:$(ROOT)/%=%)
379RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
380RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
381
382MODSRC:sh=		pwd
383
384#
385# Changes to this target may require corresponding changes to
386# Install.sh.
387# Don't issue a MOD entry if it's not in the install list.
388#
389$(MODLIST_DEPS): FRC
390	@case $@ in \
391	*32) \
392		class=32; \
393		relmodule=`dirname $(RELMODULE)`;; \
394	*64) \
395		class=64; \
396		relmodule=`dirname $(RELMODULE)`/$(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		rellinks="$(RELLINK)"; \
430		for r in $$rellinks; do \
431		if [ $$class = 32 ]; then \
432			linkdir=`dirname $$r`; \
433		else \
434			linkdir=`dirname $$r`/$(SUBDIR64); \
435		fi; \
436		echo LINK $$relmodule $$module \
437			$$linkdir `basename $$r` $$impl; \
438		done \
439	fi; \
440	if [ -n "$(UNIX32_LINK)" ]; then \
441		echo SYMLINK $(SUBDIR64)/$(UNIX) \
442		    `dirname $(RELUNIX)` unix $$impl $$module; \
443	fi; \
444	trelsoftlinks="$(RELSOFTLINKS)"; \
445	for t in $$trelsoftlinks; do \
446		if [ $$class = 32 ]; then \
447			linkdir=`dirname $$t`; \
448		else \
449			linkdir=`dirname $$t`/$(SUBDIR64); \
450		fi; \
451		linkname=`basename $$t`; \
452		echo SYMLINK $(MODULE) $$linkdir $$linkname \
453		    $$impl $$module; \
454	done
455
456#
457#	Cleanliness is next to ...
458#
459clean.targ:
460	-$(RM) $(CLEANFILES) Nothing_to_remove
461
462clobber.targ:
463	-$(RM) $(CLOBBERFILES) Nothing_to_remove
464
465clean.lint.targ:
466	-$(RM) $(CLEANLINTFILES) Nothing_to_remove
467
468#
469#	Create fake lintlibs in the 64b dirs so
470#	global linting works
471#
472lint64:
473	@$(ECHO) $(MODULE) fake lints
474	@for dir in $(LINT64_DIRS); do \
475		if [ ! -d $$dir ]; then mkdir $$dir; fi \
476	done
477	@for file in $(LINT64_FILES); do \
478		if [ ! -f $$file ]; then touch $$file; fi \
479	done
480
481#
482#	In some places we also need to create fake lintlibs for 32b
483#	dirs so global linting works
484#
485lint32:
486	@$(ECHO) $(MODULE) fake lints
487	@for dir in $(LINT32_DIRS); do \
488		if [ ! -d $$dir ]; then mkdir $$dir; fi \
489	done
490	@for file in $(LINT32_FILES); do \
491		if [ ! -f $$file ]; then touch $$file; fi \
492	done
493
494FRC:
495