Update the Makefile to support cross builds.

This commit is contained in:
David Betz 2015-04-02 17:38:40 -04:00
parent edd7a60d3c
commit f41e93b267
1 changed files with 22 additions and 7 deletions

View File

@ -1,10 +1,25 @@
# CC, EXT, and BUILD may be overridden by a top level makefile (e.g. for
# cross compiling)
CC = gcc
EXT =
BUILD = ./obj
# cross compilation scheme taken from Eric Smith's spin2cpp compiler
# if CROSS is defined, we are building a cross compiler
# possible targets are: win32, rpi
TARGET = spinsim$(EXT)
ifeq ($(CROSS),win32)
CC=i586-mingw32msvc-gcc
CXX=i586-mingw32msvc-g++
EXT=.exe
BUILD=./build-win32
else ifeq ($(CROSS),rpi)
CC=arm-linux-gnueabihf-gcc
CXX=arm-linux-gnueabihf-g++
EXT=
BUILD=./build-rpi
else
CC=gcc
CXX=g++
EXT=
BUILD=./build
endif
TARGET = $(BUILD)/spinsim$(EXT)
SOURCES = spinsim.c spininterp.c spindebug.c pasmsim.c pasmdebug.c pasmsim2.c pasmdebug2.c eeprom.c debug.c gdb.c
@ -32,5 +47,5 @@ $(BUILD)/%.o: %.c
$(CC) $(CFLAGS) $< -o $@
clean: FORCE
rm -f *.o $(TARGET)
rm -f $(BUILD)
FORCE: