Skip to content

Commit

Permalink
auto merge of #9990 : Heather/rust/configure-changes, r=brson
Browse files Browse the repository at this point in the history
Re-created: #9760

Now, without adding `pc-linux-gnu` platform

Re-created: #9565

t will be useful for unix systems, some package managers and external tools that is passing / maybe looking for GNU configure syntax options.

One of related bugs: #5138

Also that could be useful in future if project will really install man pages / other stuff using those variables.
  • Loading branch information
bors committed Oct 25, 2013
2 parents dcdcd30 + 782cf04 commit f35de11
Show file tree
Hide file tree
Showing 19 changed files with 254 additions and 223 deletions.
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
80 changes: 55 additions & 25 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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,26 @@ 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 "${CFG_PREFIX}/share" "install data"
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
valopt libdir "${CFG_PREFIX}/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 @@ -589,23 +603,44 @@ 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 $CFG_TARGET;
do
echo "$V_TEMP" | grep -qF $i || V_TEMP="$V_TEMP${V_TEMP:+ }$i"
done
CFG_TARGET=$V_TEMP

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

# XXX: Support for deprecated syntax, should be dropped.
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

# 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 +699,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 +738,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 +820,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,20 +996,15 @@ 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

if [ ! -z "$CFG_ENABLE_PAX_FLAGS" ]
then
putvar CFG_ENABLE_PAX_FLAGS
putvar CFG_PAXCTL
fi
putvar CFG_MANDIR

# Avoid spurious warnings from clang by feeding it original source on
# ccache-miss rather than preprocessed input.
Expand Down Expand Up @@ -1015,7 +1045,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
22 changes: 11 additions & 11 deletions mk/clean.mk
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

CLEAN_STAGE_RULES = \
$(foreach stage, $(STAGES), \
$(foreach host, $(CFG_HOST_TRIPLES), \
$(foreach host, $(CFG_HOST), \
clean$(stage)_H_$(host) \
$(foreach target, $(CFG_TARGET_TRIPLES), \
$(foreach target, $(CFG_TARGET), \
clean$(stage)_T_$(target)_H_$(host))))

CLEAN_LLVM_RULES = \
$(foreach target, $(CFG_HOST_TRIPLES), \
$(foreach target, $(CFG_HOST), \
clean-llvm$(target))

.PHONY: clean clean-all clean-misc clean-llvm
Expand All @@ -33,17 +33,17 @@ clean: clean-misc $(CLEAN_STAGE_RULES)

clean-misc:
@$(call E, cleaning)
$(Q)find $(CFG_BUILD_TRIPLE)/rustllvm \
$(CFG_BUILD_TRIPLE)/rt \
$(CFG_BUILD_TRIPLE)/test \
$(Q)find $(CFG_BUILD)/rustllvm \
$(CFG_BUILD)/rt \
$(CFG_BUILD)/test \
-name '*.[odasS]' -o \
-name '*.so' -o \
-name '*.dylib' -o \
-name '*.dll' -o \
-name '*.def' -o \
-name '*.bc' \
| xargs rm -f
$(Q)find $(CFG_BUILD_TRIPLE)\
$(Q)find $(CFG_BUILD)\
-name '*.dSYM' \
| xargs rm -Rf
$(Q)rm -f $(RUNTIME_OBJS) $(RUNTIME_DEF)
Expand Down Expand Up @@ -86,7 +86,7 @@ clean$(1)_H_$(2):

endef

$(foreach host, $(CFG_HOST_TRIPLES), \
$(foreach host, $(CFG_HOST), \
$(eval $(foreach stage, $(STAGES), \
$(eval $(call CLEAN_HOST_STAGE_N,$(stage),$(host))))))

Expand Down Expand Up @@ -118,8 +118,8 @@ clean$(1)_T_$(2)_H_$(3):
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/run_pass_stage* # For windows
endef

$(foreach host, $(CFG_HOST_TRIPLES), \
$(eval $(foreach target, $(CFG_TARGET_TRIPLES), \
$(foreach host, $(CFG_HOST), \
$(eval $(foreach target, $(CFG_TARGET), \
$(eval $(foreach stage, 0 1 2 3, \
$(eval $(call CLEAN_TARGET_STAGE_N,$(stage),$(target),$(host))))))))

Expand All @@ -133,5 +133,5 @@ clean-llvm$(1): ;
endif
endef

$(foreach host, $(CFG_HOST_TRIPLES), \
$(foreach host, $(CFG_HOST), \
$(eval $(call DEF_CLEAN_LLVM_HOST,$(host))))
Loading

0 comments on commit f35de11

Please sign in to comment.