From f847e8058c9d820362ff52fe06ff196e33a54962 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sat, 25 Nov 2023 06:26:51 -0300 Subject: Makefile: Compose $(CFLAGS.a) with $(CFLAGS) instead of combine Instead of defining a toplevel $(CFLAGS.a) that includes everything from $(CFLAGS) plus whatever is statically defined in the Makefile, we now use both $(CFLAGS) and $(CFLAGS.a) together, and we define neither. Now one can keep a single usage of $(CFLAGS), and override $(CFLAGS.a) when desired. Where previously, in order to give a flag only to $(CFLAGS.a), one had to write: $ make CFLAGS.a="$CFLAGS --.a-only" Now can be done via: $ make CFLAGS.a="--.a-only" IOW, previously $(CFLAGS.so) was "everything you gave to $(CFLAGS), plus this extra -fPIC" what now is "override $(CFLAGS), $(CFLAGS.a) or $(CFLAGS.so) as you wish". The same is true for $(LDLIBS), $(LDLIBS.a) and $(LDLIBS.so). --- Makefile | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 246d357..570f57e 100644 --- a/Makefile +++ b/Makefile @@ -15,12 +15,8 @@ SRCDIR = $(PREFIX)/src/$(NAME) SHAREDIR = $(PREFIX)/share LOCALEDIR = $(SHAREDIR)/locale MANDIR = $(SHAREDIR)/man -CFLAGS.a = $(CFLAGS) -CFLAGS.so = $(CFLAGS) -fPIC -LDFLAGS.a = $(LDFLAGS) -LDFLAGS.so = $(LDFLAGS) -shared -LDLIBS.a = $(LDLIBS) -LDLIBS.so = $(LDLIBS) +CFLAGS.so = -fPIC +LDFLAGS.so = --shared EXT.so = .so EXEC = ./ ## Where to store the installation. Empty by default. @@ -43,16 +39,16 @@ LDLIBS = -lsqlite3 if [ -x $< ]; then chmod +x $@; fi .c.o: - $(CC) $(CFLAGS.a) -o $@ -c $< + $(CC) $(CFLAGS) $(CFLAGS.a) -o $@ -c $< .c.lo: - $(CC) $(CFLAGS.so) -o $@ -c $< + $(CC) $(CFLAGS) $(CFLAGS.so) -o $@ -c $< .c.to: - $(CC) $(CFLAGS.a) -DTEST -o $@ -c $< + $(CC) $(CFLAGS) $(CFLAGS.a) -DTEST -o $@ -c $< .ta.t: - $(CC) $(LDFLAGS.a) -o $@ $< $(LDLIBS.a) + $(CC) $(LDFLAGS) $(LDFLAGS.a) -o $@ $< $(LDLIBS) @@ -152,7 +148,8 @@ src/napi-sqlite.node: lib$(NAME)$(EXT.so) ln -f lib$(NAME)$(EXT.so) $@ lib$(NAME)$(EXT.so): $(sources.lo) src/napi-sqlite.lo - $(CC) $(LDFLAGS.so) -o $@ $(sources.lo) src/napi-sqlite.lo $(LDLIBS.so) + $(CC) $(LDFLAGS) $(LDFLAGS.so) -o $@ $(sources.lo) src/napi-sqlite.lo \ + $(LDLIBS) $(sources.ta): $(AR) $(ARFLAGS) $@ $? -- cgit v1.2.3