From 6aa295a9fd9f9576ae3288275bf9c83ad8088492 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Tue, 9 Jul 2019 12:27:35 +0200 Subject: [PATCH] Bugfix: dependency files --- Makefile | 22 ++++++++++++---------- inc/test.h | 6 ++++++ src/main.c | 5 ++--- 3 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 inc/test.h diff --git a/Makefile b/Makefile index 68e2356..766f77c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CROSS_COMPILE ?= -TARGET_FILE ?= dnssd +TARGET_FILE ?= test CC = $(CROSS_COMPILE)gcc @@ -8,6 +8,8 @@ SRC_DIR = src OBJ_DIR = obj BIN_DIR = bin +C_FLAGS := -O0 -g -Iinc + C_SRCS = $(wildcard $(SRC_DIR)/*.c) C_OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(C_SRCS))) @@ -22,19 +24,19 @@ $(TARGET): $(OBJS) @mkdir -p $(BIN_DIR) $(CC) $(LD_FLAGS) $(OBJS) $(LIBS) -o $@ -$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c +.PRECIOUS: $(OBJ_DIR)/%.d +$(OBJ_DIR)/%.d: + @mkdir -p $(OBJ_DIR) + $(CC) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(C_FLAGS) $(filter %$(patsubst %.d,%.c,$(notdir $@)),$(C_SRCS)) + +$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)/%.d @mkdir -p $(OBJ_DIR) - $(call makedep,$<,$@,$(patsubst %c,%d,$(OBJ_DIR)/$(notdir $<))) $(CC) -c $(C_FLAGS) $< -o $@ .PHONY: clean clean: - rm -rf $(OBJ_DIR) $(BIN_DIR) - -define makedep - $(CC) -MM -MF $3 -MP -MT $2 $4 $1 -endef + rm -rf $(OBJS) $(patsubst %.o,%.d,$(OBJS)) $(TARGET) ifneq ($(MAKECMDGOALS),clean) --include $($(subst .o,.d,$(OBJS))) -endif \ No newline at end of file +-include $(patsubst %.o,%.d,$(OBJS)) +endif diff --git a/inc/test.h b/inc/test.h new file mode 100644 index 0000000..189a00b --- /dev/null +++ b/inc/test.h @@ -0,0 +1,6 @@ +#ifndef __INC_TEST_H__ +#define __INC_TEST_H__ + + + +#endif // __INC_TEST_H__ \ No newline at end of file diff --git a/src/main.c b/src/main.c index 820f765..31e233f 100644 --- a/src/main.c +++ b/src/main.c @@ -1,10 +1,9 @@ #include +#include + int main(int argc, char *argv[]) { - printf("Content-type: text/plain\n"); - printf('\n'); - printf("Hello World\n"); return 0;