xref: /illumos-gate/usr/src/uts/i86pc/unix/Makefile (revision 34bbc83afbf22a6f8e504cb99d76c97c017cb5f4)
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
115CFLAGS += -DDIS_MEM
116
117#
118# For now, disable these checks; maintainers should endeavor
119# to investigate and remove these for maximum coverage.
120# Please do not carry these forward to new Makefiles.
121#
122CERRWARN	+= -_gcc=-Wno-char-subscripts
123CERRWARN	+= -_gcc=-Wno-unused-function
124
125# false positives
126SMOFF += index_overflow
127
128# needs work
129SMOFF += all_func_returns
130
131$(OBJS_DIR)/bootrd_cpio.o := SMOFF += allocating_enough_data
132
133# too hairy
134$(OBJS_DIR)/inflate.o := SMATCH=off
135
136#
137#	Default build targets.
138#
139.KEEP_STATE:
140
141def: $(DEF_DEPS)
142
143all: $(ALL_DEPS)
144
145clean: $(CLEAN_DEPS)
146
147clobber: $(CLOBBER_DEPS)
148
149install: $(INSTALL_DEPS)
150
151MAPFILE_32 = $(UNIX_MAPFILE)
152MAPFILE_64 = $(UNIX_MAPFILE).amd64
153
154MAPFILE_NAME = $(MAPFILE_$(CLASS))
155
156$(UNIX_BIN):	$(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
157		$(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
158	$(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
159	    $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
160	    $(DTRACESTUBS)
161	$(MBH_PATCH) $(UNIX_BIN)
162	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
163	$(POST_PROCESS)
164
165$(UNIX_O):	$(OBJECTS) $(CTFEXTRAOBJS)
166	$(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
167
168$(DBOOT_BIN):	$(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
169	$(LD) -dn -e _start -M dboot/Mapfile.dboot \
170		-o $(DBOOT_BIN) $(DBOOT_OBJECTS)
171
172$(DBOOT_O):	$(DBOOT_BIN)
173	@echo "	.data"					> $(DBOOT_S)
174	@echo "	.globl	dboot_image"			>> $(DBOOT_S)
175	@echo "dboot_image:"				>> $(DBOOT_S)
176	$(ELFEXTRACT) $(DBOOT_BIN)			>> $(DBOOT_S)
177	$(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
178
179$(DBOOT_OBJS_DIR):
180	-@mkdir -p $@ 2> /dev/null
181
182$(COMMP_CTF_SRC):	$(UTSBASE)/i86pc/ml/comm_page.S
183	$(COMPILE.cpp) -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.S
184
185$(OBJS_DIR)/comm_page_ctf.o:	$(COMMP_CTF_SRC)
186	$(COMPILE.c) -o $@ $<
187	$(CTFCONVERT_O)
188
189#
190#	Special rules for generating assym.h for inclusion in assembly files.
191#
192$(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:	FRC
193	@cd $(DSF_DIR); $(MAKE) all.targ
194
195#
196#	Include common targets.
197#
198include $(UTSBASE)/i86pc/Makefile.targ
199