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