blob: dfb6c78fda4cf661269ffb29f4878634202a18b4 [file] [log] [blame]
iproctor9a41a0c2007-07-16 21:59:24 +00001###########################################################################
2# OCamlMakefile
3# Copyright (C) 1999-2007 Markus Mottl
4#
5# For updates see:
6# http://www.ocaml.info/home/ocaml_sources.html
7#
8###########################################################################
9
10# Modified by damien for .glade.ml compilation
11
12# Set these variables to the names of the sources to be processed and
13# the result variable. Order matters during linkage!
14
15ifndef SOURCES
16 SOURCES := foo.ml
17endif
18export SOURCES
19
20ifndef RES_CLIB_SUF
21 RES_CLIB_SUF := _stubs
22endif
23export RES_CLIB_SUF
24
25ifndef RESULT
26 RESULT := foo
27endif
28export RESULT := $(strip $(RESULT))
29
30export LIB_PACK_NAME
31
32ifndef DOC_FILES
33 DOC_FILES := $(filter %.mli, $(SOURCES))
34endif
35export DOC_FILES
36FIRST_DOC_FILE := $(firstword $(DOC_FILES))
37
38export BCSUFFIX
39export NCSUFFIX
40
41ifndef TOPSUFFIX
42 TOPSUFFIX := .top
43endif
44export TOPSUFFIX
45
46# Eventually set include- and library-paths, libraries to link,
47# additional compilation-, link- and ocamlyacc-flags
48# Path- and library information needs not be written with "-I" and such...
49# Define THREADS if you need it, otherwise leave it unset (same for
50# USE_CAMLP4)!
51
52export THREADS
53export VMTHREADS
54export ANNOTATE
55export USE_CAMLP4
56
57export INCDIRS
58export LIBDIRS
59export EXTLIBDIRS
60export RESULTDEPS
61export OCAML_DEFAULT_DIRS
62
63export LIBS
64export CLIBS
65export CFRAMEWORKS
66
67export OCAMLFLAGS
68export OCAMLNCFLAGS
69export OCAMLBCFLAGS
70
71export OCAMLLDFLAGS
72export OCAMLNLDFLAGS
73export OCAMLBLDFLAGS
74
75export OCAMLMKLIB_FLAGS
76
77ifndef OCAMLCPFLAGS
78 OCAMLCPFLAGS := a
79endif
80export OCAMLCPFLAGS
81
82ifndef DOC_DIR
83 DOC_DIR := doc
84endif
85export DOC_DIR
86
87export PPFLAGS
88
89export LFLAGS
90export YFLAGS
91export IDLFLAGS
92
93export OCAMLDOCFLAGS
94
95export OCAMLFIND_INSTFLAGS
96
97export DVIPSFLAGS
98
99export STATIC
100
101# Add a list of optional trash files that should be deleted by "make clean"
102export TRASH
103
104ECHO := echo
105
106ifdef REALLY_QUIET
107 export REALLY_QUIET
108 ECHO := true
109 LFLAGS := $(LFLAGS) -q
110 YFLAGS := $(YFLAGS) -q
111endif
112
113#################### variables depending on your OCaml-installation
114
115ifdef MINGW
116 export MINGW
117 WIN32 := 1
118 CFLAGS_WIN32 := -mno-cygwin
119endif
120ifdef MSVC
121 export MSVC
122 WIN32 := 1
123 ifndef STATIC
124 CPPFLAGS_WIN32 := -DCAML_DLL
125 endif
126 CFLAGS_WIN32 += -nologo
127 EXT_OBJ := obj
128 EXT_LIB := lib
129 ifeq ($(CC),gcc)
130 # work around GNU Make default value
131 ifdef THREADS
132 CC := cl -MT
133 else
134 CC := cl
135 endif
136 endif
137 ifeq ($(CXX),g++)
138 # work around GNU Make default value
139 CXX := $(CC)
140 endif
141 CFLAG_O := -Fo
142endif
143ifdef WIN32
144 EXT_CXX := cpp
145 EXE := .exe
146endif
147
148ifndef EXT_OBJ
149 EXT_OBJ := o
150endif
151ifndef EXT_LIB
152 EXT_LIB := a
153endif
154ifndef EXT_CXX
155 EXT_CXX := cc
156endif
157ifndef EXE
158 EXE := # empty
159endif
160ifndef CFLAG_O
161 CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)!
162endif
163
164export CC
165export CXX
166export CFLAGS
167export CXXFLAGS
168export LDFLAGS
169export CPPFLAGS
170
171ifndef RPATH_FLAG
172 ifdef ELF_RPATH_FLAG
173 RPATH_FLAG := $(ELF_RPATH_FLAG)
174 else
175 RPATH_FLAG := -R
176 endif
177endif
178export RPATH_FLAG
179
180ifndef MSVC
181ifndef PIC_CFLAGS
182 PIC_CFLAGS := -fPIC
183endif
184ifndef PIC_CPPFLAGS
185 PIC_CPPFLAGS := -DPIC
186endif
187endif
188
189export PIC_CFLAGS
190export PIC_CPPFLAGS
191
192BCRESULT := $(addsuffix $(BCSUFFIX), $(RESULT))
193NCRESULT := $(addsuffix $(NCSUFFIX), $(RESULT))
194TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT))
195
196ifndef OCAMLFIND
197 OCAMLFIND := ocamlfind
198endif
199export OCAMLFIND
200
201ifndef OCAMLC
202 OCAMLC := ocamlc
203endif
204export OCAMLC
205
206ifndef OCAMLOPT
207 OCAMLOPT := ocamlopt
208endif
209export OCAMLOPT
210
211ifndef OCAMLMKTOP
212 OCAMLMKTOP := ocamlmktop
213endif
214export OCAMLMKTOP
215
216ifndef OCAMLCP
217 OCAMLCP := ocamlcp
218endif
219export OCAMLCP
220
221ifndef OCAMLDEP
222 OCAMLDEP := ocamldep
223endif
224export OCAMLDEP
225
226ifndef OCAMLLEX
227 OCAMLLEX := ocamllex
228endif
229export OCAMLLEX
230
231ifndef OCAMLYACC
232 OCAMLYACC := ocamlyacc
233endif
234export OCAMLYACC
235
236ifndef OCAMLMKLIB
237 OCAMLMKLIB := ocamlmklib
238endif
239export OCAMLMKLIB
240
241ifndef OCAML_GLADECC
242 OCAML_GLADECC := lablgladecc2
243endif
244export OCAML_GLADECC
245
246ifndef OCAML_GLADECC_FLAGS
247 OCAML_GLADECC_FLAGS :=
248endif
249export OCAML_GLADECC_FLAGS
250
251ifndef CAMELEON_REPORT
252 CAMELEON_REPORT := report
253endif
254export CAMELEON_REPORT
255
256ifndef CAMELEON_REPORT_FLAGS
257 CAMELEON_REPORT_FLAGS :=
258endif
259export CAMELEON_REPORT_FLAGS
260
261ifndef CAMELEON_ZOGGY
262 CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo
263endif
264export CAMELEON_ZOGGY
265
266ifndef CAMELEON_ZOGGY_FLAGS
267 CAMELEON_ZOGGY_FLAGS :=
268endif
269export CAMELEON_ZOGGY_FLAGS
270
271ifndef OXRIDL
272 OXRIDL := oxridl
273endif
274export OXRIDL
275
276ifndef CAMLIDL
277 CAMLIDL := camlidl
278endif
279export CAMLIDL
280
281ifndef CAMLIDLDLL
282 CAMLIDLDLL := camlidldll
283endif
284export CAMLIDLDLL
285
286ifndef NOIDLHEADER
287 MAYBE_IDL_HEADER := -header
288endif
289export NOIDLHEADER
290
291export NO_CUSTOM
292
293ifndef CAMLP4
294 CAMLP4 := camlp4
295endif
296export CAMLP4
297
298ifndef REAL_OCAMLFIND
299 ifdef PACKS
300 ifndef CREATE_LIB
301 ifdef THREADS
302 PACKS += threads
303 endif
304 endif
305 empty :=
306 space := $(empty) $(empty)
307 comma := ,
308 ifdef PREDS
309 PRE_OCAML_FIND_PREDICATES := $(subst $(space),$(comma),$(PREDS))
310 PRE_OCAML_FIND_PACKAGES := $(subst $(space),$(comma),$(PACKS))
311 OCAML_FIND_PREDICATES := -predicates $(PRE_OCAML_FIND_PREDICATES)
312 # OCAML_DEP_PREDICATES := -syntax $(PRE_OCAML_FIND_PREDICATES)
313 OCAML_FIND_PACKAGES := $(OCAML_FIND_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
314 OCAML_DEP_PACKAGES := $(OCAML_DEP_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
315 else
316 OCAML_FIND_PACKAGES := -package $(subst $(space),$(comma),$(PACKS))
317 OCAML_DEP_PACKAGES :=
318 endif
319 OCAML_FIND_LINKPKG := -linkpkg
320 REAL_OCAMLFIND := $(OCAMLFIND)
321 endif
322endif
323
324export OCAML_FIND_PACKAGES
325export OCAML_DEP_PACKAGES
326export OCAML_FIND_LINKPKG
327export REAL_OCAMLFIND
328
329ifndef OCAMLDOC
330 OCAMLDOC := ocamldoc
331endif
332export OCAMLDOC
333
334ifndef LATEX
335 LATEX := latex
336endif
337export LATEX
338
339ifndef DVIPS
340 DVIPS := dvips
341endif
342export DVIPS
343
344ifndef PS2PDF
345 PS2PDF := ps2pdf
346endif
347export PS2PDF
348
349ifndef OCAMLMAKEFILE
350 OCAMLMAKEFILE := OCamlMakefile
351endif
352export OCAMLMAKEFILE
353
354ifndef OCAMLLIBPATH
355 OCAMLLIBPATH := \
356 $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml)
357endif
358export OCAMLLIBPATH
359
360ifndef OCAML_LIB_INSTALL
361 OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib
362endif
363export OCAML_LIB_INSTALL
364
365###########################################################################
366
367#################### change following sections only if
368#################### you know what you are doing!
369
370# delete target files when a build command fails
371.PHONY: .DELETE_ON_ERROR
372.DELETE_ON_ERROR:
373
374# for pedants using "--warn-undefined-variables"
375export MAYBE_IDL
376export REAL_RESULT
377export CAMLIDLFLAGS
378export THREAD_FLAG
379export RES_CLIB
380export MAKEDLL
381export ANNOT_FLAG
382export C_OXRIDL
383export SUBPROJS
384export CFLAGS_WIN32
385export CPPFLAGS_WIN32
386
387INCFLAGS :=
388
389SHELL := /bin/sh
390
391MLDEPDIR := ._d
392BCDIDIR := ._bcdi
393NCDIDIR := ._ncdi
394
395FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.m %.$(EXT_CXX) %.rep %.zog %.glade
396
397FILTERED := $(filter $(FILTER_EXTNS), $(SOURCES))
398SOURCE_DIRS := $(filter-out ./, $(sort $(dir $(FILTERED))))
399
400FILTERED_REP := $(filter %.rep, $(FILTERED))
401DEP_REP := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d)
402AUTO_REP := $(FILTERED_REP:.rep=.ml)
403
404FILTERED_ZOG := $(filter %.zog, $(FILTERED))
405DEP_ZOG := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d)
406AUTO_ZOG := $(FILTERED_ZOG:.zog=.ml)
407
408FILTERED_GLADE := $(filter %.glade, $(FILTERED))
409DEP_GLADE := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d)
410AUTO_GLADE := $(FILTERED_GLADE:.glade=.ml)
411
412FILTERED_ML := $(filter %.ml, $(FILTERED))
413DEP_ML := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d)
414
415FILTERED_MLI := $(filter %.mli, $(FILTERED))
416DEP_MLI := $(FILTERED_MLI:.mli=.di)
417
418FILTERED_MLL := $(filter %.mll, $(FILTERED))
419DEP_MLL := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d)
420AUTO_MLL := $(FILTERED_MLL:.mll=.ml)
421
422FILTERED_MLY := $(filter %.mly, $(FILTERED))
423DEP_MLY := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di)
424AUTO_MLY := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml)
425
426FILTERED_IDL := $(filter %.idl, $(FILTERED))
427DEP_IDL := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di)
428C_IDL := $(FILTERED_IDL:%.idl=%_stubs.c)
429ifndef NOIDLHEADER
430 C_IDL += $(FILTERED_IDL:.idl=.h)
431endif
432OBJ_C_IDL := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ))
433AUTO_IDL := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL)
434
435FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED))
436DEP_OXRIDL := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di)
437AUTO_OXRIDL := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL)
438
439FILTERED_C_CXX := $(filter %.c %.m %.$(EXT_CXX), $(FILTERED))
440OBJ_C_CXX := $(FILTERED_C_CXX:.c=.$(EXT_OBJ))
441OBJ_C_CXX := $(OBJ_C_CXX:.m=.$(EXT_OBJ))
442OBJ_C_CXX := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ))
443
444PRE_TARGETS += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE)
445
446ALL_DEPS := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE)
447
448MLDEPS := $(filter %.d, $(ALL_DEPS))
449MLIDEPS := $(filter %.di, $(ALL_DEPS))
450BCDEPIS := $(MLIDEPS:%.di=$(BCDIDIR)/%.di)
451NCDEPIS := $(MLIDEPS:%.di=$(NCDIDIR)/%.di)
452
453ALLML := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED))
454
455IMPLO_INTF := $(ALLML:%.mli=%.mli.__)
456IMPLO_INTF := $(foreach file, $(IMPLO_INTF), \
457 $(basename $(file)).cmi $(basename $(file)).cmo)
458IMPLO_INTF := $(filter-out %.mli.cmo, $(IMPLO_INTF))
459IMPLO_INTF := $(IMPLO_INTF:%.mli.cmi=%.cmi)
460
461IMPLX_INTF := $(IMPLO_INTF:.cmo=.cmx)
462
463INTF := $(filter %.cmi, $(IMPLO_INTF))
464IMPL_CMO := $(filter %.cmo, $(IMPLO_INTF))
465IMPL_CMX := $(IMPL_CMO:.cmo=.cmx)
466IMPL_ASM := $(IMPL_CMO:.cmo=.asm)
467IMPL_S := $(IMPL_CMO:.cmo=.s)
468
469OBJ_LINK := $(OBJ_C_IDL) $(OBJ_C_CXX)
470OBJ_FILES := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK)
471
472EXECS := $(addsuffix $(EXE), \
473 $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT)))
474ifdef WIN32
475 EXECS += $(BCRESULT).dll $(NCRESULT).dll
476endif
477
478CLIB_BASE := $(RESULT)$(RES_CLIB_SUF)
479ifneq ($(strip $(OBJ_LINK)),)
480 RES_CLIB := lib$(CLIB_BASE).$(EXT_LIB)
481endif
482
483ifdef WIN32
484DLLSONAME := $(CLIB_BASE).dll
485else
486DLLSONAME := dll$(CLIB_BASE).so
487endif
488
489NONEXECS := $(INTF) $(IMPL_CMO) $(IMPL_CMX) $(IMPL_ASM) $(IMPL_S) \
490 $(OBJ_FILES) $(PRE_TARGETS) $(BCRESULT).cma $(NCRESULT).cmxa \
491 $(NCRESULT).$(EXT_LIB) $(BCRESULT).cmi $(BCRESULT).cmo \
492 $(NCRESULT).cmi $(NCRESULT).cmx $(NCRESULT).o \
493 $(RES_CLIB) $(IMPL_CMO:.cmo=.annot) \
494 $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(LIB_PACK_NAME).cmx $(LIB_PACK_NAME).o
495
496ifndef STATIC
497 NONEXECS += $(DLLSONAME)
498endif
499
500ifndef LIBINSTALL_FILES
501 LIBINSTALL_FILES := $(RESULT).mli $(RESULT).cmi $(RESULT).cma \
502 $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB)
503 ifndef STATIC
504 ifneq ($(strip $(OBJ_LINK)),)
505 LIBINSTALL_FILES += $(DLLSONAME)
506 endif
507 endif
508endif
509
510export LIBINSTALL_FILES
511
512ifdef WIN32
513 # some extra stuff is created while linking DLLs
514 NONEXECS += $(BCRESULT).$(EXT_LIB) $(BCRESULT).exp $(NCRESULT).exp $(CLIB_BASE).exp $(CLIB_BASE).lib
515endif
516
517TARGETS := $(EXECS) $(NONEXECS)
518
519# If there are IDL-files
520ifneq ($(strip $(FILTERED_IDL)),)
521 MAYBE_IDL := -cclib -lcamlidl
522endif
523
524ifdef USE_CAMLP4
525 CAMLP4PATH := \
526 $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/local/lib/camlp4)
527 INCFLAGS := -I $(CAMLP4PATH)
528 CINCFLAGS := -I$(CAMLP4PATH)
529endif
530
531DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %)
532INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %)
533CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%)
534
535ifndef MSVC
536 CLIBFLAGS += $(SOURCE_DIRS:%=-L%) $(LIBDIRS:%=-L%) \
537 $(EXTLIBDIRS:%=-L%) $(OCAML_DEFAULT_DIRS:%=-L%)
538
539 ifeq ($(ELF_RPATH), yes)
540 CLIBFLAGS += $(EXTLIBDIRS:%=-Wl,$(RPATH_FLAG)%)
541 endif
542endif
543
544ifndef PROFILING
545 INTF_OCAMLC := $(OCAMLC)
546else
547 ifndef THREADS
548 INTF_OCAMLC := $(OCAMLCP) -p $(OCAMLCPFLAGS)
549 else
550 # OCaml does not support profiling byte code
551 # with threads (yet), therefore we force an error.
552 ifndef REAL_OCAMLC
553 $(error Profiling of multithreaded byte code not yet supported by OCaml)
554 endif
555 INTF_OCAMLC := $(OCAMLC)
556 endif
557endif
558
559ifndef MSVC
560 COMMON_LDFLAGS := $(LDFLAGS:%=-ccopt %) $(SOURCE_DIRS:%=-ccopt -L%) \
561 $(LIBDIRS:%=-ccopt -L%) $(EXTLIBDIRS:%=-ccopt -L%) \
562 $(EXTLIBDIRS:%=-ccopt -Wl $(OCAML_DEFAULT_DIRS:%=-ccopt -L%))
563
564 ifeq ($(ELF_RPATH),yes)
565 COMMON_LDFLAGS += $(EXTLIBDIRS:%=-ccopt -Wl,$(RPATH_FLAG)%)
566 endif
567else
568 COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \
569 $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \
570 $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) "
571endif
572
573CLIBS_OPTS := $(CLIBS:%=-cclib -l%) $(CFRAMEWORKS:%=-cclib '-framework %')
574ifdef MSVC
575 ifndef STATIC
576 # MSVC libraries do not have 'lib' prefix
577 CLIBS_OPTS := $(CLIBS:%=-cclib %.lib)
578 endif
579endif
580
581ifneq ($(strip $(OBJ_LINK)),)
582 ifdef CREATE_LIB
583 OBJS_LIBS := -cclib -l$(CLIB_BASE) $(CLIBS_OPTS) $(MAYBE_IDL)
584 else
585 OBJS_LIBS := $(OBJ_LINK) $(CLIBS_OPTS) $(MAYBE_IDL)
586 endif
587else
588 OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL)
589endif
590
591# If we have to make byte-code
592ifndef REAL_OCAMLC
593 BYTE_OCAML := y
594
595 # EXTRADEPS is added dependencies we have to insert for all
596 # executable files we generate. Ideally it should be all of the
597 # libraries we use, but it's hard to find the ones that get searched on
598 # the path since I don't know the paths built into the compiler, so
599 # just include the ones with slashes in their names.
600 EXTRADEPS := $(addsuffix .cma,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
601 SPECIAL_OCAMLFLAGS := $(OCAMLBCFLAGS)
602
603 REAL_OCAMLC := $(INTF_OCAMLC)
604
605 REAL_IMPL := $(IMPL_CMO)
606 REAL_IMPL_INTF := $(IMPLO_INTF)
607 IMPL_SUF := .cmo
608
609 DEPFLAGS :=
610 MAKE_DEPS := $(MLDEPS) $(BCDEPIS)
611
612 ifdef CREATE_LIB
613 override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
614 override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
615 ifndef STATIC
616 ifneq ($(strip $(OBJ_LINK)),)
617 MAKEDLL := $(DLLSONAME)
618 ALL_LDFLAGS := -dllib $(DLLSONAME)
619 endif
620 endif
621 endif
622
623 ifndef NO_CUSTOM
624 ifneq "$(strip $(OBJ_LINK) $(THREADS) $(MAYBE_IDL) $(CLIBS) $(CFRAMEWORKS))" ""
625 ALL_LDFLAGS += -custom
626 endif
627 endif
628
629 ALL_LDFLAGS += $(INCFLAGS) $(OCAMLLDFLAGS) $(OCAMLBLDFLAGS) \
630 $(COMMON_LDFLAGS) $(LIBS:%=%.cma)
631 CAMLIDLDLLFLAGS :=
632
633 ifdef THREADS
634 ifdef VMTHREADS
635 THREAD_FLAG := -vmthread
636 else
637 THREAD_FLAG := -thread
638 endif
639 ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
640 ifndef CREATE_LIB
641 ifndef REAL_OCAMLFIND
642 ALL_LDFLAGS := unix.cma threads.cma $(ALL_LDFLAGS)
643 endif
644 endif
645 endif
646
647# we have to make native-code
648else
649 EXTRADEPS := $(addsuffix .cmxa,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
650 ifndef PROFILING
651 SPECIAL_OCAMLFLAGS := $(OCAMLNCFLAGS)
652 PLDFLAGS :=
653 else
654 SPECIAL_OCAMLFLAGS := -p $(OCAMLNCFLAGS)
655 PLDFLAGS := -p
656 endif
657
658 REAL_IMPL := $(IMPL_CMX)
659 REAL_IMPL_INTF := $(IMPLX_INTF)
660 IMPL_SUF := .cmx
661
662 override CPPFLAGS := -DNATIVE_CODE $(CPPFLAGS)
663
664 DEPFLAGS := -native
665 MAKE_DEPS := $(MLDEPS) $(NCDEPIS)
666
667 ALL_LDFLAGS := $(PLDFLAGS) $(INCFLAGS) $(OCAMLLDFLAGS) \
668 $(OCAMLNLDFLAGS) $(COMMON_LDFLAGS)
669 CAMLIDLDLLFLAGS := -opt
670
671 ifndef CREATE_LIB
672 ALL_LDFLAGS += $(LIBS:%=%.cmxa)
673 else
674 override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
675 override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
676 endif
677
678 ifdef THREADS
679 THREAD_FLAG := -thread
680 ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
681 ifndef CREATE_LIB
682 ifndef REAL_OCAMLFIND
683 ALL_LDFLAGS := unix.cmxa threads.cmxa $(ALL_LDFLAGS)
684 endif
685 endif
686 endif
687endif
688
689export MAKE_DEPS
690
691ifdef ANNOTATE
692 ANNOT_FLAG := -dtypes
693else
694endif
695
696ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \
697 $(INCFLAGS) $(SPECIAL_OCAMLFLAGS)
698
699ifdef make_deps
700 -include $(MAKE_DEPS)
701 PRE_TARGETS :=
702endif
703
704###########################################################################
705# USER RULES
706
707# Call "OCamlMakefile QUIET=" to get rid of all of the @'s.
708QUIET=@
709
710# generates byte-code (default)
711byte-code: $(PRE_TARGETS)
712 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
713 REAL_RESULT="$(BCRESULT)" make_deps=yes
714bc: byte-code
715
716byte-code-nolink: $(PRE_TARGETS)
717 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
718 REAL_RESULT="$(BCRESULT)" make_deps=yes
719bcnl: byte-code-nolink
720
721top: $(PRE_TARGETS)
722 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \
723 REAL_RESULT="$(BCRESULT)" make_deps=yes
724
725# generates native-code
726
727native-code: $(PRE_TARGETS)
728 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
729 REAL_RESULT="$(NCRESULT)" \
730 REAL_OCAMLC="$(OCAMLOPT)" \
731 make_deps=yes
732nc: native-code
733
734native-code-nolink: $(PRE_TARGETS)
735 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
736 REAL_RESULT="$(NCRESULT)" \
737 REAL_OCAMLC="$(OCAMLOPT)" \
738 make_deps=yes
739ncnl: native-code-nolink
740
741# generates byte-code libraries
742byte-code-library: $(PRE_TARGETS)
743 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
744 $(RES_CLIB) $(BCRESULT).cma \
745 REAL_RESULT="$(BCRESULT)" \
746 CREATE_LIB=yes \
747 make_deps=yes
748bcl: byte-code-library
749
750# generates native-code libraries
751native-code-library: $(PRE_TARGETS)
752 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
753 $(RES_CLIB) $(NCRESULT).cmxa \
754 REAL_RESULT="$(NCRESULT)" \
755 REAL_OCAMLC="$(OCAMLOPT)" \
756 CREATE_LIB=yes \
757 make_deps=yes
758ncl: native-code-library
759
760ifdef WIN32
761# generates byte-code dll
762byte-code-dll: $(PRE_TARGETS)
763 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
764 $(RES_CLIB) $(BCRESULT).dll \
765 REAL_RESULT="$(BCRESULT)" \
766 make_deps=yes
767bcd: byte-code-dll
768
769# generates native-code dll
770native-code-dll: $(PRE_TARGETS)
771 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
772 $(RES_CLIB) $(NCRESULT).dll \
773 REAL_RESULT="$(NCRESULT)" \
774 REAL_OCAMLC="$(OCAMLOPT)" \
775 make_deps=yes
776ncd: native-code-dll
777endif
778
779# generates byte-code with debugging information
780debug-code: $(PRE_TARGETS)
781 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
782 REAL_RESULT="$(BCRESULT)" make_deps=yes \
783 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
784 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
785dc: debug-code
786
787debug-code-nolink: $(PRE_TARGETS)
788 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
789 REAL_RESULT="$(BCRESULT)" make_deps=yes \
790 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
791 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
792dcnl: debug-code-nolink
793
794# generates byte-code libraries with debugging information
795debug-code-library: $(PRE_TARGETS)
796 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
797 $(RES_CLIB) $(BCRESULT).cma \
798 REAL_RESULT="$(BCRESULT)" make_deps=yes \
799 CREATE_LIB=yes \
800 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
801 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
802dcl: debug-code-library
803
804# generates byte-code for profiling
805profiling-byte-code: $(PRE_TARGETS)
806 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
807 REAL_RESULT="$(BCRESULT)" PROFILING="y" \
808 make_deps=yes
809pbc: profiling-byte-code
810
811# generates native-code
812
813profiling-native-code: $(PRE_TARGETS)
814 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
815 REAL_RESULT="$(NCRESULT)" \
816 REAL_OCAMLC="$(OCAMLOPT)" \
817 PROFILING="y" \
818 make_deps=yes
819pnc: profiling-native-code
820
821# generates byte-code libraries
822profiling-byte-code-library: $(PRE_TARGETS)
823 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
824 $(RES_CLIB) $(BCRESULT).cma \
825 REAL_RESULT="$(BCRESULT)" PROFILING="y" \
826 CREATE_LIB=yes \
827 make_deps=yes
828pbcl: profiling-byte-code-library
829
830# generates native-code libraries
831profiling-native-code-library: $(PRE_TARGETS)
832 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
833 $(RES_CLIB) $(NCRESULT).cmxa \
834 REAL_RESULT="$(NCRESULT)" PROFILING="y" \
835 REAL_OCAMLC="$(OCAMLOPT)" \
836 CREATE_LIB=yes \
837 make_deps=yes
838pncl: profiling-native-code-library
839
840# packs byte-code objects
841pack-byte-code: $(PRE_TARGETS)
842 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \
843 REAL_RESULT="$(BCRESULT)" \
844 PACK_LIB=yes make_deps=yes
845pabc: pack-byte-code
846
847# packs native-code objects
848pack-native-code: $(PRE_TARGETS)
849 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
850 $(NCRESULT).cmx $(NCRESULT).o \
851 REAL_RESULT="$(NCRESULT)" \
852 REAL_OCAMLC="$(OCAMLOPT)" \
853 PACK_LIB=yes make_deps=yes
854panc: pack-native-code
855
856# generates HTML-documentation
857htdoc: $(DOC_DIR)/$(RESULT)/html/index.html
858
859# generates Latex-documentation
860ladoc: $(DOC_DIR)/$(RESULT)/latex/doc.tex
861
862# generates PostScript-documentation
863psdoc: $(DOC_DIR)/$(RESULT)/latex/doc.ps
864
865# generates PDF-documentation
866pdfdoc: $(DOC_DIR)/$(RESULT)/latex/doc.pdf
867
868# generates all supported forms of documentation
869doc: htdoc ladoc psdoc pdfdoc
870
871###########################################################################
872# LOW LEVEL RULES
873
874$(REAL_RESULT): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS)
875 $(REAL_OCAMLFIND) $(REAL_OCAMLC) \
876 $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
877 $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
878 $(REAL_IMPL)
879
880nolink: $(REAL_IMPL_INTF) $(OBJ_LINK)
881
882ifdef WIN32
883$(REAL_RESULT).dll: $(REAL_IMPL_INTF) $(OBJ_LINK)
884 $(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \
885 -o $@ $(REAL_IMPL)
886endif
887
888%$(TOPSUFFIX): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
889 $(REAL_OCAMLFIND) $(OCAMLMKTOP) \
890 $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
891 $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
892 $(REAL_IMPL)
893
894.SUFFIXES: .mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \
895 .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .m .$(EXT_CXX) .h .so \
896 .rep .zog .glade
897
898ifndef STATIC
899ifdef MINGW
900$(DLLSONAME): $(OBJ_LINK)
901 $(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
902 -Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
903 $(OCAMLLIBPATH)/ocamlrun.a \
904 -Wl,--export-all-symbols \
905 -Wl,--no-whole-archive
906else
907ifdef MSVC
908$(DLLSONAME): $(OBJ_LINK)
909 link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
910 $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
911 $(OCAMLLIBPATH)/ocamlrun.lib
912
913else
914$(DLLSONAME): $(OBJ_LINK)
915 $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
916 -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) $(CFRAMEWORKS:%=-framework %) \
917 $(OCAMLMKLIB_FLAGS)
918endif
919endif
920endif
921
922ifndef LIB_PACK_NAME
923$(RESULT).cma: $(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
924 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL)
925
926$(RESULT).cmxa $(RESULT).$(EXT_LIB): $(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS)
927 $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL)
928else
929ifdef BYTE_OCAML
930$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF)
931 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(OCAMLLDFLAGS) $(REAL_IMPL)
932else
933$(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF)
934 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmx $(OCAMLLDFLAGS) $(REAL_IMPL)
935endif
936
937$(RESULT).cma: $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
938 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmo
939
940$(RESULT).cmxa $(RESULT).$(EXT_LIB): $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS)
941 $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmx
942endif
943
944$(RES_CLIB): $(OBJ_LINK)
945ifndef MSVC
946 ifneq ($(strip $(OBJ_LINK)),)
947 $(AR) rcs $@ $(OBJ_LINK)
948 endif
949else
950 ifneq ($(strip $(OBJ_LINK)),)
951 lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK)
952 endif
953endif
954
955.mli.cmi: $(EXTRADEPS)
956 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
957 if [ -z "$$pp" ]; then \
958 $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
959 -c $(THREAD_FLAG) $(ANNOT_FLAG) \
960 $(OCAMLFLAGS) $(INCFLAGS) $<; \
961 $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
962 -c $(THREAD_FLAG) $(ANNOT_FLAG) \
963 $(OCAMLFLAGS) $(INCFLAGS) $<; \
964 else \
965 $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
966 -c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
967 $(OCAMLFLAGS) $(INCFLAGS) $<; \
968 $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
969 -c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \
970 $(OCAMLFLAGS) $(INCFLAGS) $<; \
971 fi
972
973.ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS)
974 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
975 if [ -z "$$pp" ]; then \
976 $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
977 -c $(ALL_OCAMLCFLAGS) $<; \
978 $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
979 -c $(ALL_OCAMLCFLAGS) $<; \
980 else \
981 $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
982 -c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
983 $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
984 -c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \
985 fi
986
987ifdef PACK_LIB
988$(REAL_RESULT).cmo $(REAL_RESULT).cmx $(REAL_RESULT).o: $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
989 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack $(ALL_LDFLAGS) \
990 $(OBJS_LIBS) -o $@ $(REAL_IMPL)
991endif
992
993.PRECIOUS: %.ml
994%.ml: %.mll
995 $(OCAMLLEX) $(LFLAGS) $<
996
997.PRECIOUS: %.ml %.mli
998%.ml %.mli: %.mly
999 $(OCAMLYACC) $(YFLAGS) $<
1000 $(QUIET)pp=`sed -n -e 's/.*(\*pp \([^*]*\) \*).*/\1/p;q' $<`; \
1001 if [ ! -z "$$pp" ]; then \
1002 mv $*.ml $*.ml.temporary; \
1003 echo "(*pp $$pp $(PPFLAGS)*)" > $*.ml; \
1004 cat $*.ml.temporary >> $*.ml; \
1005 rm $*.ml.temporary; \
1006 mv $*.mli $*.mli.temporary; \
1007 echo "(*pp $$pp $(PPFLAGS)*)" > $*.mli; \
1008 cat $*.mli.temporary >> $*.mli; \
1009 rm $*.mli.temporary; \
1010 fi
1011
1012
1013.PRECIOUS: %.ml
1014%.ml: %.rep
1015 $(CAMELEON_REPORT) $(CAMELEON_REPORT_FLAGS) -gen $<
1016
1017.PRECIOUS: %.ml
1018%.ml: %.zog
1019 $(CAMELEON_ZOGGY) $(CAMELEON_ZOGGY_FLAGS) -impl $< > $@
1020
1021.PRECIOUS: %.ml
1022%.ml: %.glade
1023 $(OCAML_GLADECC) $(OCAML_GLADECC_FLAGS) $< > $@
1024
1025.PRECIOUS: %.ml %.mli
1026%.ml %.mli: %.oxridl
1027 $(OXRIDL) $<
1028
1029.PRECIOUS: %.ml %.mli %_stubs.c %.h
1030%.ml %.mli %_stubs.c %.h: %.idl
1031 $(CAMLIDL) $(MAYBE_IDL_HEADER) $(IDLFLAGS) \
1032 $(CAMLIDLFLAGS) $<
1033 $(QUIET)if [ $(NOIDLHEADER) ]; then touch $*.h; fi
1034
1035.c.$(EXT_OBJ):
1036 $(OCAMLC) -c -cc "$(CC)" -ccopt "$(CFLAGS) \
1037 $(CPPFLAGS) $(CPPFLAGS_WIN32) \
1038 $(CFLAGS_WIN32) $(CINCFLAGS) $(CFLAG_O)$@ " $<
1039
1040.m.$(EXT_OBJ):
1041 $(CC) -c $(CFLAGS) $(CINCFLAGS) $(CPPFLAGS) \
1042 -I'$(OCAMLLIBPATH)' \
1043 $< $(CFLAG_O)$@
1044
1045.$(EXT_CXX).$(EXT_OBJ):
1046 $(CXX) -c $(CXXFLAGS) $(CINCFLAGS) $(CPPFLAGS) \
1047 -I'$(OCAMLLIBPATH)' \
1048 $< $(CFLAG_O)$@
1049
1050$(MLDEPDIR)/%.d: %.ml
1051 $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
1052 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1053 if [ -z "$$pp" ]; then \
1054 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1055 $(DINCFLAGS) $< \> $@; \
1056 $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1057 $(DINCFLAGS) $< > $@; \
1058 else \
1059 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1060 -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \
1061 $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1062 -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
1063 fi
1064
1065$(BCDIDIR)/%.di $(NCDIDIR)/%.di: %.mli
1066 $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
1067 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1068 if [ -z "$$pp" ]; then \
1069 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< \> $@; \
1070 $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< > $@; \
1071 else \
1072 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
1073 -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \
1074 $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
1075 -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
1076 fi
1077
1078$(DOC_DIR)/$(RESULT)/html:
1079 mkdir -p $@
1080
1081$(DOC_DIR)/$(RESULT)/html/index.html: $(DOC_DIR)/$(RESULT)/html $(DOC_FILES)
1082 rm -rf $</*
1083 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $(FIRST_DOC_FILE)`; \
1084 if [ -z "$$pp" ]; then \
1085 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -html -d $< $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
1086 $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -html -d $< $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
1087 else \
1088 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp \"$$pp $(PPFLAGS)\" -html -d $< $(OCAMLDOCFLAGS) \
1089 $(INCFLAGS) $(DOC_FILES); \
1090 $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp "$$pp $(PPFLAGS)" -html -d $< $(OCAMLDOCFLAGS) \
1091 $(INCFLAGS) $(DOC_FILES); \
1092 fi
1093
1094$(DOC_DIR)/$(RESULT)/latex:
1095 mkdir -p $@
1096
1097$(DOC_DIR)/$(RESULT)/latex/doc.tex: $(DOC_DIR)/$(RESULT)/latex $(DOC_FILES)
1098 rm -rf $</*
1099 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $(FIRST_DOC_FILE)`; \
1100 if [ -z "$$pp" ]; then \
1101 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) \
1102 $(DOC_FILES) -o $@; \
1103 $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES) \
1104 -o $@; \
1105 else \
1106 $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp \"$$pp $(PPFLAGS)\" -latex $(OCAMLDOCFLAGS) \
1107 $(INCFLAGS) $(DOC_FILES) -o $@; \
1108 $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp "$$pp $(PPFLAGS)" -latex $(OCAMLDOCFLAGS) \
1109 $(INCFLAGS) $(DOC_FILES) -o $@; \
1110 fi
1111
1112$(DOC_DIR)/$(RESULT)/latex/doc.ps: $(DOC_DIR)/$(RESULT)/latex/doc.tex
1113 cd $(DOC_DIR)/$(RESULT)/latex && \
1114 $(LATEX) doc.tex && \
1115 $(LATEX) doc.tex && \
1116 $(DVIPS) $(DVIPSFLAGS) doc.dvi -o $(@F)
1117
1118$(DOC_DIR)/$(RESULT)/latex/doc.pdf: $(DOC_DIR)/$(RESULT)/latex/doc.ps
1119 cd $(DOC_DIR)/$(RESULT)/latex && $(PS2PDF) $(<F)
1120
1121define make_subproj
1122.PHONY:
1123subproj_$(1):
1124 $$(eval $$(call PROJ_$(1)))
1125 $(QUIET)if [ "$(SUBTARGET)" != "all" ]; then \
1126 $(MAKE) -f $(OCAMLMAKEFILE) $(SUBTARGET); \
1127 fi
1128endef
1129
1130$(foreach subproj,$(SUBPROJS),$(eval $(call make_subproj,$(subproj))))
1131
1132.PHONY:
1133subprojs: $(SUBPROJS:%=subproj_%)
1134
1135###########################################################################
1136# (UN)INSTALL RULES FOR LIBRARIES
1137
1138.PHONY: libinstall
1139libinstall: all
1140 $(QUIET)printf "\nInstalling library with ocamlfind\n"
1141 $(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META $(LIBINSTALL_FILES)
1142 $(QUIET)printf "\nInstallation successful.\n"
1143
1144.PHONY: libuninstall
1145libuninstall:
1146 $(QUIET)printf "\nUninstalling library with ocamlfind\n"
1147 $(OCAMLFIND) remove $(OCAMLFIND_INSTFLAGS) $(RESULT)
1148 $(QUIET)printf "\nUninstallation successful.\n"
1149
1150.PHONY: rawinstall
1151rawinstall: all
1152 $(QUIET)printf "\nInstalling library to: $(OCAML_LIB_INSTALL)\n"
1153 -install -d $(OCAML_LIB_INSTALL)
1154 for i in $(LIBINSTALL_FILES); do \
1155 if [ -f $$i ]; then \
1156 install -c -m 0644 $$i $(OCAML_LIB_INSTALL); \
1157 fi; \
1158 done
1159 $(QUIET)printf "\nInstallation successful.\n"
1160
1161.PHONY: rawuninstall
1162rawuninstall:
1163 $(QUIET)printf "\nUninstalling library from: $(OCAML_LIB_INSTALL)\n"
1164 cd $(OCAML_LIB_INSTALL) && rm $(notdir $(LIBINSTALL_FILES))
1165 $(QUIET)printf "\nUninstallation successful.\n"
1166
1167###########################################################################
1168# MAINTENANCE RULES
1169
1170.PHONY: clean
1171clean::
1172 rm -f $(TARGETS) $(TRASH)
1173 rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
1174
1175.PHONY: cleanup
1176cleanup::
1177 rm -f $(NONEXECS) $(TRASH)
1178 rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
1179
1180.PHONY: clean-doc
1181clean-doc::
1182 rm -rf $(DOC_DIR)/$(RESULT)
1183
1184.PHONY: clean-all
1185clean-all:: clean clean-doc
1186
1187.PHONY: nobackup
1188nobackup:
1189 rm -f *.bak *~ *.dup