1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
dnl
dnl Copyright 2006-2020 Adrian Thurston <thurston@colm.net>
dnl
dnl Permission is hereby granted, free of charge, to any person obtaining a copy
dnl of this software and associated documentation files (the "Software"), to
dnl deal in the Software without restriction, including without limitation the
dnl rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
dnl sell copies of the Software, and to permit persons to whom the Software is
dnl furnished to do so, subject to the following conditions:
dnl
dnl The above copyright notice and this permission notice shall be included in all
dnl copies or substantial portions of the Software.
dnl
dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
dnl AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
dnl OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
dnl SOFTWARE.
AC_INIT(colm, 0.14.1)
PUBDATE="April 2020"
COLM_VERSION="0.14.1"
COLM_PUBDATE="April 2020"
AM_INIT_AUTOMAKE([foreign])
: ${CFLAGS="-Wall -g"}
: ${CXXFLAGS="-Wall -g"}
AC_CONFIG_MACRO_DIR([m4])
AC_SUBST(PUBDATE)
AC_SUBST(COLM_VERSION)
AC_SUBST(COLM_PUBDATE)
AC_CHECK_SIZEOF([int])
AC_CHECK_SIZEOF([void *])
AC_CHECK_SIZEOF([long])
AC_CHECK_SIZEOF([unsigned long])
AC_CHECK_SIZEOF([unsigned long long])
AC_CHECK_HEADERS([sys/mman.h sys/wait.h unistd.h])
dnl Checks for programs.
AC_PROG_CC
AC_PROG_CXX
AC_CHECK_TOOL(AR, ar)
AC_PROG_RANLIB
AC_PROG_LIBTOOL
SED_SUBST=["\
-e 's|@CXX@|${CXX}|g' \
-e 's|@CC@|${CC}|g' \
-e 's|@prefix@|${prefix}|g' \
"]
dnl Set test on c++ compiler.
AC_LANG_CPLUSPLUS
dnl
dnl libfsmincludedir
dnl
libfsmincludedir='${includedir}/libfsm/'
AC_SUBST(libfsmincludedir)
SED_SUBST="$SED_SUBST -e 's|[@]libfsmincludedir[@]|$libfsmincludedir|g'"
dnl
dnl aaplincludedir
dnl
aaplincludedir='${includedir}/aapl/'
AC_SUBST(aaplincludedir)
SED_SUBST="$SED_SUBST -e 's|[@]aaplincludedir[@]|$aaplincludedir|g'"
dnl Check for definition of MAKE.
AC_PROG_MAKE_SET
AC_ARG_ENABLE(pool-malloc,
AC_HELP_STRING([--enable-pool-malloc], [allocate pool objects with malloc]),
AC_DEFINE([POOL_MALLOC], [1], [allocate pool objects with malloc]))
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [enable debug statements]),
AC_DEFINE([DEBUG], [1], [enable debug statements]))
AC_CHECK_PROG([ASCIIDOC], [asciidoc], [asciidoc])
AC_CHECK_PROG([PYGMENTIZE], [pygmentize], [pygmentize])
AM_CONDITIONAL([BUILD_MANUAL], [test "x$ASCIIDOC" != x && test "x$PYGMENTIZE" != x])
dnl Choose a default for the build_manual var. If the dist file is present in
dnl the root then default to no, otherwise go for it.
AC_CHECK_FILES( [$srcdir/DIST],
[. $srcdir/DIST;],
[build_manual=yes; ] )
dnl
dnl Enable arg to explicitly control the building of the manual
dnl
AC_ARG_ENABLE(manual,
[ --enable-manual do we want to build the manual?],
[
if test "x$enableval" = "xyes"; then
build_manual=yes;
else
build_manual=no;
fi
],
)
dnl Checks to carry out if we are building the manual.
dnl if test "x$build_manual" = "xyes"; then
dnl AC_CHECK_PROG(FIG2DEV, fig2dev, fig2dev)
dnl if test -z "$FIG2DEV"; then
dnl echo
dnl echo "error: fig2dev is required to build the manual (maybe use --disable-manual)"
dnl echo
dnl exit 1
dnl fi
dnl
dnl AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex)
dnl if test -z "$PDFLATEX"; then
dnl echo
dnl echo "error: pdflatex is required to build the manual (maybe use --disable-manual)"
dnl echo
dnl exit 1
dnl fi
dnl fi
dnl Set to true if the manual should be built.
AM_CONDITIONAL(BUILD_MANUAL, [test "x$build_manual" = "xyes"])
dnl
dnl Build the program? ( no means just build libfsm )
dnl
AC_ARG_ENABLE(program,
[AC_HELP_STRING([--enable-program], [build the program? no means libfsm only] )],
[
if test "x$enableval" = "xyes"; then
build_program=yes;
else
build_program=no;
fi
],
[
build_program=yes;
]
)
AM_CONDITIONAL([BUILD_PROGRAM], [test "x$build_program" = "xyes"])
AM_CONDITIONAL([WITH_RAGEL_KELBT], [test "x$RAGEL_KELBT" = "xyes"])
dnl This is from ragel, but already have one above from colm. Need to merge.
dnl AM_CONDITIONAL([BUILD_MANUAL], [test "x$build_manual" = "xyes"])
AC_CANONICAL_HOST()
AM_CONDITIONAL([LINKER_NO_UNDEFINED], [test "x$host_os" = "xlinux-gnu"])
dnl
dnl Testing
dnl
dnl Which installed target to test. Without this option supplied testing is
dnl done against what is in the source tree.
dnl
AC_ARG_WITH(subject,
[AC_HELP_STRING([--with-subject], [location of install tree test (defaults source tree)])],
[
SUBJ_AAPL_CPPFLAGS="-I${withval}/include/aapl"
SUBJ_COLM_BIN="${withval}/bin/colm"
SUBJ_COLM_CPPFLAGS="-I${withval}/include"
SUBJ_COLM_LDFLAGS="-L${withval}/lib -Wl,-rpath,${withval}/lib"
SUBJ_RAGEL_BIN="$withval/bin/ragel"
SUBJ_RAGEL_CPPFLAGS="-I$withval/include"
SUBJ_RAGEL_LDFLAGS="-L$withval/lib -Wl,-rpath,${withval}/lib"
SUBJ_RAGEL_LM="${withval}/share"
SUBJ_RAGEL_C_BIN="$withval/bin/ragel-c"
SUBJ_RAGEL_D_BIN="$withval/bin/ragel-d"
SUBJ_RAGEL_JAVA_BIN="$withval/bin/ragel-java"
SUBJ_RAGEL_RUBY_BIN="$withval/bin/ragel-ruby"
SUBJ_RAGEL_CSHARP_BIN="$withval/bin/ragel-csharp"
SUBJ_RAGEL_GO_BIN="$withval/bin/ragel-go"
SUBJ_RAGEL_OCAML_BIN="$withval/bin/ragel-ocaml"
SUBJ_RAGEL_ASM_BIN="$withval/bin/ragel-asm"
SUBJ_RAGEL_RUST_BIN="$withval/bin/ragel-rust"
SUBJ_RAGEL_CRACK_BIN="$withval/bin/ragel-crack"
SUBJ_RAGEL_JULIA_BIN="$withval/bin/ragel-julia"
],
[
SUBJ_AAPL_CPPFLAGS='-I$(abs_top_builddir)/aapl'
SUBJ_COLM_BIN='$(abs_top_builddir)/src/colm'
SUBJ_COLM_CPPFLAGS='-I$(abs_top_builddir)/src/include'
SUBJ_COLM_LDFLAGS='-L$(abs_top_builddir)/src/.libs -Wl,-rpath,${abs_top_builddir}/src/.libs'
SUBJ_RAGEL_BIN='$(abs_top_builddir)/ragel/ragel'
SUBJ_RAGEL_CPPFLAGS='-I$(abs_top_builddir)/ragel/include -I$(abs_top_builddir)/aapl'
SUBJ_RAGEL_LDFLAGS='-L$(abs_top_builddir)/ragel/.libs -Wl,-rpath,$(abs_top_builddir)/ragel/.libs'
SUBJ_RAGEL_LM='$(abs_top_builddir)/ragel'
SUBJ_RAGEL_C_BIN='$(abs_top_builddir)/ragel/host-c/ragel-c'
SUBJ_RAGEL_D_BIN='$(abs_top_builddir)/ragel/host-d/ragel-d'
SUBJ_RAGEL_JAVA_BIN='$(abs_top_builddir)/ragel/host-java/ragel-java'
SUBJ_RAGEL_RUBY_BIN='$(abs_top_builddir)/ragel/host-ruby/ragel-ruby'
SUBJ_RAGEL_CSHARP_BIN='$(abs_top_builddir)/ragel/host-csharp/ragel-csharp'
SUBJ_RAGEL_GO_BIN='$(abs_top_builddir)/ragel/host-go/ragel-go'
SUBJ_RAGEL_OCAML_BIN='$(abs_top_builddir)/ragel/host-ocaml/ragel-ocaml'
SUBJ_RAGEL_ASM_BIN='$(abs_top_builddir)/ragel/host-asm/ragel-asm'
SUBJ_RAGEL_RUST_BIN='$(abs_top_builddir)/ragel/host-rust/ragel-rust'
SUBJ_RAGEL_CRACK_BIN='$(abs_top_builddir)/ragel/host-crack/ragel-crack'
SUBJ_RAGEL_JULIA_BIN='$(abs_top_builddir)/ragel/host-julia/ragel-julia'
]
)
SED_SUBST="$SED_SUBST -e 's|@SU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J_RAGEL_RUST_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@SUBJ_RAGEL_CRACK_BIN@|${SUBJ_RAGEL_CRACK_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@SUBJ_RAGEL_JULIA_BIN@|${SUBJ_RAGEL_JULIA_BIN}|g'"
AC_SUBST(SUBJ_AAPL_CPPFLAGS)
AC_SUBST(SUBJ_COLM_BIN)
AC_SUBST(SUBJ_COLM_CPPFLAGS)
AC_SUBST(SUBJ_COLM_LDFLAGS)
AC_SUBST(SUBJ_RAGEL_BIN)
AC_SUBST(SUBJ_RAGEL_CPPFLAGS)
AC_SUBST(SUBJ_RAGEL_LDFLAGS)
AC_SUBST(SUBJ_RAGEL_LM)
dnl
dnl Installed programs to test in
dnl
AC_PATH_PROG([D_BIN], [gdc-8])
if test "x$D_BIN" = x; then
AC_PATH_PROG([D_BIN], [gdc-7])
if test "x$D_BIN" = x; then
AC_PATH_PROG([D_BIN], [gdc-6])
if test "x$D_BIN" = x; then
AC_PATH_PROG([D_BIN], [gdc-5])
fi
fi
fi
AC_PATH_PROG([JAVAC_BIN], [javac])
dnl
dnl Java test cases are now requring a large virtual address space. On systems
dnl where this is limited by ulimit, java will fail to run.
dnl
if test "x$JAVAC_BIN" != x; then
echo 'class conftest { public static void main( String[] args ) { } }' > conftest.java
AC_MSG_CHECKING([checking if javac is able to compile programs ... ])
if sh -c "$JAVAC_BIN conftest.java" >>config.log 2>&1; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
JAVAC_BIN=""
fi
rm -f conftest.java conftest.class
fi
AC_PATH_PROG([RUBY_BIN], [ruby])
AC_PATH_PROG([CSHARP_BIN], [mcs])
AC_PATH_PROG([GO_BIN], [go])
AC_PATH_PROG([OCAML_BIN], [ocaml])
AC_PATH_PROG([RUST_BIN], [rustc])
AC_PATH_PROG([JULIA_BIN], [julia])
dnl
dnl Julia requires a large virtual address space. On systems where this is
dnl limited by ulimit, julia will fail to run.
dnl
if test "x$JULIA_BIN" != x; then
echo 'println( "can run julia programs" );' > conftest.jl
AC_MSG_CHECKING([checking if julia is able to run programs ... ])
if sh -c "$JULIA_BIN conftest.jl" >>config.log 2>&1; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
JULIA_BIN=""
fi
rm -f conftest.jl
fi
dnl We can run julia, now make sure we have 1.0
if test "x$JULIA_BIN" != x; then
AC_MSG_CHECKING([checking if julia is version 1.0 or later ... ])
dnl We assume the form "julia version X.X.X"
dnl 1. everything before the version number.
dnl 2. Remove trailing version.
dnl 3. Verify it is plain number greater than 1.
dnl Any failure comes out as empty string. Note the sed command is wrapped
dnl in [] so autotools do not interpret anything in it.
JULIA1="`$JULIA_BIN -v | sed ['s/[A-Za-z ]\+//g; s/\.[0-9\.]*//; /^[1-9][0-9]*/!d;']`"
if test "x$JULIA1" != x; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
JULIA_BIN=""
fi
fi
AC_PATH_PROG([GNUSTEP_CONFIG], [gnustep-config])
dnl
dnl The ASM tests have been based off of sources that are non-relocatable
dnl These won't assemble on some systems (with the right architecture). Check
dnl our specific flavour of ASM now so we can avoid some test failures.
dnl
ASM_BIN=$CC
cat <<\EOF > conftest.s
.section .rodata
.L_works:
.string "works"
.text
.globl main
main:
pushq %rbp
movq %rsp, %rbp
pushq %rdi
movq $.L_works, %rdi
call puts
popq %rdi
mov $0, %rax
ret
EOF
AC_MSG_CHECKING([checking if ragel ASM tests will build ... ])
if sh -c "$ASM_BIN -o conftest.bin conftest.s" >>config.log 2>&1; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
ASM_BIN=""
fi
rm -f conftest.s
SED_SUBST="$SED_SUBST -e 's|@D_BIN@|${D_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@JAVAC_BIN@|${JAVAC_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@RUBY_BIN@|${RUBY_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@CSHARP_BIN@|${CSHARP_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@GO_BIN@|${GO_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@OCAML_BIN@|${OCAML_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@RUST_BIN@|${RUST_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@JULIA_BIN@|${JULIA_BIN}|g'"
SED_SUBST="$SED_SUBST -e 's|@GNUSTEP_CONFIG@|${GNUSTEP_CONFIG}|g'"
SED_SUBST="$SED_SUBST -e 's|@ASM_BIN@|${ASM_BIN}|g'"
AC_ARG_WITH(crack,
[AC_HELP_STRING([--with-crack], [location of crack install])],
[CRACK_BIN="$withval/bin/crack"],
[AC_PATH_PROG([CRACK_BIN], [crack])]
)
SED_SUBST="$SED_SUBST -e 's|@CRACK_BIN@|${CRACK_BIN}|g'"
AC_SUBST(CRACK_BIN)
dnl Skip bootstrap process and build using an existing version of colm. Allows us to
dnl break colm without breaking the build of colm.
dnl
dnl WARNING: DO NOT USE FOR PRODUCTION BUILD
dnl
dnl Only use this when you need to in order to get colm to build. Using an external
dnl colm program (and library) has the consequence that parsing of patterns and
dnl constructors in colm programs will also use this external library, since there
dnl can only be one set of colm functions linked. It's not possible to use the
dnl external parser for parsing the colm program, then use the internal parser for
dnl the patterns.
AC_ARG_WITH(colm,
[AC_HELP_STRING([--with-colm], [prefix of colm install to build with, instead of bootstrapping])],
[
EXTERNAL_COLM="$withval"
EXTERNAL_INC="-I$withval/include"
EXTERNAL_LIBS="-L$withval/lib"
AC_CHECK_FILES(["$EXTERNAL_COLM/bin/colm"], [],
[AC_ERROR(["could not find $EXTERNAL_COLM/bin/colm"])])
],
[]
)
AM_CONDITIONAL([EXTERNAL_COLM], [test "x$EXTERNAL_COLM" != x])
AC_SUBST(EXTERNAL_COLM)
AC_SUBST(EXTERNAL_INC)
AC_SUBST(EXTERNAL_LIBS)
dnl
dnl Wrap up.
dnl
AC_SUBST(SED_SUBST)
AC_CONFIG_HEADERS([src/config.h src/defs.h])
AC_OUTPUT([
Makefile
aapl/Makefile
libfsm/Makefile
src/Makefile
cgil/Makefile
test/Makefile
test/aapl.d/Makefile
test/colm.d/Makefile
test/rlhc.d/Makefile
test/rlparse.d/Makefile
test/trans.d/Makefile
doc/Makefile
doc/colm/Makefile
])
echo "configuration of colm complete"
|