Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for GNU configure syntax #9760

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,22 @@ include config.mk
ALL_OBJ_FILES :=

MKFILE_DEPS := config.stamp $(call rwildcard,$(CFG_SRC_DIR)mk/,*)
NON_BUILD_HOST_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_HOST_TRIPLES))
NON_BUILD_TARGET_TRIPLES = $(filter-out $(CFG_BUILD_TRIPLE),$(CFG_TARGET_TRIPLES))
NON_BUILD_HOST = $(filter-out $(CFG_BUILD),$(CFG_HOST))
NON_BUILD_TARGET = $(filter-out $(CFG_BUILD),$(CFG_TARGET))

ifneq ($(MAKE_RESTARTS),)
CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
endif

CFG_INFO := $(info cfg: build triple $(CFG_BUILD_TRIPLE))
CFG_INFO := $(info cfg: host triples $(CFG_HOST_TRIPLES))
CFG_INFO := $(info cfg: target triples $(CFG_TARGET_TRIPLES))
CFG_INFO := $(info cfg: build triple $(CFG_BUILD))
CFG_INFO := $(info cfg: host triples $(CFG_HOST))
CFG_INFO := $(info cfg: target triples $(CFG_TARGET))

ifneq ($(wildcard $(NON_BUILD_HOST_TRIPLES)),)
CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST_TRIPLES))
ifneq ($(wildcard $(NON_BUILD_HOST)),)
CFG_INFO := $(info cfg: non-build host triples $(NON_BUILD_HOST))
endif
ifneq ($(wildcard $(NON_BUILD_TARGET_TRIPLES)),)
CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET_TRIPLES))
ifneq ($(wildcard $(NON_BUILD_TARGET)),)
CFG_INFO := $(info cfg: non-build target triples $(NON_BUILD_TARGET))
endif

