1### ocaml.lib.mk -- Building OCaml libraries 2 3# Author: Michael Grünewald 4# Date: Tue Apr 5 12:31:04 CEST 2005 5 6# BSD Owl Scripts (https://bitbucket.org/michipili/bsdowl) 7# This file is part of BSD Owl Scripts 8# 9# Copyright © 2005–2014 Michael Grünewald 10# 11# This file must be used under the terms of the CeCILL-B. 12# This source file is licensed as described in the file COPYING, which 13# you should have received as part of this distribution. The terms 14# are also available at 15# http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt 16 17 18### SYNOPSIS 19 20# LIBRARY= newton 21# SRCS+= newton.ml 22# 23# .include "ocaml.lib.mk" 24 25 26### DESCRIPTION 27 28# Build an ocaml library, compiling each of the module listed in SRCS 29# and creating a library named as LIBRARY. 30# 31# It supports building bytecode and native libraries, ocamlfind, 32# lexers and parsers generated by ocamllex and ocamlyacc and 33# debugging, profiling as well. 34 35# Variables: 36# 37# 38# LIBRARY 39# The name of the library 40# 41# 42# SRCS 43# Files to put in the library 44# 45# It can list implementation files, lexer and parser definitions. 46# 47# 48# LIBOWN, LIBGRP, LIBMODE, LIBDIR, LIBNAME 49# Paramters of the library installation 50# 51# See `bps.own.mk` for a closer description of these variables. If 52# the PACKAGE library is set, then LIBDIR will appropriately be 53# initialised to ${PREFIX}/lib/ocaml/site-lib${PACKAGEDIR} 54# instead of {PREFIX}/lib/ocaml. 55 56 57### IMPLEMENTATION 58 59.include "bps.init.mk" 60.include "ocaml.init.mk" 61 62# We do not support the LIB short name, because it clashes with a file 63# installation group. 64# 65# .if defined(LIB)&&!empty(LIB) 66# LIBRARY?= ${LIB} 67# .endif 68 69.if !defined(LIBRARY)||empty(LIBRARY) 70.error The ocaml.lib.mk expects you to set the LIBRARY variable to a sensible value. 71.endif 72 73_OCAML_SRCS?= 74_OCAML_CMA?= 75_OCAML_CMXA?= 76_OCAML_A?= 77 78_OCAML_LIB:=${LIBRARY} 79 80.for lib in ${_OCAML_LIB} 81SRCS.${lib:T}?=${SRCS} 82.if defined(_OCAML_COMPILE_NATIVE) 83SRCS.${lib:T}.cmxa?=${SRCS.${lib:T}} 84_OCAML_SRCS+=SRCS.${lib}.cmxa 85_OCAML_CMXA+=${lib:T}.cmxa 86_OCAML_A+=${lib:T}.a 87.endif 88.if defined(_OCAML_COMPILE_BYTE) 89SRCS.${lib:T}.cma?=${SRCS.${lib:T}} 90_OCAML_SRCS+=SRCS.${lib}.cma 91_OCAML_CMA+=${lib:T}.cma 92.endif 93.endfor 94 95 96.include "ocaml.main.mk" 97 98 99.for lib in ${_OCAML_LIB} 100.if defined(_OCAML_COMPILE_NATIVE) 101LIB+= ${lib}.cmxa ${lib}.a 102_OCAML_SRCS.${lib}.cmxa=${.ALLSRC} 103${lib}.cmxa: ${SRCS.${lib}.cmxa:C/\.ml[ly]/.ml/:M*.ml:.ml=.cmx} 104.endif 105.if defined(_OCAML_COMPILE_BYTE) 106LIB+= ${lib}.cma 107_OCAML_SRCS.${lib:T}.cma=${.ALLSRC} 108${lib}.cma: ${SRCS.${lib:T}.cma:C/\.ml[ly]/.ml/:M*.ml:.ml=.cmo} 109.endif 110.if !empty(SRCS.${lib:T}:C/\.ml[ly]/.ml/:M*.ml) 111LIB+= ${SRCS.${lib:T}:C/\.ml[ly]/.ml/:M*.ml:.ml=.cmi} 112.endif 113.endfor 114 115.include "bps.clean.mk" 116.include "bps.files.mk" 117.include "bps.usertarget.mk" 118 119### End of file `ocaml.lib.mk' 120