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 +++++++++++++++++++++-------- README.md | 1 + 2 files changed, 22 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 diff --git a/README.md b/README.md index b9c8524..eda55b6 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ to Network Programming][4]. Install these build dependencies: +- GNU coreutils - GNU make - gcc -- cgit v1.2.3-70-g09d2