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