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 | |
| parent | 15583497da174dd17b7b44701dcb000f46c235ed (diff) | |
| download | execline-7cada88937b8f7edead691a462d3339834674ec9.tar.gz | |
First version of pkg-config support
Signed-off-by: Laurent Bercot <ska@appnovation.com>
| -rw-r--r-- | Makefile | 58 | ||||
| -rwxr-xr-x | configure | 135 | ||||
| -rw-r--r-- | package/deps-build | 4 | ||||
| -rw-r--r-- | package/deps.mak | 218 | ||||
| -rw-r--r-- | package/targets.mak | 7 | ||||
| -rwxr-xr-x | tools/gen-deps.sh | 16 | ||||
| -rwxr-xr-x | tools/gen-dotpc.sh | 101 |
7 files changed, 360 insertions, 179 deletions
@@ -12,34 +12,51 @@ 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 := -PC_DEFS := define library_definition -name := $(lastword $(subst =, ,$(1))) -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 -PC_DEFS += $(lastword $(subst =, ,$(1))) -$(lastword $(subst =, ,$(1))).pc: $(if $(DO_SHARED),lib$(lastword $(subst =, ,$(1))).so.xyzzy,) $(if $(DO_STATIC),lib$(lastword $(subst =, ,$(1))).a.xyzzy,) - ./tools/gen-dotpc.sh $(lastword $(subst =, ,$(1))) $(if $(DO_SHARED),true,false) $(if $(DO_STATIC),true,false) "$$($(lastword $(subst =, ,$(1)))_description)" "$(includedir)" "$(dynlibdir)" "$(libdir)" "$$($(lastword $(subst =, ,$(1)))_dependencies)" +lib$(2).pc: + exec env \ + library="$(2)" \ + includedir="$(includedir)" \ + dynlibdir="$(dynlibdir)" \ + libdir="$(libdir)" \ + buildtime_includedirs="$(buildtime_includedirs)" \ + buildtime_dynlibdirs="$(buildtime_dynlibdirs)" \ + buildtime_libdirs="$(buildtime_libdirs)" \ + extra_libs="$$(strip $$(EXTRA_LIBS))" \ + requires="$$($(1)_REQUIRES)" \ + requires_private="$$($(1)_REQUIRES_PRIVATE)" \ + description="$$($(1)_DESCRIPTION)" \ + ldlibs="$(LDLIBS)" \ + ./tools/gen-dotpc.sh > $$@.tmp + exec mv -f $$@.tmp $$@ endef define binary_installation_rule -$(DESTDIR)$(1)/$(2): $(2) package/modes +$(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 && \ @@ -54,7 +71,7 @@ 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 @@ -74,7 +91,7 @@ RANLIB := $(CROSS_COMPILE)ranlib STRIP := $(CROSS_COMPILE)strip INSTALL := ./tools/install.sh -$(foreach var,$(filter-out define,$(BIN_TARGETS)),$(eval $(call binary_installation_rule,$(bindir),$(var)))) +$(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)))) @@ -82,10 +99,10 @@ 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) $(wildcard src/*/*.o src/*/*.lo) $(PC_TARGETS) $(EXTRA_TARGETS) distclean: clean @exec rm -f config.mak src/include/$(package)/config.h @@ -106,13 +123,14 @@ 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-symlinks 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)/%) ifneq ($(exthome),) @@ -147,27 +165,25 @@ $(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 $@ $< -ifdef DO_ALLSTATIC -$(ALL_BINS): -lskarnet - exec $(CC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS) -else $(ALL_BINS): exec $(CC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS) -endif lib%.a.xyzzy: exec $(AR) rc $@ $^ 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 tgz strip install install-dynlib install-bin install-lib install-include install-pkgconfig .DELETE_ON_ERROR: @@ -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" diff --git a/package/deps-build b/package/deps-build index eb4384b..689b950 100644 --- a/package/deps-build +++ b/package/deps-build @@ -1,2 +1,2 @@ -/package/prog/skalibs -/package/admin/nsss $usensss +true /package/prog/skalibs 2.14.4.0 true libskarnet +$usensss /package/admin/nsss 0.2.0.6 false libnsss diff --git a/package/deps.mak b/package/deps.mak index 87a4521..293e0a6 100644 --- a/package/deps.mak +++ b/package/deps.mak @@ -81,116 +81,118 @@ src/libexecline/exlsn_free.o src/libexecline/exlsn_free.lo: src/libexecline/exls src/libexecline/exlsn_importas.o src/libexecline/exlsn_importas.lo: src/libexecline/exlsn_importas.c src/include/execline/execline.h src/include-local/exlsn.h src/libexecline/exlsn_main.o src/libexecline/exlsn_main.lo: src/libexecline/exlsn_main.c src/include/execline/execline.h src/include-local/exlsn.h src/libexecline/exlsn_multidefine.o src/libexecline/exlsn_multidefine.lo: src/libexecline/exlsn_multidefine.c src/include/execline/execline.h src/include-local/exlsn.h +src/multicall/execline.o src/multicall/execline.lo: src/multicall/execline.c src/include/execline/config.h src/include/execline/execline.h src/include-local/exlsn.h -background: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -background: src/execline/background.o ${LIBEXECLINE} -backtick: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -backtick: src/execline/backtick.o ${LIBEXECLINE} -case: EXTRA_LIBS := -lskarnet -case: src/execline/case.o ${LIBEXECLINE} -define: EXTRA_LIBS := -lskarnet -define: src/execline/define.o ${LIBEXECLINE} -dollarat: EXTRA_LIBS := -lskarnet -dollarat: src/execline/dollarat.o -elgetopt: EXTRA_LIBS := -lskarnet -elgetopt: src/execline/elgetopt.o ${LIBEXECLINE} -elgetpositionals: EXTRA_LIBS := -lskarnet -elgetpositionals: src/execline/elgetpositionals.o ${LIBEXECLINE} -elglob: EXTRA_LIBS := -lskarnet -elglob: src/execline/elglob.o ${LIBEXECLINE} -eltest: EXTRA_LIBS := -lskarnet -eltest: src/execline/eltest.o -emptyenv: EXTRA_LIBS := -lskarnet -emptyenv: src/execline/emptyenv.o ${LIBEXECLINE} -envfile: EXTRA_LIBS := -lskarnet -envfile: src/execline/envfile.o -exec: EXTRA_LIBS := -lskarnet -exec: src/execline/exec.o -execline-cd: EXTRA_LIBS := -lskarnet -execline-cd: src/execline/execline-cd.o -execline-umask: EXTRA_LIBS := -lskarnet -execline-umask: src/execline/execline-umask.o -execlineb: EXTRA_LIBS := -lskarnet -execlineb: src/execline/execlineb.o ${LIBEXECLINE} -exit: EXTRA_LIBS := -lskarnet -exit: src/execline/exit.o -export: EXTRA_LIBS := -lskarnet -export: src/execline/export.o -export-array: EXTRA_LIBS := -lskarnet -export-array: src/execline/export-array.o ${LIBEXECLINE} -fdblock: EXTRA_LIBS := -lskarnet -fdblock: src/execline/fdblock.o -fdclose: EXTRA_LIBS := -lskarnet -fdclose: src/execline/fdclose.o -fdmove: EXTRA_LIBS := -lskarnet -fdmove: src/execline/fdmove.o -fdreserve: EXTRA_LIBS := -lskarnet -fdreserve: src/execline/fdreserve.o -fdswap: EXTRA_LIBS := -lskarnet -fdswap: src/execline/fdswap.o -forbacktickx: EXTRA_LIBS := -lskarnet -forbacktickx: src/execline/forbacktickx.o -foreground: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -foreground: src/execline/foreground.o ${LIBEXECLINE} -forstdin: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -forstdin: src/execline/forstdin.o ${LIBEXECLINE} -forx: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -forx: src/execline/forx.o ${LIBEXECLINE} -getcwd: EXTRA_LIBS := -lskarnet -getcwd: src/execline/getcwd.o ${LIBEXECLINE} -getpid: EXTRA_LIBS := -lskarnet -getpid: src/execline/getpid.o ${LIBEXECLINE} -heredoc: EXTRA_LIBS := -lskarnet -heredoc: src/execline/heredoc.o -homeof: EXTRA_LIBS := -lskarnet ${MAYBEPTHREAD_LIB} -homeof: src/execline/homeof.o ${LIBNSSS} -if: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -if: src/execline/if.o ${LIBEXECLINE} -ifelse: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -ifelse: src/execline/ifelse.o ${LIBEXECLINE} -ifte: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -ifte: src/execline/ifte.o ${LIBEXECLINE} -ifthenelse: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -ifthenelse: src/execline/ifthenelse.o ${LIBEXECLINE} -importas: EXTRA_LIBS := -lskarnet -importas: src/execline/importas.o ${LIBEXECLINE} -loopwhilex: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -loopwhilex: src/execline/loopwhilex.o ${LIBEXECLINE} -multidefine: EXTRA_LIBS := -lskarnet -multidefine: src/execline/multidefine.o ${LIBEXECLINE} -multisubstitute: EXTRA_LIBS := -lskarnet -multisubstitute: src/execline/multisubstitute.o ${LIBEXECLINE} -pipeline: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -pipeline: src/execline/pipeline.o ${LIBEXECLINE} -piperw: EXTRA_LIBS := -lskarnet -piperw: src/execline/piperw.o -posix-cd: EXTRA_LIBS := -lskarnet -posix-cd: src/execline/posix-cd.o -posix-umask: EXTRA_LIBS := -lskarnet -posix-umask: src/execline/posix-umask.o -redirfd: EXTRA_LIBS := -lskarnet -redirfd: src/execline/redirfd.o -runblock: EXTRA_LIBS := -lskarnet -runblock: src/execline/runblock.o ${LIBEXECLINE} -shift: EXTRA_LIBS := -lskarnet -shift: src/execline/shift.o ${LIBEXECLINE} -trap: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -trap: src/execline/trap.o ${LIBEXECLINE} -tryexec: EXTRA_LIBS := -lskarnet -tryexec: src/execline/tryexec.o ${LIBEXECLINE} -unexport: EXTRA_LIBS := -lskarnet -unexport: src/execline/unexport.o -wait: EXTRA_LIBS := -lskarnet -wait: src/execline/wait.o ${LIBEXECLINE} -withstdinas: EXTRA_LIBS := -lskarnet -withstdinas: src/execline/withstdinas.o ${LIBEXECLINE} +background: EXTRA_LIBS := ${SPAWN_LIB} +background: src/execline/background.o ${LIBEXECLINE} -lskarnet +backtick: EXTRA_LIBS := ${SPAWN_LIB} +backtick: src/execline/backtick.o ${LIBEXECLINE} -lskarnet +case: EXTRA_LIBS := +case: src/execline/case.o ${LIBEXECLINE} -lskarnet +define: EXTRA_LIBS := +define: src/execline/define.o ${LIBEXECLINE} -lskarnet +dollarat: EXTRA_LIBS := +dollarat: src/execline/dollarat.o -lskarnet +elgetopt: EXTRA_LIBS := +elgetopt: src/execline/elgetopt.o ${LIBEXECLINE} -lskarnet +elgetpositionals: EXTRA_LIBS := +elgetpositionals: src/execline/elgetpositionals.o ${LIBEXECLINE} -lskarnet +elglob: EXTRA_LIBS := +elglob: src/execline/elglob.o ${LIBEXECLINE} -lskarnet +eltest: EXTRA_LIBS := +eltest: src/execline/eltest.o -lskarnet +emptyenv: EXTRA_LIBS := +emptyenv: src/execline/emptyenv.o ${LIBEXECLINE} -lskarnet +envfile: EXTRA_LIBS := +envfile: src/execline/envfile.o -lskarnet +exec: EXTRA_LIBS := +exec: src/execline/exec.o -lskarnet +execline-cd: EXTRA_LIBS := +execline-cd: src/execline/execline-cd.o -lskarnet +execline-umask: EXTRA_LIBS := +execline-umask: src/execline/execline-umask.o -lskarnet +execlineb: EXTRA_LIBS := +execlineb: src/execline/execlineb.o ${LIBEXECLINE} -lskarnet +exit: EXTRA_LIBS := +exit: src/execline/exit.o -lskarnet +export: EXTRA_LIBS := +export: src/execline/export.o -lskarnet +export-array: EXTRA_LIBS := +export-array: src/execline/export-array.o ${LIBEXECLINE} -lskarnet +fdblock: EXTRA_LIBS := +fdblock: src/execline/fdblock.o -lskarnet +fdclose: EXTRA_LIBS := +fdclose: src/execline/fdclose.o -lskarnet +fdmove: EXTRA_LIBS := +fdmove: src/execline/fdmove.o -lskarnet +fdreserve: EXTRA_LIBS := +fdreserve: src/execline/fdreserve.o -lskarnet +fdswap: EXTRA_LIBS := +fdswap: src/execline/fdswap.o -lskarnet +forbacktickx: EXTRA_LIBS := +forbacktickx: src/execline/forbacktickx.o -lskarnet +foreground: EXTRA_LIBS := ${SPAWN_LIB} +foreground: src/execline/foreground.o ${LIBEXECLINE} -lskarnet +forstdin: EXTRA_LIBS := ${SPAWN_LIB} +forstdin: src/execline/forstdin.o ${LIBEXECLINE} -lskarnet +forx: EXTRA_LIBS := ${SPAWN_LIB} +forx: src/execline/forx.o ${LIBEXECLINE} -lskarnet +getcwd: EXTRA_LIBS := +getcwd: src/execline/getcwd.o ${LIBEXECLINE} -lskarnet +getpid: EXTRA_LIBS := +getpid: src/execline/getpid.o ${LIBEXECLINE} -lskarnet +heredoc: EXTRA_LIBS := +heredoc: src/execline/heredoc.o -lskarnet +homeof: EXTRA_LIBS := ${MAYBEPTHREAD_LIB} +homeof: src/execline/homeof.o ${LIBNSSS} -lskarnet +if: EXTRA_LIBS := ${SPAWN_LIB} +if: src/execline/if.o ${LIBEXECLINE} -lskarnet +ifelse: EXTRA_LIBS := ${SPAWN_LIB} +ifelse: src/execline/ifelse.o ${LIBEXECLINE} -lskarnet +ifte: EXTRA_LIBS := ${SPAWN_LIB} +ifte: src/execline/ifte.o ${LIBEXECLINE} -lskarnet +ifthenelse: EXTRA_LIBS := ${SPAWN_LIB} +ifthenelse: src/execline/ifthenelse.o ${LIBEXECLINE} -lskarnet +importas: EXTRA_LIBS := +importas: src/execline/importas.o ${LIBEXECLINE} -lskarnet +loopwhilex: EXTRA_LIBS := ${SPAWN_LIB} +loopwhilex: src/execline/loopwhilex.o ${LIBEXECLINE} -lskarnet +multidefine: EXTRA_LIBS := +multidefine: src/execline/multidefine.o ${LIBEXECLINE} -lskarnet +multisubstitute: EXTRA_LIBS := +multisubstitute: src/execline/multisubstitute.o ${LIBEXECLINE} -lskarnet +pipeline: EXTRA_LIBS := ${SPAWN_LIB} +pipeline: src/execline/pipeline.o ${LIBEXECLINE} -lskarnet +piperw: EXTRA_LIBS := +piperw: src/execline/piperw.o -lskarnet +posix-cd: EXTRA_LIBS := +posix-cd: src/execline/posix-cd.o -lskarnet +posix-umask: EXTRA_LIBS := +posix-umask: src/execline/posix-umask.o -lskarnet +redirfd: EXTRA_LIBS := +redirfd: src/execline/redirfd.o -lskarnet +runblock: EXTRA_LIBS := +runblock: src/execline/runblock.o ${LIBEXECLINE} -lskarnet +shift: EXTRA_LIBS := +shift: src/execline/shift.o ${LIBEXECLINE} -lskarnet +trap: EXTRA_LIBS := ${SPAWN_LIB} +trap: src/execline/trap.o ${LIBEXECLINE} -lskarnet +tryexec: EXTRA_LIBS := +tryexec: src/execline/tryexec.o ${LIBEXECLINE} -lskarnet +unexport: EXTRA_LIBS := +unexport: src/execline/unexport.o -lskarnet +wait: EXTRA_LIBS := +wait: src/execline/wait.o ${LIBEXECLINE} -lskarnet +withstdinas: EXTRA_LIBS := +withstdinas: src/execline/withstdinas.o ${LIBEXECLINE} -lskarnet ifeq ($(strip $(STATIC_LIBS_ARE_PIC)),) -libexecline.a.xyzzy: src/libexecline/el_execsequence.o src/libexecline/el_forx_pidinfo.o src/libexecline/el_getstrict.o src/libexecline/el_modif_and_exec.o src/libexecline/el_modif_and_spawn.o src/libexecline/el_modifs_and_exec.o src/libexecline/el_parse.o src/libexecline/el_parse_from_buffer.o src/libexecline/el_parse_from_string.o src/libexecline/el_popenv.o src/libexecline/el_pushenv.o src/libexecline/el_semicolon.o src/libexecline/el_spawn0.o src/libexecline/el_gspawn0.o src/libexecline/el_substandrun.o src/libexecline/el_substandrun_str.o src/libexecline/el_substitute.o src/libexecline/el_transform.o src/libexecline/el_trueargv.o src/libexecline/el_vardupl.o src/libexecline/exlsn_define.o src/libexecline/exlsn_elglob.o src/libexecline/exlsn_importas.o src/libexecline/exlsn_multidefine.o src/libexecline/exlsn_exlp.o src/libexecline/exlsn_main.o src/libexecline/exlsn_free.o src/libexecline/exlp.o +libexecline.a.xyzzy: src/libexecline/el_execsequence.o src/libexecline/el_forx_pidinfo.o src/libexecline/el_getstrict.o src/libexecline/el_modif_and_exec.o src/libexecline/el_modif_and_spawn.o src/libexecline/el_modifs_and_exec.o src/libexecline/el_parse.o src/libexecline/el_parse_from_buffer.o src/libexecline/el_parse_from_string.o src/libexecline/el_popenv.o src/libexecline/el_pushenv.o src/libexecline/el_semicolon.o src/libexecline/el_spawn0.o src/libexecline/el_gspawn0.o src/libexecline/el_substandrun.o src/libexecline/el_substandrun_str.o src/libexecline/el_substitute.o src/libexecline/el_transform.o src/libexecline/el_trueargv.o src/libexecline/el_vardupl.o src/libexecline/exlsn_define.o src/libexecline/exlsn_elglob.o src/libexecline/exlsn_importas.o src/libexecline/exlsn_multidefine.o src/libexecline/exlsn_exlp.o src/libexecline/exlsn_main.o src/libexecline/exlsn_free.o src/libexecline/exlp.o -lskarnet else -libexecline.a.xyzzy: src/libexecline/el_execsequence.lo src/libexecline/el_forx_pidinfo.lo src/libexecline/el_getstrict.lo src/libexecline/el_modif_and_exec.lo src/libexecline/el_modif_and_spawn.lo src/libexecline/el_modifs_and_exec.lo src/libexecline/el_parse.lo src/libexecline/el_parse_from_buffer.lo src/libexecline/el_parse_from_string.lo src/libexecline/el_popenv.lo src/libexecline/el_pushenv.lo src/libexecline/el_semicolon.lo src/libexecline/el_spawn0.lo src/libexecline/el_gspawn0.lo src/libexecline/el_substandrun.lo src/libexecline/el_substandrun_str.lo src/libexecline/el_substitute.lo src/libexecline/el_transform.lo src/libexecline/el_trueargv.lo src/libexecline/el_vardupl.lo src/libexecline/exlsn_define.lo src/libexecline/exlsn_elglob.lo src/libexecline/exlsn_importas.lo src/libexecline/exlsn_multidefine.lo src/libexecline/exlsn_exlp.lo src/libexecline/exlsn_main.lo src/libexecline/exlsn_free.lo src/libexecline/exlp.lo +libexecline.a.xyzzy: src/libexecline/el_execsequence.lo src/libexecline/el_forx_pidinfo.lo src/libexecline/el_getstrict.lo src/libexecline/el_modif_and_exec.lo src/libexecline/el_modif_and_spawn.lo src/libexecline/el_modifs_and_exec.lo src/libexecline/el_parse.lo src/libexecline/el_parse_from_buffer.lo src/libexecline/el_parse_from_string.lo src/libexecline/el_popenv.lo src/libexecline/el_pushenv.lo src/libexecline/el_semicolon.lo src/libexecline/el_spawn0.lo src/libexecline/el_gspawn0.lo src/libexecline/el_substandrun.lo src/libexecline/el_substandrun_str.lo src/libexecline/el_substitute.lo src/libexecline/el_transform.lo src/libexecline/el_trueargv.lo src/libexecline/el_vardupl.lo src/libexecline/exlsn_define.lo src/libexecline/exlsn_elglob.lo src/libexecline/exlsn_importas.lo src/libexecline/exlsn_multidefine.lo src/libexecline/exlsn_exlp.lo src/libexecline/exlsn_main.lo src/libexecline/exlsn_free.lo src/libexecline/exlp.lo -lskarnet endif -libexecline.so.xyzzy: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} -libexecline.so.xyzzy: src/libexecline/el_execsequence.lo src/libexecline/el_forx_pidinfo.lo src/libexecline/el_getstrict.lo src/libexecline/el_modif_and_exec.lo src/libexecline/el_modif_and_spawn.lo src/libexecline/el_modifs_and_exec.lo src/libexecline/el_parse.lo src/libexecline/el_parse_from_buffer.lo src/libexecline/el_parse_from_string.lo src/libexecline/el_popenv.lo src/libexecline/el_pushenv.lo src/libexecline/el_semicolon.lo src/libexecline/el_spawn0.lo src/libexecline/el_gspawn0.lo src/libexecline/el_substandrun.lo src/libexecline/el_substandrun_str.lo src/libexecline/el_substitute.lo src/libexecline/el_transform.lo src/libexecline/el_trueargv.lo src/libexecline/el_vardupl.lo src/libexecline/exlsn_define.lo src/libexecline/exlsn_elglob.lo src/libexecline/exlsn_importas.lo src/libexecline/exlsn_multidefine.lo src/libexecline/exlsn_exlp.lo src/libexecline/exlsn_main.lo src/libexecline/exlsn_free.lo src/libexecline/exlp.lo -execline: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} ${MAYBEPTHREAD_LIB} -execline: src/multicall/execline.o ${LIBEXECLINE} ${LIBNSSS} +libexecline.pc: EXTRA_LIBS := -lskarnet ${SPAWN_LIB} +libexecline.so.xyzzy: EXTRA_LIBS := ${SPAWN_LIB} +libexecline.so.xyzzy: src/libexecline/el_execsequence.lo src/libexecline/el_forx_pidinfo.lo src/libexecline/el_getstrict.lo src/libexecline/el_modif_and_exec.lo src/libexecline/el_modif_and_spawn.lo src/libexecline/el_modifs_and_exec.lo src/libexecline/el_parse.lo src/libexecline/el_parse_from_buffer.lo src/libexecline/el_parse_from_string.lo src/libexecline/el_popenv.lo src/libexecline/el_pushenv.lo src/libexecline/el_semicolon.lo src/libexecline/el_spawn0.lo src/libexecline/el_gspawn0.lo src/libexecline/el_substandrun.lo src/libexecline/el_substandrun_str.lo src/libexecline/el_substitute.lo src/libexecline/el_transform.lo src/libexecline/el_trueargv.lo src/libexecline/el_vardupl.lo src/libexecline/exlsn_define.lo src/libexecline/exlsn_elglob.lo src/libexecline/exlsn_importas.lo src/libexecline/exlsn_multidefine.lo src/libexecline/exlsn_exlp.lo src/libexecline/exlsn_main.lo src/libexecline/exlsn_free.lo src/libexecline/exlp.lo -lskarnet +execline: EXTRA_LIBS := ${SPAWN_LIB} ${MAYBEPTHREAD_LIB} +execline: src/multicall/execline.o ${LIBEXECLINE} ${LIBNSSS} -lskarnet INTERNAL_LIBS := diff --git a/package/targets.mak b/package/targets.mak index a7a1fd9..0f8716a 100644 --- a/package/targets.mak +++ b/package/targets.mak @@ -1,6 +1,7 @@ LIBEXEC_TARGETS := LIB_DEFS := EXECLINE=execline +EXECLINE_REQUIRES := libskarnet ifeq ($(MULTICALL),1) @@ -32,10 +33,4 @@ SYMLINK_TARGET_cd := execline-cd SYMLINK_TARGET_umask := execline-umask endif -$(DESTDIR)$(bindir)/define: ./define 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 $@ ; } - endif diff --git a/tools/gen-deps.sh b/tools/gen-deps.sh index befe021..8e944d4 100755 --- a/tools/gen-deps.sh +++ b/tools/gen-deps.sh @@ -59,22 +59,26 @@ echo for dir in $(ls -1 src | grep -v ^include) ; do for file in $(ls -1 src/$dir/deps-lib) ; do deps= + both= libs= while read dep ; do - if echo $dep | grep -q -e ^-l -e '^\${.*_LIB}' ; then + if echo $dep | grep -q '^\${.*_LIB}' ; then libs="$libs $dep" + elif echo $dep | grep -q '^-l' ; then + both="$both $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}${both}" 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')${both}" echo endif if grep -E "^LIB_DEFS [+:]=" package/targets.mak | grep -qF "$file" ; then + echo "lib${file}.pc: EXTRA_LIBS :=${both}${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}${both}" | sed 's/\.o/.lo/g')" else internal_libs="$internal_libs lib${file}.a.xyzzy" fi @@ -84,10 +88,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 -q '^\${.*_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..b33f348 --- /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" +} + +splitlibs () { + req= + while test "$1" != -lskarnet ; do + if test -z "$1" ; then + echo "gen-dotpc.sh: fatal: can't happen: was called on a library that doesn't depend on libskarnet" 1>&2 + exit 102 + fi + + done +} + +. package/info + +ilist= +dlist= +slist= + +if test "${includedir}" != /usr/include ; then + ilist="-I${includedir}" +fi +if test -n "${buildtime_includedirs}" ; then + ilist="${ilist}${ilist:+ }${buildtime_includedirs}" +fi +ilist=`uniqit ${ilist}` + +if test "${dynlibdir}" != /usr/lib && test "${dynlibdir}" != /lib ; then + dlist="-L${dynlibdir}" +fi +if test -n "${buildtime_dynlibdirs}" ; then + dlist="${dlist}${dlist:+ }${buildtime_dynlibdirs}" +fi +dlist=`uniqit ${dlist}` + +if test "${libdir}" != /usr/lib && test "${libdir}" != /lib ; then + slist="-L${libdir}" +fi +if test -n "${buildtime_libdirs}" ; then + slist="${slist}${slist:+ }${buildtime_libdirs}" +fi +slist="$(filterout "${dlist}" $(uniqit ${slist}))" + +echo "prefix=${prefix}" +echo "includedir=${includedir}" +echo "libdir=${libdir}" +echo "dynlibdir=${dynlibdir}" +echo +echo "Name: ${library}" +echo "Version: ${version}" +echo "Description: ${description:-The ${library} library.}" +echo "URL: ${url:-https://skarnet.org/software/${package}/}" +if test -n "${requires}" ; then + echo "Requires: ${requires}" +fi +if test -n "${requires_private}" ; then + echo "Requires.private: ${requires_private}" +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 |
