msg
}
+warn() {
+ echo "configure: WARNING: $1"
+}
+
err() {
echo "configure: error: $1"
exit 1
putvar CFG_BUILD_DIR
putvar CFG_OSTYPE
putvar CFG_CPUTYPE
-putvar CFG_HOST_TRIPLE
putvar CFG_CONFIGURE_ARGS
step_msg "looking for build programs"
else
CFG_C_COMPILER="gcc"
fi
+
+if [ ! -z "$CFG_LLVM_TRIPLE" ]
+then
+ if [ $CFG_HOST_TRIPLE != $CFG_LLVM_TRIPLE ]
+ then
+ warn "LLVM host-triple $CFG_LLVM_TRIPLE differs from"
+ warn "detected host triple $CFG_HOST_TRIPLE"
+ warn "choosing LLVM host-triple instead"
+ msg ""
+ CFG_HOST_TRIPLE=$CFG_LLVM_TRIPLE
+ fi
+fi
+
+# FIXME: add support for extending the target-triples list
+CFG_TARGET_TRIPLES="${CFG_HOST_TRIPLE}"
+
+putvar CFG_HOST_TRIPLE
+putvar CFG_TARGET_TRIPLES
+
+
putvar CFG_C_COMPILER
putvar CFG_LLVM_ROOT
doc \
rt rt/isaac rt/bigint rt/sync rt/test rt/arch/i386 \
rt/libuv rt/libuv/src/ares rt/libuv/src/eio rt/libuv/src/ev \
- rustllvm \
- dl stage{0,1,2,3}{,/lib,/lib/$CFG_LLVM_TRIPLE} \
+ rustllvm dl \
test/run-pass test/run-fail test/compile-fail \
test/bench test/perf test/pretty
do
make_dir $i
done
+for t in $CFG_TARGET_TRIPLES
+do
+ for i in 0 1 2 3
+ do
+ # old-style "bin" dir
+ make_dir stage$i
+
+ # new-style bin dir, not yet used
+ make_dir stage$i/bin
+
+ # old-style non-arch libs
+ make_dir stage$i/lib
+
+ # new-style arch-prefixed libs, not yet used
+ make_dir stage$i/lib/rustc/$t
+ done
+done
+
copy ${CFG_SRC_DIR}Makefile.in ./Makefile
copy ${CFG_SRC_DIR}src/rt/libuv/Makefile rt/libuv/Makefile
-# StageN template: arg 1 is the N we're building *from*, arg 2 is N+1.
+# STAGE_N template: arg 1 is the N we're building *from*, arg 2 is N+1, arg 3
+# is the target triple we're building for. You have to invoke this for each
+# target triple.
#
# The easiest way to read this template is to assume we're building stage2
# using stage1, and mentally gloss $(1) as 1, $(2) as 2.
#
-# LIBGEN is pulled out seperately because we need to specially invoke
+# TARGET_LIBS is pulled out seperately because we need to specially invoke
# it to build stage0/lib/libstd using stage0/rustc and to use the
# new rustrt in stage0/lib/.
-define LIBGEN
-stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
- stage$(2)/rustc$$(X) \
- stage$(2)/$$(CFG_RUNTIME) \
- stage$(2)/$$(CFG_RUSTLLVM) \
- stage$(2)/lib/glue.o \
- $$(SREQ$(1))
- @$$(call E, compile_and_link: $$@)
- $$(STAGE$(2)) --lib -o $$@ $$<
-
-stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
- stage$(2)/rustc$$(X) \
- stage$(2)/$$(CFG_RUNTIME) \
- stage$(2)/$$(CFG_RUSTLLVM) \
- stage$(2)/lib/glue.o \
- $$(SREQ$(1))
- @$$(call E, compile_and_link: $$@)
- $$(STAGE$(2)) --lib --static -o $$@ $$<
-
-stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
- @$$(call E, cp: $$@)
- $$(Q)cp $$< $$@
-
-endef
-
-define STAGEN
+define STAGE_N
# Host libraries and executables (stage$(2)/rustc and its runtime needs)
#
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
+# Expand out target libraries
-# Target libraries (for binaries generated by stage$(2)/rustc)
+$(eval $(call TARGET_LIBS,$(1),$(2),$(3)))
+endef
+
+
+define TARGET_LIBS
stage$(2)/lib/intrinsics.bc: $$(INTRINSICS_BC)
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@$$(call E, generate: $$@)
$$(STAGE$(2)) -c -o $$@ --glue
-$(eval $(call LIBGEN,$(1),$(2)))
-
stage$(2)/lib/main.o: rt/main.o
@$$(call E, cp: $$@)
$$(Q)cp $$< $$@
@$$(call E, compile_and_link: $$@)
$$(STAGE$(2)) --lib -o $$@ $$<
+stage$(2)/lib/$$(CFG_STDLIB): $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+ stage$(2)/rustc$$(X) \
+ stage$(2)/$$(CFG_RUNTIME) \
+ stage$(2)/$$(CFG_RUSTLLVM) \
+ stage$(2)/lib/glue.o \
+ $$(SREQ$(1))
+ @$$(call E, compile_and_link: $$@)
+ $$(STAGE$(2)) --lib -o $$@ $$<
+
+stage$(2)/lib/libstd.rlib: $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+ stage$(2)/rustc$$(X) \
+ stage$(2)/$$(CFG_RUNTIME) \
+ stage$(2)/$$(CFG_RUSTLLVM) \
+ stage$(2)/lib/glue.o \
+ $$(SREQ$(1))
+ @$$(call E, compile_and_link: $$@)
+ $$(STAGE$(2)) --lib --static -o $$@ $$<
+
+stage$(2)/lib/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
+ @$$(call E, cp: $$@)
+ $$(Q)cp $$< $$@
+
+
+# New per-target-arch target libraries; when we've transitioned to
+# using these exclusively, you should delete the non-arch-prefixed
+# rules above. They're duplicates, redundant.
+
+stage$(2)/lib/rustc/$(3)/intrinsics.bc: $$(INTRINSICS_BC)
+ @$$(call E, cp: $$@)
+ $$(Q)cp $$< $$@
+
+stage$(2)/lib/rustc/$(3)/glue.o: \
+ stage$(2)/rustc$$(X) \
+ stage$(2)/$$(CFG_RUNTIME) \
+ stage$(2)/$$(CFG_RUSTLLVM) \
+ stage$(2)/lib/intrinsics.bc \
+ $$(SREQ$(1))
+ @$$(call E, generate: $$@)
+ $$(STAGE$(2)) -c -o $$@ --glue
+
+stage$(2)/lib/rustc/$(3)/main.o: rt/main.o
+ @$$(call E, cp: $$@)
+ $$(Q)cp $$< $$@
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_LIBRUSTC): \
+ $$(COMPILER_CRATE) $$(COMPILER_INPUTS) \
+ $$(SREQ$(2))
+ @$$(call E, compile_and_link: $$@)
+ $$(STAGE$(2)) --lib -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_STDLIB): \
+ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+ stage$(2)/rustc$$(X) \
+ stage$(2)/$$(CFG_RUNTIME) \
+ stage$(2)/$$(CFG_RUSTLLVM) \
+ stage$(2)/lib/rustc/$(3)/glue.o \
+ $$(SREQ$(1))
+ @$$(call E, compile_and_link: $$@)
+ $$(STAGE$(2)) --lib -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/libstd.rlib: \
+ $$(STDLIB_CRATE) $$(STDLIB_INPUTS) \
+ stage$(2)/rustc$$(X) \
+ stage$(2)/$$(CFG_RUNTIME) \
+ stage$(2)/$$(CFG_RUSTLLVM) \
+ stage$(2)/lib/rustc/$(3)/glue.o \
+ $$(SREQ$(1))
+ @$$(call E, compile_and_link: $$@)
+ $$(STAGE$(2)) --lib --static -o $$@ $$<
+
+stage$(2)/lib/rustc/$(3)/$$(CFG_RUNTIME): rt/$$(CFG_RUNTIME)
+ @$$(call E, cp: $$@)
+ $$(Q)cp $$< $$@
+
endef
-# Instantiate template for 0->1, 1->2, 2->3 build dirs
-$(eval $(call STAGEN,0,1))
-$(eval $(call STAGEN,1,2))
-$(eval $(call STAGEN,2,3))
+
+# Instantiate template for 0->1, 1->2, 2->3 build dirs
+$(foreach target,$(CFG_TARGET_TRIPLES), \
+ $(eval $(call STAGE_N,0,1,$(target))) \
+ $(eval $(call STAGE_N,1,2,$(target))) \
+ $(eval $(call STAGE_N,2,3,$(target))))