Release coccinelle-0.1.6a
[bpt/coccinelle.git] / Makefile
index a6c7122..f516238 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# Copyright 2005-2008, Ecole des Mines de Nantes, University of Copenhagen
+# Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
 # Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller
 # This file is part of Coccinelle.
 # 
@@ -57,8 +57,8 @@ LIBS=commons/commons.cma globals/globals.cma\
 
 MAKESUBDIRS=commons globals menhirlib $(PYDIR) ctl parsing_cocci parsing_c \
  engine popl09 extra python
-INCLUDEDIRS=commons globals menhirlib $(PYDIR) ctl parsing_cocci parsing_c \
- engine popl09 extra python
+INCLUDEDIRS=commons commons/ocamlextra globals menhirlib $(PYDIR) ctl \
parsing_cocci parsing_c engine popl09 extra python
 
 ##############################################################################
 # Generic variables
@@ -85,14 +85,8 @@ OPTFLAGS=
 # but is now defined above in this file
 #OPTLIBFLAGS=-cclib dllpycaml_stubs.so
 
-# the OPTBIN variable is here to allow to use ocamlc.opt instead of 
-# ocaml, when it is available, which speeds up compilation. So
-# if you want the fast version of the ocaml chain tools, set this var 
-# or setenv it to ".opt" in your startup script.
-OPTBIN= #.opt
-
 OCAMLC=ocamlc$(OPTBIN) $(OCAMLCFLAGS)  $(INCLUDES)
-OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES) 
+OCAMLOPT=ocamlopt$(OPTBIN) $(OPTFLAGS) $(INCLUDES)
 OCAMLLEX=ocamllex #-ml # -ml for debugging lexer, but slightly slower
 OCAMLYACC=ocamlyacc -v
 OCAMLDEP=ocamldep $(INCLUDES)
@@ -107,38 +101,85 @@ BYTECODE_STATIC=-custom
 ##############################################################################
 # Top rules
 ##############################################################################
+.PHONY: all all.opt opt top clean configure
+.PHONY: $(MAKESUBDIRS) $(MAKESUBDIRS:%=%.opt) subdirs subdirs.opt
+
+all:
+       $(MAKE) subdirs
+       $(MAKE) $(EXEC)
+
+opt:
+       $(MAKE) subdirs.opt
+       $(MAKE) $(EXEC).opt
 
-all: rec $(EXEC)
-opt: rec.opt $(EXEC).opt
 all.opt: opt
+top: $(EXEC).top
+
+subdirs:
+       +for D in $(MAKESUBDIRS); do $(MAKE) $$D ; done
+
+subdirs.opt:
+       +for D in $(MAKESUBDIRS); do $(MAKE) $$D.opt ; done
+
+$(MAKESUBDIRS):
+       $(MAKE) -C $@ OCAMLCFLAGS="$(OCAMLCFLAGS)" all
+
+$(MAKESUBDIRS:%=%.opt):
+       $(MAKE) -C $(@:%.opt=%) OCAMLCFLAGS="$(OCAMLCFLAGS)" all.opt
+
+# commons:
+# globals:
+# menhirlib:
+# parsing_cocci: commons globals menhirlib
+# parsing_c:parsing_cocci
+# ctl:globals commons
+# engine: parsing_cocci parsing_c ctl
+# popl09:engine
+# extra: parsing_cocci parsing_c ctl
+# pycaml:
+# python:pycaml parsing_cocci parsing_c
+#
+# commons.opt:
+# globals.opt:
+# menhirlib.opt:
+# parsing_cocci.opt: commons.opt globals.opt menhirlib.opt
+# parsing_c.opt:parsing_cocci.opt
+# ctl.opt:globals.opt commons.opt
+# engine.opt: parsing_cocci.opt parsing_c.opt ctl.opt
+# popl09.opt:engine.opt
+# extra.opt: parsing_cocci.opt parsing_c.opt ctl.opt
+# pycaml.opt:
+# python.opt:pycaml.opt parsing_cocci.opt parsing_c.opt
 
-rec:
-       set -e; for i in $(MAKESUBDIRS); \
-       do $(MAKE) -C $$i OCAMLCFLAGS="$(OCAMLCFLAGS)" all; done 
-rec.opt:
-       set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i all.opt; done 
 clean::
