#99894 - gmiller - Thu Aug 24, 2006 5:01 pm
I noticed a problem with the base rules make file with regard to the ability to build code for IWRAM and some other related ARM verus THUMB mode lines. The current order of the makefile will compile using the .o .c rule instead of the .iwram.o .iwram.c because of the order the rules are presented. I don't think this is on purpose or if this is an appropriate place to note this. My upper level make file uses these files to automate the make and minimize the customizing.
Here is my new modified base_rules
Code: |
#--------------------------------------------------------------------------------- # Clear the implicit built in rules #--------------------------------------------------------------------------------- .SUFFIXES: #--------------------------------------------------------------------------------- ifeq ($(strip $(DEVKITARM)),) $(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM) endif -include $(DEVKITARM)/gba_rules #--------------------------------------------------------------------------------- # TARGET is the name of the output, if this ends with _mb a multiboot image is generated # BUILD is the directory where object files & intermediate files will be placed # SOURCES is a list of directories containing source code # DATA is a list of directories containing data files # INCLUDES is a list of directories containing header files #--------------------------------------------------------------------------------- # HAM Stuff no longer used .... # #PROGNAME =unused #OFILES+= unused #ADD_LIBS+= unused # ................. # TARGET := $(shell basename $(CURDIR)) BUILD := build SOURCES := source DATA := INCLUDES := $(DEVKITARM) GDB_DIRS = $cdir:$cwd:$(ADD_GDB_SOURCE_DIRS) ifeq ($(MAKECMDGOALS),gdb) DEBUG_SET := gdb endif #--------------------------------------------------------------------------------- # options for code generation #--------------------------------------------------------------------------------- ARCH := -mthumb-interwork #ARCH := -marm -mthumb-interwork ifneq ($(DEBUG_SET),gdb) THIS_BUILD := "Release Build" CFLAGS := -Wall -O3\ -mcpu=arm7tdmi -mtune=arm7tdmi\ -fomit-frame-pointer\ -ffast-math \ $(ARCH) else THIS_BUILD := "Debug Build" CFLAGS := -g -Wall -O0\ -mcpu=arm7tdmi -mtune=arm7tdmi\ -ffast-math \ $(ARCH) endif CFLAGS += $(INCLUDE) ASFLAGS := $(ARCH) ifneq ($(DEBUG_SET),gdb) LDFLAGS = $(ARCH) -Wl,-Map,$(notdir $@).map else LDFLAGS = -g $(ARCH) -Wl,-Map,$(notdir $@).map endif #--------------------------------------------------------------------------------- # path to tools - this can be deleted if you set the path to the toolchain in windows #--------------------------------------------------------------------------------- export PATH := $(DEVKITARM)/bin:$(DEVKITPRO)/msys/bin:$(PATH) #--------------------------------------------------------------------------------- # any extra libraries we wish to link with the project #--------------------------------------------------------------------------------- LIBS := -ltonc #--------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level containing # include and lib #--------------------------------------------------------------------------------- LIBDIRS := $(LIBGBA) $(DEVKITPRO)/tonclib #--------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional # rules for different file extensions #--------------------------------------------------------------------------------- ifneq ($(BUILD),$(notdir $(CURDIR))) #--------------------------------------------------------------------------------- export OUTPUT := $(CURDIR)/$(TARGET) export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) export DEPSDIR := $(CURDIR)/$(BUILD) #--------------------------------------------------------------------------------- # automatically build a list of object files for our project #--------------------------------------------------------------------------------- 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)/*.*))) #--------------------------------------------------------------------------------- # use CXX for linking C++ projects, CC for standard C #--------------------------------------------------------------------------------- ifeq ($(strip $(CPPFILES)),) #--------------------------------------------------------------------------------- export LD := $(CC) #--------------------------------------------------------------------------------- else #--------------------------------------------------------------------------------- export LD := $(CXX) #--------------------------------------------------------------------------------- endif #--------------------------------------------------------------------------------- export OFILES := $(addsuffix .o,$(BINFILES)) $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o) #--------------------------------------------------------------------------------- # build a list of include paths #--------------------------------------------------------------------------------- export INCLUDE := $(foreach dir,$(INCLUDES),-I$(dir)/include) \ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ $(foreach dir,$(CURDIR), -I$(dir)/include) \ -I$(CURDIR) #--------------------------------------------------------------------------------- # build a list of library paths #--------------------------------------------------------------------------------- export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) .PHONY: $(BUILD) clean #--------------------------------------------------------------------------------- $(BUILD): @[ -d $@ ] || mkdir -p $@ make "DEBUG_SET=$(DEBUG_SET)" --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile all : buildtype $(BUILD) buildtype: @echo "Build type: " $(THIS_BUILD) #--------------------------------------------------------------------------------- clean: @echo clean ... rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba #--------------------------------------------------------------------------------- vbawin: clean all $(DEVKITPRO)/tools/win32/vbawin.exe $(TARGET).gba #--------------------------------------------------------------------------------- runvbawin: $(DEVKITPRO)/tools/win32/vbawin.exe $(TARGET).gba #--------------------------------------------------------------------------------- vba: clean all $(DEVKITPRO)/tools/win32/vbaSDL/vba.exe -3 $(TARGET).gba #--------------------------------------------------------------------------------- runvba: $(DEVKITPRO)/tools/win32/vbaSDL/vba.exe -3 $(TARGET).gba #--------------------------------------------------------------------------------- startsdl: $(DEVKITPRO)/tools/win32/vbaSDL/vba.exe -3 -Gtcp:44444 & #--------------------------------------------------------------------------------- makeini: echo "File $(TARGET).elf" > insight.ini echo "target remote 127.0.0.1:44444" >>insight.ini echo "load $(TARGET).elf" >>insight.ini echo "b main" >>insight.ini echo "directory $(GDB_DIRS)">>insight.ini echo "c" >>insight.ini #--------------------------------------------------------------------------------- startinsight: $(DEVKITPRO)/insight-6.4.50/bin/arm-elf-insight.exe --command=insight.ini $(TARGET).elf #--------------------------------------------------------------------------------- gdb: clean @make "DEBUG_SET=$(DEBUG_SET)" all make startsdl makeini startinsight #--------------------------------------------------------------------------------- rungdb: startsdl makeini startinsight testinsight: makeini startinsight #--------------------------------------------------------------------------------- else DEPENDS := $(OFILES:.o=.d) #--------------------------------------------------------------------------------- # main targets #--------------------------------------------------------------------------------- $(OUTPUT).gba : $(OUTPUT).elf $(OUTPUT).elf : $(OFILES) %.o : %.pcx echo $(notdir $<) $(bin2o) -include $(DEPENDS) #--------------------------------------------------------------------------------- endif #-------------------------------------------------------------------------------- |
Here is my new modified base_rules
Code: |
#--------------------------------------------------------------------------------- # path to tools - this can be deleted if you set the path in windows #--------------------------------------------------------------------------------- export PATH := $(DEVKITARM)/bin:$(PATH) #--------------------------------------------------------------------------------- # the prefix on the compiler executables #--------------------------------------------------------------------------------- PREFIX := arm-eabi- export CC := $(PREFIX)gcc export CXX := $(PREFIX)g++ export AS := $(PREFIX)as export AR := $(PREFIX)ar export OBJCOPY := $(PREFIX)objcopy #--------------------------------------------------------------------------------- %.a: #--------------------------------------------------------------------------------- @echo $(notdir $@) @echo "'Lib' Rule" @rm -f $@ $(AR) -rc $@ $^ #--------------------------------------------------------------------------------- %.iwram.o: %.iwram.cpp @echo $(notdir $<) @echo "'CPP' IWRAM Rule" $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -marm-c $< -o $@ #--------------------------------------------------------------------------------- %.iwram.o: %.iwram.c @echo $(notdir $<) @echo "'C' IWRAM Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -marm -c $< -o $@ #--------------------------------------------------------------------------------- %.itcm.o: %.itcm.cpp @echo $(notdir $<) @echo "'CPP' ARM Rule" $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -marm -c $< -o $@ #--------------------------------------------------------------------------------- %.itcm.o: %.itcm.c @echo $(notdir $<) @echo "'C' ARM Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -marm -c $< -o $@ #--------------------------------------------------------------------------------- %.o: %.cpp @echo $(notdir $<) @echo "'CPP' Rule" $(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -mthumb -c $< -o $@ #--------------------------------------------------------------------------------- %.o: %.c @echo $(notdir $<) @echo "'C' Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d $(CFLAGS) -mthumb -c $< -o $@ #--------------------------------------------------------------------------------- %.iwram.o: %.iwram.s @echo $(notdir $<) @echo "'ASM' IWRAM Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -marm -c $< -o $@ #--------------------------------------------------------------------------------- %.iwram.o: %.iwram.S @echo $(notdir $<) @echo "'ASM' IWRAM Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -marm -c $< -o $@ #--------------------------------------------------------------------------------- %.o: %.s @echo $(notdir $<) @echo "'ASM' Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -mthumb -c $< -o $@ #--------------------------------------------------------------------------------- %.o: %.S @echo $(notdir $<) @echo "'ASM' Rule" $(CC) -MMD -MP -MF $(DEPSDIR)/$*.d -x assembler-with-cpp $(ASFLAGS) -mthumb -c $< -o $@ #--------------------------------------------------------------------------------- # canned command sequence for binary data #--------------------------------------------------------------------------------- define bin2o bin2s $< | $(AS) $(ARCH) -o $(@) echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h endef |