xref: /titanic_51/usr/src/uts/Makefile.targ (revision f808c858fa61e7769218966759510a8b1190dfcf)
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 2006 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) $(LINTFLAGS) $(LINTS)
80	@$(MV) $(@F) $@
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 $(PLATFORM)
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=\"$(PLATFORM)\" -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_CRYPTO_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
183	$(INS.file)
184
185$(ROOT_KGSS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
186	$(INS.file)
187
188$(ROOT_MACH_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
189	$(INS.file)
190
191$(ROOT_FONT_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
192	$(INS.file)
193
194$(ROOT_MAC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
195	$(INS.file)
196
197$(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
198	$(INS.file)
199
200$(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
201	$(INS.file)
202
203$(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
204	$(INS.file)
205
206$(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
207	$(INS.file)
208
209$(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
210	$(INS.file)
211
212$(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
213	$(INS.file)
214
215$(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
216	$(INS.file)
217
218$(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
219	$(INS.file)
220
221$(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
222	$(INS.file)
223
224include $(SRC)/Makefile.psm.targ
225
226#
227#	Target for 64b modules
228#
229$(ROOT_KERN_DIR_64):
230	-$(INS.dir.root.sys)
231
232$(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
233	$(INS.file)
234
235%/$(SUBDIR64):		%
236	-$(INS.dir.root.sys)
237
238#
239#	Targets for '.conf' file installation.
240#
241$(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
242	$(INS.conffile)
243
244#
245#	Targets for creating links between common platforms. ROOT_PLAT_LINKS
246#	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
247#	down (/platform/`uname -i`/{lib|sbin|kernel}.
248#
249$(ROOT_PLAT_LINKS):
250	$(INS.slink1)
251
252$(ROOT_PLAT_LINKS_2):
253	$(INS.slink2)
254
255$(USR_PLAT_LINKS):
256	$(INS.slink1)
257
258$(USR_PLAT_LINKS_2):
259	$(INS.slink2)
260
261#
262# multiple builds support
263#
264def $(DEF_DEPS)			:= TARGET = def
265all $(ALL_DEPS)			:= TARGET = all
266clean $(CLEAN_DEPS)		:= TARGET = clean
267clobber $(CLOBBER_DEPS)		:= TARGET = clobber
268lint $(LINT_DEPS)		:= TARGET = lint
269modlintlib $(MODLINTLIB_DEPS)	:= TARGET = modlintlib
270modlist	$(MODLIST_DEPS)		:= TARGET = modlist
271modlist	$(MODLIST_DEPS)		:= NO_STATE= -K $$MODSTATE$$$$
272clean.lint $(CLEAN_LINT_DEPS)	:= TARGET = clean.lint
273install $(INSTALL_DEPS)		:= TARGET = install
274symcheck $(SYM_DEPS)		:= TARGET = symcheck
275
276
277ALL_TARGS	= def all clean clobber lint modlintlib \
278		  clean.lint lintlib install symcheck
279
280ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)
281
282$(ALL_OBJ32):	FRC
283	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
284
285ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)
286
287$(ALL_DEBUG32):	FRC
288	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
289
290ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)
291
292$(ALL_OBJ64):	FRC
293	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
294
295ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)
296
297$(ALL_DEBUG64):	FRC
298	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
299
300
301$(OBJS_DIR):
302	-@mkdir -p $@ 2> /dev/null
303
304def.targ:		$(OBJS_DIR) $(ALL_TARGET)
305
306all.targ:		$(OBJS_DIR) $(ALL_TARGET)
307
308lint.targ:		$(OBJS_DIR) $(LINT_TARGET)
309
310modlintlib.targ:	$(OBJS_DIR) $(MOD_LINT_LIB)
311
312install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)
313
314#
315# Support for Install.sh.
316#
317
318modlist:	$(MODLIST_DEPS)
319
320# paths relative to $(ROOT).
321RELMODULE = $(ROOTMODULE:$(ROOT)/%=%)
322RELCONF = $(ROOT_CONFFILE:$(ROOT)/%=%)
323RELLINK = $(ROOTLINK:$(ROOT)/%=%)
324RELUNIX = $(UNIX32_LINK:$(ROOT)/%=%)
325RELSOFTLINKS = $(ROOTSOFTLINKS:$(ROOT)/%=%)
326
327MODSRC:sh=		pwd
328
329#
330# Changes to this target may require corresponding changes to
331# Install.sh.
332# Don't issue a MOD entry if it's not in the install list.
333#
334$(MODLIST_DEPS): FRC
335	@case $@ in \
336	*32) \
337		class=32; \
338		relmodule=`dirname $(RELMODULE)`; \
339		rellink=`dirname $(RELLINK)`;; \
340	*64) \
341		class=64; \
342		relmodule=`dirname $(RELMODULE)`/$(SUBDIR64); \
343		rellink=`dirname $(RELLINK)`/$(SUBDIR64);; \
344	esac; \
345	if [ -z "$(THISIMPL)" ]; then \
346		impl=all; \
347	else \
348		impl=$(THISIMPL); \
349	fi; \
350	if [ -n "$(ROOTMODULE)" -a -n "$(INSTALL_TARGET)" ]; then \
351		if [ -z "$(MODULE)" ]; then \
352			module=`basename $(ROOTMODULE)`; \
353		else \
354			module=$(MODULE); \
355		fi; \
356		tinstall="$(INSTALL_TARGET)"; \
357		for t in $$tinstall; do \
358			if [ "$(ROOTMODULE)" = $$t ]; then \
359				echo MOD $$module $$relmodule \
360				    $$class $$impl $(MODSRC); \
361				break; \
362			fi \
363		done \
364	fi; \
365	if [ -n "$(CONF_SRCDIR)" ]; then \
366		tinstall="$(INSTALL_TARGET)"; \
367		for t in $$tinstall; do \
368			if [ $(ROOT_CONFFILE) = $$t ]; then \
369				echo CONF $(RELCONF) \
370				    $(MODSRC)/$(CONF_SRCDIR) $$impl $$module; \
371				break; \
372			fi \
373		done \
374	fi; \
375	if [ -n "$(ROOTLINK)" ]; then \
376		echo LINK $$relmodule $$module \
377		    $$rellink `basename $(RELLINK)` $$impl; \
378	fi; \
379	if [ -n "$(UNIX32_LINK)" ]; then \
380		echo SYMLINK $(SUBDIR64)/$(UNIX) \
381		    `dirname $(RELUNIX)` unix $$impl $$module; \
382	fi; \
383	trelsoftlinks="$(RELSOFTLINKS)"; \
384	for t in $$trelsoftlinks; do \
385		if [ $$class = 32 ]; then \
386			linkdir=`dirname $$t`; \
387		else \
388			linkdir=`dirname $$t`/$(SUBDIR64); \
389		fi; \
390		linkname=`basename $$t`; \
391		echo SYMLINK $(MODULE) $$linkdir $$linkname \
392		    $$impl $$module; \
393	done
394
395#
396#	Cleanliness is next to ...
397#
398clean.targ:
399	-$(RM) $(CLEANFILES) Nothing_to_remove
400
401clobber.targ:
402	-$(RM) $(CLOBBERFILES) Nothing_to_remove
403
404clean.lint.targ:
405	-$(RM) $(CLEANLINTFILES) Nothing_to_remove
406
407#
408#	Create fake lintlibs in the 64b dirs so
409#	global linting works
410#
411lint64:
412	@$(ECHO) $(MODULE) fake lints
413	@for dir in $(LINT64_DIRS); do \
414		if [ ! -d $$dir ]; then mkdir $$dir; fi \
415	done
416	@for file in $(LINT64_FILES); do \
417		if [ ! -f $$file ]; then touch $$file; fi \
418	done
419
420#
421#	In some places we also need to create fake lintlibs for 32b
422#	dirs so global linting works
423#
424lint32:
425	@$(ECHO) $(MODULE) fake lints
426	@for dir in $(LINT32_DIRS); do \
427		if [ ! -d $$dir ]; then mkdir $$dir; fi \
428	done
429	@for file in $(LINT32_FILES); do \
430		if [ ! -f $$file ]; then touch $$file; fi \
431	done
432FRC:
433