From 3ae9ca444ce244e2bab660de28a5bf7047aa3813 Mon Sep 17 00:00:00 2001 From: Graydon Hoare Date: Thu, 17 Mar 2011 14:26:24 -0700 Subject: Move Makefile.in and configure to top level, BOOT_-qualify names, various tweaks. --- Makefile.in | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ configure | 75 +++++++++++++++++++++++++++ src/Makefile.in | 129 ---------------------------------------------- src/configure.sh | 61 ---------------------- 4 files changed, 228 insertions(+), 190 deletions(-) create mode 100644 Makefile.in create mode 100755 configure delete mode 100644 src/Makefile.in delete mode 100755 src/configure.sh diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..ad96251a --- /dev/null +++ b/Makefile.in @@ -0,0 +1,153 @@ +###################################################################### +# 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, \ + boot/version \ + $(addprefix boot/util/, fmt common bits) \ + $(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) + +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 + +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 + + +###################################################################### +# Target-and-rule "utility variables" +###################################################################### + +ifdef VERBOSE + Q := + E = +else + Q := @ + E = echo $(1) +endif + +S := $(CFG_SRC_DIR) +X := $(CFG_EXE_SUFFIX) + +# Look in doc and src dirs. +VPATH := $(CFG_SRC_DIR)/doc $(CFG_SRC_DIR)/src + +# Delete the built-in rules. +.SUFFIXES: +%:: %,v +%:: RCS/%,v +%:: RCS/% +%:: s.% +%:: SCCS/s.% + +###################################################################### +# Targets and rules +###################################################################### + +all: boot/rustboot$(X) + +ifdef CFG_NATIVE_BOOT +boot/rustboot$(X): $(BOOT_CMXS) $(MKFILES) + @$(call E, compile: $@) + $(Q)ocamlopt$(OPT) -o $@ $(BOOT_OCAMLOPT_FLAGS) $(ML_NATIVE_LIBS) \ + $(BOOT_CMXS) +else +boot/rustboot$(X): $(BOOT_CMOS) $(MKFILES) + @$(call E, compile: $@) + $(Q)ocamlc$(OPT) -o $@ $(BOOT_OCAMLC_FLAGS) $(BOOT_ML_LIBS) $(BOOT_CMOS) +endif + + +boot/version.ml: $(MKFILES) + @$(call E, git: $@) + $(Q)git log -1 \ + --pretty=format:'let version = "prerelease (%h %ci)";;' >$@ || exit 1 + +%.cmo: %.ml $(MKFILES) + @$(call E, compile: $@) + $(Q)ocamlc$(OPT) -c -o $@ $(BOOT_OCAMLC_FLAGS) $< + +%.cmo: %.cmi $(MKFILES) + + + +###################################################################### +# 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) \ + )) diff --git a/configure b/configure new file mode 100755 index 00000000..0e584f35 --- /dev/null +++ b/configure @@ -0,0 +1,75 @@ +#!/bin/sh + +CFG_SRC_DIR=${0%${0##*/}} +CFG_BUILD_DIR=$PWD + +echo "configure: recreating config.mk" +echo '' >config.mk + +echo "configure: making directories" +for i in \ + doc \ + boot/fe boot/me boot/be boot/driver boot/util \ + rt/isaac rt/bigint rt/sync rt/test +do + mkdir -p -v $i +done + +make_test_subdirs() { + for t in run-pass run-fail compile-fail + do + mkdir -p -v $1/test/$t + done +} + +make_test_subdirs boot + +for i in 0 1 2 +do + mkdir -p -v stage$i + make_test_subdirs stage$i +done + +echo "configure: copying Makefile" +cp -v ${CFG_SRC_DIR}Makefile.in ./Makefile + +putvar() { + local T + eval T=\$$1 + printf "%-20s := %s\n" $1 $T + printf "%-20s := %s\n" $1 $T >>config.mk +} + +probe() { + local V=$1 + local P=$2 + local T + T=$(which $P 2>&1) + if [ $? -ne 0 ] + then + T="" + fi + eval $V=\$T + putvar $V +} + +echo "configure: inspecting environment" + +CFG_OSTYPE=$(uname -s) +CFG_CPUTYPE=$(uname -m) + +putvar CFG_SRC_DIR +putvar CFG_BUILD_DIR +putvar CFG_OSTYPE +putvar CFG_CPUTYPE + +echo "configure: looking for programs" +probe CFG_VALGRIND valgrind +probe CFG_OCAMLC ocamlc +probe CFG_OCAMLC_OPT ocamlc.opt +probe CFG_OCAMLOPT ocamlopt +probe CFG_OCAMLOPT_OPT ocamlopt.opt +probe CFG_FLEXLINK flexlink +probe CFG_LLVM_CONFIG llvm-config + +echo "configure: complete" diff --git a/src/Makefile.in b/src/Makefile.in deleted file mode 100644 index fd4bd317..00000000 --- a/src/Makefile.in +++ /dev/null @@ -1,129 +0,0 @@ -###################################################################### -# 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, \ - $(addprefix boot/util/, version fmt common bits) \ - $(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) - -ML_DEP_INCS := -I $(S)boot/fe -I $(S)boot/me -I $(S)boot/be \ - -I $(S)boot/driver -I $(S)boot/util - -ML_INCS := $(ML_DEP_INCS) -ML_LIBS := unix.cma nums.cma bigarray.cma -ML_NATIVE_LIBS := unix.cmxa nums.cmxa bigarray.cmxa -OCAMLC_FLAGS := -g $(ML_INCS) -w Ael -warn-error Ael - - -###################################################################### -# Target-and-rule "utility variables" -###################################################################### - -ifdef VERBOSE - Q := - E = -else - Q := @ - E = echo $(1) -endif - -S := $(CFG_SRC_DIR) -X := $(CFG_EXE_SUFFIX) - -# Look in src dir. -VPATH := $(CFG_SRC_DIR) - -# Delete the built-in rules. -.SUFFIXES: -%:: %,v -%:: RCS/%,v -%:: RCS/% -%:: s.% -%:: SCCS/s.% - -###################################################################### -# Targets and rules -###################################################################### - -all: rustboot$(X) - -ifdef CFG_NATIVE_BOOT -rustboot$(X): $(BOOT_CMXS) $(MKFILES) - @$(call E, compile: $@) - $(Q)ocamlopt$(OPT) -o $@ $(OCAMLOPT_FLAGS) $(ML_NATIVE_LIBS) \ - $(BOOT_CMXS) -else -rustboot$(X): $(BOOT_CMOS) $(MKFILES) - @$(call E, compile: $@) - $(Q)ocamlc$(OPT) -o $@ $(OCAMLC_FLAGS) $(ML_LIBS) $(BOOT_CMOS) -endif - - -boot/util/version.ml: $(MKFILES) - $(Q)git log -1 \ - --pretty=format:'let version = "prerelease (%h %ci)";;' >$@ || exit 1 - -%.cmo: %.ml $(MKFILES) - @$(call E, compile: $@) - $(Q)ocamlc$(OPT) -c -o $@ $(OCAMLC_FLAGS) $< - -%.cmo: %.cmi $(MKFILES) diff --git a/src/configure.sh b/src/configure.sh deleted file mode 100755 index 03678e01..00000000 --- a/src/configure.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -CFG_SRC_DIR=${0%${0##*/}} -CFG_BUILD_DIR=$PWD - -echo "configure: recreating config.mk" -echo '' >config.mk - -echo "configure: making directories" -for i in \ - boot/fe boot/me boot/be boot/driver boot/util \ - rt/isaac rt/bigint rt/sync rt/test \ - stage0 stage1 stage2 \ - test/run-pass test/compile-pass test/compile-fail -do - mkdir -p -v $i -done - -echo "configure: copying Makefile" -cp -v ${CFG_SRC_DIR}Makefile.in ./Makefile - -putvar() { - local T - eval T=\$$1 - printf "%-20s := %s\n" $1 $T - printf "%-20s := %s\n" $1 $T >>config.mk -} - -probe() { - local V=$1 - local P=$2 - local T - T=$(which $P 2>&1) - if [ $? -ne 0 ] - then - T="" - fi - eval $V=\$T - putvar $V -} - -echo "configure: inspecting environment" - -CFG_OSTYPE=$(uname -s) -CFG_CPUTYPE=$(uname -m) - -putvar CFG_SRC_DIR -putvar CFG_BUILD_DIR -putvar CFG_OSTYPE -putvar CFG_CPUTYPE - -echo "configure: looking for programs" -probe CFG_VALGRIND valgrind -probe CFG_OCAMLC ocamlc -probe CFG_OCAMLC_OPT ocamlc.opt -probe CFG_OCAMLOPT ocamlopt -probe CFG_OCAMLOPT_OPT ocamlopt.opt -probe CFG_FLEXLINK flexlink -probe CFG_LLVM_CONFIG llvm-config - -echo "configure: complete" -- cgit v1.2.3