aboutsummaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2026-04-05 12:15:36 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2026-04-05 12:15:36 +0200
commitf0a05bebbea8f123070d0da60d781c8ca07ecb4f (patch)
treeb51f8dfdd33b5c119e04c77f956b68f53601d037 /Makefile
parent48fea88bc51d26c01faeaad4e5413d62d0294fc9 (diff)
downloaddynstr-f0a05bebbea8f123070d0da60d781c8ca07ecb4f.tar.gz
Makefile: support user CFLAGS/LDFLAGS
Users should be able to append their own CFLAGS/LDFLAGS to those defined by the project by default. This is usually required by software distributions. [1] [1]: https://wiki.debian.org/HardeningWalkthrough#Handwritten_Makefiles
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile11
1 files changed, 8 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 3342638..6a34874 100644
--- a/Makefile
+++ b/Makefile
@@ -28,8 +28,10 @@ PROJECT_A = $(PROJECT).a
PROJECT_SO = $(PROJECT).so.$(VERSION)
PROJECT_SO_FQ = $(PROJECT).so.$(MAJOR_VERSION)
PROJECT_SO_NV = $(PROJECT).so
-CFLAGS = -Iinclude -fPIC -O1
-LDFLAGS = -shared
+DEFAULT_CFLAGS = -Iinclude -fPIC
+PROJ_CFLAGS = $(DEFAULT_CFLAGS) $(CFLAGS)
+DEFAULT_LDFLAGS = -shared
+PROJ_LDFLAGS = $(DEFAULT_LDFLAGS) $(LDFLAGS)
DEPS = \
dynstr.o
@@ -55,9 +57,12 @@ $(PROJECT_A): $(DEPS)
$(AR) $(ARFLAGS) $@ $(DEPS)
$(PROJECT_SO): $(DEPS)
- $(CC) $(LDFLAGS) $(DEPS) -o $@
+ $(CC) $(PROJ_LDFLAGS) $(DEPS) -o $@
$(pkgcfgdir)/dynstr.pc: dynstr.pc
mkdir -p $(DESTDIR)$(pkgcfgdir)
sed -e 's,/usr/local,$(DESTDIR)$(prefix),' $< > $@
chmod 0644 $@
+
+.c.o:
+ $(CC) $(PROJ_CFLAGS) -c $< -o $@