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 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
36 # include comm page definitions
37 include $(SRC)/lib/commpage/Makefile.shared.com
38 include $(SRC)/lib/commpage/Makefile.shared.targ
42 # objects are grouped by source directory
44 # Symbol capabilities objects
46 $(LIBCDIR)/capabilities/i386-sse/i386/pics/symcap.o \
47 $(LIBCDIR)/capabilities/i386-sse2/i386/pics/symcap.o
132 arc4random_uniform.o \
171 sync_instruction_memory.o\
175 # sysobjs that contain large-file interfaces
327 __clock_gettime_sys.o \
330 _lwp_mutex_unlock.o \
347 # objects under $(LIBCDIR)/port which contain transitional large file interfaces
357 # objects from source under $(LIBCDIR)/port
394 ascii_strncasecmp.o \
655 # c89 variants to support 32-bit size of c89 u/intmax_t (32-bit libc only)
667 # portable stdio objects that contain large file interfaces.
668 # Note: fopen64 is a special case, as we build it small.
783 PORTINET= bindresvport.o bootparams_getbyname.o ether_addr.o \
784 getaddrinfo.o getnameinfo.o getnetent.o getnetent_r.o \
785 getprotoent.o getprotoent_r.o getservbyname_r.o getservent.o \
786 getservent_r.o inet_lnaof.o inet_mkaddr.o inet_network.o \
787 inet6_opt.o inet6_rthdr.o interface_id.o link_addr.o \
788 netmasks.o ruserpass.o sourcefilter.o \
863 PORTNSL= _conn_util.o _data2.o _errlst.o _utility.o algs.o auth_des.o \
864 auth_none.o auth_sys.o auth_time.o authdes_prot.o authsys_prot.o \
865 can_use_af.o checkver.o clnt_bcast.o clnt_dg.o clnt_door.o \
866 clnt_generic.o clnt_perror.o clnt_raw.o clnt_simple.o clnt_vc.o \
867 daemon_utils.o dbm.o des_crypt.o des_soft.o doconfig.o getauthattr.o \
868 getauuser.o getdname.o getexecattr.o gethostby_door.o \
869 gethostbyname_r.o gethostent.o gethostent6.o gethostent_r.o \
870 getipnodeby.o getipnodeby_door.o getprofattr.o getrpcent.o \
871 getrpcent_r.o getuserattr.o inet_matchaddr.o inet_ntoa.o inet_ntop.o \
872 inet_pton.o key_call.o key_prot.o mt_misc.o netdir.o netdir_inet.o \
873 netdir_inet_sundry.o netname.o netnamer.o netselect.o nis_misc.o \
874 nis_misc_proc.o nis_sec_mechs.o nis_subr.o nis_xdr.o parse.o \
875 pmap_clnt.o pmap_prot.o publickey.o rpc_callmsg.o rpc_comdata.o \
876 rpc_fdsync.o rpc_generic.o rpc_prot.o rpc_sel2poll.o \
877 rpc_soc.o rpc_td.o rpcb_clnt.o rpcb_prot.o rpcb_st_xdr.o rpcdname.o \
878 rpcsec_gss_if.o rtime_tli.o svc.o svc_auth.o svc_auth_loopb.o \
879 svc_auth_sys.o svc_dg.o svc_door.o svc_generic.o svc_raw.o svc_run.o \
880 svc_simple.o svc_vc.o svcauth_des.o svid_funcs.o t_accept.o \
881 t_alloc.o t_bind.o t_close.o t_connect.o t_error.o t_free.o \
882 t_getinfo.o t_getname.o t_getstate.o t_listen.o t_look.o t_open.o \
883 t_optmgmt.o t_rcv.o t_rcvconnect.o t_rcvdis.o t_rcvrel.o \
884 t_rcvreldata.o t_rcvudata.o t_rcvuderr.o t_rcvv.o t_rcvvudata.o \
885 t_snd.o t_snddis.o t_sndrel.o t_sndreldata.o t_sndudata.o t_sndv.o \
886 t_sndvudata.o t_strerror.o t_sync.o t_sysconf.o t_unbind.o \
887 thr_get_storage.o ti_opts.o tli_wrappers.o xdr.o xdr_array.o \
888 xdr_float.o xdr_mem.o xdr_rec.o xdr_refer.o xdr_sizeof.o xdr_stdio.o \
889 xti_wrappers.o yp_all.o yp_b_clnt.o yp_b_xdr.o yp_bind.o yp_enum.o \
890 yp_master.o yp_match.o yp_order.o yp_rsvd.o yp_update.o yp_xdr.o \
891 yperr_string.o yppasswd_xdr.o ypprot_err.o ypupd.o
951 # objects that implement the transitional large file API
1030 PORTSOCKET= _soutil.o sockatmark.o socket.o socketpair.o weaks.o
1069 $(THREADSMACHOBJS) \
1083 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1084 # modules whose source is provided in the $(SRC)/lib/crt directory.
1085 # This must be done because otherwise the Sun C compiler would insert
1086 # its own versions of these modules and those versions contain code
1087 # to call out to C++ initialization functions. Such C++ initialization
1088 # functions can call back into libc before thread initialization is
1089 # complete and this leads to segmentation violations and other problems.
1090 # Since libc contains no C++ code, linking with the minimal crti.o and
1091 # crtn.o modules is safe and avoids the problems described above.
1092 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1093 CRTSRCS= ../../crt/i86
1095 LDPASS_OFF= $(POUND_SIGN)
1097 # include common library definitions
1098 include ../../Makefile.lib
1100 # we need to override the default SONAME here because we might
1101 # be building a variant object (still libc.so.1, but different filename)
1104 CFLAGS += $(CTF_FLAGS)
1106 CERRWARN += -Wno-parentheses
1107 CERRWARN += -Wno-switch
1108 CERRWARN += -Wno-uninitialized
1109 CERRWARN += -Wno-unused-value
1110 CERRWARN += -Wno-unused-label
1111 CERRWARN += -Wno-unused-variable
1112 CERRWARN += -Wno-type-limits
1113 CERRWARN += -Wno-char-subscripts
1114 CERRWARN += -Wno-clobbered
1115 CERRWARN += -Wno-unused-function
1116 CERRWARN += -Wno-address
1118 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1119 # enables ASSERT() checking in the threads portion of the library.
1120 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1122 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1124 ALTPICS= $(TRACEOBJS:%=pics/%)
1126 # The use of sed is a gross hack needed because the current build system
1127 # assumed that the compiler accepted linker flags (-Bfoo -zfoo and -Mfoo)
1128 # directly. Here, since we're calling the linker directly, we have to
1129 # discard the prefixes. Ideally, we would be using the LD_Z* and LD_B*
1130 # variables instead, but that would require a lot of mucking with makefiles.
1131 # So for now, we do this.
1132 REMOVE_GCC_PREFIX=echo $(DYNFLAGS) | $(SED) -e 's/-Wl,//g'
1133 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(REMOVE_GCC_PREFIX:sh) $(PICS) $(ALTPICS) \
1134 $(EXTPICS) $(LDLIBS)
1136 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1139 # EXTN_CPPFLAGS and EXTN_CFLAGS set in enclosing Makefile
1141 CFLAGS += -march=pentiumpro
1142 CPPFLAGS= -Di386 $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1143 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1144 ASFLAGS= $(AS_PICFLAGS) -D_ASM $(CPPFLAGS) $(i386_AS_XARCH)
1146 # Inform the run-time linker about libc specialized initialization
1147 RTLDINFO = -z rtldinfo=tls_rtldinfo
1148 DYNFLAGS += $(RTLDINFO)
1150 # Force libc's internal references to be resolved immediately upon loading
1151 # in order to avoid critical region problems. Since almost all libc symbols
1152 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1155 DYNFLAGS += -e __rtboot
1156 DYNFLAGS += $(EXTN_DYNFLAGS)
1158 # Inform the kernel about the initial DTrace area (in case
1159 # libc is being used as the interpreter / runtime linker).
1160 DTRACE_DATA = -zdtrace=dtrace_data
1161 DYNFLAGS += $(DTRACE_DATA)
1163 # DTrace needs an executable data segment.
1164 DYNFLAGS += -M$(SRC)/common/mapfiles/common/map.execdata
1166 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1168 # Override this top level flag so the compiler builds in its native
1169 # C99 mode. This has been enabled to support the complex arithmetic
1171 C99MODE= $(C99_ENABLE)
1173 # libc method of building an archive
1174 # The "$(GREP) -v ' L '" part is necessary only until
1175 # lorder is fixed to ignore thread-local variables.
1176 BUILD.AR= $(RM) $@ ; \
1177 $(AR) qc $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1179 # extra files for the clean target
1181 $(LIBCDIR)/port/gen/errlst.c \
1182 $(LIBCDIR)/port/gen/new_list.c \
1192 CLOBBERFILES += $(LIB_PIC)
1194 # list of C source formerly for lint
1196 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1197 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1198 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1199 $(DTRACEOBJS:%.o=$(SRC)/common/dtrace/%.c) \
1200 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1201 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1202 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1203 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1204 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1205 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1206 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1207 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1208 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1209 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1210 $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
1211 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1212 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1213 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1214 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1215 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1216 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1217 $(LIBCBASE)/gen/ecvt.c \
1218 $(LIBCBASE)/gen/makectxt.c \
1219 $(LIBCBASE)/gen/siginfolst.c \
1220 $(LIBCBASE)/gen/siglongjmp.c \
1221 $(LIBCBASE)/gen/strcmp.c \
1222 $(LIBCBASE)/gen/sync_instruction_memory.c \
1223 $(LIBCBASE)/sys/ptrace.c \
1224 $(LIBCBASE)/sys/uadmin.c
1226 # conditional assignments
1227 $(DYNLIB) := CRTI = crti.o
1228 $(DYNLIB) := CRTN = crtn.o
1230 # large-file-aware components that should be built large
1232 $(COMSYSOBJS64:%=pics/%) := \
1233 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1235 $(SYSOBJS64:%=pics/%) := \
1236 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1238 $(PORTGEN64:%=pics/%) := \
1239 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1241 $(PORTREGEX64:%=pics/%) := \
1242 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1244 $(PORTSTDIO64:%=pics/%) := \
1245 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1247 $(PORTSYS64:%=pics/%) := \
1248 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
1250 $(PORTSTDIO_W:%=pics/%) := \
1253 $(PORTPRINT_W:%=pics/%) := \
1256 $(PORTPRINT_C89:%=pics/%) := \
1257 CPPFLAGS += -D_C89_INTMAX32
1259 $(PORTSTDIO_C89:%=pics/%) := \
1260 CPPFLAGS += -D_C89_INTMAX32
1262 $(PORTI18N_COND:%=pics/%) := \
1263 CPPFLAGS += -D_WCS_LONGLONG
1265 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1267 pics/__clock_gettime.o := CPPFLAGS += $(COMMPAGE_CPPFLAGS)
1271 all: $(LIBS) $(LIB_PIC)
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
1285 $(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
1286 $(CC) $(CPPFLAGS) $(CTF_FLAGS) -O -S $(C_PICFLAGS) \
1287 $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
1288 $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
1289 $(RM) $(LIBCBASE)/crt/_rtld.s
1291 # partially built from C source
1292 pics/_rtbootld.o: $(LIBCBASE)/crt/_rtbootld.s
1293 $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
1297 _lwp_mutex_unlock.o \
1304 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1306 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1308 # assym.h build rules
1310 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1312 genassym: $(GENASSYM_C)
1313 $(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1314 -D__EXTENSIONS__ $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1316 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1318 assym.h: $(OFFSETS) genassym
1319 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1322 # derived C source and related explicit dependencies
1323 $(LIBCDIR)/port/gen/errlst.c + \
1324 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1325 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1327 pics/errlst.o: $(LIBCDIR)/port/gen/errlst.c
1329 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c