commit b75c1afdd390b95d383ec0441419f34e530d260e
parent f4f5874b51817bdae4ac9d1d23aeec6f48be8fea
Author: aabacchus <ben@bvnf.space>
Date: Mon, 27 Sep 2021 05:53:03 +0100
more portable Makefile, configure script
Diffstat:
3 files changed, 33 insertions(+), 10 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,3 +1,4 @@
*.o
cgol
-out.png
+config.mk
+images/
diff --git a/Makefile b/Makefile
@@ -1,23 +1,30 @@
.POSIX:
+-include config.mk
+
DEBUG = -g
-XCFLAGS = $(CFLAGS) -Wall -Wextra -Wpedantic $(DEBUG)
-CAIROCFLAGS = $$(pkgconf --cflags cairo)
-CAIROLFLAGS = -lcairo
+XCFLAGS := $(CFLAGS) -Wall -Wextra -Wpedantic $(DEBUG) $(XXCFLAGS)
+XLDFLAGS = $(LDFLAGS) $(XXLDFLAGS)
OBJS = \
image.o \
main.o \
+ rules.o \
-all: cgol
-
-%.o: %.c cgol.h
- $(CC) -c $(XCFLAGS) $(CAIROCFLAGS) $<
+all: cgol images
cgol: $(OBJS)
- $(CC) $(LDFLAGS) $(CAIROLFLAGS) $(OBJS) -o cgol
+ $(CC) $(XLDFLAGS) $(OBJS) -o cgol
+
+$(OBJS): $(OBJS:.o=.c) cgol.h
+
+.c.o:
+ $(CC) -c $(XCFLAGS) $<
+
+images:
+ mkdir -p images
clean:
- rm -f $(OBJS) cgol
+ rm -fr $(OBJS) cgol images/ config.mk
.PHONY: clean
diff --git a/configure b/configure
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+cflags() {
+ printf "XXCFLAGS = %s\n" "$(pkgconf --cflags "$@")"
+}
+
+libs() {
+ printf "XXLDFLAGS = %s\n" "$(pkgconf --libs "$@")"
+}
+
+exec > config.mk
+cflags cairo
+libs cairo