-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
93 lines (66 loc) · 2.59 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro)
endif
include $(DEVKITARM)/gba_rules
BUILD := build
SOURCES := src
INCLUDES := include
ARCH := -mthumb -mthumb-interwork
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -O3 -Wall -Wno-switch -Wno-multichar -Wno-stringop-overflow $(ARCH) $(INCLUDE)
ASFLAGS := -g -Wa,--warn $(ARCH)
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
export TARGET := $(CURDIR)/lib/$(notdir $(CURDIR)).a
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
export OFILES := $(OFILES_SRC)
LIBTONC := $(LIBGBA)/../libtonc
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) -I$(LIBGBA)/include -I$(LIBTONC)/include
export DEPSDIR := $(CURDIR)/build
TESTS := $(wildcard test/*)
.PHONY: $(BUILD) test docs version pack release clean $(TESTS)
$(BUILD):
@[ -d lib ] || mkdir -p lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
test: $(TESTS)
$(TESTS):
$(MAKE) -C $@
docs:
@doxygen
version:
@standard-version
pack:
@zip -r $(notdir $(CURDIR))-`cat VERSION`.zip include lib LICENSE CHANGELOG.md README.md
release:
@git push --follow-tags origin main
@gh release create v`cat VERSION` $(notdir $(CURDIR))-`cat VERSION`.zip -F CHANGELOG.md
clean:
@rm -fr $(BUILD) lib *.zip
@for dir in $(TESTS); do \
$(MAKE) -C $$dir -f Makefile $@; \
done
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
$(TARGET): $(OFILES)
#---------------------------------------------------------------------------------
%.a: $(OFILES)
@echo $@
@rm -f $@
@$(AR) rcs $@ $(OFILES)
-include $(DEPENDS)
endif
#---------------------------------------------------------------------------------