|
root / base / usr / src / Makefile
Makefile Makefile 280 lines 8.4 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved.
# Copyright 2016 Toomas Soome <tsoome@me.com>
# Copyright 2018 Joyent, Inc.
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
#

#
# Makefile for system source
#
# include global definitions
include Makefile.master
#
# the Targetdirs file is the AT&T target.dirs file in a makefile format.
# it defines TARGETDIRS and ROOTDIRS.
include Targetdirs

# Hammerhead: Build tier selection
# TIER=kernel  - Only kernel (uts/)
# TIER=base    - Kernel + essential libraries + commands
# TIER=all     - Everything (default)
TIER ?= all

ifeq ($(TIER),kernel)
COMMON_SUBDIRS=	uts
else ifeq ($(TIER),base)
COMMON_SUBDIRS=	data uts lib cmd zyginit
else
COMMON_SUBDIRS=	data uts lib cmd zyginit man test
endif

# Hammerhead: sparc_SUBDIRS removed - amd64 only build
# Hammerhead: Removed grub (legacy 32-bit BIOS bootloader, dmake-only Makefiles)
ifeq ($(TIER),kernel)
i386_SUBDIRS=
else
i386_SUBDIRS= boot
endif

SUBDIRS= $(COMMON_SUBDIRS) $($(MACH)_SUBDIRS)

HDRSUBDIRS=	uts head lib cmd

CHKHDRSUBDIRS=	head uts lib

#
# Headers that can be built in parallel
#
PARALLEL_HEADERS = sysheaders userheaders libheaders cmdheaders

#
# Directories that can be built in parallel
#
PARALLEL_DIRS = data uts lib man

# The check target also causes smf(7) service manifests to be validated.
CHKMFSTSUBDIRS=	cmd

# And man page formats
CHKMANSUBDIRS = man

MSGSUBDIRS=	cmd lib data

all :			TARGET= all
install :		TARGET= install
install1 :		TARGET= install
install2 :		TARGET= install
install_h :		TARGET= install_h
clean :		TARGET= clean
clobber :		TARGET= clobber
check :		TARGET= check

.KEEP_STATE:

#
# Note: install does not cause a build in pkg.  To build packages,
#	cd pkg and do a 'make install'
#

# Hammerhead: Removed closedbins and pkg (IPS packaging to be eliminated
# in Phase 3; pkg/Makefile has GNU Make incompatibilities)
all: mapfiles sgs .WAIT $(SUBDIRS)

#
# The _msg build is a two-step process.  First, the _msg dependency
# causes recursive makes in $(MSGSUBDIRS), which stages raw message
# files in $(ROOT)/catalog.  Second, the action from the install
# target rule causes those messages to be post-processed from where
# they were staged in $(ROOT)/catalog, and the results placed into the
# proto area.
#
# The stage-licenses target causes the license files needed for
# packaging to be pulled from $(SRC) and $(CLOSED) and staged in
# $(ROOT)/licenses.
#
# Hammerhead: .WAIT ensures install2 (headers + lib + cmd) completes before
# _msg runs gcc -E on cmd/ sources (which need headers in proto area).
install: install1 install2 .WAIT _msg stage-licenses
	@cd msg; pwd; $(MAKE) _msg
	@rm -rf "$(ROOT)/catalog"

# Hammerhead: stage-licenses disabled (IPS packaging removed)
stage-licenses:

install1: mapfiles sgs

install2: install1 .WAIT $(SUBDIRS)

# Hammerhead: $(ROOTDIRS) must wait for bldtools (which builds the install
# binary). Without this, _msg triggers rootdirs in parallel with install1,
# and the install binary doesn't exist yet when $(INS.dir) runs.

_msg: rootdirs FRC
	@for m in $(MSGSUBDIRS); do \
		cd $$m; pwd; $(MAKE) _msg; cd ..; \
	done

mapfiles: bldtools
	@cd common/mapfiles; pwd; $(MAKE) install

clean: $(SUBDIRS) head
clobber: $(SUBDIRS) head clobber_local
clobber_local:
	# Hammerhead: tools clobber removed - hh-build manages tools proto lifecycle
	# to avoid race with bootstrap_tools (initial clobber was destroying tools
	# proto after bootstrap had already populated it)
	@cd common/mapfiles; pwd; $(MAKE) clobber
	@cd msg; pwd; $(MAKE) clobber

# Hammerhead: closedbins is a no-op - we don't use closed binaries
closedbins: FRC
	@$(ECHO) "Hammerhead: Skipping closedbins (not using closed binaries)"

