-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile.in
103 lines (78 loc) · 2.89 KB
/
Makefile.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# @configure_input@
LIBRARY=@LIBRARY@
BUILDDIR=_build/$(LIBRARY)
prefix=@prefix@
exec_prefix=@exec_prefix@
INSTALL_PROGRAM=install
VPATH=$(BUILDDIR):$(LIBRARY)
OCAMLFIND=@OCAMLFIND@
OCAMLOPT=$(OCAMLFIND) opt
OCAMLDIR=@OCAMLDIR@
OSTYPE=@OSTYPE@
SYSTEM=@SYSTEM@
EXTDLL=@EXTDLL@
OCAMLCC=@OCAMLCC@
$(shell mkdir -p $(BUILDDIR) $(BUILDDIR)/stub $(BUILDDIR)/lib $(BUILDDIR)/stub_generator $(BUILDDIR)/test $(BUILDDIR)/generated)
PACKAGES=$(LIBRARY),bap-plugins,ctypes.stubs,ctypes.foreign,findlib.dynload,bap-main
BINDINGS=$(BUILDDIR)/lib/bindings.cmx
# The files used to build the stub generator.
GENERATOR_FILES=$(BINDINGS) \
$(BUILDDIR)/stub_generator/generate.cmx
# The files from which we'll build a shared library.
LIBFILES=$(BINDINGS) \
$(BUILDDIR)/generated/$(LIBRARY)_bindings.cmx \
$(BUILDDIR)/lib/apply_bindings.cmx \
$(BUILDDIR)/generated/$(LIBRARY).o
CAML_INIT=$(BUILDDIR)/stub/init.o
# The files that we'll generate
GENERATED=$(BUILDDIR)/generated/$(LIBRARY).h \
$(BUILDDIR)/generated/$(LIBRARY).c \
$(BUILDDIR)/generated/$(LIBRARY)_bindings.ml
ifeq ($(OSTYPE),$(filter $(OSTYPE),Win32 Cygwin))
EXTEXE=.exe
else
EXTEXE=
endif
GENERATOR=$(BUILDDIR)/generate$(EXTEXE)
all: sharedlib
sharedlib: $(BUILDDIR)/lib$(LIBRARY)$(EXTDLL)
ifeq ($(OSTYPE),$(filter $(OSTYPE),Win32 Cygwin))
$(BUILDDIR)/lib$(LIBRARY)$(EXTDLL): $(CAML_INIT) $(LIBFILES)
$(OCAMLOPT) -o $@ -thread -linkpkg -output-obj -verbose -package $(PACKAGES) $^
else ifeq ($(SYSTEM),$(filter $(SYSTEM),macosx))
$(BUILDDIR)/lib$(LIBRARY)$(EXTDLL): $(CAML_INIT) $(LIBFILES)
$(OCAMLOPT) -o $@ -thread -linkpkg -runtime-variant _pic -verbose -ccopt -dynamiclib -package $(PACKAGES) $^
else
$(BUILDDIR)/lib$(LIBRARY)$(EXTDLL): $(CAML_INIT) $(LIBFILES)
$(OCAMLOPT) -o $@ -thread -linkpkg -output-obj -runtime-variant _pic -verbose -package $(PACKAGES) $^
endif
stubs: $(GENERATED)
$(BUILDDIR)/stub/%.o:
ocamlc -g -c $(LIBRARY)/stub/init.c
mv init.o $@
$(GENERATED): $(GENERATOR)
$(GENERATOR) $(BUILDDIR)/generated
$(BUILDDIR)/%.o: %.c
$(OCAMLCC) -c -o $@ -fPIC -I $(shell $(OCAMLFIND) query ctypes) -I $(OCAMLDIR) -I $(OCAMLDIR)/../ctypes $<
$(BUILDDIR)/%.cmx: %.ml
$(OCAMLOPT) -c -o $@ -I $(BUILDDIR)/generated -I $(BUILDDIR)/lib -package $(PACKAGES) $<
$(GENERATOR): $(GENERATOR_FILES)
$(OCAMLOPT) -o $@ -thread -linkpkg -package $(PACKAGES) $^
clean:
rm -rf $(BUILDDIR)
test: all
$(MAKE) -C $@
ifeq ($(OSTYPE),Win32)
PATH="$(BUILDDIR):$(PATH)" _build/test/test.native
else
LD_LIBRARY_PATH=$(BUILDDIR) _build/test/test.native
endif
install:
$(INSTALL_PROGRAM) -m644 $(BUILDDIR)/lib$(LIBRARY)$(EXTDLL) @libdir@/
$(INSTALL_PROGRAM) -m644 $(BUILDDIR)/generated/$(LIBRARY).h @includedir@/
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
uninstall:
rm @includedir@/$(LIBRARY).h
rm @libdir@/lib$(LIBRARY)$(EXTDLL)
.PHONY: all test install install-strip uninstall