Debian Codegraph @

Makefile

raw
1 PKGNAME = gd
2
3 OCAMLC=ocamlc
4 OCAMLOPT=ocamlopt
5 OCAMLMKLIB=ocamlmklib
6 OCAMLFIND=ocamlfind
7 OCAMLDOC=ocamldoc -html
8 OCAMLLIB=`$(OCAMLC) -where`
9
10 TASKINSTALL = $(OCAMLFIND) install $(NAME) $(TASKINSTALLOPTS)
11
12 # This turns on some checks that should make the library more secure but
13 # may degrade performance. If you're more concerned about performance than
14 # security, comment out the next line.
15 SAFETY_FLAG = -DSAFER
16 # If you don't have libjpeg, comment out the 'JPEG_LIB' line.
17 # Similarly for Freetype2.
18 JPEG_LIB = -ljpeg
19 FT2_LIB = -lfreetype
20 CC=gcc
21 CINCLUDES=-I$(OCAMLLIB) -I/usr/include
22 LIBS=-lgd -lpng -lz $(JPEG_LIB) $(FT2_LIB)
23 ifdef JPEG_LIB
24 JPEG_FLAG = -DHAVE_JPEG
25 endif
26 ifdef FT2_LIB
27 FT2_FLAG = -DHAVE_FREETYPE
28 endif
29 CFLAGS = $(CINCLUDES) -fPIC -W -Wall -Wno-unused \
30 $(JPEG_FLAG) $(FT2_FLAG) $(SAFETY_FLAG)
31
32 OCAMLCFLAGS=-labels -unsafe
33 OCAMLOPTFLAGS=-labels -inline 2
34
35 BYTE_OBJECTS = gd.cmi gd.cmo
36 NAT_OBJECTS = gd.cmi gd.cmx
37 C_OBJECTS = gdstubs.o
38 STUBLIBS = dllocamlgd.so libocamlgd.a
39 BYTE_ARCHIVE = gd.cma
40 NAT_ARCHIVE = gd.cmxa
41
42
43 .PHONY : all opt install uninstall test test.opt docs
44 all : $(BYTE_ARCHIVE)
45 opt : $(NAT_ARCHIVE)
46
47
48 $(BYTE_ARCHIVE) : $(BYTE_OBJECTS) $(C_OBJECTS)
49 $(OCAMLMKLIB) -o gd gd.cmo gdstubs.o -oc ocamlgd $(LIBS)
50 $(NAT_ARCHIVE) : $(NAT_OBJECTS) $(C_OBJECTS)
51 $(OCAMLMKLIB) -o gd gd.cmx gdstubs.o -oc ocamlgd $(LIBS)
52
53
54 gd.cmx: gd.cmi gd.ml
55 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c gd.ml
56
57 gd.cmo: gd.cmi gd.ml
58 $(OCAMLC) $(OCAMLCFLAGS) -c gd.ml
59
60 gd.cmi: gd.mli
61 $(OCAMLC) $(OCAMLCFLAGS) -c gd.mli
62
63
64 gdstubs.o : gdstubs.c
65 $(CC) $(CFLAGS) -c gdstubs.c
66
67
68 test : gdtest
69 ./gdtest gdtest.log
70
71 test.opt : gdtest.opt
72 ./gdtest.opt gdtest.log
73
74 gdtest: gdtest.cmo
75 $(OCAMLC) -o gdtest -dllpath . str.cma gd.cma gdtest.cmo
76
77 gdtest.cmo: all gdtest.ml
78 $(OCAMLC) $(OCAMLCFLAGS) -c gdtest.ml
79
80 gdtest.opt: gdtest.cmx
81 $(OCAMLOPT) -ccopt "-L ." -o gdtest.opt str.cmxa gd.cmxa gdtest.cmx
82
83 gdtest.cmx: opt gdtest.ml
84 $(OCAMLOPT) $(OCAMLOPTFLAGS) -c gdtest.ml
85
86
87 docs : gd.mli
88 $(OCAMLDOC) -d doc gd.mli
89
90
91 install :
92 files=$$( \
93 for f in $(BYTE_ARCHIVE) gd.cmx $(NAT_OBJECTS) $(NAT_ARCHIVE) $(STUBLIBS) \
94 *.mli *.cmi gd.a META; do \
95 if [ -f "$$f" ]; then echo $$f; fi; \
96 done; \
97 ) && \
98 $(TASKINSTALL) $(PKGNAME) $$files
99
100
101 uninstall :
102 ocamlfind remove $(PKGNAME)
103
104
105 clean :
106 -rm -f *.cmi *.cmo *.cmx *.cma *.cmxa *.a *.o *.so \
107 gdtest gdtest.opt gdtest.log