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