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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
|
##########################################################################
# ocaml-gettext: a library to translate messages #
# #
# Copyright (C) 2001 Jean-Christophe FILLIATRE #
# Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> #
# #
# This library is free software; you can redistribute it and/or #
# modify it under the terms of the GNU Lesser General Public #
# License as published by the Free Software Foundation; either #
# version 2.1 of the License, or (at your option) any later version; #
# with the OCaml static compilation exception. #
# #
# This library is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public #
# License along with this library; if not, write to the Free Software #
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 #
# USA #
##########################################################################
# destination dir
DOCHTML=$(DOCDIR)/html
DOCODOC=$(DOCDIR)/html
DOCPDF =$(DOCDIR)/pdf
# programs flags
FOPFLAGS =
XSLTPROCFLAGS = --xinclude
XMLLINTFLAGS = --xinclude --noent --noout --postvalid
OCAMLDOCFLAGS =
ifdef REQUIRES
CLI_REQUIRES = -package "$(REQUIRES)"
endif
ifdef PREDICATES
CLI_PREDICATES = -predicates "$(PREDICATES)"
endif
ifdef SYNTAX
CLI_SYNTAX = -syntax $(SYNTAX)
endif
CLI_OCAMLFIND = $(CLI_REQUIRES) $(CLI_PREDICATES) $(CLI_SYNTAX)
BUILDLIB = $(TMPBUILDDIR)/lib
BUILDBIN = $(TMPBUILDDIR)/bin
BUILDDOC = $(TMPBUILDDIR)/share/doc
BUILDHTML = $(BUILDDOC)/html
BUILDMAN = $(TMPBUILDDIR)/share/man
BUILDODOC = $(BUILDHTML)/api
BUILDPDF = $(BUILDDOC)
BUILDPO = $(TMPBUILDDIR)/share/locale
OCAMLPATH:=$(BUILDLIB)/:$(OCAMLPATH)
export OCAMLPATH
all: $(STUBSLIB) $(if $(NAME),all-$(OCAMLBEST))
all-byte: $(if $(LIBRARY), install-buildlib-byte, install-buildprog-byte)
all-opt: $(if $(LIBRARY), install-buildlib-opt, install-buildprog-opt)
all: install-builddoc-html
all: install-builddoc-man
all: install-builddoc-odoc
all: install-builddoc-pdf
install: all $(if $(NAME),install-$(OCAMLBEST))
install-byte: $(if $(LIBRARY), install-lib-byte, install-prog-byte)
install-opt: $(if $(LIBRARY), install-lib-opt, install-prog-byte)
install: install-doc-html
install: install-doc-man
install: install-doc-odoc
install: install-doc-pdf
uninstall: $(if $(LIBRARY), uninstall-lib, uninstall-prog)
uninstall: uninstall-doc-html
uninstall: uninstall-doc-man
uninstall: uninstall-doc-odoc
uninstall: uninstall-doc-pdf
clean:: $(if $(LIBRARY), clean-lib, clean-prog)
clean:: clean-doc-odoc
clean:: clean-doc-pdf
clean:: clean-doc-html
clean:: clean-doc-man
distclean::
CMX = $(patsubst dll%.so, lib%.a, $(CMO:.cmo=.cmx))
INSTALL_DIR_AUX=$(INSTALL) -d $(2); $(INSTALL_DATA) -t $(2) $(wildcard $(dir $(1))*)
INSTALL_DIR=$(call INSTALL_DIR_AUX,$(1),$(2)/$(notdir $(patsubst %/,%,$(dir $(1)))))
# Build the lib
ONLY_BYTE=$(filter-out %.o,$(filter-out %.a,$(filter-out %.cmx, $(filter-out %.cmxa,$(1))))) $(filter lib%.a,$(1))
ML_OR_MLI=$(if $(wildcard $(1).mli),$(1).mli,$(1).ml)
GET_MLI=$(foreach interf,$(patsubst %.mli,%,$(filter %.mli,$(patsubst %.cmi,%.mli,$(1)))),$(call ML_OR_MLI,$(interf)))
%.cmxa %.a %.so:
$(if $(STUBSOBJS), \
$(OCAMLMKLIB) -o $* $^ $(OCAMLMKLIB_FLAGS), \
$(OCAMLOPT) -a -o $*.cmxa $^ \
)
%.cma %.a %.so:
$(if $(STUBSOBJS), \
$(OCAMLMKLIB) -o $* $^ $(OCAMLMKLIB_FLAGS), \
$(OCAMLC) -a -o $*.cma $^ \
)
install-buildlib-byte: REAL_INSTALLIB = $(call ONLY_BYTE,$(INSTALLIB))
install-buildlib-byte: $(call ONLY_BYTE,$(INSTALLIB))
install-buildlib-byte: install-buildlib-common
install-buildlib-opt: REAL_INSTALLIB = $(INSTALLIB)
install-buildlib-opt: $(INSTALLIB)
install-buildlib-opt: install-buildlib-common
install-buildlib-common: $(call GET_MLI,$(INSTALLIB))
$(INSTALL) -d $(BUILDLIB)
-$(OCAMLFIND) remove -destdir $(BUILDLIB) $(NAME)
$(OCAMLFIND) install -ldconf ignore -destdir $(BUILDLIB) -patch-version $(VERSION) $(NAME) \
$(REAL_INSTALLIB) $(call GET_MLI, $(REAL_INSTALLIB))
install-lib-byte: REAL_INSTALLIB = $(call ONLY_BYTE,$(INSTALLIB))
install-lib-byte: $(call ONLY_BYTE,$(INSTALLIB))
install-lib-byte: install-lib-common
install-lib-opt: REAL_INSTALLIB = $(INSTALLIB)
install-lib-opt: $(INSTALLIB)
install-lib-opt: install-lib-common
install-lib-common: $(call GET_MLI,$(INSTALLIB))
-$(OCAMLFIND) remove $(OCAMLFIND_REMOVE_FLAGS) $(NAME)
$(OCAMLFIND) install $(OCAMLFIND_INSTALL_FLAGS) -patch-version $(VERSION) $(NAME) \
$(REAL_INSTALLIB) $(call GET_MLI,$(INSTALLIB))
uninstall-lib:
-$(OCAMLFIND) remove $(OCAMLFIND_REMOVE_FLAGS) $(NAME)
clean-lib:
-$(OCAMLFIND) remove -destdir $(BUILDLIB) $(NAME)
# Build the executable
BLIBS = $(addsuffix .cma,$(LIBS))
install-buildprog-byte: $(CMO)
$(OCAMLC) -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
-predicates "$(PREDICATES)" $(BLIBS) $(CMO)
$(INSTALL) -d $(BUILDBIN)
$(INSTALL_SCRIPT) -t $(BUILDBIN) $(NAME)
install-prog-byte: install-buildprog-byte
$(INSTALL) -d $(BINDIR)
$(INSTALL_SCRIPT) -t $(BINDIR) $(NAME)
OLIBS = $(addsuffix .cmxa,$(LIBS))
install-buildprog-opt: $(CMX)
$(OCAMLOPT) -o $(NAME) $(INCLUDES) -package "$(REQUIRES)" -linkpkg \
-predicates "$(PREDICATES)" $(OLIBS) $(CMX)
$(INSTALL) -d $(BUILDBIN)
$(INSTALL_SCRIPT) -t $(BUILDBIN) $(NAME)
install-prog-opt: install-buildprog-opt
$(INSTALL) -d $(BINDIR)
$(INSTALL_SCRIPT) -t $(BINDIR)/ $(NAME)
uninstall-prog:
$(if $(NAME),-$(RM) $(BINDIR)/$(NAME))
clean-prog:
-$(RM) $(NAME)
# Build PDF files
PDF_TARGET=$(patsubst %.xml,$(BUILDPDF)/%.pdf,$(1))
$(BUILDPDF)/%.pdf: %.fo
$(INSTALL) -d $(dir $@)
$(FOP) $(FOPFLAGS) -fo $^ -pdf $@
%.fo: %.xml
$(XMLLINT) $(XMLLINTFLAGS) $^
$(XSLTPROC) $(XSLTPROCFLAGS) -o $@ $(FOXSL) $^
install-builddoc-pdf: $(PDF_TARGETS)
clean-doc-pdf:
install-doc-pdf:
$(if $(PDF_TARGETS),$(INSTALL) -d $(DOCPDF))
$(if $(PDF_TARGETS),$(INSTALL_DATA) -t $(DOCPDF) $(PDF_TARGETS))
uninstall-doc-pdf:
-$(if $(PDF_TARGETS),$(RM) $(foreach i,$(PDF_TARGETS),$(DOCPDF)/$(notdir $(i))))
# Build OCaml documentaiton
ODOC_TARGET=$(BUILDODOC)/$(1)/index.html
TARGET_ODOC=$(notdir $(patsubst %/index.html,%,$(1)))
$(BUILDODOC)/%/index.html:
$(INSTALL) -d $(dir $@)
EXTRAFLAGS=`$(OCAMLFIND) query -i-format -r $(REQUIRES)`; \
$(OCAMLDOC) $(OCAMLDOCFLAGS) $$EXTRAFLAGS -d $(dir $@) -html $^
$(if $(EXTRAFILES),$(INSTALL_DATA) -t $(dir $@) $(EXTRAFILES))
install-builddoc-odoc: $(ODOC_TARGETS)
clean-doc-odoc:
install-doc-odoc:
$(if $(ODOC_TARGETS),$(foreach i,$(ODOC_TARGETS), $(INSTALL) -d $(DOCODOC)/$(call TARGET_ODOC,$(i));))
$(if $(ODOC_TARGETS),$(foreach i,$(ODOC_TARGETS), $(INSTALL_DATA) -t $(DOCODOC)/$(call TARGET_ODOC,$(i)) $(wildcard $(dir $(i))/*);))
uninstall-doc-odoc: clean-doc-odoc
-$(if $(ODOC_TARGETS),$(RM) -r $(foreach i,$(ODOC_TARGETS),$(DOCODOC)/$(call TARGET_ODOC,$(i))))
# Build HTML files
HTML_TARGET=$(patsubst %.xml,$(BUILDHTML)/%/index.html,$(1))
TARGET_HTML=$(notdir $(patsubst %/index.html,%,$(1)))
$(BUILDHTML)/%/index.html: %.xml
$(XMLLINT) $(XMLLINTFLAGS) $^
$(INSTALL) -d $(dir $@)
$(XSLTPROC) $(XSLTPROCFLAGS) --stringparam base.dir "$(dir $@)" $(HTMLXSL) $^
$(if $(IMAGES),$(INSTALL_DATA) -t $(dir $@) $(IMAGES))
install-builddoc-html: $(HTML_TARGETS)
clean-doc-html:
install-doc-html: install-builddoc-html
$(if $(HTML_TARGETS),$(foreach i,$(HTML_TARGETS),$(call INSTALL_DIR,$(i),$(DOCHTML));))
uninstall-doc-html: clean-doc-html
-$(if $(HTML_TARGETS),$(RM) -r $(foreach i,$(HTML_TARGETS),$(DOCHTML)/$(call TARGET_HTML,$(i))))
# Build MAN files
MAN_SECTION=man$(patsubst .%,%,$(suffix $(1)))
MAN_BUILD_TARGETS=$(BUILDMAN)/$(call MAN_SECTION,$(1))/$(1)
MAN_INSTALL_TARGETS=$(MANDIR)/$(call MAN_SECTION,$(1))/$(1)
define PROCESS_MAN
$(XMLLINT) $(XMLLINTFLAGS) $^
$(XSLTPROC) $(XSLTPROCFLAGS) $(MANXSL) $^
$(INSTALL) -d $(dir $(call MAN_BUILD_TARGETS,$@))
$(INSTALL_DATA) $@ $(call MAN_BUILD_TARGETS,$@)
endef
%.1:
$(PROCESS_MAN)
%.2:
$(PROCESS_MAN)
%.3:
$(PROCESS_MAN)
%.4:
$(PROCESS_MAN)
%.5:
$(PROCESS_MAN)
%.6:
$(PROCESS_MAN)
%.7:
$(PROCESS_MAN)
%.8:
$(PROCESS_MAN)
%.9:
$(PROCESS_MAN)
install-builddoc-man: $(MAN_TARGETS)
clean-doc-man:
install-doc-man: install-builddoc-man
$(if $(MAN_TARGETS),$(foreach i,$(MAN_TARGETS),$(INSTALL) -d $(dir $(call MAN_INSTALL_TARGETS,$(i)));))
$(if $(MAN_TARGETS),$(foreach i,$(MAN_TARGETS),$(INSTALL_DATA) $(call MAN_BUILD_TARGETS,$(i)) $(call MAN_INSTALL_TARGETS,$(i));))
uninstall-doc-man: clean-doc-man
-$(if $(MAN_TARGETS),$(RM) $(foreach i,$(MAN_TARGETS),$(call MAN_INSTALL_TARGETS,$(i))))
# Extra files
.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .zog .idl .h .o
%.ml %.mli %.h %_stubs.c: %.idl
$(CAMLIDL) -nocpp -no-include $<
.c.o:
$(OCAMLC) $(INCLUDES) -c $<
.mli.cmi:
$(OCAMLC) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.ml.cmo:
$(OCAMLC) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.ml.o:
$(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.ml.cmx:
$(OCAMLOPT) $(INCLUDES) $(CLI_OCAMLFIND) -c $<
.mll.ml:
$(OCAMLLEX) $<
.mly.ml:
$(OCAMLYACC) -v $<
.mly.mli:
$(OCAMLYACC) -v $<
#.ml.mli:
# $(OCAMLC) $(INCLUDES) $(CLI_OCAMLFIND) -i $< > $@ || $(RM) $@
# # Set date of the target to the date of the source
# touch -r $< $@
clean:: $(if $(LIBRARY),clean-lib,clean-prog)
-$(RM) *.cm[ioxa] *.o *.cmxa *.a *.so
-$(RM) $(GENERATED) *.output
distclean:: clean
|