Merge pull request #1434 from damiendoligez/makefile-cleanup

Makefile cleanup
master
Gabriel Scherer 2017-12-10 17:14:12 +01:00 committed by GitHub
commit 3882302fa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 47 additions and 110 deletions

View File

@ -198,8 +198,15 @@ for guidance on how to edit the generated files by hand.
2. From the top directory, do: 2. From the top directory, do:
make world.opt
+
if your platform is supported by the native-code compiler (as reported during
the auto-configuration), or
make world make world
+ +
if not.
This builds the OCaml bytecode compiler for the first time. This phase is This builds the OCaml bytecode compiler for the first time. This phase is
fairly verbose; consider redirecting the output to a file: fairly verbose; consider redirecting the output to a file:
@ -226,38 +233,7 @@ best thing to do is to try a second bootstrapping phase: just do
`make bootstrap` again. It will either crash almost immediately, or `make bootstrap` again. It will either crash almost immediately, or
re-re-compile everything correctly and reach the fix-point. re-re-compile everything correctly and reach the fix-point.
4. If your platform is supported by the native-code compiler (as reported during 4. You can now install the OCaml system. This will create the following commands
the auto-configuration), you can now build the native-code compiler. From
the top directory, do:
make opt
+
or:
make opt > log.opt 2>&1 # in sh
make opt >& log.opt # in csh
5. anchor:step-5[] Compile fast versions of the OCaml compilers, by compiling
them with the native-code compiler (you will have only compiled them to
bytecode in steps 2-4). Just do:
make opt.opt
+
Later, you can compile your programs to bytecode using ocamlc.opt instead of
ocamlc, and to native-code using ocamlopt.opt instead of ocamlopt. The ".opt"
compilers should run faster than the normal compilers, especially on large input
files, but they may take longer to start due to increased code size. If
compilation times are an issue on your programs, try the ".opt" compilers to see
if they make a significant difference.
+
An alternative, and faster approach to steps 2 to 5 is
make world.opt # to build using native-code compilers
+
The result is equivalent to `make world opt opt.opt`, but this may fail if
anything goes wrong in native-code generation.
6. You can now install the OCaml system. This will create the following commands
(in the binary directory selected during autoconfiguration): (in the binary directory selected during autoconfiguration):
+ +
[width="70%",frame="topbot",cols="25%,75%"] [width="70%",frame="topbot",cols="25%,75%"]
@ -277,20 +253,17 @@ anything goes wrong in native-code generation.
| `ocamlcp` | the bytecode compiler in profiling mode | `ocamlcp` | the bytecode compiler in profiling mode
|=============================================================================== |===============================================================================
+ +
and also, if you built them during <<step-5,step 5>>: `ocamlc.opt`,
`ocamlopt.opt`, `ocamllex.opt`, `ocamldep.opt` and `ocamldoc.opt`
+
From the top directory, become superuser and do: From the top directory, become superuser and do:
umask 022 # make sure to give read & execute permission to all umask 022 # make sure to give read & execute permission to all
make install make install
7. Installation is complete. Time to clean up. From the toplevel directory, 5. Installation is complete. Time to clean up. From the toplevel directory,
do: do:
make clean make clean
8. (Optional) The `emacs/` subdirectory contains Emacs-Lisp files for an OCaml 6. (Optional) The `emacs/` subdirectory contains Emacs-Lisp files for an OCaml
editing mode and an interface for the debugger. To install these files, editing mode and an interface for the debugger. To install these files,
change to the `emacs/` subdirectory and do: change to the `emacs/` subdirectory and do:
@ -303,7 +276,7 @@ or
In the latter case, the destination directory defaults to the In the latter case, the destination directory defaults to the
`site-lisp` directory of your Emacs installation. `site-lisp` directory of your Emacs installation.
9. After installation, do *not* strip the `ocamldebug` and `ocamlbrowser` 7. After installation, do *not* strip the `ocamldebug` and `ocamlbrowser`
executables. These are mixed-mode executables (containing both compiled C executables. These are mixed-mode executables (containing both compiled C
code and OCaml bytecode) and stripping erases the bytecode! Other code and OCaml bytecode) and stripping erases the bytecode! Other
executables such as `ocamlrun` can safely be stripped. executables such as `ocamlrun` can safely be stripped.

