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