diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-04-28 06:56:55 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska@appnovation.com> | 2025-04-28 06:56:55 +0000 |
| commit | 851cdc362c11c9475f6a8f1c493c2f550c15555c (patch) | |
| tree | 870ff741e9a70bcc722f0b0427e07388a978c38d | |
| parent | 938663ec4cf89443437d3f8997875a0711ff888a (diff) | |
| download | tipidee-851cdc362c11c9475f6a8f1c493c2f550c15555c.tar.gz | |
Move to new system, support pkg-config
Signed-off-by: Laurent Bercot <ska@appnovation.com>
26 files changed, 942 insertions, 90 deletions
@@ -1,3 +1,4 @@ +/*.pc *.o *.a.xyzzy *.lo @@ -6,13 +6,13 @@ Build Instructions - A POSIX-compliant C development environment - GNU make version 3.81 or later - - skalibs version 2.14.3.0 or later: https://skarnet.org/software/skalibs/ - - (optional but recommended): s6-networking version 2.7.0.4 or later: + - skalibs version 2.14.4.0 or later: https://skarnet.org/software/skalibs/ + - (optional but recommended): s6-networking version 2.7.1.0 or later: https://skarnet.org/software/s6-networking/ This software will run on any operating system that implements -POSIX.1-2008, available at: - https://pubs.opengroup.org/onlinepubs/9699919799/ +POSIX.1-2024, available at: + https://pubs.opengroup.org/onlinepubs/9799919799/ * Standard usage @@ -29,6 +29,33 @@ libraries in /usr/lib. off them. +* pkg-config + ---------- + + pkg-config is a tool used by some Linux and BSD distributions, providing +a registry to store policy information about libraries exported by a +software package; that is supposed to make it easier to build software +depending on these libraries, by having a tool to automatically extract +the various flags to pass to the compiler and linker in order to correctly +build against these libraries. + This package supports pkg-config, but you need to explicitly ask for it: + - To use the pkg-config tool to *read* information from the registry and +use it to build *this* package: --with-pkgconfig[=PROG]. This assumes +PROG supports the pkg-config interface (as the popular pkgconf +implementation does). If PROG is not supplied, the PKG_CONFIG environment +variable is used to find the program to use, and if empty/unset, it defaults +to pkg-config. + - To build a .pc file for each library exported by this package, and then +install it to the pkg-config registry, in other words to *write* information +so that other software can use pkg-config to build against this package, +use --enable-pkgconfig. + + pkg-config and slashpackage (see below) configure options can be set +together, but the slashpackage convention provides its own installation +policies that generally make it unnecessary to use pkg-config. You +probably should not mix both. + + * Customization ------------- @@ -12,28 +12,65 @@ ifeq "" "$(strip $(filter $(make_need), $(firstword $(sort $(make_need) $(MAKE_V fail := $(error Your make ($(MAKE_VERSION)) is too old. You need $(make_need) or newer) endif +uniq = $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) + CC = $(error Please use ./configure first) STATIC_LIBS := SHARED_LIBS := INTERNAL_LIBS := EXTRA_TARGETS := +PC_TARGETS := LIB_DEFS := +BIN_SYMLINKS := +TEST_BINS := define library_definition -LIB$(firstword $(subst =, ,$(1))) := lib$(lastword $(subst =, ,$(1))).$(if $(DO_ALLSTATIC),a,so).xyzzy +LIB$(1) := lib$(2).$(if $(DO_ALLSTATIC),a,so).xyzzy ifdef DO_SHARED -SHARED_LIBS += lib$(lastword $(subst =, ,$(1))).so.xyzzy +SHARED_LIBS += lib$(2).so.xyzzy endif ifdef DO_STATIC -STATIC_LIBS += lib$(lastword $(subst =, ,$(1))).a.xyzzy +STATIC_LIBS += lib$(2).a.xyzzy +endif +ifdef DO_PKGCONFIG +PC_TARGETS += lib$(2).pc endif + +lib$(2).pc: + exec env \ + library="$(2)" \ + includedir="$(includedir)" \ + dynlibdir="$(dynlibdir)" \ + libdir="$(libdir)" \ + extra_includedirs="$(extra_includedirs)" \ + extra_libdirs="$(extra_libdirs)" \ + extra_libs="$$(strip $$(EXTRA_LIBS))" \ + description="$$($(1)_DESCRIPTION)" \ + url="$$($(1)_URL)" \ + ldlibs="$(LDLIBS)" \ + ./tools/gen-dotpc.sh > $$@.tmp + exec mv -f $$@.tmp $$@ + +endef + +define binary_installation_rule +$(DESTDIR)$(1)/$(2): ./$(2) package/modes + exec $(INSTALL) -D -m 600 $$< $$@ + grep -- ^$$(@F) < package/modes | { read name mode owner && \ + if [ x$$$$owner != x ] ; then chown -- $$$$owner $$@ ; fi && \ + chmod $$$$mode $$@ ; } +endef + +define symlink_installation_rule +$(DESTDIR)$(1)/$(2): $(DESTDIR)$(1)/$(SYMLINK_TARGET_$(2)) + exec $(INSTALL) -l $$(<F) $$@ endef -include config.mak include package/targets.mak -$(foreach var,$(LIB_DEFS),$(eval $(call library_definition,$(var)))) +$(foreach var,$(LIB_DEFS),$(eval $(call library_definition,$(firstword $(subst =, ,$(var))),$(lastword $(subst =, ,$(var)))))) include package/deps.mak @@ -53,14 +90,18 @@ RANLIB := $(CROSS_COMPILE)ranlib STRIP := $(CROSS_COMPILE)strip INSTALL := ./tools/install.sh +$(foreach var,$(BIN_TARGETS),$(eval $(call binary_installation_rule,$(bindir),$(var)))) +$(foreach var,$(LIBEXEC_TARGETS),$(eval $(call binary_installation_rule,$(libexecdir),$(var)))) +$(foreach var,$(BIN_SYMLINKS),$(eval $(call symlink_installation_rule,$(bindir),$(var)))) + ALL_BINS := $(LIBEXEC_TARGETS) $(BIN_TARGETS) ALL_LIBS := $(SHARED_LIBS) $(STATIC_LIBS) $(INTERNAL_LIBS) ALL_INCLUDES := $(wildcard src/include/$(package)/*.h) -all: $(ALL_LIBS) $(ALL_BINS) $(ALL_INCLUDES) $(EXTRA_INCLUDES) +all: $(ALL_LIBS) $(ALL_BINS) $(ALL_INCLUDES) $(EXTRA_INCLUDES) $(PC_TARGETS) clean: - @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(wildcard src/*/*.o src/*/*.lo) $(EXTRA_TARGETS) + @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(TEST_BINS) $(wildcard src/*/*.o src/*/*.lo) $(PC_TARGETS) $(EXTRA_TARGETS) distclean: clean @exec rm -f config.mak src/include/$(package)/config.h @@ -81,12 +122,19 @@ ifneq ($(strip $(ALL_BINS)$(SHARED_LIBS)),) exec $(STRIP) -R .note -R .comment $(ALL_BINS) $(SHARED_LIBS) endif -install: install-dynlib install-libexec install-bin install-lib install-include +install: install-dynlib install-libexec install-bin install-symlinks install-lib install-include install-pkgconfig install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so) install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%) install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) +install-symlinks: $(BIN_SYMLINKS:%=$(DESTDIR)$(bindir)/%) install-lib: $(STATIC_LIBS:lib%.a.xyzzy=$(DESTDIR)$(libdir)/lib%.a) install-include: $(ALL_INCLUDES:src/include/$(package)/%.h=$(DESTDIR)$(includedir)/$(package)/%.h) $(EXTRA_INCLUDES:src/include/%.h=$(DESTDIR)$(includedir)/%.h) +install-pkgconfig: $(PC_TARGETS:%=$(DESTDIR)$(pkgconfdir)/%) + +tests: $(TEST_BINS) + +check: tests + @for i in $(TEST_BINS) ; do ./tools/run-test.sh $$i || exit 1 ; done ifneq ($(exthome),) @@ -95,7 +143,7 @@ $(DESTDIR)$(exthome): $(DESTDIR)$(home) update: $(DESTDIR)$(exthome) -global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M)) $(BIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%) +global-links: $(DESTDIR)$(exthome) $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(sproot)/library.so/lib%.so.$(version_M)) $(BIN_TARGETS:%=$(DESTDIR)$(sproot)/command/%) $(BIN_SYMLINKS:%=$(DESTDIR)$(sproot)/command/%) $(DESTDIR)$(sproot)/command/%: $(DESTDIR)$(home)/command/% exec $(INSTALL) -D -l ..$(subst $(sproot),,$(exthome))/command/$(<F) $@ @@ -112,12 +160,6 @@ $(DESTDIR)$(dynlibdir)/lib%.so $(DESTDIR)$(dynlibdir)/lib%.so.$(version_M): lib% $(INSTALL) -l $(@F).$(version) $@.$(version_M) && \ exec $(INSTALL) -l $(@F).$(version_M) $@ -$(DESTDIR)$(libexecdir)/% $(DESTDIR)$(bindir)/%: % package/modes - exec $(INSTALL) -D -m 600 $< $@ - grep -- ^$(@F) < package/modes | { read name mode owner && \ - if [ x$$owner != x ] ; then chown -- $$owner $@ ; fi && \ - chmod $$mode $@ ; } - $(DESTDIR)$(libdir)/lib%.a: lib%.a.xyzzy exec $(INSTALL) -D -m 644 $< $@ @@ -127,13 +169,16 @@ $(DESTDIR)$(includedir)/$(package)/%.h: src/include/$(package)/%.h $(DESTDIR)$(includedir)/%.h: src/include/%.h exec $(INSTALL) -D -m 644 $< $@ +$(DESTDIR)$(pkgconfdir)/lib%.pc: lib%.pc + exec $(INSTALL) -D -m 644 $< $@ + %.o: %.c exec $(CC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) -c -o $@ $< %.lo: %.c exec $(CC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) $(CFLAGS_SHARED) -c -o $@ $< -$(ALL_BINS): +$(ALL_BINS) $(TEST_BINS): exec $(CC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS) lib%.a.xyzzy: @@ -141,8 +186,8 @@ lib%.a.xyzzy: exec $(RANLIB) $@ lib%.so.xyzzy: - exec $(CC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$(patsubst lib%.so.xyzzy,lib%.so.$(version_M),$@) $^ $(EXTRA_LIBS) $(LDLIBS) + exec $(CC) -o $@ $(CFLAGS_ALL) $(CFLAGS_SHARED) $(LDFLAGS_ALL) $(LDFLAGS_SHARED) -Wl,-soname,$(patsubst lib%.so.xyzzy,lib%.so.$(version_M),$@) -Wl,-rpath=$(dynlibdir) $^ $(EXTRA_LIBS) $(LDLIBS) -.PHONY: it all clean distclean tgz strip install install-dynlib install-bin install-lib install-include +.PHONY: it all clean distclean tests check tgz strip install install-dynlib install-bin install-lib install-include install-pkgconfig .DELETE_ON_ERROR: @@ -4,7 +4,9 @@ In 0.0.6.0 ---------- - Bugfixes. - - CGI output is now streamed. + - pkg-config support. + - CGI output is now streamed and can be autochunked. + - Support for ip-based tarpitting. In 0.0.5.1 @@ -24,6 +24,7 @@ Fine tuning of the installation directories: --libdir=DIR static library files [PREFIX/lib] --includedir=DIR C header files [PREFIX/include] --sysconfdir=DIR global configuration files [PREFIX/etc] + --pkgconfdir=DIR pkg-config .pc files [PREFIX/lib/pkgconfig] If no --prefix option is given, by default libdir (but not dynlibdir) will be /usr/lib, and includedir will be /usr/include. @@ -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. @@ -43,9 +45,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] EOF exit 0 @@ -141,6 +143,8 @@ bindir='$exec_prefix/bin' libdir='$prefix/lib' includedir='$prefix/include' sysconfdir='$prefix/etc' +pkgconfdir='$prefix/lib/pkgconfig' +shebangdir='$bindir' sysdeps='$prefix/lib/skalibs/sysdeps' manualsysdeps=false shared=false @@ -148,18 +152,23 @@ static=true allpic=true slashpackage=false abspath=false +pcw=false sproot= home= exthome= allstatic=true evenmorestatic=false +pkgconf= addincpath='' addlibspath='' addlibdpath='' +depincpath='' +deplibpath='' vpaths='' vpathd='' build= + for arg ; do case "$arg" in --help) usage ;; @@ -171,10 +180,14 @@ for arg ; do --libdir=*) libdir=${arg#*=} ;; --includedir=*) includedir=${arg#*=} ;; --sysconfdir=*) sysconfdir=${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 ;; @@ -185,11 +198,15 @@ 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-*|--disable-*|--with-*|--without-*|--*dir=*) ;; --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; --host=*|--target=*) target=${arg#*=} ;; --build=*) build=${arg#*=} ;; @@ -204,12 +221,12 @@ if test -z "$prefix" ; then if test "$libdir" = '$prefix/lib' ; then libdir=/usr/lib fi - if test "$dynlibdir" = '$prefix/lib' ; then - dynlibdir=/usr/lib - fi 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 @@ -217,29 +234,60 @@ fi # Expand installation directories stripdir prefix -for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir sysdeps sproot ; do +for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir pkgconfdir 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 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} @@ -254,22 +302,26 @@ if $slashpackage ; then libdir=${home}/library libexecdir=$bindir includedir=${home}/include - 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}- @@ -326,15 +378,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 @@ -369,6 +421,8 @@ else LDFLAGS_NOSHARED="${LDFLAGS_NOSHARED}${addlibdpath}" fi + + echo "Creating config.mak..." cmdline=$(quote "$0") for i ; do cmdline="$cmdline $(quote "$i")" ; done @@ -388,12 +442,15 @@ bindir := $bindir libdir := $libdir includedir := $includedir sysconfdir := $sysconfdir +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} @@ -402,23 +459,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" @@ -430,6 +489,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 @@ -455,12 +519,15 @@ 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}_SYSCONFPREFIX \"$sysconfdir/\"" @@ -468,4 +535,4 @@ echo "#define ${package_macro_name}_SYSCONFPREFIX \"$sysconfdir/\"" echo echo "#endif" exec 1>&3 3>&- -echo " ... done." +echo " ... done."
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 69352ad..cb28976 100644 --- a/doc/index.html +++ b/doc/index.html @@ -115,7 +115,7 @@ make it shorter. Just like the code. requirement if you link against the shared version of the skalibs library. </li> <li> Recommended at run-time: <a href="//skarnet.org/software/s6-networking/">s6-networking</a> version -2.7.0.4 or later. It's not a strict requirement, but tipidee relies on a super-server such as +2.7.1.0 or later. It's not a strict requirement, but tipidee relies on a super-server such as <a href="//skarnet.org/software/s6-networking/s6-tcpserver.html">s6-tcpserver</a> to listen to the network and provide connection information via environment variables. It also defers to tools such as diff --git a/doc/tipideed.html b/doc/tipideed.html index 8f8e0c2..bc9326d 100644 --- a/doc/tipideed.html +++ b/doc/tipideed.html @@ -451,12 +451,12 @@ in which case tipideed adds <tt>Connection: close</tt> to its last answer. </li> <p> On systems that implement -<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html">posix_spawn()</a>, +<a href="https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn.html">posix_spawn()</a>, the <a href="//skarnet.org/software/s6-networking/s6-tcpserver.html">s6-tcpserver</a> super-server (and the <a href="//skarnet.org/software/s6-networking/s6-tlsserver.html">s6-tlsserver</a> one as well, since both use the same underlying program) uses it instead of -<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html">fork()</a>, +<a href="https://pubs.opengroup.org/onlinepubs/9799919799/functions/fork.html">fork()</a>, and that partly alleviates the performance penalty usually associated with servers that spawn one process per connection. </p> @@ -474,9 +474,9 @@ CGI script itself, never by tipideed. <p> tipideed itself does not use -<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html">fork()</a> +<a href="https://pubs.opengroup.org/onlinepubs/9799919799/functions/fork.html">fork()</a> if the system supports -<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html">posix_spawn()</a> +<a href="https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_spawn.html">posix_spawn()</a> — with one exception, that you will not hit, and if you do, fork() will not be the bottleneck. (Can you guess which case it is, without looking at the code?) tipideed does not parse its configuration file itself, delegating the task to the diff --git a/doc/upgrade.html b/doc/upgrade.html index 6c7b5e0..0bcfb28 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -23,6 +23,8 @@ <ul> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> dependency bumped to 2.14.4.0 </li> + <li> <a href="//skarnet.org/software/s6-networking/">s6-networking</a> +recommendation bumped to 2.7.1.0 </li> </ul> <h2> in 0.0.5.1 </h2> diff --git a/package/configure-snippets/configure_case_lines b/package/configure-snippets/configure_case_lines new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_case_lines @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_expand_dirs b/package/configure-snippets/configure_expand_dirs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_expand_dirs @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_extra_checks b/package/configure-snippets/configure_extra_checks new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_extra_checks @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_generate_configh b/package/configure-snippets/configure_generate_configh new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_generate_configh @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_generate_make b/package/configure-snippets/configure_generate_make new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_generate_make @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_help_dependencies b/package/configure-snippets/configure_help_dependencies new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_help_dependencies @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_help_install b/package/configure-snippets/configure_help_install new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_help_install @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_help_options b/package/configure-snippets/configure_help_options new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_help_options @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_init_vars b/package/configure-snippets/configure_init_vars new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_init_vars @@ -0,0 +1 @@ + diff --git a/package/configure-snippets/configure_slashpackage_other b/package/configure-snippets/configure_slashpackage_other new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/package/configure-snippets/configure_slashpackage_other @@ -0,0 +1 @@ + diff --git a/package/deps-build b/package/deps-build index 05d5af4..1a04c17 100644 --- a/package/deps-build +++ b/package/deps-build @@ -1 +1 @@ -/package/prog/skalibs +true true /package/prog/skalibs 2.14.4.0 libskarnet diff --git a/package/deps.mak b/package/deps.mak index ee0e9d0..df78947 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -77,19 +77,20 @@ src/tipideed/tipideed.o src/tipideed/tipideed.lo: src/tipideed/tipideed.c src/in src/tipideed/trace.o src/tipideed/trace.lo: src/tipideed/trace.c src/include/tipidee/log.h src/include/tipidee/method.h src/include/tipidee/response.h src/tipideed/tipideed-internal.h src/tipideed/util.o src/tipideed/util.lo: src/tipideed/util.c src/tipideed/tipideed-internal.h -tipidee-config: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -tipidee-config: src/config/tipidee-config.o src/config/util.o src/config/node.o src/config/repo.o src/config/conftree.o src/config/headers.o src/config/defaults.o src/config/lexparse.o -tipidee-config-preprocess: EXTRA_LIBS := -lskarnet -tipidee-config-preprocess: src/config/tipidee-config-preprocess.o +tipidee-config: EXTRA_LIBS := ${SPAWN_LIB} +tipidee-config: src/config/tipidee-config.o src/config/util.o src/config/node.o src/config/repo.o src/config/conftree.o src/config/headers.o src/config/defaults.o src/config/lexparse.o -lskarnet +tipidee-config-preprocess: EXTRA_LIBS := +tipidee-config-preprocess: src/config/tipidee-config-preprocess.o -lskarnet ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) libtipidee.a.xyzzy: src/libtipidee/tipidee_conf_free.o src/libtipidee/tipidee_conf_get.o src/libtipidee/tipidee_conf_get_argv.o src/libtipidee/tipidee_conf_get_content_type.o src/libtipidee/tipidee_conf_get_errorfile.o src/libtipidee/tipidee_conf_get_redirection.o src/libtipidee/tipidee_conf_get_resattr.o src/libtipidee/tipidee_conf_get_resattr1.o src/libtipidee/tipidee_conf_get_responseheaders.o src/libtipidee/tipidee_conf_get_string.o src/libtipidee/tipidee_conf_get_uint32.o src/libtipidee/tipidee_conf_init.o src/libtipidee/tipidee_headers_get_content_length.o src/libtipidee/tipidee_headers_init.o src/libtipidee/tipidee_headers_parse.o src/libtipidee/tipidee_headers_search.o src/libtipidee/tipidee_log_answer.o src/libtipidee/tipidee_log_exit.o src/libtipidee/tipidee_log_request.o src/libtipidee/tipidee_log_resource.o src/libtipidee/tipidee_log_start.o src/libtipidee/tipidee_method.o src/libtipidee/tipidee_response_error_nofile.o src/libtipidee/tipidee_response_error_nofile_G.o src/libtipidee/tipidee_response_file.o src/libtipidee/tipidee_response_file_G.o src/libtipidee/tipidee_response_header_date.o src/libtipidee/tipidee_response_header_date_G.o src/libtipidee/tipidee_response_header_date_fmt.o src/libtipidee/tipidee_response_header_end.o src/libtipidee/tipidee_response_header_lastmodified.o src/libtipidee/tipidee_response_header_preparebuiltin.o src/libtipidee/tipidee_response_header_write.o src/libtipidee/tipidee_response_header_writeall.o src/libtipidee/tipidee_response_header_writeall_G.o src/libtipidee/tipidee_response_header_writemerge.o src/libtipidee/tipidee_response_header_writemerge_G.o src/libtipidee/tipidee_response_partial.o src/libtipidee/tipidee_response_partial_G.o src/libtipidee/tipidee_response_status.o src/libtipidee/tipidee_rql_read.o src/libtipidee/tipidee_uri_parse.o src/libtipidee/tipidee_util_chunked_read.o src/libtipidee/tipidee_util_defaulttext.o src/libtipidee/tipidee_util_htmlescape.o src/libtipidee/tipidee_util_httpdate.o src/libtipidee/tipidee_util_parse_range.o else -libtipidee.a.xyzzy: src/libtipidee/tipidee_conf_free.lo src/libtipidee/tipidee_conf_get.lo src/libtipidee/tipidee_conf_get_argv.lo src/libtipidee/tipidee_conf_get_content_type.lo src/libtipidee/tipidee_conf_get_errorfile.lo src/libtipidee/tipidee_conf_get_redirection.lo src/libtipidee/tipidee_conf_get_resattr.lo src/libtipidee/tipidee_conf_get_resattr1.lo src/libtipidee/tipidee_conf_get_responseheaders.lo src/libtipidee/tipidee_conf_get_string.lo src/libtipidee/tipidee_conf_get_uint32.lo src/libtipidee/tipidee_conf_init.lo src/libtipidee/tipidee_headers_get_content_length.lo src/libtipidee/tipidee_headers_init.lo src/libtipidee/tipidee_headers_parse.lo src/libtipidee/tipidee_headers_search.lo src/libtipidee/tipidee_log_answer.lo src/libtipidee/tipidee_log_exit.lo src/libtipidee/tipidee_log_request.lo src/libtipidee/tipidee_log_resource.lo src/libtipidee/tipidee_log_start.lo src/libtipidee/tipidee_method.lo src/libtipidee/tipidee_response_error_nofile.lo src/libtipidee/tipidee_response_error_nofile_G.lo src/libtipidee/tipidee_response_file.lo src/libtipidee/tipidee_response_file_G.lo src/libtipidee/tipidee_response_header_date.lo src/libtipidee/tipidee_response_header_date_G.lo src/libtipidee/tipidee_response_header_date_fmt.lo src/libtipidee/tipidee_response_header_end.lo src/libtipidee/tipidee_response_header_lastmodified.lo src/libtipidee/tipidee_response_header_preparebuiltin.lo src/libtipidee/tipidee_response_header_write.lo src/libtipidee/tipidee_response_header_writeall.lo src/libtipidee/tipidee_response_header_writeall_G.lo src/libtipidee/tipidee_response_header_writemerge.lo src/libtipidee/tipidee_response_header_writemerge_G.lo src/libtipidee/tipidee_response_partial.lo src/libtipidee/tipidee_response_partial_G.lo src/libtipidee/tipidee_response_status.lo src/libtipidee/tipidee_rql_read.lo src/libtipidee/tipidee_uri_parse.lo src/libtipidee/tipidee_util_chunked_read.lo src/libtipidee/tipidee_util_defaulttext.lo src/libtipidee/tipidee_util_htmlescape.lo src/libtipidee/tipidee_util_httpdate.lo src/libtipidee/tipidee_util_parse_range.lo +libtipidee.a.xyzzy:src/libtipidee/tipidee_conf_free.lo src/libtipidee/tipidee_conf_get.lo src/libtipidee/tipidee_conf_get_argv.lo src/libtipidee/tipidee_conf_get_content_type.lo src/libtipidee/tipidee_conf_get_errorfile.lo src/libtipidee/tipidee_conf_get_redirection.lo src/libtipidee/tipidee_conf_get_resattr.lo src/libtipidee/tipidee_conf_get_resattr1.lo src/libtipidee/tipidee_conf_get_responseheaders.lo src/libtipidee/tipidee_conf_get_string.lo src/libtipidee/tipidee_conf_get_uint32.lo src/libtipidee/tipidee_conf_init.lo src/libtipidee/tipidee_headers_get_content_length.lo src/libtipidee/tipidee_headers_init.lo src/libtipidee/tipidee_headers_parse.lo src/libtipidee/tipidee_headers_search.lo src/libtipidee/tipidee_log_answer.lo src/libtipidee/tipidee_log_exit.lo src/libtipidee/tipidee_log_request.lo src/libtipidee/tipidee_log_resource.lo src/libtipidee/tipidee_log_start.lo src/libtipidee/tipidee_method.lo src/libtipidee/tipidee_response_error_nofile.lo src/libtipidee/tipidee_response_error_nofile_G.lo src/libtipidee/tipidee_response_file.lo src/libtipidee/tipidee_response_file_G.lo src/libtipidee/tipidee_response_header_date.lo src/libtipidee/tipidee_response_header_date_G.lo src/libtipidee/tipidee_response_header_date_fmt.lo src/libtipidee/tipidee_response_header_end.lo src/libtipidee/tipidee_response_header_lastmodified.lo src/libtipidee/tipidee_response_header_preparebuiltin.lo src/libtipidee/tipidee_response_header_write.lo src/libtipidee/tipidee_response_header_writeall.lo src/libtipidee/tipidee_response_header_writeall_G.lo src/libtipidee/tipidee_response_header_writemerge.lo src/libtipidee/tipidee_response_header_writemerge_G.lo src/libtipidee/tipidee_response_partial.lo src/libtipidee/tipidee_response_partial_G.lo src/libtipidee/tipidee_response_status.lo src/libtipidee/tipidee_rql_read.lo src/libtipidee/tipidee_uri_parse.lo src/libtipidee/tipidee_util_chunked_read.lo src/libtipidee/tipidee_util_defaulttext.lo src/libtipidee/tipidee_util_htmlescape.lo src/libtipidee/tipidee_util_httpdate.lo src/libtipidee/tipidee_util_parse_range.lo endif +libtipidee.pc: EXTRA_LIBS := -lskarnet libtipidee.so.xyzzy: EXTRA_LIBS := -lskarnet -libtipidee.so.xyzzy: src/libtipidee/tipidee_conf_free.lo src/libtipidee/tipidee_conf_get.lo src/libtipidee/tipidee_conf_get_argv.lo src/libtipidee/tipidee_conf_get_content_type.lo src/libtipidee/tipidee_conf_get_errorfile.lo src/libtipidee/tipidee_conf_get_redirection.lo src/libtipidee/tipidee_conf_get_resattr.lo src/libtipidee/tipidee_conf_get_resattr1.lo src/libtipidee/tipidee_conf_get_responseheaders.lo src/libtipidee/tipidee_conf_get_string.lo src/libtipidee/tipidee_conf_get_uint32.lo src/libtipidee/tipidee_conf_init.lo src/libtipidee/tipidee_headers_get_content_length.lo src/libtipidee/tipidee_headers_init.lo src/libtipidee/tipidee_headers_parse.lo src/libtipidee/tipidee_headers_search.lo src/libtipidee/tipidee_log_answer.lo src/libtipidee/tipidee_log_exit.lo src/libtipidee/tipidee_log_request.lo src/libtipidee/tipidee_log_resource.lo src/libtipidee/tipidee_log_start.lo src/libtipidee/tipidee_method.lo src/libtipidee/tipidee_response_error_nofile.lo src/libtipidee/tipidee_response_error_nofile_G.lo src/libtipidee/tipidee_response_file.lo src/libtipidee/tipidee_response_file_G.lo src/libtipidee/tipidee_response_header_date.lo src/libtipidee/tipidee_response_header_date_G.lo src/libtipidee/tipidee_response_header_date_fmt.lo src/libtipidee/tipidee_response_header_end.lo src/libtipidee/tipidee_response_header_lastmodified.lo src/libtipidee/tipidee_response_header_preparebuiltin.lo src/libtipidee/tipidee_response_header_write.lo src/libtipidee/tipidee_response_header_writeall.lo src/libtipidee/tipidee_response_header_writeall_G.lo src/libtipidee/tipidee_response_header_writemerge.lo src/libtipidee/tipidee_response_header_writemerge_G.lo src/libtipidee/tipidee_response_partial.lo src/libtipidee/tipidee_response_partial_G.lo src/libtipidee/tipidee_response_status.lo src/libtipidee/tipidee_rql_read.lo src/libtipidee/tipidee_uri_parse.lo src/libtipidee/tipidee_util_chunked_read.lo src/libtipidee/tipidee_util_defaulttext.lo src/libtipidee/tipidee_util_htmlescape.lo src/libtipidee/tipidee_util_httpdate.lo src/libtipidee/tipidee_util_parse_range.lo -ls.cgi: EXTRA_LIBS := -lskarnet -ls.cgi: src/misc/ls.cgi.o libtipidee.a.xyzzy -tipideed: EXTRA_LIBS := -lskarnet -tipideed: src/tipideed/tipideed.o src/tipideed/cgi.o src/tipideed/errors.o src/tipideed/harden.o src/tipideed/options.o src/tipideed/regular.o src/tipideed/redirection.o src/tipideed/send_file.o src/tipideed/stream.o src/tipideed/trace.o src/tipideed/util.o libtipidee.a.xyzzy +libtipidee.so.xyzzy:src/libtipidee/tipidee_conf_free.lo src/libtipidee/tipidee_conf_get.lo src/libtipidee/tipidee_conf_get_argv.lo src/libtipidee/tipidee_conf_get_content_type.lo src/libtipidee/tipidee_conf_get_errorfile.lo src/libtipidee/tipidee_conf_get_redirection.lo src/libtipidee/tipidee_conf_get_resattr.lo src/libtipidee/tipidee_conf_get_resattr1.lo src/libtipidee/tipidee_conf_get_responseheaders.lo src/libtipidee/tipidee_conf_get_string.lo src/libtipidee/tipidee_conf_get_uint32.lo src/libtipidee/tipidee_conf_init.lo src/libtipidee/tipidee_headers_get_content_length.lo src/libtipidee/tipidee_headers_init.lo src/libtipidee/tipidee_headers_parse.lo src/libtipidee/tipidee_headers_search.lo src/libtipidee/tipidee_log_answer.lo src/libtipidee/tipidee_log_exit.lo src/libtipidee/tipidee_log_request.lo src/libtipidee/tipidee_log_resource.lo src/libtipidee/tipidee_log_start.lo src/libtipidee/tipidee_method.lo src/libtipidee/tipidee_response_error_nofile.lo src/libtipidee/tipidee_response_error_nofile_G.lo src/libtipidee/tipidee_response_file.lo src/libtipidee/tipidee_response_file_G.lo src/libtipidee/tipidee_response_header_date.lo src/libtipidee/tipidee_response_header_date_G.lo src/libtipidee/tipidee_response_header_date_fmt.lo src/libtipidee/tipidee_response_header_end.lo src/libtipidee/tipidee_response_header_lastmodified.lo src/libtipidee/tipidee_response_header_preparebuiltin.lo src/libtipidee/tipidee_response_header_write.lo src/libtipidee/tipidee_response_header_writeall.lo src/libtipidee/tipidee_response_header_writeall_G.lo src/libtipidee/tipidee_response_header_writemerge.lo src/libtipidee/tipidee_response_header_writemerge_G.lo src/libtipidee/tipidee_response_partial.lo src/libtipidee/tipidee_response_partial_G.lo src/libtipidee/tipidee_response_status.lo src/libtipidee/tipidee_rql_read.lo src/libtipidee/tipidee_uri_parse.lo src/libtipidee/tipidee_util_chunked_read.lo src/libtipidee/tipidee_util_defaulttext.lo src/libtipidee/tipidee_util_htmlescape.lo src/libtipidee/tipidee_util_httpdate.lo src/libtipidee/tipidee_util_parse_range.lo +ls.cgi: EXTRA_LIBS := +ls.cgi: src/misc/ls.cgi.o libtipidee.a.xyzzy -lskarnet +tipideed: EXTRA_LIBS := +tipideed: src/tipideed/tipideed.o src/tipideed/cgi.o src/tipideed/errors.o src/tipideed/harden.o src/tipideed/options.o src/tipideed/regular.o src/tipideed/redirection.o src/tipideed/send_file.o src/tipideed/stream.o src/tipideed/trace.o src/tipideed/util.o libtipidee.a.xyzzy -lskarnet INTERNAL_LIBS := diff --git a/package/targets.mak b/package/targets.mak index b1bc92e..a600e23 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -7,3 +7,4 @@ tipidee-config-preprocess \ ls.cgi LIB_DEFS := TIPIDEE=tipidee +TIPIDEE_DESCRIPTION := A library containing helpers to write an HTTP server diff --git a/tools/configure.template b/tools/configure.template new file mode 100755 index 0000000..6ff35bb --- /dev/null +++ b/tools/configure.template @@ -0,0 +1,538 @@ +#!/bin/sh + +cd `dirname "$0"` +. package/info + +usage () { +cat <<EOF +Usage: $0 [OPTION]... [TARGET] + +Defaults for the options are specified in brackets. + +System types: + --target=TARGET configure to run on target TARGET [detected] + --host=TARGET same as --target + +Installation directories: + --prefix=PREFIX main installation prefix [/] + --exec-prefix=EPREFIX installation prefix for executable files [PREFIX] + +Fine tuning of the installation directories: + --dynlibdir=DIR shared library files [PREFIX/lib] + --bindir=BINDIR user executables [EPREFIX/bin] + --libexecdir=DIR package-scoped executables [EPREFIX/libexec] + --libdir=DIR static library files [PREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --sysconfdir=DIR global configuration files [PREFIX/etc] + --pkgconfdir=DIR pkg-config .pc files [PREFIX/lib/pkgconfig] +${configure_help_install} + If no --prefix option is given, by default libdir (but not dynlibdir) will be + /usr/lib, and includedir will be /usr/include. + +Dependencies: + --with-sysdeps=DIR use sysdeps in DIR [PREFIX/lib/skalibs/sysdeps] + --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 +${configure_help_dependencies} + If no --prefix option is given, by default sysdeps will be fetched from + /usr/lib/skalibs/sysdeps. + +Optional features: + --enable-shared build shared libraries [disabled] + --disable-static do not build static libraries [enabled] + --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 hardcode absolute BINDIR/foobar paths in binaries [disabled] +${configure_help_options} +EOF +exit 0 +} + +# Helper functions + +# If your system does not have printf, you can comment this, but it is +# generally not a good idea to use echo. +# See http://www.etalabs.net/sh_tricks.html +echo () { + printf %s\\n "$*" +} + +quote () { + tr '\n' ' ' <<EOF | grep '^[-[:alnum:]_=,./:]* $' >/dev/null 2>&1 && { echo "$1" ; return 0 ; } +$1 +EOF + echo "$1" | sed -e "s/'/'\\\\''/g" -e "1s/^/'/" -e "\$s/\$/'/" -e "s#^'\([-[:alnum:]_,./:]*\)=\(.*\)\$#\1='\2#" -e "s|\*/|* /|g" +} + +fail () { + echo "$*" + exit 1 +} + +fnmatch () { + eval "case \"\$2\" in $1) return 0 ;; *) return 1 ;; esac" +} + +cmdexists () { + type "$1" >/dev/null 2>&1 +} + +trycc () { + test -z "$CC_AUTO" && cmdexists "$1" && CC_AUTO="$*" +} + +stripdir () { + while eval "fnmatch '*/' \"\${$1}\"" ; do + eval "$1=\${$1%/}" + done +} + +tryflag () { + echo "Checking whether compiler accepts $2 ..." + echo "typedef int x;" > "$tmpc" + if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST "$2" -c -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then + echo " ... yes" + eval "$1=\"\${$1} \$2\"" + eval "$1=\${$1# }" + return 0 + else + echo " ... no" + return 1 + fi +} + +tryldflag () { + echo "Checking whether linker accepts $2 ..." + echo "typedef int x;" > "$tmpc" + if $CC_AUTO $CFLAGS_AUTO $CFLAGS $CFLAGS_POST $LDFLAGS_AUTO $LDFLAGS $LDFLAGS_POST -nostdlib "$2" -o "$tmpe" "$tmpc" >/dev/null 2>&1 ; then + echo " ... yes" + eval "$1=\"\${$1} \$2\"" + eval "$1=\${$1# }" + return 0 + else + echo " ... no" + return 1 + fi +} + + +# Actual script + +CC_AUTO= +CPPFLAGS_AUTO="-D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -iquote src/include-local -Isrc/include" +CPPFLAGS_POST="$CPPFLAGS" +CPPFLAGS= +CFLAGS_AUTO="-pipe -Wall" +CFLAGS_POST="$CFLAGS" +CFLAGS=-O2 +LDFLAGS_AUTO= +LDFLAGS_POST="$LDFLAGS" +LDFLAGS= +LDFLAGS_NOSHARED= +LDFLAGS_SHARED=-shared +prefix= +exec_prefix='$prefix' +dynlibdir='$prefix/lib' +libexecdir='$exec_prefix/libexec' +bindir='$exec_prefix/bin' +libdir='$prefix/lib' +includedir='$prefix/include' +sysconfdir='$prefix/etc' +pkgconfdir='$prefix/lib/pkgconfig' +shebangdir='$bindir' +sysdeps='$prefix/lib/skalibs/sysdeps' +manualsysdeps=false +shared=false +static=true +allpic=true +slashpackage=false +abspath=false +pcw=false +sproot= +home= +exthome= +allstatic=true +evenmorestatic=false +pkgconf= +addincpath='' +addlibspath='' +addlibdpath='' +depincpath='' +deplibpath='' +vpaths='' +vpathd='' +build= +${configure_init_vars} + +for arg ; do + case "$arg" in + --help) usage ;; + --prefix=*) prefix=${arg#*=} ;; + --exec-prefix=*) exec_prefix=${arg#*=} ;; + --dynlibdir=*) dynlibdir=${arg#*=} ;; + --libexecdir=*) libexecdir=${arg#*=} ;; + --bindir=*) bindir=${arg#*=} ;; + --libdir=*) libdir=${arg#*=} ;; + --includedir=*) includedir=${arg#*=} ;; + --sysconfdir=*) sysconfdir=${arg#*=} ;; + --pkgconfigdir=*) pkgconfigdir=${arg#*=} ;; + --with-sysdeps=*) sysdeps=${arg#*=} manualsysdeps=true ;; + --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 ;; + --disable-static|--enable-static=no) static=false ;; + --enable-allstatic|--enable-allstatic=yes) allstatic=true ;; + --disable-allstatic|--enable-allstatic=no) allstatic=false ; evenmorestatic=false ;; + --enable-static-libc|--enable-static-libc=yes) allstatic=true ; evenmorestatic=true ;; + --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 ;; +${configure_case_lines} + --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; + --enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;; + --host=*|--target=*) target=${arg#*=} ;; + --build=*) build=${arg#*=} ;; + -* ) echo "$0: unknown option $arg" ;; + *=*) eval "${arg%%=*}=\${arg#*=}" ;; + *) target=$arg ;; + esac +done + +# Add /usr in the default default case +if test -z "$prefix" ; then + if test "$libdir" = '$prefix/lib' ; then + libdir=/usr/lib + fi + 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 +fi + +# Expand installation directories +stripdir prefix +for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir pkgconfdir sysdeps sproot ${configure_expand_dirs} ; do + eval tmp=\${$i} + eval $i=$tmp + stripdir $i +done + +# 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 + +# Other slashpackage values +if $slashpackage ; then + home=${sproot}/package/${category}/${package}-${version} + exthome=${sproot}/package/${category}/${package} + if $manualsysdeps ; then + : + else + sysdeps=${DESTDIR}${sproot}/package/prog/skalibs/sysdeps + fi + extbinprefix=${exthome}/command + dynlibdir=${home}/library.so + bindir=${home}/command + libdir=${home}/library + libexecdir=$bindir + includedir=${home}/include + pkgconfdir=${home}/pkgconfig +${configure_slashpackage_other} +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}- +else + cross= +fi +echo "Checking for C compiler..." +trycc ${CC} +if test -n "$CC_AUTO" ; then + b=`basename "$CC"` + adjust_cross=false + if test "$b" != "$CC" ; then + adjust_cross=true + echo "$0: warning: compiler $CC is declared with its own path. If it's not accessible via PATH, you will need to pass AR, RANLIB and STRIP make variables to the make invocation." 1>&2 + fi + if test -n "$cross" ; then + if test "$b" = "${b##$cross}" ; then + echo "$0: warning: compiler $CC is declared as a cross-compiler for target $target but does not start with prefix ${cross}" 1>&2 + elif $adjust_cross ; then + cross=`dirname "$CC"`/"$cross" + fi + fi +fi +trycc ${cross}gcc +trycc ${cross}clang +trycc ${cross}cc +test -n "$CC_AUTO" || { echo "$0: cannot find a C compiler" ; exit 1 ; } +echo " ... $CC_AUTO" +echo "Checking whether C compiler works... " +echo "typedef int x;" > "$tmpc" +if $CC_AUTO $CPPFLAGS_AUTO $CPPFLAGS $CPPFLAGS_POST $CFLAGS_AUTO $CFLAGS $CFLAGS_POST -c -o "$tmpo" "$tmpc" 2>"$tmpe" ; then + echo " ... yes" +else + echo " ... no. Compiler output follows:" + cat < "$tmpe" + exit 1 +fi + +echo "Checking target system type..." +if test -z "$target" ; then + if test -n "$build" ; then + target=$build ; + else + target=$($CC_AUTO -dumpmachine 2>/dev/null) || target=unknown + fi +fi +echo " ... $target" +if test ! -d $sysdeps || test ! -f $sysdeps/target ; then + echo "$0: error: $sysdeps is not a valid sysdeps directory" + exit 1 +fi +if [ "x$target" != "x$(cat $sysdeps/target)" ] ; then + echo "$0: error: target $target does not match the contents of $sysdeps/target" + 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) + +tryflag CFLAGS_AUTO -std=c99 +tryflag CFLAGS -fomit-frame-pointer +tryflag CFLAGS_AUTO -fno-exceptions +tryflag CFLAGS_AUTO -fno-unwind-tables +tryflag CFLAGS_AUTO -fno-asynchronous-unwind-tables +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 CFLAGS_AUTO -ffunction-sections +tryflag CFLAGS_AUTO -fdata-sections + +tryldflag LDFLAGS_AUTO -Wl,--sort-section=alignment +tryldflag LDFLAGS_AUTO -Wl,--sort-common + +CPPFLAGS_AUTO="${CPPFLAGS_AUTO}${addincpath}" + +if $evenmorestatic ; then + LDFLAGS_NOSHARED=-static +fi + +if $shared ; then + tryldflag LDFLAGS -Wl,--hash-style=both +fi + +LDFLAGS_SHARED="${LDFLAGS_SHARED}${addlibdpath}" + +if $allstatic ; then + LDFLAGS_NOSHARED="${LDFLAGS_NOSHARED}${addlibspath}" + tryldflag LDFLAGS_NOSHARED -Wl,--gc-sections +else + LDFLAGS_NOSHARED="${LDFLAGS_NOSHARED}${addlibdpath}" +fi + +${configure_extra_checks} + +echo "Creating config.mak..." +cmdline=$(quote "$0") +for i ; do cmdline="$cmdline $(quote "$i")" ; done +exec 3>&1 1>config.mak +cat << EOF +# This file was generated by: +# $cmdline +# Any changes made here will be lost if configure is re-run. + +target := $target +package := $package +prefix := $prefix +exec_prefix := $exec_prefix +dynlibdir := $dynlibdir +libexecdir := $libexecdir +bindir := $bindir +libdir := $libdir +includedir := $includedir +sysconfdir := $sysconfdir +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} +TIMER_LIB := ${timer_lib} +UTIL_LIB := ${util_lib} + +CC := $CC_AUTO +CPPFLAGS_AUTO := $CPPFLAGS_AUTO +CPPFLAGS := ${CPPFLAGS}${CPPFLAGS_POST:+ }$CPPFLAGS_POST +CFLAGS_AUTO := $CFLAGS_AUTO +CFLAGS := ${CFLAGS}${CFLAGS_POST:+ }$CFLAGS_POST +LDFLAGS_AUTO := $LDFLAGS_AUTO +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" +else + echo "DO_STATIC :=" +fi +if $shared ; then + echo "DO_SHARED := 1" +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 + echo "STATIC_LIBS_ARE_PIC :=" +fi +${configure_generate_make} +exec 1>&3 3>&- +echo " ... done." + +echo "Creating src/include/${package}/config.h..." +mkdir -p -m 0755 src/include/${package} +exec 3>&1 1> src/include/${package}/config.h +cat <<EOF +/* ISC license. */ + +/* Generated by: $cmdline */ + +#ifndef ${package_macro_name}_CONFIG_H +#define ${package_macro_name}_CONFIG_H + +#define ${package_macro_name}_VERSION "$version" +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}_SYSCONFPREFIX \"$sysconfdir/\"" +${configure_generate_configh} +echo +echo "#endif" +exec 1>&3 3>&- +echo " ... done." diff --git a/tools/gen-configure.el b/tools/gen-configure.el new file mode 100755 index 0000000..577d86f --- /dev/null +++ b/tools/gen-configure.el @@ -0,0 +1,32 @@ +#!/command/execlineb -S0 + +# For dev use only. Don't run this, it overwrites your configure. + +# The quoting interactions in sed and sh make it impossible to get +# such a simple thing done. It's amazing how bad traditional Unix is. + +backtick -E TEMPLATE { redirfd -r 0 tools/configure.template s6-cat } +s6-envdir -Lf package/configure-snippets +multisubstitute +{ + importas -uS configure_help_install + importas -uS configure_help_dependencies + importas -uS configure_help_options + importas -uS configure_init_vars + importas -uS configure_case_lines + importas -uS configure_expand_dirs + importas -uS configure_slashpackage_other + importas -uS configure_extra_checks + importas -uS configure_generate_make + importas -uS configure_generate_configh +} + +if +{ + heredoc 0 ${TEMPLATE} + redirfd -w 1 configure.new + s6-cat +} + +if { s6-chmod 0755 configure.new } +s6-rename configure.new configure diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh index befe021..9e18eb1 100755 --- a/tools/gen-deps.sh +++ b/tools/gen-deps.sh @@ -61,20 +61,23 @@ for dir in $(ls -1 src | grep -v ^include) ; do deps= libs= while read dep ; do - if echo $dep | grep -q -e ^-l -e '^\${.*_LIB}' ; then + if echo $dep | grep -q -e '^-l' -e '^\${.*_LIB}' ; then libs="$libs $dep" + elif echo $dep | grep -q '^\${LIB' ; then + deps="$deps $dep" else deps="$deps src/$dir/$dep" fi done < src/$dir/deps-lib/$file echo 'ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),)' - echo "lib${file}.a.xyzzy:$deps" + echo "lib${file}.a.xyzzy:${deps}" echo else - echo "lib${file}.a.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" + echo "lib${file}.a.xyzzy:$(echo ${deps} | sed 's/\.o/.lo/g')" echo endif - if grep -E "^LIB_DEFS [+:]=" package/targets.mak | grep -qF "$file" ; then + if grep -qE "^LIB_DEFS [+:]= .*=$file" package/targets.mak ; then + echo "lib${file}.pc: EXTRA_LIBS :=${libs}" echo "lib${file}.so.xyzzy: EXTRA_LIBS :=$libs" - echo "lib${file}.so.xyzzy:$(echo "$deps" | sed 's/\.o/.lo/g')" + echo "lib${file}.so.xyzzy:$(echo ${deps} | sed 's/\.o/.lo/g')" else internal_libs="$internal_libs lib${file}.a.xyzzy" fi @@ -84,10 +87,10 @@ for dir in $(ls -1 src | grep -v ^include) ; do deps= libs= while read dep ; do - if echo $dep | grep -q -- \\.o$ ; then + if echo $dep | grep -q \\.o$ ; then dep="src/$dir/$dep" fi - if echo $dep | grep -q -e ^-l -e '^\${.*_LIB}' ; then + if echo $dep | grep -qx '\${.*_LIB}' ; then libs="$libs $dep" else deps="$deps $dep" diff --git a/tools/gen-dotpc.sh b/tools/gen-dotpc.sh new file mode 100755 index 0000000..802c78e --- /dev/null +++ b/tools/gen-dotpc.sh @@ -0,0 +1,101 @@ +#!/bin/sh -e + +isunique () { + x=$1 + set -- $2 + while test "$#" -gt 0 ; do + if test "$x" = "$1" ; then + return 1 + fi + shift + done + return 0 +} + +uniqit () { + res= + while test "$#" -gt 0 ; do + if isunique "$1" "$res" ; then + res="${res}${res:+ }${1}" + fi + shift + done + printf %s\\n "$res" +} + +filterout () { + res= + filter="$1" + shift + while test "$#" -gt 0 ; do + if isunique "$1" "$filter" ; then + res="${res}${res:+ }${1}" + fi + shift + done + printf %s\\n "$res" +} + +print_requires () { + line= + oldifs="$IFS" + while IFS=" " read condvar usedinlibs pkg ver libs ; do + IFS="$oldifs" + for h ; do + i=lib${h##-l} + for j in $libs ; do + if test "$i" = "$j" ; then + line="${line}${line:+, }${i} >= ${ver}" + fi + done + done + done < package/deps-build + IFS="$oldifs" + echo "Requires: $line" +} + +. package/info + +ilist= +dlist= +slist= + +if test "${includedir}" != /usr/include ; then + ilist="-I${includedir}" +fi +if test -n "${extra_includedirs}" ; then + ilist="${ilist}${ilist:+ }${extra_includedirs}" +fi +ilist=`uniqit ${ilist}` + +if test "${dynlibdir}" != /usr/lib && test "${dynlibdir}" != /lib ; then + dlist="-L${dynlibdir}" +fi + +if test "${libdir}" != /usr/lib && test "${libdir}" != /lib ; then + slist="-L${libdir}" +fi +if test -n "${extra_libdirs}" ; then + slist="${slist}${slist:+ }${extra_libdirs}" +fi +slist="$(filterout "${dlist}" $(uniqit ${slist}))" + +echo "prefix=${prefix}" +echo "includedir=${includedir}" +echo "libdir=${libdir}" +echo "dynlibdir=${dynlibdir}" +echo +echo "Name: lib${library}" +echo "Version: ${version}" +echo "Description: ${description:-The ${library} library.}" +echo "URL: ${url:-https://skarnet.org/software/${package}/}" +if test -n "${extra_libs}" ; then + print_requires ${extra_libs} +fi +if test -n "$ilist" ; then + echo "Cflags: ${ilist}" +fi +echo "Libs: ${dlist}${dlist:+ }-l${library}${ldlibs:+ }${ldlibs}" +if test -n "${extra_libs}" ; then + echo "Libs.private: ${slist}${slist:+ }${extra_libs}" +fi diff --git a/tools/run-test.sh b/tools/run-test.sh new file mode 100755 index 0000000..d651b09 --- /dev/null +++ b/tools/run-test.sh @@ -0,0 +1,22 @@ +#!/bin/sh -e + +prog="$1" + +if test -x "./src/tests/${prog}.wrapper" ; then + cmd="./src/tests/${prog}.wrapper $prog" +else + cmd="./$prog" +fi + +if test -r "./src/tests/${prog}.expected" ; then + cp -f "./src/tests/${prog}.expected" "./${prog}.expected" +elif test -x "./src/tests/${prog}.baseline" ; then + "./src/tests/${prog}.baseline" > "./${prog}.expected" +else + echo "run-test.sh: fatal: missing baseline for $prog" 1>&2 ; exit 100 +fi + +$cmd | diff "./${prog}.expected" - + +rm -f "./${prog}.expected" +echo "run-test.sh: info: $prog: pass" 1>&2 |
