1 #---------------------------------------------------------------------------------
3 #---------------------------------------------------------------------------------
4 ifeq ($(strip $(DEVKITARM
)),)
5 $(error
"Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
8 include $(DEVKITARM)/ds_rules
10 #---------------------------------------------------------------------------------
11 # BUILD is the directory where object files & intermediate files will be placed
12 # SOURCES is a list of directories containing source code
13 # INCLUDES is a list of directories containing extra header files
14 # DATA is a list of directories containing binary files
15 # LIB is where the built library will be placed
16 # all directories are relative to this makefile
17 #---------------------------------------------------------------------------------
19 SOURCES := ../source source
20 INCLUDES := ../include
22 LIB := $(TOPDIR)/nds/lib
24 #---------------------------------------------------------------------------------
25 # options for code generation
26 #---------------------------------------------------------------------------------
27 ARCH := -mthumb -mthumb-interwork
29 CFLAGS := -g -Wall -O2\
30 -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
34 CFLAGS += $(INCLUDE) -DARM9 -DNDS
39 ifneq ($(BUILD),debug)
40 export ARM9BIN := $(LIB)/libfat.a
42 export ARM9BIN := $(LIB)/libfatd.a
46 #---------------------------------------------------------------------------------
47 # any extra libraries we wish to link with the project
48 #---------------------------------------------------------------------------------
51 #---------------------------------------------------------------------------------
52 # list of directories containing libraries, this must be the top level containing
54 #---------------------------------------------------------------------------------
57 #---------------------------------------------------------------------------------
58 # no real need to edit anything past this point unless you need to add additional
59 # rules for different file extensions
60 #---------------------------------------------------------------------------------
61 ifneq ($(BUILD),$(notdir $(CURDIR)))
62 #---------------------------------------------------------------------------------
64 export TOPDIR ?= $(CURDIR)/..
67 export DEPSDIR := $(CURDIR)/$(BUILD)
69 export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
70 $(foreach dir,$(DATA),$(CURDIR)/$(dir))
72 CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
73 CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
74 SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
75 BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
78 export OFILES := $(addsuffix .o,$(BINFILES)) \
79 $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
81 export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
82 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
83 $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
86 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
88 .PHONY: $(BUILD) clean
90 #---------------------------------------------------------------------------------
92 @[ -d $@ ] || mkdir -p $@
93 @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
95 #---------------------------------------------------------------------------------
98 @rm -fr debug release $(LIB)
103 @tar --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(DATESTRING)/libfat-nds-$(DATESTRING).tar.bz2 include lib
106 cp lib/libfat.a $(DEVKITPRO)/libnds/lib
107 cp include/fat.h $(DEVKITPRO)/libnds/include
109 #---------------------------------------------------------------------------------
112 DEPENDS := $(OFILES:.o=.d)
114 #---------------------------------------------------------------------------------
116 #---------------------------------------------------------------------------------
117 $(ARM9BIN) : $(OFILES) $(LIB)
119 @$(AR) rcs "$(ARM9BIN
)" $(OFILES)
120 @echo built ... $(notdir $@)
128 #---------------------------------------------------------------------------------------
130 #---------------------------------------------------------------------------------------