Add crosscompile support to Makefile

This commit is contained in:
Stefan `Sec` Zehl 2012-05-31 17:23:18 +02:00
parent aedb52cff9
commit 603132ce04
1 changed files with 26 additions and 5 deletions

View File

@ -1,11 +1,32 @@
CC = gcc
ifneq "$(TUPLE)" ""
PREFIX=$(TUPLE)-
ARCH=$(shell echo $(TUPLE)|sed 's/-.*//')
else
PREFIX=
ARCH=$(shell uname -m)
endif
CC = $(PREFIX)gcc
STRIP = $(PREFIX)strip
CFLAGS = -Wall -O2
EXE = obreader
FILES = obreader.c
OBJS = obreader.o
all: $(FILES)
$(CC) $(CFLAGS) $(FILES) -o $(EXE)
$(ARCH)-$(EXE):
$(CC) $(CFLAGS) -o $@ $(FILES)
$(STRIP) $@
# Using OpenWRT crossbuild environment, see
# <URL:http://wiki.openwrt.org/doc/devel/crosscompile>
# for setup instructions.
WRT=~/r0ket/openwrt/trunk/staging_dir
mips:
STAGING_DIR=$(WRT)/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2 \
PATH=${PATH}:$(STAGING_DIR)/bin \
$(MAKE) TUPLE=mips-openwrt-linux
clean:
rm -f $(EXE) $(OBJS)
rm -f *-$(EXE)