You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
ugui/text_rendering/genmake.sh

46 lines
869 B

#!/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"
}
rm -f objlist
cat > Makefile << EOF
CC = gcc
# instrumentation flags
INFLAGS = -fsanitize=address,builtin,undefined
LDFLAGS = -lm -lgrapheme -lSDL2 -lGLEW -lGL \${INFLAGS}
CFLAGS = -ggdb3 -Wall -Wextra -pedantic -std=c11 \
-Wno-unused-function -fno-omit-frame-pointer \${INFLAGS}
.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 test '
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