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]
23 # Copyright 2016 Gary Mills
24 # Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 # Copyright (c) 2015, Joyent, Inc. All rights reserved.
26 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
27 # Copyright 2013 Garrett D'Amore <garrett@damore.org>
28 # Copyright 2017 Nexenta Systems, Inc.
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 \
168 sync_instruction_memory.o
170 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
171 # This macro should ALWAYS be empty; native APIs are already 'large file'.
314 _lwp_mutex_unlock.o \
320 sparc_utrap_install.o \
328 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
329 # This macro should ALWAYS be empty; native APIs are already 'large file'.
332 # objects from source under $(LIBCDIR)/port
368 ascii_strncasecmp.o \
633 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
634 # This macro should ALWAYS be empty; native APIs are already 'large file'.
880 # Preserved solely to ease maintenance of 32-bit and 64-bit library builds
881 # This macro should ALWAYS be empty; native APIs are already 'large file'.
1004 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1005 # modules whose source is provided in the $(SRC)/lib/common directory.
1006 # This must be done because otherwise the Sun C compiler would insert
1007 # its own versions of these modules and those versions contain code
1008 # to call out to C++ initialization functions. Such C++ initialization
1009 # functions can call back into libc before thread initialization is
1010 # complete and this leads to segmentation violations and other problems.
1011 # Since libc contains no C++ code, linking with the minimal crti.o and
1012 # crtn.o modules is safe and avoids the problems described above.
1013 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1014 CRTSRCS= ../../common/sparcv9
1016 # include common library definitions
1017 include $(SRC)/lib/Makefile.lib
1018 include $(SRC)/lib/Makefile.lib.64
1020 # we need to override the default SONAME here because we might
1021 # be building a variant object (still libc.so.1, but different filename)
1024 CFLAGS64 += $(CCVERBOSE)
1026 # This is necessary to avoid problems with calling _ex_unwind().
1027 # We probably don't want any inlining anyway.
1028 CFLAGS64 += -xinline=
1030 CERRWARN += -_gcc=-Wno-parentheses
1031 CERRWARN += -_gcc=-Wno-switch
1032 CERRWARN += -_gcc=-Wno-uninitialized
1033 CERRWARN += -_gcc=-Wno-unused-value
1034 CERRWARN += -_gcc=-Wno-unused-label
1035 CERRWARN += -_gcc=-Wno-unused-variable
1036 CERRWARN += -_gcc=-Wno-type-limits
1037 CERRWARN += -_gcc=-Wno-char-subscripts
1038 CERRWARN += -_gcc=-Wno-clobbered
1039 CERRWARN += -_gcc=-Wno-unused-function
1040 CERRWARN += -_gcc=-Wno-address
1042 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1043 # enables ASSERT() checking in the threads portion of the library.
1044 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1046 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1048 # Make string literals read-only to save memory.
1049 CFLAGS64 += $(XSTRCONST)
1051 ALTPICS= $(TRACEOBJS:%=pics/%)
1053 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
1055 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1057 sparcv9_C_PICFLAGS= -K PIC
1058 CFLAGS64 += $(EXTN_CFLAGS)
1059 CPPFLAGS= -D_REENTRANT -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1060 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1061 ASFLAGS= $(EXTN_ASFLAGS) -K PIC -P -D__STDC__ -D_ASM -D__sparcv9 $(CPPFLAGS) \
1064 # As a favor to the dtrace syscall provider, libc still calls the
1065 # old syscall traps that have been obsoleted by the *at() interfaces.
1066 # Delete this to compile libc using only the new *at() system call traps
1067 CPPFLAGS += -D_RETAIN_OLD_SYSCALLS
1069 # Inform the run-time linker about libc specialized initialization
1070 RTLDINFO = -z rtldinfo=tls_rtldinfo
1071 DYNFLAGS += $(RTLDINFO)
1073 # Force libc's internal references to be resolved immediately upon loading
1074 # in order to avoid critical region problems. Since almost all libc symbols
1075 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1078 DYNFLAGS += $(EXTN_DYNFLAGS)
1080 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1082 # Override this top level flag so the compiler builds in its native
1083 # C99 mode. This has been enabled to support the complex arithmetic
1085 C99MODE= $(C99_ENABLE)
1087 # libc method of building an archive
1088 # The "$(GREP) -v ' L '" part is necessary only until
1089 # lorder is fixed to ignore thread-local variables.
1090 BUILD.AR= $(RM) $@ ; \
1091 $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1093 # extra files for the clean target
1095 $(LIBCDIR)/port/gen/errlst.c \
1096 $(LIBCDIR)/port/gen/new_list.c \
1103 CLOBBERFILES += $(LIB_PIC)
1105 # list of C source for lint
1107 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1108 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1109 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1110 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1111 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1112 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1113 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1114 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1115 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1116 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1117 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1118 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1119 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1120 $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
1121 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1122 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1123 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1124 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1125 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1126 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1127 $(FPOBJS64:%.o=$(LIBCBASE)/fp/%.c) \
1128 $(LIBCBASE)/crt/_ftou.c \
1129 $(LIBCBASE)/gen/_xregs_clrptr.c \
1130 $(LIBCBASE)/gen/byteorder.c \
1131 $(LIBCBASE)/gen/endian.c \
1132 $(LIBCBASE)/gen/ecvt.c \
1133 $(LIBCBASE)/gen/getctxt.c \
1134 $(LIBCBASE)/gen/makectxt.c \
1135 $(LIBCBASE)/gen/siginfolst.c \
1136 $(LIBCBASE)/gen/siglongjmp.c \
1137 $(LIBCBASE)/gen/swapctxt.c
1139 # conditional assignments
1140 $(DYNLIB) := CRTI = crti.o
1141 $(DYNLIB) := CRTN = crtn.o
1143 # Files which need the threads .il inline template
1178 thread_interface.o \
1184 $(TIL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/threads/sparcv9.il
1186 # Files in fp, port/fp subdirectories that need base.il inline template
1191 $(IL:%=pics/%) := CFLAGS64 += $(LIBCBASE)/fp/base.il
1193 # Files in fp subdirectory which need __quad.il inline template
1212 $(QIL:%=pics/%) := CFLAGS64 += $(LIBCDIR)/$(MACH)/fp/__quad.il
1213 pics/_Qp%.o := CFLAGS64 += -I$(LIBCDIR)/$(MACH)/fp
1214 pics/_Q%.o := sparcv9_COPTFLAG = -xO4 -xchip=ultra
1216 # Files in crt subdirectory which need muldiv64.il inline template
1217 #CIL= mul64.o divrem64.o
1218 #$(CIL:%=pics/%) := CFLAGS += $(LIBCBASE)/crt/mul64.il
1220 # large-file-aware components that should be built large
1222 #$(COMSYSOBJS64:%=pics/%) := \
1223 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1225 #$(SYSOBJS64:%=pics/%) := \
1226 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1228 #$(PORTGEN64:%=pics/%) := \
1229 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1231 #$(PORTSTDIO64:%=pics/%) := \
1232 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1234 #$(PORTSYS64:%=pics/%) := \
1235 # CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1237 $(PORTSTDIO_W:%=pics/%) := \
1240 $(PORTPRINT_W:%=pics/%) := \
1243 $(PORTI18N_COND:%=pics/%) := \
1244 CPPFLAGS += -D_WCS_LONGLONG
1246 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1248 # Files which need extra optimization
1249 pics/getenv.o := sparcv9_COPTFLAG = -xO4
1253 all: $(LIBS) $(LIB_PIC)
1255 lint := CPPFLAGS += -I$(LIBCDIR)/$(MACH)/fp
1256 lint := CPPFLAGS += -D_MSE_INT_H -D_LCONV_C99
1257 lint := LINTFLAGS64 += -mn
1260 @echo $(LINT.c) ... $(LDLIBS)
1261 @$(LINT.c) $(SRCS) $(LDLIBS)
1263 $(LINTLIB):= SRCS=$(LIBCDIR)/port/llib-lc
1264 $(LINTLIB):= CPPFLAGS += -D_MSE_INT_H
1265 $(LINTLIB):= LINTFLAGS64=-nvx -m64
1267 # object files that depend on inline template
1268 $(TIL:%=pics/%): $(LIBCBASE)/threads/sparcv9.il
1269 $(IL:%=pics/%): $(LIBCBASE)/fp/base.il
1270 $(QIL:%=pics/%): $(LIBCDIR)/$(MACH)/fp/__quad.il
1271 #$(CIL:%=pics/%): $(LIBCBASE)/crt/muldiv64.il
1273 # include common libc targets
1274 include $(LIBCDIR)/Makefile.targ
1276 # We need to strip out all CTF and DOF data from the static library
1277 $(LIB_PIC) := DIR = pics
1278 $(LIB_PIC): pics $$(PICS)
1280 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1281 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1282 $(AR) -ts $@ > /dev/null
1286 #$(STRETS:%=pics/%): crt/stret.s
1287 # $(AS) $(ASFLAGS) -DSTRET$(@F:stret%.o=%) crt/stret.s -o $@
1290 #crt/_rtbootld.s: crt/_rtboot.s crt/_rtld.c
1291 # $(CC) $(CPPFLAGS) -O -S -K pic crt/_rtld.c -o crt/_rtld.s
1292 # $(CAT) crt/_rtboot.s crt/_rtld.s > $@
1296 _lwp_mutex_unlock.o \
1305 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1307 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1309 # assym.h build rules
1311 assym.h := CFLAGS64 += -g
1313 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1315 genassym: $(GENASSYM_C)
1316 $(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1317 $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1319 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1321 assym.h: $(OFFSETS) genassym
1322 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1325 # derived C source and related explicit dependencies
1326 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1327 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1329 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c