summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2022-12-01 21:25:26 +0100
committerxengineering <me@xengineering.eu>2022-12-01 21:26:20 +0100
commit488b57792601459380b3aabc2786f27cdee6af18 (patch)
tree84ec027dafe6a9825e3f68db03900ece35a8c740 /Makefile
parente9f4d57376f862f38812895bc7112419e1601234 (diff)
downloadlimox-488b57792601459380b3aabc2786f27cdee6af18.tar
limox-488b57792601459380b3aabc2786f27cdee6af18.tar.zst
limox-488b57792601459380b3aabc2786f27cdee6af18.zip
Automate Makefile and test execution
LimoX aswell as the tests should be build automatically without altering the Makefile.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile29
1 files changed, 21 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index f692264..cfe05e7 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,29 @@
-.PHONY: all clean
+CC=gcc
+CFLAGS=-I. -lSDL2
+SRC:=$(shell find ./ -maxdepth 1 -type f -regex ".*\.c" -not -name "main.c")
+OBJ:=$(patsubst ./%.c,build/%.o,$(SRC))
+_TESTS:=$(shell find ./tests/ -maxdepth 1 -type f -regex ".*\.c")
+TESTS:=$(patsubst ./%.c,build/%,$(_TESTS))
-all: build/limox build/tests/get_domainpart
- ./build/tests/get_domainpart
+LIMOX=build/limox
-build/limox: build
- gcc main.c gui.c xmpp.c -o build/limox -lSDL2
-
-build/tests/get_domainpart: build
- gcc tests/get_domainpart.c xmpp.c -o build/tests/get_domainpart -I.
+all: build $(OBJ) $(TESTS) $(LIMOX)
+ @echo "Running testsuite ..."
+ find build/tests -type f -exec {} \;
build:
mkdir -p build/tests
+$(LIMOX): $(OBJ) build/main.o
+ $(CC) -o $@ $^ $(CFLAGS)
+
+build/%.o: %.c
+ $(CC) -c -o $@ $< $(CFLAGS)
+
+build/tests/%: tests/%.c
+ $(CC) -o $@ $< $(OBJ) $(CFLAGS)
+
+.PHONY: clean
+
clean:
rm -rf build