xref: /illumos-gate/usr/src/uts/Makefile.targ (revision 41e0a469)
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 (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23# Copyright 2014 Garrett D'Amore <garrett@damore.org>
24# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org>
25# Copyright (c) 2017 by Delphix. All rights reserved.
26# Copyright 2019 Joyent, Inc.
27#
28#	This Makefiles contains the common targets and definitions for
29#	all kernels. It is to be included in the Makefiles for specific
30#	implementation architectures and processor architecture dependent
31#	modules: i.e.: all driving kernel Makefiles.
32#
33
34#
35#	Partially link .o files to generate the kmod. The fake dependency
36#	on modstubs simplifies things...
37#
38$(BINARY):		$(OBJECTS) $(DTRACE_MAPFILE) $(MAPFILE)
39	$(LD) -ztype=kmod $(LDFLAGS) -o $@ $(OBJECTS)
40	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
41	$(POST_PROCESS)
42
43#
44# Since assym.h is a derived file, the dependency must be explicit for all
45# files including this file.  The actual lists are defined in
46# */Makefile.files.
47#
48$(ASSYM_DEPS:%=$(OBJS_DIR)/%):	$(DSF_DIR)/$(OBJS_DIR)/assym.h
49
50#
51# Build the source file which contains the kernel's utsname,
52# with release, version and machine set as follows:
53#
54#	release: contents of $(RELEASE) (Spaces replaced by '_')
55#	version: contents of $(VERSION) (Spaces replaced by '_')
56#	machine: contents of $(UNAME_M)
57#
58# Build environment information is only contained in the comment section.
59#
60
61$(OBJS_DIR)/vers.o: $(OBJECTS)
62	$(COMPILE.c) -DUTS_RELEASE=\"`$(ECHO) $(RELEASE) | sed -e 's/ /_/g'`\" \
63	    -DUTS_VERSION=\"`$(ECHO) $(VERSION) | sed -e 's/ /_/g'`\" \
64	    -DUTS_PLATFORM=\"$(UNAME_M)\" -o $@ $(SRC)/uts/common/os/vers.c
65	$(CTFCONVERT_O)
66	$(POST_PROCESS_O)
67
68#
69#	Installation targets and rules:
70#
71$(ROOT_MOD_DIR) $(USR_MOD_DIR):
72	-$(INS.dir)
73
74$(ROOT_MOD_DIRS_32):	$(ROOT_MOD_DIR)
75	-$(INS.dir)
76
77$(USR_MOD_DIRS_32):	$(USR_MOD_DIR)
78	-$(INS.dir)
79
80$(ROOT_MOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) FRC
81	$(INS.file)
82
83$(ROOT_CPU_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CPU_DIR) FRC
84	$(INS.file)
85
86$(ROOT_DRV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DRV_DIR) FRC
87	$(INS.file)
88
89$(ROOT_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DTRACE_DIR) FRC
90	$(INS.file)
91
92$(ROOT_EXEC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_EXEC_DIR) FRC
93	$(INS.file)
94
95$(ROOT_FS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_FS_DIR) FRC
96	$(INS.file)
97
98$(ROOT_SCHED_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SCHED_DIR) FRC
99	$(INS.file)
100
101$(ROOT_SOCK_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SOCK_DIR) FRC
102	$(INS.file)
103
104$(ROOT_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(ROOT_STRMOD_DIR) FRC
105	$(INS.file)
106
107$(ROOT_IPP_DIR)/%:	$(OBJS_DIR)/% $(ROOT_IPP_DIR) FRC
108	$(INS.file)
109
110$(ROOT_SYS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_SYS_DIR) FRC
111	$(INS.file)
112
113$(ROOT_MISC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MISC_DIR) FRC
114	$(INS.file)
115
116$(ROOT_DACF_DIR)/%:	$(OBJS_DIR)/% $(ROOT_DACF_DIR) FRC
117	$(INS.file)
118
119$(ROOT_BRAND_DIR)/%:	$(OBJS_DIR)/% $(ROOT_BRAND_DIR) FRC
120	$(INS.file)
121
122$(ROOT_CC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_CC_DIR) FRC
123	$(INS.file)
124
125$(ROOT_CRYPTO_DIR)/%:	$(OBJS_DIR)/% $(ROOT_CRYPTO_DIR) FRC
126	$(INS.file)
127
128$(ROOT_KGSS_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KGSS_DIR) FRC
129	$(INS.file)
130
131$(ROOT_SCSI_VHCI_DIR)/%: $(OBJS_DIR)/% $(ROOT_SCSI_VHCI_DIR) FRC
132	$(INS.file)
133
134$(ROOT_PMCS_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_PMCS_FW_DIR) FRC
135	$(INS.file)
136
137$(ROOT_QLC_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_QLC_FW_DIR) FRC
138	$(INS.file)
139
140$(ROOT_EMLXS_FW_DIR)/%:	$(OBJS_DIR)/% $(ROOT_EMLXS_FW_DIR) FRC
141	$(INS.file)
142
143$(ROOT_MACH_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MACH_DIR) FRC
144	$(INS.file)
145
146$(ROOT_FONT_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_FONT_DIR) FRC
147	$(INS.file)
148
149$(ROOT_MAC_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_MAC_DIR) FRC
150	$(INS.file)
151
152$(ROOT_OVERLAY_DIR)/%:	$(OBJS_DIR)/% $(ROOT_MOD_DIR) $(ROOT_OVERLAY_DIR) FRC
153	$(INS.file)
154
155$(USR_DRV_DIR)/%:	$(OBJS_DIR)/% $(USR_DRV_DIR) FRC
156	$(INS.file)
157
158$(USR_EXEC_DIR)/%:	$(OBJS_DIR)/% $(USR_EXEC_DIR) FRC
159	$(INS.file)
160
161$(USR_FS_DIR)/%:	$(OBJS_DIR)/% $(USR_FS_DIR) FRC
162	$(INS.file)
163
164$(USR_SCHED_DIR)/%:	$(OBJS_DIR)/% $(USR_SCHED_DIR) FRC
165	$(INS.file)
166
167$(USR_SOCK_DIR)/%:	$(OBJS_DIR)/% $(USR_SOCK_DIR) FRC
168	$(INS.file)
169
170$(USR_STRMOD_DIR)/%:	$(OBJS_DIR)/% $(USR_STRMOD_DIR) FRC
171	$(INS.file)
172
173$(USR_SYS_DIR)/%:	$(OBJS_DIR)/% $(USR_SYS_DIR) FRC
174	$(INS.file)
175
176$(USR_MISC_DIR)/%:	$(OBJS_DIR)/% $(USR_MISC_DIR) FRC
177	$(INS.file)
178
179$(USR_DACF_DIR)/%:	$(OBJS_DIR)/% $(USR_DACF_DIR) FRC
180	$(INS.file)
181
182$(USR_PCBE_DIR)/%:	$(OBJS_DIR)/% $(USR_PCBE_DIR) FRC
183	$(INS.file)
184
185$(USR_DTRACE_DIR)/%:	$(OBJS_DIR)/% $(USR_DTRACE_DIR) FRC
186	$(INS.file)
187
188$(USR_BRAND_DIR)/%:	$(OBJS_DIR)/% $(USR_BRAND_DIR) FRC
189	$(INS.file)
190
191$(ROOT_KICONV_DIR)/%:	$(OBJS_DIR)/% $(ROOT_KICONV_DIR) FRC
192	$(INS.file)
193
194$(ROOT_FIRMWARE_DIR)/$(MODULE):
195	$(INS.dir)
196
197$(ROOT_FIRMWARE_DIR)/$(MODULE)/%:= FILEMODE = $(CFILEMODE)
198
199$(ROOT_FIRMWARE_DIR)/$(MODULE)/%: $(ROOT_FIRMWARE_DIR)/$(MODULE) $(FWDIR)/%
200	$(INS.file)
201
202include $(SRC)/Makefile.psm.targ
203
204#
205#	Target for 64b modules
206#
207$(ROOT_KERN_DIR_64):
208	-$(INS.dir)
209
210$(ROOT_KERN_DIR_64)/%:	$(OBJS_DIR)/% $(ROOT_KERN_DIR_64) FRC
211	$(INS.file)
212
213%/$(SUBDIR64):		%
214	-$(INS.dir)
215
216#
217#	Targets for '.conf' file installation.
218#
219$(ROOT_CONFFILE):	$(SRC_CONFFILE)	$(ROOT_CONFFILE:%/$(CONFFILE)=%)
220	$(INS.conffile)
221
222#
223#	Targets for creating links between common platforms. ROOT_PLAT_LINKS
224#	are are the /platform level while ROOT_PLAT_LINKS_2 are one level
225#	down (/platform/`uname -i`/{lib|sbin|kernel}.
226#
227$(ROOT_PLAT_LINKS):
228	$(INS.slink1)
229
230$(ROOT_PLAT_LINKS_2):
231	$(INS.slink2)
232
233$(USR_PLAT_LINKS):
234	$(INS.slink1)
235
236$(USR_PLAT_LINKS_2):
237	$(INS.slink2)
238
239#
240# multiple builds support
241#
242def $(DEF_DEPS)			:= TARGET = def
243all $(ALL_DEPS)			:= TARGET = all
244clean $(CLEAN_DEPS)		:= TARGET = clean
245clobber $(CLOBBER_DEPS)		:= TARGET = clobber
246install $(INSTALL_DEPS)		:= TARGET = install
247symcheck $(SYM_DEPS)		:= TARGET = symcheck
248
249ALL_TARGS	= def all clean clobber install symcheck
250
251ALL_OBJ32	= $(ALL_TARGS:%=%.obj32)
252
253$(ALL_OBJ32):	FRC
254	@BUILD_TYPE=OBJ32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
255
256ALL_DEBUG32	= $(ALL_TARGS:%=%.debug32)
257
258$(ALL_DEBUG32):	FRC
259	@BUILD_TYPE=DBG32 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
260
261ALL_OBJ64	= $(ALL_TARGS:%=%.obj64)
262
263$(ALL_OBJ64):	FRC
264	@BUILD_TYPE=OBJ64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
265
266ALL_DEBUG64	= $(ALL_TARGS:%=%.debug64)
267
268$(ALL_DEBUG64):	FRC
269	@BUILD_TYPE=DBG64 VERSION='$(VERSION)' $(MAKE) $(NO_STATE) $(TARGET).targ
270
271#
272#	Currently only the IP module needs symbol checking on obj64.
273#	Other modules have the same global-objs nm output for debug64 and obj64.
274#
275$(SISCHECK_DEPS):	$(DEF_DEPS)
276	@TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
277	MODSYMS=$(MODULE).symbols.$$TARG; \
278	if [ -f "$(MODULE).global-objs.$$TARG" ]; then \
279		$(GREP) -v '#' $(MODULE).global-objs.$$TARG |$(GREP) . | \
280		    $(SORT) -u > $$MODSYMS.tmp; \
281		$(NM) $$TARG/$(MODULE) |$(GREP) OBJT |$(GREP) -v UNDEF | \
282		    $(CUT) -d'|' -f8 |$(GREP) -v '^___const_' | \
283		    $(GREP) -v '\.[0-9]*$$' |$(SORT) -u \
284		    > $$MODSYMS.tmp.new; \
285		$(DIFF) $$MODSYMS.tmp $$MODSYMS.tmp.new > $$MODSYMS.diff || \
286		    ($(ECHO) "warning: $(MODULE) symbol checking:" \
287		    "global variable(s) introduced and/or removed."; \
288		    $(CAT) $$MODSYMS.diff; exit 1) \
289	fi
290
291$(SISCLEAN_DEPS):
292	-TARG=`$(ECHO) $@ | $(CUT) -d'.' -f2`; \
293	MODSYMS=$(MODULE).symbols.$$TARG; \
294	$(RM) $$MODSYMS.tmp $$MODSYMS.tmp.new $$MODSYMS.diff Nothing_to_remove
295
296
297$(OBJS_DIR):
298	-@mkdir -p $@ 2> /dev/null
299
300def.targ:		$(OBJS_DIR) $(ALL_TARGET)
301
302all.targ:		$(OBJS_DIR) $(ALL_TARGET)
303
304install.targ:		$(OBJS_DIR) $(INSTALL_TARGET)
305
306#
307#	Cleanliness is next to ...
308#
309clean.targ:
310	-$(RM) $(CLEANFILES) Nothing_to_remove
311
312clobber.targ:
313	-$(RM) $(CLOBBERFILES) Nothing_to_remove
314
315FRC:
316