Created
December 25, 2021 23:14
-
-
Save skeeto/b07bbfbf8ec7d4075685e8e9f0a7a888 to your computer and use it in GitHub Desktop.
Makefile generator for Enchive (example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
cat <<EOF | |
CC = cc | |
CFLAGS = -Os -Wall -Wextra | |
LDFLAGS = -s | |
LDLIBS = | |
obj = $(find src/ -name '*.c' | LC_ALL=C sort | xargs printf 'build/%s.o ') | |
enchive: \$(obj) | |
\$(CC) \$(CFLAGS) \$(LDFLAGS) -o \$@ \$(obj) \$(LDLIBS) | |
build: | |
mkdir -p build/src | |
clean: | |
rm -rf enchive build/ | |
EOF | |
for file in $(find src/ -name '*.c' | LC_ALL=C sort); do | |
printf 'build/%s.o: build\n' $file | |
gcc -MM -MT build/$file.o $file | |
printf '\t$(CC) -c $(CFLAGS) -o $@ %s\n' $file | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment