commit: 90518ee01fe2f0d41a0661b8f4de5cd903de60a1
parent: 6b5f7edc9b3d420837a3035fb24760de54451c4d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 4 Feb 2020 07:29:32 +0100
Makefile: use $PKGCONFIG, use += and ?= BSD extensions
Allows to use cross-compilation for ${triple}-pkg-config on systems
like Exherbo without special handling.
The BSD extensions += and ?= for variable extension is used to avoid having
to explicitely pass a list of variables to make, thus making build recipies
simpler.
Only issue is when CC is unset, you will get CC=c99, which doesn't works as c11
is used. Consider doing something like the following in your build recipes:
make CC=${CC:-cc}
Reported-by: danyspin97
Diffstat:
2 files changed, 25 insertions(+), 17 deletions(-)
diff --git a/Makefile b/Makefile
@@ -1,15 +1,26 @@
.POSIX:
+# POSIX Makefile with extensions common to *BSD and GNU such as:
+# - Usage of backticks for shell evaluation
+# - Usage of ?= for defining variables when not already defined
+# - Usage of += for appending to a variable
+PACKAGE = Badwolf
VERSION = 0.4.0
-VERSION_FULL = $(VERSION)$(shell ./version.sh)
+VERSION_FULL = $(VERSION)`./version.sh`
-PREFIX = /usr/local
-BINDIR = $(PREFIX)/bin
-MANDIR = $(PREFIX)/share/man
-DOCDIR = $(PREFIX)/share/doc/badwolf-$(VERSION)
-DATADIR = $(PREFIX)/share/badwolf
-APPSDIR = $(PREFIX)/share/applications
-PACKAGE = Badwolf
+PREFIX ?= /usr/local
+BINDIR ?= $(PREFIX)/bin
+MANDIR ?= $(PREFIX)/share/man
+DOCDIR ?= $(PREFIX)/share/doc/badwolf-$(VERSION)
+DATADIR ?= $(PREFIX)/share/badwolf
+APPSDIR ?= $(PREFIX)/share/applications
+
+CC ?= cc
+DBG ?=
+PKGCONFIG ?= pkg-config
+MSGFMT ?= msgfmt
+
+CFLAGS ?= -g -Wall -Wextra -Wconversion -Wsign-conversion -O2
DEPS = gtk+-3.0 webkit2gtk-4.0 libsoup-2.4
SRCS = uri.c uri_test.c keybindings.c badwolf.c
@@ -20,12 +31,9 @@ EXE_test = uri_test
TRANS = fr.mo pt_BR.mo
DOCS = usr.bin.badwolf README.md KnowledgeBase.md
-CC = cc
-DBG =
-CFLAGS = -g -Wall -Wextra -Wconversion -Wsign-conversion -O2
-CDEPS = `pkg-config --cflags $(DEPS)` -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\"
-LIBS = `pkg-config --libs $(DEPS)`
-MSGFMT = msgfmt
+CFLAGS += -DDATADIR=\"$(DATADIR)\" -DPACKAGE=\"$(PACKAGE)\" -D_POSIX_C_SOURCE=200809L -DVERSION=\"$(VERSION_FULL)\"
+CFLAGS += `$(PKGCONFIG) --cflags $(DEPS)`
+LIBS = `$(PKGCONFIG) --libs $(DEPS)`
all: $(EXE) $(TRANS)
@@ -43,10 +51,10 @@ badwolf: $(OBJS)
$(CC) -std=c11 -o $@ $(OBJS) $(LDFLAGS) $(LIBS)
.c:
- $(CC) -std=c11 $(CFLAGS) $(CDEPS) $(LDFLAGS) $(LIBS) -o $@ $<
+ $(CC) -std=c11 $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $<
.c.o:
- $(CC) -std=c11 $(CFLAGS) $(CDEPS) -c -o $@ $<
+ $(CC) -std=c11 $(CFLAGS) -c -o $@ $<
uri_test: uri.o uri_test.o
$(CC) -std=c11 -o $@ uri.o uri_test.o $(LDFLAGS) $(LIBS)
diff --git a/README.md b/README.md
@@ -54,7 +54,7 @@ Dependencies are:
- A pkg-config implementation (pkgconf is recommended)
- (optionnal) gettext implementation (such as GNU Gettext)
-Compilation is done with `make`, install with `make install`. An example AppArmor profile is provided at `usr.bin.badwolf`, please do runtime checks before deploying.
+Compilation is done with `make CC=${CC:-cc}`, install with `make install`. An example AppArmor profile is provided at `usr.bin.badwolf`, please do runtime checks before deploying.
## Notes
Most of the privacy/security stuff will be done with patches against WebKit as quite a lot isn’t into [WebKitSettings](https://webkitgtk.org/reference/webkit2gtk/stable/WebKitSettings.html) and with generic WebKit extensions that should be resuseable.