1 ###########################################################################
3 # Copyright (C) 1999-2004 Markus Mottl
6 # http://www.ocaml.info/home/ocaml_sources.html
8 # $Id: OCamlMakefile,v 1.72 2005/12/09 15:30:50 mottl Exp $
10 ###########################################################################
12 # Modified by damien for .glade.ml compilation
14 # Set these variables to the names of the sources to be processed and
15 # the result variable. Order matters during linkage!
23 RES_CLIB_SUF := _stubs
35 DOC_FILES := $(filter %.mli, $(SOURCES))
47 # Eventually set include- and library-paths, libraries to link,
48 # additional compilation-, link- and ocamlyacc-flags
49 # Path- and library information needs not be written with "-I" and such...
50 # Define THREADS if you need it, otherwise leave it unset (same for
62 export OCAML_DEFAULT_DIRS
88 export OCAMLFIND_INSTFLAGS
94 # Add a list of optional trash files that should be deleted by "make clean"
97 #################### variables depending on your OCaml-installation
102 CFLAGS_WIN32 := -mno-cygwin
108 CPPFLAGS_WIN32 := -DCAML_DLL
110 CFLAGS_WIN32 += -nologo
114 # work around GNU Make default value
122 # work around GNU Make default value
145 CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)!
157 RPATH_FLAG := $(ELF_RPATH_FLAG)
169 PIC_CPPFLAGS := -DPIC
176 BCRESULT := $(addsuffix $(BCSUFFIX), $(RESULT))
177 NCRESULT := $(addsuffix $(NCSUFFIX), $(RESULT))
178 TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT))
181 OCAMLFIND := ocamlfind
196 OCAMLMKTOP := ocamlmktop
216 OCAMLYACC := ocamlyacc
221 OCAMLMKLIB := ocamlmklib
226 OCAML_GLADECC := lablgladecc2
230 ifndef OCAML_GLADECC_FLAGS
231 OCAML_GLADECC_FLAGS :=
233 export OCAML_GLADECC_FLAGS
235 ifndef CAMELEON_REPORT
236 CAMELEON_REPORT := report
238 export CAMELEON_REPORT
240 ifndef CAMELEON_REPORT_FLAGS
241 CAMELEON_REPORT_FLAGS :=
243 export CAMELEON_REPORT_FLAGS
245 ifndef CAMELEON_ZOGGY
246 CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo
248 export CAMELEON_ZOGGY
250 ifndef CAMELEON_ZOGGY_FLAGS
251 CAMELEON_ZOGGY_FLAGS :=
253 export CAMELEON_ZOGGY_FLAGS
266 CAMLIDLDLL := camlidldll
271 MAYBE_IDL_HEADER := -header
282 ifndef REAL_OCAMLFIND
290 space := $(empty) $(empty)
293 PRE_OCAML_FIND_PREDICATES := $(subst $(space),$(comma),$(PREDS))
294 PRE_OCAML_FIND_PACKAGES := $(subst $(space),$(comma),$(PACKS))
295 OCAML_FIND_PREDICATES := -predicates $(PRE_OCAML_FIND_PREDICATES)
296 # OCAML_DEP_PREDICATES := -syntax $(PRE_OCAML_FIND_PREDICATES)
297 OCAML_FIND_PACKAGES := $(OCAML_FIND_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
298 OCAML_DEP_PACKAGES := $(OCAML_DEP_PREDICATES) -package $(PRE_OCAML_FIND_PACKAGES)
300 OCAML_FIND_PACKAGES := -package $(subst $(space),$(comma),$(PACKS))
301 OCAML_DEP_PACKAGES :=
303 OCAML_FIND_LINKPKG := -linkpkg
304 REAL_OCAMLFIND := $(OCAMLFIND)
308 export OCAML_FIND_PACKAGES
309 export OCAML_DEP_PACKAGES
310 export OCAML_FIND_LINKPKG
311 export REAL_OCAMLFIND
334 OCAMLMAKEFILE := OCamlMakefile
340 $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml)
344 ifndef OCAML_LIB_INSTALL
345 OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib
347 export OCAML_LIB_INSTALL
349 ###########################################################################
351 #################### change following sections only if
352 #################### you know what you are doing!
354 # delete target files when a build command fails
355 .PHONY: .DELETE_ON_ERROR
358 # for pedants using "--warn-undefined-variables"
369 export CPPFLAGS_WIN32
379 FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.$(EXT_CXX) %.rep %.zog %.glade
381 FILTERED := $(filter $(FILTER_EXTNS), $(SOURCES))
382 SOURCE_DIRS := $(filter-out ./, $(sort $(dir $(FILTERED))))
384 FILTERED_REP := $(filter %.rep, $(FILTERED))
385 DEP_REP := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d)
386 AUTO_REP := $(FILTERED_REP:.rep=.ml)
388 FILTERED_ZOG := $(filter %.zog, $(FILTERED))
389 DEP_ZOG := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d)
390 AUTO_ZOG := $(FILTERED_ZOG:.zog=.ml)
392 FILTERED_GLADE := $(filter %.glade, $(FILTERED))
393 DEP_GLADE := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d)
394 AUTO_GLADE := $(FILTERED_GLADE:.glade=.ml)
396 FILTERED_ML := $(filter %.ml, $(FILTERED))
397 DEP_ML := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d)
399 FILTERED_MLI := $(filter %.mli, $(FILTERED))
400 DEP_MLI := $(FILTERED_MLI:.mli=.di)
402 FILTERED_MLL := $(filter %.mll, $(FILTERED))
403 DEP_MLL := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d)
404 AUTO_MLL := $(FILTERED_MLL:.mll=.ml)
406 FILTERED_MLY := $(filter %.mly, $(FILTERED))
407 DEP_MLY := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di)
408 AUTO_MLY := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml)
410 FILTERED_IDL := $(filter %.idl, $(FILTERED))
411 DEP_IDL := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di)
412 C_IDL := $(FILTERED_IDL:%.idl=%_stubs.c)
414 C_IDL += $(FILTERED_IDL:.idl=.h)
416 OBJ_C_IDL := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ))
417 AUTO_IDL := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL)
419 FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED))
420 DEP_OXRIDL := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di)
421 AUTO_OXRIDL := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL)
423 FILTERED_C_CXX := $(filter %.c %.$(EXT_CXX), $(FILTERED))
424 OBJ_C_CXX := $(FILTERED_C_CXX:.c=.$(EXT_OBJ))
425 OBJ_C_CXX := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ))
427 PRE_TARGETS += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE)
429 ALL_DEPS := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE)
431 MLDEPS := $(filter %.d, $(ALL_DEPS))
432 MLIDEPS := $(filter %.di, $(ALL_DEPS))
433 BCDEPIS := $(MLIDEPS:%.di=$(BCDIDIR)/%.di)
434 NCDEPIS := $(MLIDEPS:%.di=$(NCDIDIR)/%.di)
436 ALLML := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED))
438 IMPLO_INTF := $(ALLML:%.mli=%.mli.__)
439 IMPLO_INTF := $(foreach file, $(IMPLO_INTF), \
440 $(basename $(file)).cmi $(basename $(file)).cmo)
441 IMPLO_INTF := $(filter-out %.mli.cmo, $(IMPLO_INTF))
442 IMPLO_INTF := $(IMPLO_INTF:%.mli.cmi=%.cmi)
444 IMPLX_INTF := $(IMPLO_INTF:.cmo=.cmx)
446 INTF := $(filter %.cmi, $(IMPLO_INTF))
447 IMPL_CMO := $(filter %.cmo, $(IMPLO_INTF))
448 IMPL_CMX := $(IMPL_CMO:.cmo=.cmx)
449 IMPL_ASM := $(IMPL_CMO:.cmo=.asm)
450 IMPL_S := $(IMPL_CMO:.cmo=.s)
452 OBJ_LINK := $(OBJ_C_IDL) $(OBJ_C_CXX)
453 OBJ_FILES := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK)
455 EXECS := $(addsuffix $(EXE), \
456 $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT)))
458 EXECS += $(BCRESULT).dll $(NCRESULT).dll
461 CLIB_BASE := $(RESULT)$(RES_CLIB_SUF)
462 ifneq ($(strip $(OBJ_LINK)),)
463 RES_CLIB := lib$(CLIB_BASE).$(EXT_LIB)
467 DLLSONAME := $(CLIB_BASE).dll
469 DLLSONAME := dll$(CLIB_BASE).so
472 NONEXECS := $(INTF) $(IMPL_CMO) $(IMPL_CMX) $(IMPL_ASM) $(IMPL_S) \
473 $(OBJ_FILES) $(PRE_TARGETS) $(BCRESULT).cma $(NCRESULT).cmxa \
474 $(NCRESULT).$(EXT_LIB) $(BCRESULT).cmi $(BCRESULT).cmo \
475 $(NCRESULT).cmi $(NCRESULT).cmx $(NCRESULT).o \
476 $(RES_CLIB) $(IMPL_CMO:.cmo=.annot) \
477 $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(LIB_PACK_NAME).cmx $(LIB_PACK_NAME).o
480 NONEXECS += $(DLLSONAME)
483 ifndef LIBINSTALL_FILES
484 LIBINSTALL_FILES := $(RESULT).mli $(RESULT).cmi $(RESULT).cma \
485 $(RESULT).cmxa $(RESULT).$(EXT_LIB) $(RES_CLIB)
487 ifneq ($(strip $(OBJ_LINK)),)
488 LIBINSTALL_FILES += $(DLLSONAME)
493 export LIBINSTALL_FILES
496 # some extra stuff is created while linking DLLs
497 NONEXECS += $(BCRESULT).$(EXT_LIB) $(BCRESULT).exp $(NCRESULT).exp $(CLIB_BASE).exp $(CLIB_BASE).lib
500 TARGETS := $(EXECS) $(NONEXECS)
502 # If there are IDL-files
503 ifneq ($(strip $(FILTERED_IDL)),)
504 MAYBE_IDL := -cclib -lcamlidl
509 $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/local/lib/camlp4)
510 INCFLAGS := -I $(CAMLP4PATH)
511 CINCFLAGS := -I$(CAMLP4PATH)
514 DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %)
515 INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %)
516 CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%)
519 CLIBFLAGS += $(SOURCE_DIRS:%=-L%) $(LIBDIRS:%=-L%) \
520 $(EXTLIBDIRS:%=-L%) $(OCAML_DEFAULT_DIRS:%=-L%)
522 ifeq ($(ELF_RPATH), yes)
523 CLIBFLAGS += $(EXTLIBDIRS:%=-Wl,$(RPATH_FLAG)%)
528 INTF_OCAMLC := $(OCAMLC)
531 INTF_OCAMLC := $(OCAMLCP) -p $(OCAMLCPFLAGS)
533 # OCaml does not support profiling byte code
534 # with threads (yet), therefore we force an error.
536 $(error Profiling of multithreaded byte code not yet supported by OCaml)
538 INTF_OCAMLC := $(OCAMLC)
543 COMMON_LDFLAGS := $(LDFLAGS:%=-ccopt %) $(SOURCE_DIRS:%=-ccopt -L%) \
544 $(LIBDIRS:%=-ccopt -L%) $(EXTLIBDIRS:%=-ccopt -L%) \
545 $(EXTLIBDIRS:%=-ccopt -Wl $(OCAML_DEFAULT_DIRS:%=-ccopt -L%))
547 ifeq ($(ELF_RPATH),yes)
548 COMMON_LDFLAGS += $(EXTLIBDIRS:%=-ccopt -Wl,$(RPATH_FLAG)%)
551 COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \
552 $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \
553 $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) "
556 CLIBS_OPTS := $(CLIBS:%=-cclib -l%)
559 # MSVC libraries do not have 'lib' prefix
560 CLIBS_OPTS := $(CLIBS:%=-cclib %.lib)
564 ifneq ($(strip $(OBJ_LINK)),)
566 OBJS_LIBS := -cclib -l$(CLIB_BASE) $(CLIBS_OPTS) $(MAYBE_IDL)
568 OBJS_LIBS := $(OBJ_LINK) $(CLIBS_OPTS) $(MAYBE_IDL)
571 OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL)
574 # If we have to make byte-code
578 # EXTRADEPS is added dependencies we have to insert for all
579 # executable files we generate. Ideally it should be all of the
580 # libraries we use, but it's hard to find the ones that get searched on
581 # the path since I don't know the paths built into the compiler, so
582 # just include the ones with slashes in their names.
583 EXTRADEPS := $(addsuffix .cma,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
584 SPECIAL_OCAMLFLAGS := $(OCAMLBCFLAGS)
586 REAL_OCAMLC := $(INTF_OCAMLC)
588 REAL_IMPL := $(IMPL_CMO)
589 REAL_IMPL_INTF := $(IMPLO_INTF)
593 MAKE_DEPS := $(MLDEPS) $(BCDEPIS)
596 override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
597 override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
599 ifneq ($(strip $(OBJ_LINK)),)
600 MAKEDLL := $(DLLSONAME)
601 ALL_LDFLAGS := -dllib $(DLLSONAME)
607 ifneq "$(strip $(OBJ_LINK) $(THREADS) $(MAYBE_IDL) $(CLIBS))" ""
608 ALL_LDFLAGS += -custom
612 ALL_LDFLAGS += $(INCFLAGS) $(OCAMLLDFLAGS) $(OCAMLBLDFLAGS) \
613 $(COMMON_LDFLAGS) $(LIBS:%=%.cma)
618 THREAD_FLAG := -vmthread
620 THREAD_FLAG := -thread
622 ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
624 ifndef REAL_OCAMLFIND
625 ALL_LDFLAGS := unix.cma threads.cma $(ALL_LDFLAGS)
630 # we have to make native-code
632 EXTRADEPS := $(addsuffix .cmxa,$(foreach i,$(LIBS),$(if $(findstring /,$(i)),$(i))))
634 SPECIAL_OCAMLFLAGS := $(OCAMLNCFLAGS)
637 SPECIAL_OCAMLFLAGS := -p $(OCAMLNCFLAGS)
641 REAL_IMPL := $(IMPL_CMX)
642 REAL_IMPL_INTF := $(IMPLX_INTF)
645 override CPPFLAGS := -DNATIVE_CODE $(CPPFLAGS)
648 MAKE_DEPS := $(MLDEPS) $(NCDEPIS)
650 ALL_LDFLAGS := $(PLDFLAGS) $(INCFLAGS) $(OCAMLLDFLAGS) \
651 $(OCAMLNLDFLAGS) $(COMMON_LDFLAGS)
652 CAMLIDLDLLFLAGS := -opt
655 ALL_LDFLAGS += $(LIBS:%=%.cmxa)
657 override CFLAGS := $(PIC_CFLAGS) $(CFLAGS)
658 override CPPFLAGS := $(PIC_CPPFLAGS) $(CPPFLAGS)
662 THREAD_FLAG := -thread
663 ALL_LDFLAGS := $(THREAD_FLAG) $(ALL_LDFLAGS)
665 ifndef REAL_OCAMLFIND
666 ALL_LDFLAGS := unix.cmxa threads.cmxa $(ALL_LDFLAGS)
675 ANNOT_FLAG := -dtypes
679 ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \
680 $(INCFLAGS) $(SPECIAL_OCAMLFLAGS)
683 -include $(MAKE_DEPS)
687 ###########################################################################
690 # Call "OCamlMakefile QUIET=" to get rid of all of the @'s.
693 # generates byte-code (default)
694 byte-code: $(PRE_TARGETS)
695 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
696 REAL_RESULT="$(BCRESULT)" make_deps=yes
699 byte-code-nolink: $(PRE_TARGETS)
700 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
701 REAL_RESULT="$(BCRESULT)" make_deps=yes
702 bcnl: byte-code-nolink
705 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \
706 REAL_RESULT="$(BCRESULT)" make_deps=yes
708 # generates native-code
710 native-code: $(PRE_TARGETS)
711 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
712 REAL_RESULT="$(NCRESULT)" \
713 REAL_OCAMLC="$(OCAMLOPT)" \
717 native-code-nolink: $(PRE_TARGETS)
718 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
719 REAL_RESULT="$(NCRESULT)" \
720 REAL_OCAMLC="$(OCAMLOPT)" \
722 ncnl: native-code-nolink
724 # generates byte-code libraries
725 byte-code-library: $(PRE_TARGETS)
726 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
727 $(RES_CLIB) $(BCRESULT).cma \
728 REAL_RESULT="$(BCRESULT)" \
731 bcl: byte-code-library
733 # generates native-code libraries
734 native-code-library: $(PRE_TARGETS)
735 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
736 $(RES_CLIB) $(NCRESULT).cmxa \
737 REAL_RESULT="$(NCRESULT)" \
738 REAL_OCAMLC="$(OCAMLOPT)" \
741 ncl: native-code-library
744 # generates byte-code dll
745 byte-code-dll: $(PRE_TARGETS)
746 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
747 $(RES_CLIB) $(BCRESULT).dll \
748 REAL_RESULT="$(BCRESULT)" \
752 # generates native-code dll
753 native-code-dll: $(PRE_TARGETS)
754 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
755 $(RES_CLIB) $(NCRESULT).dll \
756 REAL_RESULT="$(NCRESULT)" \
757 REAL_OCAMLC="$(OCAMLOPT)" \
762 # generates byte-code with debugging information
763 debug-code: $(PRE_TARGETS)
764 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
765 REAL_RESULT="$(BCRESULT)" make_deps=yes \
766 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
767 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
770 debug-code-nolink: $(PRE_TARGETS)
771 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \
772 REAL_RESULT="$(BCRESULT)" make_deps=yes \
773 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
774 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
775 dcnl: debug-code-nolink
777 # generates byte-code libraries with debugging information
778 debug-code-library: $(PRE_TARGETS)
779 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
780 $(RES_CLIB) $(BCRESULT).cma \
781 REAL_RESULT="$(BCRESULT)" make_deps=yes \
783 OCAMLFLAGS="-g $(OCAMLFLAGS)" \
784 OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)"
785 dcl: debug-code-library
787 # generates byte-code for profiling
788 profiling-byte-code: $(PRE_TARGETS)
789 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \
790 REAL_RESULT="$(BCRESULT)" PROFILING="y" \
792 pbc: profiling-byte-code
794 # generates native-code
796 profiling-native-code: $(PRE_TARGETS)
797 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \
798 REAL_RESULT="$(NCRESULT)" \
799 REAL_OCAMLC="$(OCAMLOPT)" \
802 pnc: profiling-native-code
804 # generates byte-code libraries
805 profiling-byte-code-library: $(PRE_TARGETS)
806 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
807 $(RES_CLIB) $(BCRESULT).cma \
808 REAL_RESULT="$(BCRESULT)" PROFILING="y" \
811 pbcl: profiling-byte-code-library
813 # generates native-code libraries
814 profiling-native-code-library: $(PRE_TARGETS)
815 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
816 $(RES_CLIB) $(NCRESULT).cmxa \
817 REAL_RESULT="$(NCRESULT)" PROFILING="y" \
818 REAL_OCAMLC="$(OCAMLOPT)" \
821 pncl: profiling-native-code-library
823 # packs byte-code objects
824 pack-byte-code: $(PRE_TARGETS)
825 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \
826 REAL_RESULT="$(BCRESULT)" \
827 PACK_LIB=yes make_deps=yes
830 # packs native-code objects
831 pack-native-code: $(PRE_TARGETS)
832 $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \
833 $(NCRESULT).cmx $(NCRESULT).o \
834 REAL_RESULT="$(NCRESULT)" \
835 REAL_OCAMLC="$(OCAMLOPT)" \
836 PACK_LIB=yes make_deps=yes
837 panc: pack-native-code
839 # generates HTML-documentation
840 htdoc: doc/$(RESULT)/html
842 # generates Latex-documentation
843 ladoc: doc/$(RESULT)/latex
845 # generates PostScript-documentation
846 psdoc: doc/$(RESULT)/latex/doc.ps
848 # generates PDF-documentation
849 pdfdoc: doc/$(RESULT)/latex/doc.pdf
851 # generates all supported forms of documentation
852 doc: htdoc ladoc psdoc pdfdoc
854 ###########################################################################
857 $(REAL_RESULT): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS)
858 $(REAL_OCAMLFIND) $(REAL_OCAMLC) \
859 $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
860 $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
863 nolink: $(REAL_IMPL_INTF) $(OBJ_LINK)
866 $(REAL_RESULT).dll: $(REAL_IMPL_INTF) $(OBJ_LINK)
867 $(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \
871 %$(TOPSUFFIX): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
872 $(REAL_OCAMLFIND) $(OCAMLMKTOP) \
873 $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \
874 $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \
877 .SUFFIXES: .mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \
878 .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .$(EXT_CXX) .h .so \
883 $(DLLSONAME): $(OBJ_LINK)
884 $(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
885 -Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
886 $(OCAMLLIBPATH)/ocamlrun.a \
887 -Wl,--export-all-symbols \
888 -Wl,--no-whole-archive
891 $(DLLSONAME): $(OBJ_LINK)
892 link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
893 $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
894 $(OCAMLLIBPATH)/ocamlrun.lib
897 $(DLLSONAME): $(OBJ_LINK)
898 $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \
899 -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) \
906 $(RESULT).cma: $(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
907 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
908 $(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(REAL_IMPL)
910 $(RESULT).cmxa $(RESULT).$(EXT_LIB): $(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS)
911 $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
912 $(OCAMLNLDFLAGS) -o $@ $(REAL_IMPL)
915 $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF)
916 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(OCAMLLDFLAGS) $(REAL_IMPL)
918 $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF)
919 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmx $(OCAMLLDFLAGS) $(REAL_IMPL)
922 $(RESULT).cma: $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS)
923 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) \
924 $(OBJS_LIBS) -o $@ $(OCAMLBLDFLAGS) $(LIB_PACK_NAME).cmo
926 $(RESULT).cmxa $(RESULT).$(EXT_LIB): $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS)
927 $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) \
928 $(OCAMLNLDFLAGS) -o $@ $(LIB_PACK_NAME).cmx
931 $(RES_CLIB): $(OBJ_LINK)
933 ifneq ($(strip $(OBJ_LINK)),)
934 $(AR) rcs $@ $(OBJ_LINK)
937 ifneq ($(strip $(OBJ_LINK)),)
938 lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK)
942 .mli.cmi: $(EXTRADEPS)
943 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
944 if [ -z "$$pp" ]; then \
945 echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
946 -c $(THREAD_FLAG) $(ANNOT_FLAG) \
947 $(OCAMLFLAGS) $(INCFLAGS) $<; \
948 $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
949 -c $(THREAD_FLAG) $(ANNOT_FLAG) \
950 $(OCAMLFLAGS) $(INCFLAGS) $<; \
952 echo $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
953 -c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \
954 $(OCAMLFLAGS) $(INCFLAGS) $<; \
955 $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \
956 -c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \
957 $(OCAMLFLAGS) $(INCFLAGS) $<; \
960 .ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS)
961 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
962 if [ -z "$$pp" ]; then \
963 echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
964 -c $(ALL_OCAMLCFLAGS) $<; \
965 $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
966 -c $(ALL_OCAMLCFLAGS) $<; \
968 echo $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
969 -c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \
970 $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \
971 -c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \
975 $(REAL_RESULT).cmo $(REAL_RESULT).cmx $(REAL_RESULT).o: $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS)
976 $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack $(ALL_LDFLAGS) \
977 $(OBJS_LIBS) -o $@ $(REAL_IMPL)
984 .PRECIOUS: %.ml %.mli
986 $(OCAMLYACC) $(YFLAGS) $<
987 $(QUIET)pp=`sed -n -e 's/.*(\*pp \([^*]*\) \*).*/\1/p;q' $<`; \
988 if [ ! -z "$$pp" ]; then \
989 mv $*.ml $*.ml.temporary; \
990 echo "(*pp $$pp $(PPFLAGS)*)" > $*.ml; \
991 cat $*.ml.temporary >> $*.ml; \
992 rm $*.ml.temporary; \
993 mv $*.mli $*.mli.temporary; \
994 echo "(*pp $$pp $(PPFLAGS)*)" > $*.mli; \
995 cat $*.mli.temporary >> $*.mli; \
996 rm $*.mli.temporary; \
1002 $(CAMELEON_REPORT) $(CAMELEON_REPORT_FLAGS) -gen $<
1006 $(CAMELEON_ZOGGY) $(CAMELEON_ZOGGY_FLAGS) -impl $< > $@
1010 $(OCAML_GLADECC) $(OCAML_GLADECC_FLAGS) $< > $@
1012 .PRECIOUS: %.ml %.mli
1013 %.ml %.mli: %.oxridl
1016 .PRECIOUS: %.ml %.mli %_stubs.c %.h
1017 %.ml %.mli %_stubs.c %.h: %.idl
1018 $(CAMLIDL) $(MAYBE_IDL_HEADER) $(IDLFLAGS) \
1020 $(QUIET)if [ $(NOIDLHEADER) ]; then touch $*.h; fi
1023 $(OCAMLC) -c -cc "$(CC)" -ccopt "$(CFLAGS) \
1024 $(CPPFLAGS) $(CPPFLAGS_WIN32) \
1025 $(CFLAGS_WIN32) $(CINCFLAGS) $(CFLAG_O)$@ " $<
1027 .$(EXT_CXX).$(EXT_OBJ):
1028 $(CXX) -c $(CXXFLAGS) $(CINCFLAGS) $(CPPFLAGS) \
1029 -I'$(OCAMLLIBPATH)' \
1032 $(MLDEPDIR)/%.d: %.ml
1033 $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
1034 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1035 if [ -z "$$pp" ]; then \
1036 echo $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1037 $(DINCFLAGS) $< \> $@; \
1038 $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1039 $(DINCFLAGS) $< > $@; \
1041 echo $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1042 -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \
1043 $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \
1044 -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
1047 $(BCDIDIR)/%.di $(NCDIDIR)/%.di: %.mli
1048 $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi
1049 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1050 if [ -z "$$pp" ]; then \
1051 echo $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< \> $@; \
1052 $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< > $@; \
1054 echo $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
1055 -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \
1056 $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \
1057 -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \
1060 doc/$(RESULT)/html: $(DOC_FILES)
1063 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1064 if [ -z "$$pp" ]; then \
1065 echo $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
1066 $(OCAMLDOC) -html -d $@ $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \
1068 echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -html -d $@ $(OCAMLDOCFLAGS) \
1069 $(INCFLAGS) $(DOC_FILES); \
1070 $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -html -d $@ $(OCAMLDOCFLAGS) \
1071 $(INCFLAGS) $(DOC_FILES); \
1074 doc/$(RESULT)/latex: $(DOC_FILES)
1077 $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \
1078 if [ -z "$$pp" ]; then \
1079 echo $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) \
1080 $(DOC_FILES) -o $@/doc.tex; \
1081 $(OCAMLDOC) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES) \
1084 echo $(OCAMLDOC) -pp \"$$pp $(PPFLAGS)\" -latex $(OCAMLDOCFLAGS) \
1085 $(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
1086 $(OCAMLDOC) -pp "$$pp $(PPFLAGS)" -latex $(OCAMLDOCFLAGS) \
1087 $(INCFLAGS) $(DOC_FILES) -o $@/doc.tex; \
1090 doc/$(RESULT)/latex/doc.ps: doc/$(RESULT)/latex
1091 cd doc/$(RESULT)/latex && \
1092 $(LATEX) doc.tex && \
1093 $(LATEX) doc.tex && \
1094 $(DVIPS) $(DVIPSFLAGS) doc.dvi -o $(@F)
1096 doc/$(RESULT)/latex/doc.pdf: doc/$(RESULT)/latex/doc.ps
1097 cd doc/$(RESULT)/latex && $(PS2PDF) $(<F)
1102 $$(eval $$(call PROJ_$(1)))
1103 $(QUIET)if [ "$(SUBTARGET)" != "all" ]; then \
1104 $(MAKE) -f $(OCAMLMAKEFILE) $(SUBTARGET); \
1108 $(foreach subproj,$(SUBPROJS),$(eval $(call make_subproj,$(subproj))))
1111 subprojs: $(SUBPROJS:%=subproj_%)
1113 ###########################################################################
1114 # (UN)INSTALL RULES FOR LIBRARIES
1118 $(QUIET)printf "\nInstalling library with ocamlfind\n"
1119 $(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META $(LIBINSTALL_FILES)
1120 $(QUIET)printf "\nInstallation successful.\n"
1122 .PHONY: libuninstall
1124 $(QUIET)printf "\nUninstalling library with ocamlfind\n"
1125 $(OCAMLFIND) remove $(OCAMLFIND_INSTFLAGS) $(RESULT)
1126 $(QUIET)printf "\nUninstallation successful.\n"
1130 $(QUIET)printf "\nInstalling library to: $(OCAML_LIB_INSTALL)\n"
1131 -install -d $(OCAML_LIB_INSTALL)
1132 for i in $(LIBINSTALL_FILES); do \
1133 if [ -f $$i ]; then \
1134 install -c -m 0644 $$i $(OCAML_LIB_INSTALL); \
1137 $(QUIET)printf "\nInstallation successful.\n"
1139 .PHONY: rawuninstall
1141 $(QUIET)printf "\nUninstalling library from: $(OCAML_LIB_INSTALL)\n"
1142 cd $(OCAML_LIB_INSTALL) && rm $(notdir $(LIBINSTALL_FILES))
1143 $(QUIET)printf "\nUninstallation successful.\n"
1145 ###########################################################################
1146 # MAINTAINANCE RULES
1150 rm -f $(TARGETS) $(TRASH)
1151 rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
1155 rm -f $(NONEXECS) $(TRASH)
1156 rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR)
1164 rm -f *.bak *~ *.dup