####################################################################### # # # The Compcert verified compiler # # # # Xavier Leroy, INRIA Paris-Rocquencourt # # # # Copyright Institut National de Recherche en Informatique et en # # Automatique. All rights reserved. This file is distributed # # under the terms of the GNU Lesser General Public License as # # published by the Free Software Foundation, either version 2.1 of # # the License, or (at your option) any later version. # # This file is also distributed under the terms of the # # INRIA Non-Commercial License Agreement. # # # ####################################################################### # Second-stage Makefile, after Coq extraction include Makefile.config # # Variables from Makefile.config: # -OCAML_NATIVE_COMP: native-code compilation is supported # -OCAML_OPT_COMP: can we use the natively-compiled compilers # -COMPFLAGS: compile options # -LINK_OPT: additional linker flags for the native binary # # Menhir configuration. include Makefile.menhir # # Variables from Makefile.menhir: # -MENHIR_INCLUDES: additional menhir include paths # -MENHIR_LIBS: additional menhir libraries # # The pre-parser's error message database is compiled as follows. cparser/pre_parser_messages.ml: $(MAKE) -C cparser correct # Directories containing plain Caml code DIRS=extraction \ lib common $(ARCH) scheduling backend cfrontend cparser driver \ export debug kvx/unittest lib/Impure/ocaml INCLUDES=$(patsubst %,-I %, $(DIRS)) # Control of warnings: WARNINGS=-w +a-4-9-27-70-42 extraction/%.cmx: WARNINGS +=-w -20-27-32..34-39-41-44..45-60-67 extraction/%.cmo: WARNINGS +=-w -20-27-32..34-39-41-44..45-60-67 cparser/pre_parser.cmx: WARNINGS += -w -41 cparser/pre_parser.cmo: WARNINGS += -w -41 # Turn warnings into errors, but not for released tarballs ifeq ($(wildcard .git),.git) WARN_ERRORS=-warn-error +a else WARN_ERRORS= endif COMPFLAGS+=-g -strict-sequence -safe-string $(INCLUDES) -I "$(MENHIR_DIR)" $(WARNINGS) $(WARN_ERRORS) # Using .opt compilers if available ifeq ($(OCAML_OPT_COMP),true) DOTOPT=.opt else DOTOPT= endif OCAMLC=ocamlc$(DOTOPT) $(COMPFLAGS) OCAMLOPT=ocamlopt$(DOTOPT) $(COMPFLAGS) OCAMLDEP=ocamldep$(DOTOPT) -slash $(INCLUDES) OCAMLFIND=ocamlfind LMFLAGS_LINK=-package landmarks -linkpkg LMFLAGS_COMP=-package landmarks -package landmarks-ppx -ppxopt landmarks-ppx,--auto OCAMLLEX=ocamllex -q MODORDER=tools/modorder .depend.extr COPY=cp PARSERS=cparser/pre_parser.mly LEXERS=cparser/Lexer.mll lib/Tokenize.mll \ lib/Readconfig.mll lib/Responsefile.mll LIBS=str.cmxa unix.cmxa $(MENHIR_LIBS) LIBS_BYTE=$(patsubst %.cmxa,%.cma,$(patsubst %.cmx,%.cmo,$(LIBS))) EXECUTABLES=ccomp ccomp.byte cchecklink cchecklink.byte clightgen clightgen.byte GENERATED=$(PARSERS:.mly=.mli) $(PARSERS:.mly=.ml) $(LEXERS:.mll=.ml) cparser/pre_parser_messages.ml # Beginning of part that assumes .depend.extr already exists ifeq ($(wildcard .depend.extr),.depend.extr) CCOMP_OBJS:=$(shell $(MODORDER) driver/Driver.cmx) ifeq ($(OCAML_NATIVE_COMP),true) ifeq ($(OCAML_LM_PROF), true) ccomp: $(CCOMP_OBJS) @echo "Linking $@ with landmarks profiling" @$(OCAMLFIND) opt $(COMPFLAGS) -o $@ $(LMFLAGS_LINK) $(LIBS) $(LINK_OPT) $+ else ccomp: $(CCOMP_OBJS) @echo "Linking $@" @$(OCAMLOPT) -o $@ $(LIBS) $(LINK_OPT) $+ endif else ccomp: ccomp.byte @echo "Copying to $@" @$(COPY) $+ $@ endif # DM force compilation without checking dependencies ccomp.force: $(OCAMLOPT) -o $@ $(LIBS) $(LINK_OPT) $(CCOMP_OBJS) ifeq ($(OCAML_LM_PROF), true) ccomp.byte: $(CCOMP_OBJS:.cmx=.cmo) @echo "Linking $@ with landmarks profiling" @$(OCAMLFIND) ocamlc $(COMPFLAGS) -o $@ $(LMFLAGS_LINK) $(LIBS_BYTE) $+ else ccomp.byte: $(CCOMP_OBJS:.cmx=.cmo) @echo "Linking $@" @$(OCAMLC) -o $@ $(LIBS_BYTE) $+ endif CLIGHTGEN_OBJS:=$(shell $(MODORDER) export/ExportDriver.cmx) ifeq ($(OCAML_NATIVE_COMP),true) ifeq ($(OCAML_LM_PROF), true) clightgen: $(CLIGHTGEN_OBJS) @echo "Linking $@ with landmarks profiling" @$(OCAMLFIND) opt $(COMPFLAGS) -o $@ $(LMFLAGS_LINK) $(LIBS) $(LINK_OPT) $+ else clightgen: $(CLIGHTGEN_OBJS) @echo "Linking $@" @$(OCAMLOPT) -o $@ $(LIBS) $(LINK_OPT) $+ endif else clightgen: clightgen.byte @echo "Copying to $@" @$(COPY) $+ $@ endif clightgen.byte: $(CLIGHTGEN_OBJS:.cmx=.cmo) @echo "Linking $@" @$(OCAMLC) -o $@ $(LIBS_BYTE) $+ include .depend.extr endif # End of part that assumes .depend.extr already exists ifeq ($(OCAML_LM_PROF), true) %.cmi: %.mli @echo "OCAMLC $< with landmarks profiling" @$(OCAMLFIND) ocamlc $(COMPFLAGS) -c $(LMFLAGS_COMP) $< else %.cmi: %.mli @echo "OCAMLC $<" @$(OCAMLC) -c $< endif ifeq ($(OCAML_LM_PROF), true) %.cmo: %.ml @echo "OCAMLC $< with landmarks profiling" @$(OCAMLFIND) ocamlc $(COMPFLAGS) -c $(LMFLAGS_COMP) $< else %.cmo: %.ml @echo "OCAMLC $<" @$(OCAMLC) -c $< endif ifeq ($(OCAML_LM_PROF), true) %.cmx: %.ml @echo "OCAMLOPT $< with landmarks profiling" @$(OCAMLFIND) opt $(COMPFLAGS) -c $(LMFLAGS_COMP) $< else %.cmx: %.ml @echo "OCAMLOPT $<" @$(OCAMLOPT) -c $< endif %.ml: %.mll $(OCAMLLEX) $< clean: rm -f $(EXECUTABLES) rm -f $(GENERATED) for d in $(DIRS); do rm -f $$d/*.cm[iotx] $$d/*cmti $$d/*.o; done $(MAKE) -C cparser clean # Generation of .depend.extr depend: $(GENERATED) @echo "Analyzing OCaml dependencies" @$(OCAMLDEP) $(foreach d,$(DIRS),$(wildcard $(d)/*.ml)) $(GENERATED) >.depend.extr || { rm -f .depend.extr; exit 2; } @$(OCAMLDEP) $(foreach d,$(DIRS),$(wildcard $(d)/*.mli)) $(GENERATED) >>.depend.extr || { rm -f .depend.extr; exit 2; }