Dash:
[t2.git] / package / base / dietlibc / parse-config-9
blob93ace9abd49d59627ef0b38012c5064def9f80a8
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
5
6 # This Copyright note is generated by scripts/Create-CopyPatch,
7 # more information can be found in the files COPYING and README.
8
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
19         fi
21         if [ "$diet_dynamic_static" == "static"  ] ; then
22           var_append extraconfopt ' ' '--disable-shared --without-shared'
23           var_append GCC_WRAPPER_INSERT ' ' '-c?:-static'
24         fi
25         var_append GCC_WRAPPER_INSERT ' ' '-D__dietlibc__'
28 function add_lib () {
29         var_append CC_WRAPPER_APPEND " " "-c?:$1"
32 function remove_lib () {
33         var_append CC_WRAPPER_REMOVE " " "$1"
36 function pkg_dietlibc_rebuild () {
37         patchfiles=
38         . $base/package/*/dietlibc/parse-config-9
39         var_append patchfiles " " `ls $confdir/*.patch.dietlibc.2nd 2>/dev/null`
40         apply_patchfiles
42         # TODO: re-schedule a clean rebuild
43         rm -f config.cache
44         eval_config_command $confopt $extraconfopt
45         eval $MAKE clean
46         eval $MAKE $makeopt
47         eval $MAKE $makeinstopt
51 # decide wether to compile the package with dietlibc or not
52 if [ "$SDECFG_LIBC" = "dietlibc" -o "$pkg" = "dietlibc" ]; then
53         pkg_dietlibc_useit=1
54 else
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
69   case $pkg in
70         udev)
71                 if [ "$pkg_udev_this_is_the_second_run" != 1 ]; then
72                         echo_status "First pass, linking against system libc"
73                         pkg_dietlibc_useit=0
74                         hook_add postmake 7 pkg_dietlibc_rebuild
75                 else
76                         echo_status "Second pass, linking against dietlibc"
77                         rm -vf config.cache
78                         var_append extraconfopt ' ' '--enable-shared=no'
79                         var_remove confopt ' ' '--enable-extras'
80                         var_append confopt ' ' '--disable-extras'
81                 fi
82                 ;;
83   esac
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
89         # instead.
90         #
91         pkg_dietlibc_orig_target="$arch_target"
92         arch_target="${arch_target%-*}-gnudietlibc"
93         if atstage native; then
94                 arch_build="${arch_target}"
95         fi
97         if [ -d $base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin ] ; then
98                 PATH="$base/build/$SDECFG_ID/TOOLCHAIN/$toolsdir/diet-bin:$PATH"
99         fi
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"
116         fi
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'
121         fi
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'
126         case "$pkg" in
127                 dietlibc)
128                         ;;
130                 linux*)
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"
134                         fi
135                         ;;
137                 iptables|mmv|grsecurity)
138                         echo_status "Enabling non-portable GNU features."
139                         var_append CC_WRAPPER_INSERT " " "-D_GNU_SOURCE"
140                         set_wrapper_and_misc
141                         ;;
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"
146                         set_wrapper_and_misc
147                         ;;
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"
152                         set_wrapper_and_misc
153                         ;;
154                 nvi)
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__"
158                         set_wrapper_and_misc
159                         ;;
160                 iproute2)
161                         echo_status "Setting __GLIBC__=3 to build the package!"
162                         var_append CC_WRAPPER_INSERT " " "-D__GLIBC__=3"
163                         set_wrapper_and_misc
164                         ;;
165                 net-tools)
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"
170                         set_wrapper_and_misc
171                         ;;
172                 #squid)
173                         #var_append CC_WRAPPER_INSERT " " "-DHAVE_SYS_TIME_H"
174                         #set_wrapper_and_misc
175                 #       ;;
176                 *)
177                         set_wrapper_and_misc
178                         ;;
179         esac
181         case "$pkg" in
182                 sed|lilo|findutils|net-tools|dropbear|udev|rng-tools|udhcp|psmisc|bsdiff)
183                         add_lib "-lcompat"
184                         ;;
185                 coreutils)
186                         add_lib "-lcompat"
187                         var_remove patchfiles " " "*acl-xattr.patch"
188                         ;;
189                 ncurses)
190                         var_append extraconfopt " " \
191                           "--without-cxx-binding --without-cxx"
192                         ;;
193                 pkgconfig)
194                         var_append extraconfopt " " "--disable-threads"
195                         ;;
196                 util-linux)
197                         add_lib "-lrpc -lcompat"
198                         ;;
199                 dump)
200                         var_append extraconfopt " " "--disable-rmt"
201                         ;;
202                 perl)
203                         add_lib "-lm -lcompat"
204                         ;;
205                 openssl|gettext)
206                         remove_lib "-ldl"
207                         ;;
208                 iptables)
209                         add_lib "-lrpc"
210                         remove_lib "-lnsl"
211                         ;;
212                 gawk)
213                         [ "$diet_dynamic_static" == "static" ] || add_lib "-ldl"
214                         ;;
216                 procps)
217                         if [ "$diet_dynamic_static" == "static"  ]; then
218                                 var_append makeopt ' ' 'SHARED=0'
219                                 var_append makeinstopt ' ' 'SHARED=0'
220                         fi
221                         ;;
222         esac
224         var_append patchfiles " " `ls $confdir/*.patch.dietlibc 2>/dev/null`
227 pkg_udev_this_is_the_second_run=1