xref: /illumos-gate/usr/src/uts/i86pc/unix/Makefile (revision 44af466baa3420f5636d8d7d1c9279f8bf27ce23)
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# too hairy
132$(OBJS_DIR)/inflate.o := SMATCH=off
133
134#
135#	Default build targets.
136#
137.KEEP_STATE:
138
139def: $(DEF_DEPS)
140
141all: $(ALL_DEPS)
142
143clean: $(CLEAN_DEPS)
144
145clobber: $(CLOBBER_DEPS)
146
147install: $(INSTALL_DEPS)
148
149MAPFILE_32 = $(UNIX_MAPFILE)
150MAPFILE_64 = $(UNIX_MAPFILE).amd64
151
152MAPFILE_NAME = $(MAPFILE_$(CLASS))
153
154$(UNIX_BIN):	$(UNIX_O) $(MODSTUBS_O) $(MAPFILE_NAME) \
155		$(GENLIB) $(DTRACESTUBS) $(DBOOT_O)
156	$(LD) -dy -b -o $@ -e dboot_image -znointerp -M $(MAPFILE_NAME) \
157	    $(UNIX_O) $(DBOOT_O) $(MODSTUBS_O) $(LIBOPTS) \
158	    $(DTRACESTUBS)
159	$(MBH_PATCH) $(UNIX_BIN)
160	$(CTFMERGE_UNIQUIFY_AGAINST_GENUNIX)
161	$(POST_PROCESS)
162
163$(UNIX_O):	$(OBJECTS) $(CTFEXTRAOBJS)
164	$(LD) -r -o $@ $(OBJECTS) $(OBJS_DIR)/vers.o
165
166$(DBOOT_BIN):	$(DBOOT_OBJS_DIR) $(DBOOT_OBJECTS) dboot/Mapfile.dboot
167	$(LD) -dn -e _start -M dboot/Mapfile.dboot \
168		-o $(DBOOT_BIN) $(DBOOT_OBJECTS)
169
170$(DBOOT_O):	$(DBOOT_BIN)
171	@echo "	.data"					> $(DBOOT_S)
172	@echo "	.globl	dboot_image"			>> $(DBOOT_S)
173	@echo "dboot_image:"				>> $(DBOOT_S)
174	$(ELFEXTRACT) $(DBOOT_BIN)			>> $(DBOOT_S)
175	$(COMPILE.s) -o $(DBOOT_O) $(DBOOT_S)
176
177$(DBOOT_OBJS_DIR):
178	-@mkdir -p $@ 2> /dev/null
179
180$(COMMP_CTF_SRC):	$(UTSBASE)/i86pc/ml/comm_page.S
181	$(COMPILE.cpp) -D_GENCTF -o $@ $(UTSBASE)/i86pc/ml/comm_page.S
182
183$(OBJS_DIR)/comm_page_ctf.o:	$(COMMP_CTF_SRC)
184	$(COMPILE.c) -o $@ $<
185	$(CTFCONVERT_O)
186
187#
188#	Special rules for generating assym.h for inclusion in assembly files.
189#
190$(DSF_DIR)/$(OBJS_DIR)/assym.h $(DSF_DIR)/$(OBJS_DIR)/kdi_assym.h:	FRC
191	@cd $(DSF_DIR); $(MAKE) all.targ
192
193#
194#	Include common targets.
195#
196include $(UTSBASE)/i86pc/Makefile.targ
197