Permalink
Browse files

Got this building libzengarden.a for Nintendo DS. A stub testing prog…

…ram is in src/ZenGardenDS/ but it is not yet functional.
  • Loading branch information...
1 parent da92238 commit afbf6587a30f1bd59972b43c6ee36c7d9923177d chrism committed Dec 28, 2009
View
@@ -10,5 +10,6 @@ Xcode/build
Xcode/Xcode.xcodeproj/mhroth.pbxuser
Xcode/Xcode.xcodeproj/mhroth.mode1v3
src/main.cpp
+src/sndfile.h
.*.swp
*.pyc
View
24 README
@@ -18,6 +18,7 @@ Requirements
libsndfile
- OSX: port install libsndfile
- Debian GNU/Linux: apt-get install libsndfile1-dev
+ - Nintendo DS: *experimental* see below
java - for the java example - you need at least java5
- Debian: apt-get install sun-java6-jdk
@@ -50,6 +51,29 @@ You can build individual components like so:
# build the Java hosted example
make examplegarden
+Build: Nintendo DS
+------------------
+
+To build for Nintendo DS you first need to build libsndfile for NDS:
+ * Download it from http://www.mega-nerd.com/libsndfile/#Download
+ * Run the following commands in the directory where you unpacked the libsndfile source:
+
+ export PATH=$PATH:$DEVKITARM/bin/
+ ./configure --enable-shared=no --enable-static=yes --disable-largefile --disable-alsa --disable-sqlite --host=arm-eabi --disable-external-libs --disable-test-coverage
+ make
+ # you may experience some errors to do with tests, but the .a file should be built anyway
+ # now copy the libsndfile.a library into your ZenGarden development directory
+ cp src/.libs/libsndfile.a ../ZenGarden/src/
+ # finally, copy the sndfile.h header file to the ZenGarden development directory
+ cp src/sndfile.h ../ZenGarden/src/
+
+Finally, to build a static library for the nintendo DS, invoke the following command:
+
+ OS=nds make libzengarden-static
+
+This will create ../libs/nds/libzengarden.a and you can use this library to
+statically link into your nintendo DS programs.
+
Advantages
----------
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
View
Binary file not shown.
View
@@ -12,7 +12,9 @@ CXXFLAGS = -g -Os -fPIC -Wall -I$(my-dir) $(SNDFILE_INCLUDE)
# figure out what platform we're on
-OS=$(shell ./platform)
+ifndef OS
+ OS=$(shell ./platform)
+endif
ifeq (,$(findstring Makefile.OS.$(OS),$(OS_MAKEFILES)))
@@ -29,14 +31,19 @@ else
include Makefile.OS.$(OS)
-all: platform libzengarden libjnizengarden examplegarden
+all: platform libzengarden libzengarden-static libjnizengarden examplegarden
platform: Makefile.OS.$(OS)
@echo "Building for the $(OS) platform"
@mkdir -p ../libs/$(OS)
clean:
- rm -rf $(LOCAL_MODULE).so *.o me/rjdj/zengarden/*.class ../ZenGarden.jar ../libs/$(OS)/*
+ rm -rf $(LOCAL_MODULE).so *.d *.o me/rjdj/zengarden/*.class ../ZenGarden.jar ../libs/$(OS)/*
+
+libzengarden-static: ../libs/$(OS)/libzengarden.a
+
+../libs/$(OS)/libzengarden.a: $(OBJS)
+ $(AR) rcs $@ $(OBJS)
libjnizengarden: ../libs/$(OS)/libjnizengarden.$(JNI_EXTENSION)
View
@@ -0,0 +1,150 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
+endif
+
+include $(DEVKITARM)/ds_rules
+
+#---------------------------------------------------------------------------------
+# TARGET is the name of the output
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# INCLUDES is a list of directories containing extra header files
+# DATA is a list of directories containing binary data
+# GRAPHICS is a list of directories containing files to be processed by grit
+#
+# All directories are specified relative to the project directory where
+# the makefile is found
+#
+#---------------------------------------------------------------------------------
+TARGET := $(notdir $(CURDIR))
+BUILD := ./
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH := -mthumb -mthumb-interwork
+
+CFLAGS := -g -Wall -O2\
+ -march=armv5te -mtune=arm946e-s -fomit-frame-pointer\
+ -ffast-math \
+ $(ARCH)
+
+CFLAGS += $(INCLUDE) -DARM
+CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -I. -L.
+
+ASFLAGS := -g $(ARCH)
+LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+
+#---------------------------------------------------------------------------------
+# any extra libraries we wish to link with the project
+#---------------------------------------------------------------------------------
+LIBS := -lmm9 -lnds9
+
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS := $(LIBNDS)
+
+#---------------------------------------------------------------------------------
+# no real need to edit anything past this point unless you need to add additional
+# rules for different file extensions
+#---------------------------------------------------------------------------------
+
+
+ifneq ($(BUILDDIR), $(CURDIR))
+#---------------------------------------------------------------------------------
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
+ $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
+ $(foreach dir,$(GRAPHICS),$(CURDIR)/$(dir))
+
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+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)/*.*))) soundbank.bin
+
+export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MUSIC)/*.*)),$(CURDIR)/$(MUSIC)/$(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)) \
+ $(BMPFILES:.bmp=.o) \
+ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
+
+export INCLUDE := $(foreach dir,$(INCLUDES),-iquote $(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD)
+
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+#.PHONY: $(BUILD) clean
+
+#---------------------------------------------------------------------------------
+#$(BUILD):
+# @[ -d $@ ] || mkdir -p $@
+# @make BUILDDIR=`cd $(BUILD) && pwd` --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+else
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).nds : $(OUTPUT).arm9
+$(OUTPUT).arm9 : $(OUTPUT).elf
+$(OUTPUT).elf : $(OFILES)
+
+
+#---------------------------------------------------------------------------------
+# The bin2o rule should be copied and modified
+# for each extension used in the data directories
+#---------------------------------------------------------------------------------
+
+#---------------------------------------------------------------------------------
+# rule to build soundbank from music files
+#---------------------------------------------------------------------------------
+soundbank.bin : $(AUDIOFILES)
+#---------------------------------------------------------------------------------
+ @mmutil $^ -d -osoundbank.bin -hsoundbank.h
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .bin extension
+#---------------------------------------------------------------------------------
+%.bin.o : %.bin
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+
+
+-include $(DEPSDIR)/*.d
+
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
+
+MAKE_SO=$(CC) -o $(1) $(CXXFLAGS) -shared $(2) $(3) $(SNDFILE_LIB) -lstdc++
+JNI_EXTENSION=so
+SO_EXTENSION=so
View
@@ -0,0 +1,142 @@
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+
+ifeq ($(strip $(DEVKITARM)),)
+$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM)
+endif
+
+include $(DEVKITARM)/ds_rules
+
+#---------------------------------------------------------------------------------
+# TARGET is the name of the output
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# INCLUDES is a list of directories containing extra header files
+# MAXMOD_SOUNDBANK contains a directory of music and sound effect files
+#---------------------------------------------------------------------------------
+TARGET := $(shell basename $(CURDIR))
+BUILD := build
+SOURCES := gfx source data
+INCLUDES := include build
+MAXMOD_SOUNDBANK := music
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+ARCH := -mthumb -mthumb-interwork \
+ -march=armv5te -mtune=arm946e-s
+
+CFLAGS := -g -Wall -O2\
+ -fomit-frame-pointer\
+ -ffast-math \
+ $(ARCH)
+
+CFLAGS += $(INCLUDE) -DARM9
+CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
+
+ASFLAGS := -g $(ARCH)
+LDFLAGS = -specs=ds_arm9.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
+
+#---------------------------------------------------------------------------------
+# any extra libraries we wish to link with the project
+#---------------------------------------------------------------------------------
+LIBS := -lnds9
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS := $(LIBNDS)
+
+#---------------------------------------------------------------------------------
+# 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))
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+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,$(SOURCES),$(notdir $(wildcard $(dir)/*.bin)))
+
+#---------------------------------------------------------------------------------
+# build audio file list, include full path
+#---------------------------------------------------------------------------------
+export AUDIOFILES := $(foreach dir,$(notdir $(wildcard $(MAXMOD_SOUNDBANK)/*.*)),$(CURDIR)/$(MAXMOD_SOUNDBANK)/$(dir))
+
+ifneq ($(strip $(AUDIOFILES)),)
+BINFILES += soundbank.bin
+endif
+
+#---------------------------------------------------------------------------------
+# use CXX for linking C++ projects, CC for standard C
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(CPPFILES)),)
+#---------------------------------------------------------------------------------
+ export LD := $(CC)
+#---------------------------------------------------------------------------------
+else
+#---------------------------------------------------------------------------------
+ export LD := $(CXX)
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
+
+export OFILES := $(BINFILES:.bin=.o) \
+ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
+
+export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ -I$(CURDIR)/$(BUILD)
+
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
+
+.PHONY: $(BUILD) clean
+
+#---------------------------------------------------------------------------------
+$(BUILD):
+ @[ -d $@ ] || mkdir -p $@
+ @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+ @echo clean ...
+ @rm -fr $(BUILD) $(TARGET).elf $(TARGET).nds $(TARGET).arm9 $(TARGET).ds.gba
+
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS := $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).nds : $(OUTPUT).arm9
+$(OUTPUT).arm9 : $(OUTPUT).elf
+$(OUTPUT).elf : $(OFILES)
+
+#---------------------------------------------------------------------------------
+%.o : %.bin
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ $(bin2o)
+
+#---------------------------------------------------------------------------------
+soundbank.bin : $(AUDIOFILES)
+#---------------------------------------------------------------------------------
+ @echo creating soundbank...
+ @mmutil -d $(AUDIOFILES) -osoundbank.bin -hsoundbank.h
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------------
View
@@ -0,0 +1 @@
+This will be the Nintendo DS example program for running ZenGarden patches.
Oops, something went wrong.

0 comments on commit afbf658

Please sign in to comment.