-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
78 lines (56 loc) · 2.24 KB
/
Makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
.SUFFIXES:
TOPDIR ?= $(CURDIR)
TARGET := $(notdir $(CURDIR))
INCLUDES := includes
SOURCES := sources
BUILD := build
LIBDIRS := $(CURDIR)/lib/yaml-cpp
LIBS := -lyaml-cpp
CXXFLAGS := $(INCLUDE) -std=gnu++11
LDFLAGS := -static -static-libgcc -static-libstdc++
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/$(BUILD)
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
# BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
export LD := $(CXX)
export OFILES := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I $(CURDIR)/$(dir) ) \
$(foreach dir,$(LIBDIRS),-I $(dir)/include) \
-I $(CURDIR)/$(BUILD) \
-I $(CTRPF_Includes)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L $(dir)/lib)
.PHONY: $(BUILD) clean all install
#---------------------------------------------------------------------------------
all: $(BUILD)
install:
@mv $(OUTPUT).exe C:\devkitPro\tools\bin\3gxtool.exe
$(BUILD):
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
#---------------------------------------------------------------------------------
clean:
@echo clean ...
@rm -fr $(BUILD) $(OUTPUT)
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).exe : $(OFILES)
#---------------------------------------------------------------------------------
%.o: %.cpp
@echo $(notdir $<)
@$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@
%.exe:
@echo linking $(notdir $@)
@$(LD) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@
-include $(DEPENDS)
#---------------------------------------------------------------------------------------
endif