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))
|
|
|
|
|
|
|
|
ifdef CFG_OCAMLC_OPT
|
|
|
|
$(info cfg: using ocaml native compiler)
|
|
|
|
OPT=.opt
|
|
|
|
else
|
|
|
|
$(info cfg: using ocaml bytecode compiler)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef PROFILE_BOOT
|
|
|
|
$(info cfg: building bootstrap compiler with profiling (forcing native))
|
|
|
|
CFG_NATIVE_BOOT := 1
|
|
|
|
CFG_OCAMLOPT_PROFILE_FLAGS := -p
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
|
|
|
$(info cfg: forcing bytecode bootstrap compiler)
|
|
|
|
CFG_NATIVE_BOOT :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef CFG_NATIVE_BOOT
|
|
|
|
$(info cfg: building native bootstrap compiler)
|
|
|
|
else
|
|
|
|
$(info cfg: building bytecode bootstrap compiler)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef NO_VALGRIND
|
|
|
|
CFG_VALGRIND :=
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# 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-17 16:26:24 -05:00
|
|
|
BOOT_ML_DEP_INCS := -I boot \
|
|
|
|
-I $(S)boot/fe -I $(S)boot/me \
|
|
|
|
-I $(S)boot/be -I $(S)boot/driver \
|
|
|
|
-I $(S)boot/util
|
2011-03-16 11:17:32 -05:00
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
BOOT_ML_INCS := $(BOOT_ML_DEP_INCS)
|
|
|
|
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-16 11:17:32 -05:00
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Target-and-rule "utility variables"
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
ifdef VERBOSE
|
|
|
|
Q :=
|
|
|
|
E =
|
|
|
|
else
|
|
|
|
Q := @
|
|
|
|
E = echo $(1)
|
|
|
|
endif
|
|
|
|
|
|
|
|
S := $(CFG_SRC_DIR)
|
|
|
|
X := $(CFG_EXE_SUFFIX)
|
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
# Look in doc and src dirs.
|
|
|
|
VPATH := $(CFG_SRC_DIR)/doc $(CFG_SRC_DIR)/src
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
# Delete the built-in rules.
|
|
|
|
.SUFFIXES:
|
|
|
|
%:: %,v
|
|
|
|
%:: RCS/%,v
|
|
|
|
%:: RCS/%
|
|
|
|
%:: s.%
|
|
|
|
%:: SCCS/s.%
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Targets and rules
|
|
|
|
######################################################################
|
|
|
|
|
2011-03-17 16:26:24 -05:00
|
|
|
all: boot/rustboot$(X)
|
2011-03-16 11:17:32 -05:00
|
|
|
|
|
|
|
ifdef CFG_NATIVE_BOOT
|
2011-03-17 16:26:24 -05:00
|
|
|
boot/rustboot$(X): $(BOOT_CMXS) $(MKFILES)
|
2011-03-16 11:17:32 -05:00
|
|
|
@$(call E, compile: $@)
|
2011-03-17 16:26:24 -05:00
|
|
|
$(Q)ocamlopt$(OPT) -o $@ $(BOOT_OCAMLOPT_FLAGS) $(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-16 11:17:32 -05:00
|
|
|
@$(call E, compile: $@)
|
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
|
|
|
|
|
|
|
|
%.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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# 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) \
|
|
|
|
))
|