From 603132ce0410b4d3a88406c8bb3c1535266d0156 Mon Sep 17 00:00:00 2001 From: Stefan `Sec` Zehl Date: Thu, 31 May 2012 17:23:18 +0200 Subject: [PATCH] Add crosscompile support to Makefile --- tools/reader/Makefile | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tools/reader/Makefile b/tools/reader/Makefile index 61e6aad..6b5ed87 100644 --- a/tools/reader/Makefile +++ b/tools/reader/Makefile @@ -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 +# +# 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)