gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > A Beginner, a makefile and grit...

#177806 - sverx - Fri Mar 15, 2013 2:36 pm

My first GBA program that needs graphics. I took the libgba template and placed a .bmp file in the gfx directory, with a .grit file with the same name.
All I get is:

Quote:
make[1]: *** No rule to make target `sprites_16.o', needed by `/c/devkitPro/myproject/myproject.elf'. Stop.
"make": *** [build] Error 2


otherwise it compiles fine. Complete makefile follows, thanks for any help...

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
#---------------------------------------------------------------------------------
TARGET      :=   $(shell basename $(CURDIR))
BUILD      :=   build
SOURCES      :=   source
DATA      :=  data
GRAPHICS   :=   gfx
INCLUDES   :=

#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH   :=   -mthumb -mthumb-interwork

CFLAGS   :=   -g -Wall -O3\
      -mcpu=arm7tdmi -mtune=arm7tdmi\
       -fomit-frame-pointer\
      -ffast-math \
      $(ARCH)

CFLAGS   +=   $(INCLUDE)

CXXFLAGS   :=   $(CFLAGS) -fno-rtti -fno-exceptions

ASFLAGS   :=   $(ARCH)
LDFLAGS   =   -g $(ARCH) -Wl,-Map,$(notdir $@).map

#---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#---------------------------------------------------------------------------------
LIBS   :=   -lgba

#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS   :=   $(LIBGBA)

#---------------------------------------------------------------------------------
# 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)/*.*)))
BMPFILES   :=   $(foreach dir,$(GRAPHICS),$(notdir $(wildcard $(dir)/*.bmp)))

#---------------------------------------------------------------------------------
# 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)) \
               $(BMPFILES:.bmp=.o) \
               $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)

#---------------------------------------------------------------------------------
# build a list of include paths
#---------------------------------------------------------------------------------
export INCLUDE   :=   $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
         $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
         -I$(CURDIR)/$(BUILD)

#---------------------------------------------------------------------------------
# build a list of library paths
#---------------------------------------------------------------------------------
export LIBPATHS   :=   $(foreach dir,$(LIBDIRS),-L$(dir)/lib)

.PHONY: $(BUILD) clean

#---------------------------------------------------------------------------------
$(BUILD):
   @[ -d $@ ] || mkdir -p $@
   @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile

all   : $(BUILD)
#---------------------------------------------------------------------------------
clean:
   @echo clean ...
   @rm -fr $(BUILD) $(TARGET).elf $(TARGET).gba

#---------------------------------------------------------------------------------
else

DEPENDS   :=   $(OFILES:.o=.d)

#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
$(OUTPUT).gba   :   $(OUTPUT).elf

$(OUTPUT).elf   :   $(OFILES)


#---------------------------------------------------------------------------------
# The bin2o rule should be copied and modified
# for each extension used in the data directories
#---------------------------------------------------------------------------------

#---------------------------------------------------------------------------------
# This rule links in binary data with the .bin extension
#---------------------------------------------------------------------------------
%.bin.o   :   %.bin
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   @$(bin2o)

#---------------------------------------------------------------------------------
# This rule links in binary data with the .txt extension (the levels!)
#---------------------------------------------------------------------------------
%.txt.o   :   %.txt
#---------------------------------------------------------------------------------
   @echo $(notdir $<)
   @$(bin2o)

#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h   : %.bmp %.grit
#---------------------------------------------------------------------------------
   grit $< -fts -o$*

-include $(DEPENDS)

#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------

_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177810 - Quirky - Sun Mar 17, 2013 9:23 pm

Code:
#---------------------------------------------------------------------------------
# This rule creates assembly source files using grit
# grit takes an image file and a .grit describing how the file is to be processed
# add additional rules like this for each image extension
# you use in the graphics folders
#---------------------------------------------------------------------------------
%.s %.h   : %.bmp %.grit
#---------------------------------------------------------------------------------
   grit $< -fts -o$*


Try removing the %.grit bit - if you don't have bmp-specific rules then this fails.

EDIT: Oops, should have read your post better! I just hit this problem
recently resurrecting some old code and this was the issue I had.

Code:

export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
         $(foreach dir,$(DATA),$(CURDIR)/$(dir))


Here's the real issue - you need to add graphics to it:

Code:
export VPATH   :=   $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
         $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir)) \
         $(foreach dir,$(DATA),$(CURDIR)/$(dir))

#177811 - sverx - Mon Mar 18, 2013 1:54 pm

Thank you so much, that fixed it! IOU a beer, if you happen to pass close where I live :)
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177816 - sverx - Tue Mar 19, 2013 2:56 pm

Oh, BTW, maybe the Makefile of the GBA template in devkitPro needs that line added too? Should I file a bug on dkP forum... or that line is it just needed in my program?
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary

#177854 - Quirky - Mon Apr 08, 2013 4:14 pm

Ooof, dunno. The GBA templates are not really maintained, they've not been updated in years at least (not much demand I guess). Most of the examples use DATA or something IIRC, not GRAPHICS.

#177855 - sverx - Tue Apr 09, 2013 10:33 am

I see. Anyway in my opinion it's better to have two different directories... I mean, in DATA I put files I want to link in my program, whereas in GRAPHICS I put files I want to pass to grit.
_________________
libXM7|NDS programming tutorial (Italiano)|Waimanu DS / GBA|A DS Homebrewer's Diary