1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
## -*- mode: makefile -*-
.PHONY: all all-subdirs all-local
.PHONY: all-auto all-auto-ocaml-prog clean-buildings
.PHONY: clean clean-subdirs clean-local
.PHONY: install install-subdirs install-local
.PHONY: dist tarball dist-subdirs dist-local
.PHONY: doc doc-local doc-subdirs doc-auto
include $(top_srcdir)/Makefile.defs
all: all-local all-subdirs all-auto
install: install-local install-subdirs
clean: clean-subdirs clean-local clean-buildings
rm -f *.~ *.orig *.cmo *.cmi *.cmx *.cma *.cmxa *.cmxs *.o *.so *.a *.annot *.cmt *.cmti
doc: doc-local doc-subdirs doc-auto
# Those rules must be bound
all-local:
install-local:
clean-local:
# Recursions
all-subdirs:
@for dir in $(SUBDIRS) ; do \
$(MAKE) -C $$dir all || exit $$? ; \
done
install-subdirs:
@for dir in $(SUBDIRS) ; do \
$(MAKE) -C $$dir install || exit $$? ; \
done
clean-subdirs:
-@for dir in $(SUBDIRS) ; do \
$(MAKE) -C $$dir clean || exit $$? ; \
done
doc-subdirs:
@for dir in $(SUBDIRS) ; do \
$(MAKE) -C $$dir doc || exit $$? ; \
done
#
# Automatic buildings
#
##############################################################################
clean-buildings:
@if test -f auto_clean ; then \
cat auto_clean | xargs rm -f ; \
rm -f auto_clean ; \
fi
ifdef ocaml_tests
rm -f *_depend
endif
ifdef ocaml_progs
rm -f *_depend
rm -f $(ocaml_progs)$(EXEEXT)
endif
all-auto: all-auto-ocaml-prog
all-auto-ocaml-prog:
@for prog in $(ocaml_progs) $(if $(BUILD_TESTS),$(ocaml_tests)) ; do \
$(MAKE) PROG=$$prog $$prog$(EXEEXT) || exit $$? ; \
done
ifdef PROG
$(PROG)_mly=$(wildcard $($(PROG)_sources:.ml=.mly))
$(PROG)_headers=$(wildcard $($(PROG)_sources:.ml=.mli)) $($(PROG)_mly:.mly=.mli)
# Grab program-specific flags
_OCAML_CFLAGS=$($(PROG)_ocamlcflags)
_OCAML_LFLAGS=$($(PROG)_ocamllflags)
-include $(PROG)_depend
$(PROG)_depend: $($(PROG)_sources) $($(PROG)_headers)
$(V)echo OCAMLDEP
$(V)$(OCAMLDEP) $(_DEP_OPTS) $(DEP_OPTS) \
$($(PROG)_sources) $($(PROG)_headers) > $@
dll$(PROG).so: $($(PROG)_c_files:.c=.o)
$(V)echo OCAMLMKLIB -o dll$(PROG).so
$(V)$(OCAMLMKLIB) -o $(PROG) $($(PROG)_c_files:.c=.o)
ifdef $(PROG)_c_files
ifeq ($(BYTE),yes)
ifeq ($(NO_CUSTOM),yes)
c_objs=dll$(PROG).so $($(PROG)_c_files:.c=.o)
c_link=-dllib dll$(PROG).so
else
c_objs=$($(PROG)_c_files:.c=.o)
c_link=-custom $($(PROG)_c_files:.c=.o)
endif
else
c_objs=$($(PROG)_c_files:.c=.o)
c_link=$(c_objs)
endif
endif
$(PROG)$(EXEEXT): $($(PROG)_sources:.ml=.$(o)) $(c_objs)
$(V)echo $(OCAMLCOMP) -o $(PROG)$(EXEEXT)
$(V)$(OCAMLC) -o $(PROG)$(EXEEXT) \
$(_OCAML_CFLAGS) $(OCAML_CFLAGS) \
$(_OCAML_LFLAGS) $(OCAML_LFLAGS) \
$($(PROG)_sources:.ml=.$(o)) \
$(c_link)
endif
%.ml: %.mll
@echo $(<:.mll=.mli) $(<:.mll=.ml) >> auto_clean
$(V)echo OCAMLLEX $<
$(V)$(OCAMLLEX) $<
%.ml %.mli: %.mly
@echo $(<:.mly=.mli) $(<:.mly=.ml) $(<:.mly=.conflicts) >> auto_clean
$(V)echo MENHIR $<
$(V)$(MENHIR) --unused-tokens --explain $<
%.$(o): %.ml
$(V)echo $(OCAMLCOMP) -c $<
$(V)$(OCAMLC) $(_OCAML_CFLAGS) $(OCAML_CFLAGS) -c $<
%.$(i): %.mli
$(V)echo $(OCAMLCOMP) -c $<
$(V)$(OCAMLC) $(_OCAML_CFLAGS) $(OCAML_CFLAGS) -c $<
%.o: %.c
$(V)echo CC -c $<
$(V)$(CC) $(CFLAGS) -c $< -o $@
#
# dist
#
##############################################################################
dist-subdirs:
for dir in $(SUBDIRS) ; do \
mkdir $(DDIR)/$$dir || exit $$? ; \
DDIR="../$(DDIR)/$$dir" $(MAKE) -C $$dir dist-local \
|| exit $$? ; \
done
dist-local: dist-subdirs
ifdef DISTFILES
cp $(DISTFILES) $(DDIR)
endif
ifdef DISTDIRS
cp -rfL $(DISTDIRS) $(DDIR)
endif
find $(DDIR) -name .svn | while read i; do rm -rf "$$i"; done
find $(DDIR) -name .git | while read i; do rm -rf "$$i"; done
dist:
@a=`cd $(top_srcdir) ; pwd ` ; b=`pwd` ; [ "eq$$a" = "eq$$b" ] \
|| (echo You must be at toplevel to invoke make dist. \
&& exit $$?)
rm -rf $(DISTDIR)
mkdir $(DISTDIR)
DDIR=$(DISTDIR) $(MAKE) dist-local
configure: configure.ac install-sh
./bootstrap
./configure-with-options || ./configure
tarball: configure pre-distclean dist
tar cjf $(DISTDIR).tar.bz2 $(DISTDIR)
rm -rf $(DISTDIR)
#
# Documentation
#
###############################################################################
ifdef PROG
# Extract the -I and -package options from the ocaml_cflags,
# but not those coming from e.g. -ccopt "-I.. -fPIC"
_OCAML_DFLAGS=$(shell echo '$(_OCAML_CFLAGS) $(OCAML_CFLAGS)' | perl -pe '$$opt = "" ; s/"[^"]*"//g ; s/(-I\s*\S+|-package\s*\S+)/my $$a = $$1 ; if ($$a =~ m:-package\s*(\S)(\S+):) { $$opt="$$opt $$a -hide ".(uc $$1).$$2 } else { $$opt="$$opt $$a" }/eg ; $$_ = $$opt')
_OCAML_DFILES=$(shell echo $($(PROG)_doc_sources) | perl -pe 's/[^\s]+\.[co]//g')
_OCAML_DFILES_H=$(wildcard $(_OCAML_DFILES:.ml=.mli))
$(top_srcdir)/autodoc/$(PROG)/index.html: $($(PROG)_doc_sources)
mkdir -p $(top_srcdir)/autodoc/$(PROG)
$(OCAMLFIND) ocamldoc -stars -sort -html -d $(top_srcdir)/autodoc/$(PROG) \
-t $(PROG) -I +threads \
$(OCAML_DFLAGS) $(_OCAML_DFLAGS) $(_OCAML_DFILES) $(_OCAML_DFILES_H)
endif
ifdef ocaml_progs
doc-auto: all-auto-ocaml-prog
for prog in $(ocaml_progs) ; do \
PROG=$$prog $(MAKE) $(top_srcdir)/autodoc/$$prog/index.html \
|| exit $$? ; \
done
endif
doc-clean:
rm -rf $(top_srcdir)/autodoc/*
|