b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# CDDL HEADER START
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# The contents of this file are subject to the terms of the
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Common Development and Distribution License (the "License").
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# You may not use this file except in compliance with the License.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# See the License for the specific language governing permissions
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# and limitations under the License.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# When distributing Covered Code, include this CDDL HEADER in each
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# If applicable, add the following below this CDDL HEADER, with the
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# fields enclosed by brackets "[]" replaced with your own identifying
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# information: Portions Copyright [yyyy] [name of copyright owner]
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# CDDL HEADER END
794f0adb050e571bbfde4d2a19b9f88b852079ddRoger A. Faulkner# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
fc2512cfb727d49529d8ed99164db871f4829b73Robert Mustacchi# Copyright 2016 Joyent, Inc.
5dbfd19ad5fcc2b779f40f80fa05c1bd28fd0b4eTheo Schlossnagle# Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
2d08521bd15501c8370ba2153b9cca4f094979d0Garrett D'Amore# Copyright 2013 Garrett D'Amore <garrett@damore.org>
475b496bc008381e64c802250441cc256622ce91Garrett D'Amore# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore# Use is subject to license terms.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# objects are grouped by source directory
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans# Symbol capabilities objects.
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4u/sparc/pics/symcap.o \
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4u-opl/sparc/pics/symcap.o \
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4u-us3-hwcap1/sparc/pics/symcap.o \
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4u-us3-hwcap2/sparc/pics/symcap.o \
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4v-hwcap1/sparc/pics/symcap.o \
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans $(LIBCDIR)/capabilities/sun4v-hwcap2/sparc/pics/symcap.o
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# local objects
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# sysobjs that contain large-file interfaces
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# objects under $(LIBCDIR)/port which contain transitional large file interfaces
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# objects from source under $(LIBCDIR)/port
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# c89 variants to support 32-bit size of c89 u/intmax_t (32-bit libc only)
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# portable stdio objects that contain large file interfaces.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Note: fopen64 is a special case, as we build it small.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# objects that implement the transitional large file API
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# modules whose source is provided in the $(SRC)/lib/common directory.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# This must be done because otherwise the Sun C compiler would insert
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# its own versions of these modules and those versions contain code
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# to call out to C++ initialization functions. Such C++ initialization
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# functions can call back into libc before thread initialization is
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# complete and this leads to segmentation violations and other problems.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Since libc contains no C++ code, linking with the minimal crti.o and
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# crtn.o modules is safe and avoids the problems described above.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# include common library definitions
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# we need to override the default SONAME here because we might
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# be building a variant object (still libc.so.1, but different filename)
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# This is necessary to avoid problems with calling _ex_unwind().
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# We probably don't want any inlining anyway.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# enables ASSERT() checking in the threads portion of the library.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# This is automatically enabled for DEBUG builds, not for non-debug builds.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Make string literals read-only to save memory.
1e49577a7fcde812700ded04431b49d67cc57d6dRod Evans$(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
b1593d50e783f7d66722dde093752b74ffa95176Jason BeloroCPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
b1593d50e783f7d66722dde093752b74ffa95176Jason BeloroASFLAGS= $(EXTN_ASFLAGS) -K pic -P -D__STDC__ -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
8fd04b8338ed5093ec2d1e668fa620b7de44c177Roger A. Faulkner# As a favor to the dtrace syscall provider, libc still calls the
8fd04b8338ed5093ec2d1e668fa620b7de44c177Roger A. Faulkner# old syscall traps that have been obsoleted by the *at() interfaces.
8fd04b8338ed5093ec2d1e668fa620b7de44c177Roger A. Faulkner# Delete this to compile libc using only the new *at() system call traps
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Inform the run-time linker about libc specialized initialization
32a6953793c636df949ca1ae3555438159bda3f6Roger A. Faulkner# Force libc's internal references to be resolved immediately upon loading
32a6953793c636df949ca1ae3555438159bda3f6Roger A. Faulkner# in order to avoid critical region problems. Since almost all libc symbols
32a6953793c636df949ca1ae3555438159bda3f6Roger A. Faulkner# are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Inform the kernel about the initial DTrace area (in case
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# libc is being used as the interpreter / runtime linker).
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# DTrace needs an executable data segment.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Override this top level flag so the compiler builds in its native
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# C99 mode. This has been enabled to support the complex arithmetic
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# added to libc.
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# libc method of building an archive
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner# The "$(GREP) -v ' L '" part is necessary only until
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner# lorder is fixed to ignore thread-local variables.
23a1ccea6aac035f084a7a4cdc968687d1b02dafRoger A. Faulkner $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# extra files for the clean target
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# list of C source for lint
4297a3b0d0a35d80f86fff155e288e885a100e6dGarrett D'Amore $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
d2a70789f056fc6c9ce3ab047b52126d80b0e3daRichard Lowe $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# conditional assignments
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Files which need the threads .il inline template
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(TIL:%=pics/%) := CFLAGS += $(LIBCBASE)/threads/sparc.il
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# special kludge for inlines with 'cas':
49b225e1cfa7bbf7738d4df0a03f18e3283426ebGavin Maltbypics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Files in port/fp subdirectory that need base.il inline template
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(IL:%=pics/%) := CFLAGS += $(LIBCBASE)/fp/base.il
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Files in fp subdirectory which need __quad.il inline template
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(QIL:%=pics/%) := CFLAGS += $(LIBCDIR)/$(MACH)/fp/__quad.il
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# large-file-aware components that should be built large
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
33e8313d921ed710d7c5957cea98e220a663a1d5Robert Mustacchi CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# printf/scanf functions to support c89-sized intmax_t variables
9d12795f87b63c2e39e87bff369182edd34677d3Robert Mustacchipics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# Files which need extra optimization
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# object files that depend on inline template
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(QIL:%=pics/%): $(LIBCDIR)/$(MACH)/fp/__quad.il
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# include common libc targets
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# We need to strip out all CTF and DOF data from the static library
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# special cases
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(AS) $(ASFLAGS) -DSTRET$(@F:stret%.o=%) $(LIBCBASE)/crt/stret.s -o $@
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# partially built from C source
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
7f11fd00fc23e2af7ae21cc8837a2b86380dcfa7Richard Lowe $(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro# derived C source and related explicit dependencies
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro$(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
b1593d50e783f7d66722dde093752b74ffa95176Jason Beloro cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist