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) 2004, 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
39 # objects are grouped by source directory
120 arc4random_uniform.o \
154 sync_instruction_memory.o
156 # sysobjs that contain large-file interfaces
309 _lwp_mutex_unlock.o \
328 # objects under $(LIBCDIR)/port which contain transitional large file interfaces
338 # objects from source under $(LIBCDIR)/port
375 ascii_strncasecmp.o \
547 select_large_fdset.o \
632 # c89 variants to support 32-bit size of c89 u/intmax_t (32-bit libc only)
644 # portable stdio objects that contain large file interfaces.
645 # Note: fopen64 is a special case, as we build it small.
893 # objects that implement the transitional large file API
1009 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1010 # modules whose source is provided in the $(SRC)/lib/common directory.
1011 # This must be done because otherwise the Sun C compiler would insert
1012 # its own versions of these modules and those versions contain code
1013 # to call out to C++ initialization functions. Such C++ initialization
1014 # functions can call back into libc before thread initialization is
1015 # complete and this leads to segmentation violations and other problems.
1016 # Since libc contains no C++ code, linking with the minimal crti.o and
1017 # crtn.o modules is safe and avoids the problems described above.
1018 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1019 CRTSRCS= ../../common/i386
1021 LDPASS_OFF= $(POUND_SIGN)
1023 # include common library definitions
1024 include ../../Makefile.lib
1026 # we need to override the default SONAME here because we might
1027 # be building a variant object (still libc.so.1, but different filename)
1030 CFLAGS += $(CCVERBOSE) $(CTF_FLAGS)
1032 # This is necessary to avoid problems with calling _ex_unwind().
1033 # We probably don't want any inlining anyway.
1035 CFLAGS += $(XINLINE)
1037 CERRWARN += -_gcc=-Wno-parentheses
1038 CERRWARN += -_gcc=-Wno-switch
1039 CERRWARN += -_gcc=-Wno-uninitialized
1040 CERRWARN += -_gcc=-Wno-unused-value
1041 CERRWARN += -_gcc=-Wno-unused-label
1042 CERRWARN += -_gcc=-Wno-unused-variable
1043 CERRWARN += -_gcc=-Wno-type-limits
1044 CERRWARN += -_gcc=-Wno-char-subscripts
1045 CERRWARN += -_gcc=-Wno-clobbered
1046 CERRWARN += -_gcc=-Wno-unused-function
1047 CERRWARN += -_gcc=-Wno-address
1049 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1050 # enables ASSERT() checking in the threads portion of the library.
1051 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1053 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1055 # Make string literals read-only to save memory.
1056 CFLAGS += $(XSTRCONST)
1058 ALTPICS= $(TRACEOBJS:%=pics/%)
1060 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(DYNFLAGS) $(PICS) $(ALTPICS) \
1061 $(EXTPICS) $(LDLIBS)
1063 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1066 # EXTN_CPPFLAGS and EXTN_CFLAGS set in enclosing Makefile
1068 CFLAGS += $(EXTN_CFLAGS)
1069 CPPFLAGS= -D_REENTRANT -Di386 $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1070 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1071 ASFLAGS= $(AS_PICFLAGS) -P -D__STDC__ -D_ASM $(CPPFLAGS) $(i386_AS_XARCH)
1073 # As a favor to the dtrace syscall provider, libc still calls the
1074 # old syscall traps that have been obsoleted by the *at() interfaces.
1075 # Delete this to compile libc using only the new *at() system call traps
1076 CPPFLAGS += -D_RETAIN_OLD_SYSCALLS
1078 # Inform the run-time linker about libc specialized initialization
1079 RTLDINFO = -z rtldinfo=tls_rtldinfo
1080 DYNFLAGS += $(RTLDINFO)
1082 # Force libc's internal references to be resolved immediately upon loading
1083 # in order to avoid critical region problems. Since almost all libc symbols
1084 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1087 DYNFLAGS += -e __rtboot
1088 DYNFLAGS += $(EXTN_DYNFLAGS)
1090 # Inform the kernel about the initial DTrace area (in case
1091 # libc is being used as the interpreter / runtime linker).
1092 DTRACE_DATA = -zdtrace=dtrace_data
1093 DYNFLAGS += $(DTRACE_DATA)
1095 # DTrace needs an executable data segment.
1098 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1100 # Override this top level flag so the compiler builds in its native
1101 # C99 mode. This has been enabled to support the complex arithmetic
1103 C99MODE= $(C99_ENABLE)
1105 # libc method of building an archive
1106 # The "$(GREP) -v ' L '" part is necessary only until
1107 # lorder is fixed to ignore thread-local variables.
1108 BUILD.AR= $(RM) $@ ; \
1109 $(AR) q $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1111 # extra files for the clean target
1113 $(LIBCDIR)/port/gen/errlst.c \
1114 $(LIBCDIR)/port/gen/new_list.c \
1124 CLOBBERFILES += $(LIB_PIC)
1126 # list of C source for lint
1128 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1129 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1130 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1131 $(DTRACEOBJS:%.o=$(SRC)/common/dtrace/%.c) \
1132 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1133 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1134 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1135 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1136 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1137 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1138 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1139 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1140 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1141 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1142 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1143 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1144 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1145 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1146 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1147 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1148 $(LIBCBASE)/gen/ecvt.c \
1149 $(LIBCBASE)/gen/makectxt.c \
1150 $(LIBCBASE)/gen/siginfolst.c \
1151 $(LIBCBASE)/gen/siglongjmp.c \
1152 $(LIBCBASE)/gen/strcmp.c \
1153 $(LIBCBASE)/gen/sync_instruction_memory.c \
1154 $(LIBCBASE)/sys/ptrace.c \
1155 $(LIBCBASE)/sys/uadmin.c
1157 # conditional assignments
1158 $(DYNLIB) := CRTI = crti.o
1159 $(DYNLIB) := CRTN = crtn.o
1161 # Files which need the threads .il inline template
1194 thread_interface.o \
1201 THREADS_INLINES = $(LIBCBASE)/threads/i386.il
1202 $(TIL:%=pics/%) := CFLAGS += $(THREADS_INLINES)
1204 # pics/mul64.o := CFLAGS += $(LIBCBASE)/crt/mul64.il
1206 # large-file-aware components that should be built large
1208 $(COMSYSOBJS64:%=pics/%) := \
1209 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1211 $(SYSOBJS64:%=pics/%) := \
1212 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1214 $(PORTGEN64:%=pics/%) := \
1215 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1217 $(PORTSTDIO64:%=pics/%) := \
1218 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1220 $(PORTSYS64:%=pics/%) := \
1221 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1223 $(PORTSTDIO_W:%=pics/%) := \
1226 $(PORTPRINT_W:%=pics/%) := \
1229 $(PORTPRINT_C89:%=pics/%) := \
1230 CPPFLAGS += -D_C89_INTMAX32
1232 $(PORTSTDIO_C89:%=pics/%) := \
1233 CPPFLAGS += -D_C89_INTMAX32
1235 $(PORTI18N_COND:%=pics/%) := \
1236 CPPFLAGS += -D_WCS_LONGLONG
1238 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1242 all: $(LIBS) $(LIB_PIC)
1244 lint := CPPFLAGS += -I$(LIBCDIR)/$(MACH)/fp
1245 lint := CPPFLAGS += -D_MSE_INT_H -D_LCONV_C99
1246 lint := LINTFLAGS += -mn -erroff=E_SUPPRESSION_DIRECTIVE_UNUSED
1250 @$(LINT.c) $(SRCS) $(LDLIBS)
1252 $(LINTLIB):= SRCS=$(LIBCDIR)/port/llib-lc
1253 $(LINTLIB):= CPPFLAGS += -D_MSE_INT_H
1254 $(LINTLIB):= LINTFLAGS=-nvx
1256 # object files that depend on inline template
1257 $(TIL:%=pics/%): $(LIBCBASE)/threads/i386.il
1258 # pics/mul64.o: $(LIBCBASE)/crt/mul64.il
1260 # include common libc targets
1261 include $(LIBCDIR)/Makefile.targ
1263 # We need to strip out all CTF and DOF data from the static library
1264 $(LIB_PIC) := DIR = pics
1265 $(LIB_PIC): pics $$(PICS)
1267 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1268 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1269 $(AR) -ts $@ > /dev/null
1272 $(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
1273 $(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S $(C_PICFLAGS) \
1274 $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
1275 $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
1276 $(RM) $(LIBCBASE)/crt/_rtld.s
1278 # partially built from C source
1279 pics/_rtbootld.o: $(LIBCBASE)/crt/_rtbootld.s
1280 $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
1284 _lwp_mutex_unlock.o \
1291 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1293 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1295 # assym.h build rules
1297 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1299 genassym: $(GENASSYM_C)
1300 $(NATIVECC) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1301 -D__EXTENSIONS__ $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1303 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1305 assym.h: $(OFFSETS) genassym
1306 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1309 # derived C source and related explicit dependencies
1310 $(LIBCDIR)/port/gen/errlst.c + \
1311 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1312 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1314 pics/errlst.o: $(LIBCDIR)/port/gen/errlst.c
1316 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c