2N/A#---------------------------------------------------------------------------------
2N/A.SUFFIXES:
2N/A#---------------------------------------------------------------------------------
2N/A
2N/Aifeq ($(strip $(DEVKITARM)),)
2N/A$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
2N/Aendif
2N/A
2N/Ainclude $(DEVKITARM)/ds_rules
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# TARGET is the name of the output
2N/A# BUILD is the directory where object files & intermediate files will be placed
2N/A# SOURCES is a list of directories containing source code
2N/A# DATA is a list of directories containing data files
2N/A# INCLUDES is a list of directories containing header files
2N/A#---------------------------------------------------------------------------------
2N/ATARGET := $(shell basename $(CURDIR))
2N/ABUILD := build
2N/ASOURCES := ../../
2N/ADATA := data
2N/AINCLUDES := include
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# options for code generation
2N/A#---------------------------------------------------------------------------------
2N/AARCH := -mthumb -mthumb-interwork
2N/A
2N/ACFLAGS := -Wall -O2\
2N/A -march=armv5te -mtune=arm946e-s \
2N/A -fomit-frame-pointer -ffast-math \
2N/A $(ARCH)
2N/A
2N/ACFLAGS += $(INCLUDE) -DARM9
2N/ACXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
2N/A
2N/AASFLAGS := $(ARCH) -march=armv5te -mtune=arm946e-s
2N/ALDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# list of directories containing libraries, this must be the top level containing
2N/A# include and lib
2N/A#---------------------------------------------------------------------------------
2N/ALIBDIRS := $(LIBNDS)
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# no real need to edit anything past this point unless you need to add additional
2N/A# rules for different file extensions
2N/A#---------------------------------------------------------------------------------
2N/Aifneq ($(BUILD),$(notdir $(CURDIR)))
2N/A#---------------------------------------------------------------------------------
2N/A
2N/Aexport OUTPUT := $(CURDIR)/lib/libz.a
2N/A
2N/Aexport VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
2N/A $(foreach dir,$(DATA),$(CURDIR)/$(dir))
2N/A
2N/Aexport DEPSDIR := $(CURDIR)/$(BUILD)
2N/A
2N/ACFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
2N/ACPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
2N/ASFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
2N/ABINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# use CXX for linking C++ projects, CC for standard C
2N/A#---------------------------------------------------------------------------------
2N/Aifeq ($(strip $(CPPFILES)),)
2N/A#---------------------------------------------------------------------------------
2N/A export LD := $(CC)
2N/A#---------------------------------------------------------------------------------
2N/Aelse
2N/A#---------------------------------------------------------------------------------
2N/A export LD := $(CXX)
2N/A#---------------------------------------------------------------------------------
2N/Aendif
2N/A#---------------------------------------------------------------------------------
2N/A
2N/Aexport OFILES := $(addsuffix .o,$(BINFILES)) \
2N/A $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
2N/A
2N/Aexport INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
2N/A $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
2N/A -I$(CURDIR)/$(BUILD)
2N/A
2N/A.PHONY: $(BUILD) clean all
2N/A
2N/A#---------------------------------------------------------------------------------
2N/Aall: $(BUILD)
2N/A @[ -d $@ ] || mkdir -p include
2N/A @cp ../../*.h include
2N/A
2N/Alib:
2N/A @[ -d $@ ] || mkdir -p $@
2N/A
2N/A$(BUILD): lib
2N/A @[ -d $@ ] || mkdir -p $@
2N/A @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
2N/A
2N/A#---------------------------------------------------------------------------------
2N/Aclean:
2N/A @echo clean ...
2N/A @rm -fr $(BUILD) lib
2N/A
2N/A#---------------------------------------------------------------------------------
2N/Aelse
2N/A
2N/ADEPENDS := $(OFILES:.o=.d)
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A# main targets
2N/A#---------------------------------------------------------------------------------
2N/A$(OUTPUT) : $(OFILES)
2N/A
2N/A#---------------------------------------------------------------------------------
2N/A%.bin.o : %.bin
2N/A#---------------------------------------------------------------------------------
2N/A @echo $(notdir $<)
2N/A @$(bin2o)
2N/A
2N/A
2N/A-include $(DEPENDS)
2N/A
2N/A#---------------------------------------------------------------------------------------
2N/Aendif
2N/A#---------------------------------------------------------------------------------------
2N/A