41 lines
721 B
Makefile
41 lines
721 B
Makefile
CROSS_COMPILE ?=
|
|
#arm-linux-gnueabihf-
|
|
|
|
TARGET_FILE ?= dnssd
|
|
|
|
CC = $(CROSS_COMPILE)gcc
|
|
|
|
SRC_DIR = src
|
|
OBJ_DIR = obj
|
|
BIN_DIR = bin
|
|
|
|
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 $@
|
|
|
|
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
|
|
@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
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
-include $($(subst .o,.d,$(OBJS)))
|
|
endif |