summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-02-05 04:37:51 +0000
committerLaurent Bercot <ska@appnovation.com>2023-02-05 04:37:51 +0000
commit4676457df2c8a73b4f589a66315b9b137ee89202 (patch)
treec9bc5310ed2930a9aa5c0b73b19cd174b8a7d43d
parent26152eb4dfe9b6ebb2360f855663d0e30177eba1 (diff)
downloadexecline-4676457df2c8a73b4f589a66315b9b137ee89202.tar.xz
Simplify build system, add --enable-multicall
Signed-off-by: Laurent Bercot <ska@appnovation.com>
-rw-r--r--Makefile27
-rwxr-xr-xconfigure9
-rw-r--r--package/targets.mak98
-rwxr-xr-xtools/install.sh11
4 files changed, 54 insertions, 91 deletions
diff --git a/Makefile b/Makefile
index 483403f..82f380f 100644
--- a/Makefile
+++ b/Makefile
@@ -17,9 +17,8 @@ CC = $(error Please use ./configure first)
STATIC_LIBS :=
SHARED_LIBS :=
INTERNAL_LIBS :=
-EXTRA_TARGETS :=
LIB_DEFS :=
-EXTRA_BINS :=
+BIN_SYMLINKS :=
EXTRA_TEMP :=
define library_definition
@@ -55,14 +54,14 @@ RANLIB := $(CROSS_COMPILE)ranlib
STRIP := $(CROSS_COMPILE)strip
INSTALL := ./tools/install.sh
-ALL_BINS := $(LIBEXEC_TARGETS) $(BIN_TARGETS)
+ALL_BINS := $(BIN_TARGETS) $(LIBEXEC_TARGETS)
ALL_LIBS := $(SHARED_LIBS) $(STATIC_LIBS) $(INTERNAL_LIBS)
ALL_INCLUDES := $(wildcard src/include/$(package)/*.h)
all: $(ALL_LIBS) $(ALL_BINS) $(ALL_INCLUDES)
clean:
- @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(EXTRA_BINS) $(EXTRA_TEMP) $(wildcard src/*/*.o src/*/*.lo)
+ @exec rm -f $(ALL_LIBS) $(ALL_BINS) $(EXTRA_TEMP) $(wildcard src/*/*.o src/*/*.lo)
distclean: clean
@exec rm -f config.mak src/include/$(package)/config.h
@@ -86,7 +85,7 @@ endif
install: install-dynlib install-libexec install-bin install-lib install-include
install-dynlib: $(SHARED_LIBS:lib%.so.xyzzy=$(DESTDIR)$(dynlibdir)/lib%.so)
install-libexec: $(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%)
-install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) $(EXTRA_TARGETS:%=$(DESTDIR)$(bindir)/%)
+install-bin: $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%) $(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)
install-data: $(ALL_DATA:src/etc/%=$(DESTDIR)$(datadir)/%)
@@ -98,7 +97,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/%) $(EXTRA_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) $@
@@ -118,11 +117,15 @@ $(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 $@ ; }
+$(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%): $(DESTDIR)$(libexecdir)/%: % package/modes
+$(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%): $(DESTDIR)$(bindir)/%: % package/modes
+$(LIBEXEC_TARGETS:%=$(DESTDIR)$(libexecdir)/%) $(BIN_TARGETS:%=$(DESTDIR)$(bindir)/%):
+ grep -- ^$(@F) < package/modes | { read name mode og && \
+ if [ x$$og != x ] ; then og="-O $${og}" ; fi && \
+ $(INSTALL) -D -m $$mode $$og $< $@ ; }
+
+$(BIN_SYMLINKS:%=$(DESTDIR)$(bindir)/%): $(BIN_SYMLINKS:%=$(DESTDIR)$(bindir)/$(SYMLINK_TARGET_%))
+ exec $(INSTALL) -l $(SYMLINK_TARGET_$(@F)) $@
$(DESTDIR)$(libdir)/lib%.a: lib%.a.xyzzy
exec $(INSTALL) -D -m 644 $< $@
@@ -136,7 +139,7 @@ $(DESTDIR)$(includedir)/$(package)/%.h: src/include/$(package)/%.h
%.lo: %.c
exec $(CC) $(CPPFLAGS_ALL) $(CFLAGS_ALL) $(CFLAGS_SHARED) -c -o $@ $<
-$(ALL_BINS) $(EXTRA_BINS):
+$(ALL_BINS):
exec $(CC) -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL) $(LDFLAGS_NOSHARED) $^ $(EXTRA_LIBS) $(LDLIBS)
lib%.a.xyzzy:
diff --git a/configure b/configure
index e977c7d..2cfe80e 100755
--- a/configure
+++ b/configure
@@ -48,6 +48,7 @@ Optional features:
hardcode absolute BINDIR/foobar paths instead [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 (EXPERIMENTAL) [disabled]
EOF
exit 0
@@ -154,6 +155,7 @@ slashpackage=false
abspath=false
usensss=false
pposix=false
+multicall=false
sproot=
home=
exthome=
@@ -200,6 +202,8 @@ for arg ; do
--disable-nsss|--enable-nsss=no) usensss=false ;;
--enable-pedantic-posix|--enable-pedantic-posix=yes) pposix=true ;;
--disable-pedantic-posix|--enable-pedantic-posix=no) pposix=false ;;
+ --enable-multicall|--enable-multicall=yes) multicall=true ;;
+ --disable-multicall|--enable-multicall=no) multicall=false ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
--enable-*|--disable-*|--with-*|--without-*|--*dir=*) ;;
--host=*|--target=*) target=${arg#*=} ;;
@@ -465,6 +469,11 @@ if $pposix ; then
else
echo "PEDANTIC_POSIX :="
fi
+if $multicall ; then
+ echo "MULTICALL := 1"
+else
+ echo "MULTICALL :="
+fi
exec 1>&3 3>&-
echo " ... done."
diff --git a/package/targets.mak b/package/targets.mak
index 37e8fa7..c8fe852 100644
--- a/package/targets.mak
+++ b/package/targets.mak
@@ -1,88 +1,34 @@
-BIN_TARGETS := \
-background \
-backtick \
-case \
-define \
-dollarat \
-elgetopt \
-elgetpositionals \
-elglob \
-eltest \
-emptyenv \
-envfile \
-exec \
-execlineb \
-execline-cd \
-execline-umask \
-exit \
-export \
-fdblock \
-fdclose \
-fdmove \
-fdswap \
-fdreserve \
-forbacktickx \
-foreground \
-forstdin \
-forx \
-getcwd \
-getpid \
-heredoc \
-homeof \
-if \
-ifelse \
-ifte \
-ifthenelse \
-importas \
-loopwhilex \
-multidefine \
-multisubstitute \
-pipeline \
-piperw \
-posix-cd \
-posix-umask \
-redirfd \
-runblock \
-shift \
-trap \
-tryexec \
-unexport \
-wait \
-withstdinas
-
LIBEXEC_TARGETS :=
LIB_DEFS := EXECLINE=execline
-ifeq ($(PEDANTIC_POSIX),1)
-PEDANTIC_PREFIX := posix
-else
-PEDANTIC_PREFIX := execline
-endif
-
-EXTRA_TARGETS := cd umask
-
-$(DESTDIR)$(bindir)/cd: $(DESTDIR)$(bindir)/$(PEDANTIC_PREFIX)-cd
- exec ./tools/install.sh -l $(PEDANTIC_PREFIX)-cd $(DESTDIR)$(bindir)/cd
-
-$(DESTDIR)$(bindir)/umask: $(DESTDIR)$(bindir)/$(PEDANTIC_PREFIX)-umask
- exec ./tools/install.sh -l $(PEDANTIC_PREFIX)-umask $(DESTDIR)$(bindir)/umask
-
+ifeq ($(MULTICALL),1)
-EXTRA_BINS := execline
+BIN_TARGETS := execline
+BIN_SYMLINKS := cd umask $(notdir $(wildcard src/execline/deps-exe/*))
EXTRA_TEMP := src/multicall/execline.c
-multicall multicall-all: execline
+define symlink_definition
+SYMLINK_TARGET_$(1) := execline
+endef
+$(foreach name,$(BIN_SYMLINKS),$(eval $(call symlink_definition,$(name))))
-multicall-strip: execline
- exec $(STRIP) -R .note -R .comment execline
+src/multicall/execline.c: tools/gen-multicall.sh src/execline/deps-exe
+ ./tools/gen-multicall.sh > src/multicall/execline.c
-multicall-install: $(DESTDIR)$(bindir)/execline
- for i in $(BIN_TARGETS) $(EXTRA_TARGETS) ; do ./tools/install.sh -l execline $(DESTDIR)$(bindir)/$$i ; done
+src/multicall/execline.o: src/multicall/execline.c src/include/execline/config.h src/include/execline/execline.h
-multicall-global-links: $(DESTDIR)$(sproot)/command/execline
+else
-.PHONY: multicall multicall-all multicall-strip multicall-install multicall-global-links
+BIN_TARGETS := $(notdir $(wildcard src/execline/deps-exe/*))
+BIN_SYMLINKS := cd umask
-src/multicall/execline.c: tools/gen-multicall.sh src/execline/deps-exe src/include/execline/config.h src/include/execline/execline.h
- ./tools/gen-multicall.sh > src/multicall/execline.c
+ifeq ($(PEDANTIC_POSIX),1)
+SYMLINK_TARGET_cd := posix-cd
+SYMLINK_TARGET_umask := posix-umask
+else
+SYMLINK_TARGET_cd := execline-cd
+SYMLINK_TARGET_umask := execline-umask
+endif
+
+endif
diff --git a/tools/install.sh b/tools/install.sh
index 89f9428..e96dd7b 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -1,19 +1,21 @@
#!/bin/sh
usage() {
- echo "usage: $0 [-D] [-l] [-m mode] src dst" 1>&2
+ echo "usage: $0 [ -D ] [ -l ] [ -m mode ] [ -O owner:group ] src dst" 1>&2
exit 1
}
mkdirp=false
symlink=false
mode=0755
+og=
-while getopts Dlm: name ; do
+while getopts Dlm:O: name ; do
case "$name" in
D) mkdirp=true ;;
l) symlink=true ;;
m) mode=$OPTARG ;;
+ O) og=$OPTARG ;;
?) usage ;;
esac
done
@@ -46,7 +48,10 @@ if $symlink ; then
ln -s "$src" "$tmp"
else
cat < "$1" > "$tmp"
- chmod "$mode" "$tmp"
+ if test -n "$og" ; then
+ chown -- "$og" "$tmp"
+ fi
+ chmod -- "$mode" "$tmp"
fi
mv -f "$tmp" "$dst"