remove nitrofs from libfat
[libfat.git] / nds / Makefile
blob511d023f86e01b3cd9335298da0db4c8b440418d
1 #---------------------------------------------------------------------------------
2 .SUFFIXES:
3 #---------------------------------------------------------------------------------
4 ifeq ($(strip $(DEVKITARM)),)
5 $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
6 endif
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 #---------------------------------------------------------------------------------
18 BUILD ?= release
19 SOURCES := ../source source
20 INCLUDES := ../include
21 DATA :=
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\
31 -ffast-math \
32 $(ARCH)
34 CFLAGS += $(INCLUDE) -DARM9 -DNDS
35 CXXFLAGS := $(CFLAGS)
37 ASFLAGS := -g $(ARCH)
39 ifneq ($(BUILD),debug)
40 export ARM9BIN := $(LIB)/libfat.a
41 else
42 export ARM9BIN := $(LIB)/libfatd.a
43 CFLAGS += -DFAT_DEBUG
44 endif
46 #---------------------------------------------------------------------------------
47 # any extra libraries we wish to link with the project
48 #---------------------------------------------------------------------------------
49 LIBS :=
51 #---------------------------------------------------------------------------------
52 # list of directories containing libraries, this must be the top level containing
53 # include and lib
54 #---------------------------------------------------------------------------------
55 LIBDIRS := $(LIBNDS)
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) \
84 -I$(CURDIR)/$(BUILD)
86 export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
88 .PHONY: $(BUILD) clean
90 #---------------------------------------------------------------------------------
91 $(BUILD):
92 @[ -d $@ ] || mkdir -p $@
93 @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
95 #---------------------------------------------------------------------------------
96 clean:
97 @echo clean ...
98 @rm -fr debug release $(LIB)
100 all: $(ARM9BIN)
102 dist-bin:
103 @tar --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(DATESTRING)/libfat-nds-$(DATESTRING).tar.bz2 include lib
105 install:
106 cp lib/libfat.a $(DEVKITPRO)/libnds/lib
107 cp include/fat.h $(DEVKITPRO)/libnds/include
109 #---------------------------------------------------------------------------------
110 else
112 DEPENDS := $(OFILES:.o=.d)
114 #---------------------------------------------------------------------------------
115 # main targets
116 #---------------------------------------------------------------------------------
117 $(ARM9BIN) : $(OFILES) $(LIB)
118 @rm -f "$(ARM9BIN)"
119 @$(AR) rcs "$(ARM9BIN)" $(OFILES)
120 @echo built ... $(notdir $@)
122 $(LIB):
123 mkdir $(LIB)
126 -include $(DEPENDS)
128 #---------------------------------------------------------------------------------------
129 endif
130 #---------------------------------------------------------------------------------------