author | Olivier Brunel
<jjk@jjacky.com> 2023-12-23 14:22:50 UTC |
committer | Olivier Brunel
<jjk@jjacky.com> 2024-01-09 18:16:31 UTC |
parent | d84f54d473477cc06c039a2a7e8b411792aedbba |
configure | +91 | -35 |
diff --git a/configure b/configure index d2871e3..952bfc4 100755 --- a/configure +++ b/configure @@ -49,6 +49,9 @@ usage: $0 [OPTION..] --sharedir=DIR Set share directory to DIR [PREFIX/share] $s + --add-deppath=DIR Add DIR to the path to look for dependencies + --add-incpath=DIR Add DIR to the path to look for dependencies' headers + --no-shared Don't build shared libraries --no-static Don't build static libraries --no-doc Don't build documentation @@ -78,6 +81,9 @@ libdir= incdir= sharedir= +deppath=/lib:/usr/lib +incpath=/include:/usr/include + # this isn't quite right, since skalibs could be optional, but it'll do. has_skalibs=0 if test -d meta/deps/skalibs; then has_skalibs=1; fi @@ -121,13 +127,19 @@ for arg ; do --sysdeps=*) if test $has_skalibs -eq 1; then sysdeps=${arg#*=}; else error 1 "invalid option '$arg'"; fi;; + --no-shared) noshared=1 ;; --no-static) nostatic=1 ;; --no-doc|--no-docs|--no-documentation) nodoc=1 ;; + + --add-deppath=*) deppath="${arg#*=}:$deppath" ;; + --add-incpath=*) incpath="${arg#*=}:$incpath" ;; + --prefer-shared) prefer=shared ;; --prefer-static) prefer=static ;; --set-shared=*) eval "link${arg#*=}=1" ;; --set-static=*) eval "link${arg#*=}=2" ;; + --with-*) setoption $(expr substr "$arg" 8 ${#arg}) 0 ;; --without-*) setoption $(expr substr "$arg" 11 ${#arg}) 1 ;; --enable-*) setoption $(expr substr "$arg" 10 ${#arg}) 0 ;; @@ -139,18 +151,27 @@ for arg ; do esac done +if test -n "$prefix"; then + deppath="$prefix/lib:$deppath" + incpath="$prefix/include:$incpath" +fi if test -z "$prefix"; then prefix="/usr"; fi if test -z "$bindir"; then bindir="$prefix/bin"; fi if test -z "$libdir"; then libdir="$prefix/lib"; fi if test -z "$incdir"; then incdir="$prefix/include"; fi if test -z "$sharedir"; then sharedir="$prefix/share"; fi -if test -z "$sysdeps"; then sysdeps="$libdir/skalibs/sysdeps"; fi +deppath="$(echo $deppath | sed 's/\/\+/\//g')" +incpath="$(echo $incpath | sed 's/\/\+/\//g')" bindir="$(echo $bindir | sed 's/\/\+/\//g')" libdir="$(echo $libdir | sed 's/\/\+/\//g')" incdir="$(echo $incdir | sed 's/\/\+/\//g')" sharedir="$(echo $sharedir | sed 's/\/\+/\//g')" -sysdeps="$(echo $sysdeps | sed 's/\/\+/\//g')" + +ndeppath=$(echo $deppath | tr -dc : | wc -c) +nincpath=$(echo $incpath | tr -dc : | wc -c) +ndeppath=$(( ndeppath + 1 )) +nincpath=$(( nincpath + 1 )) # pass 2, to be able to use state of other options as selection setoptionsdefault @@ -161,29 +182,47 @@ procdep_real() { local depdir="$1" local intdir="$2" - local libdir="$3" - local incdir="$4" local depname="${depdir##*/}" - local libname="$(cat "$depdir/library" 2>/dev/null)" - if test -z "$libname"; then libname="$depname"; fi # internal or not? local isint=0 if test -d "$intdir/$depname"; then isint=1; fi - local d + # is it lila? + local islila=0 + if ! test -e "$depdir/get_version"; then islila=1; fi - # can we find it? if test $isint -eq 1; then - d="$intdir/$depname" + procdep_search "$depname" "$depdir" "$intdir" $isint $islila "$intdir/$depname" else - d="$libdir" + local i=1 + local s + + while test $i -le $ndeppath; do + s="$(echo $deppath | cut -d: -f$i)" + s="$(procdep_search "$depname" "$depdir" "$intdir" $isint $islila "$s")" + if ! test "$(expr substr "$s" 3 8)" = "NOTFOUND"; then + echo $s + return + fi + i=$(( ++i )) + done + echo "$isint NOTFOUND" fi +} - # is it lila? - local islila=0 - if ! test -e "$depdir/get_version"; then islila=1; fi +procdep_search() +{ + local depname="$1" + local depdir="$2" + local intdir="$3" + local isint="$4" + local islila="$5" + local libdir="$6" + local d="$libdir" + + local incdir # look for it local vpath @@ -196,6 +235,7 @@ procdep_real() if test $isint -eq 1; then d="$d/build"; fi if ! test -d "$d/comain/$depname"; then echo $isint NOTFOUND + return fi else r=0 @@ -205,20 +245,41 @@ procdep_real() if test $? -eq 0; then r=1; fi if test $r -eq 0; then echo $isint NOTFOUND + return fi - r=0 + local p + local n if test $isint -eq 1; then - inc="$d" + n=1 + p="$d" else - inc="$incdir" + n=$nincpath + p="$incpath" fi - inc="$inc/$($depdir/is_found $isint include "$inc" 2>/dev/null)" - if test $? -eq 0; then r=1; fi + + local i=1 + local s + + r=0 + while test $i -le $n; do + s="$(echo $p | cut -d: -f$i)" + inc="$($depdir/is_found $isint include "$s" 2>/dev/null)" + if test $? -eq 0; then + r=1 + break + fi + i=$(( ++i )) + done if test $r -eq 0; then echo $isint INCNOTFOUND + return + fi + if test "$inc" = "-"; then + incdir= + else + incdir="$s/$inc" fi - incdir="$inc" fi fi @@ -277,26 +338,18 @@ procdep_real() cflagsA="$(cat "$d/cflags.static" 2>/dev/null)" cppflags="$(cat "$d/cppflags" 2>/dev/null)" cppflagsA="$(cat "$d/cppflags.static" 2>/dev/null)" - vpath="$libdir" - vpathA="$libdir" else libs="$("$depdir/get_libs" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" libsA="$("$depdir/get_libs" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" + inc="$incdir" ldflags="$("$depdir/get_ldflags" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" ldflagsA="$("$depdir/get_ldflags" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" cflags="$("$depdir/get_cflags" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" cflagsA="$("$depdir/get_cflags" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" cppflags="$("$depdir/get_cppflags" shared $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" cppflagsA="$("$depdir/get_cppflags" static $isint "$intdir/$depname" "$libdir" "$incdir" 2>/dev/null)" - vpath="$("$depdir/get_vpath" shared "$libdir" 2>/dev/null)" - vpathA="$("$depdir/get_vpath" static "$libdir" 2>/dev/null)" fi - if test $isint -eq 1; then - d="$intdir/$depname" - vpath="$d" - vpathA="$d" - fi - cppflags="-isystem $inc $cppflags" + test -n "$inc" && cppflags="-isystem $inc $cppflags" # lila: dependencies? if test $islila -eq 1; then @@ -316,7 +369,7 @@ procdep_real() local err local i=0 mkfifo $tmp - procdep_real "$d" "$intdir" "$libdir" "$incdir" > "$tmp" & + procdep_real "$d" "$intdir" > "$tmp" & while IFS= read -r arg; do if test $i -ne 1; then i=1 @@ -397,8 +450,6 @@ procdep() # a different dirname (inside $incdir) might be specified if test -e "$dep/include"; then path="$(cat $dep/include)"; fi local path="$incdir/$path" - local library="$depname" - if test -e "$dep/library"; then library="$(cat $dep/library)"; fi local internal=0 local found=0 local depdir= @@ -425,7 +476,7 @@ procdep() local s local i=0 mkfifo $tmp - procdep_real "$dep" "deps" "$libdir" "$incdir" > "$tmp" & + procdep_real "$dep" "deps" > "$tmp" & while IFS= read -r arg; do if test $i -ne 1; then i=1 @@ -540,8 +591,13 @@ procdep() VPATHS="$VPATHS $(mkvpath $link "$vpath" $deplibs)" - if test $internal -eq 1 && test $depname = "skalibs"; then - sysdeps="$depdir/sysdeps.cfg" + if test $depname = "skalibs"; then + if test $internal -eq 1; then + sysdeps="$depdir/sysdeps.cfg" + else + if test -z "$sysdeps"; then sysdeps="$(echo $vpath)/skalibs/sysdeps"; fi + sysdeps="$(echo $sysdeps | sed 's/\/\+/\//g')" + fi fi fi }