#
# Declare what parts can be built in parallel
# DUMMY at the end is used in case macro expansion produces an empty string to
# prevent everything going in parallel
#
.PARALLEL: $(PARALLEL_HEADERS) DUMMY
.PARALLEL: $(PARALLEL_DIRS) DUMMY

# Hammerhead: Build ordering is controlled by SUBDIRS list order
# (data uts lib cmd man test boot).
# Nightly runs without -j (serial), so list order ensures lib builds
# before cmd. Explicit ordering deps (cmd: lib) are NOT used because
# GNU Make -k skips dependents when prerequisites fail — even with
# order-only (|) prerequisites. This caused cmd to never be dispatched
# when lib had partial failures, resulting in zero commands in proto.

$(SUBDIRS) head: FRC
	@cd $@; pwd; $(MAKE) $(TARGET)

# librpcsvc has a dependency on headers installed by
# userheaders, hence the .WAIT before libheaders.
# Hammerhead: .WAIT between mapfiles and rootdirs ensures the onbld install
# tool (built by bldtools via mapfiles) is available before rootdirs uses it.
sgs: mapfiles .WAIT rootdirs .WAIT sysheaders userheaders .WAIT \
	libheaders cmdheaders

#
# Top-level setup target to setup the development environment that includes
# headers, tools and generated mapfiles.
# Hammerhead: Removed closedbins dependency - we don't use closed binaries
#
setup: bldtools sgs mapfiles

#
# Always build tools as non-DEBUG.
# When nightly launches a build it first builds non-DEBUG tools and then
# configures the environment so that these tools are used for building
# subsequently. If a recursive build from usr/src then builds DEBUG tools,
# the tools will be rebuilt using themselves resulting in a race condition
# that can cause the build to fail - see https://www.illumos.org/issues/10462
# for more details.
# A manual build in usr/src/tools in a DEBUG bldenv will still do a DEBUG
# tools build.
#
# Hammerhead: skip tools rebuild if pre-seeded onbld tools exist.
# On self-hosted builds, the tools phase has lex/yacc GCC 14 issues.
# Pre-seeded tools from an OI build are used instead.
bldtools:
	@if [ -x $(ONBLD_TOOLS)/bin/$(MACH)/sgsmsg ]; then \
		echo "Using pre-seeded onbld tools"; \
	else \
		cd tools; pwd; $(MAKE) RELEASE_BUILD= install; \
	fi

rootdirs: $(ROOTDIRS)

$(ROOTDIRS): | bldtools
	$(INS.dir)

userheaders: FRC
	@cd head; pwd; $(MAKE) install_h

libheaders: bldtools
	@cd lib; pwd; $(MAKE) install_h

sysheaders: FRC
	@cd uts; pwd; $(MAKE) install_h

cmdheaders: FRC
	@cd cmd/devfsadm; pwd; $(MAKE) install_h
	@cd cmd/fm; pwd; $(MAKE) install_h
	@cd cmd/mdb; pwd; $(MAKE) install_h

FRC:

# Hammerhead: Sysroot tarball for Coral (Tier 2) consumption.
# Creates a tarball of the proto area containing headers, libraries,
# and essential commands that Tier 2 packages build against.
sysroot:
	@$(ECHO) "Creating sysroot tarball from proto area..."
	cd $(ROOT) && gtar czf $(SRC)/sysroot-$(MACH64).tar.gz \
		--exclude='*.o' --exclude='*.a' \
		./bin ./sbin ./lib ./usr/lib ./usr/bin ./usr/sbin \
		./usr/include ./kernel
	@$(ECHO) "Sysroot tarball: $(SRC)/sysroot-$(MACH64).tar.gz"

check:	$(CHKHDRSUBDIRS) $(CHKMFSTSUBDIRS) $(CHKMANSUBDIRS)

#
# Cross-reference customization: skip all of the subdirectories that
# don't contain actual source code.
#
XRPRUNE = prototypes
XRINCDIRS = uts/common head

include Makefile.xref

XREFFLAGS = -f -x

# used by hh-build
cc-version:
	@$(GNUC_ROOT)/bin/gcc --version 2>&1 | head -1

cc64-version:

java-version:
	@if [ -x "$(JAVAC)" ]; then			\
		$(ECHO) $(JAVAC);			\
		$(JAVA_ROOT)/bin/java -fullversion 2>&1 | head -1;	\
	else						\
		$(ECHO) No Java compiler found;		\
	fi

openssl-version:
	@if [ -x "$(OPENSSL)" ]; then				\
		$(ECHO) $(OPENSSL);				\
		$(OPENSSL) version;				\
		$(OPENSSL) version -f |				\
		    $(SED) -n '/_API/{s/.*_API/    API/;s/ -.*//;p;}'; \
	else							\
		$(ECHO) No OpenSSL utility found;		\
	fi