-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMakefileModule
More file actions
55 lines (39 loc) · 1.62 KB
/
Copy pathMakefileModule
File metadata and controls
55 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
include ../../common.mk
BASE_FLAGS := -I. -I../../kernel -I../../shared -DXHCI_CTX_SIZE=$(XHCI_CTX_SIZE)
ifeq ($(TEST),true)
BASE_FLAGS += -DTEST
endif
ifeq ($(QEMU),true)
BASE_FLAGS += -DQEMU
endif
CFLAGS := $(CFLAGS_BASE) $(BASE_FLAGS)
CXXFLAGS := $(CXXFLAGS_BASE) $(BASE_FLAGS)
CLEAN_OBJS := $(shell find $(DRIVER_TARGET) -name "*.o") $(shell find ./common -name "*.o" 2>/dev/null)
CLEAN_DEPS := $(shell find $(DRIVER_TARGET) -name "*.d") $(shell find ./common -name "*.d" 2>/dev/null)
C_SRC := $(shell find $(DRIVER_TARGET) -name "*.c") $(shell find ./common -name "*.c" 2>/dev/null)
CPP_SRC := $(shell find $(DRIVER_TARGET) -name "*.cpp") $(shell find ./common -name "*.cpp" 2>/dev/null)
ASM_SRC := $(shell find $(DRIVER_TARGET) -name "*.S") $(shell find ./common -name "*.S" 2>/dev/null)
OBJ := $(C_SRC:%.c=$(BUILD_DIR)/%.o) $(ASM_SRC:%.S=$(BUILD_DIR)/%.o) $(CPP_SRC:%.cpp=$(BUILD_DIR)/%.o)
DEP := $(C_SRC:%.c=$(BUILD_DIR)/%.d) $(ASM_SRC:%.S=$(BUILD_DIR)/%.d) $(CPP_SRC:%.cpp=$(BUILD_DIR)/%.d)
TARGET := $(shell echo "../lib$(notdir $(CURDIR)).a")
.PHONY: all clean prepare
all: prepare $(TARGET)
prepare:
mkdir -p $(BUILD_DIR)
$(TARGET): $(OBJ)
@echo "Finishing build $(ARCH)"
@echo $(addprefix $(BUILD_DIR)/,$(notdir $(OBJ)))
$(VAR) rcs $@ $(OBJ)
$(BUILD_DIR)/%.o: %.S
@mkdir -p $(dir $@)
$(VAS) $(CFLAGS) $(SH_FLAGS) -c $< -o $@
$(BUILD_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(VCC) $(CFLAGS) $(SH_FLAGS) -c -MMD -MP $< -o $@
$(BUILD_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
$(VCXX) $(CXXFLAGS) $(SH_FLAGS) -c -MMD -MP $< -o $@
clean:
$(RM) $(CLEAN_OBJS) $(CLEAN_DEPS) $(TARGET)
$(RM) -r $(BUILD_DIR)
-include $(DEP)