| 1 | |
| 2 | ############################################################################# |
| 3 | # Configuration section |
| 4 | ############################################################################# |
| 5 | |
| 6 | -include Makefile.config |
| 7 | -include /etc/lsb-release |
| 8 | |
| 9 | VERSION=$(shell cat globals/config.ml.in |grep version |perl -p -e 's/.*"(.*)".*/$$1/;') |
| 10 | CCVERSION=$(shell cat scripts/coccicheck/README |grep "Coccicheck version" |perl -p -e 's/.*version (.*)[ ]*/$$1/;') |
| 11 | PKGVERSION=$(shell dpkg-parsechangelog -ldebian/changelog.$(DISTRIB_CODENAME) 2> /dev/null \ |
| 12 | | sed -n 's/^Version: \(.*\)/\1/p' ) |
| 13 | |
| 14 | ############################################################################## |
| 15 | # Variables |
| 16 | ############################################################################## |
| 17 | TARGET=spatch |
| 18 | PRJNAME=coccinelle |
| 19 | |
| 20 | SRC=flag_cocci.ml cocci.ml testing.ml test.ml main.ml |
| 21 | |
| 22 | ifeq ($(FEATURE_PYTHON),1) |
| 23 | PYCMA=pycaml.cma |
| 24 | # the following is essential for Coccinelle to compile under gentoo (weird) |
| 25 | #OPTLIBFLAGS=-cclib dllpycaml_stubs.so |
| 26 | else |
| 27 | PYCMA= |
| 28 | endif |
| 29 | OPTLIBFLAGS= |
| 30 | |
| 31 | ifeq ("$(SEXPDIR)","ocamlsexp") |
| 32 | SEXPLIB=sexplib.cmo |
| 33 | OPTSEXPLIB=sexplib.cmx |
| 34 | else |
| 35 | SEXPLIB=sexplib.cma |
| 36 | OPTSEXPLIB=sexplib.cmxa |
| 37 | endif |
| 38 | |
| 39 | ifeq ("$(DYNLINK)","no") |
| 40 | DYNLINK= |
| 41 | else |
| 42 | DYNLINK=dynlink.cma |
| 43 | endif |
| 44 | |
| 45 | SEXPSYSCMA=bigarray.cma nums.cma |
| 46 | |
| 47 | SYSLIBS=str.cma unix.cma $(SEXPSYSCMA) $(PYCMA) $(DYNLINK) # threads.cma |
| 48 | LIBS=commons/commons.cma \ |
| 49 | commons/commons_sexp.cma \ |
| 50 | globals/globals.cma \ |
| 51 | ctl/ctl.cma \ |
| 52 | parsing_cocci/cocci_parser.cma parsing_c/parsing_c.cma \ |
| 53 | engine/cocciengine.cma popl09/popl.cma \ |
| 54 | extra/extra.cma python/coccipython.cma ocaml/cocciocaml.cma |
| 55 | |
| 56 | # Should we use the local version of pycaml |
| 57 | ifeq ($(FEATURE_PYTHON),1) |
| 58 | ifeq ("$(PYCAMLDIR)","pycaml") |
| 59 | LOCALPYCAML=pycaml |
| 60 | else |
| 61 | LOCALPYCAML= |
| 62 | endif |
| 63 | endif |
| 64 | |
| 65 | # Should we use the local version of menhirLib |
| 66 | ifeq ("$(MENHIRDIR)","menhirlib") |
| 67 | LOCALMENHIR=menhirlib |
| 68 | else |
| 69 | LOCALMENHIR= |
| 70 | endif |
| 71 | |
| 72 | # Should we use the local version of ocamlsexp |
| 73 | ifeq ("$(SEXPDIR)","ocamlsexp") |
| 74 | LOCALSEXP=ocamlsexp |
| 75 | else |
| 76 | LOCALSEXP= |
| 77 | endif |
| 78 | |
| 79 | # used for depend: and a little for rec & rec.opt |
| 80 | MAKESUBDIRS=$(LOCALPYCAML) $(LOCALSEXP) commons \ |
| 81 | globals $(LOCALMENHIR) ctl parsing_cocci parsing_c \ |
| 82 | engine popl09 extra python ocaml |
| 83 | |
| 84 | # used for clean: |
| 85 | # It is like MAKESUBDIRS but also |
| 86 | # force cleaning of local library copies |
| 87 | CLEANSUBDIRS=pycaml ocamlsexp commons \ |
| 88 | globals menhirlib ctl parsing_cocci parsing_c \ |
| 89 | engine popl09 extra python ocaml |
| 90 | |
| 91 | INCLUDEDIRSDEP=commons commons/ocamlextra $(LOCALSEXP) \ |
| 92 | globals $(LOCALMENHIR) $(LOCALPYCAML) ctl \ |
| 93 | parsing_cocci parsing_c engine popl09 extra python ocaml |
| 94 | |
| 95 | INCLUDEDIRS=$(INCLUDEDIRSDEP) $(SEXPDIR) $(MENHIRDIR) $(PYCAMLDIR) |
| 96 | |
| 97 | ############################################################################## |
| 98 | # Generic variables |
| 99 | ############################################################################## |
| 100 | |
| 101 | INCLUDES=$(INCLUDEDIRS:%=-I %) |
| 102 | |
| 103 | OBJS= $(SRC:.ml=.cmo) |
| 104 | OPTOBJS= $(SRC:.ml=.cmx) |
| 105 | |
| 106 | EXEC=$(TARGET) |
| 107 | |
| 108 | ############################################################################## |
| 109 | # Generic ocaml variables |
| 110 | ############################################################################## |
| 111 | |
| 112 | OCAMLCFLAGS= |
| 113 | |
| 114 | # for profiling add -p -inline 0 |
| 115 | # but 'make forprofiling' below does that for you. |
| 116 | # This flag is also used in subdirectories so don't change its name here. |
| 117 | # To enable backtrace support for native code, you need to put -g in OPTFLAGS |
| 118 | # to also link with -g. |
| 119 | OPTFLAGS= -g |
| 120 | |
| 121 | OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS) $(INCLUDES) |
| 122 | OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES) |
| 123 | OCAMLLEX=ocamllex #-ml # -ml for debugging lexer, but slightly slower |
| 124 | OCAMLYACC=ocamlyacc -v |
| 125 | OCAMLDEP=ocamldep $(INCLUDEDIRSDEP:%=-I %) |
| 126 | OCAMLMKTOP=ocamlmktop -g -custom $(INCLUDES) |
| 127 | |
| 128 | # can also be set via 'make static' |
| 129 | CFLAGS=-pie -fPIE -fpic -fPIC -static |
| 130 | STATICCFLAGS=$(CFLAGS:%=-ccopt %) |
| 131 | STATIC= # $(STATICCFLAGS) |
| 132 | |
| 133 | # can also be unset via 'make purebytecode' |
| 134 | BYTECODE_STATIC=-custom |
| 135 | |
| 136 | ############################################################################## |
| 137 | # Top rules |
| 138 | ############################################################################## |
| 139 | .PHONY:: all all.opt byte opt top clean distclean configure |
| 140 | .PHONY:: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt) subdirs subdirs.opt |
| 141 | |
| 142 | all: Makefile.config byte preinstall |
| 143 | |
| 144 | opt: all.opt |
| 145 | all.opt: opt-compil preinstall |
| 146 | |
| 147 | world: preinstall |
| 148 | $(MAKE) byte |
| 149 | $(MAKE) opt-compil |
| 150 | |
| 151 | byte: .depend |
| 152 | $(MAKE) subdirs |
| 153 | $(MAKE) $(EXEC) |
| 154 | |
| 155 | opt-compil: .depend |
| 156 | $(MAKE) subdirs.opt |
| 157 | $(MAKE) $(EXEC).opt |
| 158 | |
| 159 | top: $(EXEC).top |
| 160 | |
| 161 | subdirs: |
| 162 | +for D in $(MAKESUBDIRS); do $(MAKE) $$D || exit 1 ; done |
| 163 | $(MAKE) -C commons sexp OCAMLCFLAGS="$(OCAMLCFLAGS)" |
| 164 | |
| 165 | subdirs.opt: |
| 166 | +for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt || exit 1 ; done |
| 167 | $(MAKE) -C commons sexp.opt OPTFLAGS="$(OPTFLAGS)" |
| 168 | |
| 169 | $(MAKESUBDIRS): |
| 170 | $(MAKE) -C $@ OCAMLCFLAGS="$(OCAMLCFLAGS)" all |
| 171 | |
| 172 | $(MAKESUBDIRS:%=%.opt): |
| 173 | $(MAKE) -C $(@:%.opt=%) OPTFLAGS="$(OPTFLAGS)" all.opt |
| 174 | |
| 175 | #dependencies: |
| 176 | # commons: |
| 177 | # globals: |
| 178 | # menhirlib: |
| 179 | # parsing_cocci: commons globals menhirlib |
| 180 | # parsing_c:parsing_cocci |
| 181 | # ctl:globals commons |
| 182 | # engine: parsing_cocci parsing_c ctl |
| 183 | # popl09:engine |
| 184 | # extra: parsing_cocci parsing_c ctl |
| 185 | # pycaml: |
| 186 | # python:pycaml parsing_cocci parsing_c |
| 187 | |
| 188 | clean:: |
| 189 | set -e; for i in $(CLEANSUBDIRS); do $(MAKE) -C $$i $@; done |
| 190 | $(MAKE) -C demos/spp $@ |
| 191 | |
| 192 | $(LIBS): $(MAKESUBDIRS) |
| 193 | $(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt) |
| 194 | |
| 195 | $(OBJS):$(LIBS) |
| 196 | $(OPTOBJS):$(LIBS:.cma=.cmxa) |
| 197 | |
| 198 | $(EXEC): $(LIBS) $(OBJS) |
| 199 | $(OCAMLC) $(BYTECODE_STATIC) -o $@ $(SYSLIBS) $(SEXPLIB) $^ |
| 200 | |
| 201 | $(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS) |
| 202 | $(OCAMLOPT) $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) $(OPTSEXPLIB) $(OPTLIBFLAGS) $^ |
| 203 | |
| 204 | $(EXEC).top: $(LIBS) $(OBJS) |
| 205 | $(OCAMLMKTOP) -custom -o $@ $(SYSLIBS) $(SEXPLIB) $^ |
| 206 | |
| 207 | clean:: |
| 208 | rm -f $(TARGET) $(TARGET).opt $(TARGET).top |
| 209 | |
| 210 | .PHONY:: tools configure |
| 211 | |
| 212 | configure: |
| 213 | ./configure |
| 214 | |
| 215 | Makefile.config: |
| 216 | @echo "Makefile.config is missing. Have you run ./configure?" |
| 217 | @exit 1 |
| 218 | |
| 219 | tools: $(LIBS) |
| 220 | $(MAKE) -C tools |
| 221 | |
| 222 | distclean:: |
| 223 | if [ -d tools ] ; then $(MAKE) -C tools distclean ; fi |
| 224 | |
| 225 | static: |
| 226 | rm -f spatch.opt spatch |
| 227 | $(MAKE) STATIC="$(STATICCFLAGS)" spatch.opt |
| 228 | cp spatch.opt spatch |
| 229 | |
| 230 | purebytecode: |
| 231 | rm -f spatch.opt spatch |
| 232 | $(MAKE) BYTECODE_STATIC="" spatch |
| 233 | perl -p -i -e 's/^#!.*/#!\/usr\/bin\/ocamlrun/' spatch |
| 234 | |
| 235 | |
| 236 | ############################################################################## |
| 237 | # Build documentation |
| 238 | ############################################################################## |
| 239 | .PHONY:: docs |
| 240 | |
| 241 | docs: |
| 242 | make -C docs |
| 243 | |
| 244 | clean:: |
| 245 | make -C docs clean |
| 246 | |
| 247 | distclean:: |
| 248 | make -C docs distclean |
| 249 | |
| 250 | ############################################################################## |
| 251 | # Pre-Install (customization of spatch frontend script) |
| 252 | ############################################################################## |
| 253 | |
| 254 | preinstall: docs/spatch.1 scripts/spatch scripts/spatch.opt scripts/spatch.byte |
| 255 | |
| 256 | docs/spatch.1: Makefile.config |
| 257 | $(MAKE) -C docs spatch.1 |
| 258 | |
| 259 | # user will use spatch to run spatch.opt (native) |
| 260 | scripts/spatch: Makefile.config |
| 261 | cp scripts/spatch.sh scripts/spatch.tmp2 |
| 262 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.tmp2 > scripts/spatch.tmp |
| 263 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.tmp > scripts/spatch |
| 264 | rm -f scripts/spatch.tmp2 scripts/spatch.tmp |
| 265 | |
| 266 | # user will use spatch to run spatch (bytecode) |
| 267 | scripts/spatch.byte: Makefile.config |
| 268 | cp scripts/spatch.sh scripts/spatch.byte.tmp3 |
| 269 | sed "s|\.opt||" scripts/spatch.byte.tmp3 > scripts/spatch.byte.tmp2 |
| 270 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.byte.tmp2 \ |
| 271 | > scripts/spatch.byte.tmp |
| 272 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.byte.tmp \ |
| 273 | > scripts/spatch.byte |
| 274 | rm -f scripts/spatch.byte.tmp3 \ |
| 275 | scripts/spatch.byte.tmp2 \ |
| 276 | scripts/spatch.byte.tmp |
| 277 | |
| 278 | # user will use spatch.opt to run spatch.opt (native) |
| 279 | scripts/spatch.opt: Makefile.config |
| 280 | cp scripts/spatch.sh scripts/spatch.opt.tmp2 |
| 281 | sed "s|SHAREDIR|$(SHAREDIR)|g" scripts/spatch.opt.tmp2 \ |
| 282 | > scripts/spatch.opt.tmp |
| 283 | sed "s|LIBDIR|$(LIBDIR)|g" scripts/spatch.opt.tmp \ |
| 284 | > scripts/spatch.opt |
| 285 | rm -f scripts/spatch.opt.tmp scripts/spatch.opt.tmp2 |
| 286 | |
| 287 | clean:: |
| 288 | rm -f scripts/spatch scripts/spatch.byte scripts/spatch.opt |
| 289 | |
| 290 | ############################################################################## |
| 291 | # Install |
| 292 | ############################################################################## |
| 293 | |
| 294 | # don't remove DESTDIR, it can be set by package build system like ebuild |
| 295 | # for staged installation. |
| 296 | install-common: |
| 297 | mkdir -p $(DESTDIR)$(BINDIR) |
| 298 | mkdir -p $(DESTDIR)$(LIBDIR) |
| 299 | mkdir -p $(DESTDIR)$(SHAREDIR)/ocaml |
| 300 | mkdir -p $(DESTDIR)$(SHAREDIR)/commons |
| 301 | mkdir -p $(DESTDIR)$(SHAREDIR)/globals |
| 302 | mkdir -p $(DESTDIR)$(SHAREDIR)/parsing_c |
| 303 | mkdir -p $(DESTDIR)$(MANDIR)/man1 |
| 304 | $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR) |
| 305 | $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR) |
| 306 | $(INSTALL_DATA) ocaml/coccilib.cmi $(DESTDIR)$(SHAREDIR)/ocaml/ |
| 307 | $(INSTALL_DATA) parsing_c/*.cmi $(DESTDIR)$(SHAREDIR)/parsing_c/ |
| 308 | $(INSTALL_DATA) commons/*.cmi $(DESTDIR)$(SHAREDIR)/commons/ |
| 309 | $(INSTALL_DATA) globals/iteration.cmi $(DESTDIR)$(SHAREDIR)/globals/ |
| 310 | $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/ |
| 311 | @if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi |
| 312 | |
| 313 | install-bash: |
| 314 | mkdir -p $(DESTDIR)$(BASH_COMPLETION_DIR) |
| 315 | $(INSTALL_DATA) scripts/spatch.bash_completion \ |
| 316 | $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch |
| 317 | |
| 318 | install-tools: |
| 319 | mkdir -p $(DESTDIR)$(BINDIR) |
| 320 | $(INSTALL_PROGRAM) tools/splitpatch \ |
| 321 | $(DESTDIR)$(BINDIR)/splitpatch |
| 322 | $(INSTALL_PROGRAM) tools/cocci-send-email.perl \ |
| 323 | $(DESTDIR)$(BINDIR)/cocci-send-email.perl |
| 324 | |
| 325 | install-python: |
| 326 | mkdir -p $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui |
| 327 | $(INSTALL_DATA) python/coccilib/*.py \ |
| 328 | $(DESTDIR)$(SHAREDIR)/python/coccilib |
| 329 | $(INSTALL_DATA) python/coccilib/coccigui/*.py \ |
| 330 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui |
| 331 | $(INSTALL_DATA) python/coccilib/coccigui/pygui.glade \ |
| 332 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui |
| 333 | $(INSTALL_DATA) python/coccilib/coccigui/pygui.gladep \ |
| 334 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui |
| 335 | if [ -f pycaml/dllpycaml_stubs.so ]; then \ |
| 336 | $(INSTALL_LIB) pycaml/dllpycaml_stubs.so $(DESTDIR)$(LIBDIR) ; fi |
| 337 | |
| 338 | install: install-common |
| 339 | @if test -x spatch -a ! -x spatch.opt ; then \ |
| 340 | $(MAKE) install-byte;fi |
| 341 | @if test ! -x spatch -a -x spatch.opt ; then \ |
| 342 | $(MAKE) install-def; $(MAKE) install-opt;fi |
| 343 | @if test -x spatch -a -x spatch.opt ; then \ |
| 344 | $(MAKE) install-byte; $(MAKE) install-opt;fi |
| 345 | @if test ! -x spatch -a ! -x spatch.opt ; then \ |
| 346 | echo "\n\n\t==> Run 'make', 'make opt', or both first. <==\n\n";fi |
| 347 | @echo "" |
| 348 | @echo "\tYou can also install spatch by copying the program spatch" |
| 349 | @echo "\t(available in this directory) anywhere you want and" |
| 350 | @echo "\tgive it the right options to find its configuration files." |
| 351 | @echo "" |
| 352 | |
| 353 | # user will use spatch to run spatch.opt (native) |
| 354 | install-def: |
| 355 | $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR) |
| 356 | $(INSTALL_PROGRAM) scripts/spatch $(DESTDIR)$(BINDIR)/spatch |
| 357 | |
| 358 | # user will use spatch to run spatch (bytecode) |
| 359 | install-byte: |
| 360 | $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR) |
| 361 | $(INSTALL_PROGRAM) scripts/spatch.byte $(DESTDIR)$(BINDIR)/spatch |
| 362 | |
| 363 | # user will use spatch.opt to run spatch.opt (native) |
| 364 | install-opt: |
| 365 | $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR) |
| 366 | $(INSTALL_PROGRAM) scripts/spatch.opt $(DESTDIR)$(BINDIR)/spatch.opt |
| 367 | |
| 368 | uninstall: |
| 369 | rm -f $(DESTDIR)$(BINDIR)/spatch |
| 370 | rm -f $(DESTDIR)$(BINDIR)/spatch.opt |
| 371 | rm -f $(DESTDIR)$(LIBDIR)/dllpycaml_stubs.so |
| 372 | rm -f $(DESTDIR)$(SHAREDIR)/spatch |
| 373 | rm -f $(DESTDIR)$(SHAREDIR)/spatch.opt |
| 374 | rm -f $(DESTDIR)$(SHAREDIR)/standard.h |
| 375 | rm -f $(DESTDIR)$(SHAREDIR)/standard.iso |
| 376 | rm -f $(DESTDIR)$(SHAREDIR)/ocaml/coccilib.cmi |
| 377 | rm -f $(DESTDIR)$(SHAREDIR)/parsing_c/*.cmi |
| 378 | rm -f $(DESTDIR)$(SHAREDIR)/commons/*.cmi |
| 379 | rm -f $(DESTDIR)$(SHAREDIR)/globals/*.cmi |
| 380 | rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui/* |
| 381 | rm -f $(DESTDIR)$(SHAREDIR)/python/coccilib/*.py |
| 382 | rmdir --ignore-fail-on-non-empty -p \ |
| 383 | $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui |
| 384 | rmdir $(DESTDIR)$(SHAREDIR)/globals |
| 385 | rmdir $(DESTDIR)$(SHAREDIR)/commons |
| 386 | rmdir $(DESTDIR)$(SHAREDIR)/parsing_c |
| 387 | rmdir $(DESTDIR)$(SHAREDIR)/ocaml |
| 388 | rmdir $(DESTDIR)$(SHAREDIR) |
| 389 | rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1 |
| 390 | |
| 391 | uninstall-bash: |
| 392 | rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/spatch |
| 393 | rmdir --ignore-fail-on-non-empty -p \ |
| 394 | $(DESTDIR)$(BASH_COMPLETION_DIR) |
| 395 | |
| 396 | uninstall-tools: |
| 397 | rm -f $(DESTDIR)$(BINDIR)/splitpatch |
| 398 | rm -f $(DESTDIR)$(BINDIR)/cocci-send-email.perl |
| 399 | |
| 400 | version: |
| 401 | @echo "spatch $(VERSION)" |
| 402 | @echo "spatch $(PKGVERSION) ($(DISTRIB_ID))" |
| 403 | @echo "coccicheck $(CCVERSION)" |
| 404 | |
| 405 | |
| 406 | ############################################################################## |
| 407 | # Deb package (for Ubuntu) and release rules |
| 408 | ############################################################################## |
| 409 | |
| 410 | include Makefile.release |
| 411 | |
| 412 | ############################################################################## |
| 413 | # Developer rules |
| 414 | ############################################################################## |
| 415 | |
| 416 | -include Makefile.dev |
| 417 | |
| 418 | test: $(TARGET) |
| 419 | ./$(TARGET) -testall |
| 420 | |
| 421 | testparsing: |
| 422 | ./$(TARGET) -D standard.h -parse_c -dir tests/ |
| 423 | |
| 424 | |
| 425 | |
| 426 | # -inline 0 to see all the functions in the profile. |
| 427 | # Can also use the profile framework in commons/ and run your program |
| 428 | # with -profile. |
| 429 | forprofiling: |
| 430 | $(MAKE) OPTFLAGS="-p -inline 0 " opt |
| 431 | |
| 432 | clean:: |
| 433 | rm -f gmon.out |
| 434 | |
| 435 | tags: |
| 436 | otags -no-mli-tags -r . |
| 437 | |
| 438 | dependencygraph: |
| 439 | find -name "*.ml" |grep -v "scripts" | xargs ocamldep -I commons -I globals -I ctl -I parsing_cocci -I parsing_c -I engine -I popl09 -I extra > /tmp/dependfull.depend |
| 440 | ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot |
| 441 | dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps |
| 442 | ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf |
| 443 | |
| 444 | ############################################################################## |
| 445 | # Misc rules |
| 446 | ############################################################################## |
| 447 | |
| 448 | # each member of the project can have its own test.ml. this file is |
| 449 | # not under CVS. |
| 450 | test.ml: |
| 451 | echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \ |
| 452 | > test.ml |
| 453 | |
| 454 | beforedepend:: test.ml |
| 455 | |
| 456 | |
| 457 | #INC=$(dir $(shell which ocaml)) |
| 458 | #INCX=$(INC:/=) |
| 459 | #INCY=$(dir $(INCX)) |
| 460 | #INCZ=$(INCY:/=)/lib/ocaml |
| 461 | # |
| 462 | #prim.o: prim.c |
| 463 | # gcc -c -o prim.o -I $(INCZ) prim.c |
| 464 | |
| 465 | |
| 466 | ############################################################################## |
| 467 | # Generic ocaml rules |
| 468 | ############################################################################## |
| 469 | |
| 470 | .SUFFIXES: .ml .mli .cmo .cmi .cmx |
| 471 | |
| 472 | .ml.cmo: |
| 473 | $(OCAMLC) -c $< |
| 474 | .mli.cmi: |
| 475 | $(OCAMLC) -c $< |
| 476 | .ml.cmx: |
| 477 | $(OCAMLOPT) -c $< |
| 478 | |
| 479 | .ml.mldepend: |
| 480 | $(OCAMLC) -i $< |
| 481 | |
| 482 | clean:: |
| 483 | rm -f *.cm[iox] *.o *.annot |
| 484 | rm -f *~ .*~ *.exe #*# |
| 485 | |
| 486 | distclean:: clean |
| 487 | set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done |
| 488 | rm -f .depend |
| 489 | rm -f Makefile.config |
| 490 | rm -f globals/config.ml test.ml |
| 491 | rm -f TAGS |
| 492 | rm -f tests/SCORE_actual.sexp |
| 493 | rm -f tests/SCORE_best_of_both.sexp |
| 494 | find -name ".#*1.*" | xargs rm -f |
| 495 | |
| 496 | beforedepend:: |
| 497 | |
| 498 | depend:: beforedepend |
| 499 | $(OCAMLDEP) *.mli *.ml > .depend |
| 500 | set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i $@; done |
| 501 | |
| 502 | .depend:: |
| 503 | @if [ ! -f .depend ] ; then $(MAKE) depend ; fi |
| 504 | |
| 505 | -include .depend |