-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
77 lines (58 loc) · 2.27 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 := source source/gba graphics
INCLUDES := include graphics
ENABLE_DEBUG_CHECKS := 1
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -mthumb -mthumb-interwork
DEFINES := -D__GBA__
ifeq ($(ENABLE_DEBUG_CHECKS),1)
DEFINES += -DUGBA_DEBUG
endif
CFLAGS := -g -O3 -Wall -Wno-switch -Wno-multichar \
-ffunction-sections -fdata-sections \
$(ARCH) $(INCLUDE) $(DEFINES) \
-gdwarf-4 # Needed by no$gba v3.05
ASFLAGS := -g -Wa,--warn $(ARCH) $(DEFINES) \
-gdwarf-4 # Needed by no$gba v3.05
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
export TARGET := $(CURDIR)/lib/libugba.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 := $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/build
.PHONY: $(BUILD) clean
$(BUILD):
@[ -d lib ] || mkdir -p lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
clean:
@echo clean ...
@rm -fr $(BUILD) lib
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
$(TARGET): $(OFILES)
#---------------------------------------------------------------------------------
%.a: $(OFILES)
@echo $@
@rm -f $@
@$(AR) rcs $@ $(OFILES)
-include $(DEPENDS)
endif
#---------------------------------------------------------------------------------