lib/sod-hosted.c (sod_makev): Use two statements rather than tricky expression.
[sod] / configure.ac
CommitLineData
97a9a385
MW
1dnl -*-autoconf-*-
2dnl
3dnl Configuration script for SOD
4dnl
5dnl (c) 2015 Straylight/Edgeware
6dnl
7
8dnl----- Licensing notice ---------------------------------------------------
9dnl
e0808c47 10dnl This file is part of the Sensible Object Design, an object system for C.
97a9a385
MW
11dnl
12dnl SOD is free software; you can redistribute it and/or modify
13dnl it under the terms of the GNU General Public License as published by
14dnl the Free Software Foundation; either version 2 of the License, or
15dnl (at your option) any later version.
16dnl
17dnl SOD is distributed in the hope that it will be useful,
18dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
19dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20dnl GNU General Public License for more details.
21dnl
22dnl You should have received a copy of the GNU General Public License
23dnl along with SOD; if not, write to the Free Software Foundation,
24dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26dnl--------------------------------------------------------------------------
27dnl Initialization.
28
29mdw_AUTO_VERSION
30AC_INIT([sod], AUTO_VERSION, [mdw@distorted.org.uk])
31AC_CONFIG_SRCDIR([lib/sod.h])
32AC_CONFIG_AUX_DIR([config])
33AM_INIT_AUTOMAKE([foreign])
34mdw_SILENT_RULES
35
36AC_PROG_CC
37AM_PROG_LIBTOOL
38AX_CFLAGS_WARN_ALL
39mdw_LIBTOOL_VERSION_INFO
40
41dnl--------------------------------------------------------------------------
58a95090
MW
42dnl Convert the version number for ASDF.
43
44## This is surprisingly awful. The convention for official version numbers
31194ea5
MW
45## is that they look like [MAJOR.MINOR.PATCH~]MAJOR.MINOR.PATCH[.BPB]
46## [-N-gHEX[+]]. ASDF insists on simple numeric things separated by dots.
47## If there's no interim-version thing on the front or Git thing on the end,
48## then the main version number will do fine. If there is, then we insert
49## /two/ `0's in, followed by N and the HEX converted to decimal. Why two?
50## Because if there's no brown-paper-bag number, we want to make sure that
51## the first BPB release is higher than any of the preceding Git revisions.
58a95090
MW
52ver=AC_PACKAGE_VERSION
53case $ver in
54 *-*-g*)
31194ea5
MW
55 case $ver in
56 *~*) pre=${ver%%~*}. tail=${ver#*~} ;;
57 *) pre= tail=$ver ;;
58 esac
59 base=${tail%%-*} tail=${tail#*-}
58a95090 60 n=${tail%%-*} tail=${tail#*-g}
31194ea5 61 case $tail in *+) grubby=.0.1 tail=${tail%+} ;; *) grubby= ;; esac
58a95090 62 rev=$(( 0x$tail ))
31194ea5 63 ASDF_VERSION=$pre$base.0.0.$n.$rev$grubby
58a95090
MW
64 ;;
65 *)
66 ASDF_VERSION=$ver
67 ;;
68esac
69AC_SUBST([ASDF_VERSION])
70
71dnl--------------------------------------------------------------------------
97a9a385
MW
72dnl Common Lisp things.
73
74AC_ARG_WITH([lisp-system],
75 [AS_HELP_STRING([--with-lisp-system=SYSTEMS],
76 [preference order of cl-launch Lisp systems])],
77 [], [with_lisp_system="sbcl clisp"])
78
79AC_CHECK_PROGS([CL_LAUNCH], [cl-launch], [not-found])
80case "$CL_LAUNCH" in
81 not-found) AC_MSG_ERROR([\`cl-launch' not found]) ;;
82esac
83
84AC_MSG_CHECKING([for best choice of Lisp system])
85if ! LISPSYS=$($CL_LAUNCH -l "$with_lisp_system" \
86 -ip '(string-downcase (lisp-implementation-type))'); then
87 AC_MSG_ERROR([cl-launch didn't like any Lisp system])
88fi
89AC_SUBST([LISPSYS])
90AC_MSG_RESULT([$LISPSYS])
91
92AC_MSG_CHECKING([FASL file extension])
5e6bcea3 93fasl=$($CL_LAUNCH -l $LISPSYS -ip \
97a9a385 94 '(pathname-type (compile-file-pathname "foo.lisp"))')
5e6bcea3
MW
95AC_SUBST([fasl])
96AC_MSG_RESULT([.$fasl])
97a9a385
MW
97
98AC_ARG_WITH([lisp-source-dir],
99 [AS_HELP_STRING([--with-lisp-source-dir=DIR],
100 [where to install Common Lisp source files])],
101 [], [with_lisp_source_dir='${datadir}/common-lisp/source'])
102AC_ARG_WITH([lisp-system-dir],
103 [AS_HELP_STRING([--with-lisp-system-dir=DIR],
104 [where to install ASDF system links])],
105 [], [with_lisp_system_dir='${datadir}/common-lisp/systems'])
106AC_SUBST([lispsrcdir], [$with_lisp_source_dir])
107AC_SUBST([lispsysdir], [$with_lisp_system_dir])
108
109dnl--------------------------------------------------------------------------
b20e5e26
MW
110dnl TeX things.
111
112AC_DEFUN([SOD_CHECK_LATEX_FILE],
113 [sod_thing="$1"; case $sod_thing in
114 *.sty) sod_thing=${sod_thing%.sty} sod_what=package ;;
115 *.cls) sod_thing=${sod_thing%.cls} sod_what="document class" ;;
116 *.tfm) sod_thing=${sod_thing%.tfm} sod_what="font metrics" ;;
117 *) sod_what="file" ;;
118 esac
119 AS_VAR_PUSHDEF([SOD_Pkg], [sod_cv_latex_$1])
120 AC_CACHE_CHECK([for LaTeX `$sod_thing' $sod_what],
121 [SOD_Pkg],
122 [if $KPSEWHICH >/dev/null 2>&1 --progname=pdflatex $1
123 then SOD_Pkg=yes
124 else SOD_Pkg=no; fi])
125 case $SOD_Pkg in
126 yes) m4_default([$2], [:]) ;;
127 no) m4_default([$3], [AC_MSG_ERROR([Can't find `$1'])]) ;;
128 esac
129 AS_VAR_POPDEF([SOD_Pkg])])
130
131dnl See if we want to build the documentation.
132AC_ARG_ENABLE([manual], [AS_HELP_STRING([--enable-manual])],
133 [if test "$enableval" = "no"
134 then sod_want_latex=no sod_have_latex=no
135 else sod_want_latex=must sod_have_latex=maybe; fi],
136 [sod_want_latex=maybe sod_have_latex=maybe])
137
138dnl Make sure the TeX programs we need are available.
139case $sod_have_latex in maybe)
d892b0c3 140AC_CHECK_PROGS([TEX], [tex], [none])
b20e5e26
MW
141AC_CHECK_PROGS([PDFLATEX], [pdflatex], [none])
142AC_CHECK_PROGS([KPSEWHICH], [kpsewhich], [none])
143AC_CHECK_PROGS([BIBTEX], [bibtex], [none])
144AC_CHECK_PROGS([MAKEINDEX], [makeindex], [none])
d892b0c3 145case ,$TEX,$PDFLATEX,$KPSEWHICH,$BIBTEX,$MAKEINDX, in
b20e5e26
MW
146 *,none,*)
147 AC_MSG_WARN([Necessary TeX programs not found: can't build manual!])
148 sod_have_latex=no
149 ;;
150esac
151;; esac
152
d892b0c3 153sod_have_custom_bib=no
b20e5e26
MW
154case $sod_have_latex in maybe)
155SOD_CHECK_LATEX_FILE([strayman.cls], [], [sod_have_latex=no])
156SOD_CHECK_LATEX_FILE([fontenc.sty], [], [sod_have_latex=no])
157SOD_CHECK_LATEX_FILE([inputenc.sty], [], [sod_have_latex=no])
158SOD_CHECK_LATEX_FILE([longtable.sty], [], [sod_have_latex=no])
159SOD_CHECK_LATEX_FILE([makeidx.sty], [], [sod_have_latex=no])
160SOD_CHECK_LATEX_FILE([amssymb.sty], [], [sod_have_latex=no])
161SOD_CHECK_LATEX_FILE([tikz.sty], [], [sod_have_latex=no])
162SOD_CHECK_LATEX_FILE([at.sty], [], [sod_have_latex=no])
163SOD_CHECK_LATEX_FILE([footnote.sty], [], [sod_have_latex=no])
164SOD_CHECK_LATEX_FILE([mdwfonts.sty], [], [sod_have_latex=no])
165SOD_CHECK_LATEX_FILE([mdwref.sty], [], [sod_have_latex=no])
166SOD_CHECK_LATEX_FILE([mdwtab.sty], [], [sod_have_latex=no])
167SOD_CHECK_LATEX_FILE([mdwthm.sty], [], [sod_have_latex=no])
168SOD_CHECK_LATEX_FILE([sverb.sty], [], [sod_have_latex=no])
169SOD_CHECK_LATEX_FILE([syntax.sty], [], [sod_have_latex=no])
170
171SOD_CHECK_LATEX_FILE([cmr12.tfm], [], [sod_have_latex=no])
172SOD_CHECK_LATEX_FILE([cmbx10.tfm], [], [sod_have_latex=no])
173SOD_CHECK_LATEX_FILE([cmcsc10.tfm], [], [sod_have_latex=no])
174SOD_CHECK_LATEX_FILE([cmex10.tfm], [], [sod_have_latex=no])
175SOD_CHECK_LATEX_FILE([cmmi12.tfm], [], [sod_have_latex=no])
176SOD_CHECK_LATEX_FILE([cmsy10.tfm], [], [sod_have_latex=no])
177SOD_CHECK_LATEX_FILE([cmti10.tfm], [], [sod_have_latex=no])
178SOD_CHECK_LATEX_FILE([msam10.tfm], [], [sod_have_latex=no])
179SOD_CHECK_LATEX_FILE([msbm10.tfm], [], [sod_have_latex=no])
180SOD_CHECK_LATEX_FILE([ecrm1000.tfm], [], [sod_have_latex=no])
181SOD_CHECK_LATEX_FILE([logo10.tfm], [], [sod_have_latex=no])
182SOD_CHECK_LATEX_FILE([pplr8r.tfm], [], [sod_have_latex=no])
183SOD_CHECK_LATEX_FILE([pplri8r.tfm], [], [sod_have_latex=no])
184SOD_CHECK_LATEX_FILE([pplb8r.tfm], [], [sod_have_latex=no])
185SOD_CHECK_LATEX_FILE([phvr8r.tfm], [], [sod_have_latex=no])
186SOD_CHECK_LATEX_FILE([phvb8r.tfm], [], [sod_have_latex=no])
187SOD_CHECK_LATEX_FILE([pcrr8rn.tfm], [], [sod_have_latex=no])
188
d892b0c3
MW
189SOD_CHECK_LATEX_FILE([merlin.mbs], [sod_have_custom_bib=yes], [:])
190
b20e5e26
MW
191case $sod_have_latex in
192 no)
193 AC_MSG_WARN([Necessary LaTeX packages not found: can't build manual!])
194 ;;
195esac
196;; esac
197
198case $sod_want_latex,$sod_have_latex in
199 must,no)
200 AC_MSG_ERROR([Couldn't find necessary LaTeX support to build manual!])
201 ;;
202 *,maybe)
203 sod_have_latex=yes
204 ;;
205esac
206AM_CONDITIONAL([HAVE_LATEX], [test "$sod_have_latex" = "yes"])
d892b0c3 207AM_CONDITIONAL([HAVE_CUSTOM_BIB], [test "$sod_have_custom_bib" = "yes"])
b20e5e26
MW
208
209dnl--------------------------------------------------------------------------
97a9a385
MW
210dnl Output.
211
3f725f73
MW
212AC_CONFIG_FILES(
213 [Makefile]
214 [src/Makefile]
215 [lib/Makefile]
216 [doc/Makefile]
217 [test/Makefile])
97a9a385
MW
218AC_OUTPUT
219
220dnl----- That's all, folks --------------------------------------------------