Bugfix: dependency files
This commit is contained in:
parent
dc884d51a9
commit
6aa295a9fd
20
Makefile
20
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)))
|
||||
-include $(patsubst %.o,%.d,$(OBJS))
|
||||
endif
|
6
inc/test.h
Normal file
6
inc/test.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __INC_TEST_H__
|
||||
#define __INC_TEST_H__
|
||||
|
||||
|
||||
|
||||
#endif // __INC_TEST_H__
|
@ -1,10 +1,9 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include <test.h>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("Content-type: text/plain\n");
|
||||
printf('\n');
|
||||
|
||||
printf("Hello World\n");
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user