-       set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i clean; done 
+       set -e; for i in $(MAKESUBDIRS); do $(MAKE) -C $$i clean; done
+
+configure:
+       ./configure
+
+$(LIBS): $(MAKESUBDIRS)
+$(LIBS:.cma=.cmxa): $(MAKESUBDIRS:%=%.opt)
 
+$(OBJS):$(LIBS)
+$(OPTOBJS):$(LIBS:.cma=.cmxa)
 
 $(EXEC): $(LIBS) $(OBJS)
        $(OCAMLC) $(BYTECODE_STATIC) -o $@ $(SYSLIBS)  $^
 
-$(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS) 
+$(EXEC).opt: $(LIBS:.cma=.cmxa) $(OPTOBJS)
        $(OCAMLOPT) $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) $(OPTLIBFLAGS)  $^
 
-$(EXEC).top: $(LIBS) $(OBJS) 
+$(EXEC).top: $(LIBS) $(OBJS)
        $(OCAMLMKTOP) -custom -o $@ $(SYSLIBS) $^
 
 clean::
        rm -f $(TARGET) $(TARGET).opt $(TARGET).top
 
-
 clean::
        rm -f dllpycaml_stubs.so
 
 
-.PHONY: tools
+.PHONY: tools all configure
 
 tools:
        $(MAKE) -C tools
@@ -161,27 +202,56 @@ purebytecode:
 ##############################################################################
 
 # don't remove DESTDIR, it can be set by package build system like ebuild
-install: all
+# for staged installation.
+install-common:
        mkdir -p $(DESTDIR)$(BINDIR)
        mkdir -p $(DESTDIR)$(LIBDIR)
        mkdir -p $(DESTDIR)$(SHAREDIR)
-       cp spatch $(DESTDIR)$(BINDIR)   
-       cp -f dllpycaml_stubs.so $(DESTDIR)$(LIBDIR)    
-       cp standard.h $(DESTDIR)$(SHAREDIR)
-       cp standard.iso $(DESTDIR)$(SHAREDIR)
-       mkdir -p $(DESTDIR)$(SHAREDIR)/python
-       cp -a python/coccilib $(DESTDIR)$(SHAREDIR)/python
+       mkdir -p $(DESTDIR)$(MANDIR)/man1
+       $(INSTALL_DATA) standard.h $(DESTDIR)$(SHAREDIR)
+       $(INSTALL_DATA) standard.iso $(DESTDIR)$(SHAREDIR)
+       $(INSTALL_DATA) docs/spatch.1 $(DESTDIR)$(MANDIR)/man1/
+       @if [ $(FEATURE_PYTHON) -eq 1 ]; then $(MAKE) install-python; fi
        @echo ""
        @echo "You can also install spatch by copying the program spatch"
        @echo "(available in this directory) anywhere you want and"
        @echo "give it the right options to find its configuration files."
+       @echo ""
+
+install-python:
+       mkdir -p $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
+       $(INSTALL_DATA) python/coccilib/*.py \
+               $(DESTDIR)$(SHAREDIR)/python/coccilib
+       $(INSTALL_DATA) python/coccilib/coccigui/*.py \
+               $(DESTDIR)$(SHAREDIR)/python/coccilib/coccigui
+       $(INSTALL_LIB) dllpycaml_stubs.so $(DESTDIR)$(LIBDIR)
+
+# user will use spatch to run spatch.opt (native)
+install: all.opt install-common
+       $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
+       cat scripts/spatch.sh | sed "s|SHAREDIR|$(SHAREDIR)|g" > $(DESTDIR)$(BINDIR)/spatch
+       chmod 755 $(DESTDIR)$(BINDIR)/spatch
+
+# user will use spatch to run spatch (bytecode)
+install-byte: all install-common
+       $(INSTALL_PROGRAM) spatch $(DESTDIR)$(SHAREDIR)
+       cat scripts/spatch.sh | sed "s|\.opt||" | sed "s|SHAREDIR|$(SHAREDIR)|g" > $(DESTDIR)$(BINDIR)/spatch
+       chmod 755 $(DESTDIR)$(BINDIR)/spatch
+
+# user will use spatch.opt to run spatch.opt (native)
+install-opt: all.opt install-common
+       $(INSTALL_PROGRAM) spatch.opt $(DESTDIR)$(SHAREDIR)
+       cat scripts/spatch.sh | sed "s|SHAREDIR|$(SHAREDIR)|g" > $(DESTDIR)$(BINDIR)/spatch.opt
+       chmod 755 $(DESTDIR)$(BINDIR)/spatch.opt
 
 uninstall:
        rm -f $(DESTDIR)$(BINDIR)/spatch
+       rm -f $(DESTDIR)$(BINDIR)/spatch.opt
        rm -f $(DESTDIR)$(LIBDIR)/dllpycaml_stubs.so
        rm -f $(DESTDIR)$(SHAREDIR)/standard.h
        rm -f $(DESTDIR)$(SHAREDIR)/standard.iso
        rm -rf $(DESTDIR)$(SHAREDIR)/python/coccilib
+       rm -f $(DESTDIR)$(MANDIR)/man1/spatch.1
 
 
 
@@ -197,7 +267,7 @@ PACKAGE=coccinelle-$(VERSION)
 
 BINSRC=spatch env.sh env.csh standard.h standard.iso \
        *.txt docs/* \
-       demos/foo.* demos/simple.* 
+       demos/foo.* demos/simple.*
 #      $(PYLIB) python/coccilib/ demos/printloc.*
 BINSRC2=$(BINSRC:%=$(PACKAGE)/%)
 
@@ -211,53 +281,57 @@ OCAMLVERSION=$(shell ocaml -version |perl -p -e 's/.*version (.*)/$$1/;')
 #  cvs update -d -P
 #  touch **/*
 #  make licensify
