fix build
[vsys.git] / Makefile
1 #
2 # $Id: Makefile 16196 2009-12-15 20:36:21Z thierry $
3 # $URL: https://svn.planet-lab.org/svn/vsys/branches/0.9/Makefile $
4 #
5
6 # OCAML_OLD is set to non-empty if str.cmxa needs to be passed twice to the loader
7 OCAML_RELEASE := $(shell ocaml -version)
8 OCAML_OLD := $(strip $(findstring version 3.09,$(OCAML_RELEASE)) $(findstring version 3.10,$(OCAML_RELEASE)))
9
10 all: vsys docs
11
12 include .dep
13
14 .SUFFIXES: .ml .cmo
15 .SUFFIXES: .mli .cmi
16 .SUFFIXES: .ml .cmx
17 .SUFFIXES: .mll .ml
18 .SUFFIXES: .mly .ml
19
20 .ml.cmo:
21         ocamlc -g -c $(INCLUDEDIR) $<
22
23 .mli.cmi:
24         ocamlopt -c $<
25
26 .ml.cmx: 
27         ocamlopt $(CFLAGS) -c $(INCLUDEDIR) $<
28
29 .mly.ml: 
30         ocamlyacc $< 
31
32 .mll.ml:
33         ocamllex $< 
34
35 docs: *.ml
36         ocamldoc -d . -html -o docs *.ml
37         mkdir -p docs;mv *.html *.css docs
38
39 ocaml_inotify-0.4/inotify.cmxa:
40         $(MAKE) -C ocaml_inotify-0.4 && cp -f ocaml_inotify-0.4/inotify_stubs.o ./
41
42 splice_stub.o: splice_stub.c
43         gcc -c -I /usr/lib/ocaml -I /usr/lib64/ocaml splice_stub.c -o splice_stub.o
44
45 vsys: ocaml_inotify-0.4/inotify.cmxa globals.cmx fdwatcher.cmx conffile.cmx splice_stub.o splice.cmx dirwatcher.cmx fifowatcher.cmx frontend.cmx unixsocketwatcher.cmx backend.cmx main.cmx 
46 ifneq "$(OCAML_OLD)" ""
47         ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx  frontend.cmx backend.cmx str.cmxa conffile.cmx main.cmx -o vsys
48 else
49         ocamlopt -I ocaml_inotify-0.4 str.cmxa unix.cmxa inotify.cmxa globals.cmx fdwatcher.cmx dirwatcher.cmx splice.cmx splice_stub.o directfifowatcher.cmx unixsocketwatcher.cmx  frontend.cmx backend.cmx conffile.cmx main.cmx -o vsys
50 endif
51
52 vsys.b: ocaml_inotify-0.4/inotify.cma inotify.cmi globals.ml fdwatcher.ml dirwatcher.ml directfifowatcher.ml frontend.ml backend.ml main.ml
53         ocamlc -g str.cma unix.cma ocaml_inotify-0.4/inotify.cma globals.cmo fdwatcher.cmo dirwatcher.cmo directfifowatcher.cmo frontend.cmo backend.cmo str.cma conffile.cmo main.cmo -o vsys.b
54
55 install: vsys
56         cp vsys $(INSTALL_DIR)/usr/bin
57         cp vsys-initscript $(INSTALL_DIR)/etc/init.d/vsys 
58
59 dep:
60         ocamldep *.ml > .dep
61
62 clean:
63         $(MAKE) -C ocaml_inotify-0.4 clean
64         rm -f *.cmi *.cmx sys usys *.o vsys vsys.b *.html *.css