2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
.SUFFIXES:
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ifeq ($(strip $(DEVKITARM)),)
|
|
|
|
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
|
|
|
|
endif
|
|
|
|
|
|
|
|
include $(DEVKITARM)/ds_rules
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# BUILD is the directory where object files & intermediate files will be placed
|
|
|
|
# SOURCES is a list of directories containing source code
|
|
|
|
# INCLUDES is a list of directories containing extra header files
|
|
|
|
# DATA is a list of directories containing binary files
|
|
|
|
# LIB is where the built library will be placed
|
|
|
|
# all directories are relative to this makefile
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
BUILD ?= release
|
2008-11-20 06:22:28 +01:00
|
|
|
SOURCES := ../source source
|
2006-07-14 04:42:37 +02:00
|
|
|
INCLUDES := ../include
|
|
|
|
DATA :=
|
2006-07-14 05:00:30 +02:00
|
|
|
LIB := $(TOPDIR)/nds/lib
|
2006-07-14 04:42:37 +02:00
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# options for code generation
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ARCH := -mthumb -mthumb-interwork
|
|
|
|
|
|
|
|
CFLAGS := -g -Wall -O2\
|
2006-07-14 05:00:30 +02:00
|
|
|
-march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
|
|
|
|
-ffast-math \
|
|
|
|
$(ARCH)
|
2006-07-14 04:42:37 +02:00
|
|
|
|
|
|
|
CFLAGS += $(INCLUDE) -DARM9 -DNDS
|
|
|
|
CXXFLAGS := $(CFLAGS)
|
|
|
|
|
|
|
|
ASFLAGS := -g $(ARCH)
|
|
|
|
|
|
|
|
ifneq ($(BUILD),debug)
|
|
|
|
export ARM9BIN := $(LIB)/libfat.a
|
|
|
|
else
|
|
|
|
export ARM9BIN := $(LIB)/libfatd.a
|
|
|
|
CFLAGS += -DFAT_DEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# any extra libraries we wish to link with the project
|
|
|
|
#---------------------------------------------------------------------------------
|
2006-07-14 05:00:30 +02:00
|
|
|
LIBS :=
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# list of directories containing libraries, this must be the top level containing
|
|
|
|
# include and lib
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
LIBDIRS := $(LIBNDS)
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# no real need to edit anything past this point unless you need to add additional
|
|
|
|
# rules for different file extensions
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
|
2007-12-21 10:30:15 +01:00
|
|
|
export TOPDIR ?= $(CURDIR)/..
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
|
|
|
|
export DEPSDIR := $(CURDIR)/$(BUILD)
|
|
|
|
|
|
|
|
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
2006-07-14 05:00:30 +02:00
|
|
|
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
|
|
|
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
|
|
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
|
|
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
|
|
|
|
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
2006-07-14 05:00:30 +02:00
|
|
|
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
2006-07-14 05:00:30 +02:00
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
|
|
|
-I$(CURDIR)/$(BUILD)
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
.PHONY: $(BUILD) clean
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
$(BUILD):
|
|
|
|
@[ -d $@ ] || mkdir -p $@
|
2008-05-01 11:57:23 +02:00
|
|
|
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
clean:
|
|
|
|
@echo clean ...
|
|
|
|
@rm -fr debug release $(LIB)
|
|
|
|
|
|
|
|
all: $(ARM9BIN)
|
|
|
|
|
|
|
|
dist-bin:
|
2009-05-01 02:36:01 +02:00
|
|
|
@tar --exclude=.svn --exclude=*CVS* -cvjf $(TOPDIR)/distribute/$(VERSTRING)/libfat-nds-$(VERSTRING).tar.bz2 include lib
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2008-05-01 11:57:23 +02:00
|
|
|
install:
|
|
|
|
cp lib/libfat.a $(DEVKITPRO)/libnds/lib
|
2008-12-03 22:39:19 +01:00
|
|
|
cp include/fat.h $(DEVKITPRO)/libnds/include
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
else
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
DEPENDS := $(OFILES:.o=.d)
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
# main targets
|
|
|
|
#---------------------------------------------------------------------------------
|
|
|
|
$(ARM9BIN) : $(OFILES) $(LIB)
|
|
|
|
@rm -f "$(ARM9BIN)"
|
|
|
|
@$(AR) rcs "$(ARM9BIN)" $(OFILES)
|
|
|
|
@echo built ... $(notdir $@)
|
|
|
|
|
2007-12-21 10:30:15 +01:00
|
|
|
$(LIB):
|
|
|
|
mkdir $(LIB)
|
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
|
|
|
|
-include $(DEPENDS)
|
2006-07-14 05:00:30 +02:00
|
|
|
|
2006-07-14 04:42:37 +02:00
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
endif
|
|
|
|
#---------------------------------------------------------------------------------------
|
|
|
|
|