Commit | Line | Data |
---|---|---|
feec80c3 C |
1 | # This Makefile serves as a wrapper to bundle the |
2 | # extlib module without modifications. | |
3 | ||
4 | ifneq ($(MAKECMDGOALS),distclean) | |
5 | include ../../Makefile.config | |
6 | endif | |
7 | ||
755320b0 C |
8 | OCAMLCFLAGS ?= -g |
9 | OPTFLAGS ?= -g | |
d6ce1786 C |
10 | |
11 | # note: the extra linker flags are needed so that the produced shared | |
12 | # library gets dynamically linked to libpcre. | |
13 | EXTRACFLAGS=$(PCRE_CFLAGS:%=-ccopt %) $(PCRE_LIBS:%=-ccopt %) | |
14 | EXTRALNKFLAGS=$(PCRE_LIBS:%=-ldopt %) | |
15 | ||
755320b0 C |
16 | OCAMLC_CMD=$(OCAMLC) $(OCAMLCFLAGS) $(EXTRACFLAGS) -cc "${CC} ${CFLAGS}" |
17 | OCAMLOPT_CMD=$(OCAMLOPT) $(OPTFLAGS) $(EXTRACFLAGS) | |
d6ce1786 | 18 | OCAMLMKLIB_CMD=$(OCAMLMKLIB) $(EXTRALNKFLAGS) |
feec80c3 C |
19 | |
20 | PCRE_VERSION=6.2.5 | |
21 | PCRE_DIR=pcre-ocaml-release-$(PCRE_VERSION) | |
22 | PCRE_LIB=$(PCRE_DIR)/lib | |
23 | PCRE_MARKER=$(PCRE_DIR)/.marker | |
24 | ||
d6ce1786 C |
25 | all: $(PCRE_MARKER) |
26 | @$(MAKE) all-build | |
27 | all-build: $(PCRE_MARKER) pcre.cma META | |
28 | all.opt: $(PCRE_MARKER) | |
29 | @$(MAKE) all-opt-build | |
30 | all-opt-build: $(PCRE_MARKER) pcre.cmxa META | |
feec80c3 C |
31 | |
32 | clean: | |
33 | rm -f dllpcre_stubs.so libpcre_stubs.a pcre_stubs.o \ | |
34 | pcre.cma pcre.cmi pcre.cmo META \ | |
d6ce1786 | 35 | pcre.a pcre.cmx pcre.cmxa pcre.o pcre.annot |
feec80c3 C |
36 | |
37 | distclean: clean | |
38 | rm -rf $(PCRE_DIR) | |
39 | ||
40 | depend: $(PCRE_MARKER) | |
41 | ||
d6ce1786 | 42 | .PHONEY: all all.opt clean distclean depend all-build all-opt-build |
feec80c3 C |
43 | |
44 | # prepare the pcre directory | |
45 | $(PCRE_MARKER): $(PCRE_DIR).tar.gz | |
46 | $(TAR) xfvz $< | |
47 | touch $@ | |
48 | ||
49 | $(PCRE_DIR).tar.gz: | |
50 | @echo "$@ not found. Please download it and drop it in this directory ($(pwd))." | |
51 | @false | |
52 | ||
53 | # handle the building of pcre ourselves | |
54 | ||
55 | pcre.cmi: $(PCRE_LIB)/pcre.mli | |
56 | $(OCAMLC_CMD) -c -o $@ $^ | |
57 | ||
58 | pcre.cmo: $(PCRE_LIB)/pcre.ml pcre.cmi | |
59 | $(OCAMLC_CMD) -c -o $@ $< | |
60 | ||
61 | pcre.cma: pcre.cmo dllpcre_stubs.so | |
d6ce1786 | 62 | $(OCAMLC_CMD) -a -o $@ $< |
feec80c3 C |
63 | |
64 | pcre.cmx: $(PCRE_LIB)/pcre.ml pcre.cmi | |
65 | $(OCAMLOPT_CMD) -c -o $@ $< | |
66 | ||
67 | pcre.cmxa: pcre.cmx dllpcre_stubs.so | |
d6ce1786 | 68 | $(OCAMLOPT_CMD) -a -o pcre.cmxa $< |
feec80c3 C |
69 | |
70 | pcre_stubs.o: $(PCRE_LIB)/pcre_stubs.c | |
d6ce1786 | 71 | $(OCAMLC_CMD) -ccopt -shared -ccopt -fPIC $< |
feec80c3 C |
72 | |
73 | dllpcre_stubs.so: pcre_stubs.o | |
74 | $(OCAMLMKLIB_CMD) -o pcre_stubs $< | |
75 | ||
76 | META: $(PCRE_LIB)/META | |
77 | cp "${PCRE_LIB}/META" ./META | |
d6ce1786 C |
78 | |
79 | include ../../Makefile.common |