* imported qemu/hotfix-glibc-2.41.patch
[t2sde.git] / package / develop / libtool / parse-config
blob5aed50b078d7db896f3936a02cce940a124ca268
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # T2 SDE: package/*/libtool/parse-config
3 # Copyright (C) 2006 - 2023 The T2 SDE Project
4
5 # This Copyright note is generated by scripts/Create-CopyPatch,
6 # more information can be found in the files COPYING and README.
7
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2.
10 # --- T2-COPYRIGHT-NOTE-END ---
12 # On cross-builds libtool gets everything, really everything that is
13 # possible mess up, messed up - seriously. Just not installing the
14 # annoying .la-hell already helps.
16 libtool_remove_la() {
17         # A simple:
18         # var_append INSTALL_WRAPPER_FILTER '|' "sed -e 's,.*$root/.*lib.*\.la,/tmp/weg.la,'"
19         # didn't cut it, as some packages run some libtool finalization after the files
20         # got installed, and error out if the files are translated away, ...
22         grep '\.la$' $builddir/flist.txt |
23         while read f; do
24                 rm -fv "$root/$f"
25         done
26         var_append flistdel '|' '.*\.la'
28 #atstage native ||
29 hook_add postflist 5 libtool_remove_la
31 # Some packges have outdated libtool that e.g. does not handle lib64. The
32 # LIBTOOL-QUIRK flag allows automated updating of those files.
34 libtool_fixup() {
35         if atstage native; then
36                 pref=$root
37         else
38                 pref=$base/build/$SDECFG_ID/TOOLCHAIN/cross
39         fi
40         
41         [ -f configure.in -o -f configure.ac ] && libtoolize -c -f
43         find -name libtool -o -name ltmain.sh | while read fn; do
44                 case $fn in
45                         *libtool) cp -fv $pref/usr/bin/libtool $fn ;;
46                         *) cp -fv $pref/usr/share/libtool/ltmain.sh $fn ;;
47                 esac
48         done
51 # Many libtool and ltmain files contain an error which is hostile in
52 # our build environment:
53 # - on systems where the libdir is not */lib, libtool still searches
54 #   /lib and /usr/lib first
55 # - removal of temporary paths during library search does not work,
56 #   this concerns mainly dependency_libs in .la files where build system
57 #   paths and other things survive
59 # We try to correct any libtool and ltmain file now:
60 libtool_correct_files() {
61         # do not do anything if we're outside builddir (like sysfiles is)
62         [[ ${PWD//src.$pkg.$config.$id/} = $PWD ]] && return
64         # find all libtool etal files, and sed them
65         find -type f -name "libtool*" -o -name "ltmain*" -o -name "ltconfig*" -o -name "ltcf*" | while read f; do
66                 mv $f $f.ltcorrect
67                 sed    -e 's,sys_lib_dlsearch_path_spec="/lib .*$lt_ld_extra.*,sys_lib_dlsearch_path_spec="$lt_ld_extra",' \
68                        -e "s,'s% \$path % %g',\"s% \$path % %g\",g" -e "s,'s% -L\$path % %g',\"s% -L\$path % %g\",g" \
69                        -e 's,echo "$\(lib_search_path\|deplibs\|dependency_libs\) ",echo " $\1 ",g' \
70                        $f.ltcorrect > $f
71                 touch -r $f.ltcorrect $f
73                 # previous sed does (per line):
74                 # 1. Dynamic library search path
75                 #   libtool.m4/ltmain.sh use the ld.so.conf list (lt_ld_extra) of path to search for dynamic libs,
76                 #   that variable is, however prefixed with "-L/lib -L/usr/lib" statically, the latter paths are
77                 #   removed by the sed expression
78                 # 2. Wrong quotes around sed expression
79                 #   A cleanup routine for temporary paths (grep for notinst_path) in libtool*/ltmain.* removes
80                 #   paths that should not appear after installation of the library. For this to work the "$path"
81                 #   variable must be evaluated (which is not possible with ' around it)
82                 # 3. Sed expects a leading whitespace
83                 #   To be sure that the cleaning process (mentioned in 2.) works also for the first argument,
84                 #   a " " is prepended before it is run through the sed expression (see 2.).
86                 diff $f.ltcorrect $f >/dev/null || echo_warning "Corrected $f"
87                 rm -f $f.ltcorrect
88         done
91 libtool_final_check() {
92         local ld=${libdir##*/}
93         # do not do anything if we're outside builddir (like sysfiles is)
94         [[ ${PWD//src.$pkg.$config.$id/} = $PWD ]] && return
95         if [ -f libtool -a -f $root/usr/bin/libtool ] &&
96            ! egrep -q "sys_lib_search_path_spec=.* /usr/$ld " libtool
97         then
98                 echo_warning "Overwriting libtool: configure broken beyond believe"
99                 cp $root/usr/bin/libtool .
100                 echo -e "#!/bin/true" > missing
101         fi
104 if ! atstage toolchain && hasflag LIBTOOL-QUIRK; then
105         hook_add preconf 8 libtool_fixup
106 elif ! hasflag NO-LIBTOOL-FIX; then
107         hook_add preconf 8 libtool_correct_files
110 #hook_add premake 7 libtool_final_check