1 #---------------------------------------------------------------------------------
3 #---------------------------------------------------------------------------------
4 ifeq ($(strip $(DEVKITARM
)),)
5 $(error
"Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
8 include $(DEVKITARM)/gba_rules
11 #---------------------------------------------------------------------------------
12 # BUILD is the directory where object files & intermediate files will be placed
13 # SOURCES is a list of directories containing source code
14 # INCLUDES is a list of directories containing extra header files
15 # DATA is a list of directories containing binary files
16 # LIB is where the built library will be placed
17 # all directories are relative to this makefile
18 #---------------------------------------------------------------------------------
21 INCLUDES := ../include
23 LIB := $(TOPDIR)/gba/lib
25 #---------------------------------------------------------------------------------
26 # options for code generation
27 #---------------------------------------------------------------------------------
28 ARCH := -mthumb -mthumb-interwork
30 CFLAGS := -g -Wall -O2\
31 -mcpu=arm7tdmi -mtune=arm7tdmi\
36 CFLAGS += $(INCLUDE) -DGBA
41 ifneq ($(BUILD),debug)
42 export GBABIN := $(LIB)/libfat.a
44 export GBABIN := $(LIB)/libfatd.a
49 #---------------------------------------------------------------------------------
50 # any extra libraries we wish to link with the project
51 #---------------------------------------------------------------------------------
55 #---------------------------------------------------------------------------------
56 # list of directories containing libraries, this must be the top level containing
58 #---------------------------------------------------------------------------------
61 #---------------------------------------------------------------------------------
62 # no real need to edit anything past this point unless you need to add additional
63 # rules for different file extensions
64 #---------------------------------------------------------------------------------
65 ifneq ($(BUILD),$(notdir $(CURDIR)))
66 #---------------------------------------------------------------------------------
68 export TOPDIR ?= $(CURDIR)/..
70 export DEPSDIR := $(CURDIR)/$(BUILD)
72 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
73 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
75 export CC := $(PREFIX)gcc
76 export CXX := $(PREFIX)g++
77 export AR := $(PREFIX)ar
78 export OBJCOPY := $(PREFIX)objcopy
80 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
81 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
82 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
83 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
85 #---------------------------------------------------------------------------------
86 # use CXX for linking C++ projects, CC for standard C
87 #---------------------------------------------------------------------------------
88 ifeq ($(strip $(CPPFILES)),)
89 #---------------------------------------------------------------------------------
91 #---------------------------------------------------------------------------------
93 #---------------------------------------------------------------------------------
95 #---------------------------------------------------------------------------------
97 #---------------------------------------------------------------------------------
99 export OFILES := $(addsuffix .o,$(BINFILES)) \
100 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
102 export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
103 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
104 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
107 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
109 .PHONY: $(BUILD) clean
111 #---------------------------------------------------------------------------------
113 @[ -d $@ ] || mkdir -p $@
114 @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
116 #---------------------------------------------------------------------------------
119 @rm -fr debug release $(LIB)
124 @tar --exclude=.svn --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(VERSTRING)/libfat-gba-$(VERSTRING).tar.bz2 include lib
127 cp lib/libfat.a $(DEVKITPRO)/libgba/lib
128 cp include/fat.h $(DEVKITPRO)/libgba/include
130 #---------------------------------------------------------------------------------
133 DEPENDS := $(OFILES:.o=.d)
135 #---------------------------------------------------------------------------------
137 #---------------------------------------------------------------------------------
138 $(GBABIN) : $(OFILES) $(LIB)
140 @$(AR) rcs "$(GBABIN
)" $(OFILES)
141 @echo built ... $(notdir $@)
146 #---------------------------------------------------------------------------------
147 # you need a rule like this for each extension you use as binary data
148 #---------------------------------------------------------------------------------
150 #---------------------------------------------------------------------------------
157 #---------------------------------------------------------------------------------------
159 #---------------------------------------------------------------------------------------