+#  remember to comment the -g -dtypes in this Makefile
 
 # Procedure to do each time:
 #  cvs update
+#  make sure that ocaml is the distribution ocaml of /usr/bin, not ~pad/...
+#  modify globals/config.ml
+#  cd globals/; cvs commit -m"new version"  (do not commit from the root!)
 #  ./configure --without-python
 #  make package
 #  make website
-# Check also that run an ocaml in /usr/bin
+# Check that run an ocaml in /usr/bin
 
-# To test you can try compile and run spatch from different instances 
-# like my ~/coccinelle, ~/release/coccinelle, and the /tmp/coccinelle-0.X 
-# downloaded from the website. 
+# To test you can try compile and run spatch from different instances
+# like my ~/coccinelle, ~/release/coccinelle, and the /tmp/coccinelle-0.X
+# downloaded from the website.
 
 # For 'make srctar' it must done from a clean
-# repo such as ~/release/coccinelle. It must also be a repo where 
-# the scripts/licensify has been run at least once. 
+# repo such as ~/release/coccinelle. It must also be a repo where
+# the scripts/licensify has been run at least once.
 # For the 'make bintar' I can do it from my original repo.
 
 
-package: 
-       make srctar 
-       make bintar 
-       make staticbintar 
+package:
+       make srctar
+       make bintar
+       make staticbintar
        make bytecodetar
 
-# I currently pre-generate the parser so the user does not have to 
+# I currently pre-generate the parser so the user does not have to
 # install menhir on his machine. I also do a few cleanups like 'rm todo_pos'.
 # You may have first to do a 'make licensify'.
 srctar:
        make clean
        cp -a .  $(TMP)/$(PACKAGE)
        cd $(TMP)/$(PACKAGE); cd parsing_cocci/; make parser_cocci_menhir.ml
-       cd $(TMP)/$(PACKAGE); rm todo_pos
-       cd $(TMP); tar cvfz $(PACKAGE).tgz  --exclude=CVS  $(PACKAGE)
+       cd $(TMP)/$(PACKAGE); rm -f todo_pos
+       cd $(TMP); tar cvfz $(PACKAGE).tgz --exclude-vcs $(PACKAGE)
        rm -rf  $(TMP)/$(PACKAGE)
 
 
 bintar: all
        rm -f $(TMP)/$(PACKAGE)
        ln -s `pwd` $(TMP)/$(PACKAGE)
-       cd $(TMP); tar cvfz $(PACKAGE)-bin-x86.tgz $(BINSRC2)
+       cd $(TMP); tar cvfz $(PACKAGE)-bin-x86.tgz --exclude-vcs $(BINSRC2)
        rm -f $(TMP)/$(PACKAGE)
 
 staticbintar: all.opt
        rm -f $(TMP)/$(PACKAGE)
        ln -s `pwd` $(TMP)/$(PACKAGE)
        make static
-       cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-static.tgz $(BINSRC2)
+       cd $(TMP); tar cvfz $(PACKAGE)-bin-x86-static.tgz --exclude-vcs $(BINSRC2)
        rm -f $(TMP)/$(PACKAGE)
 
 # add ocaml version in name ?
