commit: d3ac3dcdcf6aff622f0b654bda1dd9e0a4aff34a
parent 7e03fa125fbc6b64d60f8349f092f1c946b5936f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 12 Jan 2024 20:11:04 +0100
Add LDSTATIC
Took this variable name from mksh, allows to avoid requiring a static
library for atf-c.
Diffstat:
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
@@ -7,7 +7,7 @@ all: $(EXE) $(MAN1SO)
.c:
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ $< $(LDFLAGS)
+ $(CC) -std=c99 $(CFLAGS) -o $@ $< $(LDFLAGS) $(LDSTATIC)
.c.o:
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
@@ -46,21 +46,21 @@ format: $(C_SOURCES)
cmd/date: cmd/date.c lib/iso_parse.c Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/date.c lib/iso_parse.c $(LDFLAGS)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/date.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
build/cmd/date.1: cmd/date.1.in lib/iso_parse.mdoc Makefile
$(M4) cmd/date.1.in > $@
cmd/touch: cmd/touch.c lib/iso_parse.c Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/touch.c lib/iso_parse.c $(LDFLAGS)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/touch.c lib/iso_parse.c $(LDFLAGS) $(LDSTATIC)
build/cmd/touch.1: cmd/touch.1.in lib/iso_parse.mdoc Makefile
$(M4) cmd/touch.1.in > $@
cmd/sleep: cmd/sleep.c lib/strtodur.c Makefile
rm -f ${<:=.gcov} ${@:=.gcda} ${@:=.gcno}
- $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sleep.c lib/strtodur.c $(LDFLAGS)
+ $(CC) -std=c99 $(CFLAGS) -o $@ cmd/sleep.c lib/strtodur.c $(LDFLAGS) $(LDSTATIC)
test-lib/strtodur: test-lib/strtodur.c lib/strtodur.c Makefile
$(CC) -std=c99 $(CFLAGS) $(ATF_CFLAGS) -o $@ test-lib/strtodur.c lib/strtodur.c $(LDFLAGS) $(ATF_LIBS)
diff --git a/README.md b/README.md
@@ -32,3 +32,4 @@ Tested on Linux(musl), FreeBSD, NetBSD, OpenBSD: <https://builds.sr.ht/~lanodan/
## Packaging
- The `./configure` script isn't auto*hell based, you can pass it arguments via key-value arguments or environment variables
- You can define the `NO_BWRAP` environment variable to skip the bwrap-based tests which can cause issues in some environments like Gentoo `sandbox`
+- If you want statically linked executables, define `LDSTATIC=-static` in the environment
diff --git a/configure b/configure
@@ -29,6 +29,7 @@ Variables:
CFLAGS=OPTIONS
LDFLAGS=OPTIONS
+ LDSTATIC=OPTIONS
EXTRA_CFLAGS=OPTIONS
Variables are set in the following order: Default, Environment, Arguments
@@ -242,6 +243,7 @@ REUSE = ${REUSE}
CFLAGS = ${CFLAGS}
LDFLAGS = ${LDFLAGS}
+LDSTATIC = ${LDSTATIC}
ATF_CFLAGS = ${ATF_CFLAGS}
ATF_LIBS = ${ATF_LIBS}