Allow cross-compilation with --cross-prefix.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
diff --git a/Makefile b/Makefile
index 147df92..223bdaa 100644
--- a/Makefile
+++ b/Makefile
@@ -31,8 +31,8 @@ dlfcn.o:
$(CC) -o dlfcn.o -c dlfcn.c -Wall -O3 -fomit-frame-pointer
libdl.a: dlfcn.o
- ar cru libdl.a dlfcn.o
- ranlib libdl.a
+ $(AR) cru libdl.a dlfcn.o
+ $(RANLIB) libdl.a
libdl.dll: dlfcn.o
$(CC) $(SHFLAGS) -shared -o libdl.dll dlfcn.o
diff --git a/configure b/configure
index 69ce2f3..df2b494 100755
--- a/configure
+++ b/configure
@@ -42,7 +42,8 @@ show_help(){
echo " --enable-msvc create msvc-compatible import lib [auto]"
echo " --enable-strip strip shared library [yes]"
echo
- echo " --cc=CC use C compiler CC [$cc]"
+ echo " --cc=CC use C compiler CC [$cc_default]"
+ echo " --cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]"
exit 1
}
@@ -55,7 +56,9 @@ die_unknown(){
PREFIX="/mingw"
libdir="${PREFIX}/lib"
incdir="${PREFIX}/include"
-cc="gcc"
+ar="ar"
+cc_default="gcc"
+ranlib="ranlib"
DEFAULT="msvc
"
@@ -93,6 +96,9 @@ for opt do
--cc=*)
cc="$optval"
;;
+ --cross-prefix=*)
+ cross_prefix="$optval"
+ ;;
--enable-?*|--disable-?*)
eval `echo "$opt" | sed 's/--/action=/;s/-/ option=/;s/-/_/g'`
echo "$CMDLINE_SELECT" | grep -q "^ *$option\$" || die_unknown $opt
@@ -104,6 +110,15 @@ for opt do
esac
done
+ar="${cross_prefix}${ar}"
+cc_default="${cross_prefix}${cc_default}"
+ranlib="${cross_prefix}${ranlib}"
+
+if ! test -z $cc; then
+ cc_default="${cc}"
+fi
+cc="${cc_default}"
+
disabled shared && disabled static && {
echo "At least one library type must be set.";
exit 1;
@@ -115,6 +130,7 @@ cat > /tmp/test.c << EOF
void function(void)
{ LoadLibrary(NULL); }
EOF
+echo testing compiler: $cc -shared -o /tmp/test.dll /tmp/test.c
$cc -shared -o /tmp/test.dll /tmp/test.c
test "$?" != 0 && {
@@ -144,7 +160,9 @@ echo "# Automatically generated by configure" > config.mak
echo "PREFIX=$PREFIX" >> config.mak
echo "libdir=$libdir" >> config.mak
echo "incdir=$incdir" >> config.mak
+echo "AR=$ar" >> config.mak
echo "CC=$cc" >> config.mak
+echo "RANLIB=$ranlib" >> config.mak
echo "BUILD_SHARED=$shared" >> config.mak
echo "BUILD_STATIC=$static" >> config.mak
echo "BUILD_MSVC=$msvc" >> config.mak
@@ -153,7 +171,9 @@ echo "DO_STRIP=$strip" >> config.mak
echo "prefix: $PREFIX"
echo "libdir: $libdir"
echo "incdir: $incdir"
+echo "ar: $ar"
echo "cc: $cc"
+echo "ranlib: $ranlib"
echo "static: $static"
echo "shared: $shared"
enabled shared && {