xref: /illumos-gate/usr/src/uts/i86pc/unix/Makefile (revision 2dc5cbd37af38054ac6aab88a3ecee22a13ed2eb)
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# Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
22# Use is subject to license terms.
23#
24# Copyright (c) 2018, Joyent, Inc.
25
26#
27#	Path to the base of the uts directory tree (usually /usr/src/uts).
28#
29UTSBASE	= ../..
30
31#
32#	Define the module and object file sets.
33#
34UNIX		= unix
35DBOOT		= dboot
36
37OBJECTS		= $(SPECIAL_OBJS:%=$(OBJS_DIR)/%) \
38		  $(CORE_OBJS:%=$(OBJS_DIR)/%) \
39		  $(KRTLD_OBJS:%=$(OBJS_DIR)/%) \
40		  $(MACH_NOT_YET_KMODS:%=$(OBJS_DIR)/%)
41
42LINTS		= $(SPECIAL_OBJS:%.o=$(LINTS_DIR)/%.ln) \
43		  $(CORE_OBJS:%.o=$(LINTS_DIR)/%.ln) \
44		  $(KRTLD_OBJS:%.o=$(LINTS_DIR)/%.ln) \
45		  $(MACH_NOT_YET_KMODS:%.o=$(LINTS_DIR)/%.ln) \
46		  $(LINTS_DIR)/vers.ln \
47		  $(LINTS_DIR)/modstubs.ln
48
49ROOTMODULE	= $(ROOT_PSM_KERN_DIR)/$(UNIX)
50
51UNIX_BIN	= $(OBJS_DIR)/$(UNIX)
52
53LIBS		= $(GENLIB)
54
55GENUNIX		= genunix
56GENUNIX_DIR	= ../../intel/$(GENUNIX)
57
58LIBOPTS		= -L $(GENUNIX_DIR)/$(OBJS_DIR) -l $(GENUNIX)
59
60COMMP_CTF_SRC	= $(OBJS_DIR)/comm_page_ctf.c
61
62CTFEXTRAOBJS	= $(OBJS_DIR)/vers.o $(OBJS_DIR)/comm_page_ctf.o
63
64DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
65DBOOT_OBJECTS	= $(DBOOT_OBJS:%=$(DBOOT_OBJS_DIR)/%)
66DBOOT_BIN	= $(DBOOT_OBJS_DIR)/$(DBOOT)
67DBOOT_O		= $(OBJS_DIR)/$(DBOOT).o
68DBOOT_S		= $(DBOOT_O:%.o=%.s)
69DBOOT_LINTS	= $(DBOOT_OBJS:%.o=$(DBOOT_OBJS_DIR)/%.ln)
70DBOOT_LINT	= $(i386_LINT)
71DBOOT_LINTTAGS	= -erroff=E_STATIC_UNUSED
72
73#
74#	Include common rules.
75#
76include $(UTSBASE)/i86pc/Makefile.i86pc
77
78#
79#	Define targets
80#
81ALL_TARGET	= $(UNIX_BIN)
82LINT_TARGET	= $(LINT_LIB) $(DBOOT_LINT_LIB)
83INSTALL_TARGET	= $(UNIX_BIN) $(ROOTMODULE)
84
85#
86#	This is UNIX_DIR. Use a short path.
87#
88UNIX_DIR	= .
89
90#
91#	Overrides
92#
93CLEANFILES	+=		\
94	$(UNIX_O) $(MODSTUBS_O)	\
95	$(OBJS_DIR)/vers.c \
96	$(OBJS_DIR)/dtracestubs.s \
97	$(DTRACESTUBS_O) $(DTRACESTUBS) \
98	$(CTFEXTRAOBJS) \
99	$(COMMP_CTF_SRC)
100
101CLEANFILES	+=		\
102	$(DBOOT_O) $(DBOOT_S)	\
103	$(DBOOT_OBJECTS)	\
104	$(OBJS_DIR)/bios_call_src.o \
105	$(OBJS_DIR)/bios_call_src \
106	$(OBJS_DIR)/bios_call.s \
107	$(DBOOT_BIN)
108
109CLEANFILES	+=		\
110	$(DBOOT_OBJS_DIR)/$(VGATEXT_FONT).c \
111	$(OBJS_DIR)/$(VGATEXT_FONT).c
112
113CLEANFILES	+=		\
114	$(OBJS_DIR)/fb_swtch_src.o \
115	$(OBJS_DIR)/fb_swtch_src \
116	$(OBJS_DIR)/fb_swtch.s
117
118CLEANFILES	+= \
119	$(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.o) \
120	$(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.ln)
121
122CLOBBERFILES	= $(CLEANFILES) $(UNIX_BIN)
123CLEANLINTFILES	+= $(LINT_LIB) $(DBOOT_LINT_LIB) $(DBOOT_LINTS)
124
125# instr_size needs a special header
126$(OBJS_DIR)/instr_size.o :=	EXTRA_OPTIONS	= -I$(SRC)/common/dis/i386
127$(OBJS_DIR)/instr_size.ln :=	EXTRA_OPTIONS	= -I$(SRC)/common/dis/i386
128
129#
130# When performing shadow studio builds, the pre-processed comm page
131# output from gcc can end up confusing studio.
132#
133$(OBJS_DIR)/comm_page_ctf.o :=	CERRWARN += -_cc=-erroff=E_TKNS_IGNORED_AT_END_OF_DIR
134
135CFLAGS += -DDIS_MEM
136
137#
138# For now, disable these lint checks; maintainers should endeavor
139# to investigate and remove these for maximum lint coverage.
140# Please do not carry these forward to new Makefiles.
141#
142LINTTAGS	+= -erroff=E_BAD_PTR_CAST_ALIGN
143LINTTAGS	+= -erroff=E_SUSPICIOUS_COMPARISON
144LINTTAGS	+= -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
145LINTTAGS	+= -erroff=E_STATIC_UNUSED
146LINTTAGS	+= -erroff=E_PTRDIFF_OVERFLOW
147LINTTAGS	+= -erroff=E_ASSIGN_NARROW_CONV
148
149CERRWARN	+= -_gcc=-Wno-parentheses
150CERRWARN	+= -_gcc=-Wno-uninitialized
151CERRWARN	+= -_gcc=-Wno-char-subscripts
152CERRWARN	+= -_gcc=-Wno-unused-variable
153CERRWARN	+= -_gcc=-Wno-unused-function
154CERRWARN	+= -_gcc=-Wno-unused-label
155CERRWARN	+= -_gcc=-Wno-type-limits
156CERRWARN	+= -_gcc=-Wno-clobbered
157CERRWARN	+= -_gcc=-Wno-empty-body
158CERRWARN	+= -_gcc=-Wno-unused-value
159
160# false positives
161SMOFF += index_overflow
162
163# needs work
164SMOFF += all_func_returns,deref_check,signed
165
166$(OBJS_DIR)/fmsmb.o := SMOFF += indenting
167$(OBJS_DIR)/zutil.o := SMOFF += indenting
168$(OBJS_DIR)/bootrd_cpio.o := SMOFF += allocating_enough_data
169
170# Ensure that lint sees 'struct cpu' containing a fully declared
171# embedded 'struct machcpu'
172#
173LINTFLAGS	+= -D_MACHDEP -I../../i86pc
174
175#
176#	Default build targets.
177#
178.KEEP_STATE:
179
180def: $(DEF_DEPS)
181
182all: $(ALL_DEPS)
183
184clean: $(CLEAN_DEPS)
185
186clobber: $(CLOBBER_DEPS)
187
188lint: $(LINT_DEPS)
189
190clean.lint: $(CLEAN_LINT_DEPS)
191
192install: $(INSTALL_DEPS)
193
194MAPFILE_32 = $(MAPFILE)
195MAPFILE_64 = $(MAPFILE).amd64
196
197MAPFILE_NAME = $(MAPFILE_$(CLASS))
198
199$(UNIX_BIN):	$(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
200		$(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
201	$(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
202	    $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
203	    $(DTRACESTUBS)
204	$(MBH_PATCH) $(UNIX_BIN)
205	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
206	$(POST_PROCESS)
207
208$(UNIX_O):	$(OBJECTS) $(CTFEXTRAOBJS)
209	$(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
210
211$(DBOOT_BIN):	$(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
212	$(LD) -dn -e _start -M dboot/Mapfile.dboot \
213		-o $(DBOOT_BIN) $(DBOOT_OBJECTS)
214
215$(DBOOT_O):	$(DBOOT_BIN)
216	@echo "	.data"					> $(DBOOT_S)
217	@echo "	.globl	dboot_image"			>> $(DBOOT_S)
218	@echo "dboot_image:"				>> $(DBOOT_S)
219	$(ELFEXTRACT) $(DBOOT_BIN)			>> $(DBOOT_S)
220	$(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
221
222$(DBOOT_OBJS_DIR):
223	-@mkdir -p $@ 2> /dev/null
224
225$(COMMP_CTF_SRC):	$(UTSBASE)/i86pc/ml/comm_page.s
226	$(COMPILE.cpp) -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.s
227
228$(OBJS_DIR)/comm_page_ctf.o:	$(COMMP_CTF_SRC)
229	$(COMPILE.c) -o $@ $<
230	$(CTFCONVERT_O)
231
232#
233#	Special rules for generating assym.h for inclusion in assembly files.
234#
235$(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:	FRC
236	@cd $(DSF_DIR); $(MAKE) all.targ
237
238#
239#	The global lint target builds the kernel lint library (llib-lunix.ln)
240#	which is equivalent to a lint of /unix.o. Then all kernel modules for
241#	this architecture are linted against the kernel lint library.
242#
243#	Note:	lint errors in the kernel lint library will be repeated for
244#		each module. It is important that the kernel lint library
245#		be clean to keep the textual output to a reasonable level.
246#
247
248$(LINT_LIB):	$(LINT_LIB_DIR) $(LINTS)
249	@pwd
250	@-$(ECHO) "\n$(UNIX): (library construction):"
251	@$(LINT) -o$(UNIX) $(LINTFLAGS) $(LINTS)
252	@$(MV) $(@F) $@
253
254$(DBOOT_LINT_LIB):	$(LINT_LIB_DIR) $(DBOOT_LINTS)
255	@pwd
256	@-$(ECHO) "\n$(DBOOT): (library construction):"
257	@$(LINT) -o$(DBOOT) $(DBOOT_LINTFLAGS) $(DBOOT_LINTS)
258	@$(MV) $(@F) $@
259
260lintlib:	$(LINT_DEPS)
261
262#
263#	Include common targets.
264#
265include $(UTSBASE)/i86pc/Makefile.targ
266