# ============================================= # # makefile.arm-gcc.macosx, v0.1 for play+mobile # http://hypermedia.loeil.org/playmobile/ # # BUILD AND INSTALL A GCC CROSS COMPILER FOR # "ARM7TDMI" PROCESSOR ON MACOS X # # ============================================= PREFIX = /usr/local/arm-gcc/ TARGET = arm-agb-elf # -- BINUTILS_VERSION = 2.15 GCC_VERSION = 3.4.3 NEWLIB_VERSION = 1.13.0 # -- CONFIG_OPTIONS = --target=$(TARGET) \ --prefix=$(PREFIX)\ --with-cpu=arm7tdmi \ --disable-shared \ --enable-multilib \ --disable-threads \ --enable-interwork \ --enable-languages=c \ --with-newlib \ --without-local-prefix \ --disable-nls # -- AS = $(PREFIX)/bin/$(TARGET)-as CC = $(PREFIX)/bin/$(TARGET)-gcc LD = $(PREFIX)/bin/$(TARGET)-ld OBJCOPY = $(PREFIX)/bin/$(TARGET)-objcopy ASFLAGS = -I$(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)/include \ -mthumb-interwork CFLAGS = -I$(PREFIX)/lib/gcc/$(TARGET)/$(GCC_VERSION)/include \ -mthumb \ -mthumb-interwork \ -c \ -g \ -Wall \ -fverbose-asm LIBC = `$(CC) $(CFLAGS) -print-file-name=libc.a` LIBGCC = `$(CC) $(CFLAGS) -print-file-name=libgcc.a` LDFLAGS = -Tlnkscript $(LIBC) $(LIBGCC) # -- all : help help : @printf "\n\ //\n\ // This makefile is intented to build and install a GCC cross compiler\n\ // required for GBA development on MacOS X. This file is configured\n\ // to support the C language and to compile gcc with newlib as\n\ // the C library. The default installation path is /usr/local/arm-gcc\n\ // edit this makefile and change the PREFIX value to specify the toplevel\n\ // installation directory (absolute path required).\n\ //\n\ \n\ Download, build, install and test with one command : type \`make do-all\'\n\ or process step by step in the following way:\n\ \t1- Type \`make download\' to download all sources (require wget)\n\ \t2- Type \`make untar\' to extract files in *.tar.gz and *.tar.bz2 archives\n\ \t3- Type \`make all-binutils\' to configure, build and install binutils\n\ \t4- Type \`make all-gcc\' to configure, build and install gcc (with newlib)\n\ \t5- Type \`make test\' to run a small program on your emulator\n\ Type \`make clean-all\' to remove all temporary files created\n\ \n\ Some other rules:\n\ \t\`do-arm-gcc\' only configure, build and install arm-gcc\n\ \t\`clean\' call respectivly the binutils clean rule and the gcc clean rule\n\ Edit this makefile to see (or modify) all sub-process for more flexibility\n\ \n\ All download process required wget installed. If the command line could not be\n\ found download manually each tarballs, move each files in the same directory of\n\ this makefile, and type \`make untar do-arm-gcc\' to finalyze the process\n\ or \`make help\' for more informations.\n\ Here some FTP address\n\ \twget : ftp://ftp.gnu.org/gnu/wget/wget-1.9.1.tar.gz (optional)\n\ \tbinutils: ftp://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz\n\ \tnewlib : ftp://sources.redhat.com/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz\n\ \tgcc-core: ftp://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-core-$(GCC_VERSION).tar.bz2\n\ To test you need crt0.s & lnkscript available at http://www.devrs.com/gba/files/crtls.zip\n\ \n\ good luck\n\ " do-all : download untar do-arm-gcc test do-arm-gcc : all-binutils all-gcc # --------------------------------------------- # | 1 | DOWNLOAD SOURCES # --------------------------------------------- # # required wget tools installed available at # ftp://ftp.gnu.org/gnu/wget/wget-1.9.1.tar.gz # download : @echo downloading tarballs... wget -c ftp://ftp.gnu.org/gnu/binutils/binutils-$(BINUTILS_VERSION).tar.gz wget -c ftp://sources.redhat.com/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz wget -c ftp://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-core-$(GCC_VERSION).tar.bz2 @echo download done # --------------------------------------------- # | 2 | EXTRACT FILES # --------------------------------------------- # # extract files in the created 'source' folder # untar: @echo extracting files... mkdir -p source cd source/ && tar -xzvf ../binutils-$(BINUTILS_VERSION).tar.gz cd source/ && tar -xzvf ../newlib-$(NEWLIB_VERSION).tar.gz cd source/ && tar -xjvf ../gcc-core-$(GCC_VERSION).tar.bz2 @echo extract done # --------------------------------------------- # | 3 | BINUTILS PROCESS # --------------------------------------------- # # configure, build, install binutils # all-binutils : binutils-configure binutils-make binutils-install @echo process with binutils done binutils-configure : mkdir -p build/binutils-$(BINUTILS_VERSION) cd build/binutils-$(BINUTILS_VERSION) && ../../source/binutils-$(BINUTILS_VERSION)/configure $(CONFIG_OPTIONS) binutils-make : cd build/binutils-$(BINUTILS_VERSION) && make all binutils-install : cd build/binutils-$(BINUTILS_VERSION) && make install binutils-clean : @cd build/binutils-$(BINUTILS_VERSION) && make clean # --------------------------------------------- # | 4 | GCC & NEWLIB PROCESS # --------------------------------------------- # # Link 'newlib' and 'libgloss' from newlib sources into # the gcc build folder, set $PATH to find the arm-agb-elf-* # binutils bin and configure, build, install gcc # all-gcc : gcc-configure gcc-make gcc-install @echo process with gcc done gcc-configure : mkdir -p build/gcc-$(GCC_VERSION) ln -fhs $(PWD)/source/newlib-$(NEWLIB_VERSION)/newlib/ $(PWD)/source/gcc-$(GCC_VERSION)/newlib export PATH=$(PREFIX)/bin:$$PATH; \ cd build/gcc-$(GCC_VERSION) && ../../source/gcc-$(GCC_VERSION)/configure $(CONFIG_OPTIONS) gcc-make : export PATH=$(PREFIX)/bin:$$PATH; \ cd build/gcc-$(GCC_VERSION) && make all gcc-install : export PATH=$(PREFIX)/bin:$$PATH; \ cd build/gcc-$(GCC_VERSION) && make install gcc-clean : @cd build/gcc-$(GCC_VERSION) && make clean # --------------------------------------------- # TEST # --------------------------------------------- # # create a small program, compile and run it # on your GBA emulator # # the test program : draw random colored pixels on screen GBA_PROGRAM = "\n// main.c\n// Draw random colored pixels on screen directly to video memory\n\n\#include \n\n\#define RGB(r,g,b) ((r)+(g<<5)+(b<<10)) \n\nint AgbMain() {\n\t\n\tint x, y;\n\t\n\tunsigned short* videoBuffer = (unsigned short*)0x6000000;\n\t*(unsigned long*)0x4000000 = (0x3 | 0x400);\n\t\n\twhile(1) {\n\t\tx = rand()\x25240;\n\t\ty = rand()\x25160;\n\t\tvideoBuffer[y * 240 + x] = RGB(rand()\x2531, rand()\x2531, rand()\x2531);\n\t}\n\t\n\treturn 0;\n\n}\n" .PHONY: test test : if test ! -f crtls.zip; then \ wget http://www.devrs.com/gba/files/crtls.zip; \ fi; \ mkdir -p test; \ cd test; \ printf $(GBA_PROGRAM) > main.c; \ unzip -oq ../crtls.zip; \ mv CRT0.S crt0.S; \ $(AS) -o crt0.o $(ASFLAGS) crt0.S; \ $(CC) -c main.c -o main.o $(CFLAGS); \ $(LD) crt0.o main.o -o test.elf $(LDFLAGS); \ $(OBJCOPY) -v -O binary test.elf test.gba open test/test.gba # --------------------------------------------- # CLEAN # --------------------------------------------- # # remove all the files created by running make # except the downloaded sources # .PHONY: clean clean : binutils-clean gcc-clean @echo clean done clean-all : @echo removing all the files created... @rm -rf build/ @rm -rf source/ @rm -rf test/ @echo clean done # --- # EOF