Merge tag 'v3.0.0-20140213' into debian
v3.0.0-20140213
Alaaf!
Michael Grünewald
9 years ago
31 | 31 | SHARE+= bps.subdir.mk |
32 | 32 | SHARE+= bps.files.mk |
33 | 33 | SHARE+= bps.autoconf.mk |
34 | SHARE+= bps.replace.mk | |
34 | 35 | SHARE+= bps.project.mk |
35 | 36 | SHARE+= bps.m4.mk |
36 | 37 | SHARE+= bps.noweb.mk |
81 | 81 | .if ${_BPS_SWITCH_CREDENTIALS_STRATEGY} == su |
82 | 82 | @(cd ${.CURDIR} && ${SU} root -c '${MAKE} ${target}') |
83 | 83 | .elif ${_BPS_SWITCH_CREDENTIALS_STRATEGY} == sudo |
84 | @(cd ${.CURDIR} && ${SUDO} ${MAKE} UID=0 ${target}>) | |
84 | @(cd ${.CURDIR} && ${SUDO} ${MAKE} UID=0 ${target}) | |
85 | 85 | .else |
86 | 86 | @(cd ${.CURDIR} && ${MAKE} UID=0 ${target}) |
87 | 87 | .endif |
181 | 181 | # Macro for copying entire directory tree with correct permissions |
182 | 182 | .if ${UID} == 0 |
183 | 183 | COPYTREE_${group}=\ |
184 | ${SH} -c '(${FIND} $$1 -depth $$3 | ${CPIO} -dumpl $$2 >/dev/null 2>&1) &&\ | |
184 | ${SH} -c '(${FIND} $$1 -depth $$3 | ${CPIO} -dump $$2 >/dev/null 2>&1) &&\ | |
185 | 185 | ${CHOWN} -Rh ${${group}OWN}:${${group}GRP} $$2 &&\ |
186 | 186 | ${FIND} $$1 -depth $$3 -type d -exec ${CHMOD} 755 $$2/{} \; &&\ |
187 | 187 | ${FIND} $$1 -depth $$3 -type f -exec ${CHMOD} ${${group}MODE} $$2/{} \;'\ |
188 | 188 | COPYTREE_${group} |
189 | 189 | .else |
190 | 190 | COPYTREE_${group}=\ |
191 | ${SH} -c '(${FIND} $$1 -depth $$3 | ${CPIO} -dumpl $$2 >/dev/null 2>&1) &&\ | |
191 | ${SH} -c '(${FIND} $$1 -depth $$3 | ${CPIO} -dump $$2 >/dev/null 2>&1) &&\ | |
192 | 192 | ${FIND} $$1 -depth $$3 -type d -exec ${CHMOD} 755 $$2/{} \; &&\ |
193 | 193 | ${FIND} $$1 -depth $$3 -type f -exec ${CHMOD} ${${group}MODE} $$2/{} \;'\ |
194 | 194 | COPYTREE_${group} |
190 | 190 | # .CURDIR. |
191 | 191 | # |
192 | 192 | # |
193 | # _MAKE_USERTARGET [configure obj depend build doc all | |
193 | # _MAKE_USERTARGET [obj configure depend build doc all | |
194 | 194 | # install test clean distclean realclean benchmark] |
195 | 195 | # The list of targets that are defined by every module. |
196 | 196 | # |
197 | 197 | # |
198 | # _MAKE_ALLSUBTARGET [configure depend build doc] | |
198 | # _MAKE_ALLSUBTARGET [configure depend build doc test] | |
199 | 199 | # The list of subtargets of the all target. |
200 | 200 | |
201 | 201 | |
336 | 336 | # Set _MAKE_USERTARGET and _MAKE_ALLSUBTARGET |
337 | 337 | # |
338 | 338 | |
339 | _MAKE_USERTARGET?= configure obj depend build doc all install\ | |
339 | _MAKE_USERTARGET?= obj configure depend build doc all install\ | |
340 | 340 | test clean distclean realclean benchmark |
341 | 341 | |
342 | 342 | .if defined(MAKEOBJDIR)||defined(MAKEOBJDIRPREFIX) |
343 | _MAKE_ALLSUBTARGET?= configure obj depend build doc | |
343 | _MAKE_ALLSUBTARGET?= obj configure depend build doc test | |
344 | 344 | .else |
345 | _MAKE_ALLSUBTARGET?= configure depend build doc | |
345 | _MAKE_ALLSUBTARGET?= configure depend build doc test | |
346 | 346 | .endif |
347 | 347 | |
348 | 348 | # |
359 | 359 | .include "bps.own.mk" |
360 | 360 | .include "bps.objdir.mk" |
361 | 361 | .include "bps.autoconf.mk" |
362 | .include "bps.replace.mk" | |
362 | 363 | .include "bps.credentials.mk" |
363 | 364 | .include "bps.noweb.mk" |
364 | 365 | .include "bps.test-expected.mk" |
343 | 343 | ${_NOTANGLE_TOOL.${file:T}} -R${.TARGET} ${.ALLSRC} | cpif ${.TARGET} |
344 | 344 | .endfor |
345 | 345 | |
346 | .if defined(NOTANGLE) && !empty(NOTANGLE) | |
346 | 347 | do-clean-notangle: |
347 | 348 | ${RM} -f ${NOTANGLE} |
349 | .else | |
350 | do-clean-notangle: | |
351 | ${NOP} | |
352 | .endif | |
348 | 353 | |
349 | 354 | do-${NOWEB_CLEAN}: do-clean-notangle |
350 | 355 | |
493 | 498 | .endfor |
494 | 499 | .endfor |
495 | 500 | |
501 | .if defined(_NOWEAVE_OBJS) && !empty(_NOWEAVE_OBJS) | |
496 | 502 | do-clean-noweave: |
497 | 503 | ${RM} -f ${_NOWEAVE_OBJS} |
504 | .else | |
505 | do-clean-noweave: | |
506 | ${NOP} | |
507 | .endif | |
498 | 508 | |
499 | 509 | do-${NOWEB_CLEAN}: do-clean-noweave |
500 | 510 |
357 | 357 | SUBSHELLDIR?= ${.CURDIR} |
358 | 358 | subshell: .PHONY |
359 | 359 | ${INFO} "Entering developper's subshell" |
360 | @(cd ${SUBSHELLDIR} && ${ENVTOOL} ${PROJECTENV} ${SHELL}) | |
360 | @(cd ${.CURDIR} && cd ${SUBSHELLDIR} && ${ENVTOOL} ${PROJECTENV} ${SHELL}) | |
361 | 361 | ${INFO} "Exiting developper's subshell" |
362 | 362 | |
363 | 363 | # Remove the global product file before generating dependencies |
0 | ### bps.replace.mk -- Replace configuration variables | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sat Jan 3 13:08:29 CET 2015 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2015 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | ||
17 | ### SYNOPSIS | |
18 | ||
19 | # REPLACESUBST= ${STDSUBST} | |
20 | # REPLACESUBST+= VARIABLE1 | |
21 | # REPLACESUBST+= VARIABLE2 | |
22 | # | |
23 | # REPLACEFILE+= configuration_values.in | |
24 | ||
25 | ||
26 | ### DESCRIPTION | |
27 | ||
28 | # Substitute placeholders of the form @variable@ with the expansion of | |
29 | # variable. This mechanism can be used to replace configuration | |
30 | # variables, typically listed in the Makefile.config file of the | |
31 | # project. | |
32 | ||
33 | # Variables: | |
34 | # | |
35 | # REPLACESUBST [not set] | |
36 | # The list of variable to replace | |
37 | # | |
38 | # | |
39 | # STDREPLACESUBST [a long list of typical autoconf variables] | |
40 | # A pre-made list that can be added to REPLACESUBST | |
41 | # | |
42 | # | |
43 | # REPLACEFILTER [set by initialisation strategy] | |
44 | # A filter performing the replacement | |
45 | # | |
46 | # If REPLACESUBST is not set or empty, then REPLACEFILTER remains | |
47 | # undefined. | |
48 | # | |
49 | # | |
50 | # REPLACEFILE [not set] | |
51 | # The list of file where substitutions are to be performed | |
52 | # | |
53 | # Each file in the list is subject to replacement. These files must | |
54 | # have a name ending in .in, which is removed in the replaced file. | |
55 | ||
56 | ||
57 | .if !target(__<bps.init.mk>__) | |
58 | .error bps.replace.mk cannot be included directly. | |
59 | .endif | |
60 | ||
61 | .if !target(__<bps.replace.mk>__) | |
62 | __<bps.replace.mk>__: | |
63 | ||
64 | STDREPLACESUBST= PACKAGE | |
65 | STDREPLACESUBST+= VERSION | |
66 | STDREPLACESUBST+= prefix | |
67 | STDREPLACESUBST+= exec_prefix | |
68 | STDREPLACESUBST+= bindir | |
69 | STDREPLACESUBST+= sbindir | |
70 | STDREPLACESUBST+= libexecdir | |
71 | STDREPLACESUBST+= datarootdir | |
72 | STDREPLACESUBST+= datadir | |
73 | STDREPLACESUBST+= sysconfdir | |
74 | STDREPLACESUBST+= sharedstatedir | |
75 | STDREPLACESUBST+= localstatedir | |
76 | STDREPLACESUBST+= runstatedir | |
77 | STDREPLACESUBST+= includedir | |
78 | STDREPLACESUBST+= docdir | |
79 | STDREPLACESUBST+= infodir | |
80 | STDREPLACESUBST+= libdir | |
81 | STDREPLACESUBST+= localedir | |
82 | STDREPLACESUBST+= mandir | |
83 | ||
84 | .if defined(REPLACESUBST)&&!empty(REPLACESUBST) | |
85 | .for var in ${REPLACESUBST} | |
86 | _REPLACE_SED_SCRIPT+= -e 's|@${var}@|${${var:S/|/\|/g}}|g' | |
87 | .endfor | |
88 | REPLACEFILTER?= ${SED} ${_REPLACE_SED_SCRIPT} | |
89 | .endif | |
90 | ||
91 | .if defined(REPLACEFILE)&&!empty(REPLACEFILE) | |
92 | .if !empty(REPLACEFILE:N*.in) | |
93 | .error Cannot process files ${REPLACEFILE:N*.in} in REPLACEFILE. | |
94 | .endif | |
95 | .for file in ${REPLACEFILE} | |
96 | ${file:.in=}: ${file} | |
97 | ${REPLACEFILTER} < ${.ALLSRC} > ${.TARGET} | |
98 | DISTCLEANFILES+= ${file:.in=} | |
99 | .endfor | |
100 | .endif | |
101 | ||
102 | .endif # !target(__<bps.replace.mk>__) | |
103 | ||
104 | ### End of file `bps.replace.mk' |
77 | 77 | .if !target(__<bps.subdir.mk>__) |
78 | 78 | __<bps.subdir.mk>__: |
79 | 79 | |
80 | _SUBDIR_TARGET+= ${_MAKE_USERTARGET} | |
80 | _SUBDIR_TARGET?= ${_MAKE_USERTARGET:Nall:Nconfigure} | |
81 | 81 | SUBDIR_PREFIX?= |
82 | 82 | |
83 | 83 | .if defined(SUBDIR) && !empty(SUBDIR) |
95 | 95 | _SUBDIR: .USE |
96 | 96 | .for item in ${_SUBDIR_LIST} |
97 | 97 | ${INFO} "${SUBDIR_PREFIX}${item} (${.TARGET:S/^do-//:S/-subdir$//})" |
98 | @cd ${.CURDIR}/${item}\ | |
99 | &&${MAKE} SUBDIR_PREFIX=${SUBDIR_PREFIX}${item}/ ${.TARGET:S/^do-//:S/-subdir$//} | |
98 | @(cd ${.CURDIR}/${item}\ | |
99 | &&${MAKE} SUBDIR_PREFIX=${SUBDIR_PREFIX}${item}/\ | |
100 | ${.TARGET:S/^do-//:S/-subdir$//} ) | |
100 | 101 | .endfor |
101 | 102 | |
102 | 103 | ${_SUBDIR_LIST}:: |
103 | 104 | ${INFO} "${.TARGET} (all)" |
104 | @cd ${.CURDIR}/${.TARGET}; ${MAKE} all | |
105 | @(cd ${.CURDIR}/${.TARGET}; ${MAKE} all) | |
105 | 106 | |
106 | 107 | .if defined(_SUBDIR_TARGET)&&!empty(_SUBDIR_TARGET) |
107 | 108 | .for target in ${_SUBDIR_TARGET} |
62 | 62 | |
63 | 63 | do-all-${target}: .USE |
64 | 64 | @echo ${MAKE} ${target} |
65 | @cd ${.CURDIR} && ${MAKE} ${target} | |
65 | @(cd ${.CURDIR} && ${MAKE} ${target}) | |
66 | 66 | .endfor |
67 | 67 | |
68 | 68 |
0 | 0 | dnl Process this file with autoconf to produce a configure script. |
1 | 1 | AC_INIT(bps/Makefile) |
2 | AC_SUBST([version], [3.0.0-20141228]) | |
2 | AC_SUBST([version], [3.0.0-20150213]) | |
3 | 3 | AC_CONFIG_AUX_DIR([Library/Autoconf]) |
4 | 4 | AC_CANONICAL_HOST |
5 | 5 | AC_NEED_BSDMAKE() |
0 | bsdowl (3.0.0-20141228-1) UNRELEASED; urgency=medium | |
0 | bsdowl (3.0.0-20140213-1) UNRELEASED; urgency=medium | |
1 | 1 | |
2 | 2 | * Update package to 3.0.0-20141203. |
3 | 3 | * Update package to 3.0.0-20141228. |
4 | * Update package to 3.0.0-20140228, which should have been | |
5 | 3.0.0-20150228. | |
4 | 6 | |
5 | -- Michael Grünewald <michipili@gmail.com> Fri, 20 Mar 2015 15:56:09 +0100 | |
7 | -- Michael Grünewald <michipili@gmail.com> Fri, 20 Mar 2015 16:03:23 +0100 | |
6 | 8 | |
7 | 9 | bsdowl (2.2.2-1) unstable; urgency=medium |
8 | 10 |
117 | 117 | |
118 | 118 | ### IMPLEMENTATION |
119 | 119 | |
120 | ||
121 | .if defined(MODULE)&&!empty(MODULE) | |
122 | .if "${MODULE:O}" != "${MODULE:O:u}" | |
123 | .error The MODULE variable lists redundant entries, this is an error.\ | |
124 | Please verify that the first module is assigned to the list\ | |
125 | with MODULE= and not MODULE+=. | |
126 | .endif | |
127 | .endif | |
128 | ||
129 | ||
120 | 130 | .if defined(MODULE) |
121 | 131 | _SUBDIR_LIST+= ${MODULE:C@.*\:@@} |
122 | 132 | .endif |
13 | 13 | # are also available at |
14 | 14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt |
15 | 15 | |
16 | _MAKE_ALLSUBTARGET?= | |
17 | ||
16 | 18 | .include "bps.init.mk" |
17 | 19 | .include "bps.credentials.mk" |
18 | 20 | .include "bps.subdir.mk" |
19 | 21 | .include "bps.clean.mk" |
20 | 22 | |
23 | _SUBDIR_TARGET?= ${_MAKE_USERTARGET} | |
24 | ||
21 | 25 | obj: do-obj-subdir |
22 | 26 | |
27 | .unexport SRCDIR | |
28 | .unexport WRKDIR | |
29 | .unexport PACKAGE | |
30 | .unexport PACKAGEDIR | |
31 | .unexport VERSION | |
32 | .unexport OFFICER | |
33 | .unexport MODULE | |
34 | .unexport EXTERNAL | |
35 | ||
23 | 36 | ### End of file `generic.subdir.mk' |
245 | 245 | .undef clib |
246 | 246 | .endif |
247 | 247 | .if (empty(_OCAML_CMO)||empty(_OCAML_CMO:M${obj}))\ |
248 | &&(empty(_OCAML_CMX)||empty(_OCAML_CMX:M${obj}))\ | |
249 | &&(empty(_OCAML_CMXS)||empty(_OCAML_CMXS:M${obj})) | |
248 | &&(empty(_OCAML_CMX)||empty(_OCAML_CMX:M${obj})) | |
250 | 249 | # We are not building a CMO nor a CMX file |
251 | 250 | ${obj}: |
252 | 251 | ${_OCAML_BUILD.${obj:T}} ${.ALLSRC:N*.cmi} |
253 | 252 | .else |
254 | 253 | # We are building a CMO or a CMX file |
255 | if:=${obj:C/.cm[xo]/.cmi/:C/.cmxs/.cmi/} | |
254 | if:=${obj:C/.cm[xo]/.cmi/} | |
256 | 255 | .if !(empty(_OCAML_CMI)||empty(_OCAML_CMI:M${if})) |
257 | 256 | ${obj}: ${if} |
258 | 257 | ${obj}: |
30 | 30 | .endfor |
31 | 31 | |
32 | 32 | .for external_arg in ${_EXTERNAL_ocaml.lib_ARGS} |
33 | .if defined(_EXTERNAL_ocaml.lib_${external_arg}_DIR) | |
34 | DIRS+= ${_EXTERNAL_ocaml.lib_${external_arg}_DIR} | |
35 | .endif | |
36 | .if !defined(_EXTERNAL_ocaml.lib_${external_arg}_BYTE)\ | |
37 | &&!defined(_EXTERNAL_ocaml.lib_${external_arg}_NATIVE) | |
33 | 38 | _EXTERNAL_LIBS+= ${external_arg} |
34 | .if defined(_EXTERNAL_ocaml.lib_${external_arg}_DIRS) | |
35 | DIRS+= ${_EXTERNAL_ocaml.lib_${external_arg}_DIRS} | |
39 | .endif | |
40 | .if defined(_EXTERNAL_ocaml.lib_${external_arg}_BYTE) | |
41 | OCAMLLBADD+= ${_EXTERNAL_ocaml.lib_${external_arg}_BYTE} | |
42 | OCAMLABADD+= ${_EXTERNAL_ocaml.lib_${external_arg}_BYTE} | |
43 | .endif | |
44 | .if defined(_EXTERNAL_ocaml.lib_${external_arg}_NATIVE) | |
45 | OCAMLLNADD+= ${_EXTERNAL_ocaml.lib_${external_arg}_NATIVE} | |
46 | OCAMLANADD+= ${_EXTERNAL_ocaml.lib_${external_arg}_NATIVE} | |
47 | OCAMLCSADD+= ${_EXTERNAL_ocaml.lib_${external_arg}_NATIVE} | |
36 | 48 | .endif |
37 | 49 | .endfor |
38 | 50 |
98 | 98 | _OCAML_A+= ${lib:T}.a |
99 | 99 | _OCAML_SRCS.${lib:T}.cmxa+=\ |
100 | 100 | ${SRCS.${lib}.cmxa:C@\.ml[ly]@.ml@:M*.ml:.ml=.cmx} |
101 | LIB+= ${lib}.cmxa ${lib}.a | |
101 | LIB+= ${lib:T}.cmxa ${lib:T}.a | |
102 | 102 | .endif |
103 | 103 | .if defined(_OCAML_COMPILE_NATIVE)&&defined(_OCAML_COMPILE_PLUGIN) |
104 | _OCAML_CMXS+= ${SRCS.${lib}.cmxa:C@\.ml[ly]@.ml@:M*.ml:.ml=.cmxs} | |
104 | _OCAML_CMXS+= ${lib:T}.cmxs | |
105 | LIB+= ${lib:T}.cmxs | |
106 | CLEANFILES+= ${lib:T}.cmxs | |
107 | _OCAML_SRCS.${lib:T}.cmxs+=\ | |
108 | ${_OCAML_SRCS.${lib:T}.cmxa} | |
105 | 109 | .endif |
106 | 110 | .if defined(_OCAML_COMPILE_BYTE) |
107 | 111 | SRCS.${lib:T}.cma?= ${SRCS.${lib:T}} |
108 | _OCAML_SRCS+= SRCS.${lib}.cma | |
112 | _OCAML_SRCS+= SRCS.${lib:T}.cma | |
109 | 113 | _OCAML_CMA+= ${lib:T}.cma |
110 | 114 | _OCAML_SRCS.${lib:T}.cma+=\ |
111 | 115 | ${SRCS.${lib:T}.cma:C@\.ml[ly]@.ml@:M*.ml:.ml=.cmo} |
116 | 120 | .endif |
117 | 121 | .endfor |
118 | 122 | |
119 | .if !empty(_OCAML_CMXS) | |
120 | LIB+= ${_OCAML_CMXS} | |
121 | CLEANFILES+= ${_OCAML_CMXS} | |
122 | .endif | |
123 | ||
124 | 123 | .include "ocaml.main.mk" |
125 | ||
126 | .if !empty(_OCAML_CMXS) | |
127 | .for plugin in ${_OCAML_CMXS} | |
128 | ${plugin}: ${plugin:.cmxs=.ml} | |
129 | .endfor | |
130 | .endif | |
131 | ||
132 | 124 | |
133 | 125 | .for lib in ${_OCAML_LIB} |
134 | 126 | .if defined(_OCAML_COMPILE_NATIVE) |
135 | ${lib}.cmxa: ${_OCAML_SRCS.${lib}.cmxa} | |
127 | ${lib:T}.cmxa: ${_OCAML_SRCS.${lib:T}.cmxa} | |
136 | 128 | .endif |
137 | 129 | .if defined(_OCAML_COMPILE_BYTE) |
138 | ${lib}.cma: ${_OCAML_SRCS.${lib:T}.cma} | |
130 | ${lib:T}.cma: ${_OCAML_SRCS.${lib:T}.cma} | |
131 | .endif | |
132 | .if defined(_OCAML_COMPILE_NATIVE)&&defined(_OCAML_COMPILE_PLUGIN) | |
133 | ${lib:T}.cmxs: ${_OCAML_SRCS.${lib:T}.cmxs} | |
139 | 134 | .endif |
140 | 135 | .endfor |
141 | 136 | |
148 | 143 | .include "bps.files.mk" |
149 | 144 | .include "bps.usertarget.mk" |
150 | 145 | |
146 | .if !target(display-ocaml-lib) | |
147 | display-ocaml-lib: | |
148 | ${INFO} 'Display ocaml.lib information' | |
149 | .for displayvar in LIBRARY | |
150 | ${MESG} "${displayvar}=${${displayvar}}" | |
151 | .endfor | |
152 | .for lib in ${LIBRARY} | |
153 | .for suffix in cma cmxa cmxs | |
154 | .for displayvar in _OCAML_SRCS.${lib:T}.${suffix} | |
155 | ${MESG} "${displayvar}=${${displayvar}}" | |
156 | .endfor | |
157 | .endfor | |
158 | .endfor | |
159 | .endif | |
160 | ||
151 | 161 | ### End of file `ocaml.lib.mk' |
18 | 18 | |
19 | 19 | # TOPLEVEL= toplevel |
20 | 20 | # SRCS= initialize_toplevel.ml |
21 | # LIBS= unix | |
22 | # LIBS+= str | |
23 | 21 | # |
24 | 22 | # .include "ocaml.toplevel.mk" |
25 | 23 | |
74 | 72 | # Pass the given library names to the C linker |
75 | 73 | # |
76 | 74 | # This forces TOPLEVEL_CUSTOM to yes. |
75 | # | |
76 | # | |
77 | # TOPLEVEL_FLAGS | |
78 | # Flags passed to ocamlmktop | |
77 | 79 | |
78 | 80 | |
79 | 81 | ### IMPLEMENTATION |
89 | 91 | .error The ocaml.toplevel.mk module expects you to set the TOPLEVEL variable to a sensible value. |
90 | 92 | .endif |
91 | 93 | |
92 | TOPLEVEL_CUSTOM?= no | |
93 | TOPLEVEL_COPT?= | |
94 | TOPLEVEL_CLIB?= | |
94 | .if defined(TOPLEVEL_COPT)||defined(TOPLEVEL_CLIB) | |
95 | TOPLEVEL_CUSTOM?= yes | |
96 | .elif defined(SRCS)&&!empty(SRCS:M*.c) | |
97 | TOPLEVEL_CUSTOM?= yes | |
98 | .else | |
99 | TOPLEVEL_CUSTOM?= no | |
100 | .endif | |
95 | 101 | |
96 | OCAMLMKTOP?=ocamlmktop | |
102 | OCAMLMKTOP?= ocamlmktop | |
97 | 103 | |
98 | _TOPLEVEL_FLAGS=-custom -linkall | |
99 | 104 | |
100 | 105 | # |
101 | 106 | # Determining toplevel flags |
102 | 107 | # |
103 | 108 | |
104 | .if defined(TOPLEVEL_COPT)&&!empty(TOPLEVEL_COPT) | |
105 | TOPLEVEL_CUSTOM=yes | |
109 | .if ${TOPLEVEL_CUSTOM} == yes | |
110 | .if !defined(TOPLEVEL_FLAGS)||empty(TOPLEVEL_FLAGS:M-custom) | |
111 | TOPLEVEL_FLAGS+= -custom | |
106 | 112 | .endif |
107 | ||
108 | .if defined(TOPLEVEL_CLIB)&&!empty(TOPLEVEL_CLIB) | |
109 | TOPLEVEL_CUSTOM=yes | |
110 | .endif | |
111 | ||
112 | .if ${TOPLEVEL_CUSTOM} == yes | |
113 | _TOPLEVEL_FLAGS+=-custom | |
114 | 113 | .endif |
115 | 114 | |
116 | 115 | .if defined(TOPLEVEL_COPT)&&!empty(TOPLEVEL_COPT) |
117 | 116 | .for item in ${TOPLEVEL_COPT} |
118 | _TOPLEVEL_FLAGS+=-ccopt ${item} | |
117 | TOPLEVEL_FLAGS+= -ccopt ${item} | |
119 | 118 | .endfor |
120 | 119 | .endif |
121 | 120 | |
122 | 121 | .if defined(TOPLEVEL_CLIB)&&!empty(TOPLEVEL_CLIB) |
123 | 122 | .for item in ${TOPLEVEL_CLIB} |
124 | _TOPLEVEL_FLAGS+=-cclib -l${item} | |
123 | TOPLEVEL_FLAGS+= -cclib -l${item} | |
125 | 124 | .endfor |
126 | 125 | .endif |
127 | 126 | |
128 | 127 | .if defined(DIRS)&&!empty(DIRS) |
129 | 128 | .for item in ${DIRS} |
130 | _TOPLEVEL_FLAGS+=-I ${item} | |
129 | TOPLEVEL_FLAGS+= -I ${item} | |
131 | 130 | .endfor |
132 | 131 | .endif |
133 | 132 | |
134 | 133 | |
135 | 134 | .if !defined(_OCAML_COMPILE_NATIVE_ONLY) |
136 | 135 | |
137 | .for file in ${SRCS} | |
138 | _OCAML_CMO+= ${file:.ml=.cmo} | |
136 | .for file in ${SRCS:M*.ml} | |
137 | _OCAML_CMO+= ${file:.ml=.cmo} | |
139 | 138 | ${TOPLEVEL}: ${file:.ml=.cmo} |
140 | 139 | .endfor |
140 | ||
141 | .for file in ${SRCS:M*.c} | |
142 | ${TOPLEVEL}: ${file:.c=.o} | |
143 | CLEANFILES+= ${file:.c=.o} | |
144 | .endfor | |
145 | ||
146 | .if defined(SRCS)&&!empty(SRCS:M*.c) | |
147 | CFLAGS+= -I ${OCAMLROOTDIR} | |
148 | .endif | |
141 | 149 | |
142 | 150 | .for file in ${LIBS} |
143 | 151 | ${TOPLEVEL}: ${file:=.cma} |
144 | 152 | .endfor |
145 | 153 | |
146 | 154 | ${TOPLEVEL}: |
147 | ${OCAMLMKTOP} ${_TOPLEVEL_FLAGS} ${.ALLSRC} -o ${.TARGET} | |
155 | ${OCAMLMKTOP} ${TOPLEVEL_FLAGS} -o ${.TARGET} ${.ALLSRC} | |
148 | 156 | |
149 | 157 | CLEANFILES+= ${TOPLEVEL} |
150 | 158 | BIN+= ${TOPLEVEL} |
151 | 159 | |
152 | 160 | .else |
153 | ${TOPLEVEL}: | |
161 | ${TOPLEVEL}: .PHONY | |
154 | 162 | ${INFO} Not building toplevel ${.TARGET} in native-only mode |
155 | 163 | .endif |
164 | ||
165 | display-developer-dirs: .PHONY | |
166 | .for dir in ${DIRS} | |
167 | @printf '#directory "%s";;\n' "${dir}" | |
168 | .endfor | |
156 | 169 | |
157 | 170 | .include "ocaml.main.mk" |
158 | 171 | .include "bps.clean.mk" |
159 | 172 | .include "bps.files.mk" |
160 | 173 | .include "bps.usertarget.mk" |
161 | 174 | |
162 | ### End of file `ocaml.odoc.mk' | |
175 | ### End of file `ocaml.toplevel.mk' |
49 | 49 | |
50 | 50 | PRODUCT= ${PROGRAM:C@\.py$@@} |
51 | 51 | _PACKAGE_CANDIDATE= ${PRODUCT} |
52 | REPLACE+= PYTHON | |
53 | REPLACE+= ${STDREPLACE} | |
54 | REPLACE+= ${BINDIR} | |
52 | REPLACESUBST+= PYTHON | |
53 | REPLACESUBST+= ${STDREPLACESUBST} | |
54 | REPLACESUBST+= BINDIR | |
55 | 55 | |
56 | 56 | .for product in ${PRODUCT} |
57 | 57 | _MAN_AUTO+= ${product}.1 |
0 | ### script.shell.mk -- Development of shell scripts | |
0 | ### script.main.mk -- Development of shell scripts | |
1 | 1 | |
2 | 2 | # Author: Michael Grünewald |
3 | 3 | # Date: Fri Feb 10 10:40:49 GMT 2006 |
16 | 16 | |
17 | 17 | ### SYNOPSIS |
18 | 18 | |
19 | # SCRIPT= mp2eps.sh | |
20 | # SCRIPT+= mp2pdf.sh | |
21 | # SCRIPT+= mp2png.sh | |
19 | # PROGRAM= mp2eps.sh | |
20 | # PROGRAM+= mp2pdf.sh | |
21 | # PROGRAM+= mp2png.sh | |
22 | 22 | # |
23 | # SCRIPTLIB+= mp2pnglib.sh | |
23 | # SUBR+= mp2pnglib.sh | |
24 | 24 | # |
25 | 25 | # |
26 | # TMPDIR= /var/run/tmp | |
26 | # tmpdir= /var/run/tmp | |
27 | 27 | # |
28 | # REPLACE= PREFIX TMPDIR | |
28 | # REPLACESUBST= ${STDREPLACESUBST} | |
29 | 29 | # |
30 | # .include "script.shell.mk" | |
30 | # .include "script.main.mk" | |
31 | 31 | |
32 | 32 | |
33 | 33 | ### DESCRIPTION |
66 | 66 | # List of script subroutine libraries to install |
67 | 67 | # |
68 | 68 | # |
69 | # SUBRDIR [${SHAREDIR}${PACKAGEDIR}] | |
69 | # SUBRDIR [${datadir}${PACKAGEDIR}] | |
70 | 70 | # List of script libraries to install |
71 | 71 | # |
72 | 72 | # The variables SUBRDIR, SUBRMODE, SUBROWN and |
73 | 73 | # SUBRGRP parametrise the installation. |
74 | 74 | # |
75 | 75 | # The SUBRDIR variable defaults to |
76 | # `${SHAREDIR}${PACKAGEDIR}` but other sensible locations could | |
77 | # be `${LIBDIR}/perl5/5.12.4${PACKAGEDIR}`. | |
76 | # `${datadir}${PACKAGEDIR}` but other sensible locations could | |
77 | # follow another pattern, like for instance | |
78 | # `${libdir}/perl5/5.12.4${PACKAGEDIR}`. | |
78 | 79 | # |
79 | 80 | # |
80 | # REPLACE [not set] | |
81 | # REPLACESUBST [not set] | |
81 | 82 | # List of variables to be replaced in the preparation step |
82 | 83 | # |
83 | 84 | # The pipe character `|` must not appear in replacement text of the |
84 | 85 | # variables enumerated by REPLACE. |
85 | 86 | # |
86 | # STDREPLACE [see description] | |
87 | # | |
88 | # STDREPLACESUBST [see description] | |
87 | 89 | # The standard replacement list |
88 | 90 | |
89 | 91 | |
93 | 95 | .error shell.main.mk cannot be included directly. |
94 | 96 | .endif |
95 | 97 | |
96 | .if !target(__<script.shell.mk>__) | |
97 | __<script.shell.mk>__: | |
98 | .if !target(__<script.main.mk>__) | |
99 | __<script.main.mk>__: | |
98 | 100 | |
99 | 101 | .include "bps.init.mk" |
100 | ||
101 | ||
102 | # | |
103 | # Replacement of variables | |
104 | # | |
105 | ||
106 | STDREPLACE= PACKAGE | |
107 | STDREPLACE+= VERSION | |
108 | STDREPLACE+= prefix | |
109 | STDREPLACE+= exec_prefix | |
110 | STDREPLACE+= bindir | |
111 | STDREPLACE+= sbindir | |
112 | STDREPLACE+= libexecdir | |
113 | STDREPLACE+= datarootdir | |
114 | STDREPLACE+= datadir | |
115 | STDREPLACE+= sysconfdir | |
116 | STDREPLACE+= sharedstatedir | |
117 | STDREPLACE+= localstatedir | |
118 | STDREPLACE+= runstatedir | |
119 | STDREPLACE+= includedir | |
120 | STDREPLACE+= docdir | |
121 | STDREPLACE+= infodir | |
122 | STDREPLACE+= libdir | |
123 | STDREPLACE+= localedir | |
124 | STDREPLACE+= mandir | |
125 | ||
126 | .if defined(REPLACE)&&!empty(REPLACE) | |
127 | .for var in ${REPLACE} | |
128 | _SCRIPT_SED+= -e 's|@${var}@|${${var:S/|/\|/g}}|g' | |
129 | .endfor | |
130 | .endif | |
131 | 102 | |
132 | 103 | |
133 | 104 | # |
144 | 115 | .for script in ${PROGRAM:M*.${ext}} |
145 | 116 | CLEANFILES+= ${script:T:.${ext}=} |
146 | 117 | buildfiles: ${script:T:.${ext}=} |
147 | .if defined(_SCRIPT_SED) | |
118 | .if defined(REPLACEFILTER) | |
148 | 119 | ${script:T:.${ext}=}: ${script} |
149 | ${SED} ${_SCRIPT_SED} < ${.ALLSRC} > ${.TARGET}.output | |
150 | ${MV} ${.TARGET}.output ${.TARGET} | |
120 | ${REPLACEFILTER} < ${.ALLSRC} > ${.TARGET} | |
151 | 121 | .else |
152 | 122 | ${script:T:.${ext}=}: ${script} |
153 | 123 | ${CP} ${.ALLSRC} ${.TARGET} |
188 | 158 | .include "bps.clean.mk" |
189 | 159 | .include "bps.usertarget.mk" |
190 | 160 | |
191 | .endif #!target(__<script.shell.mk>__) | |
161 | .endif #!target(__<script.main.mk>__) | |
192 | 162 | |
193 | ### End of file `script.shell.mk' | |
163 | ### End of file `script.main.mk' |
39 | 39 | |
40 | 40 | PRODUCT= ${LIBRARY:C@\.(sh|bash|ksh|csh|awk|sed|subr)$@@} |
41 | 41 | _PACKAGE_CANDIDATE= ${PRODUCT} |
42 | REPLACE+= ${STDREPLACE} | |
43 | REPLACE+= SUBRDIR | |
42 | REPLACESUBST+= ${STDREPLACESUBST} | |
43 | REPLACESUBST+= SUBRDIR | |
44 | 44 | |
45 | 45 | .for product in ${PRODUCT} |
46 | 46 | _MAN_AUTO+= ${product}.3 |
28 | 28 | # is a single word or from the last component of SRCDIR otherwise. |
29 | 29 | # |
30 | 30 | # |
31 | # SUBR | |
32 | # List of script subroutine libraries to install | |
33 | # | |
34 | # | |
35 | # SUBRDIR [${datadir}${PACKAGEDIR}] | |
36 | # List of script libraries to install | |
37 | # | |
38 | # The variables SUBRDIR, SUBRMODE, SUBROWN and | |
39 | # SUBRGRP parametrise the installation. | |
40 | # | |
41 | # The SUBRDIR variable defaults to | |
42 | # `${datadir}${PACKAGEDIR}` but other sensible locations could | |
43 | # follow another pattern, like for instance | |
44 | # `${libdir}/perl5/5.12.4${PACKAGEDIR}`. | |
45 | # | |
46 | # | |
31 | 47 | # BINOWN, BINGRP, BINMODE, BINDIR, BINNAME |
32 | 48 | # Parameters of the program installation |
33 | 49 | # |
45 | 61 | |
46 | 62 | PRODUCT= ${PROGRAM:C@\.(sh|bash|ksh|csh|awk|sed)$@@} |
47 | 63 | _PACKAGE_CANDIDATE= ${PRODUCT} |
48 | REPLACE+= ${STDREPLACE} | |
49 | REPLACE+= ${BINDIR} | |
64 | REPLACESUBST+= ${STDREPLACESUBST} | |
65 | REPLACESUBST+= BINDIR | |
50 | 66 | |
51 | 67 | .for product in ${PRODUCT} |
52 | 68 | _MAN_AUTO+= ${product}.1 |
0 | *.o | |
1 | *.a | |
2 | *.byte | |
3 | *.native | |
4 | *.cmo | |
5 | *.cmx | |
6 | basic/basic_lexer.ml | |
7 | basic/basic_parser.ml | |
8 | basic/basic_parser.mli | |
9 | basic/minibasic | |
10 | newton-doc/newtontk.odoc | |
11 | newton-doc/newtontk_html/ | |
12 | ocamlfind/wordcount | |
13 | toplevel/toplevel | |
14 | wordcount-1/wordcount | |
15 | wordcount-2/wordcount | |
16 | basic-1/basic_lexer.ml | |
17 | basic-1/basic_parser.ml | |
18 | basic-1/basic_parser.mli | |
19 | basic-1/minibasic | |
20 | basic-2/basic_lexer.ml | |
21 | basic-2/basic_parser.ml | |
22 | basic-2/basic_parser.mli | |
23 | basic-2/minibasic | |
24 | golden-ratio/golden-ratio | |
25 | basic-3/basic_lexer.ml | |
26 | basic-3/basic_parser.ml | |
27 | basic-3/basic_parser.mli | |
28 | basic-4/basic_lexer.ml | |
29 | basic-4/basic_parser.ml | |
30 | basic-4/basic_parser.mli | |
31 | golden_ratio/golden_ratio | |
32 | miniproj-1/golden_ratio/golden_ratio | |
33 | miniproj-2/golden_ratio/golden_ratio | |
34 | miniproj-2/manual/golden_ratio_html/ | |
35 | miniproj-3/golden_ratio/golden_ratio | |
36 | miniproj-3/manual/golden_ratio_html/ | |
37 | objdir/ |
0 | ### Makefile -- Test OCaml support | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Fri Oct 4 20:54:55 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | SUBDIR= wordcount-1 | |
17 | SUBDIR+= wordcount-2 | |
18 | SUBDIR+= fibonacci | |
19 | SUBDIR+= newton | |
20 | SUBDIR+= newton-doc | |
21 | SUBDIR+= toplevel | |
22 | SUBDIR+= basic-1 | |
23 | SUBDIR+= basic-2 | |
24 | SUBDIR+= basic-3 | |
25 | SUBDIR+= basic-4 | |
26 | SUBDIR+= ocamlfind | |
27 | SUBDIR+= golden_ratio | |
28 | SUBDIR+= miniproj-1 | |
29 | SUBDIR+= miniproj-2 | |
30 | SUBDIR+= miniproj-3 | |
31 | ||
32 | # | |
33 | # Test setup | |
34 | # | |
35 | ||
36 | COMPILE?= byte_code | |
37 | ||
38 | TESTENV= ${ENVTOOL} -i "PATH=${PATH}" "COMPILE=${COMPILE}" | |
39 | TESTENV+= "MAKEFLAGS=${MAKEFLAGS:NPACKAGE*:NPROJECT*}" | |
40 | ||
41 | test-clean: | |
42 | ${TESTENV} ${MAKE} realclean | |
43 | ||
44 | test-base: | |
45 | ${TESTENV} ${MAKE} all | |
46 | ${TESTENV} ${MAKE} realclean | |
47 | ||
48 | test-doc: | |
49 | ${TESTENV} ${MAKE} doc | |
50 | ${TESTENV} ${MAKE} realclean | |
51 | ||
52 | test-parallel: | |
53 | ${TESTENV} ${MAKE} depend | |
54 | ${TESTENV} ${MAKE} -j4 build | |
55 | ${TESTENV} ${MAKE} realclean | |
56 | ||
57 | test-objdir: | |
58 | ${INSTALL_DIR} ${.CURDIR}/objdir | |
59 | ${TESTENV} MAKEOBJDIRPREFIX=${.CURDIR}/objdir ${MAKE} | |
60 | test -r ${.CURDIR}/objdir/${.CURDIR}/basic-1/.depend | |
61 | test -r ${.CURDIR}/objdir/${.CURDIR}/basic-1/basic_lexer.ml | |
62 | test -r ${.CURDIR}/objdir/${.CURDIR}/basic-1/basic_parser.ml | |
63 | test -r ${.CURDIR}/objdir/${.CURDIR}/basic-1/basic_parser.mli | |
64 | test -x ${.CURDIR}/objdir/${.CURDIR}/golden_ratio/golden_ratio | |
65 | ||
66 | test-compile: | |
67 | ${TESTENV} COMPILE="byte_code" ${MAKE} test | |
68 | ${TESTENV} COMPILE="native_code" ${MAKE} test | |
69 | ${TESTENV} COMPILE="both" ${MAKE} test | |
70 | ||
71 | CLEANDIRS+= ${.CURDIR}/objdir | |
72 | ||
73 | test: test-clean | |
74 | test: test-base | |
75 | test: test-doc | |
76 | test: test-parallel | |
77 | test: test-objdir | |
78 | ||
79 | .include "bps.subdir.mk" | |
80 | ||
81 | ### End of file `Makefile' |
0 | ### Makefile -- Computing the golden ratio | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sat Oct 5 20:47:48 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | PROGRAM= golden_ratio | |
17 | ||
18 | SRCS= main.ml | |
19 | ||
20 | LIBS+= nums | |
21 | LIBS+= newton | |
22 | LIBS+= fibonacci | |
23 | ||
24 | DIRS= ${.OBJDIR}/../newton | |
25 | DIRS+= ${.OBJDIR}/../fibonacci | |
26 | ||
27 | newton.cma: | |
28 | @cd ${.CURDIR}/../newton && ${MAKE} ${.TARGET} | |
29 | ||
30 | fibonacci.cma: | |
31 | @cd ${.CURDIR}/../fibonacci && ${MAKE} ${.TARGET} | |
32 | ||
33 | .include "ocaml.prog.mk" | |
34 | ||
35 | ### End of file `Makefile' |
0 | open Printf | |
1 | ||
2 | let rec loop iter n x = | |
3 | printf "%02d %12.8f %s\n" n x (Fibonacci.phi_string n); | |
4 | if n < iter then | |
5 | loop iter (succ n) (Newton.phi_iter x) | |
6 | ||
7 | let () = | |
8 | loop 20 0 1.0 |
0 | ### Makefile -- Mini project | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sun Oct 13 10:50:45 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | PROJECT= golden_ratio | |
17 | VERSION= 1.0 | |
18 | AUTHOR= Michael Grünewald | |
19 | ||
20 | SUBDIR+= fibonacci | |
21 | SUBDIR+= newton | |
22 | SUBDIR+= golden_ratio | |
23 | SUBDIR+= manual | |
24 | ||
25 | PROJECTSETUP= debug profile release | |
26 | ||
27 | universe: | |
28 | .for setup in ${PROJECTSETUP} | |
29 | ${ENVTOOL} MAKEINITRC=Makefile.${setup} MAKEOBJDIR=${.CURDIR}/obj/${setup} ${MAKE} all | |
30 | .endfor | |
31 | ||
32 | .include "bps.project.mk" | |
33 | ||
34 | ### End of file `Makefile' |
0 | ### Makefile -- Newton's method | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sat Oct 5 20:40:24 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | LIBRARY= fibonacci | |
17 | SRCS+= fibonacci.ml | |
18 | ||
19 | LIBS= nums | |
20 | ||
21 | USE_ODOC= yes | |
22 | ODOC_FORMAT= odoc | |
23 | ||
24 | .include "ocaml.lib.mk" | |
25 | ||
26 | ### End of file `Makefile' |
0 | (* Fibonacci -- Compute Fibonacci numbers | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | open Num | |
13 | ||
14 | let rec fibo_num n = | |
15 | match n with | |
16 | | 0 -> Int 1 | |
17 | | 1 -> Int 1 | |
18 | | n -> add_num (fibo_num (n-1)) (fibo_num(n-2)) | |
19 | ||
20 | let calc n = | |
21 | if n < 0 then | |
22 | invalid_arg "Fibonacci.calc" | |
23 | else | |
24 | fibo_num n | |
25 | ||
26 | let phi_string n = | |
27 | let p, q = calc (n+1), calc n in | |
28 | let phi = div_num p q in | |
29 | approx_num_fix 8 phi |
0 | (* Fibonacci -- Compute Fibonacci numbers | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | ||
13 | (** Compute Fibonacci numbers. | |
14 | ||
15 | The 0-th and 1-st Fibonacci numbers [F_0] and [F_1] are 1, and then [F_n+2 | |
16 | = F_n + F_n+1]. *) | |
17 | val calc : int -> Num.num | |
18 | ||
19 | val phi_string : int -> string |
0 | ### Makefile -- Computing the golden ratio | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sat Oct 5 20:47:48 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | PROGRAM= golden_ratio | |
17 | ||
18 | SRCS= main.ml | |
19 | ||
20 | LIBS+= nums | |
21 | LIBS+= newton | |
22 | LIBS+= fibonacci | |
23 | ||
24 | DIRS= ${.OBJDIR}/../newton | |
25 | DIRS+= ${.OBJDIR}/../fibonacci | |
26 | ||
27 | ||
28 | .include "ocaml.prog.mk" | |
29 | ||
30 | ### End of file `Makefile' |
0 | open Printf | |
1 | ||
2 | let rec loop iter n x = | |
3 | printf "%02d %12.8f %s\n" n x (Fibonacci.phi_string n); | |
4 | if n < iter then | |
5 | loop iter (succ n) (Newton.phi_iter x) | |
6 | ||
7 | let () = | |
8 | loop 20 0 1.0 |
0 | ### Makefile -- Preparation of the golden_ratio manual | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Tue Oct 15 21:37:11 CEST 2013 | |
4 | ||
5 | # Copyright (c) 2013 Michael Grünewald | |
6 | # All rights reserved. | |
7 | # | |
8 | # This file is part of Waermondt. | |
9 | ||
10 | ||
11 | ODOC_TITLE= Golden Ratio | |
12 | ||
13 | DIRS+= ../newton | |
14 | MANUAL+= newton.odoc | |
15 | ||
16 | DIRS+= ../fibonacci | |
17 | MANUAL+= fibonacci.odoc | |
18 | ||
19 | .include "ocaml.manual.mk" | |
20 | ||
21 | ### End of file `Makefile' |
0 | ### Makefile -- Newton's method | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Thu Oct 3 23:39:20 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | LIBRARY= newton | |
17 | SRCS+= newton.ml | |
18 | ||
19 | USE_ODOC= yes | |
20 | ODOC_FORMAT= odoc | |
21 | ||
22 | .include "ocaml.lib.mk" | |
23 | ||
24 | ### End of file `Makefile' |
0 | (* Newton -- Newton's method | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | ||
13 | let iter dx f x0 = | |
14 | let y = f x0 in | |
15 | let dy= (f(x0 +. dx) -. y) in | |
16 | x0 -. dx *. y /. dy | |
17 | ||
18 | let phi_iter x0 = | |
19 | (x0 *. x0 +. 1.0) /. (2.0 *. x0 -. 1.0) |
0 | (* Newton -- Newton's method | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | ||
13 | (** Newton's method. *) | |
14 | ||
15 | val iter : float -> (float -> float) -> float -> float | |
16 | (** [iter dx f x0] is the Newton iterate obtained by applying one time | |
17 | Newton's method to [f] and [x0], using the infinitesimal [dx]. | |
18 | ||
19 | It assumes the function [f] is defined for every real number. *) | |
20 | ||
21 | val phi_iter : float -> float | |
22 | (** [phi_iter x0] is the Newton iterate following [x0] and converging | |
23 | the golden ratio [phi]. *) |
0 | ### Makefile -- Custom toplevel | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Fri Oct 4 08:23:21 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | TOPLEVEL= toplevel | |
17 | SRCS+= initialise_toplevel.ml | |
18 | ||
19 | LIBS+= unix | |
20 | LIBS+= str | |
21 | ||
22 | .include "ocaml.toplevel.mk" | |
23 | ||
24 | ### End of file `Makefile' |
0 | ### Makefile -- Counting characters and lines in a file | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Fri Oct 4 06:52:41 CEST 2013 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2014 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | PROGRAM= wordcount | |
17 | ||
18 | SRCS+= ancillary.ml | |
19 | SRCS+= application.ml | |
20 | ||
21 | .include "ocaml.prog.mk" | |
22 | ||
23 | ### End of file `Makefile' |
0 | (* Ancillary -- Count characters and words on stdin | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | ||
13 | let is_word c = | |
14 | (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') | |
15 | ||
16 | let rec wc chan wordflag nc nw nl = | |
17 | let next = | |
18 | try Some(input_char chan) | |
19 | with End_of_file -> None | |
20 | in | |
21 | match next with | |
22 | | Some '\n' -> wc chan false (succ nc) nw (succ nl) | |
23 | | Some c -> ( match is_word c, wordflag with | |
24 | | true, true | |
25 | | false, false -> wc chan wordflag (succ nc) nw nl | |
26 | | true, false -> wc chan true (succ nc) (succ nw) nl | |
27 | | false, true -> wc chan false (succ nc) nw nl | |
28 | ) | |
29 | | None -> (nc, nw, nl) |
0 | (* Application -- Count characters and words on stdin | |
1 | ||
2 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
3 | This file is part of BSD Owl Scripts | |
4 | ||
5 | Copyright © 2005–2014 Michael Grünewald | |
6 | ||
7 | This file must be used under the terms of the CeCILL-B. | |
8 | This source file is licensed as described in the file COPYING, which | |
9 | you should have received as part of this distribution. The terms | |
10 | are also available at | |
11 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
12 | ||
13 | let main () = | |
14 | let (nc, nw, nl) = Ancillary.wc stdin false 0 0 1 in | |
15 | Printf.printf "%d %d %d\n" nc nw nl | |
16 | ||
17 | let () = main () |
17 | 17 | SUBDIR= test_program |
18 | 18 | SUBDIR+= test_library |
19 | 19 | SUBDIR+= test_complex |
20 | SUBDIR+= test_toplevel | |
20 | 21 | |
21 | 22 | .include "generic.subdir.mk" |
22 | 23 |
19 | 19 | TEST+= TestProgramProfile |
20 | 20 | TEST+= TestProgramMultiple |
21 | 21 | TEST+= TestProgramLexerParser |
22 | TEST+= TestProgramExternalOCaml | |
22 | 23 | |
23 | 24 | .if "${WITH_TESTSUITE_FINDLIB}" == "yes" |
24 | 25 | TEST+= TestProgramExternalFindlib |
0 | ### TestProgramExternalOCaml.mk -- How does it feel? | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Fri Jan 9 09:06:51 CET 2015 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2015 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | PROGRAM= rolling_stone | |
17 | EXTERNAL= ocaml.lib:unix | |
18 | ||
19 | _EXTERNAL_ocaml.lib_unix_DIR= ${ocamllibdir}/ocaml | |
20 | _EXTERNAL_ocaml.lib_unix_BYTE= unix.cma | |
21 | _EXTERNAL_ocaml.lib_unix_NATIVE=unix.cmxa | |
22 | ||
23 | test: | |
24 | test -x ${DESTDIR}${BINDIR}/rolling_stone | |
25 | ||
26 | .include "ocaml.prog.mk" | |
27 | ||
28 | ### End of file `TestProgramExternalOCaml.mk' |
0 | ### Makefile -- Test features of module ocaml.toplevel | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sun Dec 28 18:14:15 CET 2014 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2015 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | TEST= TestToplevel | |
17 | TEST+= TestToplevelCustom | |
18 | ||
19 | .include "bsdowl.test.mk" | |
20 | ||
21 | ### End of file `Makefile' |
0 | ### TestToplevel.mk -- Prepare an OCaml toplevel | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sun Dec 28 18:15:21 CET 2014 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2015 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | TOPLEVEL= custom_toplevel | |
17 | ||
18 | EXTERNAL+= ocaml.findlib:compiler-libs | |
19 | ||
20 | SRCS= custom_configuration.ml | |
21 | SRCS+= custom_library.ml | |
22 | SRCS+= custom_bootstrap.ml | |
23 | ||
24 | REPLACESUBST= ${STDREPLACESUBST} | |
25 | REPLACEFILE= custom_configuration.ml.in | |
26 | ||
27 | test: | |
28 | test -x ${DESTDIR}${BINDIR}/custom_toplevel | |
29 | ||
30 | .include "ocaml.toplevel.mk" | |
31 | ||
32 | ### End of file `TestToplevel.mk' |
0 | ### TestToplevelCustom.mk -- Prepare an OCaml custom toplevel | |
1 | ||
2 | # Author: Michael Grünewald | |
3 | # Date: Sat Jan 3 16:18:30 CET 2015 | |
4 | ||
5 | # BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | # This file is part of BSD Owl Scripts | |
7 | # | |
8 | # Copyright © 2005–2015 Michael Grünewald | |
9 | # | |
10 | # This file must be used under the terms of the CeCILL-B. | |
11 | # This source file is licensed as described in the file COPYING, which | |
12 | # you should have received as part of this distribution. The terms | |
13 | # are also available at | |
14 | # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt | |
15 | ||
16 | TOPLEVEL= custom_toplevel | |
17 | ||
18 | SRCS= greeting.ml | |
19 | SRCS+= greeting_stub.c | |
20 | ||
21 | EXTERNAL+= ocaml.findlib:compiler-libs | |
22 | ||
23 | # We provide a quick and dirty way to produce the C object, but in | |
24 | # real projects, it is reasonable to write a small library as a | |
25 | # separate project module to provide all the required stubs. | |
26 | ||
27 | test: | |
28 | test -x ${DESTDIR}${BINDIR}/custom_toplevel | |
29 | ||
30 | .include "ocaml.toplevel.mk" | |
31 | ||
32 | ### End of file `TestToplevel.mk' |
0 | (* Custom_bootstrap -- Bootstrap our custom toplevel | |
1 | ||
2 | Author: Michael Grünewald | |
3 | Date: Mon Dec 29 11:33:55 CET 2014 | |
4 | ||
5 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | This file is part of BSD Owl Scripts | |
7 | ||
8 | Copyright © 2005–2015 Michael Grünewald | |
9 | ||
10 | This file must be used under the terms of the CeCILL-B. | |
11 | This source file is licensed as described in the file COPYING, which | |
12 | you should have received as part of this distribution. The terms | |
13 | are also available at | |
14 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
15 | let directory_list = [ | |
16 | "+compiler-libs"; | |
17 | ] | |
18 | ||
19 | let install_printer_list = [ | |
20 | [ "Custom_library"; "Thing" ]; | |
21 | ] | |
22 | ||
23 | let install_printer path = | |
24 | let rec loop p = | |
25 | match p with | |
26 | | [] -> invalid_arg "Custom_bootstrap.install_printer" | |
27 | | h :: [] -> Longident.Lident h | |
28 | | h :: t -> Longident.Ldot (loop t, h) | |
29 | in | |
30 | let longident = loop ("format" :: List.rev path) in | |
31 | let phrase = Parsetree.Ptop_dir( | |
32 | "install_printer", Parsetree.Pdir_ident longident | |
33 | ) | |
34 | in | |
35 | ignore(Toploop.execute_phrase false Format.std_formatter phrase) | |
36 | ||
37 | let bootstrap () = | |
38 | begin | |
39 | List.iter Topdirs.dir_directory directory_list; | |
40 | List.iter install_printer install_printer_list; | |
41 | end | |
42 | ||
43 | let _ = | |
44 | Toploop.toplevel_startup_hook := bootstrap |
0 | (* Custom_configuration -- Configuration for our custom toplevel | |
1 | ||
2 | Author: Michael Grünewald | |
3 | Date: Mon Dec 29 11:22:17 CET 2014 | |
4 | ||
5 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | This file is part of BSD Owl Scripts | |
7 | ||
8 | Copyright © 2005–2015 Michael Grünewald | |
9 | ||
10 | This file must be used under the terms of the CeCILL-B. | |
11 | This source file is licensed as described in the file COPYING, which | |
12 | you should have received as part of this distribution. The terms | |
13 | are also available at | |
14 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
15 | ||
16 | let project = "bsdowl" | |
17 | let officer = "michipili@gmail.com" | |
18 | let version = "@version@" | |
19 | let prefix = "@prefix@" | |
20 | let exec_prefix = "@exec_prefix@" | |
21 | let bindir = "@bindir@" | |
22 | let sbindir = "@sbindir@" | |
23 | let libexecdir = "@libexecdir@" | |
24 | let datarootdir = "@datarootdir@" | |
25 | let datadir = "@datadir@" | |
26 | let sysconfdir = "@sysconfdir@" | |
27 | let sharedstatedir = "@sharedstatedir@" | |
28 | let localstatedir = "@localstatedir@" | |
29 | let runstatedir = "@runstatedir@" | |
30 | let includedir = "@includedir@" | |
31 | let docdir = "@docdir@" | |
32 | let infodir = "@infodir@" | |
33 | let libdir = "@libdir@" | |
34 | let localedir = "@localedir@" | |
35 | let mandir = "@mandir@" |
0 | (* Custom_library -- Our custom library | |
1 | ||
2 | Author: Michael Grünewald | |
3 | Date: Sat Jan 3 15:00:00 CET 2015 | |
4 | ||
5 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | This file is part of BSD Owl Scripts | |
7 | ||
8 | Copyright © 2005–2015 Michael Grünewald | |
9 | ||
10 | This file must be used under the terms of the CeCILL-B. | |
11 | This source file is licensed as described in the file COPYING, which | |
12 | you should have received as part of this distribution. The terms | |
13 | are also available at | |
14 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
15 | module Thing : sig | |
16 | type t | |
17 | val make : unit -> t | |
18 | val format : Format.formatter -> t -> unit | |
19 | end = struct | |
20 | type t = unit | |
21 | let make () = () | |
22 | let format ppt () = | |
23 | Format.pp_print_string ppt "Something strange" | |
24 | end |
0 | (* Greeting -- Say hello | |
1 | ||
2 | Author: Michael Grünewald | |
3 | Date: Sat Jan 3 16:31:02 CET 2015 | |
4 | ||
5 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | This file is part of BSD Owl Scripts | |
7 | ||
8 | Copyright © 2005–2015 Michael Grünewald | |
9 | ||
10 | This file must be used under the terms of the CeCILL-B. | |
11 | This source file is licensed as described in the file COPYING, which | |
12 | you should have received as part of this distribution. The terms | |
13 | are also available at | |
14 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt *) | |
15 | ||
16 | external hello_world : unit -> unit = "hello_world" | |
17 | ||
18 | let () = hello_world () |
0 | /* greeting_stub.c -- OCaml stubs to greet people | |
1 | ||
2 | Author: Michael Grünewald | |
3 | Date: Sat Jan 3 16:25:15 CET 2015 | |
4 | ||
5 | BSD Owl Scripts (https://github.com/michipili/bsdowl) | |
6 | This file is part of BSD Owl Scripts | |
7 | ||
8 | Copyright © 2005–2015 Michael Grünewald | |
9 | ||
10 | This file must be used under the terms of the CeCILL-B. | |
11 | This source file is licensed as described in the file COPYING, which | |
12 | you should have received as part of this distribution. The terms | |
13 | are also available at | |
14 | http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.txt */ | |
15 | ||
16 | #include <stdlib.h> | |
17 | #include <stdio.h> | |
18 | #include <caml/mlvalues.h> | |
19 | #include <caml/memory.h> | |
20 | #include <caml/alloc.h> | |
21 | #include <caml/custom.h> | |
22 | ||
23 | value hello_world(value unit) | |
24 | { | |
25 | CAMLparam1 (unit); | |
26 | printf("Hello, world!\n"); | |
27 | CAMLreturn (Val_unit); | |
28 | } |