Permalink
Browse files

Expand our own config.guess-like logic in configure, rather than only…

… asking LLVM. We have to decide some things before we get an LLVM to ask.
  • Loading branch information...
1 parent f19ab1f commit 13215809a897b3b14eb8a078b8931bb01dba14ce @graydon graydon committed Sep 21, 2011
Showing with 56 additions and 6 deletions.
  1. +2 −1 Makefile.in
  2. +50 −1 configure
  3. +4 −4 mk/platform.mk
View
@@ -11,7 +11,8 @@ ifneq ($(MAKE_RESTARTS),)
CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
endif
-CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE))
+CFG_INFO := $(info cfg: shell host triple $(CFG_HOST_TRIPLE))
+CFG_INFO := $(info cfg: llvm host triple $(CFG_LLVM_TRIPLE))
ifdef CFG_DISABLE_OPTIMIZE
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
View
@@ -127,8 +127,8 @@ need_cmd sed
msg "inspecting environment"
CFG_OSTYPE=$(uname -s)
-
CFG_CPUTYPE=$(uname -m)
+
if [ $CFG_OSTYPE = Darwin -a $CFG_CPUTYPE = i386 ]
then
# Darwin's `uname -s` lies and always returns i386. We have to use sysctl
@@ -139,6 +139,54 @@ then
fi
fi
+
+# The goal here is to come up with the same triple as LLVM would,
+# at least for the subset of platforms we're willing to target.
+
+case $CFG_OSTYPE in
+
+ Linux)
+ CFG_OSTYPE=unknown-linux-gnu
+ ;;
+
+ FreeBSD)
+ CFG_OSTYPE=unknown-freebsd
+ ;;
+
+ Darwin)
+ CFG_OSTYPE=apple-darwin
+ ;;
+
+ MINGW32*)
+ CFG_OSTYPE=pc-mingw32
+ ;;
+
+ *)
+ err "unknown OS type: $CFG_OSTYPE"
+ ;;
+esac
+
+
+case $CFG_CPUTYPE in
+
+ i386 | i486 | i686 | i786 | x86)
+ CFG_CPUTYPE=i686
+ ;;
+
+ xscale | arm)
+ CFG_CPUTYPE=arm
+ ;;
+
+ x86_64 | x86-64 | x64)
+ CFG_CPUTYPE=x86_64
+ ;;
+
+ *)
+ err "unknown CPU type: $CFG_CPUTYPE"
+esac
+
+CFG_HOST_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"
+
CFG_SELF=$(echo $0 | tr '\\' '/')
CFG_SRC_DIR=${CFG_SELF%${CFG_SELF##*/}}
CFG_BUILD_DIR=$(echo $PWD | tr '\\' '/')
@@ -180,6 +228,7 @@ putvar CFG_SRC_DIR
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
+putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS
step_msg "looking for build programs"
View
@@ -7,7 +7,7 @@ CFG_GCCISH_LINK_FLAGS :=
# embedded into the executable, so use a no-op command.
CFG_DSYMUTIL := true
-ifeq ($(CFG_OSTYPE), FreeBSD)
+ifeq ($(findstring freebsd,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686 -I/usr/local/include
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -lpthread -lrt
@@ -20,7 +20,7 @@ ifeq ($(CFG_OSTYPE), FreeBSD)
CFG_DEF_SUFFIX := .bsd.def
endif
-ifeq ($(CFG_OSTYPE), Linux)
+ifneq ($(findstring linux,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).so
CFG_GCCISH_CFLAGS += -fPIC -march=i686
CFG_GCCISH_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
@@ -46,7 +46,7 @@ ifeq ($(CFG_OSTYPE), Linux)
endif
endif
-ifeq ($(CFG_OSTYPE), Darwin)
+ifneq ($(findstring darwin,$(CFG_OSTYPE)),)
CFG_LIB_NAME=lib$(1).dylib
CFG_UNIXY := 1
CFG_LDENV := DYLD_LIBRARY_PATH
@@ -69,7 +69,7 @@ ifeq ($(CFG_OSTYPE), Darwin)
CFG_DEF_SUFFIX := .darwin.def
endif
-ifneq ($(findstring MINGW,$(CFG_OSTYPE)),)
+ifneq ($(findstring mingw,$(CFG_OSTYPE)),)
CFG_WINDOWSY := 1
endif

0 comments on commit 1321580

Please sign in to comment.