1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/dietlibc/parse-config-9
3 # Copyright (C) 2004 - 2021 The T2 SDE Project
4 # Copyright (C) 1998 - 2004 ROCK Linux Project
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; version 2 of the License. A copy of the
12 # GNU General Public License can be found in the file COPYING.
13 # --- T2-COPYRIGHT-NOTE-END ---
15 function set_wrapper_and_misc () {
16 export DIETHOME=$root/usr/dietlibc
17 if ! atstage native || [ "$SDECFG_LIBC" != "dietlibc" ] ; then
18 var_append CC_WRAPPER_OTHERS ":" $dietbin
21 if [ "$diet_dynamic_static" == "static" ] ; then
22 var_append extraconfopt ' ' '--disable-shared --without-shared'
23 var_append GCC_WRAPPER_INSERT ' ' '-c?:-static'
25 var_append GCC_WRAPPER_INSERT ' ' '-D__dietlibc__'
29 var_append CC_WRAPPER_APPEND " " "-c?:$1"
32 function remove_lib () {
33 var_append CC_WRAPPER_REMOVE " " "$1"
36 function pkg_dietlibc_rebuild () {
38 . $base/package/*/dietlibc/parse-config-9
39 var_append patchfiles " " `ls $confdir/*.patch.dietlibc.2nd 2>/dev/null`
42 # TODO: re-schedule a clean rebuild
44 eval_config_command $confopt $extraconfopt
47 eval $MAKE $makeinstopt
51 # decide wether to compile the package with dietlibc or not
52 if [ "$SDECFG_LIBC" = "dietlibc" -o "$pkg" = "dietlibc" ]; then
55 x="${pkg//-/_}" ; x="${x//+/_}"
56 eval "pkg_dietlibc_useit=\$SDECFG_DIETLIBC_${x}"
59 [ "$pkg_dietlibc_useit" != 1 ] && pkg_dietlibc_useit=0
61 [ "$pkg_dietlibc_useit" = 1 -a $pkg = gcc ] &&
62 var_append extraconfopt " " "--disable-threads"
64 # never use dietlibc in stage 0
65 atstage toolchain && pkg_dietlibc_useit=0
67 # for some package only build with dielitbc, if this is the second run
68 if [ "$SDECFG_LIBC" != "dietlibc" -a "$pkg_dietlibc_useit" = 1 ]; then
71 if [ "$pkg_udev_this_is_the_second_run" != 1 ]; then
72 echo_status "First pass, linking against system libc"
74 hook_add postmake 7 pkg_dietlibc_rebuild
76 echo_status "Second pass, linking against dietlibc"
78 var_append extraconfopt ' ' '--enable-shared=no'
79 var_remove confopt ' ' '--enable-extras'
80 var_append confopt ' ' '--disable-extras'
86 if [ "$pkg_dietlibc_useit" = 1 ]; then
87 # If we use something like 'i386-pc-linux-gnu' as architecture name,
88 # some programs start using gnu extensions. So we use ...-gnudietlibc
91 pkg_dietlibc_orig_target="$arch_target"
92 arch_target="${arch_target%-*}-gnudietlibc"
93 if atstage native; then
94 arch_build="${arch_target}"
97 if [ -d $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin ] ; then
98 PATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin:$PATH"
101 if [ "$SDECFG_DIETLIBC_DYN" = "1" ]
102 then dietbin="diet-dyn" ; diet_dynamic_static="dynamic"
103 else dietbin="diet" ; diet_dynamic_static="static" ; fi
105 echo_status "Preparing configuration to build this package with dietlibc ("${diet_dynamic_static}"ally)"
107 if atstage native; then
108 var_remove CC_WRAPPER_INSERT " " "-pipe"
109 var_append CC_WRAPPER_REMOVE " " "-pipe"
111 var_remove GCC_WRAPPER_INSERT " " "-pipe"
112 var_append GCC_WRAPPER_REMOVE " " "-pipe"
114 var_remove KCC_WRAPPER_INSERT " " "-pipe"
115 var_append KCC_WRAPPER_REMOVE " " "-pipe"
118 if [ "$GCC_WRAPPER_INSERT" != "${GCC_WRAPPER_INSERT/-fstack-protector}" ]; then
119 echo_warning 'Disabling GCC stack-protector for dietlibc-based package.'
120 var_remove GCC_WRAPPER_INSERT ' ' '-fstack-protector'
123 # patch has problems with Plan A patching so we switch with -x 16 to Plan B
124 atstage rebuild && var_append patchopt ' ' '-x 16'
131 echo_status "Dietlibc not utilized for this package."
132 if atstage native && [ "$diet_dynamic_static" == "static" ]; then
133 var_append GCC_WRAPPER_INSERT " " "-static"
137 iptables|mmv|grsecurity)
138 echo_status "Enabling non-portable GNU features."
139 var_append CC_WRAPPER_INSERT " " "-D_GNU_SOURCE"
143 coreutils|findutils|curl|procps|radiusclient-ng|libpcap|binutils|udhcp|file|libxml|mdadm|lvm2|iputils|bsdiff)
144 echo_status "Enabling non-portable BSD features."
145 var_append CC_WRAPPER_INSERT " " "-D_BSD_SOURCE"
149 e2fsprogs|util-linux|ash|irda-utils|ppp|dropbear|nullmailer|traceroute|udev)
150 echo_status "Enabling non-portable GNU and BSD features."
151 var_append CC_WRAPPER_INSERT " " "-D_GNU_SOURCE -D_BSD_SOURCE"
155 echo_status "Enabling non-portable GNU, BSD features and types."
156 var_append CC_WRAPPER_INSERT " " "-D_GNU_SOURCE -D_BSD_SOURCE"
157 var_append CC_WRAPPER_INSERT " " "-D__BIT_TYPES_DEFINED__"
161 echo_status "Setting __GLIBC__=3 to build the package!"
162 var_append CC_WRAPPER_INSERT " " "-D__GLIBC__=3"
166 echo_status "Enabling non-portable GNU, BSD features and a lot of other tweaks."
167 var_append CC_WRAPPER_INSERT " " "-D_GNU_SOURCE -D_BSD_SOURCE"
168 var_append CC_WRAPPER_INSERT " " "-D__GLIBC__"
169 var_append CC_WRAPPER_INSERT " " "-D_LINUX_IN6_H"
173 #var_append CC_WRAPPER_INSERT " " "-DHAVE_SYS_TIME_H"
174 #set_wrapper_and_misc
182 sed|lilo|findutils|net-tools|dropbear|udev|rng-tools|udhcp|psmisc|bsdiff)
187 var_remove patchfiles " " "*acl-xattr.patch"
190 var_append extraconfopt " " \
191 "--without-cxx-binding --without-cxx"
194 var_append extraconfopt " " "--disable-threads"
197 add_lib "-lrpc -lcompat"
200 var_append extraconfopt " " "--disable-rmt"
203 add_lib "-lm -lcompat"
213 [ "$diet_dynamic_static" == "static" ] || add_lib "-ldl"
217 if [ "$diet_dynamic_static" == "static" ]; then
218 var_append makeopt ' ' 'SHARED=0'
219 var_append makeinstopt ' ' 'SHARED=0'
224 var_append patchfiles " " `ls $confdir/*.patch.dietlibc 2>/dev/null`
227 pkg_udev_this_is_the_second_run=1