# # Template tonc makefile # # Yoinked mostly from DKP's template # # === SETUP =========================================================== # --- No implicit rules --- .SUFFIXES: # --- Paths --- export TONCLIB := ${DEVKITPRO}/libtonc # === TONC RULES ====================================================== # # Yes, this is almost, but not quite, completely like to # DKP's base_rules and gba_rules # export PATH := $(DEVKITARM)/bin:$(DEVKITPRO)/tools/bin:$(PATH) # --- Executable names --- PREFIX ?= arm-none-eabi- export CC := $(PREFIX)gcc export CXX := $(PREFIX)g++ export AS := $(PREFIX)as export AR := $(PREFIX)ar export NM := $(PREFIX)nm export OBJCOPY := $(PREFIX)objcopy # LD defined in Makefile # === LINK / TRANSLATE ================================================ %.gba : %.elf @$(OBJCOPY) -O binary $< $@ @echo built ... $(notdir $@) @gbafix $@ -t$(TITLE) #---------------------------------------------------------------------- %.mb.elf : @echo Linking multiboot $(LD) -specs=gba_mb.specs $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ $(NM) -Sn $@ > $(basename $(notdir $@)).map #---------------------------------------------------------------------- %.elf : @echo Linking cartridge $(LD) -specs=gba.specs $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ $(NM) -Sn $@ > $(basename $(notdir $@)).map #---------------------------------------------------------------------- %.a : @echo $(notdir $@) @rm -f $@ $(AR) -crs $@ $^ # === OBJECTIFY ======================================================= %.iwram.o : %.iwram.cpp @echo $(notdir $<) $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(IARCH) -c $< -o $@ #---------------------------------------------------------------------- %.iwram.o : %.iwram.c @echo $(notdir $<) $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(IARCH) -c $< -o $@ #---------------------------------------------------------------------- %.o : %.cpp @echo $(notdir $<) $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) $(RARCH) -c $< -o $@ #---------------------------------------------------------------------- %.o : %.c @echo $(notdir $<) $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) $(RARCH) -c $< -o $@ #---------------------------------------------------------------------- %.o : %.s @echo $(notdir $<) $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ #---------------------------------------------------------------------- %.o : %.S @echo $(notdir $<) $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -c $< -o $@ #---------------------------------------------------------------------- # canned command sequence for binary data #---------------------------------------------------------------------- define bin2o bin2s $< | $(AS) -o $(@) echo "extern const u8" `(echo $( `(echo $(> `(echo $(> `(echo $( $(BUILD)/$(TARGET).map all : $(BUILD) clean: @echo clean ... @rm -rf $(BUILD) $(TARGET).elf $(TARGET).gba $(TARGET).sav else # If we're here, we should be in the BUILD dir DEPENDS := $(OFILES:.o=.d) # --- Main targets ---- $(OUTPUT).gba : $(OUTPUT).elf $(OUTPUT).elf : $(OFILES) -include $(DEPENDS) endif # End BUILD switch # --- More targets ---------------------------------------------------- .PHONY: clean rebuild start rebuild: clean $(BUILD) start: start "$(TARGET).gba" restart: rebuild start # EOF