aboutsummaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2025-04-27 21:53:35 +0000
committerLaurent Bercot <ska@appnovation.com>2025-04-27 21:53:35 +0000
commit1a24089c821b7ab71af9733a58ffc762accd84dd (patch)
tree790ebe40aa8da93d76e974921c18f4434cddea90 /configure
parente850b94f5e796ad12b994ea664d3ecfd2d176620 (diff)
downloads6-linux-init-1a24089c821b7ab71af9733a58ffc762accd84dd.tar.gz
Prepare for 1.1.3.0, templated configure, pkg-config support, etc.
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure189
1 files changed, 125 insertions, 64 deletions
diff --git a/configure b/configure
index 0e3b80f..7f8d5c5 100755
--- a/configure
+++ b/configure
@@ -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]
--skeldir=DIR script skeleton files [PREFIX/etc/s6-linux-init/skel]
--tmpfsdir=DIR assume the initial tmpfs will be mounted on DIR [/run]
--scandir=DIR use tmpfsdir/DIR as the s6-svscan directory [service]
@@ -35,6 +36,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.
@@ -45,10 +47,9 @@ Optional features:
--disable-allstatic do not prefer linking against static libraries [enabled]
--enable-static-libc make entirely static binaries [disabled]
--disable-all-pic do not build executables or static libs as PIC [enabled]
+ --enable-pkgconfig Build and install .pc files for pkg-config [disabled]
--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-nsss use the nsss library for user information [disabled]
--enable-utmps link against the utmps library [disabled]
@@ -77,10 +78,6 @@ fail () {
exit 1
}
-isprefix() {
- case "$1" in "$2"*) return 0 ;; *) return 1 ;; esac ;
-}
-
fnmatch () {
eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac"
}
@@ -127,13 +124,6 @@ tryldflag () {
fi
}
-getmacro () {
- echo "#include <$1>" | $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -E -dM - | grep -F -- "$2" | cut -d' ' -f3-
-}
-
-getmacrostring () {
- getmacro "$1" "$2" | sed -e 's/^"//' -e 's/"$//'
-}
# Actual script
@@ -156,6 +146,8 @@ libexecdir='$exec_prefix/libexec'
bindir='$exec_prefix/bin'
libdir='$prefix/lib'
includedir='$prefix/include'
+pkgconfdir='$prefix/lib/pkgconfig'
+shebangdir='$bindir'
sysdeps='$prefix/lib/skalibs/sysdeps'
manualsysdeps=false
shared=false
@@ -163,21 +155,25 @@ static=true
allpic=true
slashpackage=false
abspath=false
-usensss=false
+pcw=false
sproot=
home=
exthome=
allstatic=true
evenmorestatic=false
+pkgconf=
addincpath=''
addlibspath=''
addlibdpath=''
+depincpath=''
+deplibpath=''
vpaths=''
vpathd=''
build=
skeldir='$prefix/etc/s6-linux-init/skel'
tmpfsdir=/run
scandir=service
+usensss=false
utmps=false
for arg ; do
@@ -190,10 +186,14 @@ for arg ; do
--bindir=*) bindir=${arg#*=} ;;
--libdir=*) libdir=${arg#*=} ;;
--includedir=*) includedir=${arg#*=} ;;
+ --pkgconfigdir=*) pkgconfigdir=${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-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ; depincpath="${depincpath}${depincpath:+ }-I$var" ;;
+ --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; deplibpath="${deplibpath}${deplibpath:+ }-I$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 ;;
@@ -204,19 +204,22 @@ for arg ; do
--disable-static-libc|--enable-static-libc=no) evenmorestatic=false ;;
--enable-all-pic|--enable-all-pic=yes) allpic=true ;;
--disable-all-pic|--enable-all-pic=no) allpic=false ;;
+ --enable-pkgconfig|--enable-pkgconfig=yes) pcw=true ;;
+ --disable-pkgconfig|--enable-pkgconfig=no) pcw=false ;;
--enable-slashpackage=*) sproot=${arg#*=} ; slashpackage=true ; ;;
--enable-slashpackage) sproot= ; slashpackage=true ;;
--disable-slashpackage) sproot= ; slashpackage=false ;;
--enable-absolute-paths|--enable-absolute-paths=yes) abspath=true ;;
--disable-absolute-paths|--enable-absolute-paths=no) abspath=false ;;
- --enable-nsss|--enable-nsss=yes) usensss=true ;;
- --disable-nsss|--enable-nsss=no) usensss=false ;;
--skeldir=*) skeldir=${arg#*=} ;;
--tmpfsdir=*) tmpfsdir=${arg#*=} ;;
--scandir=*) scandir=${arg#*=} ;;
+ --enable-nsss|--enable-nsss=yes) usensss=true ;;
+ --disable-nsss|--enable-nsss=no) usensss=false ;;
--enable-utmps|--enable-utmps=yes) utmps=true ;;
--disable-utmps|--enable-utmps=no) utmps=false ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
+ --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
--host=*|--target=*) target=${arg#*=} ;;
--build=*) build=${arg#*=} ;;
-* ) echo "$0: unknown option $arg" ;;
@@ -233,6 +236,9 @@ if test -z "$prefix" ; then
if test "$includedir" = '$prefix/include' ; then
includedir=/usr/include
fi
+ if test "$pkgconfdir" = '$prefix/lib/pkgconfig' ; then
+ pkgconfdir=/usr/lib/pkgconfig
+ fi
if test "$sysdeps" = '$prefix/lib/skalibs/sysdeps' ; then
sysdeps=/usr/lib/skalibs/sysdeps
fi
@@ -240,29 +246,60 @@ fi
# Expand installation directories
stripdir prefix
-for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysdeps sproot tmpfsdir skeldir ; do
+for i in exec_prefix dynlibdir libexecdir bindir libdir includedir pkgconfdir sysdeps sproot tmpfsdir skeldir ; 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 cond usedinlibs pkg ver libs ; do
+ IFS="$oldifs"
+ eval "cond=$cond; usedinlibs=$usedinlibs"
+ 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`"
+ sldflags="`$pkgconf --libs-only-L --static -- $lib`"
+ dldflags="`$pkgconf --libs-only-L -- $lib`"
+ addincpath="${addincpath}${thisinc:+ }$thisinc"
+ addlibspath="${addlibspath}${sldflags:+ }$sldflags"
+ addlibdpath="${addlibdpath}${dldflags:+ }$dldflags"
+ for i in $sldflags ; do
+ vpaths="$vpaths ${i##-L}"
+ done
+ for i in $dldflags ; do
+ vpathd="$vpathd ${i##-L}"
+ done
+ if $usedinlibs ; then
+ depincpath="${depincpath}${thisinc:+ }$thisinc"
+ deplibpath="${deplibpath}${sldflags:+ }$sldflags"
+ fi
+ done
+ fi
+ if $slashpackage ; then
+ addincpath="$addincpath -I${DESTDIR}${sproot}${pkg}/include"
+ 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"
+ if $usedinlibs ; then
+ depincpath="$depincpath -I${DESTDIR}${sproot}${pkg}/include"
+ deplibpath="$deplibpath -L${DESTDIR}${sproot}${pkg}/library"
+ fi
+ 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}
@@ -277,23 +314,26 @@ if $slashpackage ; then
libdir=${home}/library
libexecdir=$bindir
includedir=${home}/include
- skeldir=${home}/etc/skel
- 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
+ pkgconfdir=${home}/pkgconfig
+
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}-
@@ -350,15 +390,15 @@ if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then
exit 1
fi
+if $allpic ; then
+ tryflag CPPFLAGS_AUTO -fPIC
+fi
spawn_lib=$(cat $sysdeps/spawn.lib)
socket_lib=$(cat $sysdeps/socket.lib)
sysclock_lib=$(cat $sysdeps/sysclock.lib)
timer_lib=$(cat $sysdeps/timer.lib)
util_lib=$(cat $sysdeps/util.lib)
-if $allpic ; then
- tryflag CPPFLAGS_AUTO -fPIC
-fi
tryflag CFLAGS_AUTO -std=c99
tryflag CFLAGS -fomit-frame-pointer
tryflag CFLAGS_AUTO -fno-exceptions
@@ -368,7 +408,6 @@ tryflag CPPFLAGS_AUTO -Werror=implicit-function-declaration
tryflag CPPFLAGS_AUTO -Werror=implicit-int
tryflag CPPFLAGS_AUTO -Werror=pointer-sign
tryflag CPPFLAGS_AUTO -Werror=pointer-arith
-tryflag CPPFLAGS_AUTO -Wno-parentheses
tryflag CFLAGS_AUTO -ffunction-sections
tryflag CFLAGS_AUTO -fdata-sections
@@ -394,6 +433,18 @@ else
LDFLAGS_NOSHARED="${LDFLAGS_NOSHARED}${addlibdpath}"
fi
+isprefix () {
+ case "$1" in "$2"*) return 0 ;; *) return 1 ;; esac ;
+}
+
+getmacro () {
+ echo "#include <$1>" | $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -E -dM - | grep -F -- "$2" | cut -d' ' -f3-
+}
+
+getmacrostring () {
+ getmacro "$1" "$2" | sed -e 's/^"//' -e 's/"$//'
+}
+
if $utmps ; then
echo "Sanity checking cross-package configuration..."
p=`getmacrostring utmps/config.h UTMPS_UTMPD_PATH`
@@ -429,13 +480,15 @@ libexecdir := $libexecdir
bindir := $bindir
libdir := $libdir
includedir := $includedir
-skeldir := $skeldir
+pkgconfdir := $pkgconfdir
sysdeps := $sysdeps
slashpackage := $slashpackage
sproot := $sproot
version := $version
home := $home
exthome := $exthome
+extra_includedirs :=$depincpath
+extra_libdirs :=$deplibpath
SPAWN_LIB := ${spawn_lib}
SOCKET_LIB := ${socket_lib}
SYSCLOCK_LIB := ${sysclock_lib}
@@ -444,23 +497,25 @@ 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"
echo "DO_ALLSTATIC := 1"
else
echo ".LIBPATTERNS := lib%.so"
+ echo "DO_ALLSTATIC :="
fi
if $static ; then
echo "DO_STATIC := 1"
@@ -472,6 +527,11 @@ if $shared ; then
else
echo "DO_SHARED :="
fi
+if $pcw ; then
+ echo "DO_PKGCONFIG := 1"
+else
+ echo "DO_PKGCONFIG :="
+fi
if $allpic ; then
echo "STATIC_LIBS_ARE_PIC := 1"
else
@@ -489,7 +549,6 @@ if $utmps ; then
else
echo "LIBUTMPS :="
fi
-
exec 1>&3 3>&-
echo " ... done."
@@ -509,26 +568,28 @@ EOF
if $slashpackage ; then
echo "#define ${package_macro_name}_BINPREFIX \"$bindir/\""
echo "#define ${package_macro_name}_EXTBINPREFIX \"$extbinprefix/\""
+ echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$extbinprefix/\""
elif $abspath ; then
echo "#define ${package_macro_name}_BINPREFIX \"$bindir/\""
echo "#define ${package_macro_name}_EXTBINPREFIX \"$bindir/\""
+ echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$libexecdir/\""
else
echo "#define ${package_macro_name}_BINPREFIX \"\""
echo "#define ${package_macro_name}_EXTBINPREFIX \"\""
+ echo "#define ${package_macro_name}_EXTLIBEXECPREFIX \"$libexecdir/\""
fi
echo "#define ${package_macro_name}_LIBEXECPREFIX \"$libexecdir/\""
echo "#define ${package_macro_name}_SKELDIR \"$skeldir\""
echo "#define ${package_macro_name}_TMPFS \"$tmpfsdir\""
echo "#define ${package_macro_name}_SCANDIR \"$scandir\""
echo
+echo "#undef ${package_macro_name}_UTMPD_PATH"
+echo "#undef ${package_macro_name}_WTMPD_PATH"
if $utmps ; then
echo "#define ${package_macro_name}_UTMPD_PATH \"$utmpd_path\""
echo "#define ${package_macro_name}_WTMPD_PATH \"$wtmpd_path\""
-else
- echo "#undef ${package_macro_name}_UTMPD_PATH"
- echo "#undef ${package_macro_name}_WTMPD_PATH"
fi
echo
echo "#endif"
exec 1>&3 3>&-
-echo " ... done."
+echo " ... done." \ No newline at end of file