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