summaryrefslogtreecommitdiff
path: root/src/Makefile
blob: ced04057b5ba40247a48b1a68f553c04ce812a10 (plain)
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

include ../config.make

CPPFLAGS = -g

TARGETS = cairo
ifdef LABLGTKDIR
TARGETS += lablgtk
ifdef GTKCAIRO_CFLAGS
TARGETS += gtkcairo
endif
endif

all : $(TARGETS) $(if $(OCAMLOPT),opt)
opt : $(addsuffix .opt,$(TARGETS))

cairo     : cairo.cma  libmlcairo.a
cairo.opt : cairo.cmxa dllmlcairo.so
lablgtk     : cairo_lablgtk.cma  libmlcairo_lablgtk.a
lablgtk.opt : cairo_lablgtk.cmxa dllmlcairo_lablgtk.so
gtkcairo     : gtkcairo.cma  libmlgtkcairo.a
gtkcairo.opt : gtkcairo.cmxa dllmlgtkcairo.so

cairo_SRC = cairo_channel.mli cairo.mli cairo.ml \
            cairo_bigarray.mli cairo_bigarray.ml \
            ocairo.mli ocairo.ml \
	    ml_cairo_status.c ml_cairo_channel.c \
            ml_cairo.c ml_cairo_bigarr.c

cairo.cma : $(call mlobjs,$(cairo_SRC))
	$(OCAMLMKLIB) -o cairo -oc mlcairo $^ $(CAIRO_LIBS)
cairo.cmxa : $(call mloptobjs,$(cairo_SRC))
	$(OCAMLMKLIB) -o cairo -oc mlcairo $^ $(CAIRO_LIBS)
libmlcairo.a dllmlcairo.so : $(call cobjs,$(cairo_SRC))
	$(OCAMLMKLIB) -o cairo -oc mlcairo $^ $(CAIRO_LIBS)

lablgtk_SRC = cairo_lablgtk.mli ocairo_lablgtk.mli ocairo_lablgtk.ml \
              ml_cairo_lablgtk.c

cairo_lablgtk.cma : $(call mlobjs,$(lablgtk_SRC))
	$(OCAMLMKLIB) -o cairo_lablgtk -oc mlcairo_lablgtk $^
cairo_lablgtk.cmxa : $(call mloptobjs,$(lablgtk_SRC))
	$(OCAMLMKLIB) -o cairo_lablgtk -oc mlcairo_lablgtk $^
libmlcairo_lablgtk.a dllmlcairo_lablgtk.so : $(call cobjs,$(lablgtk_SRC))
	$(OCAMLMKLIB) -o cairo_lablgtk -oc mlcairo_lablgtk $^

gtkcairo_SRC = ocairo_gtkcairo.mli ocairo_gtkcairo.ml ml_cairo_gtkcairo.c

gtkcairo.cma : $(call mlobjs,$(gtkcairo_SRC))
	$(OCAMLMKLIB) -o gtkcairo -oc mlgtkcairo $^ $(GTKCAIRO_LIBS)
gtkcairo.cmxa : $(call mloptobjs,$(gtkcairo_SRC))
	$(OCAMLMKLIB) -o gtkcairo -oc mlgtkcairo $^ $(GTKCAIRO_LIBS)
libmlgtkcairo.a dllmlgtkcairo.so : $(call cobjs,$(gtkcairo_SRC))
	$(OCAMLMKLIB) -o gtkcairo -oc mlgtkcairo $^ $(GTKCAIRO_LIBS)

$(call cobjs,$(cairo_SRC))    : CPPFLAGS+=$(CAIRO_CFLAGS)
$(call cobjs,$(lablgtk_SRC))  : CPPFLAGS+=$(GDK_CFLAGS) -I$(C_LABLGTKDIR)
$(call cobjs,$(gtkcairo_SRC)) : CPPFLAGS+=$(GTKCAIRO_CFLAGS) -I$(C_LABLGTKDIR)
$(call mlobjs,$(lablgtk_SRC))  : INCFLAGS=-I $(LABLGTKDIR)
$(call mlobjs,$(gtkcairo_SRC)) : INCFLAGS=-I $(LABLGTKDIR)
$(call mloptobjs,$(lablgtk_SRC))  : INCFLAGS=-I $(LABLGTKDIR)
$(call mloptobjs,$(gtkcairo_SRC)) : INCFLAGS=-I $(LABLGTKDIR)

install: all
	mkdir -p $(DESTDIR)$(INSTALLDIR) $(DESTDIR)$(OCAMLLIB)/stublibs
	install -m 644 *.mli *.cmi *.cma lib*.a $(DESTDIR)$(INSTALLDIR)
ifdef OCAMLOPT
	install -m644 *.cmxa *.a *.cmx $(DESTDIR)$(INSTALLDIR)
endif
	install -m 755 dll*.so $(DESTDIR)$(INSTALLDIR)
	if test -w $(DESTDIR)$(OCAMLLIB)/stublibs ; then \
          for lib in dll*.so ; do \
            ln -s $(INSTALLDIR)/$$lib $(DESTDIR)$(OCAMLLIB)/stublibs ; done ; fi

DOCFILES = cairo_channel.mli cairo.mli ocairo.mli cairo_bigarray.mli
ifdef LABLGTKDIR
DOCFILES += cairo_lablgtk.mli ocairo_lablgtk.mli
ifdef GTKCAIRO_CFLAGS
DOCFILES += ocairo_gtkcairo.mli
endif
endif
doc: $(DOCFILES:%.mli=%.cmi)
	mkdir -p ../doc/html
	ocamldoc -v -html -d ../doc/html $(if $(LABLGTKDIR),-I $(LABLGTKDIR)) $(DOCFILES) 

clean :
	rm -f *.cm* *.o *.a *.so

.depend : $(wildcard *.ml *.mli)
	@echo "making deps"
	@$(OCAMLDEP) $^ > $@

-include .depend
include .depend_c

.PHONY : cairo lablgtk gtkcairo

include ../Makefile.rules