Auto-detect target arch via cross-compiler. Drop TARGET=arch.

This commit is contained in:
Mike Pall 2011-12-15 19:16:06 +01:00
parent 6ace80c897
commit b61be299c9
2 changed files with 10 additions and 9 deletions

View File

@ -355,7 +355,7 @@ EGLIBC). The <tt>CROSS</tt> prefix may vary depending on the
<tt>--target</tt> of the toolchain: <tt>--target</tt> of the toolchain:
</p> </p>
<pre class="code"> <pre class="code">
make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- TARGET=arm make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi-
</pre> </pre>
<p> <p>
You can cross-compile for <b id="android">Android (ARM)</b> using the <a href="http://developer.android.com/sdk/ndk/index.html"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>. You can cross-compile for <b id="android">Android (ARM)</b> using the <a href="http://developer.android.com/sdk/ndk/index.html"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>.
@ -368,7 +368,7 @@ NDKABI=8
NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3 NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3
NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi- NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm" NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF" TARGET=arm make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
</pre> </pre>
<p> <p>
You can cross-compile for <b id="ios">iOS 3.0+</b> (iPhone/iPad) using the <a href="http://developer.apple.com/devcenter/ios/index.action"><span class="ext">&raquo;</span>&nbsp;iOS SDK</a>. You can cross-compile for <b id="ios">iOS 3.0+</b> (iPhone/iPad) using the <a href="http://developer.apple.com/devcenter/ios/index.action"><span class="ext">&raquo;</span>&nbsp;iOS SDK</a>.
@ -387,7 +387,7 @@ ISDKVER=iPhoneOS4.3.sdk
ISDKP=$ISDK/usr/bin/ ISDKP=$ISDK/usr/bin/
ISDKF="-arch armv6 -isysroot $ISDK/SDKs/$ISDKVER" ISDKF="-arch armv6 -isysroot $ISDK/SDKs/$ISDKVER"
make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \ make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
TARGET=arm TARGET_SYS=iOS TARGET_SYS=iOS
</pre> </pre>
<p> <p>
You can cross-compile for a <b id="ppc">PPC target</b> or a You can cross-compile for a <b id="ppc">PPC target</b> or a
@ -398,11 +398,11 @@ of the toolchain:
</p> </p>
<pre class="code"> <pre class="code">
# PPC # PPC
make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu- TARGET=ppc make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
</pre> </pre>
<pre class="code"> <pre class="code">
# PPC/e500v2 # PPC/e500v2
make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe- TARGET=ppcspe make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
</pre> </pre>
<p> <p>
Whenever the <b>host OS and the target OS differ</b>, you need to specify Whenever the <b>host OS and the target OS differ</b>, you need to specify

View File

@ -173,13 +173,11 @@ XCFLAGS=
# #
# Cross-compilation examples: # Cross-compilation examples:
# make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows # make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
# make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe- TARGET=ppcspe # make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS) CCOPTIONS= $(CCDEBUG) $(CCOPT) $(CCWARN) $(XCFLAGS) $(CFLAGS)
LDOPTIONS= $(CCDEBUG) $(LDFLAGS) LDOPTIONS= $(CCDEBUG) $(LDFLAGS)
TARGET_ARCH= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET))
HOST_CC= $(CC) HOST_CC= $(CC)
HOST_RM= rm -f HOST_RM= rm -f
# NOTE: The LuaJIT distribution comes with pre-generated buildvm_*.h files. # NOTE: The LuaJIT distribution comes with pre-generated buildvm_*.h files.
@ -214,6 +212,7 @@ TARGET_DYNXLDOPTS=
TARGET_XCFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U_FORTIFY_SOURCE TARGET_XCFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -U_FORTIFY_SOURCE
TARGET_XLDFLAGS= TARGET_XLDFLAGS=
TARGET_XLIBS= -lm TARGET_XLIBS= -lm
TARGET_TCFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS) TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_ARCH) $(TARGET_FLAGS) $(TARGET_CFLAGS)
TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS) TARGET_ALDFLAGS= $(LDOPTIONS) $(TARGET_XLDFLAGS) $(TARGET_FLAGS) $(TARGET_LDFLAGS)
TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS) TARGET_ASHLDFLAGS= $(LDOPTIONS) $(TARGET_XSHLDFLAGS) $(TARGET_FLAGS) $(TARGET_SHLDFLAGS)
@ -223,7 +222,7 @@ ifneq (,$(findstring stack-protector,$(shell $(TARGET_CC) -dumpspecs)))
TARGET_XCFLAGS+= -fno-stack-protector TARGET_XCFLAGS+= -fno-stack-protector
endif endif
TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_ACFLAGS) -E lj_arch.h -dM) TARGET_TESTARCH=$(shell $(TARGET_CC) $(TARGET_TCFLAGS) -E lj_arch.h -dM)
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH))) ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
TARGET_CCARCH= x64 TARGET_CCARCH= x64
TARGET_XCFLAGS+= $(CCOPT_X64) TARGET_XCFLAGS+= $(CCOPT_X64)
@ -251,6 +250,8 @@ endif
endif endif
endif endif
TARGET_ARCH= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_CCARCH))
ifneq (,$(PREFIX)) ifneq (,$(PREFIX))
ifneq (/usr/local,$(PREFIX)) ifneq (/usr/local,$(PREFIX))
TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\" TARGET_XCFLAGS+= -DLUA_XROOT=\"$(PREFIX)/\"