2011-03-16 11:17:32 -05:00
|
|
|
######################################################################
|
|
|
|
# Residual auto-configuration
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
include config.mk
|
|
|
|
MKFILES := Makefile config.mk
|
|
|
|
|
|
|
|
ifneq ($(MAKE_RESTARTS),)
|
|
|
|
CFG_INFO := $(info cfg: make restarts: $(MAKE_RESTARTS))
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFG_INFO := $(info cfg: building on $(CFG_OSTYPE) $(CFG_CPUTYPE))
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
CFG_GCC_CFLAGS :=
|
|
|
|
CFG_GCC_LINK_FLAGS :=
|
|
|
|
CFG_BOOT_FLAGS := $(BOOT_FLAGS)
|
|
|
|
CFG_RUSTC_FLAGS := -nowarn
|
|
|
|
|
|
|
|
# On Darwin, we need to run dsymutil so the debugging information ends
|
|
|
|
# up in the right place. On other platforms, it automatically gets
|
|
|
|
# embedded into the executable, so use a no-op command.
|
|
|
|
CFG_DSYMUTIL := true
|
|
|
|
|
|
|
|
ifeq ($(CFG_OSTYPE), FreeBSD)
|
2011-03-18 18:05:56 -05:00
|
|
|
CFG_LIB_NAME=lib$(1).so
|
2011-03-18 01:51:45 -05:00
|
|
|
CFG_GCC_CFLAGS += -fPIC -march=i686 -I/usr/local/include
|
|
|
|
CFG_GCC_LINK_FLAGS += -shared -fPIC -lpthread -lrt
|
|
|
|
ifeq ($(CFG_CPUTYPE), x86_64)
|
|
|
|
CFG_GCC_CFLAGS += -m32
|
|
|
|
CFG_GCC_LINK_FLAGS += -m32
|
|
|
|
endif
|
|
|
|
CFG_UNIXY := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CFG_OSTYPE), Linux)
|
2011-03-18 18:05:56 -05:00
|
|
|
CFG_LIB_NAME=lib$(1).so
|
2011-03-18 01:51:45 -05:00
|
|
|
CFG_GCC_CFLAGS += -fPIC -march=i686
|
|
|
|
CFG_GCC_LINK_FLAGS += -shared -fPIC -ldl -lpthread -lrt
|
|
|
|
ifeq ($(CFG_CPUTYPE), x86_64)
|
|
|
|
CFG_GCC_CFLAGS += -m32
|
|
|
|
CFG_GCC_LINK_FLAGS += -m32
|
|
|
|
endif
|
|
|
|
CFG_UNIXY := 1
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(CFG_OSTYPE), Darwin)
|
2011-03-18 18:05:56 -05:00
|
|
|
CFG_LIB_NAME=lib$(1).dylib
|
2011-03-18 01:51:45 -05:00
|
|
|
CFG_UNIXY := 1
|
|
|
|
CFG_GCC_LINK_FLAGS += -dynamiclib -lpthread
|
|
|
|
# Darwin has a very blurry notion of "64 bit", and claims it's running
|
|
|
|
# "on an i386" when the whole userspace is 64-bit and the compiler
|
|
|
|
# emits 64-bit binaries by default. So we just force -m32 here. Smarter
|
|
|
|
# approaches welcome!
|
|
|
|
CFG_GCC_CFLAGS += -m32
|
|
|
|
CFG_GCC_LINK_FLAGS += -m32
|
|
|
|
CFG_DSYMUTIL := dsymutil
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq ($(findstring MINGW,$(CFG_OSTYPE)),)
|
|
|
|
CFG_WINDOWSY := 1
|
|
|
|
endif
|
|
|
|
|
2011-03-19 20:34:19 -05:00
|
|
|
CFG_LDPATH :=$(CFG_BUILD_DIR)/rt
|
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_BUILD_DIR)/llvmext
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef CFG_WINDOWSY
|
|
|
|
CFG_INFO := $(info cfg: windows-y environment)
|
|
|
|
|
|
|
|
CFG_EXE_SUFFIX := .exe
|
|
|
|
CFG_LIB_NAME=$(1).dll
|
2011-03-19 20:34:19 -05:00
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_BINDIR)
|
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$$PATH
|
2011-03-20 03:12:26 -05:00
|
|
|
CFG_RUN_TARG=PATH=$(CFG_LDPATH) $(1)
|
2011-03-18 01:51:45 -05:00
|
|
|
|
2011-03-19 20:33:16 -05:00
|
|
|
CFG_PATH_MUNGE := $(strip | perl -p \
|
|
|
|
-e 's@\\(.)@/\1@go;' \
|
|
|
|
-e 's@^/([a-zA-Z])/@\1:/@o;')
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef CFG_FLEXLINK
|
|
|
|
CFG_BOOT_NATIVE := 1
|
|
|
|
endif
|
|
|
|
CFG_GCC_CFLAGS += -march=i686
|
|
|
|
CFG_GCC_LINK_FLAGS += -shared -fPIC
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef CFG_UNIXY
|
|
|
|
CFG_INFO := $(info cfg: unix-y environment)
|
|
|
|
|
|
|
|
CFG_EXE_SUFFIX :=
|
2011-03-19 20:34:19 -05:00
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_LIBDIR)
|
2011-03-20 03:12:26 -05:00
|
|
|
CFG_RUN_TARG=\
|
2011-03-19 20:34:19 -05:00
|
|
|
LD_LIBRARY_PATH=$(dir $(1)):$(CFG_LDPATH) $(CFG_VALGRIND) $(1)
|
2011-03-18 01:51:45 -05:00
|
|
|
|
|
|
|
CFG_BOOT_NATIVE := 1
|
|
|
|
|
|
|
|
ifdef MINGW_CROSS
|
|
|
|
CFG_EXE_SUFFIX := .exe
|
|
|
|
CFG_LIB_NAME=$(1).dll
|
2011-03-19 20:34:19 -05:00
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$(CFG_LLVM_BINDIR)
|
|
|
|
CFG_LDPATH :=$(CFG_LDPATH):$$PATH
|
2011-03-20 03:12:26 -05:00
|
|
|
CFG_RUN_TARG=PATH=$(CFG_LDPATH) $(1)
|
2011-03-18 01:51:45 -05:00
|
|
|
|
|
|
|
CFG_INFO := $(info cfg: mingw-cross)
|
|
|
|
CFG_GCC_CROSS := i586-mingw32msvc-
|
|
|
|
CFG_BOOT_FLAGS += -t win32-x86-pe
|
|
|
|
ifdef CFG_VALGRIND
|
|
|
|
CFG_VALGRIND += wine
|
|
|
|
endif
|
|
|
|
CFG_GCC_CFLAGS := -march=i686
|
|
|
|
CFG_GCC_LINK_FLAGS := -shared
|
|
|
|
ifeq ($(CFG_CPUTYPE), x86_64)
|
|
|
|
CFG_GCC_CFLAGS += -m32
|
|
|
|
CFG_GCC_LINK_FLAGS += -m32
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
ifdef CFG_VALGRIND
|
|
|
|
CFG_VALGRIND += --leak-check=full \
|
|
|
|
--error-exitcode=1 \
|
|
|
|
--quiet --vex-iropt-level=0 \
|
2011-03-18 20:32:31 -05:00
|
|
|
--suppressions=$(S)src/etc/x86.supp
|
2011-03-18 01:51:45 -05:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
|
|
|
|
CFG_LLVMEXT :=$(call CFG_LIB_NAME,llvmext)
|
|
|
|
CFG_STDLIB :=$(call CFG_LIB_NAME,std)
|
|
|
|
|
2011-03-18 20:32:31 -05:00
|
|
|
CFG_LLC_CFLAGS := -march=x86
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef CFG_GCC
|
|
|
|
CFG_INFO := $(info cfg: using gcc)
|
|
|
|
CFG_GCC_CFLAGS += -Wall -Werror -fno-rtti -fno-exceptions -g
|
|
|
|
CFG_GCC_LINK_FLAGS += -g
|
|
|
|
CFG_COMPILE_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_CFLAGS) -c -o $(1) $(2)
|
|
|
|
CFG_LINK_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_LINK_FLAGS) -o $(1)
|
|
|
|
CFG_DEPEND_C = $(CFG_GCC_CROSS)g++ $(CFG_GCC_CFLAGS) -MT "$(1)" -MM $(2)
|
|
|
|
else
|
|
|
|
CFG_ERR := $(error please try on a system with gcc)
|
|
|
|
endif
|
|
|
|
|
2011-03-16 11:17:32 -05:00
|
|
|
ifdef CFG_OCAMLC_OPT
|
2011-03-18 01:51:45 -05:00
|
|
|
$(info cfg: have ocaml native compiler)
|
2011-03-16 11:17:32 -05:00
|
|
|
OPT=.opt
|
|
|
|
else
|
2011-03-18 01:51:45 -05:00
|
|
|
$(info cfg: have only ocaml bytecode compiler)
|
2011-03-16 11:17:32 -05:00
|
|
|
endif
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef BOOT_PROFILE
|
|
|
|
$(info cfg: forcing native bootstrap compiler (BOOT_PROFILE))
|
|
|
|
CFG_BOOT_NATIVE := 1
|
2011-03-16 11:17:32 -05:00
|
|
|
CFG_OCAMLOPT_PROFILE_FLAGS := -p
|
|
|
|
endif
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef BOOT_DEBUG
|
|
|
|
$(info cfg: forcing bytecode bootstrap compiler (DEBUG))
|
|
|
|
CFG_BOOT_NATIVE :=
|
2011-03-16 11:17:32 -05:00
|
|
|
endif
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
ifdef CFG_BOOT_NATIVE
|
2011-03-16 11:17:32 -05:00
|
|
|
$(info cfg: building native bootstrap compiler)
|
|
|
|
else
|
|
|
|
$(info cfg: building bytecode bootstrap compiler)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef NO_VALGRIND
|
2011-03-18 01:51:45 -05:00
|
|
|
$(info cfg: disabling valgrind (NO_VALGRIND))
|
|
|
|
CFG_VALGRIND :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Target-and-rule "utility variables"
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
ifdef VERBOSE
|
|
|
|
Q :=
|
|
|
|
E =
|
|
|
|
else
|
|
|
|
Q := @
|
|
|
|
E = echo $(1)
|
2011-03-16 11:17:32 -05:00
|
|
|
endif
|
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
R := $(CFG_RUN_TARG)
|
2011-03-18 01:51:45 -05:00
|
|
|
S := $(CFG_SRC_DIR)
|
|
|
|
X := $(CFG_EXE_SUFFIX)
|
|
|
|
|
|
|
|
# Look in doc and src dirs.
|
|
|
|
VPATH := $(S)doc $(S)src
|
|
|
|
|
|
|
|
# Compilers we build, we now know how to run.
|
2011-03-20 21:42:27 -05:00
|
|
|
BOOT := $(Q)OCAMLRUNPARAM="b1" boot/rustboot$(X) $(CFG_BOOT_FLAGS) -L boot
|
|
|
|
STAGE0 := $(Q)$(CFG_RUN_TARG) stage0/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage0
|
|
|
|
STAGE1 := $(Q)$(CFG_RUN_TARG) stage1/rustc$(X) $(CFG_RUSTC_FLAGS) -L stage1
|
2011-03-18 01:51:45 -05:00
|
|
|
|
|
|
|
# "Source" files we generate in builddir along the way.
|
|
|
|
GENERATED := boot/fe/lexer.ml boot/version.ml
|
|
|
|
|
|
|
|
# Delete the built-in rules.
|
|
|
|
.SUFFIXES:
|
|
|
|
%:: %,v
|
|
|
|
%:: RCS/%,v
|
|
|
|
%:: RCS/%
|
|
|
|
%:: s.%
|
|
|
|
%:: SCCS/s.%
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Bootstrap compiler variables
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# We must list them in link order.
|
|
|
|
# Nobody calculates the link-order DAG automatically, sadly.
|
|
|
|
|
|
|
|
BOOT_MLS := \
|
|
|
|
$(addsuffix .ml, \
|
2011-03-17 16:26:24 -05:00
|
|
|
boot/version \
|
|
|
|
$(addprefix boot/util/, fmt common bits) \
|
2011-03-16 11:17:32 -05:00
|
|
|
$(addprefix boot/driver/, session) \
|
|
|
|
$(addprefix boot/fe/, ast token lexer parser \
|
|
|
|
extfmt pexp item cexp fuzz) \
|
|
|
|
$(addprefix boot/be/, asm il abi) \
|
|
|
|
$(addprefix boot/me/, walk semant resolve alias \
|
|
|
|
simplify type dead layer effect typestate \
|
|
|
|
loop layout transutil trans dwarf) \
|
|
|
|
$(addprefix boot/be/, x86 ra pe elf macho) \
|
|
|
|
$(addprefix boot/driver/, lib glue main)) \
|
|
|
|
|
|
|
|
BOOT_CMOS := $(BOOT_MLS:.ml=.cmo)
|
|
|
|
BOOT_CMXS := $(BOOT_MLS:.ml=.cmx)
|
|
|
|
BOOT_OBJS := $(BOOT_MLS:.ml=.o)
|
|
|
|
BOOT_CMIS := $(BOOT_MLS:.ml=.cmi)
|
|
|
|
|
2011-03-18 19:30:06 -05:00
|
|
|
BS := $(S)src/boot/
|
2011-03-18 01:51:45 -05:00
|
|
|
|
|
|
|
BOOT_ML_DEP_INCS := -I $(BS)/fe -I $(BS)/me \
|
|
|
|
-I $(BS)/be -I $(BS)/driver \
|
|
|
|
-I $(BS)/util -I boot
|
|
|
|
|
|
|
|
BOOT_ML_INCS := -I boot/fe -I boot/me \
|
|
|
|
-I boot/be -I boot/driver \
|
|
|
|
-I boot/util -I boot
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
BOOT_ML_LIBS := unix.cma nums.cma bigarray.cma
|
|
|
|
BOOT_ML_NATIVE_LIBS := unix.cmxa nums.cmxa bigarray.cmxa
|
|
|
|
BOOT_OCAMLC_FLAGS := -g $(BOOT_ML_INCS) -w Ael -warn-error Ael
|
2011-03-18 01:51:45 -05:00
|
|
|
BOOT_OCAMLOPT_FLAGS := -g $(BOOT_ML_INCS) -w Ael -warn-error Ael
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Runtime (C++) library variables
|
|
|
|
######################################################################
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
RUNTIME_CS := rt/sync/timer.cpp \
|
|
|
|
rt/sync/sync.cpp \
|
|
|
|
rt/sync/lock_and_signal.cpp \
|
|
|
|
rt/rust.cpp \
|
|
|
|
rt/rust_builtin.cpp \
|
|
|
|
rt/rust_run_program.cpp \
|
|
|
|
rt/rust_crate.cpp \
|
|
|
|
rt/rust_crate_cache.cpp \
|
|
|
|
rt/rust_crate_reader.cpp \
|
|
|
|
rt/rust_comm.cpp \
|
|
|
|
rt/rust_dom.cpp \
|
|
|
|
rt/rust_task.cpp \
|
|
|
|
rt/rust_task_list.cpp \
|
|
|
|
rt/rust_proxy.cpp \
|
|
|
|
rt/rust_chan.cpp \
|
|
|
|
rt/rust_port.cpp \
|
|
|
|
rt/rust_upcall.cpp \
|
|
|
|
rt/rust_log.cpp \
|
|
|
|
rt/rust_message.cpp \
|
|
|
|
rt/rust_timer.cpp \
|
|
|
|
rt/circular_buffer.cpp \
|
|
|
|
rt/isaac/randport.cpp \
|
|
|
|
rt/rust_srv.cpp \
|
|
|
|
rt/rust_kernel.cpp \
|
|
|
|
rt/memory_region.cpp \
|
|
|
|
rt/test/rust_test_harness.cpp \
|
|
|
|
rt/test/rust_test_runtime.cpp \
|
|
|
|
rt/test/rust_test_util.cpp
|
|
|
|
|
|
|
|
RUNTIME_HDR := rt/globals.h \
|
|
|
|
rt/rust.h \
|
|
|
|
rt/rust_dwarf.h \
|
|
|
|
rt/rust_internal.h \
|
|
|
|
rt/rust_util.h \
|
|
|
|
rt/rust_chan.h \
|
|
|
|
rt/rust_port.h \
|
|
|
|
rt/rust_dom.h \
|
|
|
|
rt/rust_task.h \
|
|
|
|
rt/rust_task_list.h \
|
|
|
|
rt/rust_proxy.h \
|
|
|
|
rt/rust_log.h \
|
|
|
|
rt/rust_message.h \
|
|
|
|
rt/circular_buffer.h \
|
|
|
|
rt/util/array_list.h \
|
|
|
|
rt/util/indexed_list.h \
|
|
|
|
rt/util/synchronized_indexed_list.h \
|
|
|
|
rt/util/hash_map.h \
|
|
|
|
rt/sync/sync.h \
|
|
|
|
rt/sync/timer.h \
|
|
|
|
rt/sync/lock_free_queue.h \
|
|
|
|
rt/rust_srv.h \
|
|
|
|
rt/rust_kernel.h \
|
|
|
|
rt/memory_region.h \
|
|
|
|
rt/memory.h \
|
|
|
|
rt/test/rust_test_harness.h \
|
|
|
|
rt/test/rust_test_runtime.h \
|
|
|
|
rt/test/rust_test_util.h
|
|
|
|
|
|
|
|
RUNTIME_INCS := -I $(S)src/rt/isaac -I $(S)src/rt/uthash
|
|
|
|
RUNTIME_OBJS := $(RUNTIME_CS:.cpp=.o)
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
######################################################################
|
2011-03-18 01:51:45 -05:00
|
|
|
# rustc LLVM-extensions (C++) library variables
|
2011-03-16 11:17:32 -05:00
|
|
|
######################################################################
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
LLVMEXT_CS := $(addprefix llvmext/, \
|
|
|
|
MachOObjectFile.cpp Object.cpp RustWrapper.cpp)
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
LLVMEXT_HDR := llvmext/include/llvm-c/Object.h
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-18 18:23:35 -05:00
|
|
|
LLVMEXT_INCS := -iquote $(CFG_LLVM_INCDIR) \
|
2011-03-18 19:30:06 -05:00
|
|
|
-iquote $(S)src/llvmext/include
|
2011-03-18 01:51:45 -05:00
|
|
|
LLVMEXT_OBJS := $(LLVMEXT_CS:.cpp=.o)
|
|
|
|
LLVMEXT_LIBS := $(CFG_LLVM_LDFLAGS) $(CFG_LLVM_LIBS)
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
######################################################################
|
|
|
|
# Standard library variables
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
STDLIB_CRATE := lib/std.rc
|
|
|
|
STDLIB_INPUTS := $(wildcard $(addprefix $(S)src/lib/,*.rc *.rs */*.rs))
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
######################################################################
|
2011-03-18 01:51:45 -05:00
|
|
|
# rustc crate variables
|
2011-03-16 11:17:32 -05:00
|
|
|
######################################################################
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
COMPILER_CRATE := comp/rustc.rc
|
2011-03-18 19:30:06 -05:00
|
|
|
COMPILER_INPUTS := $(wildcard $(addprefix $(S)src/comp/, \
|
2011-03-18 01:51:45 -05:00
|
|
|
rustc.rc *.rs */*.rs))
|
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
######################################################################
|
|
|
|
# test dependency variables
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
LREQ := rt/$(CFG_RUNTIME) llvmext/$(CFG_LLVMEXT)
|
|
|
|
BREQ := boot/rustboot$(X) boot/$(CFG_STDLIB)
|
|
|
|
SREQ0 := stage0/rustc$(X) $(LREQ)
|
|
|
|
SREQ1 := stage1/rustc$(X) $(LREQ)
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
######################################################################
|
|
|
|
# Single-target rules
|
|
|
|
######################################################################
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-18 19:41:32 -05:00
|
|
|
all: boot/rustboot$(X) \
|
2011-03-20 03:12:26 -05:00
|
|
|
boot/$(CFG_STDLIB) \
|
2011-03-18 19:41:32 -05:00
|
|
|
rt/$(CFG_RUNTIME) \
|
|
|
|
llvmext/$(CFG_LLVMEXT) \
|
|
|
|
stage0/rustc$(X) \
|
2011-03-18 20:32:31 -05:00
|
|
|
stage0/glue.o \
|
2011-03-20 03:12:26 -05:00
|
|
|
stage0/$(CFG_STDLIB) \
|
2011-03-18 19:41:32 -05:00
|
|
|
$(GENERATED)
|
2011-03-18 01:51:45 -05:00
|
|
|
|
|
|
|
rt/$(CFG_RUNTIME): $(RUNTIME_OBJS) $(MKFILES) $(RUNTIME_HDR)
|
|
|
|
@$(call E, link: $@)
|
|
|
|
$(Q)$(call CFG_LINK_C, $@) $(RUNTIME_OBJS)
|
|
|
|
|
|
|
|
llvmext/$(CFG_LLVMEXT): $(LLVMEXT_OBJS) $(MKFILES) $(LLVMEXT_HDR)
|
|
|
|
@$(call E, link: $@)
|
|
|
|
$(Q)$(call CFG_LINK_C, $@ $(LLVMEXT_OBJS) \
|
|
|
|
$(CFG_LLVM_LIBS) $(CFG_LLVM_LDFLAGS))
|
|
|
|
|
|
|
|
ifdef CFG_BOOT_NATIVE
|
2011-03-17 16:26:24 -05:00
|
|
|
boot/rustboot$(X): $(BOOT_CMXS) $(MKFILES)
|
2011-03-18 01:51:45 -05:00
|
|
|
@$(call E, link: $@)
|
|
|
|
$(Q)ocamlopt$(OPT) -o $@ $(BOOT_OCAMLOPT_FLAGS) $(BOOT_ML_NATIVE_LIBS) \
|
2011-03-16 11:17:32 -05:00
|
|
|
$(BOOT_CMXS)
|
|
|
|
else
|
2011-03-17 16:26:24 -05:00
|
|
|
boot/rustboot$(X): $(BOOT_CMOS) $(MKFILES)
|
2011-03-18 01:51:45 -05:00
|
|
|
@$(call E, link: $@)
|
2011-03-17 16:26:24 -05:00
|
|
|
$(Q)ocamlc$(OPT) -o $@ $(BOOT_OCAMLC_FLAGS) $(BOOT_ML_LIBS) $(BOOT_CMOS)
|
2011-03-16 11:17:32 -05:00
|
|
|
endif
|
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
boot/version.ml: $(MKFILES)
|
|
|
|
@$(call E, git: $@)
|
2011-03-16 11:17:32 -05:00
|
|
|
$(Q)git log -1 \
|
|
|
|
--pretty=format:'let version = "prerelease (%h %ci)";;' >$@ || exit 1
|
|
|
|
|
2011-03-20 00:55:28 -05:00
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
boot/$(CFG_STDLIB): $(S)src/$(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
|
|
|
boot/rustboot$(X) $(MKFILES)
|
2011-03-18 19:41:32 -05:00
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(BOOT) -shared -o $@ $<
|
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
stage0/$(CFG_STDLIB): $(S)src/$(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
2011-03-20 00:55:28 -05:00
|
|
|
stage0/rustc$(X) $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(STAGE0) -shared -o $@ $<
|
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
stage1/$(CFG_STDLIB): $(S)src/$(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
|
|
|
stage1/rustc$(X) $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(STAGE1) -shared -o $@ $<
|
|
|
|
|
|
|
|
stage2/$(CFG_STDLIB): $(S)src/$(STDLIB_CRATE) $(STDLIB_INPUTS) \
|
|
|
|
stage2/rustc$(X) $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(STAGE2) -shared -o $@ $<
|
|
|
|
|
|
|
|
|
2011-03-20 00:55:28 -05:00
|
|
|
|
2011-03-18 19:41:32 -05:00
|
|
|
stage0/rustc$(X): $(S)src/$(COMPILER_CRATE) $(COMPILER_INPUTS) \
|
2011-03-20 03:12:26 -05:00
|
|
|
$(BREQ)
|
2011-03-18 19:41:32 -05:00
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(BOOT) -minimal -o $@ $<
|
|
|
|
$(Q)chmod 0755 $@
|
|
|
|
|
2011-03-20 00:55:28 -05:00
|
|
|
stage1/rustc$(X): $(S)src/$(COMPILER_CRATE) $(COMPILER_INPUTS) \
|
2011-03-20 03:12:26 -05:00
|
|
|
$(SREQ0) stage0/$(CFG_STDLIB)
|
2011-03-20 00:55:28 -05:00
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(STAGE0) -o $@ $<
|
|
|
|
$(Q)chmod 0755 $@
|
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
stage2/rustc$(X): $(S)src/$(COMPILER_CRATE) $(COMPILER_INPUTS) \
|
|
|
|
$(SREQ1) stage1/$(CFG_STDLIB)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(STAGE1) -o $@ $<
|
|
|
|
$(Q)chmod 0755 $@
|
|
|
|
|
|
|
|
|
2011-03-20 00:55:28 -05:00
|
|
|
|
2011-03-19 20:33:32 -05:00
|
|
|
stage0/glue.bc: stage0/rustc$(X) stage0/$(CFG_STDLIB) \
|
|
|
|
llvmext/$(CFG_LLVMEXT) rt/$(CFG_RUNTIME)
|
2011-03-18 19:41:32 -05:00
|
|
|
@$(call E, generate: $@)
|
|
|
|
$(STAGE0) -o $@ -glue
|
2011-03-18 01:51:45 -05:00
|
|
|
|
2011-03-20 00:55:28 -05:00
|
|
|
stage1/glue.bc: stage1/rustc$(X) stage1/$(CFG_STDLIB) \
|
|
|
|
llvmext/$(CFG_LLVMEXT) rt/$(CFG_RUNTIME)
|
|
|
|
@$(call E, generate: $@)
|
|
|
|
$(STAGE1) -o $@ -glue
|
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
stage2/glue.bc: stage2/rustc$(X) stage2/$(CFG_STDLIB) \
|
|
|
|
llvmext/$(CFG_LLVMEXT) rt/$(CFG_RUNTIME)
|
|
|
|
@$(call E, generate: $@)
|
|
|
|
$(STAGE2) -o $@ -glue
|
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
######################################################################
|
2011-03-20 03:12:26 -05:00
|
|
|
# Library and boot rules
|
2011-03-18 01:51:45 -05:00
|
|
|
######################################################################
|
|
|
|
|
|
|
|
rt/%.o: rt/%.cpp $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(Q)$(call CFG_COMPILE_C, $@, $(RUNTIME_INCS)) $<
|
|
|
|
|
|
|
|
llvmext/%.o: llvmext/%.cpp $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
2011-03-18 19:29:30 -05:00
|
|
|
$(Q)$(call CFG_COMPILE_C, $@, $(CFG_LLVM_CXXFLAGS) $(LLVMEXT_INCS)) $<
|
2011-03-18 01:51:45 -05:00
|
|
|
|
2011-03-16 11:17:32 -05:00
|
|
|
%.cmo: %.ml $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
2011-03-17 16:26:24 -05:00
|
|
|
$(Q)ocamlc$(OPT) -c -o $@ $(BOOT_OCAMLC_FLAGS) $<
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
%.cmo: %.cmi $(MKFILES)
|
2011-03-17 16:26:24 -05:00
|
|
|
|
2011-03-18 01:51:45 -05:00
|
|
|
%.cmx %.o: %.ml $(MKFILES)
|
|
|
|
@$(call E, compile: $@)
|
|
|
|
$(Q)ocamlopt$(OPT) -c -o $@ $(BOOT_OCAMLOPT_FLAGS) $<
|
|
|
|
|
|
|
|
%.ml: %.mll $(MKFILES)
|
|
|
|
@$(call E, lex-gen: $@)
|
|
|
|
$(Q)ocamllex$(OPT) -q -o $@ $<
|
2011-03-17 16:26:24 -05:00
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Testing rules
|
|
|
|
######################################################################
|
|
|
|
|
2011-03-20 21:08:37 -05:00
|
|
|
%.stage0$(X): %.stage0.o rt/$(CFG_RUNTIME) stage0/glue.o
|
2011-03-20 23:05:31 -05:00
|
|
|
@$(call E, link [gcc]: $@)
|
|
|
|
$(Q)gcc $(CFG_GCC_CFLAGS) stage0/glue.o -o $@ $< -Lstage0 -Lrt -lrustrt
|
2011-03-20 03:12:26 -05:00
|
|
|
@# dsymutil sometimes fails or prints a warning, but the
|
|
|
|
@# program still runs. Since it simplifies debugging other
|
|
|
|
@# programs, I\'ll live with the noise.
|
|
|
|
-$(Q)$(DSYMUTIL) $@
|
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
%.stage1(X): %.stage1.o rt/$(CFG_RUNTIME) stage1/glue.o
|
2011-03-20 23:05:31 -05:00
|
|
|
@$(call E, link [gcc]: $@)
|
|
|
|
$(Q)gcc $(CFG_GCC_CFLAGS) stage1/glue.o -o $@ $< -Lstage1 -Lrt -lrustrt
|
2011-03-20 21:42:27 -05:00
|
|
|
@# dsymutil sometimes fails or prints a warning, but the
|
|
|
|
@# program still runs. Since it simplifies debugging other
|
|
|
|
@# programs, I\'ll live with the noise.
|
|
|
|
-$(Q)$(DSYMUTIL) $@
|
|
|
|
|
|
|
|
%.stage2(X): %.stage2.o rt/$(CFG_RUNTIME) stage2/glue.o
|
2011-03-20 23:05:31 -05:00
|
|
|
@$(call E, link [gcc]: $@)
|
|
|
|
$(Q)gcc $(CFG_GCC_CFLAGS) stage2/glue.o -o $@ $< -Lstage2 -Lrt -lrustrt
|
2011-03-20 21:42:27 -05:00
|
|
|
@# dsymutil sometimes fails or prints a warning, but the
|
|
|
|
@# program still runs. Since it simplifies debugging other
|
|
|
|
@# programs, I\'ll live with the noise.
|
|
|
|
-$(Q)$(DSYMUTIL) $@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
%.boot$(X): %.rs $(BREQ)
|
|
|
|
@$(call E, compile [boot]: $@)
|
|
|
|
$(BOOT) -o $@ $<
|
|
|
|
|
|
|
|
%.boot$(X): %.rc $(BREQ)
|
|
|
|
@$(call E, compile [boot]: $@)
|
|
|
|
$(BOOT) -o $@ $<
|
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
%.stage0.bc: %.rc $(SREQ0)
|
|
|
|
@$(call E, compile [stage0]: $@)
|
|
|
|
$(STAGE0) -o $@ $<
|
|
|
|
|
|
|
|
%.stage0.bc: %.rs $(SREQ0)
|
|
|
|
@$(call E, compile [stage0]: $@)
|
|
|
|
$(STAGE0) -o $@ $<
|
|
|
|
|
2011-03-20 21:42:27 -05:00
|
|
|
%.stage1.bc: %.rc $(SREQ1)
|
|
|
|
@$(call E, compile [stage1]: $@)
|
|
|
|
$(STAGE1) -o $@ $<
|
|
|
|
|
|
|
|
%.stage1.bc: %.rs $(SREQ1)
|
|
|
|
@$(call E, compile [stage1]: $@)
|
|
|
|
$(STAGE1) -o $@ $<
|
|
|
|
|
|
|
|
%.stage2.bc: %.rc $(SREQ2)
|
|
|
|
@$(call E, compile [stage2]: $@)
|
|
|
|
$(STAGE2) -o $@ $<
|
|
|
|
|
|
|
|
%.stage2.bc: %.rs $(SREQ2)
|
|
|
|
@$(call E, compile [stage2]: $@)
|
|
|
|
$(STAGE2) -o $@ $<
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-03-18 20:32:31 -05:00
|
|
|
%.o: %.s
|
|
|
|
@$(call E, assemble [llvm]: $@)
|
|
|
|
$(Q)gcc $(CFG_GCC_CFLAGS) -o $@ -c $<
|
|
|
|
|
|
|
|
%.ll: %.bc
|
|
|
|
@$(call E, dis [llvm]: $@)
|
|
|
|
$(Q)$(CFG_LLVM_BINDIR)/llvm-dis -o $@ $<
|
|
|
|
|
|
|
|
%.s: %.bc
|
|
|
|
@$(call E, compile [llvm]: $@)
|
|
|
|
$(Q)$(CFG_LLVM_BINDIR)/llc $(CFG_LLC_CFLAGS) -o $@ $<
|
|
|
|
|
2011-03-20 03:12:26 -05:00
|
|
|
# Cancel the implicit .out rule in GNU make.
|
|
|
|
%.out: %
|
|
|
|
|
|
|
|
%.out: %.out.tmp
|
|
|
|
$(Q)mv $< $@
|
|
|
|
|
|
|
|
test/run-pass/%.out.tmp: test/run-pass/%$(CFG_EXE_SUFFIX) rt/$(CFG_RUNTIME)
|
|
|
|
$(Q)rm -f $<.tmp
|
|
|
|
@$(call E, run: $@)
|
|
|
|
$(Q)$(call CFG_RUN_TARG, $<) > $@
|
|
|
|
|
|
|
|
test/bench/shootout/%.out.tmp: test/bench/shootout/%$(X) \
|
|
|
|
rt/$(CFG_RUNTIME)
|
|
|
|
$(Q)rm -f $<.tmp
|
|
|
|
@$(call E, run: $@)
|
|
|
|
$(Q)$(call CFG_RUN_TARG, $<) > $@
|
|
|
|
|
|
|
|
test/bench/99-bottles/%.out.tmp: test/bench/99-bottles/%$(X) \
|
|
|
|
rt/$(CFG_RUNTIME)
|
|
|
|
$(Q)rm -f $<.tmp
|
|
|
|
@$(call E, run: $@)
|
|
|
|
$(Q)$(call CFG_RUN_TARG, $<) > $@
|
|
|
|
|
|
|
|
test/run-fail/%.out.tmp: test/run-fail/%$(X) \
|
|
|
|
rt/$(CFG_RUNTIME)
|
|
|
|
$(Q)rm -f $<.tmp
|
|
|
|
@$(call E, run: $@)
|
|
|
|
$(Q)grep -q error-pattern $(S)src/test/run-fail/$(basename $*).rs
|
|
|
|
$(Q)rm -f $@
|
|
|
|
$(Q)$(call CFG_RUN_TARG, $<) >$@ 2>&1 ; X=$$? ; \
|
|
|
|
if [ $$X -eq 0 ] ; then exit 1 ; else exit 0 ; fi
|
|
|
|
$(Q)grep --text --quiet \
|
|
|
|
"$$(grep error-pattern $(S)src/test/run-fail/$(basename $*).rs \
|
|
|
|
| cut -d : -f 2- | tr -d '\n\r')" $@
|
|
|
|
|
|
|
|
test/compile-fail/%.boot.out.tmp: test/compile-fail/%.rs $(BREQ)
|
|
|
|
@$(call E, compile [boot]: $@)
|
|
|
|
$(Q)grep -q error-pattern $<
|
|
|
|
$(Q)rm -f $@
|
|
|
|
$(BOOT) -o $(@:.out=$(X)) $< >$@ 2>&1; test $$? -ne 0
|
|
|
|
$(Q)grep --text --quiet \
|
|
|
|
"$$(grep error-pattern $< | cut -d : -f 2- | tr -d '\n\r')" $@
|
|
|
|
|
|
|
|
test/compile-fail/%.stage0.out.tmp: test/compile-fail/%.rs $(SREQ0)
|
|
|
|
@$(call E, compile [stage0]: $@)
|
|
|
|
$(Q)grep -q error-pattern $<
|
|
|
|
$(Q)rm -f $@
|
|
|
|
$(STAGE0) -o $(@:.out=$(X)) $< >$@ 2>&1; test $$? -ne 0
|
|
|
|
$(Q)grep --text --quiet \
|
|
|
|
"$$(grep error-pattern $< | cut -d : -f 2- | tr -d '\n\r')" $@
|
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Cleanup
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
|
|
|
|
clean:
|
|
|
|
@$(call E, cleaning)
|
|
|
|
$(Q)rm -f $(foreach ext, cmx cmi cmo cma bc o a d $(X) \
|
|
|
|
h cpp ml s \
|
|
|
|
out bc dSYM \
|
|
|
|
, \
|
|
|
|
$(wildcard *.$(ext) \
|
|
|
|
*/*.$(ext) \
|
|
|
|
*/*/*.$(ext) \
|
|
|
|
*/*/*/*.$(ext) \
|
|
|
|
))
|