CFG_RUSTC_FLAGS := $(RUSTFLAGS)
Expand Down Expand Up @@ -189,7 +189,7 @@ S := $(CFG_SRC_DIR)
define DEF_X
X_$(1) := $(CFG_EXE_SUFFIX_$(1))
endef
$(foreach target,$(CFG_TARGET_TRIPLES),\
$(foreach target,$(CFG_TARGET),\
$(eval $(call DEF_X,$(target))))

# Look in doc and src dirs.
Expand Down Expand Up @@ -270,7 +270,7 @@ define LIST_ALL_OLD_GLOB_MATCHES_EXCEPT
endef
endif

$(foreach target,$(CFG_TARGET_TRIPLES),\
$(foreach target,$(CFG_TARGET),\
$(eval $(call DEF_LIBS,$(target))))

######################################################################
Expand Down Expand Up @@ -336,7 +336,7 @@ LLC_$(1)=$$(CFG_LLVM_INST_DIR_$(1))/bin/llc$$(X_$(1))

endef

$(foreach host,$(CFG_HOST_TRIPLES), \
$(foreach host,$(CFG_HOST), \
$(eval $(call DEF_LLVM_VARS,$(host))))

######################################################################
Expand All @@ -350,7 +350,7 @@ export CFG_SRC_DIR
export CFG_BUILD_DIR
export CFG_VERSION
export CFG_VERSION_WIN
export CFG_BUILD_TRIPLE
export CFG_BUILD
export CFG_LLVM_ROOT
export CFG_ENABLE_MINGW_CROSS
export CFG_PREFIX
Expand Down Expand Up @@ -465,7 +465,7 @@ CFGFLAG$(1)_T_$(2)_H_$(3) = stage$(1)
# if you're building a cross config, the host->* parts are
# effectively stage1, since it uses the just-built stage0.
ifeq ($(1),0)
ifneq ($(strip $(CFG_BUILD_TRIPLE)),$(strip $(3)))
ifneq ($(strip $(CFG_BUILD)),$(strip $(3)))
CFGFLAG$(1)_T_$(2)_H_$(3) = stage1
endif
endif
Expand All @@ -488,8 +488,8 @@ PERF_STAGE$(1)_T_$(2)_H_$(3) := \

endef

$(foreach build,$(CFG_HOST_TRIPLES), \
$(eval $(foreach target,$(CFG_TARGET_TRIPLES), \
$(foreach build,$(CFG_HOST), \
$(eval $(foreach target,$(CFG_TARGET), \
$(eval $(foreach stage,$(STAGES), \
$(eval $(call SREQ,$(stage),$(target),$(build))))))))

Expand All @@ -504,34 +504,34 @@ define DEF_RUSTC_STAGE_TARGET
# $(2) == stage

rustc-stage$(2)-H-$(1): \
$$(foreach target,$$(CFG_TARGET_TRIPLES), \
$$(foreach target,$$(CFG_TARGET), \
$$(SREQ$(2)_T_$$(target)_H_$(1)))

endef

$(foreach host,$(CFG_HOST_TRIPLES), \
$(foreach host,$(CFG_HOST), \
$(eval $(foreach stage,1 2 3, \
$(eval $(call DEF_RUSTC_STAGE_TARGET,$(host),$(stage))))))

rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
rustc-stage3: rustc-stage3-H-$(CFG_BUILD)

define DEF_RUSTC_TARGET
# $(1) == architecture

rustc-H-$(1): rustc-stage2-H-$(1)
endef

$(foreach host,$(CFG_TARGET_TRIPLES), \
$(foreach host,$(CFG_TARGET), \
$(eval $(call DEF_RUSTC_TARGET,$(host))))

rustc-stage1: rustc-stage1-H-$(CFG_BUILD_TRIPLE)
rustc-stage2: rustc-stage2-H-$(CFG_BUILD_TRIPLE)
rustc-stage3: rustc-stage3-H-$(CFG_BUILD_TRIPLE)
rustc: rustc-H-$(CFG_BUILD_TRIPLE)
rustc-stage1: rustc-stage1-H-$(CFG_BUILD)
rustc-stage2: rustc-stage2-H-$(CFG_BUILD)
rustc-stage3: rustc-stage3-H-$(CFG_BUILD)
rustc: rustc-H-$(CFG_BUILD)

rustc-H-all: $(foreach host,$(CFG_HOST_TRIPLES),rustc-H-$(host))
rustc-H-all: $(foreach host,$(CFG_HOST),rustc-H-$(host))

######################################################################
# Entrypoint rule
Expand All @@ -547,12 +547,12 @@ CFG_INFO := $(info cfg: *** stage2 and later will not be built ***)
CFG_INFO := $(info cfg:)

#XXX This is surely busted
all: $(SREQ1$(CFG_BUILD_TRIPLE)) $(GENERATED) docs
all: $(SREQ1$(CFG_BUILD)) $(GENERATED) docs

else

define ALL_TARGET_N
ifneq ($$(findstring $(1),$$(CFG_HOST_TRIPLES)),)
ifneq ($$(findstring $(1),$$(CFG_HOST)),)
# This is a host
all-target-$(1)-host-$(2): $$(CSREQ2_T_$(1)_H_$(2))
else
Expand All @@ -561,12 +561,12 @@ all-target-$(1)-host-$(2): $$(SREQ2_T_$(1)_H_$(2))
endif
endef

$(foreach target,$(CFG_TARGET_TRIPLES), \
$(foreach host,$(CFG_HOST_TRIPLES), \
$(foreach target,$(CFG_TARGET), \
$(foreach host,$(CFG_HOST), \
$(eval $(call ALL_TARGET_N,$(target),$(host)))))

ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET_TRIPLES), \
$(foreach host,$(CFG_HOST_TRIPLES), \
ALL_TARGET_RULES = $(foreach target,$(CFG_TARGET), \
$(foreach host,$(CFG_HOST), \
all-target-$(target)-host-$(host)))

all: $(ALL_TARGET_RULES) $(GENERATED) docs
Expand Down
81 changes: 55 additions & 26 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ fi
case $CFG_OSTYPE in

Linux)
CFG_OSTYPE=unknown-linux-gnu
CFG_OSTYPE=pc-linux-gnu
;;

FreeBSD)
Expand Down Expand Up @@ -327,7 +327,7 @@ case $CFG_CPUTYPE in
esac

# Detect 64 bit linux systems with 32 bit userland and force 32 bit compilation
if [ $CFG_OSTYPE = unknown-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
if [ $CFG_OSTYPE = pc-linux-gnu -a $CFG_CPUTYPE = x86_64 ]
then
file -L "$SHELL" | grep -q "x86[_-]64"
if [ $? != 0 ]; then
Expand All @@ -336,7 +336,7 @@ then
fi


DEFAULT_BUILD_TRIPLE="${CFG_CPUTYPE}-${CFG_OSTYPE}"
DEFAULT_BUILD="${CFG_CPUTYPE}-${CFG_OSTYPE}"

CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
CFG_BUILD_DIR="$(pwd)/"
Expand Down Expand Up @@ -385,12 +385,25 @@ opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-
valopt prefix "/usr/local" "set installation prefix"
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
valopt llvm-root "" "set LLVM root"
valopt build-triple "${DEFAULT_BUILD_TRIPLE}" "LLVM build triple"
valopt host-triples "${CFG_BUILD_TRIPLE}" "LLVM host triples"
valopt target-triples "${CFG_HOST_TRIPLES}" "LLVM target triples"
valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path"
valopt mingw32-cross-path "" "MinGW32 cross compiler path"

valopt build "${DEFAULT_BUILD}" "GNUs ./configure syntax LLVM build triple"
valopt host "${CFG_BUILD}" "GNUs ./configure syntax LLVM host triples"
valopt target "${CFG_HOST}" "GNUs ./configure syntax LLVM target triples"

valopt localstatedir "/var/lib" "local state directory"
valopt sysconfdir "/etc" "install system configuration files"
valopt datadir "/usr/share" "install data"
valopt infodir "/usr/share/info" "install additional info"
valopt mandir "/usr/share/man" "install man pages in PATH"
valopt libdir "/usr/lib" "install libraries"

#Deprecated opts to keep compatibility
valopt build-triple "${DEFAULT_BUILD}" "LLVM build triple"
valopt host-triples "${CFG_BUILD}" "LLVM host triples"
valopt target-triples "${CFG_HOST}" "LLVM target triples"

# Validate Options
step_msg "validating $CFG_SELF args"
validate_opt
Expand Down Expand Up @@ -438,7 +451,7 @@ probe CFG_XETEX xetex
probe CFG_LUATEX luatex
probe CFG_NODE nodejs node
probe CFG_GDB gdb
if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
if [ "$CFG_OSTYPE" = "pc-linux-gnu" ]
then
probe CFG_PAXCTL paxctl /sbin/paxctl
probe CFG_ZCAT zcat
Expand All @@ -464,7 +477,7 @@ then
fi
fi

if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
if [ "$CFG_OSTYPE" = "pc-linux-gnu" ]
then
if [ ! -z "$CFG_ENABLE_PAX_FLAGS" -a -z "$CFG_PAXCTL" ]
then
Expand Down Expand Up @@ -589,23 +602,24 @@ fi
# a little post-processing of various config values

CFG_PREFIX=${CFG_PREFIX%/}
CFG_HOST_TRIPLES="$(echo $CFG_HOST_TRIPLES | tr ',' ' ')"
CFG_TARGET_TRIPLES="$(echo $CFG_TARGET_TRIPLES | tr ',' ' ')"
CFG_SUPPORTED_TARGET_TRIPLES="$(grep ^CC_*=* $CFG_SRC_DIR/mk/platform.mk | sed -e 's/^CC_//' -e 's/\([^=]*\).*/\1/' | xargs)"
CFG_MANDIR=${CFG_MANDIR%/}
CFG_HOST="$(echo $CFG_HOST | tr ',' ' ')"
CFG_TARGET="$(echo $CFG_TARGET | tr ',' ' ')"
CFG_SUPPORTED_TARGET="$(grep ^CC_*=* $CFG_SRC_DIR/mk/platform.mk | sed -e 's/^CC_//' -e 's/\([^=]*\).*/\1/' | xargs)"

# copy host-triples to target-triples so that hosts are a subset of targets
V_TEMP=""
for i in $CFG_HOST_TRIPLES $CFG_TARGET_TRIPLES;
for i in $CFG_HOST $CFG_TARGET;
do
echo "$V_TEMP" | grep -qF $i || V_TEMP="$V_TEMP${V_TEMP:+ }$i"
done
CFG_TARGET_TRIPLES=$V_TEMP
CFG_TARGET=$V_TEMP

# check target-specific tool-chains
for i in $CFG_TARGET_TRIPLES
for i in $CFG_TARGET
do
L_CHECK=false
for j in $CFG_SUPPORTED_TARGET_TRIPLES
for j in $CFG_SUPPORTED_TARGET
do
if [ $i = $j ]
then
Expand Down Expand Up @@ -664,17 +678,17 @@ do
make_dir $i
done

for t in $CFG_HOST_TRIPLES
for t in $CFG_HOST
do
make_dir $t/llvm
done

for t in $CFG_HOST_TRIPLES
for t in $CFG_HOST
do
make_dir $t/rustllvm
done

for t in $CFG_TARGET_TRIPLES
for t in $CFG_TARGET
do
make_dir $t/rt
for s in 0 1 2 3
Expand Down Expand Up @@ -703,9 +717,9 @@ then
CFG_LIBDIR=bin
fi

for h in $CFG_HOST_TRIPLES
for h in $CFG_HOST_
do
for t in $CFG_TARGET_TRIPLES
for t in $CFG_TARGET
do
for i in 0 1 2 3
do
Expand Down Expand Up @@ -785,7 +799,7 @@ fi
# Configure llvm, only if necessary
step_msg "looking at LLVM"
CFG_LLVM_SRC_DIR=${CFG_SRC_DIR}src/llvm/
for t in $CFG_HOST_TRIPLES
for t in $CFG_HOST
do
do_reconfigure=1

Expand Down Expand Up @@ -961,14 +975,29 @@ putvar CFG_OSTYPE
putvar CFG_CPUTYPE
putvar CFG_CONFIGURE_ARGS
putvar CFG_PREFIX
putvar CFG_BUILD_TRIPLE
putvar CFG_HOST_TRIPLES
putvar CFG_TARGET_TRIPLES
putvar CFG_BUILD
putvar CFG_HOST
putvar CFG_TARGET
putvar CFG_C_COMPILER
putvar CFG_LIBDIR
putvar CFG_DISABLE_MANAGE_SUBMODULES
putvar CFG_ANDROID_CROSS_PATH
putvar CFG_MINGW32_CROSS_PATH
putvar CFG_MANDIR

# Support for deprecated syntax, should be dropped.
putvar CFG_BUILD_TRIPLE
putvar CFG_HOST_TRIPLES
putvar CFG_TARGET_TRIPLES
if [ ! -z "$CFG_BUILD_TRIPLE" ]; then
CFG_BUILD=${CFG_BUILD_TRIPLE}
fi
if [ ! -z "$CFG_HOST_TRIPLES" ]; then
CFG_HOST=${CFG_HOST_TRIPLES}
fi
if [ ! -z "$CFG_TARGET_TRIPLES" ]; then
CFG_TARGET=${CFG_TARGET_TRIPLES}
fi

if [ ! -z "$CFG_ENABLE_PAX_FLAGS" ]
then
Expand Down Expand Up @@ -1006,7 +1035,7 @@ fi
# Valgrind is only reliable on Linux. On Windows it doesn't work at all, and
# on the Mac the dynamic linker causes Valgrind to emit a huge stream of
# errors.
if [ $CFG_OSTYPE != unknown-linux-gnu ] && [ $CFG_OSTYPE != apple-darwin ]
if [ $CFG_OSTYPE != pc-linux-gnu ] && [ $CFG_OSTYPE != apple-darwin ]
then
CFG_BAD_VALGRIND=1
putvar CFG_BAD_VALGRIND
Expand All @@ -1015,7 +1044,7 @@ fi
putvar CFG_LLVM_ROOT
putvar CFG_LLVM_SRC_DIR

for t in $CFG_HOST_TRIPLES
for t in $CFG_HOST
do
CFG_LLVM_BUILD_DIR=$(echo CFG_LLVM_BUILD_DIR_${t} | tr - _)
CFG_LLVM_INST_DIR=$(echo CFG_LLVM_INST_DIR_${t} | tr - _)
Expand Down
Loading