aboutsummaryrefslogtreecommitdiffgithub
diff options
context:
space:
mode:
authorAustin Adams <git@austinjadams.com>2017-03-04 15:23:56 -0500
committerAustin Adams <git@austinjadams.com>2017-03-04 15:23:56 -0500
commitb4c73899ab4e25d1f98cd69b2dc2aed31a5a224c (patch)
tree074e1f4785969c5d350928e0cedb458cce025517
parentd77a4c786afe6c3c044c79924ef42dd5f5eacc11 (diff)
downloadgustave-b4c73899ab4e25d1f98cd69b2dc2aed31a5a224c.tar.gz
gustave-b4c73899ab4e25d1f98cd69b2dc2aed31a5a224c.tar.xz
Makefile: Improve to allow incremental builds
Replace the two-line Makefile with one that is much more maintainable and allows incremental builds. (This one does not hardcode the names of each source and header file, for example.)
-rw-r--r--Makefile20
1 files changed, 18 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 2797b8a..1747432 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,18 @@
-gustave: gustave.c cgitrc.c repo.c commits.c repo.h commits.h content.c content.h
- gcc -std=gnu99 -g gustave.c cgitrc.c repo.c commits.c content.c -lgit2 -o gustave
+CC=gcc
+CFLAGS=-std=gnu99 -pedantic -Wall -Werror
+LIBS=-lgit2
+BINARY=gustave
+DEPS=$(wildcard *.h)
+SOURCE=$(wildcard *.c)
+OBJ=$(patsubst %.c,%.o,$(SOURCE))
+
+.PHONY: clean
+
+$(BINARY): $(OBJ)
+ $(CC) -o $@ $(CFLAGS) $^ $(LIBS)
+
+%.o: %.c $(DEPS)
+ $(CC) -c $(CFLAGS) $<
+
+clean:
+ rm -f $(OBJ) $(BINARY)