diff --git a/text_rendering/.gitignore b/text_rendering/.gitignore index e179b20..d747511 100644 --- a/text_rendering/.gitignore +++ b/text_rendering/.gitignore @@ -1,2 +1,3 @@ *.png -test \ No newline at end of file +test +obj/** \ No newline at end of file diff --git a/text_rendering/Makefile b/text_rendering/Makefile index 530574e..9de0726 100644 --- a/text_rendering/Makefile +++ b/text_rendering/Makefile @@ -1,7 +1,17 @@ +CC = gcc LDFLAGS = -lm -lgrapheme -lSDL2 -lGLEW -lGL -CFLAGS = -g -Wall -Wextra -pedantic -SOURCE = main.c font.c cache.c hash.c util.c ren.c -HEADER = font.h hash.h cache.h util.h ren.h +CFLAGS = -g -Wall -Wextra -pedantic -test: ${HEADER} ${SOURCE} - gcc ${CFLAGS} ${LDFLAGS} ${SOURCE} -o test +.PHONY: clean all +all: test + +cache.o: cache.c cache.h hash.h font.h util.h +font.o: font.c font.h stb_truetype.h stb_image_write.h util.h cache.h +hash.o: hash.c hash.h util.h +main.o: main.c ren.h util.h +ren.o: ren.c util.h font.h ren.h stack.h +util.o: util.c util.h +test: cache.o font.o hash.o main.o ren.o util.o + ${CC} ${LDFLAGS} -o test cache.o font.o hash.o main.o ren.o util.o +clean: + rm -f cache.o font.o hash.o main.o ren.o util.o diff --git a/text_rendering/genmake.sh b/text_rendering/genmake.sh new file mode 100755 index 0000000..ecb7b78 --- /dev/null +++ b/text_rendering/genmake.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +genobj() { + #echo "$1" | sed -e 's/^/obj\//' -e 's/\.c/\.o/' + echo "$1" | sed -e 's/\.c/\.o/' +} + +genrule() { + #gcc -MM "$1" | sed 's/^/obj\//' + gcc -MM "$1" +} + + +mkdir -p obj +rm -f objlist + +cat > Makefile << EOF +CC = gcc +LDFLAGS = -lm -lgrapheme -lSDL2 -lGLEW -lGL +CFLAGS = -g -Wall -Wextra -pedantic + +.PHONY: clean all +all: test + +EOF + +for f in *.c; do + genrule $f >> Makefile + genobj $f >> objlist +done + +mainrule='test: ' +linkcmd=' ${CC} ${LDFLAGS} -o test ' +cleanrule='clean: + rm -f ' +while IFS="" read -r line; do + mainrule="$mainrule $line" + linkcmd="$linkcmd $line" + cleanrule="$cleanrule $line" +done < objlist + +echo "$mainrule" >> Makefile +echo "$linkcmd" >> Makefile +echo "$cleanrule" >> Makefile \ No newline at end of file diff --git a/text_rendering/objlist b/text_rendering/objlist new file mode 100644 index 0000000..73a0480 --- /dev/null +++ b/text_rendering/objlist @@ -0,0 +1,6 @@ +cache.o +font.o +hash.o +main.o +ren.o +util.o diff --git a/text_rendering/test b/text_rendering/test index 3215d3f..21e96c9 100755 Binary files a/text_rendering/test and b/text_rendering/test differ