|
| 1 | +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2 | +# This file is part of the DpdGraph tools. |
| 3 | +# Copyright (C) 2009-2017 Anne Pacalet ([email protected]) |
| 4 | +# and Yves Bertot ([email protected]) |
| 5 | +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 6 | +# This file is distributed under the terms of the |
| 7 | +# GNU Lesser General Public License Version 2.1 |
| 8 | +#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 9 | + |
| 10 | +.SUFFIXES: |
| 11 | + |
| 12 | +ECHO=@echo |
| 13 | +ECHO_CIBLE = $(ECHO) " * build $@" |
| 14 | + |
| 15 | +PRE=dpd |
| 16 | + |
| 17 | +NAME=@PACKAGE_NAME@ |
| 18 | +VERSION=@PACKAGE_VERSION@ |
| 19 | + |
| 20 | +BINDIR=@BINDIR@ |
| 21 | + |
| 22 | +DPDPLUGIN=./dpdgraph.vo |
| 23 | +DPD2DOT=./dpd2dot |
| 24 | +DPDUSAGE=./dpdusage |
| 25 | + |
| 26 | +INCLUDES = -I @OCAMLGRAPH_PATH@ |
| 27 | + |
| 28 | +all : $(DPDPLUGIN) $(DPD2DOT) $(DPDUSAGE) |
| 29 | + |
| 30 | +DISTRIBUTED = $(PRE)_compute.ml $(PRE)_dot.ml \ |
| 31 | + $(PRE)_parse.mly $(PRE)_lex.mll $(PRE)2dot.ml $(PRE)usage.ml |
| 32 | + |
| 33 | +DISTRIBUTED+=dpdgraph.v |
| 34 | + |
| 35 | +ML_COMMON = version.ml $(PRE)_compute.ml $(PRE)_dot.ml \ |
| 36 | + $(PRE)_parse.ml $(PRE)_lex.ml |
| 37 | +MLI_COMMON = version.mli $(PRE)_compute.mli $(PRE)_dot.mli $(PRE)_lex.mli |
| 38 | +ML_DPD2DOT = $(PRE)2dot.ml |
| 39 | +MLI_DPD2DOT = $(PRE)2dot.mli |
| 40 | +ML_DPDUSAGE = $(PRE)usage.ml |
| 41 | +MLI_DPDUSAGE = $(PRE)usage.mli |
| 42 | + |
| 43 | +DISTRIBUTED+=$(MLI_COMMON) $(MLI_DPD2DOT) $(MLI_DPDUSAGE) |
| 44 | + |
| 45 | +ML_ALL = $(ML_COMMON) $(ML_DPD2DOT) $(ML_DPDUSAGE) |
| 46 | + |
| 47 | +CMIS_DPD2DOT=$(MLI_COMMON:%.ml=%.cmo) $(MLI_DPD2DOT:%.ml=%.cmo) |
| 48 | +CMOS_DPD2DOT=$(ML_COMMON:%.ml=%.cmo) $(ML_DPD2DOT:%.ml=%.cmo) |
| 49 | +CMIS_DPDUSAGE=$(MLI_COMMON:%.ml=%.cmo) $(MLI_DPDUSAGE:%.ml=%.cmo) |
| 50 | +CMOS_DPDUSAGE=$(ML_COMMON:%.ml=%.cmo) $(ML_DPDUSAGE:%.ml=%.cmo) |
| 51 | +CMXS=$(ML_ALL:%.ml=%.cmx) |
| 52 | + |
| 53 | +OCAMLC=@OCAMLC@ |
| 54 | +OCAMLOPT=@OCAMLOPT@ |
| 55 | +OCAMLDEP=@OCAMLDEP@ |
| 56 | +OCAMLLEX=@OCAMLLEX@ |
| 57 | +OCAMLYACC=@OCAMLYACC@ |
| 58 | + |
| 59 | +WARN_ERR := -warn-error +a |
| 60 | +OCAMLFLAGS := -w +a $(WARN_ERR) -g -dtypes $(INCLUDES) -c |
| 61 | +OCAMLFLAGS += $(OCAML_EXTRA_OPTS) |
| 62 | +OCAMLOPTFLAGS = -c |
| 63 | + |
| 64 | +COQ_MAKEFILE=@COQ_MAKEFILE@ |
| 65 | +# COQDEP=$(OCAMLDEP) |
| 66 | + |
| 67 | +COQEXTFILES=searchdepend.mlg graphdepend.mlg |
| 68 | + |
| 69 | +GENERATED+=$(COQEXTFILES:%.mlg=%.o) $(COQEXTFILES:%.mlg=%.cmx) dpdgraph.cmxs |
| 70 | + |
| 71 | +DISTRIBUTED+=$(COQEXTFILES) dpdgraph.mllib |
| 72 | +DISTRIBUTED+=Make |
| 73 | + |
| 74 | +install : Make_coq |
| 75 | + $(MAKE) -f $< install |
| 76 | + cp dpd2dot dpdusage $(BINDIR)/ |
| 77 | + |
| 78 | +$(DPDPLUGIN) : Make_coq $(DISTRIBUTED) |
| 79 | + $(ECHO_CIBLE) |
| 80 | + $(MAKE) -f $< $@ |
| 81 | + |
| 82 | +Make_coq : Make |
| 83 | + $(ECHO_CIBLE) |
| 84 | + $(COQ_MAKEFILE) -f $< -o $@ |
| 85 | + |
| 86 | +GENERATED+= Make_coq |
| 87 | + |
| 88 | +version.ml : configure |
| 89 | + $(ECHO_CIBLE) |
| 90 | + $(ECHO) "(* This file is generated by Makefile. Do not modify. *)" > $@ |
| 91 | + $(ECHO) "let version = \""$(VERSION)"\"" >> $@ |
| 92 | + |
| 93 | +GENERATED+=version.ml |
| 94 | + |
| 95 | +$(DPD2DOT) : $(CMOS_DPD2DOT) $(CMIS_DPD2DOT) |
| 96 | + $(ECHO_CIBLE) |
| 97 | + $(OCAMLC) -g $(INCLUDES) -o $@ graph.cma $(CMOS_DPD2DOT) |
| 98 | + |
| 99 | +$(DPDUSAGE) : $(CMOS_DPDUSAGE) $(CMIS_DPDUSAGE) |
| 100 | + $(ECHO_CIBLE) |
| 101 | + $(OCAMLC) -g $(INCLUDES) -o $@ graph.cma $(CMOS_DPDUSAGE) |
| 102 | + |
| 103 | +%.cmo : %.ml |
| 104 | + $(ECHO_CIBLE) |
| 105 | + $(OCAMLC) $(OCAMLFLAGS) $< |
| 106 | + |
| 107 | +%.cmx : %.ml |
| 108 | + $(ECHO_CIBLE) |
| 109 | + $(OCAMLOPT) $(OPTPACKFLAGS) $(OCAMLOPTFLAGS) $< |
| 110 | + |
| 111 | +%.cmi : %.mli |
| 112 | + $(ECHO_CIBLE) |
| 113 | + $(OCAMLC) $(OCAMLFLAGS) $< |
| 114 | + |
| 115 | +%.ml : %.mll |
| 116 | + $(ECHO_CIBLE) |
| 117 | + $(OCAMLLEX) $< |
| 118 | + |
| 119 | +GENERATED+=$(PRE)_lex.ml |
| 120 | + |
| 121 | +%.ml : %.mly |
| 122 | + $(ECHO_CIBLE) |
| 123 | + $(OCAMLYACC) $< |
| 124 | + |
| 125 | +GENERATED+=$(PRE)_parse.ml $(PRE)_parse.mli |
| 126 | + |
| 127 | +depend: .depend |
| 128 | + |
| 129 | +.depend : $(ML_ALL) |
| 130 | + $(ECHO_CIBLE) |
| 131 | + $(OCAMLDEP) $(ML_ALL) *.mli > $@ |
| 132 | + |
| 133 | +include .depend |
| 134 | + |
| 135 | +GENERATED+=.depend |
| 136 | + |
| 137 | +#------------------------------------------------------------------------------- |
| 138 | + |
| 139 | +TESTDIR=tests |
| 140 | +TESTS_SRC=$(TESTDIR)/Morph.v $(TESTDIR)/Test.v $(TESTDIR)/Polymorph.v \ |
| 141 | + $(TESTDIR)/PrimitiveProjections.v\ |
| 142 | + $(TESTDIR)/Morph.cmd $(TESTDIR)/Test.cmd $(TESTDIR)/search.cmd \ |
| 143 | + $(TESTDIR)/Polymorph.cmd $(TESTDIR)/PrimitiveProjections.cmd |
| 144 | +TESTS_DPD=$(TESTDIR)/graph.dpd $(TESTDIR)/graph2.dpd \ |
| 145 | + $(TESTDIR)/Morph.dpd $(TESTDIR)/Morph_rw.dpd \ |
| 146 | + $(TESTDIR)/Polymorph.dpd \ |
| 147 | + $(TESTDIR)/PrimitiveProjections.dpd \ |
| 148 | + $(TESTDIR)/PrimitiveProjections2.dpd |
| 149 | +TESTS_DOT=$(TESTS_DPD:%.dpd=%.dot) |
| 150 | +TESTS_ERR_DPD=$(wildcard $(TESTDIR)/*.err.dpd) |
| 151 | + |
| 152 | +TESTS=$(TESTS_DPD) $(TESTS_DOT) $(TESTDIR)/graph.without.dot \ |
| 153 | + $(TESTDIR)/search $(TESTDIR)/graph2.dpdusage \ |
| 154 | + $(TESTS_ERR_DPD:%.dpd=%) $(TESTDIR)/file_not_found.err |
| 155 | +TESTS_LOG=$(TESTS:%=%.log) |
| 156 | +TESTS_ORACLE=$(TESTS:%=%.oracle) |
| 157 | +TESTS_OK=$(TESTS:%=%.ok) |
| 158 | + |
| 159 | +DISTRIBUTED+=$(TESTS_SRC) $(TESTS_ORACLE) |
| 160 | + |
| 161 | +.PRECIOUS : $(TESTS) $(TESTS_LOG) $(TESTS_ORACLE) |
| 162 | + |
| 163 | +.PHONY: tests test |
| 164 | +tests test : $(TESTS_OK) |
| 165 | + |
| 166 | +.PHONY: test-suite |
| 167 | +test-suite: |
| 168 | + rm -f tests.ok |
| 169 | + ($(MAKE) tests && touch tests.ok) | tee tmp.log |
| 170 | + if grep DIFFERENCES tmp.log >/dev/null 2>&1 ; then \ |
| 171 | + for i in $$(grep DIFFERENCES tmp.log | grep -o 'diff .*' | sed s'/diff //g' | sed s'/ /~/g'); do \ |
| 172 | + i="$$(echo "$$i" | sed s'/~/ /g')"; \ |
| 173 | + echo diff $$i; \ |
| 174 | + diff $$i; \ |
| 175 | + done ; \ |
| 176 | + fi |
| 177 | + if grep DIFFERENCES tmp.log >/dev/null 2>&1 ; then false ; else true ; fi |
| 178 | + rm tests.ok |
| 179 | + |
| 180 | +$(TESTDIR)/%.dpdusage.log: $(TESTDIR)/%.dpd $(DPDUSAGE) |
| 181 | + $(DPDUSAGE) $< > $@ |
| 182 | + |
| 183 | +$(TESTDIR)/file_not_found.err.log: $(DPD2DOT) |
| 184 | + $(DPD2DOT) file_not_found.err.dpd > $@ 2>&1 |
| 185 | + |
| 186 | +$(TESTDIR)/%.err.log: $(TESTDIR)/%.err.dpd $(DPD2DOT) |
| 187 | + $(DPD2DOT) $< > $@ 2>&1 |
| 188 | + |
| 189 | +%.log : % |
| 190 | + cp $< $@ |
| 191 | + |
| 192 | +%.vo : %.v |
| 193 | + coqc -q -R . dpdgraph $< |
| 194 | + |
| 195 | +%.html : %.v |
| 196 | + coqdoc $< |
| 197 | + |
| 198 | +%.svg : %.dot |
| 199 | + dot -Tsvg -o$@ $< |
| 200 | + |
| 201 | +$(TESTDIR)/Morph%.dpd : $(TESTDIR)/Morph.vo $(TESTDIR)/Morph.cmd $(DPDPLUGIN) |
| 202 | + # cd to tests to generate .dpd file there. |
| 203 | + cd $(TESTDIR); coqtop -R .. dpdgraph -I .. < Morph.cmd > /dev/null 2>&1 |
| 204 | + |
| 205 | +$(TESTDIR)/Polymorph%.dpd : $(TESTDIR)/Polymorph.vo $(TESTDIR)/Polymorph.cmd \ |
| 206 | + $(DPDPLUGIN) |
| 207 | + cd $(TESTDIR); coqtop -R .. dpdgraph -I .. < Polymorph.cmd |
| 208 | + |
| 209 | +$(TESTDIR)/graph.dpd $(TESTDIR)/graph2.dpd: \ |
| 210 | + $(TESTDIR)/Test.vo $(TESTDIR)/Test.cmd $(DPDPLUGIN) |
| 211 | + # cd to tests to generate .dpd file there. |
| 212 | + cd $(TESTDIR); coqtop -R .. dpdgraph -I .. < Test.cmd > /dev/null 2>&1 |
| 213 | + |
| 214 | +$(TESTDIR)/PrimitiveProjections.dpd $(TESTDIR)/PrimitiveProjections2.dpd: \ |
| 215 | + $(TESTDIR)/PrimitiveProjections.vo $(TESTDIR)/PrimitiveProjections.cmd $(DPDPLUGIN) |
| 216 | + # cd to tests to generate .dpd file there. |
| 217 | + cd $(TESTDIR); coqtop -R .. dpdgraph -I .. < PrimitiveProjections.cmd > /dev/null 2>&1 |
| 218 | + |
| 219 | +%.dpd : %.vo %.cmd |
| 220 | + # cd to tests to generate .dpd file there. |
| 221 | + cd $(TESTDIR); coqtop -R .. dpdgraph -I .. < $(*F).cmd > /dev/null 2>&1 |
| 222 | + |
| 223 | +$(TESTDIR)/search.log : $(TESTDIR)/Test.vo $(TESTDIR)/search.cmd $(DPDPLUGIN) |
| 224 | + cat $(TESTDIR)/search.cmd | coqtop -R . dpdgraph -I . 2> /dev/null \ |
| 225 | + | sed -e 's/Welcome to Coq.*/Welcome to Coq/' > $@ |
| 226 | + |
| 227 | +%.dot : %.dpd $(DPD2DOT) |
| 228 | + $(DPD2DOT) $< > /dev/null |
| 229 | + |
| 230 | +%.without.dot : %.dpd $(DPD2DOT) |
| 231 | + $(DPD2DOT) -without-defs -o $@ $< > /dev/null |
| 232 | + |
| 233 | +%.zgr : %.dot |
| 234 | + zgrviewer $< |
| 235 | + |
| 236 | +%.ok : %.log %.oracle |
| 237 | + $(ECHO_CIBLE) |
| 238 | + @if diff $*.oracle $*.log > /dev/null ; then \ |
| 239 | + echo "Bravo... Test [32mOk[0m" ; \ |
| 240 | + touch $@ ; \ |
| 241 | + else \ |
| 242 | + echo "[31mDIFFERENCES[0m : diff $*.oracle $*.log" ; \ |
| 243 | + echo "To force a new execution of the test:" ; \ |
| 244 | + echo " rm $*.log ; make $*.ok"; \ |
| 245 | + echo "[31mTo accept the results[0m: " ; \ |
| 246 | + echo " cp $*.log $*.oracle" ; \ |
| 247 | + rm -f $@ ; \ |
| 248 | + fi |
| 249 | + |
| 250 | +# oracle is updated by user, but one is needed the first time |
| 251 | +%.oracle : |
| 252 | + $(ECHO_CIBLE) "[WARNING : automatic generation of $@]" |
| 253 | + $(MAKE) $*.log |
| 254 | + cp $*.log $*.oracle |
| 255 | + |
| 256 | +#------------------------------------------------------------------------------- |
| 257 | +DISTRIBUTED+=Makefile LICENSE README.md configure Makefile.in |
| 258 | + |
| 259 | +distrib : $(NAME)-$(VERSION).tgz |
| 260 | + |
| 261 | +%.tgz : clean |
| 262 | + $(ECHO_CIBLE) |
| 263 | + rm -rf $* $@ |
| 264 | + mkdir $* |
| 265 | + cp --parents $(DISTRIBUTED) $* |
| 266 | + tar zcvf $@ $* |
| 267 | + rm -rf $* |
| 268 | + $(ECHO) "Don't forget to copy README.md and $@ on the server if needed" |
| 269 | + |
| 270 | + |
| 271 | +#------------------------------------------------------------------------------- |
| 272 | +# Configuration |
| 273 | + |
| 274 | +Makefile: Makefile.in config.status |
| 275 | + $(ECHO_CIBLE) |
| 276 | + ./config.status $@ |
| 277 | + |
| 278 | +config.status: configure |
| 279 | + ./config.status --recheck |
| 280 | + |
| 281 | +#------------------------------------------------------------------------------- |
| 282 | +clean_coq : Make_coq |
| 283 | + $(MAKE) -f $< clean |
| 284 | + |
| 285 | +clean_test : |
| 286 | + rm -f $(TESTS) $(TESTS_LOG) $(TESTS_OK) |
| 287 | + rm -f $(TESTDIR)/Test.vo $(TESTDIR)/Test.glob |
| 288 | + rm -f $(TESTDIR)/Morph.vo $(TESTDIR)/Morph.glob |
| 289 | + rm -f $(TESTDIR)/Polymorph.vo $(TESTDIR)/Polymorph.glob |
| 290 | + rm -f $(TESTDIR)/.*.vo.aux |
| 291 | + |
| 292 | +clean_config: |
| 293 | + rm -rf autom4te.cache |
| 294 | + rm -f configure config.log config.status |
| 295 | + rm -r Makefile |
| 296 | + |
| 297 | +clean : clean_coq clean_test |
| 298 | + rm -f $(GENERATED) |
| 299 | + rm -f $(CMOS_DPDUSAGE) $(CMOS_DPD2DOT) $(CMXS) $(ML_ALL:%.ml=%.o) *.cmi |
| 300 | + rm -f $(ML_ALL:%.ml=%.annot) |
| 301 | + rm -f $(DPD2DOT) $(DPDUSAGE) $(DPDPLUGIN) |
| 302 | + $(ECHO) "Use: make clean_config to remove configuration generated files" |
| 303 | + |
| 304 | +archi_clean: clean clean_config |
| 305 | + |
| 306 | +#------------------------------------------------------------------------------- |
0 commit comments