@@ -265,21 +339,21 @@ bytecodetar: all
        rm -f $(TMP)/$(PACKAGE)
        ln -s `pwd` $(TMP)/$(PACKAGE)
        make purebytecode
-       cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz $(BINSRC2)
+       cd $(TMP); tar cvfz $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz --exclude-vcs $(BINSRC2)
        rm -f $(TMP)/$(PACKAGE)
 
 clean::
-       rm -f $(PACKAGE) 
-       rm -f $(PACKAGE)-bin-x86.tgz 
-       rm -f $(PACKAGE)-bin-x86-static.tgz 
+       rm -f $(PACKAGE)
+       rm -f $(PACKAGE)-bin-x86.tgz
+       rm -f $(PACKAGE)-bin-x86-static.tgz
        rm -f $(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz
 
 
 
 TOLICENSIFY=ctl engine parsing_cocci popl popl09 python
 licensify:
-       ocaml tools/licensify.ml 
-       set -e; for i in $(TOLICENSIFY); do cd $$i; ocaml ../tools/licensify.ml; cd ..; done 
+       ocaml tools/licensify.ml
+       set -e; for i in $(TOLICENSIFY); do cd $$i; ocaml ../tools/licensify.ml; cd ..; done
 
 # When checking out the source from diku sometimes I have some "X in the future"
 # error messages.
@@ -306,16 +380,29 @@ website:
        cp $(TMP)/$(PACKAGE)-bin-x86.tgz        $(WEBSITE)
        cp $(TMP)/$(PACKAGE)-bin-x86-static.tgz $(WEBSITE)
        cp $(TMP)/$(PACKAGE)-bin-bytecode-$(OCAMLVERSION).tgz   $(WEBSITE)
+       rm -f $(WEBSITE)/LATEST* $(WEBSITE)/coccinelle-latest.tgz
+       cd $(WEBSITE); touch LATEST_IS_$(VERSION); ln -s $(PACKAGE).tgz coccinelle-latest.tgz
 
 
 #TXT=$(wildcard *.txt)
 syncwiki:
 #      unison ~/public_html/wiki/wiki-LFS/data/pages/ docs/wiki/
-#      set -e; for i in $(TXT); do unison $$i docs/wiki/$$i; done 
+#      set -e; for i in $(TXT); do unison $$i docs/wiki/$$i; done
 
 darcsweb:
 #      @echo pull from ~/public_html/darcs/c-coccinelle and c-commons and lib-xxx
 
+DARCSFORESTS=commons \
+ parsing_c parsing_cocci engine
+
+update_darcs:
+       darcs pull
+       set -e; for i in $(DARCSFORESTS); do cd $$i; darcs pull; cd ..; done
+
+#darcs diff -u
+diff_darcs:
+       set -e; for i in $(DARCSFORESTS); do cd $$i; darcs diff -u; cd ..; done
+
 
 ##############################################################################
 # Developer rules
@@ -329,30 +416,31 @@ testparsing:
 
 
 
-# -inline 0  to see all the functions in the profile. 
-# Can also use the profile framework in commons/ and run your program 
+# -inline 0  to see all the functions in the profile.
+# Can also use the profile framework in commons/ and run your program
 # with -profile.
 forprofiling:
        $(MAKE) OPTFLAGS="-p -inline 0 " opt
 
 clean::
-       rm -f gmon.out 
+       rm -f gmon.out
 
 tags:
        otags -no-mli-tags -r  .
 
 dependencygraph:
        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
-       ocamldot -fullgraph /tmp/dependfull.depend > /tmp/dependfull.dot
+       ocamldot -lr /tmp/dependfull.depend > /tmp/dependfull.dot
        dot -Tps /tmp/dependfull.dot > /tmp/dependfull.ps
+       ps2pdf /tmp/dependfull.ps /tmp/dependfull.pdf
 
 ##############################################################################
 # Misc rules
 ##############################################################################
 
-# each member of the project can have its own test.ml. this file is 
+# each member of the project can have its own test.ml. this file is
 # not under CVS.
-test.ml: 
+test.ml:
        echo "let foo_ctl () = failwith \"there is no foo_ctl formula\"" \
          > test.ml
 
@@ -381,7 +469,7 @@ beforedepend:: test.ml
 .ml.cmx:
        $(OCAMLOPT)  -c $<
 
-.ml.mldepend: 
+.ml.mldepend:
        $(OCAMLC) -i $<
 
 clean::