Jump to content
  • 0

"makefiles" for the nintendo ds...


EpicEbilninja
 Share

Question

2 answers to this question

Recommended Posts

  • 0

Makefiles conceptually aren't platform-specific, so any tutorial on making them for PC is also in principle valid for the DS. This one for example looks like an easy to understand tutorial: http://mrbook.org/tutorials/make/

 

They can get convoluted if you've got a big project or want everything to be as automatic as possible (like creating a CD image for a PSX game), but with DS homebrew you should be able to get by with something simpler than this mess:

 

 

# Makefile for Modified Psy-Q PSX SDK + GMSS pseudo-template

# Project properties
PROJECT = PANELFLIP
MAINFILE = main
TIMEZONE = CET-1CEST

# User-dependant paths & files
MINGW_DIR = C:\\MinGW\\msys\\1.0\\bin
EMUCMD = C:\\Users\\Daniel\\Emulation\\pSX_1_13\\psxfin.exe
LICENSE = C:\\psx\\tools\\infoeur.dat

# Code paths & files
SRCPATH = src
OBJPATH = obj
INCPATH = $(SRCPATH)/include
GMSSINC = $(SRCPATH)/system/include
SRCS := $(shell ufind $(SRCPATH) -name '*.c' ! -name "version.c" ! -name "gmssver.c")
OBJS = $(SRCS:.c=.obj)
VERFILE = $(SRCPATH)/version
GMSSVER = $(SRCPATH)/system/gmssver
OBJS += $(VERFILE).obj $(GMSSVER).obj

# Compiler
CC = ccpsx
OPTIONS = -O3 -I $(GMSSINC) -I $(INCPATH)
ADRFLAG = -Xo0x80010000

# External objects
EXTOBJS =

# Target files
TRGFILE = $(MAINFILE).cpe
EXEFILE = $(TRGFILE:.cpe=.exe)
OBJFILE = $(TRGFILE:.cpe=.obj)
SYMFILE = $(TRGFILE:.cpe=.sym)
MAPFILE = $(TRGFILE:.cpe=.map)
HSFFILE = $(TRGFILE:.cpe=.hsf)
CDIMAGE = $(TRGFILE:.cpe=.bin)

# CD compilation
DATAPATH = data
DATA_TIMS = $(shell $(MINGW_DIR)\find $(DATAPATH) \( -iname \*.tim -o -iname \*.TIM \))
DATA_BGMS = $(shell $(MINGW_DIR)\find $(DATAPATH) \( -iname \*.vag -o -iname \*.VAG \))
CDBUILD = cd
CDROOT = $(CDBUILD)/root
CDDATA = $(CDROOT)/data
CDDATA_TIMS = $(subst $(DATAPATH),$(CDDATA),$(DATA_TIMS))
CDDATA_BGMS = $(subst $(DATAPATH),$(CDDATA),$(DATA_BGMS))

define \n


endef

# Debug CD (default)
.PHONY debug_cd: version
debug_cd: debug
debug_cd: run_cd

# Final release build; cleans before building
.PHONY release_cd: clean version
release_cd: release
release_cd: run_cd

.PHONY debug:
debug: OPTIONS += -DDEBUG
debug: compile_cd

.PHONY release: version
release: $(MAINFILE)
@cpe2psx $(TRGFILE) $(EXEFILE)

.PHONY version:
version:
@$(MINGW_DIR)\rm -f $(VERFILE).c
@$(MINGW_DIR)\rm -f $(GMSSVER).c
@echo 'const char * GAME_BUILD_DATE = "$(shell export TZ=$(TIMEZONE) && date +'%a %b %d %Y')";' >> $(VERFILE).c;
@echo 'const char * GAME_BUILD_TIME = "$(shell export TZ=$(TIMEZONE) && date +'%H:%M:%S %Z')";' >> $(VERFILE).c;
@echo 'const char * GAME_BUILD_CREATOR = "$(shell id -un)@$(shell hostname)";' >> $(VERFILE).c;
@echo 'const char * GMSS_BUILD_DATE = "$(shell export TZ=$(TIMEZONE) && date +'%a %b %d %Y')";' >> $(GMSSVER).c;
@echo 'const char * GMSS_BUILD_TIME = "$(shell export TZ=$(TIMEZONE) && date +'%H:%M:%S %Z')";' >> $(GMSSVER).c;
@echo 'const char * GMSS_BUILD_CREATOR = "$(shell id -un)@$(shell hostname)";' >> $(GMSSVER).c;

$(MAINFILE): $(OBJS)
$(CC) $(OPTIONS) $(ADRFLAG) $(EXTOBJS) $(OBJS) -o $(TRGFILE),$(SYMFILE),$(MAPFILE)

%.obj: %.c
$(CC) $(OPTIONS) -c -o $@ $<

.PHONY: compile_cd
compile_cd: release
@$(MINGW_DIR)\\mkdir.exe -p $(CDBUILD)
@$(MINGW_DIR)\\mkdir.exe -p $(CDROOT)
@$(MINGW_DIR)\\mkdir.exe -p $(CDDATA)
@$(foreach var,$(dir $(CDDATA_TIMS)),$(MINGW_DIR)\\mkdir.exe -p $(var);)
@$(foreach var,$(dir $(CDDATA_BGMS)),$(MINGW_DIR)\\mkdir.exe -p $(var);)
@cp $(EXEFILE) $(CDROOT)
@systemcnf $(EXEFILE) > $(CDROOT)/system.cnf
@$(foreach var,$(DATA_TIMS),cp $(var) $(subst $(DATAPATH),$(CDDATA),$(var))${\n})
@$(foreach var,$(DATA_BGMS),cp $(var) $(subst $(DATAPATH),$(CDDATA),$(var))${\n})

.PHONY: build_cd
build_cd: compile_cd
@mkisofs -o $(HSFFILE) -V $(PROJECT) -sysid PLAYSTATION $(CDROOT)
@mkpsxiso $(HSFFILE) $(CDBUILD)/$(CDIMAGE) $(LICENSE)
@$(MINGW_DIR)\rm -f $(HSFFILE)

.PHONY: run_cd
run_cd: build_cd
@$(EMUCMD) $(CDBUILD)/$(CDIMAGE:.bin=.cue)

.PHONY: clean
clean:
@$(MINGW_DIR)\rm -rf $(CDDATA)
@$(MINGW_DIR)\rm -rf $(CDROOT)
@$(MINGW_DIR)\rm -rf $(CDBUILD)
@$(MINGW_DIR)\rm -f $(OBJS) $(TRGFILE) $(EXEFILE) $(OBJFILE) $(SYMFILE) $(MAPFILE)
@$(MINGW_DIR)\rm -f $(VERFILE).c
@$(MINGW_DIR)\rm -f $(GMSSVER).c

 

 

(Man, how many headaches that thing's given me already <.<)

Link to comment
Share on other sites

  • 0

I just get so caught up in wanting to make the game, that I jump ahead trying to understand a language that I have no experience in...

 

I know each makefile is unique to the program in development, and the makefiles just seem rather intimidating...

 

Thanks again xdan :)

 

now I just to figure out how to get it to spit out .elf and .nds to actually run a game... (I'll try to find it myself over the next few days)

  • Like 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.