diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d21b4c2 --- /dev/null +++ b/Makefile @@ -0,0 +1,54 @@ +.PHONY = agbcc old_agbcc agbcc_arm libc.a libgcc.a + +# needed for out-of-tree builds of agbcc and old_agbcc +export srcdir = ../gcc + +all: agbcc old_agbcc agbcc_arm libc.a libgcc.a + +clean: + rm -rf build_agbcc build_old_agbcc + -$(MAKE) -C gcc_arm distclean + $(MAKE) -C libc clean + $(MAKE) -C libgcc clean + +agbcc: + mkdir -p build_agbcc + $(MAKE) -C build_agbcc -f ../gcc/Makefile clean + $(MAKE) -C build_agbcc -f ../gcc/Makefile normal + +old_agbcc: + mkdir -p build_old_agbcc + $(MAKE) -C build_old_agbcc -f ../gcc/Makefile clean + $(MAKE) -C build_old_agbcc -f ../gcc/Makefile old + +agbcc_arm: + -$(MAKE) -C gcc_arm distclean + cd gcc_arm && ./configure --target=arm-elf --host=i386-linux-gnu + $(MAKE) -C gcc_arm cc1 + +libc.a: old_agbcc + $(MAKE) -C libc clean + $(MAKE) -C libc + +libgcc.a: old_agbcc + $(MAKE) -C libgcc clean + $(MAKE) -C libgcc + +install: all +ifeq ($(PREFIX),) + $(error PREFIX is empty! Specify a PREFIX to install to) +endif + $(info Installing into $(PREFIX)) + mkdir -p $(PREFIX)/tools/agbcc + mkdir -p $(PREFIX)/tools/agbcc/bin + mkdir -p $(PREFIX)/tools/agbcc/include + mkdir -p $(PREFIX)/tools/agbcc/lib + cp build_agbcc/agbcc $(PREFIX)/tools/agbcc/bin/ + cp build_old_agbcc/old_agbcc $(PREFIX)/tools/agbcc/bin/ + cp gcc_arm/cc1 $(PREFIX)/tools/agbcc/bin/agbcc_arm + @# drop include, because we don't want include/include + cp -R libc/include $(PREFIX)/tools/agbcc/ + cp ginclude/* $(PREFIX)/tools/agbcc/include/ + cp libgcc/libgcc.a $(PREFIX)/tools/agbcc/lib/ + cp libc/libc.a $(PREFIX)/tools/agbcc/lib/ + diff --git a/build.sh b/build.sh index a1671fd..db2a948 100755 --- a/build.sh +++ b/build.sh @@ -1,29 +1,28 @@ #!/bin/sh + set -e CCOPT= CXXOPT= -# error if devkitarm is not installed and binutils-arm-none-eabi is not installed -if ! ([ -n "$DEVKITARM" ] && [ -d "$DEVKITARM/bin" ]) && ! (command -v arm-none-eabi-as &> /dev/null && command -v arm-none-eabi-ar &> /dev/null) ; then - echo "Could not find a binutils installation! Re-read the instructions and make sure you've installed either devkitARM or binutils-arm-none-eabi, depending on your system." - exit 1 -fi - if [ ! -z "$CC" ]; then CCOPT=CC=$CC; fi if [ ! -z "$CXX" ]; then CXXOPT=CXX=$CXX; fi -make -C gcc clean -make -C gcc old $CCOPT $CXXOPT -mv gcc/old_agbcc . -make -C gcc clean -make -C gcc $CCOPT $CXXOPT -mv gcc/agbcc . + +mkdir -p build_old_agbcc +srcdir=../gcc make -C build_old_agbcc -f ../gcc/Makefile clean +srcdir=../gcc make -C build_old_agbcc -f ../gcc/Makefile old $CCOPT $CXXOPT + +mkdir -p build_agbcc +srcdir=../gcc make -C build_agbcc -f ../gcc/Makefile clean +srcdir=../gcc make -C build_agbcc -f ../gcc/Makefile normal $CCOPT $CXXOPT + # not sure if the ARM compiler is the old one or the new one (-DOLD_COMPILER) -rm -f gcc_arm/config.status gcc_arm/config.cache -cd gcc_arm && ./configure --target=arm-elf --host=i386-linux-gnu && make cc1 && cd .. -mv gcc_arm/cc1 agbcc_arm +# || true is needed to keep going if the distclean fails, such as when no configure has been done before +make -C gcc_arm distclean || true +cd gcc_arm && ./configure --target=arm-elf --host=i386-linux-gnu && cd .. +make -C gcc_arm cc1 + make -C libgcc clean make -C libgcc $CCOPT $CXXOPT -mv libgcc/libgcc.a . + make -C libc clean make -C libc $CCOPT $CXXOPT -mv libc/libc.a . diff --git a/gcc/Makefile b/gcc/Makefile index 9756e90..abba727 100644 --- a/gcc/Makefile +++ b/gcc/Makefile @@ -19,12 +19,12 @@ #Boston MA 02111-1307, USA. # Directory where sources are, from where we are. -srcdir = . +srcdir ?= . VPATH = $(srcdir) CC = gcc -BASE_CFLAGS = -g -std=gnu11 -Werror-implicit-function-declaration +BASE_CFLAGS = -g -std=gnu11 INCLUDES = -I. -I$(srcdir) @@ -81,7 +81,7 @@ $(OBJS): %.o: %.c $(DEPDIR)/%.d | $(GENERATED) $(COMPILE) $< $(POSTCOMPILE) -$(RTL_OBJS) $(RTLANAL_OBJS) $(PRINT_OBJS): %.o: %.c $(DEPDIR)/%.d +$(RTL_OBJS) $(RTLANAL_OBJS) $(PRINT_OBJS): %.o: %.c $(DEPDIR)/%.d genrtl.h $(COMPILE) $< $(POSTCOMPILE) diff --git a/gcc_arm/Make-hooks b/gcc_arm/Make-hooks deleted file mode 100644 index 1fa9bbd..0000000 --- a/gcc_arm/Make-hooks +++ /dev/null @@ -1,21 +0,0 @@ -lang.all.build: -lang.all.cross: -lang.start.encap: -lang.rest.encap: -lang.info: -lang.dvi: -lang.install-normal: -lang.install-common: -lang.install-info: -lang.install-man: -lang.uninstall: -lang.distdir: -lang.mostlyclean: -lang.clean: -lang.distclean: -lang.extraclean: -lang.maintainer-clean: -lang.stage1: -lang.stage2: -lang.stage3: -lang.stage4: diff --git a/gcc_arm/Make-host b/gcc_arm/Make-host deleted file mode 100644 index e69de29..0000000 diff --git a/gcc_arm/Make-lang b/gcc_arm/Make-lang deleted file mode 100644 index e69de29..0000000 diff --git a/gcc_arm/Make-target b/gcc_arm/Make-target deleted file mode 100644 index b57eeca..0000000 --- a/gcc_arm/Make-target +++ /dev/null @@ -1,35 +0,0 @@ -CROSS_LIBGCC1 = libgcc1-asm.a -LIB1ASMSRC = arm/lib1funcs.asm -# CYGNUS LOCAL interworking -LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX -# END CYGNUS LOCAL interworking - -# These are really part of libgcc1, but this will cause them to be -# built correctly, so... - -LIB2FUNCS_EXTRA = fp-bit.c dp-bit.c - -fp-bit.c: $(srcdir)/config/fp-bit.c - echo '#define FLOAT' > fp-bit.c - echo '#ifndef __ARMEB__' >> fp-bit.c - echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c - echo '#endif' >> fp-bit.c - cat $(srcdir)/config/fp-bit.c >> fp-bit.c - -dp-bit.c: $(srcdir)/config/fp-bit.c - echo '#ifndef __ARMEB__' > dp-bit.c - echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c - echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c - echo '#endif' >> dp-bit.c - cat $(srcdir)/config/fp-bit.c >> dp-bit.c - -# CYGNUS LOCAL -MULTILIB_OPTIONS = mlittle-endian/mbig-endian mhard-float/msoft-float mapcs-32/mapcs-26 mno-thumb-interwork/mthumb-interwork fno-leading-underscore/fleading-underscore mcpu=arm7 -MULTILIB_DIRNAMES = le be fpu soft 32bit 26bit normal interwork elf under nofmult -MULTILIB_EXCEPTIONS = *mapcs-26/*mthumb-interwork* *mthumb-interwork*/*mcpu=arm7* -MULTILIB_MATCHES = mbig-endian=mbe mlittle-endian=mle mcpu?arm7=mcpu?arm7d mcpu?arm7=mcpu?arm7di mcpu?arm7=mcpu?arm70 mcpu?arm7=mcpu?arm700 mcpu?arm7=mcpu?arm700i mcpu?arm7=mcpu?arm710 mcpu?arm7=mcpu?arm710c mcpu?arm7=mcpu?arm7100 mcpu?arm7=mcpu?arm7500 mcpu?arm7=mcpu?arm7500fe mcpu?arm7=mcpu?arm6 mcpu?arm7=mcpu?arm60 mcpu?arm7=mcpu?arm600 mcpu?arm7=mcpu?arm610 mcpu?arm7=mcpu?arm620 -LIBGCC = stmp-multilib -INSTALL_LIBGCC = install-multilib -# END CYGNUS LOCAL - -TARGET_LIBGCC2_CFLAGS = -Dinhibit_libc diff --git a/gcc_arm/config.h b/gcc_arm/config.h deleted file mode 100644 index 0c48f96..0000000 --- a/gcc_arm/config.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "auto-host.h" -#include "gansidecl.h" -#include "i386/xm-i386.h" -#ifndef HAVE_ATEXIT -#define HAVE_ATEXIT -#endif -#ifndef POSIX -#define POSIX -#endif -#ifndef BSTRING -#define BSTRING -#endif diff --git a/gcc_arm/cstamp-h b/gcc_arm/cstamp-h deleted file mode 100644 index 8b13789..0000000 --- a/gcc_arm/cstamp-h +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gcc_arm/gencheck.h b/gcc_arm/gencheck.h deleted file mode 100644 index e69de29..0000000 diff --git a/gcc_arm/hconfig.h b/gcc_arm/hconfig.h deleted file mode 100644 index 0c48f96..0000000 --- a/gcc_arm/hconfig.h +++ /dev/null @@ -1,12 +0,0 @@ -#include "auto-host.h" -#include "gansidecl.h" -#include "i386/xm-i386.h" -#ifndef HAVE_ATEXIT -#define HAVE_ATEXIT -#endif -#ifndef POSIX -#define POSIX -#endif -#ifndef BSTRING -#define BSTRING -#endif diff --git a/gcc_arm/options.h b/gcc_arm/options.h deleted file mode 100644 index e69de29..0000000 diff --git a/gcc_arm/specs.h b/gcc_arm/specs.h deleted file mode 100644 index e69de29..0000000 diff --git a/gcc_arm/tconfig.h b/gcc_arm/tconfig.h deleted file mode 100644 index 1fa5d1e..0000000 --- a/gcc_arm/tconfig.h +++ /dev/null @@ -1,2 +0,0 @@ -#include "gansidecl.h" -#include "arm/xm-arm.h" diff --git a/gcc_arm/tm.h b/gcc_arm/tm.h deleted file mode 100644 index bda15db..0000000 --- a/gcc_arm/tm.h +++ /dev/null @@ -1,3 +0,0 @@ -#define TARGET_CPU_DEFAULT (TARGET_CPU_generic) -#include "gansidecl.h" -#include "arm/unknown-elf.h" diff --git a/install.sh b/install.sh index 637a21d..67ad4dd 100755 --- a/install.sh +++ b/install.sh @@ -6,13 +6,13 @@ if [ "$1" != "" ]; then mkdir -p $1/tools/agbcc/bin mkdir -p $1/tools/agbcc/include mkdir -p $1/tools/agbcc/lib - cp agbcc $1/tools/agbcc/bin/ - cp old_agbcc $1/tools/agbcc/bin/ - cp agbcc_arm $1/tools/agbcc/bin/ + cp build_agbcc/agbcc $1/tools/agbcc/bin/ + cp build_old_agbcc/old_agbcc $1/tools/agbcc/bin/ + cp gcc_arm/cc1 $1/tools/agbcc/bin/agbcc_arm cp -R libc/include $1/tools/agbcc/ #drop include, because we don't want include/include cp ginclude/* $1/tools/agbcc/include/ - cp libgcc.a $1/tools/agbcc/lib/ - cp libc.a $1/tools/agbcc/lib/ + cp libgcc/libgcc.a $1/tools/agbcc/lib/ + cp libc/libc.a $1/tools/agbcc/lib/ echo "agbcc successfully installed!" else if [ -d "../$1" ]; then diff --git a/libc/Makefile b/libc/Makefile index d9de489..0fef62d 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -9,17 +9,24 @@ else DKA_EXISTS=0 endif -ifneq ($(DKA_EXISTS),1) PREFIX := arm-none-eabi- export AR := $(PREFIX)ar export AS := $(PREFIX)as + +ifeq ($(DKA_EXISTS),0) +ifeq ($(shell which $(AR)),) +$(info DKA_EXISTS=$(DKA_EXISTS)) +$(info DEVKITARM=$(DEVKITARM)) +$(info which arm-none-eabi-ar is $(shell which arm-none-eabi-ar)) +$(error Cannot find $(AR) or devkitARM, make sure you have an arm-none-eabi toolchain or devkitARM installed and your environment variables properly set up) +endif endif SHELL := /bin/bash -o pipefail ASFLAGS := -mcpu=arm7tdmi -CC1 := ../old_agbcc +CC1 := ../build_old_agbcc/old_agbcc CFLAGS := -O2 -fno-builtin CPPFLAGS := -I ../ginclude -I include -nostdinc -undef \ diff --git a/libgcc/Makefile b/libgcc/Makefile index 0e96527..d46bd84 100644 --- a/libgcc/Makefile +++ b/libgcc/Makefile @@ -9,17 +9,24 @@ else DKA_EXISTS=0 endif -ifneq ($(DKA_EXISTS),1) PREFIX := arm-none-eabi- export AR := $(PREFIX)ar export AS := $(PREFIX)as + +ifeq ($(DKA_EXISTS),0) +ifeq ($(shell which $(AR)),) +$(info DKA_EXISTS=$(DKA_EXISTS)) +$(info DEVKITARM=$(DEVKITARM)) +$(info which arm-none-eabi-ar is $(shell which arm-none-eabi-ar)) +$(error Cannot find $(AR) or devkitARM, make sure you have an arm-none-eabi toolchain or devkitARM installed and your environment variables properly set up) +endif endif -CC1 = ../old_agbcc +CC1 = ../build_old_agbcc/old_agbcc libgcc.a: libgcc1.a libgcc2.a fp-bit.o dp-bit.o - $(AR) -x libgcc1.a; - $(AR) -x libgcc2.a; + $(AR) -x libgcc1.a + $(AR) -x libgcc2.a $(AR) -rc libgcc.a *.o LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _call_via_rX @@ -66,19 +73,19 @@ libgcc2.a: libgcc2.c longlong.h mv tmplibgcc2.a libgcc2.a fp-bit.o: fp-bit.c - $(CPP) -undef -I ../ginclude -nostdinc -o fp-bit.i fp-bit.c; + $(CPP) -undef -I ../ginclude -nostdinc -o fp-bit.i fp-bit.c $(CC1) -O2 fp-bit.i rm -f fp-bit.i bash -c 'echo -e ".text\n\t.align\t2, 0\n"' >> fp-bit.s - $(AS) -mcpu=arm7tdmi -o fp-bit.o fp-bit.s; + $(AS) -mcpu=arm7tdmi -o fp-bit.o fp-bit.s rm -f fp-bit.s dp-bit.o: dp-bit.c - $(CPP) -undef -I ../ginclude -nostdinc -o dp-bit.i dp-bit.c; + $(CPP) -undef -I ../ginclude -nostdinc -o dp-bit.i dp-bit.c $(CC1) -O2 dp-bit.i rm -f dp-bit.i bash -c 'echo -e ".text\n\t.align\t2, 0\n"' >> dp-bit.s - $(AS) -mcpu=arm7tdmi -o dp-bit.o dp-bit.s; + $(AS) -mcpu=arm7tdmi -o dp-bit.o dp-bit.s rm -f dp-bit.s fp-bit.c: fp-bit-base.c @@ -94,4 +101,4 @@ dp-bit.c: fp-bit-base.c .PHONY: clean clean: - rm -f *.o *.a *.s *.i \ No newline at end of file + rm -f *.o *.a *.s *.i