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 2019 Joyent, Inc.
24 # Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
25 # Copyright 2013 Garrett D'Amore <garrett@damore.org>
26 # Copyright 2018 Nexenta Systems, Inc.
29 LIBCDIR= $(SRC)/lib/libc
34 # include comm page definitions
35 include $(SRC)/lib/commpage/Makefile.shared.com
36 include $(SRC)/lib/commpage/Makefile.shared.targ
40 # objects are grouped by source directory
42 # Symbol capabilities objects
44 $(LIBCDIR)/capabilities/i386-sse/i386/pics/symcap.o \
45 $(LIBCDIR)/capabilities/i386-sse2/i386/pics/symcap.o
130 arc4random_uniform.o \
169 sync_instruction_memory.o\
306 __clock_gettime_sys.o \
309 _lwp_mutex_unlock.o \
325 # objects from source under $(LIBCDIR)/port
361 ascii_strncasecmp.o \
536 set_constraint_handler_s.o \
736 bootparams_getbyname.o \
834 PORTNSL= _conn_util.o _data2.o _errlst.o _utility.o algs.o auth_des.o \
835 auth_none.o auth_sys.o auth_time.o authdes_prot.o authsys_prot.o \
836 can_use_af.o checkver.o clnt_bcast.o clnt_dg.o clnt_door.o \
837 clnt_generic.o clnt_perror.o clnt_raw.o clnt_simple.o clnt_vc.o \
838 daemon_utils.o dbm.o des_crypt.o des_soft.o doconfig.o getauthattr.o \
839 getdname.o getexecattr.o gethostby_door.o \
840 gethostbyname_r.o gethostent.o gethostent6.o gethostent_r.o \
841 getipnodeby.o getipnodeby_door.o getprofattr.o getrpcent.o \
842 getrpcent_r.o getuserattr.o inet_matchaddr.o \
843 key_call.o key_prot.o mt_misc.o netdir.o netdir_inet.o \
844 netdir_inet_sundry.o netname.o netnamer.o netselect.o nis_misc.o \
845 nis_misc_proc.o nis_sec_mechs.o nis_subr.o nis_xdr.o parse.o \
846 pmap_clnt.o pmap_prot.o publickey.o rpc_callmsg.o rpc_comdata.o \
847 rpc_fdsync.o rpc_generic.o rpc_prot.o rpc_sel2poll.o \
848 rpc_soc.o rpc_td.o rpcb_clnt.o rpcb_prot.o rpcb_st_xdr.o rpcdname.o \
849 rpcsec_gss_if.o rtime_tli.o svc.o svc_auth.o svc_auth_loopb.o \
850 svc_auth_sys.o svc_dg.o svc_door.o svc_generic.o svc_raw.o svc_run.o \
851 svc_simple.o svc_vc.o svcauth_des.o svid_funcs.o t_accept.o \
852 t_alloc.o t_bind.o t_close.o t_connect.o t_error.o t_free.o \
853 t_getinfo.o t_getname.o t_getstate.o t_listen.o t_look.o t_open.o \
854 t_optmgmt.o t_rcv.o t_rcvconnect.o t_rcvdis.o t_rcvrel.o \
855 t_rcvreldata.o t_rcvudata.o t_rcvuderr.o t_rcvv.o t_rcvvudata.o \
856 t_snd.o t_snddis.o t_sndrel.o t_sndreldata.o t_sndudata.o t_sndv.o \
857 t_sndvudata.o t_strerror.o t_sync.o t_sysconf.o t_unbind.o \
858 thr_get_storage.o ti_opts.o tli_wrappers.o xdr.o xdr_array.o \
859 xdr_float.o xdr_mem.o xdr_rec.o xdr_refer.o xdr_sizeof.o xdr_stdio.o \
860 xti_wrappers.o yp_all.o yp_b_clnt.o yp_b_xdr.o yp_bind.o yp_enum.o \
861 yp_master.o yp_match.o yp_order.o yp_rsvd.o yp_update.o yp_xdr.o \
862 yperr_string.o yppasswd_xdr.o ypprot_err.o ypupd.o
991 PORTSOCKET= _soutil.o sockatmark.o socket.o socketpair.o weaks.o
1024 $(THREADSMACHOBJS) \
1036 # NOTE: libc.so.1 must be linked with the minimal crti.o and crtn.o
1037 # modules whose source is provided in the $(SRC)/lib/crt directory.
1038 # This must be done because otherwise the Sun C compiler would insert
1039 # its own versions of these modules and those versions contain code
1040 # to call out to C++ initialization functions. Such C++ initialization
1041 # functions can call back into libc before thread initialization is
1042 # complete and this leads to segmentation violations and other problems.
1043 # Since libc contains no C++ code, linking with the minimal crti.o and
1044 # crtn.o modules is safe and avoids the problems described above.
1045 OBJECTS= $(CRTI) $(MOSTOBJS) $(CRTN)
1046 CRTSRCS= ../../crt/i386
1048 LDPASS_OFF= $(POUND_SIGN)
1050 # include common library definitions
1051 include ../../Makefile.lib
1053 # we need to override the default SONAME here because we might
1054 # be building a variant object (still libc.so.1, but different filename)
1057 CFLAGS += $(CTF_FLAGS)
1059 CERRWARN += -Wno-parentheses
1060 CERRWARN += -Wno-switch
1061 CERRWARN += -Wno-uninitialized
1062 CERRWARN += -Wno-unused-value
1063 CERRWARN += -Wno-unused-label
1064 CERRWARN += -Wno-unused-variable
1065 CERRWARN += -Wno-type-limits
1066 CERRWARN += -Wno-char-subscripts
1067 CERRWARN += -Wno-clobbered
1068 CERRWARN += -Wno-unused-function
1069 CERRWARN += -Wno-address
1074 # Setting THREAD_DEBUG = -DTHREAD_DEBUG (make THREAD_DEBUG=-DTHREAD_DEBUG ...)
1075 # enables ASSERT() checking in the threads portion of the library.
1076 # This is automatically enabled for DEBUG builds, not for non-debug builds.
1078 $(NOT_RELEASE_BUILD)THREAD_DEBUG = -DTHREAD_DEBUG
1080 ALTPICS= $(TRACEOBJS:%=pics/%)
1082 # The use of sed is a gross hack needed because the current build system
1083 # assumed that the compiler accepted linker flags (-Bfoo -zfoo and -Mfoo)
1084 # directly. Here, since we're calling the linker directly, we have to
1085 # discard the prefixes. Ideally, we would be using the LD_Z* and LD_B*
1086 # variables instead, but that would require a lot of mucking with makefiles.
1087 # So for now, we do this.
1088 REMOVE_GCC_PREFIX=echo $(DYNFLAGS) | $(SED) -e 's/-Wl,//g'
1089 $(DYNLIB) := BUILD.SO = $(LD) -o $@ -G $(REMOVE_GCC_PREFIX:sh) $(PICS) $(ALTPICS) \
1090 $(EXTPICS) $(LDLIBS)
1092 MAPFILES = $(LIBCDIR)/port/mapfile-vers
1095 # EXTN_CPPFLAGS and EXTN_CFLAGS set in enclosing Makefile
1097 CFLAGS += -march=pentiumpro
1098 CPPFLAGS= -Di386 $(EXTN_CPPFLAGS) $(THREAD_DEBUG) \
1099 -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc $(CPPFLAGS.master)
1100 ASFLAGS= $(AS_PICFLAGS) -D_ASM $(CPPFLAGS) $(i386_AS_XARCH)
1102 # Inform the run-time linker about libc specialized initialization
1103 RTLDINFO = -z rtldinfo=tls_rtldinfo
1104 DYNFLAGS += $(RTLDINFO)
1106 # Force libc's internal references to be resolved immediately upon loading
1107 # in order to avoid critical region problems. Since almost all libc symbols
1108 # are marked 'protected' in the mapfiles, this is a minimal set (15 to 20).
1111 DYNFLAGS += -e __rtboot
1112 DYNFLAGS += $(EXTN_DYNFLAGS)
1114 # Inform the kernel about the initial DTrace area (in case
1115 # libc is being used as the interpreter / runtime linker).
1116 DTRACE_DATA = -zdtrace=dtrace_data
1117 DYNFLAGS += $(DTRACE_DATA)
1119 # DTrace needs an executable data segment.
1120 DYNFLAGS += -M$(SRC)/common/mapfiles/common/map.execdata
1122 BUILD.s= $(AS) $(ASFLAGS) $< -o $@
1124 # Override this top level flag so the compiler builds in its native
1125 # C99 mode. This has been enabled to support the complex arithmetic
1129 # libc method of building an archive
1130 # The "$(GREP) -v ' L '" part is necessary only until
1131 # lorder is fixed to ignore thread-local variables.
1132 BUILD.AR= $(RM) $@ ; \
1133 $(AR) qc $@ `$(LORDER) $(MOSTOBJS:%=$(DIR)/%) | $(GREP) -v ' L ' | $(TSORT)`
1135 # extra files for the clean target
1137 $(LIBCDIR)/port/gen/errlst.c \
1138 $(LIBCDIR)/port/gen/new_list.c \
1148 CLOBBERFILES += $(LIB_PIC)
1150 # list of C source formerly for lint
1152 $(ATOMICOBJS:%.o=$(SRC)/common/atomic/%.c) \
1153 $(XATTROBJS:%.o=$(SRC)/common/xattr/%.c) \
1154 $(COMOBJS:%.o=$(SRC)/common/util/%.c) \
1155 $(DTRACEOBJS:%.o=$(SRC)/common/dtrace/%.c) \
1156 $(PORTFP:%.o=$(LIBCDIR)/port/fp/%.c) \
1157 $(PORTGEN:%.o=$(LIBCDIR)/port/gen/%.c) \
1158 $(PORTI18N:%.o=$(LIBCDIR)/port/i18n/%.c) \
1159 $(PORTLOCALE:%.o=$(LIBCDIR)/port/locale/%.c) \
1160 $(PORTPRINT:%.o=$(LIBCDIR)/port/print/%.c) \
1161 $(PORTREGEX:%.o=$(LIBCDIR)/port/regex/%.c) \
1162 $(PORTSTDIO:%.o=$(LIBCDIR)/port/stdio/%.c) \
1163 $(PORTSYS:%.o=$(LIBCDIR)/port/sys/%.c) \
1164 $(AIOOBJS:%.o=$(LIBCDIR)/port/aio/%.c) \
1165 $(RTOBJS:%.o=$(LIBCDIR)/port/rt/%.c) \
1166 $(SECFLAGSOBJS:%.o=$(SRC)/common/secflags/%.c) \
1167 $(TPOOLOBJS:%.o=$(LIBCDIR)/port/tpool/%.c) \
1168 $(THREADSOBJS:%.o=$(LIBCDIR)/port/threads/%.c) \
1169 $(THREADSMACHOBJS:%.o=$(LIBCDIR)/$(MACH)/threads/%.c) \
1170 $(UNICODEOBJS:%.o=$(SRC)/common/unicode/%.c) \
1171 $(UNWINDMACHOBJS:%.o=$(LIBCDIR)/port/unwind/%.c) \
1172 $(FPOBJS:%.o=$(LIBCDIR)/$(MACH)/fp/%.c) \
1173 $(LIBCBASE)/gen/ecvt.c \
1174 $(LIBCBASE)/gen/makectxt.c \
1175 $(LIBCBASE)/gen/siginfolst.c \
1176 $(LIBCBASE)/gen/siglongjmp.c \
1177 $(LIBCBASE)/gen/strcmp.c \
1178 $(LIBCBASE)/gen/sync_instruction_memory.c \
1179 $(LIBCBASE)/sys/ptrace.c \
1180 $(LIBCBASE)/sys/uadmin.c
1182 # conditional assignments
1183 $(DYNLIB) := CRTI = crti.o
1184 $(DYNLIB) := CRTN = crtn.o
1186 $(PORTSTDIO_W:%=pics/%) := \
1189 $(PORTPRINT_W:%=pics/%) := \
1192 $(PORTI18N_COND:%=pics/%) := \
1193 CPPFLAGS += -D_WCS_LONGLONG
1195 pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
1197 pics/__clock_gettime.o := CPPFLAGS += $(COMMPAGE_CPPFLAGS)
1201 all: $(LIBS) $(LIB_PIC)
1203 # include common libc targets
1204 include $(LIBCDIR)/Makefile.targ
1206 # We need to strip out all CTF and DOF data from the static library
1207 $(LIB_PIC) := DIR = pics
1208 $(LIB_PIC): pics $$(PICS)
1210 $(MCS) -d -n .SUNW_ctf $@ > /dev/null 2>&1
1211 $(MCS) -d -n .SUNW_dof $@ > /dev/null 2>&1
1212 $(AR) -ts $@ > /dev/null
1215 $(LIBCBASE)/crt/_rtbootld.s: $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.c
1216 $(CC) $(CPPFLAGS) $(i386_XARCH) $(CTF_FLAGS) -O -S $(C_PICFLAGS) \
1217 $(LIBCBASE)/crt/_rtld.c -o $(LIBCBASE)/crt/_rtld.s
1218 $(CAT) $(LIBCBASE)/crt/_rtboot.s $(LIBCBASE)/crt/_rtld.s > $@
1219 $(RM) $(LIBCBASE)/crt/_rtld.s
1221 # partially built from C source
1222 pics/_rtbootld.o: $(LIBCBASE)/crt/_rtbootld.s
1223 $(AS) $(ASFLAGS) $(LIBCBASE)/crt/_rtbootld.s -o $@
1227 _lwp_mutex_unlock.o \
1234 $(ASSYMDEP_OBJS:%=pics/%) := CPPFLAGS += -I.
1236 $(ASSYMDEP_OBJS:%=pics/%): assym.h
1238 # assym.h build rules
1240 GENASSYM_C = $(LIBCDIR)/$(MACH)/genassym.c
1242 genassym: $(GENASSYM_C)
1243 $(NATIVECC) $(NATIVE_CFLAGS) -I$(LIBCBASE)/inc -I$(LIBCDIR)/inc \
1244 -D__EXTENSIONS__ $(CPPFLAGS.native) -o $@ $(GENASSYM_C)
1246 OFFSETS = $(LIBCDIR)/$(MACH)/offsets.in
1248 assym.h: $(OFFSETS) genassym
1249 $(OFFSETS_CREATE) <$(OFFSETS) >$@
1252 # derived C source and related explicit dependencies
1253 $(LIBCDIR)/port/gen/errlst.c + \
1254 $(LIBCDIR)/port/gen/new_list.c: $(LIBCDIR)/port/gen/errlist $(LIBCDIR)/port/gen/errlist.awk
1255 cd $(LIBCDIR)/port/gen; pwd; $(AWK) -f errlist.awk < errlist
1257 pics/errlst.o: $(LIBCDIR)/port/gen/errlst.c
1259 pics/new_list.o: $(LIBCDIR)/port/gen/new_list.c