-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
77 lines (55 loc) · 2.23 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
#---------------------------------------------------------------------------------
.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 src/fs src/fs/libgbfs
INCLUDES := include
ARCH := -mthumb -mthumb-interwork
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
CFLAGS := -g -O3 -Wall -Wno-switch -Wno-multichar $(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
.PHONY: $(BUILD) test clean
$(BUILD):
@[ -d lib ] || mkdir -p lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
test:
make -C test/fs
make -C test/fs-cpp
clean:
@rm -fr $(BUILD) lib
@make -C test/fs clean
@make -C test/fs-cpp clean
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
$(TARGET): $(OFILES)
#---------------------------------------------------------------------------------
%.a: $(OFILES)
@echo $@
@rm -f $@
@$(AR) rcs $@ $(OFILES)
-include $(DEPENDS)
endif
#---------------------------------------------------------------------------------