30 lines
541 B
Makefile
30 lines
541 B
Makefile
TARGET_EXEC ?= msh
|
|
|
|
BUILD_DIR ?= ./build
|
|
SRC_DIRS ?= ./src
|
|
|
|
SRCS := $(shell find $(SRC_DIRS) -name *.c)
|
|
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
|
DEPS := $(OBJS:.o=.d)
|
|
|
|
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
|
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
|
|
|
CPPFLAGS ?= $(INC_FLAGS) -MMD -MP
|
|
|
|
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
|
$(CC) -ggdb3 $(OBJS) -o $@ $(LDFLAGS)
|
|
|
|
$(BUILD_DIR)/%.c.o: %.c
|
|
$(MKDIR_P) $(dir $@)
|
|
$(CC) -ggdb3 $(CPPFLAGS) $(CFLAGS) -c $< -o $@
|
|
|
|
.PHONY: clean
|
|
|
|
clean:
|
|
$(RM) -r $(BUILD_DIR)
|
|
|
|
-include $(DEPS)
|
|
|
|
MKDIR_P ?= mkdir -p
|