#149082 - Cave Johnson - Tue Jan 15, 2008 12:28 am
Ive decided to try and create homebrew, and im running into roadblocks from the get go. Im using devkitPro, and following a tutorial at http://www.double.co.nz/nintendo_ds/nds_develop1.html. In the Msys shell, it says "From within this shell change to the 'demo1' subdirectory that unzipping the file creates and run the command 'make'." How on earth do i change to a subdirectory in the shell? Thanks for your help.
#149087 - Lick - Tue Jan 15, 2008 2:44 am
#149144 - Cave Johnson - Wed Jan 16, 2008 12:14 am
It says "sh: cd: demo1: No such file or directory" I know the file exists because i can open it, but why won't it register it? I've tried creating pathways, but nothing seems to help (im probably not doing it right, though). Any other ideas? Thanks. (also i assume u meant type cd demo1, hit enter, type in make, hit enter)
#149167 - knight0fdragon - Wed Jan 16, 2008 6:37 am
I would start all over if I were you, and not look at that website, the information is too old to be of any use really, and it will just hurt you in the long run
_________________
http://www.myspace.com/knight0fdragonds
MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206
#149177 - Cave Johnson - Wed Jan 16, 2008 12:23 pm
Ok, the website wasnt being that helpful to begin with, but my problem still stands. I have no idea how to switch to a makefile so that i can begin programming on it, when i try to find it(which i have no idea how to, from licks post i assume you type "cd makefile") i still get the same response from my first post. I think this may have something to do with pathways, but once again i dont think i did them correctly either (how far do i take its value? just to the main folder (ds), or all the way to the file so that it reads C:\Taylor\ds\demo1\demo1\makefile?) Thanks for your help.
#149191 - gmiller - Wed Jan 16, 2008 3:17 pm
the "cd demo" causes you to change to the demo "folder" or "directory" the the next line "make" invokes the make utility. This utility looks for a file called "Makefile" to describe the dependencies of your project.
A makefile is a text file that contains lines that describe files that are dependent on others and how to regenerate the files. I use a standard makefile for my GBA projects that uses files from the devKitPro install and some of my own work.
You can build simple makefiles like:
Code: |
#
# "$Id: makefile,v 1.4 2005/08/10 14:09:19 gmiller Exp gmiller $"
#
#
exercise : array
array: array.o
$(CC) -o $@ array.o $(LLFLAGS)
.c.o :
$(CC) -c -g $(CCFLAGS) $*.c
array.o: array.c
|
This makefile defines a label "exercise" which is dependent on "array". "array" is dependent on "array.o" (object file, output of compiler) and defines rules to convert the object file to the executable with the linker "$(CC) -o $@ array.o $(LLFLAGS)" the next rule shows how to convert the .c files to .o (C source files to object files) using the compiler. The last rule shows that the array.o file is dependent on the array.c file. The defined rule for .c to .o will be used for this. BEWARE: The lines in a rule have format rules defined for them. The label must start in column 1 and and lines that that follow that label that are associated with the label (usually commands to do what you want for that label) must start with a TAB not a space.
The commands to be used depend on the tools you are using so this would not be very helpful for a GBA or NDS code project. My makefile for GBA projects looks like this:
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 -mthumb-interwork
ARCH :=
ifneq ($(DEBUG_SET),gdb)
THIS_BUILD := "Release Build"
CFLAGS := -Wall -O3 -save-temps \
-mcpu=arm7tdmi -mtune=arm7tdmi\
-fomit-frame-pointer\
-ffast-math \
$(ARCH)
else
THIS_BUILD := "Debug Build"
CFLAGS := -g -Wall -O0 -save-temps \
-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 :=
#---------------------------------------------------------------------------------
# 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)/*.*)))
#---------------------------------------------------------------------------------
# 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/VisualBoyAdvance-SDL.exe -D1024 -v-1 -3 -Gtcp:44444 2>err.log &
#---------------------------------------------------------------------------------
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
#---------------------------------------------------------------------------------
startinsightnew:
$(DEVKITPRO)/insight/bin/arm-eabi-insight.exe --command=insight.ini $(TARGET).elf
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
#--------------------------------------------------------------------------------
|
Of course this is a more complex makefile and will only work for GBA project in my development environment.
#149211 - Cave Johnson - Wed Jan 16, 2008 8:40 pm
Wow, first of all, thank you for the indepth reply. It seems all of this is starting to make sense, but i still have 2 main problems:
1. How do i create and work on a project directory in a shell. Im guessing that it would work similar to trying to pull up demo1 (from the origional post) but as i said, i was getting the error message "sh: cd: demo1: No such file or directory." I have a feeling that this has something to do with me assigning the pathway variable name or variable value wrong. If so, how do you properly assign them?
2. The mumbo jumbo language that you use to code, but this is something that i will just have to learn over time.
Thanks.