ed41f8e489614a96c8658eef3322a19bb93b8a79
[ocaml-bitstring.git] / cil-tools / Makefile.in
1 # Bitstring CIL tools for processing C code.
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 enable_coverage = @enable_coverage@
29
30 OCAMLCFLAGS     = -g
31 OCAMLCPACKAGES  = -package unix,str,extlib,cil -I +camlp4 -I ..
32 OCAMLCLIBS      = $(OCAMLCPACKAGES) camlp4lib.cma -linkpkg ../bitstring.cma ../bitstring_persistent.cma
33 OCAMLOPTFLAGS   =
34 OCAMLOPTPACKAGES = $(OCAMLCPACKAGES)
35 OCAMLOPTLIBS    = $(OCAMLOPTPACKAGES) camlp4lib.cmxa -linkpkg ../bitstring.cmxa ../bitstring_persistent.cmxa
36
37 ifneq ($(enable_coverage),no)
38 OCAMLCLIBS      := -I +bisect bisect.cma $(OCAMLCLIBS)
39 OCAMLOPTLIBS    := -I +bisect bisect.cmxa $(OCAMLOPTLIBS)
40 endif
41
42 PP              = -pp "camlp4o -I .. bitstring.cma bitstring_persistent.cma pa_bitstring.cmo"
43
44 OCAMLDOCFLAGS   = -html -sort
45
46 all:            bitstring-import-c bitstring-import-c.opt
47
48 bitstring-import-c: bitstring_import_c.cmo
49         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
50
51 bitstring-import-c.opt: bitstring_import_c.cmx
52         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTLIBS) $< -o $@
53
54 test:
55
56 # Examples.
57 #
58 # To compile task_struct you'll need to grab a copy of the Linux
59 # kernel original header files and set the directory below.
60
61 #DEBUG          =
62 DEBUG           = --debug
63 LINUX_HEADERS   = linux-2.6.25.7-headers
64 LINUX_INCLUDES  = -I $(LINUX_HEADERS)
65
66 #EXAMPLES       = ext3 task_struct
67 EXAMPLES        = ext3
68
69 examples: $(EXAMPLES)
70
71 ext3: ext3.cmo
72         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
73
74 ext3.cmo: ext3.ml ext3.bmpp
75         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
76
77 ext3.bmpp: ext3.c bitstring-import-c
78         rm -f $@.new
79         ./bitstring-import-c $(DEBUG) $< > $@.new
80         mv $@.new $@
81
82 task_struct: task_struct.cmo
83         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCLIBS) $< -o $@
84
85 task_struct.cmo: task_struct.ml task_struct.bmpp
86         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) $(PP) -c $< -o $@
87
88 task_struct.bmpp: task_struct.c bitstring-import-c
89         cd $(LINUX_HEADERS) && ln -sf asm-x86 asm
90         rm -f $@.new
91         ./bitstring-import-c $(DEBUG) $(LINUX_INCLUDES) $< > $@.new
92         mv $@.new $@
93
94 # Clean.
95
96 clean:
97         rm -f core *~ *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o *.bmpp
98         rm -f bitstring-import-c bitstring-import-c.opt
99         rm -f ext3 task_struct
100
101 distclean: clean
102
103 # Install.
104
105 install:
106
107 # Standard rules.
108
109 .mli.cmi:
110         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
111 .ml.cmo:
112         $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) $(OCAMLCPACKAGES) -c $<
113 .ml.cmx:
114         $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) $(OCAMLOPTPACKAGES) -c $<
115
116 depend: .depend
117
118 .depend: bitstring_import_c.ml
119         rm -f .depend
120         $(OCAMLFIND) ocamldep $(OCAMLCPACKAGES) $^ > $@
121
122 ifeq ($(wildcard .depend),.depend)
123 include .depend
124 endif
125
126 .PHONY: depend dist check-manifest dpkg doc \
127         print-examples print-tests examples test
128
129 .SUFFIXES:      .cmo .cmi .cmx .ml .mli .mll