Makefile revision 1767006bb066ef500b90b432fba79d63d0d09b36
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER START
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# The contents of this file are subject to the terms of the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Common Development and Distribution License (the "License").
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You may not use this file except in compliance with the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# See the License for the specific language governing permissions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# and limitations under the License.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# When distributing Covered Code, include this CDDL HEADER in each
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
5dbfd19ad5fcc2b779f40f80fa05c1bd28fd0b4eTheo Schlossnagle# If applicable, add the following below this CDDL HEADER, with the
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore# fields enclosed by brackets "[]" replaced with your own identifying
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchi# information: Portions Copyright [yyyy] [name of copyright owner]
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CDDL HEADER END
a9478106a12424322498e53cf7cd75bd8a4d6004Yuri Pankov# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright (c) 2015, Joyent, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright 2013 Garrett D'Amore <garrett@damore.org>
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Use is subject to license terms.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# objects are grouped by source directory
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# local objects
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Preserved solely to ease maintenance of 32-bit and 64-bit library builds
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This macro should ALWAYS be empty; native APIs are already 'large file'.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Preserved solely to ease maintenance of 32-bit and 64-bit library builds
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This macro should ALWAYS be empty; native APIs are already 'large file'.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# objects from source under $(LIBCDIR)/port
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Preserved solely to ease maintenance of 32-bit and 64-bit library builds
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This macro should ALWAYS be empty; native APIs are already 'large file'.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Preserved solely to ease maintenance of 32-bit and 64-bit library builds
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This macro should ALWAYS be empty; native APIs are already 'large file'.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# modules whose source is provided in the $(SRC)/lib/common directory.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This must be done because otherwise the Sun C compiler would insert
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# its own versions of these modules and those versions contain code
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# to call out to C++ initialization functions. Such C++ initialization
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# functions can call back into libc before thread initialization is
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# complete and this leads to segmentation violations and other problems.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Since libc contains no C++ code, linking with the minimal crti.o and
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# crtn.o modules is safe and avoids the problems described above.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# include common library definitions
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This is necessary to avoid problems with calling _ex_unwind().
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# We probably don't want any inlining anyway.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# enables ASSERT() checking in the threads portion of the library.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# This is automatically enabled for DEBUG builds, not for non-debug builds.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe$(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Make string literals read-only to save memory
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe$(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweCPPFLAGS= -D_REENTRANT -D$(MACH64) -D__$(MACH64) $(THREAD_DEBUG) \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe -I. -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
c10c16dec587a0662068f6e2991c29ed3a9db943Richard LoweASFLAGS= $(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(CPPFLAGS) \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# As a favor to the dtrace syscall provider, libc still calls the
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# old syscall traps that have been obsoleted by the *at() interfaces.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Delete this to compile libc using only the new *at() system call traps
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# proc64_id.o is built with defines in $(SRC)/uts/intel/sys/x86_archext.h
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowepics/proc64_id.o := CFLAGS64 += -I$(SRC)/uts/intel
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Inform the run-time linker about libc specialized initialization
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Force libc's internal references to be resolved immediately upon loading
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# in order to avoid critical region problems. Since almost all libc symbols
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Override this top level flag so the compiler builds in its native
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# C99 mode. This has been enabled to support the complex arithmetic
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# added to libc.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# libc method of building an archive
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# The "$(GREP) -v ' L '" part is necessary only until
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# lorder is fixed to ignore thread-local variables.
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# extra files for the clean target
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# list of C source for lint
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe $(FPOBJS:%.o=fp/%.c) \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# conditional assignments
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# $(DYNLIB) $(LIB_PIC) := DYNOBJS = _rtbootld.o
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# Files which need the threads .il inline template
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe$(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/amd64.il
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# pics/mul64.o := CFLAGS64 += crt/mul64.il
ead9bb4b1be81d7bbf8ed86ee41d6c1e58b069a3Yuri Pankov# large-file-aware components that should be built large
bad51a906c423d0d7ab33fcc1a4e317d789e3c49Robert Mustacchi#$(COMSYSOBJS64:%=pics/%) := \
bad51a906c423d0d7ab33fcc1a4e317d789e3c49Robert Mustacchi# CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore#$(SYSOBJS64:%=pics/%) := \
bad51a906c423d0d7ab33fcc1a4e317d789e3c49Robert Mustacchi# CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#$(PORTGEN64:%=pics/%) := \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#$(PORTSTDIO64:%=pics/%) := \
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore# CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe#$(PORTSYS64:%=pics/%) := \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowepics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowelint := LINTFLAGS64 += -mn -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# object files that depend on inline template
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# include common libc targets
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# We need to strip out all CTF data from the static library
cb66c7814563eb32e20c1be88ae738ad8d63079dRobert Mustacchi $(NATIVECC) -Iinc -I$(LIBCDIR)/inc $(CPPFLAGS.native) \
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe# derived C source and related explicit dependencies
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe$(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
c10c16dec587a0662068f6e2991c29ed3a9db943Richard Lowe cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist