From 488b57792601459380b3aabc2786f27cdee6af18 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 1 Dec 2022 21:25:26 +0100 Subject: Automate Makefile and test execution LimoX aswell as the tests should be build automatically without altering the Makefile. --- Makefile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'Makefile') 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 -- cgit v1.2.3-70-g09d2