gpio_ftdi/Makefile

43 lines
822 B
Makefile
Raw Normal View History

2019-06-29 11:29:51 +02:00
CROSS_COMPILE ?=
2019-07-09 12:27:35 +02:00
TARGET_FILE ?= test
2019-06-29 11:29:51 +02:00
CC = $(CROSS_COMPILE)gcc
SRC_DIR = src
OBJ_DIR = obj
BIN_DIR = bin
2019-07-09 12:27:35 +02:00
C_FLAGS := -O0 -g -Iinc
2019-06-29 11:29:51 +02:00
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
C_OBJS = $(patsubst %.c,$(OBJ_DIR)/%.o,$(notdir $(C_SRCS)))
OBJS = $(C_OBJS)
TARGET = $(BIN_DIR)/$(TARGET_FILE)
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJS)
@mkdir -p $(BIN_DIR)
$(CC) $(LD_FLAGS) $(OBJS) $(LIBS) -o $@
2019-07-09 12:27:35 +02:00
.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
2019-06-29 11:29:51 +02:00
@mkdir -p $(OBJ_DIR)
$(CC) -c $(C_FLAGS) $< -o $@
.PHONY: clean
clean:
2019-07-09 12:27:35 +02:00
rm -rf $(OBJS) $(patsubst %.o,%.d,$(OBJS)) $(TARGET)
2019-06-29 11:29:51 +02:00
ifneq ($(MAKECMDGOALS),clean)
2019-07-09 12:27:35 +02:00
-include $(patsubst %.o,%.d,$(OBJS))
endif