CIL examples.
[ocaml-bitstring.git] / cil-tools / Makefile.in
1 # Bitmatch syntax extension.
2 # Copyright (C) 2008 Red Hat Inc., Richard W.M. Jones
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2 of the License, or (at your option) any later version.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17 #
18 # $Id$
19
20 PACKAGE         = @PACKAGE_NAME@
21 VERSION         = @PACKAGE_VERSION@
22
23 OCAMLFIND       = @OCAMLFIND@
24 OCAMLMKLIB      = @OCAMLMKLIB@
25 OCAMLDOC        = @OCAMLDOC@
26 INSTALL         = @INSTALL@
27
28 OCAMLCFLAGS     = -g
29 OCAMLCPACKAGES  = -package unix,str,extlib,cil -I +camlp4 -I ..
30 OCAMLCLIBS      = $(OCAMLCPACKAGES) camlp4lib.cma -linkpkg ../bitmatch.cma ../bitmatch_persistent.cma
31 OCAMLOPTFLAGS   =
32 OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
33 OCAMLOPTLIBS    = $(OCAMLOPTPACKAGES) camlp4lib.cmxa -linkpkg ../bitmatch.cmxa ../bitmatch_persistent.cmxa
34
35 PP              = -pp "camlp4o -I .. bitmatch.cma bitmatch_persistent.cma pa_bitmatch.cmo"
36
37 OCAMLDOCFLAGS   = -html -sort
38
39 all:            bitmatch-import-c bitmatch-import-c.opt
40
41 bitmatch-import-c: bitmatch_import_c.cmo
42         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
43
44 bitmatch-import-c.opt: bitmatch_import_c.cmx
45         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) $< -o $@
46
47 test:
48
49 # Examples.
50 #
51 # To compile task_struct you'll need to grab a copy of the Linux
52 # kernel original header files and set the directory below.
53
54 #DEBUG          =
55 DEBUG           = --debug
56 LINUX_HEADERS   = linux-2.6.25.7-headers
57 LINUX_INCLUDES  = -I $(LINUX_HEADERS)
58
59 #EXAMPLES       = ext3 task_struct
60 EXAMPLES        = ext3
61
62 examples: $(EXAMPLES)
63
64 ext3: ext3.cmo ext3.bmpp
65         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
66
67 ext3.cmo: ext3.ml
68         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
69
70 ext3.bmpp: ext3.c bitmatch-import-c
71         rm -f $@.new
72         ./bitmatch-import-c $(DEBUG) $(LINUX_INCLUDES) $< > $@.new
73         mv $@.new $@
74
75 task_struct: task_struct.cmo task_struct.bmpp
76         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
77
78 task_struct.cmo: task_struct.ml
79         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
80
81 task_struct.bmpp: task_struct.c bitmatch-import-c
82         cd $(LINUX_HEADERS) && ln -sf asm-x86 asm
83         rm -f $@.new
84         ./bitmatch-import-c $(DEBUG) $(LINUX_INCLUDES) $< > $@.new
85         mv $@.new $@
86
87 # Clean.
88
89 clean:
90         rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o
91         rm -f bitmatch-import-c bitmatch-import-c.opt
92
93 distclean: clean
94
95 # Install.
96
97 install:
98
99 # Standard rules.
100
101 .mli.cmi:
102         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
103 .ml.cmo:
104         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
105 .ml.cmx:
106         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
107
108 depend: .depend
109
110 .depend: bitmatch_import_c.ml
111         rm -f .depend
112         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) $^ > $@
113
114 ifeq ($(wildcard .depend),.depend)
115 include .depend
116 endif
117
118 .PHONY: depend dist check-manifest dpkg doc \
119         print-examples print-tests examples test
120
121 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll