xref: /illumos-gate/usr/src/uts/i86pc/unix/Makefile (revision 5d9d9091f564c198a760790b0bfa72c44e17912b)
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 2019 Joyent, Inc.
25# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
26
27#
28#	Path to the base of the uts directory tree (usually /usr/src/uts).
29#
30UTSBASE	= ../..
31
32#
33#	Define the module and object file sets.
34#
35UNIX		= unix
36DBOOT		= dboot
37
38OBJECTS		= $(SPECIAL_OBJS:%=$(OBJS_DIR)/%) \
39		  $(CORE_OBJS:%=$(OBJS_DIR)/%) \
40		  $(KRTLD_OBJS:%=$(OBJS_DIR)/%) \
41		  $(MACH_NOT_YET_KMODS:%=$(OBJS_DIR)/%)
42
43ROOTMODULE	= $(ROOT_PSM_KERN_DIR)/$(UNIX)
44
45UNIX_BIN	= $(OBJS_DIR)/$(UNIX)
46
47LIBS		= $(GENLIB)
48
49GENUNIX		= genunix
50GENUNIX_DIR	= ../../intel/$(GENUNIX)
51
52LIBOPTS		= -L $(GENUNIX_DIR)/$(OBJS_DIR) -l $(GENUNIX)
53
54COMMP_CTF_SRC	= $(OBJS_DIR)/comm_page_ctf.c
55
56CTFEXTRAOBJS	= $(OBJS_DIR)/vers.o $(OBJS_DIR)/comm_page_ctf.o
57
58DBOOT_OBJS_DIR	= dboot/$(OBJS_DIR)
59DBOOT_OBJECTS	= $(DBOOT_OBJS:%=$(DBOOT_OBJS_DIR)/%)
60DBOOT_BIN	= $(DBOOT_OBJS_DIR)/$(DBOOT)
61DBOOT_O		= $(OBJS_DIR)/$(DBOOT).o
62DBOOT_S		= $(DBOOT_O:%.o=%.s)
63
64#
65#	Include common rules.
66#
67include $(UTSBASE)/i86pc/Makefile.i86pc
68
69#
70#	Define targets
71#
72ALL_TARGET	= $(UNIX_BIN)
73INSTALL_TARGET	= $(UNIX_BIN) $(ROOTMODULE)
74
75#
76#	This is UNIX_DIR. Use a short path.
77#
78UNIX_DIR	= .
79
80#
81#	Overrides
82#
83CLEANFILES	+=		\
84	$(UNIX_O) $(MODSTUBS_O)	\
85	$(OBJS_DIR)/vers.c \
86	$(OBJS_DIR)/dtracestubs.s \
87	$(DTRACESTUBS_O) $(DTRACESTUBS) \
88	$(CTFEXTRAOBJS) \
89	$(COMMP_CTF_SRC)
90
91CLEANFILES	+=		\
92	$(DBOOT_O) $(DBOOT_S)	\
93	$(DBOOT_OBJECTS)	\
94	$(OBJS_DIR)/bios_call_src.o \
95	$(OBJS_DIR)/bios_call_src \
96	$(OBJS_DIR)/bios_call.s \
97	$(DBOOT_BIN)
98
99CLEANFILES	+=		\
100	$(DBOOT_OBJS_DIR)/$(FONT).c \
101	$(OBJS_DIR)/$(FONT).c
102
103CLEANFILES	+=		\
104	$(OBJS_DIR)/fb_swtch_src.o \
105	$(OBJS_DIR)/fb_swtch_src \
106	$(OBJS_DIR)/fb_swtch.s
107
108CLEANFILES	+= $(ZLIB_OBJS:%.o=$(OBJS_DIR)/%.o)
109
110CLOBBERFILES	= $(CLEANFILES) $(UNIX_BIN)
111
112# instr_size needs a special header
113$(OBJS_DIR)/instr_size.o :=	EXTRA_OPTIONS	= -I$(SRC)/common/dis/i386
114
115#
116# When performing shadow studio builds, the pre-processed comm page
117# output from gcc can end up confusing studio.
118#
119$(OBJS_DIR)/comm_page_ctf.o :=	CERRWARN += -_cc=-erroff=E_TKNS_IGNORED_AT_END_OF_DIR
120
121CFLAGS += -DDIS_MEM
122
123#
124# For now, disable these checks; maintainers should endeavor
125# to investigate and remove these for maximum coverage.
126# Please do not carry these forward to new Makefiles.
127#
128CERRWARN	+= -_gcc=-Wno-char-subscripts
129CERRWARN	+= -_gcc=-Wno-unused-function
130
131# false positives
132SMOFF += index_overflow
133
134# needs work
135SMOFF += all_func_returns
136
137$(OBJS_DIR)/bootrd_cpio.o := SMOFF += allocating_enough_data
138
139# too hairy
140$(OBJS_DIR)/inflate.o := SMATCH=off
141
142#
143#	Default build targets.
144#
145.KEEP_STATE:
146
147def: $(DEF_DEPS)
148
149all: $(ALL_DEPS)
150
151clean: $(CLEAN_DEPS)
152
153clobber: $(CLOBBER_DEPS)
154
155install: $(INSTALL_DEPS)
156
157MAPFILE_32 = $(UNIX_MAPFILE)
158MAPFILE_64 = $(UNIX_MAPFILE).amd64
159
160MAPFILE_NAME = $(MAPFILE_$(CLASS))
161
162$(UNIX_BIN):	$(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
163		$(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
164	$(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
165	    $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
166	    $(DTRACESTUBS)
167	$(MBH_PATCH) $(UNIX_BIN)
168	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
169	$(POST_PROCESS)
170
171$(UNIX_O):	$(OBJECTS) $(CTFEXTRAOBJS)
172	$(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
173
174$(DBOOT_BIN):	$(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
175	$(LD) -dn -e _start -M dboot/Mapfile.dboot \
176		-o $(DBOOT_BIN) $(DBOOT_OBJECTS)
177
178$(DBOOT_O):	$(DBOOT_BIN)
179	@echo "	.data"					> $(DBOOT_S)
180	@echo "	.globl	dboot_image"			>> $(DBOOT_S)
181	@echo "dboot_image:"				>> $(DBOOT_S)
182	$(ELFEXTRACT) $(DBOOT_BIN)			>> $(DBOOT_S)
183	$(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
184
185$(DBOOT_OBJS_DIR):
186	-@mkdir -p $@ 2> /dev/null
187
188$(COMMP_CTF_SRC):	$(UTSBASE)/i86pc/ml/comm_page.S
189	$(COMPILE.cpp) -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.S
190
191$(OBJS_DIR)/comm_page_ctf.o:	$(COMMP_CTF_SRC)
192	$(COMPILE.c) -o $@ $<
193	$(CTFCONVERT_O)
194
195#
196#	Special rules for generating assym.h for inclusion in assembly files.
197#
198$(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:	FRC
199	@cd $(DSF_DIR); $(MAKE) all.targ
200
201#
202#	Include common targets.
203#
204include $(UTSBASE)/i86pc/Makefile.targ
205