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 2016 Joyent, Inc.
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/sparc/pics/symcap.o \
42 $(LIBCDIR)/capabilities/sun4u-opl/sparc/pics/symcap.o \
43 $(LIBCDIR)/capabilities/sun4u-us3-hwcap1/sparc/pics/symcap.o \
44 $(LIBCDIR)/capabilities/sun4u-us3-hwcap2/sparc/pics/symcap.o \
45 $(LIBCDIR)/capabilities/sun4v-hwcap1/sparc/pics/symcap.o \
46 $(LIBCDIR)/capabilities/sun4v-hwcap2/sparc/pics/symcap.o
146 arc4random_uniform.o \
178 sync_instruction_memory.o\
182 # sysobjs that contain large-file interfaces
335 _lwp_mutex_unlock.o \
350 # objects under $(LIBCDIR)/port which contain transitional large file interfaces
360 # objects from source under $(LIBCDIR)/port
413 ascii_strncasecmp.o \
675 # c89 variants to support 32-bit size of c89 u/intmax_t (32-bit libc only)
687 # portable stdio objects that contain large file interfaces.
688 # Note: fopen64 is a special case, as we build it small.
937 # objects that implement the transitional large file API
1049 $(THREADSMACHOBJS) \
1063 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1064 # modules whose source is provided in the $(SRC)/lib/crt directory.
1065 # This must be done because otherwise the Sun C compiler would insert
1066 # its own versions of these modules and those versions contain code
1067 # to call out to C++ initialization functions. Such C++ initialization
1068 # functions can call back into libc before thread initialization is
1069 # complete and this leads to segmentation violations and other problems.
1070 # Since libc contains no C++ code, linking with the minimal crti.o and
1071 # crtn.o modules is safe and avoids the problems described above.
1072 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1073 CRTSRCS= ../../crt/sparcv7
1075 # include common library definitions
1076 include $(SRC)/lib/Makefile.lib
1078 # we need to override the default SONAME here because we might
1079 # be building a variant object (still libc.so.1, but different filename)
1083 CERRWARN += -Wno-parentheses
1084 CERRWARN += -Wno-switch
1085 CERRWARN += -Wno-uninitialized
1086 CERRWARN += -Wno-unused-value
1087 CERRWARN += -Wno-unused-label
1088 CERRWARN += -Wno-unused-variable
1089 CERRWARN += -Wno-type-limits
1090 CERRWARN += -Wno-char-subscripts
1091 CERRWARN += -Wno-clobbered
1092 CERRWARN += -Wno-unused-function
1093 CERRWARN += -Wno-address
1095 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1096 # enables ASSERT() checking in the threads portion of the library.
1097 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1099 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1101 ALTPICS= $(TRACEOBJS:%=pics/%)
1103 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) $(EXTPICS)
1105 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1107 CFLAGS += $(EXTN_CFLAGS)
1108 CPPFLAGS= -Dsparc $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1109 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1110 ASFLAGS= $(EXTN_ASFLAGS) -D_ASM $(CPPFLAGS) $(sparc_AS_XARCH)
1112 # As a favor to the dtrace syscall provider, libc still calls the
1113 # old syscall traps that have been obsoleted by the *at() interfaces.
1114 # Delete this to compile libc using only the new *at() system call traps
1115 CPPFLAGS += -D_RETAIN_OLD_SYSCALLS
1117 # Inform the run-time linker about libc specialized initialization
1118 RTLDINFO = -z rtldinfo=tls_rtldinfo
1119 DYNFLAGS += $(RTLDINFO)
1121 # Force libc's internal references to be resolved immediately upon loading
1122 # in order to avoid critical region problems. Since almost all libc symbols
1123 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1126 DYNFLAGS += -e __rtboot
1127 DYNFLAGS += $(EXTN_DYNFLAGS)
1129 # Inform the kernel about the initial DTrace area (in case
1130 # libc is being used as the interpreter / runtime linker).
1131 DTRACE_DATA = -zdtrace=dtrace_data
1132 DYNFLAGS += $(DTRACE_DATA)
1134 # DTrace needs an executable data segment.
1135 DYNFLAGS += -M$(SRC)/common/mapfiles/common/map.execdata
1137 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1139 # Override this top level flag so the compiler builds in its native
1140 # C99 mode. This has been enabled to support the complex arithmetic
1142 C99MODE= $(C99_ENABLE)
1144 # libc method of building an archive
1145 # The "$(GREP) -v ' L '" part is necessary only until
1146 # lorder is fixed to ignore thread-local variables.
1147 BUILD.AR= $(RM) $@ ; \
1148 $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1150 # extra files for the clean target
1152 $(LIBCDIR)/port/gen/errlst.c \
1153 $(LIBCDIR)/port/gen/new_list.c \
1156 $(LIBCBASE)/crt/_rtld.s \
1157 $(LIBCBASE)/crt/_rtbootld.s \
1163 CLOBBERFILES += $(LIB_PIC)
1165 # list of C source formerly for lint
1167 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1168 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1169 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1170 $(DTRACEOBJS:%.o=$(SRC)/common/dtrace/%.c) \
1171 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1172 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1173 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1174 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1175 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1176 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1177 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1178 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1179 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1180 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1181 $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
1182 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1183 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1184 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1185 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1186 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1187 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1188 $(LIBCBASE)/crt/_ftou.c \
1189 $(LIBCBASE)/gen/_xregs_clrptr.c \
1190 $(LIBCBASE)/gen/byteorder.c \
1191 $(LIBCBASE)/gen/ecvt.c \
1192 $(LIBCBASE)/gen/endian.c \
1193 $(LIBCBASE)/gen/getctxt.c \
1194 $(LIBCBASE)/gen/lmul.c \
1195 $(LIBCBASE)/gen/makectxt.c \
1196 $(LIBCBASE)/gen/siginfolst.c \
1197 $(LIBCBASE)/gen/siglongjmp.c \
1198 $(LIBCBASE)/gen/swapctxt.c \
1199 $(LIBCBASE)/sys/ptrace.c \
1200 $(LIBCBASE)/sys/uadmin.c
1202 # conditional assignments
1203 $(DYNLIB) := CRTI = crti.o
1204 $(DYNLIB) := CRTN = crtn.o
1206 # special kludge for inlines with 'cas':
1207 pics/rwlock.o pics/synch.o pics/lwp.o pics/door_calls.o := \
1208 sparc_CFLAGS += -Wa,-xarch=v8plus
1210 pics/_Q%.o := sparc_COPTFLAG = -fno-strict-aliasing \
1211 -fno-unit-at-a-time \
1212 -fno-optimize-sibling-calls \
1214 pics/__quad%.o := sparc_COPTFLAG = -fno-strict-aliasing \
1215 -fno-unit-at-a-time \
1216 -fno-optimize-sibling-calls \
1219 # large-file-aware components that should be built large
1221 $(COMSYSOBJS64:%=pics/%) := \
1222 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1224 $(SYSOBJS64:%=pics/%) := \
1225 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1227 $(PORTGEN64:%=pics/%) := \
1228 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1230 $(PORTREGEX64:%=pics/%) := \
1231 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1233 $(PORTSTDIO64:%=pics/%) := \
1234 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1236 $(PORTSYS64:%=pics/%) := \
1237 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1239 $(PORTSTDIO_W:%=pics/%) := \
1242 $(PORTPRINT_W:%=pics/%) := \
1245 # printf/scanf functions to support c89-sized intmax_t variables
1246 $(PORTPRINT_C89:%=pics/%) := \
1247 CPPFLAGS += -D_C89_INTMAX32
1249 $(PORTSTDIO_C89:%=pics/%) := \
1250 CPPFLAGS += -D_C89_INTMAX32
1252 $(PORTI18N_COND:%=pics/%) := \
1253 CPPFLAGS += -D_WCS_LONGLONG
1255 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1257 # Files which need extra optimization
1258 pics/getenv.o := sparc_COPTFLAG = -fno-strict-aliasing \
1259 -fno-unit-at-a-time \
1260 -fno-optimize-sibling-calls \
1265 all: $(LIBS) $(LIB_PIC)
1267 # include common libc targets
1268 include $(LIBCDIR)/Makefile.targ
1270 # We need to strip out all CTF and DOF data from the static library
1271 $(LIB_PIC) := DIR = pics
1272 $(LIB_PIC): pics $$(PICS)
1274 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1275 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1276 $(AR) -ts $@ > /dev/null
1280 $(STRETS:%=pics/%): $(LIBCBASE)/crt/stret.s
1281 $(AS) $(ASFLAGS) -DSTRET$(@F:stret%.o=%) $(LIBCBASE)/crt/stret.s -o $@
1284 $(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
1285 $(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S -fpic \
1286 $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
1287 $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
1288 $(RM) $(LIBCBASE)/crt/_rtld.s
1290 # partially built from C source
1291 pics/_rtbootld.o: $(LIBCBASE)/crt/_rtbootld.s
1292 $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
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 := CFLAGS += -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/errlst.c + \
1327 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1328 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1330 pics/errlst.o: $(LIBCDIR)/port/gen/errlst.c
1332 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c