From 8b613bf677ae5f0940b112477ff3e5979ec58f36 Mon Sep 17 00:00:00 2001 From: "Alex Xu (Hello71)" Date: Sat, 9 Jul 2016 15:37:41 -0400 Subject: Add dependency generation to makefile. --- .gitignore | 1 + Makefile | 17 +++++++++++------ 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) -- cgit v1.2.3-54-g00ecf