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