Debian Codegraph @

common/mlpcre/Makefile.am

raw
1 # Bindings for Perl-compatible Regular Expressions.
2 # Copyright (C) 2017 Red Hat Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program 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
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18 include $(top_srcdir)/subdir-rules.mk
19
20 EXTRA_DIST = \
21 $(SOURCES_MLI) \
22 $(SOURCES_ML) \
23 $(SOURCES_C) \
24 pcre_tests.ml
25
26 SOURCES_MLI = \
27 PCRE.mli
28
29 SOURCES_ML = \
30 PCRE.ml
31
32 SOURCES_C = \
33 pcre-c.c
34
35 # We pretend that we're building a C library. automake handles the
36 # compilation of the C sources for us. At the end we take the C
37 # objects and OCaml objects and link them into the OCaml library.
38 # This C library is never used.
39
40 noinst_LIBRARIES = libmlpcre.a
41
42 if !HAVE_OCAMLOPT
43 MLPCRE_CMA = mlpcre.cma
44 else
45 MLPCRE_CMA = mlpcre.cmxa
46 endif
47
48 noinst_DATA = $(MLPCRE_CMA)
49
50 libmlpcre_a_SOURCES = $(SOURCES_C)
51 libmlpcre_a_CPPFLAGS = \
52 -DCAML_NAME_SPACE \
53 -I. \
54 -I$(top_builddir) \
55 -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
56 -I$(top_srcdir)/common/utils -I$(top_builddir)/common/utils \
57 -I$(shell $(OCAMLC) -where)
58 libmlpcre_a_CFLAGS = \
59 -pthread \
60 $(WARN_CFLAGS) $(WERROR_CFLAGS) \
61 -fPIC
62
63 BOBJECTS = $(SOURCES_ML:.ml=.cmo)
64 XOBJECTS = $(BOBJECTS:.cmo=.cmx)
65
66 # -I $(top_builddir)/lib/.libs is a hack which forces corresponding -L
67 # option to be passed to gcc, so we don't try linking against an
68 # installed copy of libguestfs.
69 OCAMLPACKAGES = \
70 -I $(top_builddir)/gnulib/lib/.libs \
71 -I $(top_builddir)/common/utils/.libs \
72 -I $(builddir)
73 OCAMLPACKAGES_TESTS = $(MLPCRE_CMA)
74
75 OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) -ccopt '$(CFLAGS)'
76
77 if !HAVE_OCAMLOPT
78 OBJECTS = $(BOBJECTS)
79 else
80 OBJECTS = $(XOBJECTS)
81 endif
82
83 libmlpcre_a_DEPENDENCIES = $(OBJECTS)
84
85 $(MLPCRE_CMA): $(OBJECTS) libmlpcre.a
86 $(OCAMLFIND) mklib $(OCAMLPACKAGES) \
87 $(OBJECTS) $(libmlpcre_a_OBJECTS) -cclib -lpcre2-8 -o mlpcre
88
89 # Tests.
90
91 pcre_tests_SOURCES = dummy.c
92 pcre_tests_BOBJECTS = pcre_tests.cmo
93 pcre_tests_XOBJECTS = $(pcre_tests_BOBJECTS:.cmo=.cmx)
94
95 # Can't call the following as <test>_OBJECTS because automake gets confused.
96 if !HAVE_OCAMLOPT
97 pcre_tests_THEOBJECTS = $(pcre_tests_BOBJECTS)
98 pcre_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
99 else
100 pcre_tests_THEOBJECTS = $(pcre_tests_XOBJECTS)
101 pcre_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
102 endif
103
104 OCAMLLINKFLAGS = $(LINK_CUSTOM_OCAMLC_ONLY)
105
106 pcre_tests_DEPENDENCIES = \
107 $(pcre_tests_THEOBJECTS) \
108 $(MLPCRE_CMA) \
109 $(top_srcdir)/ocaml-link.sh
110 pcre_tests_LINK = \
111 $(top_srcdir)/ocaml-link.sh \
112 -cclib '-pthread -lpthread -lutils -lpcre2-8 -lgnu' -- \
113 $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLLINKFLAGS) \
114 $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) \
115 $(pcre_tests_THEOBJECTS) -o $@
116
117 TESTS_ENVIRONMENT = $(top_builddir)/run --test
118 LOG_COMPILER = $(VG)
119
120 check_PROGRAMS = pcre_tests
121 TESTS = pcre_tests
122
123 check-valgrind:
124 $(MAKE) VG="@VG@" check
125
126 # Dependencies.
127 .depend: $(srcdir)/*.mli $(srcdir)/*.ml
128 $(top_builddir)/ocaml-dep.sh $^
129 -include .depend
130
131 .PHONY: docs