1### ocaml.source.mk -- Scanning lists of source files 2 3# Author: Michael Grünewald 4# Date: Wed Aug 1 11:47:44 CEST 2007 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# _OCAML_SRCS=SRCS.prog1 SRCS.prog2 SRCS.lib1 21# 22# SRCS.prog1= src11.ml src12.ml sec13.mli 23# SRCS.prog2= src21.ml src22.ml 24# SRCS.lib1= mod1.ml lexer.mll parser.mly 25# 26# .include "ocaml.source.mk" 27 28### DESCRIPTION 29 30# We scan the lists of sources files enumerated in _OCAML_SRCS and 31# assign their content to specialised lists (such as _OCAML_ML and 32# _OCAML_MLI are) accordinf to their type. 33# 34# Each time that we meet an implementation file, the correponding 35# interface file is appended to _OCAML_MLI. 36# 37# This module is intended to be included by other modules rather than 38# to serve as is to the end user. (See ocaml.manual.mk for a 39# module producing HTML documentation.) 40 41.if !target(__<ocaml.source.mk>__) 42__<ocaml.source.mk>__: 43 44# _OCAML_SOURCE = _OCAML_MLY 45# _OCAML_SOURCE+= _OCAML_MLL 46# _OCAML_SOURCE+= _OCAML_MLI 47# _OCAML_SOURCE+= _OCAML_ML 48# _OCAML_SOURCE+= _OCAML_C 49# _OCAML_SOURCE+= _OCAML_H 50 51# REMARK(michipili) About the M modificator 52# 53# When we use the match `M` modificator in variable expansion, the 54# pattern is *everything* that follows it. For instance 55# 56# ${VAR:M*.${SUFFIX}} 57# 58# is analysed as 59# 60# ${<variable>}} 61# <variable>=VAR:M*.${SUFFIX 62# 63# and expands to a `}`. But if we write things like 64# 65# .for suffix in ${SUFFIX} 66# ${VAR:M*.${suffix}} 67# .endfor 68# 69# then the expansion of ${suffix} precedes the expansion of the 70# surrounding match modificator and we obtan the expected result. 71 72.for src in ${_OCAML_SRCS} 73.if defined(${src}) 74.if !empty(${src}:M*.mli) 75.for if in ${${src}:M*.mli} 76.if empty(_OCAML_MLI:M${if}) 77_OCAML_MLI+=${if} 78.endif 79.endfor 80.endif 81.if !empty(${src}:M*.ml) 82.for unit in ${${src}:M*.ml} 83.if empty(_OCAML_ML)||empty(_OCAML_ML:M${unit}) 84_OCAML_ML+=${unit} 85.endif 86.endfor 87.endif 88.endif 89.endfor 90 91 92.if defined(_OCAML_ML)&&!empty(_OCAML_ML) 93.for if in ${_OCAML_ML:.ml=.mli} 94.if exists(${if})&&(empty(_OCAML_MLI)||empty(_OCAML_MLI:M${if})) 95_OCAML_MLI+= ${if} 96.endif 97.endfor 98.endif 99 100.endif # !target(__<ocaml.source.mk>__) 101 102### End of file `ocaml.source.mk' 103