Makefiles: restructure CAMLDEP usage to easily add flags
This change should be a refactoring no-op. Before, a DEPFLAGS variable existed in some makefiles to contain include directories to be passed to ocamldep invocations, but no support for easily adding command-line flags to ocamldep was available (invocations would systematically use -slash, which was duplicated across callsites). With this PR, a new DEPINCLUDES variable contains the include directories, and DEPFLAGS is repurposed to contain other command-line flags for the tool -- currently "slash".master
parent
9cabb9fa54
commit
46ef054330
19
Makefile
19
Makefile
|
@ -65,7 +65,8 @@ endif
|
|||
YACCFLAGS=-v --strict
|
||||
CAMLLEX=$(CAMLRUN) boot/ocamllex
|
||||
CAMLDEP=$(CAMLRUN) boot/ocamlc -depend
|
||||
DEPFLAGS=$(INCLUDES)
|
||||
DEPFLAGS=-slash
|
||||
DEPINCLUDES=$(INCLUDES)
|
||||
|
||||
OCAMLDOC_OPT=$(WITH_OCAMLDOC:=.opt)
|
||||
|
||||
|
@ -1373,21 +1374,21 @@ partialclean::
|
|||
depend: beforedepend
|
||||
(for d in utils parsing typing bytecomp asmcomp middle_end \
|
||||
middle_end/base_types asmcomp/debug driver toplevel; \
|
||||
do $(CAMLDEP) -slash $(DEPFLAGS) $$d/*.mli $$d/*.ml || exit; \
|
||||
do $(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) $$d/*.mli $$d/*.ml || exit; \
|
||||
done) > .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -native \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -native \
|
||||
-impl driver/compdynlink.mlopt >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -bytecode \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -bytecode \
|
||||
-impl driver/compdynlink.mlbyte >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -native \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -native \
|
||||
-impl driver/compdynlink_common.mlopt >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -bytecode \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -bytecode \
|
||||
-impl driver/compdynlink_common.mlbyte >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -native \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -native \
|
||||
-impl driver/compdynlink_platform_intf.ml >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -native \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -native \
|
||||
-impl driver/compdynlink_types.mlopt >> .depend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) -bytecode \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -bytecode \
|
||||
-impl driver/compdynlink_types.mlbyte >> .depend
|
||||
|
||||
.PHONY: distclean
|
||||
|
|
|
@ -139,10 +139,10 @@ clean-menhir: partialclean-menhir
|
|||
|
||||
.PHONY: depend-menhir
|
||||
depend-menhir:
|
||||
$(MENHIR) --depend --ocamldep "$(CAMLDEP) -slash $(DEPFLAGS)" \
|
||||
$(MENHIR) --depend --ocamldep "$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES)" \
|
||||
parsing/parser.mly > .depend.menhir
|
||||
# this rule depends on the variables CAMLDEP and DEPFLAGS
|
||||
# define in Makefile, so it can only be invoked from the main Makefile
|
||||
# this rule depends on the variables CAMLDEP, DEPFLAGS, DEPINCLUDES
|
||||
# defined in Makefile, so it can only be invoked from the main Makefile
|
||||
|
||||
include .depend.menhir
|
||||
|
||||
|
|
|
@ -29,7 +29,8 @@ LINKFLAGS=-linkall -I $(UNIXDIR)
|
|||
YACCFLAGS=
|
||||
CAMLLEX=$(CAMLRUN) $(ROOTDIR)/boot/ocamllex
|
||||
CAMLDEP=$(CAMLRUN) $(ROOTDIR)/tools/ocamldep
|
||||
DEPFLAGS=$(INCLUDES)
|
||||
DEPFLAGS=-slash
|
||||
DEPINCLUDES=$(INCLUDES)
|
||||
|
||||
DIRECTORIES=$(UNIXDIR) $(addprefix $(ROOTDIR)/,\
|
||||
utils parsing typing bytecomp toplevel driver)
|
||||
|
@ -92,7 +93,7 @@ clean::
|
|||
$(CAMLC) -c $(COMPFLAGS) $<
|
||||
|
||||
depend: beforedepend
|
||||
$(CAMLDEP) -slash $(DEPFLAGS) *.mli *.ml \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mli *.ml \
|
||||
| sed -e 's,$(UNIXDIR)/,$$(UNIXDIR)/,' > .depend
|
||||
|
||||
lexer.ml: lexer.mll
|
||||
|
|
|
@ -32,7 +32,8 @@ LINKFLAGS =
|
|||
YACCFLAGS = -v
|
||||
CAMLLEX = $(CAMLRUN) $(ROOTDIR)/boot/ocamllex
|
||||
CAMLDEP = $(CAMLRUN) $(ROOTDIR)/tools/ocamldep
|
||||
|
||||
DEPFLAGS = -slash
|
||||
DEPINCLUDES =
|
||||
|
||||
OBJS=cset.cmo syntax.cmo parser.cmo lexer.cmo table.cmo lexgen.cmo \
|
||||
compact.cmo common.cmo output.cmo outputbis.cmo main.cmo
|
||||
|
@ -81,6 +82,6 @@ beforedepend:: lexer.ml
|
|||
$(CAMLOPT) -c $(COMPFLAGS) $<
|
||||
|
||||
depend: beforedepend
|
||||
$(CAMLDEP) -slash *.mli *.ml > .depend
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mli *.ml > .depend
|
||||
|
||||
include .depend
|
||||
|
|
|
@ -24,7 +24,8 @@ OCAMLYACC ?= $(ROOTDIR)/yacc/ocamlyacc
|
|||
STDLIBFLAGS = -nostdlib -I $(ROOTDIR)/stdlib
|
||||
OCAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc $(STDLIBFLAGS)
|
||||
OCAMLOPT = $(OCAMLRUN) $(ROOTDIR)/ocamlopt $(STDLIBFLAGS)
|
||||
OCAMLDEP = $(OCAMLRUN) $(ROOTDIR)/tools/ocamldep -slash
|
||||
OCAMLDEP = $(OCAMLRUN) $(ROOTDIR)/tools/ocamldep
|
||||
DEPFLAGS = -slash
|
||||
OCAMLLEX = $(OCAMLRUN) $(ROOTDIR)/boot/ocamllex
|
||||
# TODO: figure out whether the DEBUG lines the following preprocessor removes
|
||||
# are actually useful.
|
||||
|
@ -99,6 +100,7 @@ INCLUDES_NODEP=\
|
|||
-I $(ROOTDIR)/otherlibs/$(UNIXLIB) \
|
||||
-I $(ROOTDIR)/otherlibs/$(GRAPHLIB)
|
||||
|
||||
DEPINCLUDES=$(INCLUDES_DEP)
|
||||
INCLUDES=$(INCLUDES_DEP) $(INCLUDES_NODEP)
|
||||
|
||||
COMPFLAGS=$(INCLUDES) -absname -w +a-4-9-41-42-44-45-48 -warn-error A -safe-string -strict-sequence -strict-formats -bin-annot
|
||||
|
@ -509,7 +511,7 @@ depend:
|
|||
$(OCAMLLEX) odoc_lexer.mll
|
||||
$(OCAMLLEX) odoc_ocamlhtml.mll
|
||||
$(OCAMLLEX) odoc_see_lexer.mll
|
||||
$(OCAMLDEP) $(INCLUDES_DEP) *.mll *.mly *.ml *.mli > .depend
|
||||
$(OCAMLDEP) $(INCLUDES_DEP) -shared generators/*.ml >> .depend
|
||||
$(OCAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mll *.mly *.ml *.mli > .depend
|
||||
$(OCAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) -shared generators/*.ml >> .depend
|
||||
|
||||
include .depend
|
||||
|
|
|
@ -159,7 +159,9 @@ ocamlc := $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/ocamlc $(flags)
|
|||
|
||||
ocamlopt := $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/ocamlopt $(flags)
|
||||
|
||||
ocamldep := $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/tools/ocamldep -slash
|
||||
ocamldep := $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/tools/ocamldep
|
||||
depflags := -slash
|
||||
depincludes :=
|
||||
|
||||
ocamllex := $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/lex/ocamllex
|
||||
|
||||
|
@ -246,7 +248,8 @@ ifneq "$(TOOLCHAIN)" "msvc"
|
|||
depend: $(dependencies_generated_prereqs)
|
||||
$(CC) -MM $(OC_CPPFLAGS) $(c_files) \
|
||||
| sed -e 's/\.o/.$$(O)/' > .depend
|
||||
$(ocamldep) $(mli_files) $(ml_files) >> .depend
|
||||
$(ocamldep) $(depflags) $(depincludes) $(mli_files) $(ml_files) \
|
||||
>> .depend
|
||||
endif
|
||||
|
||||
-include .depend
|
||||
|
|
|
@ -34,6 +34,7 @@ endif
|
|||
OPTCOMPILER=$(ROOTDIR)/ocamlopt
|
||||
CAMLOPT=$(CAMLRUN) $(OPTCOMPILER)
|
||||
CAMLDEP=$(CAMLRUN) $(ROOTDIR)/tools/ocamldep
|
||||
DEPFLAGS=-slash
|
||||
|
||||
OC_CPPFLAGS += -I$(ROOTDIR)/runtime
|
||||
|
||||
|
@ -303,13 +304,14 @@ SPACE := $(EMPTY) $(EMPTY)
|
|||
# it looks for the .cmx file (not .p.cmx).
|
||||
.PHONY: depend
|
||||
depend:
|
||||
$(CAMLDEP) -slash $(filter-out stdlib.%,$(wildcard *.mli *.ml)) \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(filter-out stdlib.%,$(wildcard *.mli *.ml)) \
|
||||
> .depend.tmp
|
||||
$(CAMLDEP) -slash -pp "$(AWK) -f remove_module_aliases.awk" \
|
||||
$(CAMLDEP) $(DEPFLAGS) -pp "$(AWK) -f remove_module_aliases.awk" \
|
||||
stdlib.ml stdlib.mli >> .depend.tmp
|
||||
$(CAMLDEP) -slash $(filter-out stdlib.%,$(wildcard *.ml)) \
|
||||
$(CAMLDEP) $(DEPFLAGS) $(filter-out stdlib.%,$(wildcard *.ml)) \
|
||||
| sed -e 's/\.cmx : /.p.cmx : /g' >>.depend.tmp
|
||||
$(CAMLDEP) -slash -pp "$(AWK) -f remove_module_aliases.awk" stdlib.ml \
|
||||
$(CAMLDEP) $(DEPFLAGS) -pp "$(AWK) -f remove_module_aliases.awk" \
|
||||
stdlib.ml \
|
||||
| sed -e 's/\.cmx : /.p.cmx : /g' >> .depend.tmp
|
||||
sed -Ee \
|
||||
's#(^| )(${subst ${SPACE},|,${UNPREFIXED_OBJS}})[.]#\1stdlib__\2.#g' \
|
||||
|
|
|
@ -425,8 +425,11 @@ clean::
|
|||
clean::
|
||||
rm -f *.cmo *.cmi *.cma *.dll *.so *.lib *.a
|
||||
|
||||
CAMLDEP=$(CAMLRUN) ./ocamldep
|
||||
DEPFLAGS=-slash
|
||||
DEPINCLUDES=$(INCLUDES)
|
||||
depend: beforedepend
|
||||
$(CAMLRUN) ./ocamldep -slash $(INCLUDES) *.mli *.ml > .depend
|
||||
$(CAMLDEP) $(DEPFLAGS) $(DEPINCLUDES) *.mli *.ml > .depend
|
||||
|
||||
.PHONY: clean install beforedepend depend
|
||||
|
||||
|
|
Loading…
Reference in New Issue