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.
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.
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]
22 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
23 # Copyright (c) 2015, Joyent, Inc. All rights reserved.
24 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
25 # Copyright 2013 Garrett D'Amore <garrett@damore.org>
27 # Copyright 2011 Nexenta Systems, Inc. All rights reserved.
28 # Use is subject to license terms.
31 LIBCDIR= $(SRC)/lib/libc
37 # objects are grouped by source directory
39 # Symbol capabilities objects.
41 $(LIBCDIR)/capabilities/sun4u/sparcv9/pics/symcap.o \
42 $(LIBCDIR)/capabilities/sun4u-opl/sparcv9/pics/symcap.o \
43 $(LIBCDIR)/capabilities/sun4u-us3-hwcap1/sparcv9/pics/symcap.o \
44 $(LIBCDIR)/capabilities/sun4u-us3-hwcap2/sparcv9/pics/symcap.o \
45 $(LIBCDIR)/capabilities/sun4v-hwcap1/sparcv9/pics/symcap.o \
46 $(LIBCDIR)/capabilities/sun4v-hwcap2/sparcv9/pics/symcap.o
114 $(__GNUC)FPASMOBJS += \
144 arc4random_uniform.o \
167 sync_instruction_memory.o
169 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
170 # This macro should ALWAYS be empty; native APIs are already 'large file'.
312 _lwp_mutex_unlock.o \
318 sparc_utrap_install.o \
326 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
327 # This macro should ALWAYS be empty; native APIs are already 'large file'.
330 # objects from source under $(LIBCDIR)/port
366 ascii_strncasecmp.o \
625 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
626 # This macro should ALWAYS be empty; native APIs are already 'large file'.
872 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
873 # This macro should ALWAYS be empty; native APIs are already 'large file'.
987 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
988 # modules whose source is provided in the $(SRC)/lib/common directory.
989 # This must be done because otherwise the Sun C compiler would insert
990 # its own versions of these modules and those versions contain code
991 # to call out to C++ initialization functions. Such C++ initialization
992 # functions can call back into libc before thread initialization is
993 # complete and this leads to segmentation violations and other problems.
994 # Since libc contains no C++ code, linking with the minimal crti.o and
995 # crtn.o modules is safe and avoids the problems described above.
996 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
997 CRTSRCS= ../../common/sparcv9
999 # include common library definitions
1000 include $(SRC)/lib/Makefile.lib
1001 include $(SRC)/lib/Makefile.lib.64
1003 # we need to override the default SONAME here because we might
1004 # be building a variant object (still libc.so.1, but different filename)
1007 CFLAGS64 += $(CCVERBOSE)
1009 # This is necessary to avoid problems with calling _ex_unwind().
1010 # We probably don't want any inlining anyway.
1011 CFLAGS64 += -xinline=
1013 CERRWARN += -_gcc=-Wno-parentheses
1014 CERRWARN += -_gcc=-Wno-switch
1015 CERRWARN += -_gcc=-Wno-uninitialized
1016 CERRWARN += -_gcc=-Wno-unused-value
1017 CERRWARN += -_gcc=-Wno-unused-label
1018 CERRWARN += -_gcc=-Wno-unused-variable
1019 CERRWARN += -_gcc=-Wno-type-limits
1020 CERRWARN += -_gcc=-Wno-char-subscripts
1021 CERRWARN += -_gcc=-Wno-clobbered
1022 CERRWARN += -_gcc=-Wno-unused-function
1023 CERRWARN += -_gcc=-Wno-address
1025 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1026 # enables ASSERT() checking in the threads portion of the library.
1027 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1029 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1031 # Make string literals read-only to save memory.
1032 CFLAGS64 += $(XSTRCONST)
1034 ALTPICS= $(TRACEOBJS:%=pics/%)
1036 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
1038 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1040 sparcv9_C_PICFLAGS= -K PIC
1041 CFLAGS64 += $(EXTN_CFLAGS)
1042 CPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1043 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1044 ASFLAGS= $(EXTN_ASFLAGS) -K PIC -P -D__STDC__ -D_ASM -D__sparcv9 $(CPPFLAGS) \
1047 # As a favor to the dtrace syscall provider, libc still calls the
1048 # old syscall traps that have been obsoleted by the *at() interfaces.
1049 # Delete this to compile libc using only the new *at() system call traps
1050 CPPFLAGS += -D_RETAIN_OLD_SYSCALLS
1052 # Inform the run-time linker about libc specialized initialization
1053 RTLDINFO = -z rtldinfo=tls_rtldinfo
1054 DYNFLAGS += $(RTLDINFO)
1056 # Force libc's internal references to be resolved immediately upon loading
1057 # in order to avoid critical region problems. Since almost all libc symbols
1058 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1061 DYNFLAGS += $(EXTN_DYNFLAGS)
1063 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1065 # Override this top level flag so the compiler builds in its native
1066 # C99 mode. This has been enabled to support the complex arithmetic
1068 C99MODE= $(C99_ENABLE)
1070 # libc method of building an archive
1071 # The "$(GREP) -v ' L '" part is necessary only until
1072 # lorder is fixed to ignore thread-local variables.
1073 BUILD.AR= $(RM) $@ ; \
1074 $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1076 # extra files for the clean target
1078 $(LIBCDIR)/port/gen/errlst.c \
1079 $(LIBCDIR)/port/gen/new_list.c \
1086 CLOBBERFILES += $(LIB_PIC)
1088 # list of C source for lint
1090 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1091 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1092 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1093 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1094 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1095 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1096 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1097 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1098 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1099 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1100 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1101 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1102 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1103 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1104 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1105 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1106 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1107 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1108 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1109 $(FPOBJS64:%.o=$(LIBCBASE)/fp/%.c) \
1110 $(LIBCBASE)/crt/_ftou.c \
1111 $(LIBCBASE)/gen/_xregs_clrptr.c \
1112 $(LIBCBASE)/gen/byteorder.c \
1113 $(LIBCBASE)/gen/ecvt.c \
1114 $(LIBCBASE)/gen/getctxt.c \
1115 $(LIBCBASE)/gen/makectxt.c \
1116 $(LIBCBASE)/gen/siginfolst.c \
1117 $(LIBCBASE)/gen/siglongjmp.c \
1118 $(LIBCBASE)/gen/swapctxt.c
1120 # conditional assignments
1121 $(DYNLIB) := CRTI = crti.o
1122 $(DYNLIB) := CRTN = crtn.o
1124 # Files which need the threads .il inline template
1159 thread_interface.o \
1165 $(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/sparcv9.il
1167 # Files in fp, port/fp subdirectories that need base.il inline template
1172 $(IL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/fp/base.il
1174 # Files in fp subdirectory which need __quad.il inline template
1193 $(QIL:%=pics/%) := CFLAGS64 += $(LIBCDIR)/$(MACH)/fp/__quad.il
1194 pics/_Qp%.o := CFLAGS64 += -I$(LIBCDIR)/$(MACH)/fp
1195 pics/_Q%.o := sparcv9_COPTFLAG = -xO4 -xchip=ultra
1197 # Files in crt subdirectory which need muldiv64.il inline template
1198 #CIL= mul64.o divrem64.o
1199 #$(CIL:%=pics/%) := CFLAGS += $(LIBCBASE)/crt/mul64.il
1201 # large-file-aware components that should be built large
1203 #$(COMSYSOBJS64:%=pics/%) := \
1204 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1206 #$(SYSOBJS64:%=pics/%) := \
1207 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1209 #$(PORTGEN64:%=pics/%) := \
1210 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1212 #$(PORTSTDIO64:%=pics/%) := \
1213 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1215 #$(PORTSYS64:%=pics/%) := \
1216 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1218 $(PORTSTDIO_W:%=pics/%) := \
1221 $(PORTPRINT_W:%=pics/%) := \
1224 $(PORTI18N_COND:%=pics/%) := \
1225 CPPFLAGS += -D_WCS_LONGLONG
1227 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1229 # Files which need extra optimization
1230 pics/getenv.o := sparcv9_COPTFLAG = -xO4
1234 all: $(LIBS) $(LIB_PIC)
1236 lint := CPPFLAGS += -I$(LIBCDIR)/$(MACH)/fp
1237 lint := CPPFLAGS += -D_MSE_INT_H -D_LCONV_C99
1238 lint := LINTFLAGS64 += -mn
1241 @echo $(LINT.c) ... $(LDLIBS)
1242 @$(LINT.c) $(SRCS) $(LDLIBS)
1244 $(LINTLIB):= SRCS=$(LIBCDIR)/port/llib-lc
1245 $(LINTLIB):= CPPFLAGS += -D_MSE_INT_H
1246 $(LINTLIB):= LINTFLAGS64=-nvx -m64
1248 # object files that depend on inline template
1249 $(TIL:%=pics/%): $(LIBCBASE)/threads/sparcv9.il
1250 $(IL:%=pics/%): $(LIBCBASE)/fp/base.il
1251 $(QIL:%=pics/%): $(LIBCDIR)/$(MACH)/fp/__quad.il
1252 #$(CIL:%=pics/%): $(LIBCBASE)/crt/muldiv64.il
1254 # include common libc targets
1255 include $(LIBCDIR)/Makefile.targ
1257 # We need to strip out all CTF and DOF data from the static library
1258 $(LIB_PIC) := DIR = pics
1259 $(LIB_PIC): pics $$(PICS)
1261 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1262 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1263 $(AR) -ts $@ > /dev/null
1267 #$(STRETS:%=pics/%): crt/stret.s
1268 # $(AS) $(ASFLAGS) -DSTRET$(@F:stret%.o=%) crt/stret.s -o $@
1271 #crt/_rtbootld.s: crt/_rtboot.s crt/_rtld.c
1272 # $(CC) $(CPPFLAGS) -O -S -K pic crt/_rtld.c -o crt/_rtld.s
1273 # $(CAT) crt/_rtboot.s crt/_rtld.s > $@
1277 _lwp_mutex_unlock.o \
1286 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1288 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1290 # assym.h build rules
1292 assym.h := CFLAGS64 += -g
1294 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1296 genassym: $(GENASSYM_C)
1297 $(NATIVECC) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1298 $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1300 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1302 assym.h: $(OFFSETS) genassym
1303 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1306 # derived C source and related explicit dependencies
1307 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1308 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1310 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c