View File

@ -16,13 +16,18 @@
# The main Makefile # The main Makefile
# Hard bootstrap how-to: # Hard bootstrap how-to:
# (only necessary in some cases, for example if you remove some primitive) # (only necessary if you remove or rename some primitive)
# #
# make coreboot [old system -- you were in a stable state] # make core [old system -- you were in a stable state]
# <change the source> # make coreboot [optional -- check state stability]
# make clean runtime coreall # <add new primitives and remove uses of old primitives>
# <debug your changes> # make clean && make core
# make clean runtime coreall # if the above fails:
# <debug your changes>
# make clean && make core
# make coreboot [intermediate state with both old and new primitives]
# <remove old primitives>
# make clean && make runtime && make coreall
# make coreboot [new system -- now in a stable state] # make coreboot [new system -- now in a stable state]
include config/Makefile include config/Makefile
@ -280,7 +285,7 @@ RUNTOP=./byterun/ocamlrun ./ocaml \
-noinit $(TOPFLAGS) \ -noinit $(TOPFLAGS) \
-I otherlibs/$(UNIXLIB) -I otherlibs/$(UNIXLIB)
NATRUNTOP=./ocamlnat$(EXE) -nostdlib -I stdlib -noinit $(TOPFLAGS) NATRUNTOP=./ocamlnat$(EXE) -nostdlib -I stdlib -noinit $(TOPFLAGS)
ifeq "UNIX_OR_WIN32" "unix" ifeq "$(UNIX_OR_WIN32)" "unix"
EXTRAPATH= EXTRAPATH=
else else
EXTRAPATH = PATH="otherlibs/win32unix:$(PATH)" EXTRAPATH = PATH="otherlibs/win32unix:$(PATH)"
@ -398,11 +403,7 @@ coreall:
# Build the core system: the minimum needed to make depend and bootstrap # Build the core system: the minimum needed to make depend and bootstrap
.PHONY: core .PHONY: core
core: core:
ifeq "$(UNIX_OR_WIN32)" "unix"
$(MAKE) coldstart $(MAKE) coldstart
else # Windows, to be fixed!
$(MAKE) runtime
endif
$(MAKE) coreall $(MAKE) coreall
# Save the current bootstrap compiler # Save the current bootstrap compiler
@ -461,19 +462,13 @@ opt-core: runtimeopt
.PHONY: opt .PHONY: opt
opt: opt:
ifeq "$(UNIX_OR_WIN32)" "unix"
$(MAKE) runtimeopt $(MAKE) runtimeopt
$(MAKE) ocamlopt $(MAKE) ocamlopt
$(MAKE) libraryopt $(MAKE) libraryopt
$(MAKE) otherlibrariesopt ocamltoolsopt $(MAKE) otherlibrariesopt ocamltoolsopt
else
$(MAKE) opt-core
$(MAKE) otherlibrariesopt ocamltoolsopt
endif
# Native-code versions of the tools # Native-code versions of the tools
.PHONY: opt.opt .PHONY: opt.opt
ifeq "$(UNIX_OR_WIN32)" "unix"
opt.opt: opt.opt:
$(MAKE) checkstack $(MAKE) checkstack
$(MAKE) runtime $(MAKE) runtime
@ -486,23 +481,6 @@ opt.opt:
$(MAKE) otherlibrariesopt $(MAKE) otherlibrariesopt
$(MAKE) ocamllex.opt ocamltoolsopt ocamltoolsopt.opt $(OCAMLDOC_OPT) \ $(MAKE) ocamllex.opt ocamltoolsopt ocamltoolsopt.opt $(OCAMLDOC_OPT) \
ocamltest.opt ocamltest.opt
else
opt.opt: core opt-core ocamlc.opt all ocamlopt.opt ocamllex.opt \
ocamltoolsopt ocamltoolsopt.opt otherlibrariesopt $(OCAMLDOC_OPT) \
ocamltest.opt
endif
.PHONY: base.opt
base.opt:
$(MAKE) checkstack
$(MAKE) runtime
$(MAKE) core
$(MAKE) ocaml
$(MAKE) opt-core
$(MAKE) ocamlc.opt
$(MAKE) otherlibraries $(WITH_DEBUGGER) $(WITH_OCAMLDOC) ocamltest
$(MAKE) ocamlopt.opt
$(MAKE) otherlibrariesopt
# Core bootstrapping cycle # Core bootstrapping cycle
.PHONY: coreboot .PHONY: coreboot
@ -679,12 +657,12 @@ installopt:
$(MAKE) -C stdlib installopt $(MAKE) -C stdlib installopt
cp middle_end/*.cmi middle_end/*.cmt middle_end/*.cmti \ cp middle_end/*.cmi middle_end/*.cmt middle_end/*.cmti \
middle_end/*.mli \ middle_end/*.mli \
"$(INSTALL_COMPLIBDIR)" "$(INSTALL_COMPLIBDIR)"
cp middle_end/base_types/*.cmi middle_end/base_types/*.cmt \ cp middle_end/base_types/*.cmi middle_end/base_types/*.cmt \
middle_end/base_types/*.cmti middle_end/base_types/*.mli \ middle_end/base_types/*.cmti middle_end/base_types/*.mli \
"$(INSTALL_COMPLIBDIR)" "$(INSTALL_COMPLIBDIR)"
cp asmcomp/*.cmi asmcomp/*.cmt asmcomp/*.cmti asmcomp/*.mli \ cp asmcomp/*.cmi asmcomp/*.cmt asmcomp/*.cmti asmcomp/*.mli \
"$(INSTALL_COMPLIBDIR)" "$(INSTALL_COMPLIBDIR)"
cp compilerlibs/ocamloptcomp.cma $(OPTSTART) "$(INSTALL_COMPLIBDIR)" cp compilerlibs/ocamloptcomp.cma $(OPTSTART) "$(INSTALL_COMPLIBDIR)"
if test -n "$(WITH_OCAMLDOC)"; then \ if test -n "$(WITH_OCAMLDOC)"; then \
$(MAKE) -C ocamldoc installopt; \ $(MAKE) -C ocamldoc installopt; \
@ -818,21 +796,17 @@ partialclean::
.PHONY: runtop .PHONY: runtop
runtop: runtop:
ifeq "$(UNIX_OR_WIN32)" "unix" $(MAKE) coldstart
$(MAKE) runtime $(MAKE) ocamlc
$(MAKE) coreall $(MAKE) otherlibraries
$(MAKE) ocaml $(MAKE) ocaml
else
$(MAKE) core
$(MAKE) ocaml
endif
@rlwrap --help 2>/dev/null && $(EXTRAPATH) rlwrap $(RUNTOP) ||\ @rlwrap --help 2>/dev/null && $(EXTRAPATH) rlwrap $(RUNTOP) ||\
$(EXTRAPATH) $(RUNTOP) $(EXTRAPATH) $(RUNTOP)
.PHONY: natruntop .PHONY: natruntop
natruntop: natruntop:
$(MAKE) runtime $(MAKE) core
$(MAKE) coreall $(MAKE) opt
$(MAKE) opt.opt $(MAKE) opt.opt
$(MAKE) ocamlnat $(MAKE) ocamlnat
@rlwrap --help 2>/dev/null && $(EXTRAPATH) rlwrap $(NATRUNTOP) ||\ @rlwrap --help 2>/dev/null && $(EXTRAPATH) rlwrap $(NATRUNTOP) ||\
@ -1110,15 +1084,16 @@ ocamldebugger: ocamlc ocamlyacc ocamllex otherlibraries
partialclean:: partialclean::
$(MAKE) -C debugger clean $(MAKE) -C debugger clean
# Check that the stack limit is reasonable. # Check that the stack limit is reasonable (Unix-only)
ifeq "$(UNIX_OR_WIN32)" "unix"
.PHONY: checkstack .PHONY: checkstack
checkstack: checkstack:
ifeq "$(UNIX_OR_WIN32)" "unix"
if $(MKEXE) $(OUTPUTEXE)tools/checkstack$(EXE) tools/checkstack.c; \ if $(MKEXE) $(OUTPUTEXE)tools/checkstack$(EXE) tools/checkstack.c; \
then tools/checkstack$(EXE); \ then tools/checkstack$(EXE); \
else :; \
fi fi
rm -f tools/checkstack$(EXE) rm -f tools/checkstack$(EXE)
else
@
endif endif
# Lint @since and @deprecated annotations # Lint @since and @deprecated annotations
@ -1136,19 +1111,6 @@ lintapidiff:
clean:: clean::
cd testsuite; $(MAKE) clean cd testsuite; $(MAKE) clean
# Make MacOS X package
ifeq "$(UNIX_OR_WIN32)" "unix"
.PHONY: package-macosx
package-macosx:
sudo rm -rf package-macosx/root
$(MAKE) PREFIX="`pwd`"/package-macosx/root install
tools/make-package-macosx
sudo rm -rf package-macosx/root
clean::
rm -rf package-macosx/*.pkg package-macosx/*.dmg
endif
# The middle end (whose .cma library is currently only used for linking # The middle end (whose .cma library is currently only used for linking
# the "ocamlobjinfo" program, since we cannot depend on the whole native code # the "ocamlobjinfo" program, since we cannot depend on the whole native code
# compiler for "make world" and the list of dependencies for # compiler for "make world" and the list of dependencies for

View File

@ -188,7 +188,7 @@ the top-level of the OCaml distribution by running:
eval $(tools/msvs-promote-path) eval $(tools/msvs-promote-path)
If you forget to do this, `make world` will fail relatively If you forget to do this, `make world.opt` will fail relatively
quickly as it will be unable to link `ocamlrun`. quickly as it will be unable to link `ocamlrun`.
Now run: Now run:
@ -210,7 +210,8 @@ which indicates where to install everything.
Finally, use `make` to build the system, e.g. Finally, use `make` to build the system, e.g.
make world bootstrap opt opt.opt install make world.opt
make install
After installing, it is not necessary to keep the Cygwin installation (although After installing, it is not necessary to keep the Cygwin installation (although
you may require it to build additional third party libraries and tools). You you may require it to build additional third party libraries and tools). You
@ -281,7 +282,8 @@ which indicates where to install everything.
Finally, use `make` to build the system, e.g. Finally, use `make` to build the system, e.g.
make world bootstrap opt opt.opt install make world.opt
make install
After installing, you will need to ensure that `ocamlopt` (or `ocamlc -custom`) After installing, you will need to ensure that `ocamlopt` (or `ocamlc -custom`)
can access the C compiler. You can do this either by using OCaml from Cygwin's can access the C compiler. You can do this either by using OCaml from Cygwin's
@ -327,7 +329,10 @@ done in one of three ways:
OCaml is then compiled as normal for the port you require, except that before OCaml is then compiled as normal for the port you require, except that before
compiling `world`, you must compile `flexdll`, i.e.: compiling `world`, you must compile `flexdll`, i.e.:
make flexdll world [bootstrap] opt opt.opt flexlink.opt install make flexdll
make world.opt
make flexlink.opt
make install
* You should ignore the error messages that say ocamlopt was not found. * You should ignore the error messages that say ocamlopt was not found.
* `make install` will install FlexDLL by placing `flexlink.exe` * `make install` will install FlexDLL by placing `flexlink.exe`

View File

@ -218,14 +218,11 @@ case $configure in
*) error "internal error";; *) error "internal error";;
esac esac
$make $jobs coldstart
$make $jobs core
$make $jobs coreboot
$make $jobs world
if $make_native; then if $make_native; then
$make $jobs opt $make $jobs world.opt
$make $jobs opt.opt
if $check_make_alldepend; then $make alldepend; fi if $check_make_alldepend; then $make alldepend; fi
else
$make $jobs world
fi fi
if $dorebase; then if $dorebase; then
# temporary solution to the cygwin fork problem # temporary solution to the cygwin fork problem