iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 1 | ########################################################################### |
| 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 | |
| 15 | ifndef SOURCES |
| 16 | SOURCES := foo.ml |
| 17 | endif |
| 18 | export SOURCES |
| 19 | |
| 20 | ifndef RES_CLIB_SUF |
| 21 | RES_CLIB_SUF := _stubs |
| 22 | endif |
| 23 | export RES_CLIB_SUF |
| 24 | |
| 25 | ifndef RESULT |
| 26 | RESULT := foo |
| 27 | endif |
| 28 | export RESULT := $(strip $(RESULT)) |
| 29 | |
| 30 | export LIB_PACK_NAME |
| 31 | |
| 32 | ifndef DOC_FILES |
| 33 | DOC_FILES := $(filter %.mli, $(SOURCES)) |
| 34 | endif |
| 35 | export DOC_FILES |
| 36 | FIRST_DOC_FILE := $(firstword $(DOC_FILES)) |
| 37 | |
| 38 | export BCSUFFIX |
| 39 | export NCSUFFIX |
| 40 | |
| 41 | ifndef TOPSUFFIX |
| 42 | TOPSUFFIX := .top |
| 43 | endif |
| 44 | export 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 | |
| 52 | export THREADS |
| 53 | export VMTHREADS |
| 54 | export ANNOTATE |
| 55 | export USE_CAMLP4 |
| 56 | |
| 57 | export INCDIRS |
| 58 | export LIBDIRS |
| 59 | export EXTLIBDIRS |
| 60 | export RESULTDEPS |
| 61 | export OCAML_DEFAULT_DIRS |
| 62 | |
| 63 | export LIBS |
| 64 | export CLIBS |
| 65 | export CFRAMEWORKS |
| 66 | |
| 67 | export OCAMLFLAGS |
| 68 | export OCAMLNCFLAGS |
| 69 | export OCAMLBCFLAGS |
| 70 | |
| 71 | export OCAMLLDFLAGS |
| 72 | export OCAMLNLDFLAGS |
| 73 | export OCAMLBLDFLAGS |
| 74 | |
| 75 | export OCAMLMKLIB_FLAGS |
| 76 | |
| 77 | ifndef OCAMLCPFLAGS |
| 78 | OCAMLCPFLAGS := a |
| 79 | endif |
| 80 | export OCAMLCPFLAGS |
| 81 | |
| 82 | ifndef DOC_DIR |
| 83 | DOC_DIR := doc |
| 84 | endif |
| 85 | export DOC_DIR |
| 86 | |
| 87 | export PPFLAGS |
| 88 | |
| 89 | export LFLAGS |
| 90 | export YFLAGS |
| 91 | export IDLFLAGS |
| 92 | |
| 93 | export OCAMLDOCFLAGS |
| 94 | |
| 95 | export OCAMLFIND_INSTFLAGS |
| 96 | |
| 97 | export DVIPSFLAGS |
| 98 | |
| 99 | export STATIC |
| 100 | |
| 101 | # Add a list of optional trash files that should be deleted by "make clean" |
| 102 | export TRASH |
| 103 | |
| 104 | ECHO := echo |
| 105 | |
| 106 | ifdef REALLY_QUIET |
| 107 | export REALLY_QUIET |
| 108 | ECHO := true |
| 109 | LFLAGS := $(LFLAGS) -q |
| 110 | YFLAGS := $(YFLAGS) -q |
| 111 | endif |
| 112 | |
| 113 | #################### variables depending on your OCaml-installation |
| 114 | |
| 115 | ifdef MINGW |
| 116 | export MINGW |
| 117 | WIN32 := 1 |
| 118 | CFLAGS_WIN32 := -mno-cygwin |
| 119 | endif |
| 120 | ifdef 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 |
| 142 | endif |
| 143 | ifdef WIN32 |
| 144 | EXT_CXX := cpp |
| 145 | EXE := .exe |
| 146 | endif |
| 147 | |
| 148 | ifndef EXT_OBJ |
| 149 | EXT_OBJ := o |
| 150 | endif |
| 151 | ifndef EXT_LIB |
| 152 | EXT_LIB := a |
| 153 | endif |
| 154 | ifndef EXT_CXX |
| 155 | EXT_CXX := cc |
| 156 | endif |
| 157 | ifndef EXE |
| 158 | EXE := # empty |
| 159 | endif |
| 160 | ifndef CFLAG_O |
| 161 | CFLAG_O := -o # do not delete this comment (preserves trailing whitespace)! |
| 162 | endif |
| 163 | |
| 164 | export CC |
| 165 | export CXX |
| 166 | export CFLAGS |
| 167 | export CXXFLAGS |
| 168 | export LDFLAGS |
| 169 | export CPPFLAGS |
| 170 | |
| 171 | ifndef RPATH_FLAG |
| 172 | ifdef ELF_RPATH_FLAG |
| 173 | RPATH_FLAG := $(ELF_RPATH_FLAG) |
| 174 | else |
| 175 | RPATH_FLAG := -R |
| 176 | endif |
| 177 | endif |
| 178 | export RPATH_FLAG |
| 179 | |
| 180 | ifndef MSVC |
| 181 | ifndef PIC_CFLAGS |
| 182 | PIC_CFLAGS := -fPIC |
| 183 | endif |
| 184 | ifndef PIC_CPPFLAGS |
| 185 | PIC_CPPFLAGS := -DPIC |
| 186 | endif |
| 187 | endif |
| 188 | |
| 189 | export PIC_CFLAGS |
| 190 | export PIC_CPPFLAGS |
| 191 | |
| 192 | BCRESULT := $(addsuffix $(BCSUFFIX), $(RESULT)) |
| 193 | NCRESULT := $(addsuffix $(NCSUFFIX), $(RESULT)) |
| 194 | TOPRESULT := $(addsuffix $(TOPSUFFIX), $(RESULT)) |
| 195 | |
| 196 | ifndef OCAMLFIND |
| 197 | OCAMLFIND := ocamlfind |
| 198 | endif |
| 199 | export OCAMLFIND |
| 200 | |
| 201 | ifndef OCAMLC |
| 202 | OCAMLC := ocamlc |
| 203 | endif |
| 204 | export OCAMLC |
| 205 | |
| 206 | ifndef OCAMLOPT |
| 207 | OCAMLOPT := ocamlopt |
| 208 | endif |
| 209 | export OCAMLOPT |
| 210 | |
| 211 | ifndef OCAMLMKTOP |
| 212 | OCAMLMKTOP := ocamlmktop |
| 213 | endif |
| 214 | export OCAMLMKTOP |
| 215 | |
| 216 | ifndef OCAMLCP |
| 217 | OCAMLCP := ocamlcp |
| 218 | endif |
| 219 | export OCAMLCP |
| 220 | |
| 221 | ifndef OCAMLDEP |
| 222 | OCAMLDEP := ocamldep |
| 223 | endif |
| 224 | export OCAMLDEP |
| 225 | |
| 226 | ifndef OCAMLLEX |
| 227 | OCAMLLEX := ocamllex |
| 228 | endif |
| 229 | export OCAMLLEX |
| 230 | |
| 231 | ifndef OCAMLYACC |
| 232 | OCAMLYACC := ocamlyacc |
| 233 | endif |
| 234 | export OCAMLYACC |
| 235 | |
| 236 | ifndef OCAMLMKLIB |
| 237 | OCAMLMKLIB := ocamlmklib |
| 238 | endif |
| 239 | export OCAMLMKLIB |
| 240 | |
| 241 | ifndef OCAML_GLADECC |
| 242 | OCAML_GLADECC := lablgladecc2 |
| 243 | endif |
| 244 | export OCAML_GLADECC |
| 245 | |
| 246 | ifndef OCAML_GLADECC_FLAGS |
| 247 | OCAML_GLADECC_FLAGS := |
| 248 | endif |
| 249 | export OCAML_GLADECC_FLAGS |
| 250 | |
| 251 | ifndef CAMELEON_REPORT |
| 252 | CAMELEON_REPORT := report |
| 253 | endif |
| 254 | export CAMELEON_REPORT |
| 255 | |
| 256 | ifndef CAMELEON_REPORT_FLAGS |
| 257 | CAMELEON_REPORT_FLAGS := |
| 258 | endif |
| 259 | export CAMELEON_REPORT_FLAGS |
| 260 | |
| 261 | ifndef CAMELEON_ZOGGY |
| 262 | CAMELEON_ZOGGY := camlp4o pa_zog.cma pr_o.cmo |
| 263 | endif |
| 264 | export CAMELEON_ZOGGY |
| 265 | |
| 266 | ifndef CAMELEON_ZOGGY_FLAGS |
| 267 | CAMELEON_ZOGGY_FLAGS := |
| 268 | endif |
| 269 | export CAMELEON_ZOGGY_FLAGS |
| 270 | |
| 271 | ifndef OXRIDL |
| 272 | OXRIDL := oxridl |
| 273 | endif |
| 274 | export OXRIDL |
| 275 | |
| 276 | ifndef CAMLIDL |
| 277 | CAMLIDL := camlidl |
| 278 | endif |
| 279 | export CAMLIDL |
| 280 | |
| 281 | ifndef CAMLIDLDLL |
| 282 | CAMLIDLDLL := camlidldll |
| 283 | endif |
| 284 | export CAMLIDLDLL |
| 285 | |
| 286 | ifndef NOIDLHEADER |
| 287 | MAYBE_IDL_HEADER := -header |
| 288 | endif |
| 289 | export NOIDLHEADER |
| 290 | |
| 291 | export NO_CUSTOM |
| 292 | |
| 293 | ifndef CAMLP4 |
| 294 | CAMLP4 := camlp4 |
| 295 | endif |
| 296 | export CAMLP4 |
| 297 | |
| 298 | ifndef 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 |
| 322 | endif |
| 323 | |
| 324 | export OCAML_FIND_PACKAGES |
| 325 | export OCAML_DEP_PACKAGES |
| 326 | export OCAML_FIND_LINKPKG |
| 327 | export REAL_OCAMLFIND |
| 328 | |
| 329 | ifndef OCAMLDOC |
| 330 | OCAMLDOC := ocamldoc |
| 331 | endif |
| 332 | export OCAMLDOC |
| 333 | |
| 334 | ifndef LATEX |
| 335 | LATEX := latex |
| 336 | endif |
| 337 | export LATEX |
| 338 | |
| 339 | ifndef DVIPS |
| 340 | DVIPS := dvips |
| 341 | endif |
| 342 | export DVIPS |
| 343 | |
| 344 | ifndef PS2PDF |
| 345 | PS2PDF := ps2pdf |
| 346 | endif |
| 347 | export PS2PDF |
| 348 | |
| 349 | ifndef OCAMLMAKEFILE |
| 350 | OCAMLMAKEFILE := OCamlMakefile |
| 351 | endif |
| 352 | export OCAMLMAKEFILE |
| 353 | |
| 354 | ifndef OCAMLLIBPATH |
| 355 | OCAMLLIBPATH := \ |
| 356 | $(shell $(OCAMLC) 2>/dev/null -where || echo /usr/local/lib/ocaml) |
| 357 | endif |
| 358 | export OCAMLLIBPATH |
| 359 | |
| 360 | ifndef OCAML_LIB_INSTALL |
| 361 | OCAML_LIB_INSTALL := $(OCAMLLIBPATH)/contrib |
| 362 | endif |
| 363 | export 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" |
| 375 | export MAYBE_IDL |
| 376 | export REAL_RESULT |
| 377 | export CAMLIDLFLAGS |
| 378 | export THREAD_FLAG |
| 379 | export RES_CLIB |
| 380 | export MAKEDLL |
| 381 | export ANNOT_FLAG |
| 382 | export C_OXRIDL |
| 383 | export SUBPROJS |
| 384 | export CFLAGS_WIN32 |
| 385 | export CPPFLAGS_WIN32 |
| 386 | |
| 387 | INCFLAGS := |
| 388 | |
| 389 | SHELL := /bin/sh |
| 390 | |
| 391 | MLDEPDIR := ._d |
| 392 | BCDIDIR := ._bcdi |
| 393 | NCDIDIR := ._ncdi |
| 394 | |
| 395 | FILTER_EXTNS := %.mli %.ml %.mll %.mly %.idl %.oxridl %.c %.m %.$(EXT_CXX) %.rep %.zog %.glade |
| 396 | |
| 397 | FILTERED := $(filter $(FILTER_EXTNS), $(SOURCES)) |
| 398 | SOURCE_DIRS := $(filter-out ./, $(sort $(dir $(FILTERED)))) |
| 399 | |
| 400 | FILTERED_REP := $(filter %.rep, $(FILTERED)) |
| 401 | DEP_REP := $(FILTERED_REP:%.rep=$(MLDEPDIR)/%.d) |
| 402 | AUTO_REP := $(FILTERED_REP:.rep=.ml) |
| 403 | |
| 404 | FILTERED_ZOG := $(filter %.zog, $(FILTERED)) |
| 405 | DEP_ZOG := $(FILTERED_ZOG:%.zog=$(MLDEPDIR)/%.d) |
| 406 | AUTO_ZOG := $(FILTERED_ZOG:.zog=.ml) |
| 407 | |
| 408 | FILTERED_GLADE := $(filter %.glade, $(FILTERED)) |
| 409 | DEP_GLADE := $(FILTERED_GLADE:%.glade=$(MLDEPDIR)/%.d) |
| 410 | AUTO_GLADE := $(FILTERED_GLADE:.glade=.ml) |
| 411 | |
| 412 | FILTERED_ML := $(filter %.ml, $(FILTERED)) |
| 413 | DEP_ML := $(FILTERED_ML:%.ml=$(MLDEPDIR)/%.d) |
| 414 | |
| 415 | FILTERED_MLI := $(filter %.mli, $(FILTERED)) |
| 416 | DEP_MLI := $(FILTERED_MLI:.mli=.di) |
| 417 | |
| 418 | FILTERED_MLL := $(filter %.mll, $(FILTERED)) |
| 419 | DEP_MLL := $(FILTERED_MLL:%.mll=$(MLDEPDIR)/%.d) |
| 420 | AUTO_MLL := $(FILTERED_MLL:.mll=.ml) |
| 421 | |
| 422 | FILTERED_MLY := $(filter %.mly, $(FILTERED)) |
| 423 | DEP_MLY := $(FILTERED_MLY:%.mly=$(MLDEPDIR)/%.d) $(FILTERED_MLY:.mly=.di) |
| 424 | AUTO_MLY := $(FILTERED_MLY:.mly=.mli) $(FILTERED_MLY:.mly=.ml) |
| 425 | |
| 426 | FILTERED_IDL := $(filter %.idl, $(FILTERED)) |
| 427 | DEP_IDL := $(FILTERED_IDL:%.idl=$(MLDEPDIR)/%.d) $(FILTERED_IDL:.idl=.di) |
| 428 | C_IDL := $(FILTERED_IDL:%.idl=%_stubs.c) |
| 429 | ifndef NOIDLHEADER |
| 430 | C_IDL += $(FILTERED_IDL:.idl=.h) |
| 431 | endif |
| 432 | OBJ_C_IDL := $(FILTERED_IDL:%.idl=%_stubs.$(EXT_OBJ)) |
| 433 | AUTO_IDL := $(FILTERED_IDL:.idl=.mli) $(FILTERED_IDL:.idl=.ml) $(C_IDL) |
| 434 | |
| 435 | FILTERED_OXRIDL := $(filter %.oxridl, $(FILTERED)) |
| 436 | DEP_OXRIDL := $(FILTERED_OXRIDL:%.oxridl=$(MLDEPDIR)/%.d) $(FILTERED_OXRIDL:.oxridl=.di) |
| 437 | AUTO_OXRIDL := $(FILTERED_OXRIDL:.oxridl=.mli) $(FILTERED_OXRIDL:.oxridl=.ml) $(C_OXRIDL) |
| 438 | |
| 439 | FILTERED_C_CXX := $(filter %.c %.m %.$(EXT_CXX), $(FILTERED)) |
| 440 | OBJ_C_CXX := $(FILTERED_C_CXX:.c=.$(EXT_OBJ)) |
| 441 | OBJ_C_CXX := $(OBJ_C_CXX:.m=.$(EXT_OBJ)) |
| 442 | OBJ_C_CXX := $(OBJ_C_CXX:.$(EXT_CXX)=.$(EXT_OBJ)) |
| 443 | |
| 444 | PRE_TARGETS += $(AUTO_MLL) $(AUTO_MLY) $(AUTO_IDL) $(AUTO_OXRIDL) $(AUTO_ZOG) $(AUTO_REP) $(AUTO_GLADE) |
| 445 | |
| 446 | ALL_DEPS := $(DEP_ML) $(DEP_MLI) $(DEP_MLL) $(DEP_MLY) $(DEP_IDL) $(DEP_OXRIDL) $(DEP_ZOG) $(DEP_REP) $(DEP_GLADE) |
| 447 | |
| 448 | MLDEPS := $(filter %.d, $(ALL_DEPS)) |
| 449 | MLIDEPS := $(filter %.di, $(ALL_DEPS)) |
| 450 | BCDEPIS := $(MLIDEPS:%.di=$(BCDIDIR)/%.di) |
| 451 | NCDEPIS := $(MLIDEPS:%.di=$(NCDIDIR)/%.di) |
| 452 | |
| 453 | ALLML := $(filter %.mli %.ml %.mll %.mly %.idl %.oxridl %.rep %.zog %.glade, $(FILTERED)) |
| 454 | |
| 455 | IMPLO_INTF := $(ALLML:%.mli=%.mli.__) |
| 456 | IMPLO_INTF := $(foreach file, $(IMPLO_INTF), \ |
| 457 | $(basename $(file)).cmi $(basename $(file)).cmo) |
| 458 | IMPLO_INTF := $(filter-out %.mli.cmo, $(IMPLO_INTF)) |
| 459 | IMPLO_INTF := $(IMPLO_INTF:%.mli.cmi=%.cmi) |
| 460 | |
| 461 | IMPLX_INTF := $(IMPLO_INTF:.cmo=.cmx) |
| 462 | |
| 463 | INTF := $(filter %.cmi, $(IMPLO_INTF)) |
| 464 | IMPL_CMO := $(filter %.cmo, $(IMPLO_INTF)) |
| 465 | IMPL_CMX := $(IMPL_CMO:.cmo=.cmx) |
| 466 | IMPL_ASM := $(IMPL_CMO:.cmo=.asm) |
| 467 | IMPL_S := $(IMPL_CMO:.cmo=.s) |
| 468 | |
| 469 | OBJ_LINK := $(OBJ_C_IDL) $(OBJ_C_CXX) |
| 470 | OBJ_FILES := $(IMPL_CMO:.cmo=.$(EXT_OBJ)) $(OBJ_LINK) |
| 471 | |
| 472 | EXECS := $(addsuffix $(EXE), \ |
| 473 | $(sort $(TOPRESULT) $(BCRESULT) $(NCRESULT))) |
| 474 | ifdef WIN32 |
| 475 | EXECS += $(BCRESULT).dll $(NCRESULT).dll |
| 476 | endif |
| 477 | |
| 478 | CLIB_BASE := $(RESULT)$(RES_CLIB_SUF) |
| 479 | ifneq ($(strip $(OBJ_LINK)),) |
| 480 | RES_CLIB := lib$(CLIB_BASE).$(EXT_LIB) |
| 481 | endif |
| 482 | |
| 483 | ifdef WIN32 |
| 484 | DLLSONAME := $(CLIB_BASE).dll |
| 485 | else |
| 486 | DLLSONAME := dll$(CLIB_BASE).so |
| 487 | endif |
| 488 | |
| 489 | NONEXECS := $(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 | |
| 496 | ifndef STATIC |
| 497 | NONEXECS += $(DLLSONAME) |
| 498 | endif |
| 499 | |
| 500 | ifndef 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 |
| 508 | endif |
| 509 | |
| 510 | export LIBINSTALL_FILES |
| 511 | |
| 512 | ifdef 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 |
| 515 | endif |
| 516 | |
| 517 | TARGETS := $(EXECS) $(NONEXECS) |
| 518 | |
| 519 | # If there are IDL-files |
| 520 | ifneq ($(strip $(FILTERED_IDL)),) |
| 521 | MAYBE_IDL := -cclib -lcamlidl |
| 522 | endif |
| 523 | |
| 524 | ifdef USE_CAMLP4 |
| 525 | CAMLP4PATH := \ |
| 526 | $(shell $(CAMLP4) -where 2>/dev/null || echo /usr/local/lib/camlp4) |
| 527 | INCFLAGS := -I $(CAMLP4PATH) |
| 528 | CINCFLAGS := -I$(CAMLP4PATH) |
| 529 | endif |
| 530 | |
| 531 | DINCFLAGS := $(INCFLAGS) $(SOURCE_DIRS:%=-I %) $(OCAML_DEFAULT_DIRS:%=-I %) |
| 532 | INCFLAGS := $(DINCFLAGS) $(INCDIRS:%=-I %) |
| 533 | CINCFLAGS += $(SOURCE_DIRS:%=-I%) $(INCDIRS:%=-I%) $(OCAML_DEFAULT_DIRS:%=-I%) |
| 534 | |
| 535 | ifndef 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 |
| 542 | endif |
| 543 | |
| 544 | ifndef PROFILING |
| 545 | INTF_OCAMLC := $(OCAMLC) |
| 546 | else |
| 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 |
| 557 | endif |
| 558 | |
| 559 | ifndef 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 |
| 567 | else |
| 568 | COMMON_LDFLAGS := -ccopt "/link -NODEFAULTLIB:LIBC $(LDFLAGS:%=%) $(SOURCE_DIRS:%=-LIBPATH:%) \ |
| 569 | $(LIBDIRS:%=-LIBPATH:%) $(EXTLIBDIRS:%=-LIBPATH:%) \ |
| 570 | $(OCAML_DEFAULT_DIRS:%=-LIBPATH:%) " |
| 571 | endif |
| 572 | |
| 573 | CLIBS_OPTS := $(CLIBS:%=-cclib -l%) $(CFRAMEWORKS:%=-cclib '-framework %') |
| 574 | ifdef MSVC |
| 575 | ifndef STATIC |
| 576 | # MSVC libraries do not have 'lib' prefix |
| 577 | CLIBS_OPTS := $(CLIBS:%=-cclib %.lib) |
| 578 | endif |
| 579 | endif |
| 580 | |
| 581 | ifneq ($(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 |
| 587 | else |
| 588 | OBJS_LIBS := $(CLIBS_OPTS) $(MAYBE_IDL) |
| 589 | endif |
| 590 | |
| 591 | # If we have to make byte-code |
| 592 | ifndef 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 |
| 648 | else |
| 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 |
| 687 | endif |
| 688 | |
| 689 | export MAKE_DEPS |
| 690 | |
| 691 | ifdef ANNOTATE |
| 692 | ANNOT_FLAG := -dtypes |
| 693 | else |
| 694 | endif |
| 695 | |
| 696 | ALL_OCAMLCFLAGS := $(THREAD_FLAG) $(ANNOT_FLAG) $(OCAMLFLAGS) \ |
| 697 | $(INCFLAGS) $(SPECIAL_OCAMLFLAGS) |
| 698 | |
| 699 | ifdef make_deps |
| 700 | -include $(MAKE_DEPS) |
| 701 | PRE_TARGETS := |
| 702 | endif |
| 703 | |
| 704 | ########################################################################### |
| 705 | # USER RULES |
| 706 | |
| 707 | # Call "OCamlMakefile QUIET=" to get rid of all of the @'s. |
| 708 | QUIET=@ |
| 709 | |
| 710 | # generates byte-code (default) |
| 711 | byte-code: $(PRE_TARGETS) |
| 712 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \ |
| 713 | REAL_RESULT="$(BCRESULT)" make_deps=yes |
| 714 | bc: byte-code |
| 715 | |
| 716 | byte-code-nolink: $(PRE_TARGETS) |
| 717 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \ |
| 718 | REAL_RESULT="$(BCRESULT)" make_deps=yes |
| 719 | bcnl: byte-code-nolink |
| 720 | |
| 721 | top: $(PRE_TARGETS) |
| 722 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(TOPRESULT) \ |
| 723 | REAL_RESULT="$(BCRESULT)" make_deps=yes |
| 724 | |
| 725 | # generates native-code |
| 726 | |
| 727 | native-code: $(PRE_TARGETS) |
| 728 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \ |
| 729 | REAL_RESULT="$(NCRESULT)" \ |
| 730 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 731 | make_deps=yes |
| 732 | nc: native-code |
| 733 | |
| 734 | native-code-nolink: $(PRE_TARGETS) |
| 735 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \ |
| 736 | REAL_RESULT="$(NCRESULT)" \ |
| 737 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 738 | make_deps=yes |
| 739 | ncnl: native-code-nolink |
| 740 | |
| 741 | # generates byte-code libraries |
| 742 | byte-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 |
| 748 | bcl: byte-code-library |
| 749 | |
| 750 | # generates native-code libraries |
| 751 | native-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 |
| 758 | ncl: native-code-library |
| 759 | |
| 760 | ifdef WIN32 |
| 761 | # generates byte-code dll |
| 762 | byte-code-dll: $(PRE_TARGETS) |
| 763 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 764 | $(RES_CLIB) $(BCRESULT).dll \ |
| 765 | REAL_RESULT="$(BCRESULT)" \ |
| 766 | make_deps=yes |
| 767 | bcd: byte-code-dll |
| 768 | |
| 769 | # generates native-code dll |
| 770 | native-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 |
| 776 | ncd: native-code-dll |
| 777 | endif |
| 778 | |
| 779 | # generates byte-code with debugging information |
| 780 | debug-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)" |
| 785 | dc: debug-code |
| 786 | |
| 787 | debug-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)" |
| 792 | dcnl: debug-code-nolink |
| 793 | |
David Reiss | 1dd17f5 | 2008-04-03 20:16:45 +0000 | [diff] [blame] | 794 | # generates byte-code with debugging information (native code) |
| 795 | debug-native-code: $(PRE_TARGETS) |
| 796 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \ |
| 797 | REAL_RESULT="$(NCRESULT)" make_deps=yes \ |
| 798 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 799 | OCAMLFLAGS="-g $(OCAMLFLAGS)" \ |
| 800 | OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)" |
| 801 | dnc: debug-native-code |
| 802 | |
| 803 | debug-native-code-nolink: $(PRE_TARGETS) |
| 804 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) nolink \ |
| 805 | REAL_RESULT="$(NCRESULT)" make_deps=yes \ |
| 806 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 807 | OCAMLFLAGS="-g $(OCAMLFLAGS)" \ |
| 808 | OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)" |
| 809 | dncnl: debug-native-code-nolink |
| 810 | |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 811 | # generates byte-code libraries with debugging information |
| 812 | debug-code-library: $(PRE_TARGETS) |
| 813 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 814 | $(RES_CLIB) $(BCRESULT).cma \ |
| 815 | REAL_RESULT="$(BCRESULT)" make_deps=yes \ |
| 816 | CREATE_LIB=yes \ |
| 817 | OCAMLFLAGS="-g $(OCAMLFLAGS)" \ |
| 818 | OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)" |
| 819 | dcl: debug-code-library |
| 820 | |
David Reiss | 1dd17f5 | 2008-04-03 20:16:45 +0000 | [diff] [blame] | 821 | # generates byte-code libraries with debugging information (native code) |
| 822 | debug-native-code-library: $(PRE_TARGETS) |
| 823 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 824 | $(RES_CLIB) $(NCRESULT).cma \ |
| 825 | REAL_RESULT="$(NCRESULT)" make_deps=yes \ |
| 826 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 827 | CREATE_LIB=yes \ |
| 828 | OCAMLFLAGS="-g $(OCAMLFLAGS)" \ |
| 829 | OCAMLLDFLAGS="-g $(OCAMLLDFLAGS)" |
| 830 | dncl: debug-native-code-library |
| 831 | |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 832 | # generates byte-code for profiling |
| 833 | profiling-byte-code: $(PRE_TARGETS) |
| 834 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT) \ |
| 835 | REAL_RESULT="$(BCRESULT)" PROFILING="y" \ |
| 836 | make_deps=yes |
| 837 | pbc: profiling-byte-code |
| 838 | |
| 839 | # generates native-code |
| 840 | |
| 841 | profiling-native-code: $(PRE_TARGETS) |
| 842 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(NCRESULT) \ |
| 843 | REAL_RESULT="$(NCRESULT)" \ |
| 844 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 845 | PROFILING="y" \ |
| 846 | make_deps=yes |
| 847 | pnc: profiling-native-code |
| 848 | |
| 849 | # generates byte-code libraries |
| 850 | profiling-byte-code-library: $(PRE_TARGETS) |
| 851 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 852 | $(RES_CLIB) $(BCRESULT).cma \ |
| 853 | REAL_RESULT="$(BCRESULT)" PROFILING="y" \ |
| 854 | CREATE_LIB=yes \ |
| 855 | make_deps=yes |
| 856 | pbcl: profiling-byte-code-library |
| 857 | |
| 858 | # generates native-code libraries |
| 859 | profiling-native-code-library: $(PRE_TARGETS) |
| 860 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 861 | $(RES_CLIB) $(NCRESULT).cmxa \ |
| 862 | REAL_RESULT="$(NCRESULT)" PROFILING="y" \ |
| 863 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 864 | CREATE_LIB=yes \ |
| 865 | make_deps=yes |
| 866 | pncl: profiling-native-code-library |
| 867 | |
| 868 | # packs byte-code objects |
| 869 | pack-byte-code: $(PRE_TARGETS) |
| 870 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) $(BCRESULT).cmo \ |
| 871 | REAL_RESULT="$(BCRESULT)" \ |
| 872 | PACK_LIB=yes make_deps=yes |
| 873 | pabc: pack-byte-code |
| 874 | |
| 875 | # packs native-code objects |
| 876 | pack-native-code: $(PRE_TARGETS) |
| 877 | $(QUIET)$(MAKE) -r -f $(OCAMLMAKEFILE) \ |
| 878 | $(NCRESULT).cmx $(NCRESULT).o \ |
| 879 | REAL_RESULT="$(NCRESULT)" \ |
| 880 | REAL_OCAMLC="$(OCAMLOPT)" \ |
| 881 | PACK_LIB=yes make_deps=yes |
| 882 | panc: pack-native-code |
| 883 | |
| 884 | # generates HTML-documentation |
| 885 | htdoc: $(DOC_DIR)/$(RESULT)/html/index.html |
| 886 | |
| 887 | # generates Latex-documentation |
| 888 | ladoc: $(DOC_DIR)/$(RESULT)/latex/doc.tex |
| 889 | |
| 890 | # generates PostScript-documentation |
| 891 | psdoc: $(DOC_DIR)/$(RESULT)/latex/doc.ps |
| 892 | |
| 893 | # generates PDF-documentation |
| 894 | pdfdoc: $(DOC_DIR)/$(RESULT)/latex/doc.pdf |
| 895 | |
| 896 | # generates all supported forms of documentation |
| 897 | doc: htdoc ladoc psdoc pdfdoc |
| 898 | |
| 899 | ########################################################################### |
| 900 | # LOW LEVEL RULES |
| 901 | |
| 902 | $(REAL_RESULT): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) $(RESULTDEPS) |
| 903 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) \ |
| 904 | $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \ |
| 905 | $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \ |
| 906 | $(REAL_IMPL) |
| 907 | |
| 908 | nolink: $(REAL_IMPL_INTF) $(OBJ_LINK) |
| 909 | |
| 910 | ifdef WIN32 |
| 911 | $(REAL_RESULT).dll: $(REAL_IMPL_INTF) $(OBJ_LINK) |
| 912 | $(CAMLIDLDLL) $(CAMLIDLDLLFLAGS) $(OBJ_LINK) $(CLIBS) \ |
| 913 | -o $@ $(REAL_IMPL) |
| 914 | endif |
| 915 | |
| 916 | %$(TOPSUFFIX): $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) |
| 917 | $(REAL_OCAMLFIND) $(OCAMLMKTOP) \ |
| 918 | $(OCAML_FIND_PACKAGES) $(OCAML_FIND_LINKPKG) \ |
| 919 | $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@$(EXE) \ |
| 920 | $(REAL_IMPL) |
| 921 | |
| 922 | .SUFFIXES: .mli .ml .cmi .cmo .cmx .cma .cmxa .$(EXT_OBJ) \ |
| 923 | .mly .di .d .$(EXT_LIB) .idl %.oxridl .c .m .$(EXT_CXX) .h .so \ |
| 924 | .rep .zog .glade |
| 925 | |
| 926 | ifndef STATIC |
| 927 | ifdef MINGW |
| 928 | $(DLLSONAME): $(OBJ_LINK) |
| 929 | $(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \ |
| 930 | -Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \ |
| 931 | $(OCAMLLIBPATH)/ocamlrun.a \ |
| 932 | -Wl,--export-all-symbols \ |
| 933 | -Wl,--no-whole-archive |
| 934 | else |
| 935 | ifdef MSVC |
| 936 | $(DLLSONAME): $(OBJ_LINK) |
| 937 | link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \ |
| 938 | $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \ |
| 939 | $(OCAMLLIBPATH)/ocamlrun.lib |
| 940 | |
| 941 | else |
| 942 | $(DLLSONAME): $(OBJ_LINK) |
| 943 | $(OCAMLMKLIB) $(INCFLAGS) $(CLIBFLAGS) \ |
| 944 | -o $(CLIB_BASE) $(OBJ_LINK) $(CLIBS:%=-l%) $(CFRAMEWORKS:%=-framework %) \ |
| 945 | $(OCAMLMKLIB_FLAGS) |
| 946 | endif |
| 947 | endif |
| 948 | endif |
| 949 | |
| 950 | ifndef LIB_PACK_NAME |
| 951 | $(RESULT).cma: $(REAL_IMPL_INTF) $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS) |
| 952 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL) |
| 953 | |
| 954 | $(RESULT).cmxa $(RESULT).$(EXT_LIB): $(REAL_IMPL_INTF) $(EXTRADEPS) $(RESULTDEPS) |
| 955 | $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(REAL_IMPL) |
| 956 | else |
| 957 | ifdef BYTE_OCAML |
| 958 | $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo: $(REAL_IMPL_INTF) |
| 959 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack -o $(LIB_PACK_NAME).cmo $(OCAMLLDFLAGS) $(REAL_IMPL) |
| 960 | else |
| 961 | $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx: $(REAL_IMPL_INTF) |
David Reiss | 1dd17f5 | 2008-04-03 20:16:45 +0000 | [diff] [blame] | 962 | $(REAL_OCAMLFIND) $(OCAMLOPT) -pack -o $(LIB_PACK_NAME).cmx $(OCAMLLDFLAGS) $(REAL_IMPL) |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 963 | endif |
| 964 | |
| 965 | $(RESULT).cma: $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmo $(MAKEDLL) $(EXTRADEPS) $(RESULTDEPS) |
| 966 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) -a $(ALL_LDFLAGS) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmo |
| 967 | |
| 968 | $(RESULT).cmxa $(RESULT).$(EXT_LIB): $(LIB_PACK_NAME).cmi $(LIB_PACK_NAME).cmx $(EXTRADEPS) $(RESULTDEPS) |
David Reiss | 1dd17f5 | 2008-04-03 20:16:45 +0000 | [diff] [blame] | 969 | $(REAL_OCAMLFIND) $(OCAMLOPT) -a $(filter-out -custom, $(ALL_LDFLAGS)) $(OBJS_LIBS) -o $@ $(LIB_PACK_NAME).cmx |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 970 | endif |
| 971 | |
| 972 | $(RES_CLIB): $(OBJ_LINK) |
| 973 | ifndef MSVC |
| 974 | ifneq ($(strip $(OBJ_LINK)),) |
| 975 | $(AR) rcs $@ $(OBJ_LINK) |
| 976 | endif |
| 977 | else |
| 978 | ifneq ($(strip $(OBJ_LINK)),) |
| 979 | lib -nologo -debugtype:cv -out:$(RES_CLIB) $(OBJ_LINK) |
| 980 | endif |
| 981 | endif |
| 982 | |
| 983 | .mli.cmi: $(EXTRADEPS) |
| 984 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \ |
| 985 | if [ -z "$$pp" ]; then \ |
| 986 | $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 987 | -c $(THREAD_FLAG) $(ANNOT_FLAG) \ |
| 988 | $(OCAMLFLAGS) $(INCFLAGS) $<; \ |
| 989 | $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 990 | -c $(THREAD_FLAG) $(ANNOT_FLAG) \ |
| 991 | $(OCAMLFLAGS) $(INCFLAGS) $<; \ |
| 992 | else \ |
| 993 | $(ECHO) $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 994 | -c -pp \"$$pp $(PPFLAGS)\" $(THREAD_FLAG) $(ANNOT_FLAG) \ |
| 995 | $(OCAMLFLAGS) $(INCFLAGS) $<; \ |
| 996 | $(REAL_OCAMLFIND) $(INTF_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 997 | -c -pp "$$pp $(PPFLAGS)" $(THREAD_FLAG) $(ANNOT_FLAG) \ |
| 998 | $(OCAMLFLAGS) $(INCFLAGS) $<; \ |
| 999 | fi |
| 1000 | |
| 1001 | .ml.cmi .ml.$(EXT_OBJ) .ml.cmx .ml.cmo: $(EXTRADEPS) |
| 1002 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \ |
| 1003 | if [ -z "$$pp" ]; then \ |
| 1004 | $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 1005 | -c $(ALL_OCAMLCFLAGS) $<; \ |
| 1006 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 1007 | -c $(ALL_OCAMLCFLAGS) $<; \ |
| 1008 | else \ |
| 1009 | $(ECHO) $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 1010 | -c -pp \"$$pp $(PPFLAGS)\" $(ALL_OCAMLCFLAGS) $<; \ |
| 1011 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) $(OCAML_FIND_PACKAGES) \ |
| 1012 | -c -pp "$$pp $(PPFLAGS)" $(ALL_OCAMLCFLAGS) $<; \ |
| 1013 | fi |
| 1014 | |
| 1015 | ifdef PACK_LIB |
| 1016 | $(REAL_RESULT).cmo $(REAL_RESULT).cmx $(REAL_RESULT).o: $(REAL_IMPL_INTF) $(OBJ_LINK) $(EXTRADEPS) |
| 1017 | $(REAL_OCAMLFIND) $(REAL_OCAMLC) -pack $(ALL_LDFLAGS) \ |
| 1018 | $(OBJS_LIBS) -o $@ $(REAL_IMPL) |
| 1019 | endif |
| 1020 | |
| 1021 | .PRECIOUS: %.ml |
| 1022 | %.ml: %.mll |
| 1023 | $(OCAMLLEX) $(LFLAGS) $< |
| 1024 | |
| 1025 | .PRECIOUS: %.ml %.mli |
| 1026 | %.ml %.mli: %.mly |
| 1027 | $(OCAMLYACC) $(YFLAGS) $< |
| 1028 | $(QUIET)pp=`sed -n -e 's/.*(\*pp \([^*]*\) \*).*/\1/p;q' $<`; \ |
| 1029 | if [ ! -z "$$pp" ]; then \ |
| 1030 | mv $*.ml $*.ml.temporary; \ |
| 1031 | echo "(*pp $$pp $(PPFLAGS)*)" > $*.ml; \ |
| 1032 | cat $*.ml.temporary >> $*.ml; \ |
| 1033 | rm $*.ml.temporary; \ |
| 1034 | mv $*.mli $*.mli.temporary; \ |
| 1035 | echo "(*pp $$pp $(PPFLAGS)*)" > $*.mli; \ |
| 1036 | cat $*.mli.temporary >> $*.mli; \ |
| 1037 | rm $*.mli.temporary; \ |
| 1038 | fi |
| 1039 | |
| 1040 | |
| 1041 | .PRECIOUS: %.ml |
| 1042 | %.ml: %.rep |
| 1043 | $(CAMELEON_REPORT) $(CAMELEON_REPORT_FLAGS) -gen $< |
| 1044 | |
| 1045 | .PRECIOUS: %.ml |
| 1046 | %.ml: %.zog |
| 1047 | $(CAMELEON_ZOGGY) $(CAMELEON_ZOGGY_FLAGS) -impl $< > $@ |
| 1048 | |
| 1049 | .PRECIOUS: %.ml |
| 1050 | %.ml: %.glade |
| 1051 | $(OCAML_GLADECC) $(OCAML_GLADECC_FLAGS) $< > $@ |
| 1052 | |
| 1053 | .PRECIOUS: %.ml %.mli |
| 1054 | %.ml %.mli: %.oxridl |
| 1055 | $(OXRIDL) $< |
| 1056 | |
| 1057 | .PRECIOUS: %.ml %.mli %_stubs.c %.h |
| 1058 | %.ml %.mli %_stubs.c %.h: %.idl |
| 1059 | $(CAMLIDL) $(MAYBE_IDL_HEADER) $(IDLFLAGS) \ |
| 1060 | $(CAMLIDLFLAGS) $< |
| 1061 | $(QUIET)if [ $(NOIDLHEADER) ]; then touch $*.h; fi |
| 1062 | |
| 1063 | .c.$(EXT_OBJ): |
| 1064 | $(OCAMLC) -c -cc "$(CC)" -ccopt "$(CFLAGS) \ |
| 1065 | $(CPPFLAGS) $(CPPFLAGS_WIN32) \ |
| 1066 | $(CFLAGS_WIN32) $(CINCFLAGS) $(CFLAG_O)$@ " $< |
| 1067 | |
| 1068 | .m.$(EXT_OBJ): |
| 1069 | $(CC) -c $(CFLAGS) $(CINCFLAGS) $(CPPFLAGS) \ |
| 1070 | -I'$(OCAMLLIBPATH)' \ |
| 1071 | $< $(CFLAG_O)$@ |
| 1072 | |
| 1073 | .$(EXT_CXX).$(EXT_OBJ): |
| 1074 | $(CXX) -c $(CXXFLAGS) $(CINCFLAGS) $(CPPFLAGS) \ |
| 1075 | -I'$(OCAMLLIBPATH)' \ |
| 1076 | $< $(CFLAG_O)$@ |
| 1077 | |
| 1078 | $(MLDEPDIR)/%.d: %.ml |
| 1079 | $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi |
| 1080 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \ |
| 1081 | if [ -z "$$pp" ]; then \ |
| 1082 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \ |
| 1083 | $(DINCFLAGS) $< \> $@; \ |
| 1084 | $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \ |
| 1085 | $(DINCFLAGS) $< > $@; \ |
| 1086 | else \ |
| 1087 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \ |
| 1088 | -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \ |
| 1089 | $(REAL_OCAMLFIND) $(OCAMLDEP) $(OCAML_DEP_PACKAGES) \ |
| 1090 | -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \ |
| 1091 | fi |
| 1092 | |
| 1093 | $(BCDIDIR)/%.di $(NCDIDIR)/%.di: %.mli |
| 1094 | $(QUIET)if [ ! -d $(@D) ]; then mkdir -p $(@D); fi |
| 1095 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $<`; \ |
| 1096 | if [ -z "$$pp" ]; then \ |
| 1097 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< \> $@; \ |
| 1098 | $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) $(DINCFLAGS) $< > $@; \ |
| 1099 | else \ |
| 1100 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \ |
| 1101 | -pp \"$$pp $(PPFLAGS)\" $(DINCFLAGS) $< \> $@; \ |
| 1102 | $(REAL_OCAMLFIND) $(OCAMLDEP) $(DEPFLAGS) \ |
| 1103 | -pp "$$pp $(PPFLAGS)" $(DINCFLAGS) $< > $@; \ |
| 1104 | fi |
| 1105 | |
| 1106 | $(DOC_DIR)/$(RESULT)/html: |
| 1107 | mkdir -p $@ |
| 1108 | |
| 1109 | $(DOC_DIR)/$(RESULT)/html/index.html: $(DOC_DIR)/$(RESULT)/html $(DOC_FILES) |
| 1110 | rm -rf $</* |
| 1111 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $(FIRST_DOC_FILE)`; \ |
| 1112 | if [ -z "$$pp" ]; then \ |
| 1113 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -html -d $< $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \ |
| 1114 | $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -html -d $< $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES); \ |
| 1115 | else \ |
| 1116 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp \"$$pp $(PPFLAGS)\" -html -d $< $(OCAMLDOCFLAGS) \ |
| 1117 | $(INCFLAGS) $(DOC_FILES); \ |
| 1118 | $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp "$$pp $(PPFLAGS)" -html -d $< $(OCAMLDOCFLAGS) \ |
| 1119 | $(INCFLAGS) $(DOC_FILES); \ |
| 1120 | fi |
| 1121 | |
| 1122 | $(DOC_DIR)/$(RESULT)/latex: |
| 1123 | mkdir -p $@ |
| 1124 | |
| 1125 | $(DOC_DIR)/$(RESULT)/latex/doc.tex: $(DOC_DIR)/$(RESULT)/latex $(DOC_FILES) |
| 1126 | rm -rf $</* |
| 1127 | $(QUIET)pp=`sed -n -e '/^#/d' -e 's/(\*pp \([^*]*\) \*)/\1/p;q' $(FIRST_DOC_FILE)`; \ |
| 1128 | if [ -z "$$pp" ]; then \ |
| 1129 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) \ |
| 1130 | $(DOC_FILES) -o $@; \ |
| 1131 | $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -latex $(OCAMLDOCFLAGS) $(INCFLAGS) $(DOC_FILES) \ |
| 1132 | -o $@; \ |
| 1133 | else \ |
| 1134 | $(ECHO) $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp \"$$pp $(PPFLAGS)\" -latex $(OCAMLDOCFLAGS) \ |
| 1135 | $(INCFLAGS) $(DOC_FILES) -o $@; \ |
| 1136 | $(REAL_OCAMLFIND) $(OCAMLDOC) $(OCAML_FIND_PACKAGES) -pp "$$pp $(PPFLAGS)" -latex $(OCAMLDOCFLAGS) \ |
| 1137 | $(INCFLAGS) $(DOC_FILES) -o $@; \ |
| 1138 | fi |
| 1139 | |
| 1140 | $(DOC_DIR)/$(RESULT)/latex/doc.ps: $(DOC_DIR)/$(RESULT)/latex/doc.tex |
| 1141 | cd $(DOC_DIR)/$(RESULT)/latex && \ |
| 1142 | $(LATEX) doc.tex && \ |
| 1143 | $(LATEX) doc.tex && \ |
| 1144 | $(DVIPS) $(DVIPSFLAGS) doc.dvi -o $(@F) |
| 1145 | |
| 1146 | $(DOC_DIR)/$(RESULT)/latex/doc.pdf: $(DOC_DIR)/$(RESULT)/latex/doc.ps |
| 1147 | cd $(DOC_DIR)/$(RESULT)/latex && $(PS2PDF) $(<F) |
| 1148 | |
| 1149 | define make_subproj |
| 1150 | .PHONY: |
| 1151 | subproj_$(1): |
| 1152 | $$(eval $$(call PROJ_$(1))) |
| 1153 | $(QUIET)if [ "$(SUBTARGET)" != "all" ]; then \ |
| 1154 | $(MAKE) -f $(OCAMLMAKEFILE) $(SUBTARGET); \ |
| 1155 | fi |
| 1156 | endef |
| 1157 | |
| 1158 | $(foreach subproj,$(SUBPROJS),$(eval $(call make_subproj,$(subproj)))) |
| 1159 | |
| 1160 | .PHONY: |
| 1161 | subprojs: $(SUBPROJS:%=subproj_%) |
| 1162 | |
| 1163 | ########################################################################### |
| 1164 | # (UN)INSTALL RULES FOR LIBRARIES |
| 1165 | |
| 1166 | .PHONY: libinstall |
| 1167 | libinstall: all |
| 1168 | $(QUIET)printf "\nInstalling library with ocamlfind\n" |
| 1169 | $(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META $(LIBINSTALL_FILES) |
| 1170 | $(QUIET)printf "\nInstallation successful.\n" |
| 1171 | |
David Reiss | 1dd17f5 | 2008-04-03 20:16:45 +0000 | [diff] [blame] | 1172 | .PHONY: libinstall-byte-code |
| 1173 | libinstall-byte-code: all |
| 1174 | $(QUIET)printf "\nInstalling byte-code library with ocamlfind\n" |
| 1175 | $(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META \ |
| 1176 | $(filter-out $(RESULT).$(EXT_LIB) $(RESULT).cmxa, $(LIBINSTALL_FILES)) |
| 1177 | $(QUIET)printf "\nInstallation successful.\n" |
| 1178 | |
| 1179 | .PHONY: libinstall-native-code |
| 1180 | libinstall-native-code: all |
| 1181 | $(QUIET)printf "\nInstalling native-code library with ocamlfind\n" |
| 1182 | $(OCAMLFIND) install $(OCAMLFIND_INSTFLAGS) $(RESULT) META \ |
| 1183 | $(filter-out $(DLLSONAME) $(RESULT).cma, $(LIBINSTALL_FILES)) |
| 1184 | $(QUIET)printf "\nInstallation successful.\n" |
| 1185 | |
iproctor | 9a41a0c | 2007-07-16 21:59:24 +0000 | [diff] [blame] | 1186 | .PHONY: libuninstall |
| 1187 | libuninstall: |
| 1188 | $(QUIET)printf "\nUninstalling library with ocamlfind\n" |
| 1189 | $(OCAMLFIND) remove $(OCAMLFIND_INSTFLAGS) $(RESULT) |
| 1190 | $(QUIET)printf "\nUninstallation successful.\n" |
| 1191 | |
| 1192 | .PHONY: rawinstall |
| 1193 | rawinstall: all |
| 1194 | $(QUIET)printf "\nInstalling library to: $(OCAML_LIB_INSTALL)\n" |
| 1195 | -install -d $(OCAML_LIB_INSTALL) |
| 1196 | for i in $(LIBINSTALL_FILES); do \ |
| 1197 | if [ -f $$i ]; then \ |
| 1198 | install -c -m 0644 $$i $(OCAML_LIB_INSTALL); \ |
| 1199 | fi; \ |
| 1200 | done |
| 1201 | $(QUIET)printf "\nInstallation successful.\n" |
| 1202 | |
| 1203 | .PHONY: rawuninstall |
| 1204 | rawuninstall: |
| 1205 | $(QUIET)printf "\nUninstalling library from: $(OCAML_LIB_INSTALL)\n" |
| 1206 | cd $(OCAML_LIB_INSTALL) && rm $(notdir $(LIBINSTALL_FILES)) |
| 1207 | $(QUIET)printf "\nUninstallation successful.\n" |
| 1208 | |
| 1209 | ########################################################################### |
| 1210 | # MAINTENANCE RULES |
| 1211 | |
| 1212 | .PHONY: clean |
| 1213 | clean:: |
| 1214 | rm -f $(TARGETS) $(TRASH) |
| 1215 | rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR) |
| 1216 | |
| 1217 | .PHONY: cleanup |
| 1218 | cleanup:: |
| 1219 | rm -f $(NONEXECS) $(TRASH) |
| 1220 | rm -rf $(BCDIDIR) $(NCDIDIR) $(MLDEPDIR) |
| 1221 | |
| 1222 | .PHONY: clean-doc |
| 1223 | clean-doc:: |
| 1224 | rm -rf $(DOC_DIR)/$(RESULT) |
| 1225 | |
| 1226 | .PHONY: clean-all |
| 1227 | clean-all:: clean clean-doc |
| 1228 | |
| 1229 | .PHONY: nobackup |
| 1230 | nobackup: |
| 1231 | rm -f *.bak *~ *.dup |