1994-05-27 05:00:24 +00:00
|
|
|
# @(#)Makefile 8.2 (Berkeley) 2/3/94
|
1999-08-28 00:22:10 +00:00
|
|
|
# $FreeBSD$
|
2006-03-17 18:54:44 +00:00
|
|
|
|
2006-03-18 11:01:06 +00:00
|
|
|
SHLIBDIR?= /lib
|
|
|
|
|
2006-03-17 18:54:44 +00:00
|
|
|
.include <bsd.own.mk>
|
|
|
|
|
2010-08-25 20:48:24 +00:00
|
|
|
# Pick the current architecture directory for libc. In general, this is
|
|
|
|
# named MACHINE_CPUARCH, but some ABIs are different enough to require
|
|
|
|
# their own libc, so allow a directory named MACHINE_ARCH to override this.
|
|
|
|
|
|
|
|
.if exists(${.CURDIR}/${MACHINE_ARCH})
|
2010-08-24 20:54:43 +00:00
|
|
|
LIBC_ARCH=${MACHINE_ARCH}
|
|
|
|
.else
|
2010-08-24 21:28:34 +00:00
|
|
|
LIBC_ARCH=${MACHINE_CPUARCH}
|
2010-08-24 20:54:43 +00:00
|
|
|
.endif
|
|
|
|
|
2002-03-23 20:08:00 +00:00
|
|
|
# All library objects contain FreeBSD revision strings by default; they may be
|
1994-05-27 05:00:24 +00:00
|
|
|
# excluded as a space-saving measure. To produce a library that does
|
2002-03-26 23:08:42 +00:00
|
|
|
# not contain these strings, add -DSTRIP_FBSDID (see <sys/cdefs.h>) to CFLAGS
|
2003-12-11 09:53:25 +00:00
|
|
|
# below. Note: there are no IDs for syscall stubs whose sources are generated.
|
|
|
|
# To include legacy CSRG sccsid strings, add -DLIBC_SCCS and -DSYSLIBC_SCCS
|
|
|
|
# to CFLAGS below. -DSYSLIBC_SCCS affects just the system call stubs.
|
1994-05-27 05:00:24 +00:00
|
|
|
LIB=c
|
2006-05-21 15:15:21 +00:00
|
|
|
SHLIB_MAJOR= 7
|
Turn libc.so into an ld script rather than a symlink pointing to the
real shared object and libssp_nonshared.a.
This was the last showstopper that prevented from enabling SSP for ports
by default. portmgr@ performed a buildworld which showed no significant
breakage with this patch.
Details:
On i386 for PIC objects, gcc uses the __stack_chk_fail_local hidden
symbol instead of calling __stack_chk_fail directly [1]. This happen
not only with our gcc-4.2.1 but also with the latest gcc-4.8. If you
want the very nasty details, see [2].
OTOH the problem doesn't exist on other architectures. It also doesn't
exist with Clang as the latter will somehow manage to create the
function in the object file at compile time (contrary to only
referencing it through a symbol that will be brought in at link time).
In a perfect world, when an object file is compiled with
-fstack-protector, it will be linked into a binary or a DSO with this
same flag as well, so GCC will add libssp_nonshared.a to the linker
command-line. Unfortunately, we don't control softwares in ports and we
may have such broken DSO. This is the whole point of this patch.
You can reproduce the problem on i386 by compiling a source file into an
object file with "-fstack-protector-all -fPIE" and linking it
into a binary without "-fstack-protector".
This ld script automatically proposes libssp_nonshared.a along with the
real libc DSO to the linker. It is important to understand that the
object file contained in this library will be pulled in the resulting
binary _only if_ the linker notices one of its symbols is needed (i.e.
one of the SSP symbol is missing).
A theorical performance impact could be when compiling, but my testing
showed less than 0.1% of difference.
[1] For 32-bit code gcc saves the PIC register setup by using
__stack_chk_fail_local hidden function instead of calling
__stack_chk_fail directly. See comment line 19460 in:
src/contrib/gcc/config/i386/i386.c
[2] When compiling a source file to an object file, if you use something
which is external to the compilation unit, GCC doesn't know yet if
this symbol will be inside or outside the DSO. So it expects the
worst case and routes the symbol through the GOT, which means
additional space and extra relocation for rtld(1).
Declaring a symbol has hidden tells GCC to use the optimal route (no
GOT), but on the other hand this means the symbol has to be provided
in the same DSO (namely libssp_nonshared.a).
On i386, GCC actually uses an hidden symbol for SSP in PIC objects
to save PIC register setup, as said in [1].
PR: ports/138228
PR: ports/168010
Reviewed by: kib, kan
2013-06-12 21:12:05 +00:00
|
|
|
SHLIB_LDSCRIPT=libc.ldscript
|
2004-01-19 16:16:53 +00:00
|
|
|
WARNS?= 2
|
2003-07-01 15:07:01 +00:00
|
|
|
CFLAGS+=-I${.CURDIR}/include -I${.CURDIR}/../../include
|
2010-08-24 20:54:43 +00:00
|
|
|
CFLAGS+=-I${.CURDIR}/${LIBC_ARCH}
|
2012-05-21 08:10:42 +00:00
|
|
|
.if ${MK_NLS} != "no"
|
2009-03-13 10:40:38 +00:00
|
|
|
CFLAGS+=-DNLS
|
2012-05-21 08:10:42 +00:00
|
|
|
.endif
|
1994-05-27 05:00:24 +00:00
|
|
|
CLEANFILES+=tags
|
2004-10-24 15:33:08 +00:00
|
|
|
INSTALL_PIC_ARCHIVE=
|
|
|
|
PRECIOUSLIB=
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-09-25 01:57:47 +00:00
|
|
|
.ifndef NO_THREAD_STACK_UNWIND
|
|
|
|
CANCELPOINTS_CFLAGS=-fexceptions
|
|
|
|
CFLAGS+=${CANCELPOINTS_CFLAGS}
|
|
|
|
.endif
|
|
|
|
|
2007-05-19 04:32:56 +00:00
|
|
|
#
|
|
|
|
# Only link with static libgcc.a (no libgcc_eh.a).
|
|
|
|
#
|
2007-10-01 18:15:11 +00:00
|
|
|
DPADD+= ${LIBGCC}
|
2007-05-19 16:38:39 +00:00
|
|
|
LDFLAGS+= -nodefaultlibs
|
2012-05-19 17:49:20 +00:00
|
|
|
LDADD+= -lgcc
|
|
|
|
|
|
|
|
.if ${MK_SSP} != "no"
|
|
|
|
LDADD+= -lssp_nonshared
|
|
|
|
.endif
|
2007-05-19 04:32:56 +00:00
|
|
|
|
2013-11-25 20:17:55 +00:00
|
|
|
# Extras that live in either libc.a or libc_nonshared.a
|
|
|
|
LIBC_NONSHARED_SRCS=
|
|
|
|
|
2002-11-18 09:50:57 +00:00
|
|
|
# Define (empty) variables so that make doesn't give substitution
|
|
|
|
# errors if the included makefiles don't change these:
|
|
|
|
MDSRCS=
|
|
|
|
MISRCS=
|
|
|
|
MDASM=
|
|
|
|
MIASM=
|
|
|
|
NOASM=
|
|
|
|
|
2010-08-24 20:54:43 +00:00
|
|
|
.include "${.CURDIR}/${LIBC_ARCH}/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/db/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/compat-43/Makefile.inc"
|
2003-03-13 18:55:14 +00:00
|
|
|
.include "${.CURDIR}/gdtoa/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/gen/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/gmon/Makefile.inc"
|
Add the BSD-licensed Citrus iconv to the base system with default off
setting. It can be built by setting the WITH_ICONV knob. While this
knob is unset, the library part, the binaries, the header file and
the metadata files will not be built or installed so it makes no impact
on the system if left turned off.
This work is based on the iconv implementation in NetBSD but a great
number of improvements and feature additions have been included:
- Some utilities have been added. There is a conversion table generator,
which can compare conversion tables to reference data generated by
GNU libiconv. This helps ensuring conversion compatibility.
- UTF-16 surrogate support and some endianness issues have been fixed.
- The rather chaotic Makefiles to build metadata have been refactored
and cleaned up, now it is easy to read and it is also easier to add
support for new encodings.
- A bunch of new encodings and encoding aliases have been added.
- Support for 1->2, 1->3 and 1->4 mappings, which is needed for
transliterating with flying accents as GNU does, like "u.
- Lots of warnings have been fixed, the major part of the code is
now WARNS=6 clean.
- New section 1 and section 5 manual pages have been added.
- Some GNU-specific calls have been implemented:
iconvlist(), iconvctl(), iconv_canonicalize(), iconv_open_into()
- Support for GNU's //IGNORE suffix has been added.
- The "-" argument for stdin is now recognized in iconv(1) as per POSIX.
- The Big5 conversion module has been fixed.
- The iconv.h header files is supposed to be compatible with the
GNU version, i.e. sources should build with base iconv.h and
GNU libiconv. It also includes a macro magic to deal with the
char ** and const char ** incompatibility.
- GNU compatibility: "" or "char" means the current local
encoding in use
- Various cleanups and style(9) fixes.
Approved by: delphij (mentor)
Obtained from: The NetBSD Project
Sponsored by: Google Summer of Code 2009
2011-02-25 00:04:39 +00:00
|
|
|
.if ${MK_ICONV} != "no"
|
|
|
|
.include "${.CURDIR}/iconv/Makefile.inc"
|
|
|
|
.endif
|
Update the resolver in libc to BIND9's one.
Since, res_sendsigned(3) and the friends use MD5 functions, it is
hard to include them without having MD5 functions in libc. So,
res_sendsigned(3) is not merged into libc.
Since, res_update(3) in BIND9 is not binary compatible with our
res_update(3), res_update(3) is leaved as is, except some
necessary modifications.
The res_update(3) and the friends are not essential part of the
resolver. They are not defined in resolv.h but defined in
res_update.h separately in BIND9. Further, they are not called from
our tree. So, I hide them from our resolv.h, but leave them only
for binary backward compatibility (perhaps, no one calls them).
Since, struct __res_state_ext is not exposed in BIND9, I hide it
from our resolv.h. And, global variable _res_ext is removed. It
breaks binary backward compatibility. But, since it is not used from
outside of our libc, I think it is safe.
Reviewed by: arch@ (no objection)
2006-03-21 16:11:11 +00:00
|
|
|
.include "${.CURDIR}/inet/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/isc/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/locale/Makefile.inc"
|
Update the resolver in libc to BIND9's one.
Since, res_sendsigned(3) and the friends use MD5 functions, it is
hard to include them without having MD5 functions in libc. So,
res_sendsigned(3) is not merged into libc.
Since, res_update(3) in BIND9 is not binary compatible with our
res_update(3), res_update(3) is leaved as is, except some
necessary modifications.
The res_update(3) and the friends are not essential part of the
resolver. They are not defined in resolv.h but defined in
res_update.h separately in BIND9. Further, they are not called from
our tree. So, I hide them from our resolv.h, but leave them only
for binary backward compatibility (perhaps, no one calls them).
Since, struct __res_state_ext is not exposed in BIND9, I hide it
from our resolv.h. And, global variable _res_ext is removed. It
breaks binary backward compatibility. But, since it is not used from
outside of our libc, I think it is safe.
Reviewed by: arch@ (no objection)
2006-03-21 16:11:11 +00:00
|
|
|
.include "${.CURDIR}/nameser/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/net/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/nls/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/posix1e/Makefile.inc"
|
2010-08-24 20:54:43 +00:00
|
|
|
.if ${LIBC_ARCH} != "amd64" && \
|
|
|
|
${LIBC_ARCH} != "ia64" && \
|
|
|
|
${LIBC_ARCH} != "powerpc64" && \
|
|
|
|
${LIBC_ARCH} != "sparc64" && \
|
2011-01-27 14:16:12 +00:00
|
|
|
${MACHINE_ARCH:Mmipsn32*} == "" && \
|
2011-01-07 20:26:33 +00:00
|
|
|
${MACHINE_ARCH:Mmips64*} == ""
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/quad/Makefile.inc"
|
|
|
|
.endif
|
|
|
|
.include "${.CURDIR}/regex/Makefile.inc"
|
Update the resolver in libc to BIND9's one.
Since, res_sendsigned(3) and the friends use MD5 functions, it is
hard to include them without having MD5 functions in libc. So,
res_sendsigned(3) is not merged into libc.
Since, res_update(3) in BIND9 is not binary compatible with our
res_update(3), res_update(3) is leaved as is, except some
necessary modifications.
The res_update(3) and the friends are not essential part of the
resolver. They are not defined in resolv.h but defined in
res_update.h separately in BIND9. Further, they are not called from
our tree. So, I hide them from our resolv.h, but leave them only
for binary backward compatibility (perhaps, no one calls them).
Since, struct __res_state_ext is not exposed in BIND9, I hide it
from our resolv.h. And, global variable _res_ext is removed. It
breaks binary backward compatibility. But, since it is not used from
outside of our libc, I think it is safe.
Reviewed by: arch@ (no objection)
2006-03-21 16:11:11 +00:00
|
|
|
.include "${.CURDIR}/resolv/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/stdio/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/stdlib/Makefile.inc"
|
2012-04-17 07:22:14 +00:00
|
|
|
.include "${.CURDIR}/stdlib/jemalloc/Makefile.inc"
|
2002-11-18 09:50:57 +00:00
|
|
|
.include "${.CURDIR}/stdtime/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/string/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/sys/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/rpc/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/uuid/Makefile.inc"
|
|
|
|
.include "${.CURDIR}/xdr/Makefile.inc"
|
2010-08-24 20:54:43 +00:00
|
|
|
.if ${LIBC_ARCH} == "arm" || ${LIBC_ARCH} == "mips"
|
2004-05-14 12:04:31 +00:00
|
|
|
.include "${.CURDIR}/softfloat/Makefile.inc"
|
|
|
|
.endif
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_NIS} != "no"
|
2002-11-18 09:50:57 +00:00
|
|
|
CFLAGS+= -DYP
|
|
|
|
.include "${.CURDIR}/yp/Makefile.inc"
|
|
|
|
.endif
|
Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.
The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.
The structure definition looks like this:
struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};
The initial CAP_RIGHTS_VERSION is 0.
The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.
The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.
To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.
#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)
We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:
#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)
#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)
There is new API to manage the new cap_rights_t structure:
cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);
bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);
Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:
cap_rights_t rights;
cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);
There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:
#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);
Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:
cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);
Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.
This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.
Sponsored by: The FreeBSD Foundation
2013-09-05 00:09:56 +00:00
|
|
|
.include "${.CURDIR}/capability/Makefile.inc"
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_HESIOD} != "no"
|
2002-11-18 09:50:57 +00:00
|
|
|
CFLAGS+= -DHESIOD
|
|
|
|
.endif
|
2006-03-17 18:54:44 +00:00
|
|
|
.if ${MK_FP_LIBC} == "no"
|
2004-05-02 10:55:07 +00:00
|
|
|
CFLAGS+= -DNO_FLOATING_POINT
|
|
|
|
.endif
|
2006-04-28 12:03:38 +00:00
|
|
|
.if ${MK_NS_CACHING} != "no"
|
|
|
|
CFLAGS+= -DNS_CACHING
|
|
|
|
.endif
|
2007-03-04 12:25:03 +00:00
|
|
|
.if defined(_FREEFALL_CONFIG)
|
|
|
|
CFLAGS+=-D_FREEFALL_CONFIG
|
|
|
|
.endif
|
2002-11-18 09:50:57 +00:00
|
|
|
|
2013-11-25 20:17:55 +00:00
|
|
|
STATICOBJS+=${LIBC_NONSHARED_SRCS:S/.c$/.o/}
|
|
|
|
|
2006-03-16 15:16:23 +00:00
|
|
|
VERSION_DEF=${.CURDIR}/Versions.def
|
|
|
|
SYMBOL_MAPS=${SYM_MAPS}
|
|
|
|
CFLAGS+= -DSYMBOL_VERSIONING
|
|
|
|
|
2002-11-18 09:50:57 +00:00
|
|
|
# If there are no machine dependent sources, append all the
|
|
|
|
# machine-independent sources:
|
|
|
|
.if empty(MDSRCS)
|
|
|
|
SRCS+= ${MISRCS}
|
|
|
|
.else
|
|
|
|
# Append machine-dependent sources, then append machine-independent sources
|
|
|
|
# for which there is no machine-dependent variant.
|
|
|
|
SRCS+= ${MDSRCS}
|
|
|
|
.for _src in ${MISRCS}
|
|
|
|
.if ${MDSRCS:R:M${_src:R}} == ""
|
|
|
|
SRCS+= ${_src}
|
|
|
|
.endif
|
|
|
|
.endfor
|
|
|
|
.endif
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
KQSRCS= adddi3.c anddi3.c ashldi3.c ashrdi3.c cmpdi2.c divdi3.c iordi3.c \
|
|
|
|
lshldi3.c lshrdi3.c moddi3.c muldi3.c negdi2.c notdi2.c qdivrem.c \
|
|
|
|
subdi3.c ucmpdi2.c udivdi3.c umoddi3.c xordi3.c
|
2012-01-03 07:14:01 +00:00
|
|
|
KSRCS= bcmp.c ffs.c ffsl.c fls.c flsl.c mcount.c strcat.c strchr.c \
|
|
|
|
strcmp.c strcpy.c strlen.c strncpy.c strrchr.c
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-08-24 20:54:43 +00:00
|
|
|
libkern: libkern.gen libkern.${LIBC_ARCH}
|
1994-05-27 05:00:24 +00:00
|
|
|
|
|
|
|
libkern.gen: ${KQSRCS} ${KSRCS}
|
1997-05-23 08:24:00 +00:00
|
|
|
cp -p ${.CURDIR}/quad/quad.h ${.ALLSRC} ${DESTDIR}/sys/libkern
|
1994-05-27 05:00:24 +00:00
|
|
|
|
2010-08-24 20:54:43 +00:00
|
|
|
libkern.${LIBC_ARCH}:: ${KMSRCS}
|
1994-05-27 05:00:24 +00:00
|
|
|
.if defined(KMSRCS) && !empty(KMSRCS)
|
2010-08-24 20:54:43 +00:00
|
|
|
cp -p ${.ALLSRC} ${DESTDIR}/sys/libkern/${LIBC_ARCH}
|
1994-05-27 05:00:24 +00:00
|
|
|
.endif
|
2010-08-23 15:18:35 +00:00
|
|
|
|
1994-05-27 05:00:24 +00:00
|
|
|
.include <bsd.lib.mk>
|
2004-01-11 10:42:47 +00:00
|
|
|
|
|
|
|
# Disable warnings in contributed sources.
|
2010-08-01 12:35:01 +00:00
|
|
|
CWARNFLAGS:= ${.IMPSRC:Ngdtoa_*.c:C/^.+$/${CWARNFLAGS}/:C/^$/-w/}
|
2008-06-25 21:33:28 +00:00
|
|
|
# XXX For now, we don't allow libc to be compiled with
|
|
|
|
# -fstack-protector-all because it breaks rtld. We may want to make a librtld
|
|
|
|
# in the future to circumvent this.
|
|
|
|
SSP_CFLAGS:= ${SSP_CFLAGS:S/^-fstack-protector-all$/-fstack-protector/}
|
|
|
|
# Disable stack protection for SSP symbols.
|
|
|
|
SSP_CFLAGS:= ${.IMPSRC:N*/stack_protector.c:C/^.+$/${SSP_CFLAGS}/}
|
2010-09-25 01:57:47 +00:00
|
|
|
# Generate stack unwinding tables for cancellation points
|
|
|
|
CANCELPOINTS_CFLAGS:= ${.IMPSRC:Mcancelpoints_*:C/^.+$/${CANCELPOINTS_CFLAGS}/:C/^$//}
|