diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-04-25 03:42:40 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-04-25 03:42:40 +0000 |
| commit | 7cada88937b8f7edead691a462d3339834674ec9 (patch) | |
| tree | 0d9934aff03081ed35949a3e0bbabcf324d49705 /configure | |
| parent | 15583497da174dd17b7b44701dcb000f46c235ed (diff) | |
| download | execline-7cada88937b8f7edead691a462d3339834674ec9.tar.gz | |
First version of pkg-config support
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'configure')
| -rwxr-xr-x | configure | 135 |
1 files changed, 99 insertions, 36 deletions
@@ -23,6 +23,7 @@ Fine tuning of the installation directories: --libexecdir=DIR package-scoped executables [EPREFIX/libexec] --libdir=DIR static library files [PREFIX/lib] --includedir=DIR C header files [PREFIX/include] + --pkgconfdir=DIR pkg-config .pc files [PREFIX/lib/pkgconfig] --shebangdir=DIR absolute path for #! invocations [BINDIR] If no --prefix option is given, by default libdir (but not dynlibdir) will be @@ -33,6 +34,7 @@ Dependencies: --with-include=DIR add DIR to the list of searched directories for headers --with-lib=DIR add DIR to the list of searched directories for static libraries --with-dynlib=DIR add DIR to the list of searched directories for shared libraries + --with-pkgconfig[=PROG] use pkg-config to look for dependencies If no --prefix option is given, by default sysdeps will be fetched from /usr/lib/skalibs/sysdeps. @@ -44,8 +46,8 @@ Optional features: --enable-static-libc make entirely static binaries [disabled] --disable-all-pic do not build executables or static libs as PIC [enabled] --enable-slashpackage[=ROOT] assume /package installation at ROOT [disabled] - --enable-absolute-paths do not rely on PATH to access this package's binaries, - hardcode absolute BINDIR/foobar paths instead [disabled] + --enable-absolute-paths hardcode absolute BINDIR/foobar paths in binaries [disabled] + --enable-pkgconfig Build and install .pc files for pkg-config [disabled] --enable-nsss use the nsss library for user information [disabled] --enable-pedantic-posix use pedantically POSIX-compatible binaries [disabled] --enable-multicall build a multicall binary [disabled] @@ -143,6 +145,7 @@ libexecdir='$exec_prefix/libexec' bindir='$exec_prefix/bin' libdir='$prefix/lib' includedir='$prefix/include' +pkgconfdir='$prefix/lib/pkgconfig' shebangdir='$bindir' shebangisdefault=true sysdeps='$prefix/lib/skalibs/sysdeps' @@ -152,6 +155,7 @@ static=true allpic=true slashpackage=false abspath=false +pcw=false usensss=false pposix=false multicall=false @@ -160,11 +164,14 @@ home= exthome= allstatic=true evenmorestatic=false +pkgconf= addincpath='' +depincpath='' addlibspath='' addlibdpath='' vpaths='' vpathd='' +requires='' build= for arg ; do @@ -177,11 +184,15 @@ for arg ; do --bindir=*) bindir=${arg#*=} ;; --libdir=*) libdir=${arg#*=} ;; --includedir=*) includedir=${arg#*=} ;; + --pkgconfigdir=*) pkgconfigdir=${arg#*=} ;; --shebangdir=*) shebangisdefault=false ; shebangdir=${arg#*=} ;; --with-sysdeps=*) sysdeps=${arg#*=} manualsysdeps=true ;; --with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ;; --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; vpaths="$vpaths $var" ;; --with-dynlib=*) var=${arg#*=} ; stripdir var ; addlibdpath="$addlibdpath -L$var" ; vpathd="$vpathd $var" ;; + --with-pkgconfig=*) pkgconf=${arg#*=} ;; + --with-pkgconfig) pkgconf=${PKG_CONFIG:-pkg-config} ;; + --without-pkgconfig) pkgconf= ;; --enable-shared|--enable-shared=yes) shared=true ;; --disable-shared|--enable-shared=no) shared=false ;; --enable-static|--enable-static=yes) static=true ;; @@ -197,6 +208,8 @@ for arg ; do --disable-slashpackage) sproot= ; slashpackage=false ;; --enable-absolute-paths|--enable-absolute-paths=yes) abspath=true ;; --disable-absolute-paths|--enable-absolute-paths=no) abspath=false ;; + --enable-pkgconfig|--enable-pkgconfig=yes) pcw=true ;; + --disable-pkgconfig|--enable-pkgconfig=no) pcw=false ;; --enable-nsss|--enable-nsss=yes) usensss=true ;; --disable-nsss|--enable-nsss=no) usensss=false ;; --enable-pedantic-posix|--enable-pedantic-posix=yes) pposix=true ;; @@ -218,6 +231,9 @@ if test -z "$prefix" ; then if test "$libdir" = '$prefix/lib' ; then libdir=/usr/lib fi + if test "$pkgconfdir" = '$prefix/lib/pkgconfig' ; then + pkgconfdir=/usr/lib/pkgconfig + fi if test "$includedir" = '$prefix/include' ; then includedir=/usr/include fi @@ -228,29 +244,63 @@ fi # Expand installation directories stripdir prefix -for i in exec_prefix dynlibdir libexecdir bindir libdir includedir shebangdir sysdeps sproot ; do +for i in exec_prefix dynlibdir libexecdir bindir libdir includedir pkgconfdir shebangdir sysdeps sproot ; do eval tmp=\${$i} eval $i=$tmp stripdir $i done -# Get usable temp filenames -i=0 -set -C -while : ; do - i=$(($i+1)) - tmpc="./tmp-configure-$$-$PPID-$i.c" - tmpo="./tmp-configure-$$-$PPID-$i.o" - tmpe="./tmp-configure-$$-$PPID-$i.tmp" - 2>|/dev/null > "$tmpc" && break - 2>|/dev/null > "$tmpo" && break - 2>|/dev/null > "$tmpe" && break - test "$i" -gt 50 && fail "$0: cannot create temporary files" -done -set +C -trap 'rm -f "$tmpc" "$tmpo" "$tmpe"' EXIT ABRT INT QUIT TERM HUP +# Process deps-build +if test -n "$pkgconf" || $pcw || $slashpackage ; then + oldifs="$IFS" + while IFS=" " read condvar pkg ver isdepinc libs ; do + IFS="$oldifs" + eval "cond=$condvar" + if $cond ; then + if test -n "$pkgconf" ; then + for lib in $libs ; do + if ! $pkgconf --atleast-version=${ver} --print-errors -- "$lib" ; then + echo "./configure: fatal: $pkgconf --atleast-version=${ver} --print-errors -- $lib failed" 1>&2 + exit 1 + fi + thisinc=`$pkgconf --cflags-only-I -- $lib` + addincpath="${addincpath}${thisinc:+ }$thisinc" + if $isdepinc ; then + depincpath="${depincpath}${thisinc:+ }$thisinc" + fi + sldflags="`$pkgconf --libs-only-L --static -- $lib`" + dldflags="`$pkgconf --libs-only-L -- $lib`" + addlibspath="$addlibspath $sldflags" + addlibdpath="$addlibdpath $dldflags" + for i in $sldflags ; do + vpaths="$vpaths ${i##-L}" + done + for i in $dldflags ; do + vpathd="$vpathd ${i##-L}" + done + done + fi + if $pcw ; then + for lib in $libs ; do + req="${req}${req:+, }$lib >= $ver" + done + fi + if $slashpackage ; then + addincpath="$addincpath -I${DESTDIR}${sproot}${pkg}/include" + if $isdepinc ; then + depincpath="$depincpath -I${DESTDIR}${sproot}${pkg}/include" + fi + vpaths="$vpaths ${DESTDIR}${sproot}${pkg}/library" + addlibspath="$addlibspath -L${DESTDIR}${sproot}${pkg}/library" + vpathd="$vpathd ${DESTDIR}${sproot}${pkg}/library.so" + addlibdpath="$addlibdpath -L${DESTDIR}${sproot}${pkg}/library.so" + fi + fi + done < package/deps-build + IFS="$oldifs" +fi -# Set slashpackage values +# Other slashpackage values if $slashpackage ; then home=${sproot}/package/${category}/${package}-${version} exthome=${sproot}/package/${category}/${package} @@ -265,25 +315,28 @@ if $slashpackage ; then libdir=${home}/library libexecdir=$bindir includedir=${home}/include + pkgconfdir=${home}/pkgconfig if $shebangisdefault ; then shebangdir=${extbinprefix} fi - while read dep condvar ; do - if test -n "$condvar" ; then - eval "cond=$condvar" - else - cond=true - fi - if $cond ; then - addincpath="$addincpath -I${DESTDIR}${sproot}${dep}/include" - vpaths="$vpaths ${DESTDIR}${sproot}${dep}/library" - addlibspath="$addlibspath -L${DESTDIR}${sproot}${dep}/library" - vpathd="$vpathd ${DESTDIR}${sproot}${dep}/library.so" - addlibdpath="$addlibdpath -L${DESTDIR}${sproot}${dep}/library.so" - fi - done < package/deps-build fi +# Get usable temp filenames +i=0 +set -C +while : ; do + i=$(($i+1)) + tmpc="./tmp-configure-$$-$PPID-$i.c" + tmpo="./tmp-configure-$$-$PPID-$i.o" + tmpe="./tmp-configure-$$-$PPID-$i.tmp" + 2>|/dev/null > "$tmpc" && break + 2>|/dev/null > "$tmpo" && break + 2>|/dev/null > "$tmpe" && break + test "$i" -gt 50 && fail "$0: cannot create temporary files" +done +set +C +trap 'rm -f "$tmpc" "$tmpo" "$tmpe"' EXIT ABRT INT QUIT TERM HUP + # Find a C compiler to use if test -n "$target" && test x${build} != x${target} ; then cross=${target}- @@ -401,12 +454,16 @@ libexecdir := $libexecdir bindir := $bindir libdir := $libdir includedir := $includedir +pkgconfdir := $pkgconfdir sysdeps := $sysdeps slashpackage := $slashpackage sproot := $sproot version := $version home := $home exthome := $exthome +buildtime_includedirs :=$depincpath +buildtime_libdirs :=$addlibspath +buildtime_dynlibdirs :=$addlibdpath SPAWN_LIB := ${spawn_lib} SOCKET_LIB := ${socket_lib} SYSCLOCK_LIB := ${sysclock_lib} @@ -415,17 +472,18 @@ UTIL_LIB := ${util_lib} CC := $CC_AUTO CPPFLAGS_AUTO := $CPPFLAGS_AUTO -CPPFLAGS := $CPPFLAGS $CPPFLAGS_POST +CPPFLAGS := ${CPPFLAGS}${CPPFLAGS_POST:+ }$CPPFLAGS_POST CFLAGS_AUTO := $CFLAGS_AUTO -CFLAGS := $CFLAGS $CFLAGS_POST +CFLAGS := ${CFLAGS}${CFLAGS_POST:+ }$CFLAGS_POST LDFLAGS_AUTO := $LDFLAGS_AUTO -LDFLAGS := $LDFLAGS $LDFLAGS_POST +LDFLAGS := ${LDFLAGS}${LDFLAGS_POST:+ }$LDFLAGS_POST LDFLAGS_SHARED := $LDFLAGS_SHARED LDFLAGS_NOSHARED := $LDFLAGS_NOSHARED CROSS_COMPILE := $cross vpath lib%.a$vpaths vpath lib%.so$vpathd + EOF if $allstatic ; then echo ".LIBPATTERNS := lib%.a" @@ -449,6 +507,11 @@ if $allpic ; then else echo "STATIC_LIBS_ARE_PIC :=" fi +if $pcw ; then + echo "DO_PKGCONFIG := 1" +else + echo "DO_PKGCONFIG :=" +fi if $usensss ; then echo "LIBNSSS := -lnsss" echo "MAYBEPTHREAD_LIB := -lpthread" |
