From 920aed36f81bcce40c9f1c5bcda906a13e4fb5e4 Mon Sep 17 00:00:00 2001 From: Tristan Riehs Date: Tue, 4 Aug 2026 20:40:44 +0200 Subject: Start rewriting the build system Good old makefiles should do the job. --- .gitignore | 5 +++++ Makefile | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/calculer.c | 4 +--- src/cli.c | 1 - src/disp.c | 1 - src/ray.c | 1 - 6 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d18d6f5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +calculer +src/calc_data.o +src/calculer.o +src/disp.o +src/input.o diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..776e988 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +PREFIX ?= /usr/local +PROG ?= calculer +CFLAGS ?= -O0 -g3 +LDFLAGS ?= +LIBS ?= + + +CALCULER_VERSION := 1.0 + +__CFLAGS := -std=c99 \ + -Wall \ + -DCALCULER_VERSION=\"$(CALCULER_VERSION)\" \ + $(shell pkg-config --cflags readline) +__LDFLAGS := +__LIBS := $(shell pkg-config --libs readline) + +all: $(PROG) + +$(PROG): src/calc_data.o src/calculer.o src/disp.o src/input.o + $(CC) -o $@ $^ $(__LDFLAGS) $(__LIBS) $(LDFLAGS) $(LIBS) + +src/calc_data.o: src/calc_data.c src/calc_data.h +src/calculer.o: src/calculer.c src/disp.h +src/disp.o: src/disp.c src/disp.h +.c.o: + $(CC) $(__CFLAGS) $(CFLAGS) -o $@ -c $< + +install: $(PROG) + mkdir -p $(PREFIX)/bin + install --mode=0755 $(PROG) $(PREFIX)/bin/ + +uninstall: + rm -rf $(PREFIX)/bin/$(PROG) + +clean: + rm -rf $(PROG) *.tar.gz src/*.o + +dist: + git archive \ + --output="calculer-$(CALCULER_VERSION).tar.gz" \ + --prefix="calculer-$(CALCULER_VERSION)/" \ + HEAD + +.PHONY: all clean dist install uninstall diff --git a/src/calculer.c b/src/calculer.c index 6bf8fbb..a3512d0 100644 --- a/src/calculer.c +++ b/src/calculer.c @@ -15,8 +15,6 @@ * along with this program. If not, see . */ -#include "config.h" - #include #include #include @@ -115,7 +113,7 @@ print_help(void) void print_version(void) { - printf("%s\n", VERSION); + printf("%s\n", CALCULER_VERSION); } void diff --git a/src/cli.c b/src/cli.c index afbb540..a24d771 100644 --- a/src/cli.c +++ b/src/cli.c @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "config.h" #include #include diff --git a/src/disp.c b/src/disp.c index 26bb2f2..02f9bdc 100644 --- a/src/disp.c +++ b/src/disp.c @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "config.h" #include #include diff --git a/src/ray.c b/src/ray.c index 9fb9023..7de5591 100644 --- a/src/ray.c +++ b/src/ray.c @@ -14,7 +14,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "config.h" #include #include -- cgit v1.2.3