-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
141 lines (100 loc) · 4.03 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#
# Makefile for tonclib.
#
#---------------------------------------------------------------------------------
.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
SRCDIRS := asm src src/font src/tte src/pre1.3
INCDIRS := include
DATADIRS := data
DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d)
ARCH := -mthumb -mthumb-interwork
RARCH := -mthumb-interwork -mthumb
IARCH := -mthumb-interwork -marm
bTEMPS := 0 # Save gcc temporaries (.i and .s files)
bDEBUG2 := 0 # Generate debug info (bDEBUG2? Not a full DEBUG flag. Yet)
VERSION := 1.4.3
#---------------------------------------------------------------------------------
# Options for code generation
#---------------------------------------------------------------------------------
CBASE := $(INCLUDE) -Wall -fno-strict-aliasing #-fno-tree-loop-optimize
CBASE += -O2
RCFLAGS := $(CBASE) $(RARCH)
ICFLAGS := $(CBASE) $(IARCH) -mlong-calls #-fno-gcse
CFLAGS := $(RCFLAGS)
ASFLAGS := $(INCLUDE) -Wa,--warn $(ARCH)
# --- Save temporary files ? ---
ifeq ($(strip $(bTEMPS)), 1)
RCFLAGS += -save-temps
ICFLAGS += -save-temps
CFLAGS += -save-temps
CXXFLAGS += -save-temps
endif
# --- Debug info ? ---
ifeq ($(strip $(bDEBUG2)), 1)
CFLAGS += -g
LDFLAGS += -g
endif
#---------------------------------------------------------------------------------
# Path to tools - this can be deleted if you set the path in windows
#---------------------------------------------------------------------------------
export PATH := $(DEVKITARM)/bin:$(PATH)
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
export TARGET := $(CURDIR)/lib/libtonc.a
export VPATH := $(foreach dir,$(DATADIRS),$(CURDIR)/$(dir)) $(foreach dir,$(SRCDIRS),$(CURDIR)/$(dir))
ICFILES := $(foreach dir,$(SRCDIRS),$(notdir $(wildcard $(dir)/*.iwram.c)))
RCFILES := $(foreach dir,$(SRCDIRS),$(notdir $(wildcard $(dir)/*.c)))
CFILES := $(ICFILES) $(RCFILES)
SFILES := $(foreach dir,$(SRCDIRS),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATADIRS),$(notdir $(wildcard $(dir)/*.*)))
export OFILES := $(addsuffix .o,$(BINFILES)) $(CFILES:.c=.o) $(SFILES:.s=.o)
export INCLUDE := $(foreach dir,$(INCDIRS),-I$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/build
.PHONY: $(BUILD) clean docs
$(BUILD):
@[ -d lib ] || mkdir -p lib
@[ -d $@ ] || mkdir -p $@
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
docs:
doxygen libtonc.dox
clean:
@echo clean ...
@rm -fr $(BUILD)
install:
@mkdir -p $(DESTDIR)$(DEVKITPRO)/libtonc/lib
@cp -rv include $(DESTDIR)$(DEVKITPRO)/libtonc/include
@cp -v lib/libtonc.a $(DESTDIR)$(DEVKITPRO)/libtonc/lib/
#-------------------------------------------------------------------------------
dist:
#-------------------------------------------------------------------------------
@tar -cvjf libtonc-src-$(VERSION).tar.bz2 asm src include \
Makefile todo.txt libtonc.dox base.c base.h
#---------------------------------------------------------------------------------
else
DEPENDS := $(OFILES:.o=.d)
#---------------------------------------------------------------------------------
%.a :
$(TARGET): $(OFILES)
%.a : $(OFILES)
@echo Building $@
@rm -f $@
@$(AR) -crs $@ $^
$(PREFIX)nm -Sn $@ > $(basename $(notdir $@)).map
%.iwram.o : %.iwram.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$(@:.o=.d) $(ICFLAGS) -c $< -o $@
%.o : %.c
@echo $(notdir $<)
$(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(RCFLAGS) -c $< -o $@
-include $(DEPENDS)
endif
#---------------------------------------------------------------------------------