summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-09 15:37:41 -0400
committerAlex Xu (Hello71) <alex_y_xu@yahoo.ca>2016-07-09 15:37:41 -0400
commit8b613bf677ae5f0940b112477ff3e5979ec58f36 (patch)
treed8832b2a5845118369cb57f42af5e5dd8945e668
parent3d7bf5253af49db6436261fadaea7b5fc85be03a (diff)
downloadudpastcp-8b613bf677ae5f0940b112477ff3e5979ec58f36.tar.xz
udpastcp-8b613bf677ae5f0940b112477ff3e5979ec58f36.zip
Add dependency generation to makefile.
-rw-r--r--.gitignore1
-rw-r--r--Makefile17
2 files changed, 12 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index edfb0a4..f8c4fe2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
/src/*.o
+/src/*.d
/udpastcp
diff --git a/Makefile b/Makefile
index bde9466..d4664b1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,15 +1,20 @@
CFLAGS += -Wall -Wextra -Wwrite-strings -Wno-missing-field-initializers -std=c99 -D_BSD_SOURCE -D_DEFAULT_SOURCE
-
+CPPFLAGS += -MMD -MP
LDLIBS := -lev
-NET_OBJS := src/checksum.o src/client.o src/server.o
-OBJS := src/udpastcp.o $(NET_OBJS)
+TARGET := udpastcp
+NET_SRC := src/checksum.c src/client.c src/server.c
+SRC := src/udpastcp.c $(NET_SRC)
+OBJ := $(SRC:%.c=%.o)
+DEP := $(SRC:%.c=%.d)
-udpastcp: $(OBJS)
+$(TARGET): $(OBJ)
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
# networking code needs aliasing to work at all
-$(NET_OBJS): CFLAGS+=-fno-strict-aliasing -Wno-sign-compare
+$(NET_SRC:%.c=%.o): CFLAGS+=-fno-strict-aliasing -Wno-sign-compare
+
+-include $(DEP)
clean:
- $(RM) $(OBJS)
+ $(RM) $(TARGET) $(OBJ) $(DEP)