Versio 0.0.2 initial check in

Sat, 04 Aug 2018 21:19:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 04 Aug 2018 21:19:15 +0200
changeset 0
033898178630
child 1
37f1a08315f3

Versio 0.0.2 initial check in

.hgignore file | annotate | diff | comparison | revisions
COPYING file | annotate | diff | comparison | revisions
Makefile file | annotate | diff | comparison | revisions
Makefile.global.in file | annotate | diff | comparison | revisions
README.design file | annotate | diff | comparison | revisions
aclocal.m4 file | annotate | diff | comparison | revisions
bmsd/Makefile file | annotate | diff | comparison | revisions
bmsd/bms.c file | annotate | diff | comparison | revisions
bmsd/bms.h file | annotate | diff | comparison | revisions
bmsd/fermenters.c file | annotate | diff | comparison | revisions
bmsd/fermenters.h file | annotate | diff | comparison | revisions
bmsd/futil.c file | annotate | diff | comparison | revisions
bmsd/futil.h file | annotate | diff | comparison | revisions
bmsd/header file | annotate | diff | comparison | revisions
bmsd/lock.c file | annotate | diff | comparison | revisions
bmsd/lock.h file | annotate | diff | comparison | revisions
bmsd/mqtt.c file | annotate | diff | comparison | revisions
bmsd/mqtt.h file | annotate | diff | comparison | revisions
bmsd/mysql.c file | annotate | diff | comparison | revisions
bmsd/mysql.h file | annotate | diff | comparison | revisions
bmsd/nodes.c file | annotate | diff | comparison | revisions
bmsd/nodes.h file | annotate | diff | comparison | revisions
bmsd/rdconfig.c file | annotate | diff | comparison | revisions
bmsd/rdconfig.h file | annotate | diff | comparison | revisions
bmsd/xutil.c file | annotate | diff | comparison | revisions
bmsd/xutil.h file | annotate | diff | comparison | revisions
config.h.in file | annotate | diff | comparison | revisions
config.log file | annotate | diff | comparison | revisions
config.status file | annotate | diff | comparison | revisions
configure file | annotate | diff | comparison | revisions
configure.ac file | annotate | diff | comparison | revisions
doc/Makefile file | annotate | diff | comparison | revisions
doc/bms-ch1.sgml file | annotate | diff | comparison | revisions
doc/bms-ch2.sgml file | annotate | diff | comparison | revisions
doc/bms-ch3.sgml file | annotate | diff | comparison | revisions
doc/bms-flow.png file | annotate | diff | comparison | revisions
doc/bms.sgml file | annotate | diff | comparison | revisions
doc/docbook-utils.dsl file | annotate | diff | comparison | revisions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,15 @@
+Makefile.global
+config.h
+config.log
+config.status
+stamp-h
+autom4te.cache
+.filelist
+bmsd/bmsd
+doc/bms.pdf
+
+syntax: glob
+*.o
+*/filelist
+tools/*
+Makefile.bak
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,32 @@
+# Top-level makefile for bms.
+
+include Makefile.global
+
+OTHER		= ChangeLog COPYING Makefile Makefile.global.in aclocal.m4 \
+		  config.h.in configure configure.ac
+TARFILE		= ${PACKAGE}-${VERSION}.tar.bz2
+
+###############################################################################
+
+
+all depend:
+		for d in ${SUBDIRS}; do (cd $$d && ${MAKE} $@) || exit; done;
+
+install:
+		for d in ${SUBDIRS}; do (cd $$d && ${MAKE} $@) || exit; done;
+
+dist tar:	${TARFILE}
+
+clean:
+		for d in ${SUBDIRS}; do (cd $$d && ${MAKE} $@) || exit; done;
+		rm -f .filelist core ${TARFILE} config.h Makefile.global
+
+${TARFILE}:	.filelist
+		cd ..; ln -s ${PACKAGE} ${PACKAGE}-${VERSION} ; rm -f ${TARFILE}; \
+		${TAR} cvTf ./${PACKAGE}-${VERSION}/.filelist - | bzip2 >${TARFILE} ; \
+		rm -f ${PACKAGE}-${VERSION}
+
+.filelist filelist:
+		(for f in ${OTHER} ;do echo ${PACKAGE}-${VERSION}/$$f; done) >.filelist
+		for d in ${SUBDIRS}; do (cd $$d && ${MAKE} filelist && cat filelist >>../.filelist) || exit; done;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.global.in	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,28 @@
+# Compile-time configuration for bms.
+
+VERSION		= @VERSION@
+PACKAGE		= @PACKAGE@
+
+# for make install, where to put binaries and what owner to set
+SUBDIRS		= @SUBDIRS@
+PREFIX		= @prefix@
+BINDIR		= @prefix@/bin
+ETCDIR		= @prefix@/etc
+DOCDIR		= @prefix@/doc
+VARDIR		= @prefix@/var
+DATADIR		= @prefix@/share/@PACKAGE@/
+
+INSTALL		= @INSTALL@
+SHELL		= /bin/sh
+ECHO		= echo -e
+CC		= @CC@
+TAR		= @TAR@
+RANLIB		= @RANLIB@
+
+CFLAGS		= @CFLAGS@
+CXXFLAGS	= @CXXFLAGS@
+LIBS		= @LIBS@
+
+SDL_CFLAGS	= @SDL_CFLAGS@
+SDL_LIBS	= @SDL_LIBS@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.design	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,82 @@
+Centrale daemon 'bmsd' regelt de dagelijkse berichten tussen MQTT en de
+database. Om deze berichten betrouwbaar af te handelen is MQTT er tussen
+gezet.
+Alle sensoren en controllers communiceren uitsluitend via MQTT.
+
+Sensoren en controllers:
+
+  1.  Vergisting controllers.
+  2.  Temperatuur loggen.
+  3.  Hergisting drukmeters. (druk + temp).
+  4.  Brouw controllers.
+  5.  Ispindel.
+
+
+Stappen:
+
+  1.  Importeren oude vergisting en brouw logs.  DONE.
+  2.  Thermferm moet DLOG berichten gaan sturen, per wijziging en per 5 minuten.  DONE.
+  3.  bmsd moet deze DLOG berichten verwerken. Versie 0.0.2. Bier producten in database. DONE.
+  4.  Versie 0.0.2 handmatig installeren op productie. DONE.
+  5.  Thermferm uitbreiden met vergisting stage. DONE.
+  6.  Brouw controller uitbreiden met MQTT.
+  7.  bmsd uitbreiden met brouw controller berichten.
+  8.  bmsd productie platform upgraden, versie 0.0.3
+
+
+Web interface bouwen met jqwidgets, breeze en knockout.
+
+
+Database:
+
+  1.  Recepten opslaan in json formaat omdat dit flexibel is.
+  2.  Brouwsels zijn recepten plus extra gegegevens. json formaat.
+  3.  Inventaris ingredienten in json. Voorraad historie is extra arrays.
+  4.  Export naar beerxml.
+  5.  Import van brouwhulp xml met sync vanuit backup locatie.
+  6.  Brouwerij configuratie voornamelijk in json.
+
+
+MQTT structuur volgens Sparkplug model.
+
+mbv1.0/fermenters/[NBIRTH,DBIRTH]/<hostname>/
+mbv1.0/fermenters/DDATA/<hostname>/<unitalias>/
+
+---------------------------------------------------------------------------
+
+namespace/group_id/message_type/edge_node_id/{device_id}
+
+namespace is de root, "mbv1.0"
+
+group_id oa: fermenters, brewcontrol, env_sensor
+
+message_type:	NBIRTH	- Birth certificate for MQTT EoN nodes.
+		NDEATH	- Death certificate for MQTT EoN nodes.
+		NCMD	- Node command message.
+		DBIRTH	- Birth certificate for devices.
+		DDEATH	- Death certificate for devices.
+		NDATA	- Node data message.
+		DDATA	- Device data message.
+		DLOG	- Device data logging.
+		DCMD	- Device command message.
+		STATE	- Critical application state message.
+
+NCMD:	reboot (application restart)
+	rebirth
+
+DCMD:	fermenter state change + temperature settings.
+	fermenter profile install.
+	fermenter load product.
+	fermenter set stage
+
+
+Product: code en naam.
+	BIRTH date
+	Recept.
+	Locatie: Plan - Wacht - Brouw - Vergisting - Verpakken - Hergisting - Rijpen - Proeven - Afgesloten.
+	                          |         |            |           |
+	                          |         |            |           +--------	Log/rapport
+	                          |         |            +--------------------	rapport/etiketten
+	                          |         +---------------------------------	Log/rapport
+	                          +-------------------------------------------	Log/rapport
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aclocal.m4	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,26 @@
+# generated automatically by aclocal 1.11.5 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+# Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/Makefile	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,65 @@
+# Makefile for the mbsePi-apps/thermferm.
+
+include ../Makefile.global
+
+SRCS		= $(wildcard *.c)
+HDRS		= $(wildcard *.h)
+OBJS		= $(SRCS:.c=.o)
+SLIBS		= -lpthread
+TARGET		= bmsd
+OTHER		= Makefile
+
+#############################################################################
+
+.c.o:
+		${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $<
+
+all:		${TARGET}
+
+bmsd:		${OBJS} ${SLIBS}
+		${CC} -o bmsd ${OBJS} ${LDFLAGS} ${LIBS} ${SLIBS}
+
+clean:
+		rm -f ${TARGET} *.o *.h~ *.c~ core filelist Makefile.bak
+
+install:	all
+		${INSTALL} -c -s -g root -o root -m 0755 bmsd ${BINDIR}
+
+filelist:	Makefile
+		BASE=`pwd`; \
+		BASE=`basename $${BASE}`; \
+		(for f in ${SRCS} ${HDRS} ${OTHER} ;do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist
+
+depend:
+	@rm -f Makefile.bak; \
+	mv Makefile Makefile.bak; \
+	sed -e '/^# DO NOT DELETE/,$$d' Makefile.bak >Makefile; \
+	${ECHO} '# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT' \
+		>>Makefile; \
+	${ECHO} '# Dependencies generated by make depend' >>Makefile; \
+	for f in ${SRCS}; \
+	do \
+		${ECHO} "Dependencies for $$f:\c"; \
+		${ECHO} "`basename $$f .c`.o:\c" >>Makefile; \
+		for h in `sed -n -e \
+			's/^#[ 	]*include[ 	]*"\([^"]*\)".*/\1/p' $$f`; \
+		do \
+			${ECHO} " $$h\c"; \
+			${ECHO} " $$h\c" >>Makefile; \
+		done; \
+		${ECHO} " done."; \
+		${ECHO} "" >>Makefile; \
+	done; \
+	${ECHO} '# End of generated dependencies' >>Makefile
+
+# DO NOT DELETE THIS LINE - MAKE DEPEND RELIES ON IT
+# Dependencies generated by make depend
+mqtt.o: bms.h xutil.h mqtt.h nodes.h
+nodes.o: bms.h xutil.h nodes.h mysql.h
+futil.o: bms.h futil.h
+lock.o: lock.h bms.h futil.h
+bms.o: bms.h xutil.h rdconfig.h lock.h mqtt.h mysql.h
+xutil.o: bms.h xutil.h
+rdconfig.o: bms.h xutil.h futil.h rdconfig.h
+mysql.o: bms.h xutil.h mysql.h
+# End of generated dependencies
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/bms.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,237 @@
+/*****************************************************************************
+ * Copyright (C) 2017-2018
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "bms.h"
+#include "xutil.h"
+#include "rdconfig.h"
+#include "lock.h"
+#include "mqtt.h"
+#include "mysql.h"
+
+
+int			my_shutdown = FALSE;
+int			debug = FALSE;
+static pid_t		pgrp, mypid;
+char			*Private_Path = NULL;	/* Users data path		*/
+//char			*resource_path = NULL;	/* Webserver root		*/
+
+//extern struct lws_context *context;
+
+
+void help(void)
+{
+    fprintf(stdout, "bmsd v%s starting\n\n", VERSION);
+    fprintf(stdout, "Usage: bmsd [-d] [-h]\n");
+    fprintf(stdout, "  -d --debug              Debug and run in foreground\n");
+    fprintf(stdout, "  -h --help               Display this help\n");
+}
+
+
+
+void die(int onsig)
+{
+    switch (onsig) {
+	case SIGHUP:    syslog(LOG_NOTICE, "Got SIGHUP, shutting down");
+			break;
+	case SIGINT:    syslog(LOG_NOTICE, "Keyboard interrupt, shutting down");
+			break;
+	case SIGTERM:   syslog(LOG_NOTICE, "Got SIGTERM, shutting down");
+			break;
+	case SIGSEGV:   syslog(LOG_NOTICE, "Got SIGSEGV, shutting down");
+			my_shutdown = TRUE;
+			exit(SIGSEGV);
+			break;
+	default:        syslog(LOG_NOTICE, "die() on signal %d", onsig);
+    }
+    my_shutdown = TRUE;
+}
+
+
+
+int server(void) {
+    uid_t               myuid;
+    struct passwd       *mypwd;
+    int			rc = 0;
+
+    myuid = getuid();
+    mypwd = getpwuid(myuid);
+    if (mypwd == NULL) {
+	fprintf(stderr, "[main] Could not find passwd entry\n");
+	return 1;
+    }
+
+    Private_Path = xstrcpy(mypwd->pw_dir);
+    Private_Path = xstrcat(Private_Path, (char *)"/.bms");
+
+    if (lockprog((char *)"bmsd")) {
+	syslog(LOG_NOTICE, "Can't lock");
+	return 1;
+    }
+
+    if (rdconfig()) {
+	rc = 2;
+	goto endit1;
+    }
+
+    if (bms_mysql_init()) {
+	rc = 3;
+	goto endit1;
+    }
+    if (mqtt_connect()) {
+	rc = 4;
+	goto endit2;
+    }
+
+    if (debug)
+	fprintf(stdout, "[main] Entering main loop\n");
+
+    while (my_shutdown == FALSE) {
+
+	usleep(100000);
+    }
+    if (debug)
+	fprintf(stdout, "[main] Exit from main loop\n");
+
+    /*
+     * Remove our topics and close MQTT connection.
+     */
+    mqtt_disconnect();
+
+endit2:
+    bms_mysql_end();
+
+endit1:
+
+    killconfig();
+
+    ulockprog((char *)"bmsd");
+
+    free(Private_Path);
+    Private_Path = NULL;
+
+    if (debug)
+	fprintf(stdout, "[main] Server shutdown complete\n");
+    return rc;
+}
+
+
+
+int main(int argc, char *argv[]) {
+    int		rc, c, i;
+    pid_t	frk;
+
+    while (1) {
+	int option_index = 0;
+	static struct option long_options[] = {
+	    {"debug", 0, 0, 'c'},
+	    {"help", 0, 0, 'h'},
+	    {0, 0, 0, 0}
+	};
+
+	c = getopt_long(argc, argv, "dh", long_options, &option_index);
+	if (c == -1)
+	    break;
+	switch (c) {
+	    case 'd':   debug = TRUE;
+			break;
+	    case 'h':   help();
+			return 1;
+	}
+    }
+
+    openlog("bmsd", LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_USER);
+    syslog(LOG_NOTICE, "bmsd v%s starting", VERSION);
+    if (debug)
+	fprintf(stdout, "bmsd v%s starting\n", VERSION);
+
+
+    /*
+     *  Catch all the signals we can, and ignore the rest. Note that SIGKILL can't be ignored
+     *  but that's live. This daemon should only be stopped by SIGTERM.
+     *  Don't catch SIGCHLD.
+     */
+    for (i = 0; i < NSIG; i++) {
+	if ((i != SIGCHLD) && (i != SIGKILL) && (i != SIGSTOP))
+	    signal(i, (void (*))die);
+    }
+
+    if (debug) {
+	/*
+	 * For debugging run in foreground.
+	 */
+	rc = server();
+    } else {
+	/*
+	 * Server initialization is complete. Now we can fork the 
+	 * daemon and return to the user. We need to do a setpgrp
+	 * so that the daemon will no longer be assosiated with the
+	 * users control terminal. This is done before the fork, so
+	 * that the child will not be a process group leader. Otherwise,
+	 * if the child were to open a terminal, it would become
+	 * associated with that terminal as its control terminal.
+	 */
+	if ((pgrp = setpgid(0, 0)) == -1) {
+	    syslog(LOG_NOTICE, "setpgpid failed");
+	}
+
+	frk = fork();
+	switch (frk) {
+	    case -1:    
+			syslog(LOG_NOTICE, "Daemon fork failed: %s", strerror(errno));
+			exit(1);
+	    case 0:     /*
+			 * Run the daemon
+			 */
+			fclose(stdin);
+			if (open("/dev/null", O_RDONLY) != 0) {
+			    syslog(LOG_NOTICE, "Reopen of stdin to /dev/null failed");
+			    _exit(2);
+			}
+			fclose(stdout);
+			if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 1) {
+			    syslog(LOG_NOTICE, "Reopen of stdout to /dev/null failed");
+			    _exit(2);
+			}
+			fclose(stderr);
+			if (open("/dev/null", O_WRONLY | O_APPEND | O_CREAT,0600) != 2) {
+			    syslog(LOG_NOTICE, "Reopen of stderr to /dev/null failed");
+			    _exit(2);
+			}
+			mypid = getpid();
+			rc = server();
+			break;
+			/* Not reached */
+	    default:
+			/*
+			 * Here we detach this process and let the child
+			 * run the deamon process.
+			 */
+			syslog(LOG_NOTICE, "Starting daemon with pid %d", frk);
+			exit(0);
+	}
+    }
+
+    syslog(LOG_NOTICE, "Finished, rc=%d", rc);
+    return rc;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/bms.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,285 @@
+/**
+ * @file bms.h
+ */
+
+#ifndef	_BMS_H
+#define	_BMS_H
+
+#define TRUE 1
+#define FALSE 0
+
+#include "../config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdarg.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/un.h>
+#include <sys/utsname.h>
+#include <pwd.h>
+#include <time.h>
+#include <fcntl.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <errno.h>
+#include <signal.h>
+#include <getopt.h>
+#include <limits.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <poll.h>
+#include <dirent.h>
+#include <uuid/uuid.h>
+#include <math.h>
+#include <assert.h>
+#include <libgen.h>
+#include <libxml/xmlmemory.h>
+#include <libxml/parser.h>
+#include <libxml/encoding.h>
+#include <libxml/xmlwriter.h>
+#include <mosquitto.h>
+#include <libwebsockets.h>
+#include <mysql/mysql.h>
+#include <json-c/json.h>
+
+
+#define MBSE_SS(x) (x)?(x):"(null)"
+
+
+#define MQTT_NODE_CONTROL	0x0001			///< Show node control
+
+
+
+/**
+ * @brief Configuration structure. Stored in a flat ascii file ~/.bms/bms.config
+ */
+typedef struct _sys_config {
+    char			*bms_name;		///< Brewery name
+    char			*bms_uuid;		///< Brewery uuid
+    char			*mysql_host;		///< MySQL host
+    int				mysql_port;		///< MySQL port
+    char			*mysql_user;		///< MySQL user name
+    char			*mysql_pass;		///< MySQL password
+    char			*mysql_database;	///< MySQL database
+    char			*mqtt_host;		///< MQTT host
+    int				mqtt_port;		///< MQTT port
+    char			*mqtt_user;		///< MQTT username of NULL
+    char			*mqtt_pass;		///< MQTT password of NULL
+} sys_config;
+
+
+/**
+ * @brief Structure for the nodes. Database table 'nodes'.
+ */
+typedef struct _sys_node_list {
+    struct _sys_node_list	*next;
+    char			*uuid;			///< uuid string
+    char			*node;			///< nodename
+    bool			online;			///< on-line state
+    char			*group_id;		///< group type
+    char			*hardwaremake;		///< hardware make
+    char			*hardwaremodel;		///< hardware model
+    char			*os;			///< os type
+    char			*os_version;		///< os version
+    char			*firmware;		///< application version
+    time_t			firstseen;		///< First seen this session
+    time_t			lastseen;		///< Last seen this session
+    float			temperature;		///< environment temperature
+    float			humidity;		///< environment humidity
+    float			barometer;		///< environment barometer pressure
+    float			gps_latitude;		///< GPS latitude
+    float			gps_longitude;		///< GPS longitude
+    float			gps_altitude;		///< GPS altitude
+    char			*net_address;		///< IPv4 or IPv6 address
+    char			*net_ifname;		///< Interface name
+    int				net_rssi;		///< RSSI value if wireless.
+} sys_node_list;
+
+
+/**
+ * @brief Fermenting profile steps
+ */
+typedef struct _prof_step {
+    struct _prof_step   	*next;
+    int                 	steptime;               ///< Step time to target in hours
+    int                 	resttime;               ///< Rest time on target in hours
+    float               	target_lo;              ///< Low Target temperature
+    float               	target_hi;              ///< High target temperature
+    int                 	fridge_mode;            ///< Fridge or beer mode
+} prof_step;
+
+
+typedef enum
+{
+    FERMENTER_MODE_OFF = 0,		///< Fermenter is off.
+    FERMENTER_MODE_NONE,		///< Fermenter on but does nothing.
+    FERMENTER_MODE_FRIDGE,		///< Fermenter acts as a fridge.
+    FERMENTER_MODE_BEER,		///< Fermenter acts as beer cooler.
+    FERMENTER_MODE_PROFILE,		///< Fermenter runs in profile mode.
+} FERMENTER_MODE;
+
+typedef enum
+{
+    FERMENTER_STAGE_PRIMARY = 0,	///< Fermentation primage stage.
+    FERMENTER_STAGE_SECONDARY,		///< Fermenter secondary stage.
+    FERMENTER_STAGE_TERTIARY,		///< Fermenter tertiary stage.
+} FERMENTER_STAGE;
+
+typedef enum
+{
+    DEVPRESENT_UNDEF = 0,		///< Precence not detectable.
+    DEVPRESENT_NO,			///< Device is missing.
+    DEVPRESENT_YES,			///< Device is present and Ok.
+    DEVPRESENT_ERROR,			///< Device is present but in error state.
+} DEVPRESENT_STATE;
+
+
+typedef enum
+{
+    ALARM_FLAG_DOOR	= 0x0001,	///< Door open
+    ALARM_FLAG_PSU	= 0x0002,	///< PSU problem
+    ALARM_FLAG_CHILLER	= 0x0100,	///< Chiller too warm
+} ALARM_FLAGS;
+
+
+/**
+ * @brief Structure for the fermenters. Stored in database table 'fermenters'.
+ */
+typedef struct _fermenter_list {
+    struct _fermenter_list	*next;
+    char			*uuid;			///< Fixed uuid string
+    char			*alias;			///< Fixed short name
+    char			*node;			///< Fixed node name
+    bool			online;			///< Online status
+    char			*beercode;		///< Beer unique code
+    char			*beername;		///< Beer name in fermenter
+    char			*air_address;		///< Air sensor address
+    char			*air_state;		///< Air sensor state
+    float			air_temperature;	///< Air temperature
+    char			*beer_address;		///< Beer sensor address
+    char			*beer_state;		///< Beer sensor state
+    float			beer_temperature;	///< Beer temperature
+    char			*chiller_address;	///< Chiller sensor address
+    char			*chiller_state;		///< Chiller sensor state
+    float			chiller_temperature;	///< Chiller temperature
+    char			*heater_address;	///< Heater address
+    int				heater_state;		///< Heater state
+    uint64_t			heater_usage;		///< Heater usage
+    char			*cooler_address;	///< Cooler address
+    int				cooler_state;		///< Cooler state
+    uint64_t			cooler_usage;		///> Cooler usage
+    char			*fan_address;		///< Fan address
+    int				fan_state;		///< Fan state
+    uint64_t			fan_usage;		///< Fan usage
+    char			*light_address;		///< Light address
+    int				light_state;		///< Light state
+    uint64_t			light_usage;		///< Light usage
+    char			*door_address;		///< Door address
+    int				door_state;		///< Door state
+    char 			*psu_address;		///< PSU address
+    int				psu_state;		///< PSU state
+    char			*mode;			///< Fermenter mode
+    char			*stage;			///< Fermentation stage
+    uint32_t			alarm;			///< Alarm flag
+    float			setpoint_high;		///< Setpoint high
+    float			setpoint_low;		///< Setpoint low
+    char			*profile_uuid;		///< Profile uuid
+    char			*profile_name;		///< Profile name
+    char			*profile_state;		///< Profile state
+    int				profile_percent;	///< Profile percent done
+    float			profile_inittemp_high;	///< Profile init temp high
+    float			profile_inittemp_low;	///< Profile init temp low
+    char			*profile_steps;		///< Profile steps in JSON
+} sys_fermenter_list;
+
+
+
+typedef enum
+{
+    PROFILE_OFF = 0,			///< Profile not active
+    PROFILE_PAUSE,               	///< Profile pause
+    PROFILE_RUN,               		///< Profile is running
+    PROFILE_DONE,               	///< Profile is finished
+    PROFILE_ABORT,               	///< Profile abort
+} PROFILE_STATE;
+
+
+
+/**
+ * @brief Strcuture holding a fermentation log entry.
+ */
+typedef struct fermenting_log {
+    char	*datetime;		///< Date/time stamp
+    char	*product_uuid;		///< Product uuid
+    char	*product_code;		///< Product code
+    char	*product_name;		///< Product name
+    float	temperature_air;	///< Temperature air
+    float	temperature_beer;	///< Temperature beer
+    float	temperature_chiller;	///< Temperature chiller (if pressent)
+    float	temperature_room;	///< Temperature room
+    int		heater_power;		///< Heater power 0..100
+    uint64_t	heater_usage;		///< Heater usage counter in seconds.
+    int		cooler_power;		///< Cooler power 0..100
+    uint64_t	cooler_usage;		///< Cooler usage counter in seconds.
+    int		fan_power;		///< Fan power 0 or 100
+    uint64_t	fan_usage;		///< Fan usage counter in seconds
+    float	setpoint_low;		///< Target temperature low
+    float	setpoint_high;		///< Tarhet temperature high
+    char	*mode;			///< Working mode.
+    char	*stage;			///< Fermentation stage
+    char	*event;			///< Optional event
+    char	*fermenter_uuid;	///< Fermenter in use
+    char	*fermenter_node;	///< Fermenter node
+    char	*fermenter_alias;	///< Fermenter_alias
+} fermentation_log;
+
+
+
+/**
+ * @brief Brew computer controllers. Must have hardware + installation + recipe data.
+ */
+typedef struct _brewer_list {
+    struct _brewer_list		*next;
+    char			*uuid;
+} brewer_list;
+
+
+// Make it universal and make it connectable with a fermenter.
+typedef struct _ispindel_list {
+    struct _ispindel_list	*next;
+    char			*uuid;			///< Fixed uuid string
+    char			*name;			///< Name or description (Red iSpindle).
+    char			*beercode;		///< Beer code if in use.
+    float			temperature;		///< Temperature of the beer.
+    float			gravity;		///< Measured gravity
+    							// What nore, battery?
+} ispindel_list;
+
+
+// Hergisting meters.
+
+/**
+ * @brief Standalone temperature loggers. (Freezers, refrigerators, chambers).
+ */
+typedef struct _thb_list {
+    struct _thb_list		*next;
+    char			*uuit;			///< Fixed uuid string
+    char			*name;			///< Name or description
+    char			*beercode;		///< Beer code if needed.
+    float			temperature;		///< Temperature in Celcius
+    float			humidity;		///< Humidity in %
+    float			barometer;		///< Air pressure.
+    float			gps_latitude;		///< GPS latitude
+    float			gps_longitude;		///< GPS longitide
+    float			gps_altitude;		///< GPS altitude
+} thb_list;
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/fermenters.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,635 @@
+/**
+ * @file fermenters.c
+ * @brief Handle fermenters status
+ * @author Michiel Broek <mbroek at mbse dot eu>
+ *
+ * Copyright (C) 2018
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+
+#include "bms.h"
+#include "xutil.h"
+#include "fermenters.h"
+#include "mysql.h"
+
+
+sys_fermenter_list	*fermenters = NULL;
+
+extern int		debug;
+
+
+
+
+void fermenter_set(char *edge_node, char *alias, bool birth, char *payload)
+{
+    struct json_object	*jobj, *val, *sensor, *temp;
+    sys_fermenter_list	*fermenter, *tmpp;
+    bool		new_fermenter = true;
+
+//    fprintf(stdout, "fermenter_set: %s/%s %s %s\n", edge_node, alias, birth ? "BIRTH":"DATA", payload);
+
+    /*
+     * Search fermenter record in the memory array and use it if found.
+     */
+    if (fermenters) {
+	for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
+	    if ((strcmp(tmpp->alias, alias) == 0) && (strcmp(tmpp->node, edge_node) == 0)) {
+		new_fermenter = false;
+		fermenter = tmpp;
+		break;
+	    }
+	}
+    }
+
+    if (! birth && new_fermenter) {
+	printf("ERROR got DDATA and fermenter %s/%s doesn't exist\n", edge_node, alias);
+	return;
+    }
+//printf("new_fermenter %s\n", new_fermenter ? "true":"false");
+
+    /*
+     * Allocate new fermenter if not yet known.
+     */
+    if (new_fermenter) {
+	fermenter = (sys_fermenter_list *)malloc(sizeof(sys_fermenter_list));
+	memset(fermenter, 0, sizeof(sys_fermenter_list));
+	fermenter->alias = xstrcpy(alias);
+	fermenter->node = xstrcpy(edge_node);
+	fermenter->mode = xstrcpy((char *)"OFF");
+	fermenter->stage = xstrcpy((char *)"PRIMARY");
+    }
+
+    fermenter->online = true;
+    if (birth) {
+	syslog(LOG_NOTICE, "Online fermenter %s/%s mode %s", edge_node, alias, fermenter->mode);
+    }
+
+    /*
+     * Process the JSON formatted payload. 
+     * Update only the fields that are found in the payload.
+     */
+    jobj = json_tokener_parse(payload);
+
+    if (json_object_object_get_ex(jobj, "uuid", &val)) {
+	if (fermenter->uuid)
+	    free(fermenter->uuid);
+	fermenter->uuid = xstrcpy((char *)json_object_get_string(val));
+    }
+    if (json_object_object_get_ex(jobj, "mode", &val)) {
+	if (fermenter->mode) {
+	    if (strcmp(fermenter->mode, (char *)json_object_get_string(val))) {
+		syslog(LOG_NOTICE, "Change mode fermenter %s/%s: %s to %s", edge_node, alias, fermenter->mode, (char *)json_object_get_string(val));
+	    }
+	    free(fermenter->mode);
+	}
+	fermenter->mode = xstrcpy((char *)json_object_get_string(val));
+    }
+    if (json_object_object_get_ex(jobj, "stage", &val)) {
+	if (fermenter->stage) {
+	    if (strcmp(fermenter->stage, (char *)json_object_get_string(val))) {
+		syslog(LOG_NOTICE, "Change stage fermenter %s/%s: %s to %s", edge_node, alias, fermenter->stage, (char *)json_object_get_string(val));
+	    }
+	    free(fermenter->stage);
+	}
+	fermenter->stage = xstrcpy((char *)json_object_get_string(val));
+    }
+    if (json_object_object_get_ex(jobj, "alarm", &val)) {
+	if (fermenter->alarm != json_object_get_int(val)) {
+	    syslog(LOG_NOTICE, "Change alarm fermenter %s/%s: %d to %d", edge_node, alias, fermenter->alarm, json_object_get_int(val));
+	}
+	fermenter->alarm = json_object_get_int(val);
+    }
+    if (json_object_object_get_ex(jobj, "product", &sensor)) {
+	if (json_object_object_get_ex(sensor, "code", &val)) {
+	    if (fermenter->beercode)
+		free(fermenter->beercode);
+	    fermenter->beercode = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "name", &val)) {
+	    if (fermenter->beername)
+		free(fermenter->beername);
+	    fermenter->beername = xstrcpy((char *)json_object_get_string(val));
+	}
+    }
+    if (json_object_object_get_ex(jobj, "air", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->air_address)
+		free(fermenter->air_address);
+	    fermenter->air_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    if (fermenter->air_state)
+		free(fermenter->air_state);
+	    fermenter->air_state= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "temperature", &val)) {
+	    fermenter->air_temperature = json_object_get_double(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "beer", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->beer_address)
+		free(fermenter->beer_address);
+	    fermenter->beer_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    if (fermenter->beer_state)
+		free(fermenter->beer_state);
+	    fermenter->beer_state= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "temperature", &val)) {
+	    fermenter->beer_temperature = json_object_get_double(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "chiller", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->chiller_address)
+		free(fermenter->chiller_address);
+	    fermenter->chiller_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    if (fermenter->chiller_state)
+		free(fermenter->chiller_state);
+	    fermenter->chiller_state= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "temperature", &val)) {
+	    fermenter->chiller_temperature = json_object_get_double(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "heater", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->heater_address)
+		free(fermenter->heater_address);
+	    fermenter->heater_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->heater_state = json_object_get_int(val);
+	}
+	if (json_object_object_get_ex(sensor, "usage", &val)) {
+	    fermenter->heater_usage = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "cooler", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->cooler_address)
+		free(fermenter->cooler_address);
+	    fermenter->cooler_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->cooler_state = json_object_get_int(val);
+	}
+	if (json_object_object_get_ex(sensor, "usage", &val)) {
+	    fermenter->cooler_usage = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "fan", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->fan_address)
+		free(fermenter->fan_address);
+	    fermenter->fan_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->fan_state = json_object_get_int(val);
+	}
+	if (json_object_object_get_ex(sensor, "usage", &val)) {
+	    fermenter->fan_usage = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "light", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->light_address)
+		free(fermenter->light_address);
+	    fermenter->light_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->light_state = json_object_get_int(val);
+	}
+	if (json_object_object_get_ex(sensor, "usage", &val)) {
+	    fermenter->light_usage = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "door", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->door_address)
+		free(fermenter->door_address);
+	    fermenter->door_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->door_state = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "psu", &sensor)) {
+	if (json_object_object_get_ex(sensor, "address", &val)) {
+	    if (fermenter->psu_address)
+		free(fermenter->psu_address);
+	    fermenter->psu_address= xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(sensor, "state", &val)) {
+	    fermenter->psu_state = json_object_get_int(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "setpoint", &sensor)) {
+	if (json_object_object_get_ex(sensor, "low", &val)) {
+	    fermenter->setpoint_low = json_object_get_double(val);
+	}
+	if (json_object_object_get_ex(sensor, "high", &val)) {
+	    fermenter->setpoint_high = json_object_get_double(val);
+	}
+    }
+    if (json_object_object_get_ex(jobj, "profile", &sensor)) {
+	if (strcmp(json_object_to_json_string_ext(sensor, 0), "null")) {
+//	    printf("profile: %s\n", json_object_to_json_string_ext(sensor, 0));
+
+	    if (json_object_object_get_ex(sensor, "uuid", &val)) {
+		if (fermenter->profile_uuid)
+		    free(fermenter->profile_uuid);
+		fermenter->profile_uuid = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(sensor, "name", &val)) {
+		if (fermenter->profile_name)
+		    free(fermenter->profile_name);
+		fermenter->profile_name = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(sensor, "state", &val)) {
+		if (fermenter->profile_state)
+		    free(fermenter->profile_state);
+		fermenter->profile_state = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(sensor, "inittemp", &temp)) {
+		if (json_object_object_get_ex(temp, "low", &val)) {
+		    fermenter->profile_inittemp_low = json_object_get_double(val);
+		}
+            	if (json_object_object_get_ex(temp, "high", &val)) {
+                    fermenter->profile_inittemp_high = json_object_get_double(val);
+		}
+	    }
+	    if (json_object_object_get_ex(sensor, "steps", &val)) {
+		if (fermenter->profile_steps)
+		    free(fermenter->profile_steps);
+		fermenter->profile_steps = xstrcpy((char *)json_object_to_json_string_ext(val, 0));
+	    }
+
+
+	} else {
+	    if (fermenter->profile_uuid)
+		free(fermenter->profile_uuid);
+	    if (fermenter->profile_name)
+		free(fermenter->profile_name);
+	    if (fermenter->profile_state)
+		free(fermenter->profile_state);
+	    if (fermenter->profile_steps)
+		free(fermenter->profile_steps);
+	    fermenter->profile_uuid = fermenter->profile_name = fermenter->profile_state = fermenter->profile_steps = NULL;
+	    fermenter->profile_percent = 0;
+	    fermenter->profile_inittemp_high = fermenter->profile_inittemp_low = 0.0;
+	}
+    }
+    json_object_put(jobj);
+
+//    fermenter_dump(fermenter);
+
+    if (new_fermenter) {
+    	if (fermenters == NULL) {
+	    fermenters = fermenter;
+	} else {
+	    for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
+		if (tmpp->next == NULL) {
+		    tmpp->next = fermenter;
+		    break;
+		}
+	    }
+	}
+	fermenter_mysql_insert(fermenter);
+    } else {
+	fermenter_mysql_update(fermenter);
+    }
+
+}
+
+
+
+/*
+ * With DBIRTH all active fermenters are publishd in an array.
+ * With DDATA only one fermenter is published in the payload.
+ */
+void fermenter_birth_data(char *topic, char *payload)
+{
+    char		*message_type, *edge_node, *alias;
+    struct json_object  *jobj, *val, *metric, *units, *unit;
+    int			arraylen;
+
+    strtok(topic, "/"); // ignore namespace
+    strtok(NULL, "/");
+    message_type = strtok(NULL, "/");
+    edge_node = strtok(NULL, "/\0");
+    alias = strtok(NULL, "/\0");
+
+    if ((alias == NULL) && (strcmp("DBIRTH", message_type) == 0)) {
+	/*
+	 * Global initial DBIRTH message with array of fermenters.
+	 */
+	jobj = json_tokener_parse(payload);
+
+	if (json_object_object_get_ex(jobj, "metric", &metric)) {
+	    if (json_object_object_get_ex(metric, "units", &units)) {
+		arraylen = json_object_array_length(units);
+		for (int i = 0; i < arraylen; i++) {
+		    /*
+		     * Parse the array of units
+		     */
+		    unit = json_object_array_get_idx(units, i);
+
+		    if (json_object_object_get_ex(unit, "alias", &val)) {
+			if (alias)
+			    free(alias);
+			alias = xstrcpy((char *)json_object_get_string(val));
+		    	fermenter_set(edge_node, alias, true, (char *)json_object_to_json_string_ext(unit, 0));
+			free(alias);
+			alias = NULL;
+		    }
+		}
+	    }
+	}
+	json_object_put(jobj);
+	return;
+    }
+
+    if (strcmp("DBIRTH", message_type) == 0) {
+	/*
+	 * DBIRTH for just one fermenter.
+	 */
+	jobj = json_tokener_parse(payload);
+
+	if (json_object_object_get_ex(jobj, "metric", &metric)) {
+	    fermenter_set(edge_node, alias, true, (char *)json_object_to_json_string_ext(metric, 0));
+	}
+	json_object_put(jobj);
+	return;
+    }
+
+    if (strcmp("DDATA", message_type) == 0) {
+	/*
+	 * DDATA update messages for each fermenter.
+	 */
+	jobj = json_tokener_parse(payload);
+
+	if (json_object_object_get_ex(jobj, "metric", &metric)) {
+	    fermenter_set(edge_node, alias, false, (char *)json_object_to_json_string_ext(metric, 0));
+	}
+	json_object_put(jobj);
+	return;
+    }
+
+    /*
+     * The rest are errors.
+     */
+    printf("ERROR fermenter_birth_data: %s %s %s\n", message_type, edge_node, alias);
+}
+
+
+
+void fermenter_log(char *topic, char *payload)
+{
+    char                *edge_node, *alias;
+    struct json_object  *jobj, *val, *metric, *metric2;
+    fermentation_log	*log;
+    struct tm		*mytime;
+    time_t		timestamp;
+
+    strtok(topic, "/"); // ignore namespace
+    strtok(NULL, "/");	// group_id
+    strtok(NULL, "/");	// message_type
+    edge_node = strtok(NULL, "/\0");
+    alias = strtok(NULL, "/\0");
+
+    log = (fermentation_log *)malloc(sizeof(fermentation_log));
+    memset(log, 0, sizeof(fermentation_log));
+
+    log->fermenter_node = xstrcpy(edge_node);
+    log->fermenter_alias = xstrcpy(alias);
+    jobj = json_tokener_parse(payload);
+
+    if (json_object_object_get_ex(jobj, "timestamp", &val)) {
+	timestamp = json_object_get_int(val);
+    	log->datetime = malloc(21);
+    	mytime = localtime(&timestamp);
+    	snprintf(log->datetime, 20, "%04d-%02d-%02d %02d:%02d:%02d", 
+	    mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
+    }
+
+    if (json_object_object_get_ex(jobj, "metric", &metric)) {
+
+	if (json_object_object_get_ex(metric, "product", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "uuid", &val)) {
+		if (strcmp((char *)"(null)", json_object_get_string(val)))
+		    log->product_uuid = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "code", &val)) {
+		if (strcmp((char *)"(null)", json_object_get_string(val)))
+		    log->product_code = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "name", &val)) {
+		if (strcmp((char *)"(null)", json_object_get_string(val)))
+		    log->product_name = xstrcpy((char *)json_object_get_string(val));
+	    }
+	}
+	if (json_object_object_get_ex(metric, "stage", &val)) {
+	    log->stage = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(metric, "mode", &val)) {
+	    log->mode = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(metric, "event", &val)) {
+	    if (strcmp((char *)"(null)", json_object_get_string(val)))
+	    	log->event = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(metric, "fermenter_uuid", &val)) {
+	    if (strcmp((char *)"(null)", json_object_get_string(val)))
+	    	log->fermenter_uuid = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(metric, "temperature", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "air", &val)) {
+		log->temperature_air = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "beer", &val)) {
+		log->temperature_beer = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "chiller", &val)) {
+		log->temperature_chiller = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "room", &val)) {
+		log->temperature_room = json_object_get_double(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "setpoint", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "low", &val)) {
+		log->setpoint_low = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "high", &val)) {
+		log->setpoint_high = json_object_get_double(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "heater", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "power", &val)) {
+		log->heater_power = json_object_get_int(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "usage", &val)) {
+		log->heater_usage = json_object_get_int(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "cooler", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "power", &val)) {
+		log->cooler_power = json_object_get_int(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "usage", &val)) {
+		log->cooler_usage = json_object_get_int(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "fan", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "power", &val)) {
+		log->fan_power = json_object_get_int(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "usage", &val)) {
+		log->fan_usage = json_object_get_int(val);
+	    }
+	}
+//	printf("%s\n", (char *)json_object_to_json_string_ext(metric, 0));
+    }
+    json_object_put(jobj);
+
+    fermentation_mysql_log(log);
+/*
+    printf("datetime      %s\n", log->datetime);
+    printf("product       %s %s\n", log->product_code, log->product_name);
+    printf("stage/mode    %s %s\n", log->stage, log->mode);
+    printf("temp air      %.3f\n", log->temperature_air);
+    printf("temp beer     %.3f\n", log->temperature_beer);
+    printf("temp chiller  %.3f\n", log->temperature_chiller);
+    printf("temp room     %.3f\n", log->temperature_room);
+    printf("setpoint      %.1f %.1f\n", log->setpoint_low, log->setpoint_high);
+    printf("heater        %3d %ld\n", log->heater_power, log->heater_usage);
+    printf("cooler        %3d %ld\n", log->cooler_power, log->cooler_usage);
+    printf("fan           %3d %ld\n", log->fan_power, log->fan_usage);
+    printf("event         %s\n", log->event);
+    printf("fermenter     %s\n", log->fermenter_uuid);
+*/
+    if (log->datetime)
+    	free(log->datetime);
+    if (log->product_uuid )
+	free(log->product_uuid );
+    if (log->product_code )
+	free(log->product_code );
+    if (log->product_name )
+	free(log->product_name );
+    if (log->stage)
+	free(log->stage);
+    if (log->mode)
+	free(log->mode);
+    if (log->event)
+	free(log->event);
+    if (log->fermenter_uuid)
+	free(log->fermenter_uuid);
+    if (log->fermenter_node)
+	free(log->fermenter_node);
+    if (log->fermenter_alias)
+	free(log->fermenter_alias);
+    free(log);
+}
+
+
+
+void fermenter_dump(sys_fermenter_list *fermenter)
+{
+    if (debug) {
+    	printf("uuid      %s\n", fermenter->uuid);
+    	printf("alias     %s\n", fermenter->alias);
+    	printf("node      %s\n", fermenter->node);
+	printf("online    %s\n", fermenter->online ? "yes":"no");
+	printf("product   %s / %s\n", fermenter->beercode, fermenter->beername);
+	if (fermenter->air_address) 
+	    printf("Air       %-36s %10s %8.3f\n", fermenter->air_address, fermenter->air_state, fermenter->air_temperature);
+	if (fermenter->beer_address) 
+	    printf("Beer      %-36s %10s %8.3f\n", fermenter->beer_address, fermenter->beer_state, fermenter->beer_temperature);
+	if (fermenter->chiller_address) 
+	    printf("Chiller   %-36s %10s %8.3f\n", fermenter->chiller_address, fermenter->chiller_state, fermenter->chiller_temperature);
+	if (fermenter->heater_address) 
+	    printf("Heater    %-36s %9d%% %8lu\n", fermenter->heater_address, fermenter->heater_state, fermenter->heater_usage);
+	if (fermenter->cooler_address) 
+	    printf("Cooler    %-36s %9d%% %8lu\n", fermenter->cooler_address, fermenter->cooler_state, fermenter->cooler_usage);
+	if (fermenter->fan_address) 
+	    printf("Fan       %-36s %9d%% %8lu\n", fermenter->fan_address, fermenter->fan_state, fermenter->fan_usage);
+	if (fermenter->light_address) 
+	    printf("Light     %-36s %9d%% %8lu\n", fermenter->light_address, fermenter->light_state, fermenter->light_usage);
+	if (fermenter->door_address) 
+	    printf("Door      %-36s %10d\n", fermenter->door_address, fermenter->door_state);
+	if (fermenter->psu_address)
+	    printf("PSU       %-36s %10d\n", fermenter->psu_address, fermenter->psu_state);
+	printf("mode      %s\n", fermenter->mode);
+	printf("alarm     %04x\n", fermenter->alarm);
+	printf("sp high   %8.3f\n", fermenter->setpoint_high);
+	printf("sp low    %8.3f\n", fermenter->setpoint_low);
+	if (fermenter->profile_uuid) {
+	    printf("profile uuid     %s\n", fermenter->profile_uuid);
+	    printf("profile name     %s\n", fermenter->profile_name);
+	    printf("profile state    %s\n", fermenter->profile_state);
+	    printf("profile percent  %d\n", fermenter->profile_percent);
+	    printf("profile sp high  %.3f\n", fermenter->profile_inittemp_high);
+	    printf("profile sp low   %.3f\n", fermenter->profile_inittemp_low);
+	    printf("profile steps    %s\n", fermenter->profile_steps);
+	}
+    }
+}
+
+
+
+void fermenter_death(char *topic)
+{
+    char		*edge_node, *alias;
+    sys_fermenter_list	*tmpp;
+
+    printf("fermenter_death: %s\n", topic);
+    strtok(topic, "/"); // ignore namespace
+    strtok(NULL, "/");	// ignore group_id
+    strtok(NULL, "/");	// ignore message_type
+    edge_node = strtok(NULL, "/\0");
+    alias = strtok(NULL, "/\0");
+
+    fermenter_mysql_death(edge_node, alias);
+
+    if (alias) {
+    	for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
+	    if ((strcmp(tmpp->node, edge_node) == 0) && (strcmp(tmpp->alias, alias) == 0)) {
+		if (tmpp->online)
+		    syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias);
+	    	tmpp->online = false;
+	    	break;
+	    }
+    	}
+    } else {
+	for (tmpp = fermenters; tmpp; tmpp = tmpp->next) {
+	    if (strcmp(tmpp->node, edge_node) == 0) {
+		if (tmpp->online)
+		    syslog(LOG_NOTICE, "Offline fermenter %s/%s", tmpp->node, tmpp->alias);
+		tmpp->online = false;
+	    }
+	}
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/fermenters.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,32 @@
+/**
+ * @file fermenters.h
+ */
+
+#ifndef _FERMENTERS_H
+#define _FERMENTERS_H
+
+void fermenter_dump(sys_fermenter_list *fermenter);
+
+/**
+ * @brief Birth of a fermenter or data update. Create it in the database if 
+ *        never seen before, else just update the database entry.
+ * @param topic The MQTT topic string, contains the fermenter type and name.
+ * @param payload The JSON formatted payload with the fermenter details.
+ */
+void fermenter_birth_data(char *topic, char *payload);
+
+/**
+ * @brief Death of a fermenter. Mark it offline in the database.
+ * @param topic The MQTT topic string, contains the fermenter type and name.
+ */
+void fermenter_death(char *topic);
+
+/**
+ * @brief Data logging from fermenters.
+ * @param topic The MQTT topic string, contains the fermenter type and name.
+ * @param payload The JSON formatted payload with the fermenter details.
+ */
+void fermenter_log(char *topic, char *payload);
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/futil.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,91 @@
+/*****************************************************************************
+ * Copyright (C) 2017
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "bms.h"
+#include "futil.h"
+
+
+/*
+ * Make directory tree, the name must end with a /
+ */
+int mkdirs(char *name, mode_t mode)
+{
+    char	buf[PATH_MAX], *p, *q;
+    int		last = 0, oldmask;
+
+    memset(&buf, 0, sizeof(buf));
+    strncpy(buf, name, sizeof(buf)-1);
+    buf[sizeof(buf)-1] = '\0';
+
+    p = buf+1;
+
+    oldmask = umask(000);
+    while ((q = strchr(p, '/'))) {
+	*q = '\0';
+	mkdir(buf, mode);
+	last = errno;
+	*q = '/';
+	p = q+1;
+    }
+
+    umask(oldmask);
+											
+    if ((last == 0) || (last == EEXIST)) {
+	return TRUE;
+    } else {
+	syslog(LOG_NOTICE, "mkdirs(%s)", name);
+	return FALSE;
+    }
+}
+
+
+
+/*
+ * Test if the given file exists. The second option is:
+ * R_OK - test for Read rights 
+ * W_OK - test for Write rights
+ * X_OK - test for eXecute rights
+ * F_OK - test file presence only
+ */ 
+int file_exist(char *path, int mode)
+{
+    if (access(path, mode) != 0)
+	return errno;
+
+    return 0;
+}
+
+
+
+/*
+ * Return size of file, or -1 if file doesn't exist
+ */
+int file_size(char *path)
+{
+    static struct   stat sb;
+
+    if (stat(path, &sb) == -1)
+	return -1;
+
+    return sb.st_size;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/futil.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,9 @@
+#ifndef	FUTIL_H
+#define	FUTIL_H
+
+
+int  mkdirs(char *, mode_t);
+int  file_exist(char *, int);
+int  file_size(char *);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/header	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,23 @@
+/**
+ * @file xxx.c
+ * @brief Something
+ * @author Michiel Broek <mbroek at mbse dot eu>
+ *
+ * Copyright (C) 2018
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/lock.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,145 @@
+/*****************************************************************************
+ * Copyright (C) 2017
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "lock.h"
+#include "bms.h"
+#include "futil.h"
+
+
+extern char     *Private_Path;
+
+
+/*
+ *  Put a lock on this program.
+ */
+int lockprog(char *name)
+{
+    char    *tempfile, *lockfile;
+    FILE    *fp;
+    pid_t   oldpid;
+
+    tempfile = calloc(PATH_MAX, sizeof(char));
+    lockfile = calloc(PATH_MAX, sizeof(char));
+
+    snprintf(tempfile, PATH_MAX, "%s/run/%s.tmp", Private_Path, name);
+    snprintf(lockfile, PATH_MAX, "%s/run/%s.pid", Private_Path, name);
+
+    if (mkdirs(tempfile, 0755) == FALSE) {
+	printf("Can't create path \"%s\"\n", tempfile);
+	free(tempfile);
+	free(lockfile);
+	return 1;
+    }
+
+    if ((fp = fopen(tempfile, "w")) == NULL) {
+	perror(name);
+	printf("Can't create lockfile \"%s\"\n", tempfile);
+	free(tempfile);
+	free(lockfile);
+	return 1;
+    }
+    fprintf(fp, "%10u\n", getpid());
+    fclose(fp);
+
+    while (TRUE) {
+	if (link(tempfile, lockfile) == 0) {
+	    unlink(tempfile);
+	    free(tempfile);
+	    free(lockfile);
+	    return 0;
+	}
+	if ((fp = fopen(lockfile, "r")) == NULL) {
+	    perror(name);
+	    printf("Can't open lockfile \"%s\"\n", tempfile);
+	    unlink(tempfile);
+	    free(tempfile);
+	    free(lockfile);
+	    return 1;
+	}
+	if (fscanf(fp, "%u", &oldpid) != 1) {
+	    perror(name);
+	    printf("Can't read old pid from \"%s\"\n", tempfile);
+	    fclose(fp);
+	    unlink(tempfile);
+	    free(tempfile);
+	    free(lockfile);
+	    return 1;
+	}
+	fclose(fp);
+	if (kill(oldpid,0) == -1) {
+	    if (errno == ESRCH) {
+		printf("Stale lock found for pid %u\n", oldpid);
+		unlink(lockfile);
+		/* no return, try lock again */  
+	    } else {
+		perror(name);
+		printf("Kill for %u failed\n",oldpid);
+		unlink(tempfile);
+		free(tempfile);
+		free(lockfile);
+		return 1;
+	    }
+	} else {
+	    printf("Another %s is already running, pid=%u\n", name, oldpid);
+	    unlink(tempfile);
+	    free(tempfile);
+	    free(lockfile);
+	    return 1;
+	}
+    }
+}
+
+
+
+void ulockprog(char *name)
+{
+    char	    *lockfile;
+    pid_t	    oldpid;
+    FILE	    *fp;
+
+    lockfile = calloc(PATH_MAX, sizeof(char));
+    snprintf(lockfile, PATH_MAX, "%s/run/%s.pid", Private_Path, name);
+
+    if ((fp = fopen(lockfile, "r")) == NULL) {
+	syslog(LOG_NOTICE, "Can't open lockfile \"%s\"", lockfile);
+	free(lockfile);
+	return;
+    }
+
+    if (fscanf(fp, "%u", &oldpid) != 1) {
+	syslog(LOG_NOTICE, "Can't read old pid from \"%s\"", lockfile);
+	fclose(fp);
+	unlink(lockfile);
+	free(lockfile);
+	return;
+    }
+
+    fclose(fp);
+
+    if (oldpid == getpid()) {
+	(void)unlink(lockfile);
+    }
+
+    free(lockfile);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/lock.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,8 @@
+#ifndef	LOCK_H
+#define	LOCK_H
+
+
+int  lockprog(char *);
+void ulockprog(char *);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/mqtt.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,409 @@
+/*****************************************************************************
+ * Copyright (C) 2017-2018
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "bms.h"
+#include "xutil.h"
+#include "mqtt.h"
+#include "nodes.h"
+#include "fermenters.h"
+
+
+extern sys_config       Config;
+extern int		debug;
+
+
+
+/* Global variables for use in callbacks. */
+int              	mqtt_qos = 0;
+int              	mqtt_status = STATUS_CONNECTING;
+int              	mqtt_mid_sent = 0;
+int              	mqtt_last_mid = -1;
+int              	mqtt_last_mid_sent = -1;
+int              	mqtt_connected = TRUE;
+int              	mqtt_disconnect_sent = FALSE;
+int              	mqtt_connect_lost = FALSE;
+int              	mqtt_my_shutdown = FALSE;
+int              	mqtt_use = FALSE;
+int			keepalive = 60;
+unsigned int		max_inflight = 20;
+struct mosquitto	*mosq = NULL;
+char			*state = NULL;
+char			my_hostname[256];
+int			Sequence = 0;
+
+
+char *payload_header(void)
+{
+    static char	*tmp;
+    char	buf[128];
+
+    tmp = xstrcpy((char *)"{\"timestamp\":");
+    sprintf(buf, "%ld", time(NULL));
+    tmp = xstrcat(tmp, buf);
+    tmp = xstrcat(tmp, (char *)",\"seq\":");
+    sprintf(buf, "%d", Sequence++);
+    tmp = xstrcat(tmp, buf);
+    tmp = xstrcat(tmp, (char *)",\"metric\":");
+    return tmp;
+}
+
+
+
+char *topic_base(char *msgtype)
+{
+    static char	*tmp;
+
+    tmp = xstrcpy((char *)"mbv1.0/brewery/");
+    tmp = xstrcat(tmp, msgtype);
+    tmp = xstrcat(tmp, (char *)"/");
+    tmp = xstrcat(tmp, my_hostname);
+    return tmp;
+}
+
+
+
+void my_connect_callback(struct mosquitto *my_mosq, void *obj, int result)
+{
+    char	*topic = NULL;
+
+    if (mqtt_connect_lost) {
+        mqtt_connect_lost = FALSE;
+        syslog(LOG_NOTICE, "MQTT: reconnect: %s", mosquitto_connack_string(result));
+    }
+
+    if (!result) {
+	topic = topic_base((char *)"NCMD");		// TODO: do we need this??
+	topic = xstrcat(topic, (char *)"/#");
+	mosquitto_subscribe(mosq, NULL, topic, 0);
+	free(topic);
+	topic = xstrcpy((char *)"mbv1.0/fermenters/#");		// Subscribe to fermenter messages.
+	mosquitto_subscribe(mosq, NULL, topic, 0);
+	free(topic);
+	topic = NULL;
+       	mqtt_status = STATUS_CONNACK_RECVD;
+    } else {
+       	syslog(LOG_NOTICE, "MQTT: my_connect_callback: %s\n", mosquitto_connack_string(result));
+    }
+}
+
+
+
+void my_disconnect_callback(struct mosquitto *my_mosq, void *obj, int rc)
+{
+    if (mqtt_my_shutdown) {
+       	syslog(LOG_NOTICE, "MQTT: acknowledged DISCONNECT from %s", Config.mqtt_host);
+       	mqtt_connected = FALSE;
+    } else {
+       	/*
+         * The remote server was brought down. We must keep running
+         */
+       	syslog(LOG_NOTICE, "MQTT: received DISCONNECT from %s, connection lost", Config.mqtt_host);
+       	mqtt_connect_lost = TRUE;
+    }
+}
+
+
+
+void my_publish_callback(struct mosquitto *my_mosq, void *obj, int mid)
+{
+    mqtt_last_mid_sent = mid;
+}
+
+
+
+void my_subscribe_callback(struct mosquitto *my_mosq, void *userdata, int mid, int qos_count, const int *granted_qos)
+{
+    int i;
+
+    syslog(LOG_NOTICE, "Subscribed (mid: %d): %d", mid, granted_qos[0]);
+    for (i = 1; i < qos_count; i++) {
+	syslog(LOG_NOTICE, "     %d", granted_qos[i]);
+    }
+}
+
+
+
+void my_log_callback(struct mosquitto *my_mosq, void *obj, int level, const char *str)
+{
+    syslog(LOG_NOTICE, "MQTT: %s", str);
+    if (debug)
+    	fprintf(stdout, "MQTT: %s\n", str);
+}
+
+
+
+void my_message_callback(struct mosquitto *my_mosq, void *userdata, const struct mosquitto_message *message)
+{
+    if (message->payloadlen) {
+	// TODO: process subscribed topics here.
+	if (strstr(message->topic, (char *)"NBIRTH") || strstr(message->topic, (char *)"NDATA")) {
+	    node_birth_data(message->topic, (char *)message->payload);
+	    return;
+	}
+	if (strstr(message->topic, (char *)"fermenters") &&  (strstr(message->topic, (char *)"DBIRTH") || strstr(message->topic, (char *)"DDATA"))) {
+	    fermenter_birth_data(message->topic, (char *)message->payload);
+	    return;
+	}
+	if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DLOG")) {
+	    fermenter_log(message->topic, (char *)message->payload);
+	    return;
+	}
+	syslog(LOG_NOTICE, "MQTT: message callback %s :: %d", message->topic, message->payloadlen);
+    } else {
+	if (strstr(message->topic, (char *)"NBIRTH")) {
+	    // Ignore ??
+	    fprintf(stdout, "MQTT: %s NULL\n", message->topic);
+	    return;
+	}
+	if (strstr(message->topic, (char *)"NDEATH")) {
+	    node_death(message->topic);
+	    return;
+	}
+	if (strstr(message->topic, (char *)"fermenters") && strstr(message->topic, (char *)"DDEATH")) {
+	    fermenter_death(message->topic);
+	    return;
+	}
+	syslog(LOG_NOTICE, "MQTT: message callback %s (null)", message->topic);
+    }
+}
+
+
+
+void publisher(struct mosquitto *my_mosq, char *topic, char *payload, bool retain) 
+{
+    // publish the data
+    if (payload)
+	mosquitto_publish(my_mosq, &mqtt_mid_sent, topic, strlen(payload), payload, mqtt_qos, retain);
+    else
+	mosquitto_publish(my_mosq, &mqtt_mid_sent, topic, 0, NULL, mqtt_qos, retain);
+}
+
+
+
+void publishNData(bool birth, int flag)
+{
+    char                *topic = NULL, *payload = NULL;
+    struct utsname      ubuf;
+    bool                comma = false;
+
+    payload = payload_header();
+    payload = xstrcat(payload, (char *)"{");
+			        
+    if (birth || flag & MQTT_NODE_CONTROL) {
+	payload = xstrcat(payload, (char *)"\"nodecontrol\":{\"reboot\":false,\"rebirth\":false,\"nextserver\":false,\"scanrate\":3000}");
+	comma = true;
+    }
+
+    if (birth) {
+	if (comma)
+	    payload = xstrcat(payload, (char *)",");
+	payload = xstrcat(payload, (char *)"\"properties\":{\"hardwaremake\":\"Unknown\",\"hardwaremodel\":\"Unknown\"");
+	if (uname(&ubuf) == 0) {
+	    payload = xstrcat(payload, (char *)",\"os\":\"");
+	    payload = xstrcat(payload, ubuf.sysname);
+	    payload = xstrcat(payload, (char *)"\",\"os_version\":\"");
+	    payload = xstrcat(payload, ubuf.release);
+	    payload = xstrcat(payload, (char *)"\"");
+	} else {
+	    payload = xstrcat(payload, (char *)",\"os\":\"Unknown\",\"os_version\":\"Unknown\"");
+	}
+
+	payload = xstrcat(payload, (char *)",\"FW\":\"");
+	payload = xstrcat(payload, (char *)VERSION);
+	payload = xstrcat(payload, (char *)"\"}");
+	comma = true;
+    }
+    payload = xstrcat(payload, (char *)"}}");
+
+    if (birth) {
+	topic = topic_base((char *)"NBIRTH");
+	publisher(mosq, topic, payload, true);
+    } else {
+	topic = topic_base((char *)"NDATA");
+	publisher(mosq, topic, payload, false);
+    }
+
+    free(payload);
+    payload = NULL;
+    free(topic);
+    topic = NULL;
+}
+
+
+
+int mqtt_connect(void)
+{
+    char	*id = NULL, *topic = NULL;
+    char	err[1024];
+    int		rc;
+
+    /*
+     * Initialize mosquitto communication
+     */
+    gethostname(my_hostname, 255);
+    mosquitto_lib_init();
+    id = xstrcpy((char *)"bmsd/");
+    id = xstrcat(id, my_hostname);
+    if (strlen(id) > MOSQ_MQTT_ID_MAX_LENGTH) {
+       /*
+        * Enforce maximum client id length of 23 characters
+        */
+       id[MOSQ_MQTT_ID_MAX_LENGTH] = '\0';
+    }
+
+    mosq = mosquitto_new(id, TRUE, NULL);
+    if (!mosq) {
+       switch(errno) {
+           case ENOMEM:
+               syslog(LOG_NOTICE, "MQTT: mosquitto_new: Out of memory");
+               break;
+           case EINVAL:
+               syslog(LOG_NOTICE, "MQTT: mosquitto_new: Invalid id");
+               break;
+       }
+       mosquitto_lib_cleanup();
+       return 1;
+    }
+    free(id);
+    id = NULL;
+
+    /*
+     * Set our will
+     */
+    topic = topic_base((char *)"NDEATH");
+    if ((rc = mosquitto_will_set(mosq, topic, 0, NULL, mqtt_qos, false))) {
+	if (rc > MOSQ_ERR_SUCCESS)
+	    syslog(LOG_NOTICE, "MQTT: mosquitto_will_set: %s", mosquitto_strerror(rc));
+	mosquitto_lib_cleanup();
+	return 2;
+    }
+    free(topic);
+    topic = NULL;
+
+    if (debug)
+       mosquitto_log_callback_set(mosq, my_log_callback);
+
+    /*
+     * Username/Password
+     */
+    if (Config.mqtt_user) {
+	if (Config.mqtt_pass) {
+	    rc = mosquitto_username_pw_set(mosq, Config.mqtt_user, Config.mqtt_pass);
+	} else {
+	    rc = mosquitto_username_pw_set(mosq, Config.mqtt_user, NULL);
+	}
+	if (rc == MOSQ_ERR_INVAL) {
+	    syslog(LOG_NOTICE, "MQTT: mosquitto_username_pw_set: input parameters invalid");
+	} else if (rc == MOSQ_ERR_NOMEM) {
+	    syslog(LOG_NOTICE, "MQTT: mosquitto_username_pw_set: Out of Memory");
+	}
+	if (rc != MOSQ_ERR_SUCCESS) {
+	    mosquitto_lib_cleanup();
+	    return 3;
+	}
+    }
+
+    mosquitto_max_inflight_messages_set(mosq, max_inflight);
+    mosquitto_connect_callback_set(mosq, my_connect_callback);
+    mosquitto_disconnect_callback_set(mosq, my_disconnect_callback);
+    mosquitto_publish_callback_set(mosq, my_publish_callback);
+    mosquitto_message_callback_set(mosq, my_message_callback);
+    mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
+
+    if ((rc = mosquitto_connect(mosq, Config.mqtt_host, Config.mqtt_port, keepalive))) {
+        if (rc == MOSQ_ERR_ERRNO) {
+            strerror_r(errno, err, 1024);
+            syslog(LOG_NOTICE, "MQTT: mosquitto_connect: error: %s", err);
+        } else {
+            syslog(LOG_NOTICE, "MQTT: mosquitto_connect: unable to connect (%d)", rc);
+        }
+        mosquitto_lib_cleanup();
+	syslog(LOG_NOTICE, "MQTT: will run without an MQTT broker.");
+	return 4;
+    } else {
+        mqtt_use = TRUE;
+        syslog(LOG_NOTICE, "MQTT: connected with %s:%d", Config.mqtt_host, Config.mqtt_port);
+
+        /*
+         * Initialise is complete, report our presence state
+         */
+        mosquitto_loop_start(mosq);
+	publishNData(true, 0);
+    }
+
+    return 0;
+}
+
+
+
+void mqtt_disconnect(void)
+{
+    int		rc;
+    char	*topic = NULL;
+
+    if (mqtt_use) {
+        /*
+         * Final publish 0 to clients/<hostname>/bmsd/state
+	 * After that, remove the retained topic.
+         */
+        syslog(LOG_NOTICE, "MQTT disconnecting");
+	topic = topic_base((char *)"NBIRTH");
+	publisher(mosq, topic, NULL, true);
+	free(topic);
+	topic = topic_base((char *)"NDEATH");
+	publisher(mosq, topic, NULL, true);
+	free(topic);
+	topic = NULL;
+	mqtt_last_mid = mqtt_mid_sent;
+        mqtt_status = STATUS_WAITING;
+	mqtt_my_shutdown = TRUE;
+
+        do {
+            if (mqtt_status == STATUS_WAITING) {
+                if (debug)
+                    fprintf(stdout, (char *)"Waiting\n");
+                if (mqtt_last_mid_sent == mqtt_last_mid && mqtt_disconnect_sent == FALSE) {
+                    mosquitto_disconnect(mosq);
+                    mqtt_disconnect_sent = TRUE;
+                }
+                usleep(100000);
+            }
+            rc = MOSQ_ERR_SUCCESS;
+        } while (rc == MOSQ_ERR_SUCCESS && mqtt_connected);
+
+        mosquitto_loop_stop(mosq, FALSE);
+        mosquitto_destroy(mosq);
+        mosquitto_lib_cleanup();
+	mqtt_use = FALSE;
+	mqtt_status = STATUS_CONNECTING;
+	mqtt_mid_sent = 0;
+	mqtt_last_mid = -1;
+	mqtt_last_mid_sent = -1;
+	mqtt_connected = TRUE;
+	mqtt_disconnect_sent = FALSE;
+	mqtt_connect_lost = FALSE;
+	mqtt_my_shutdown = FALSE;
+	syslog(LOG_NOTICE, "MQTT: disconnected");
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/mqtt.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,20 @@
+#ifndef _MQTT_H
+#define	_MQTT_H
+
+#define STATUS_CONNECTING 0
+#define STATUS_CONNACK_RECVD 1
+#define STATUS_WAITING 2
+
+
+/**
+ * @brief Connect to the MQTT server.
+ * @return 0 if success, else the connection failed.
+ */
+int mqtt_connect(void);
+
+/**
+ * @brief Disconnect from the MQTT server.
+ */
+void mqtt_disconnect(void);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/mysql.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,600 @@
+/**
+ * @file mysql.c
+ * @brief MySQL/MariaDB access.
+ * @author Michiel Broek <mbroek at mbse dot eu>
+ *
+ * Copyright (C) 2018
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "bms.h"
+#include "xutil.h"
+#include "mysql.h"
+#include "nodes.h"
+
+
+MYSQL				*con = NULL;
+MYSQL_RES			*res_set;
+MYSQL_ROW			row;
+
+extern sys_config       	Config;
+extern sys_node_list		*nodes;
+extern sys_fermenter_list	*fermenters;
+extern int              	debug;
+
+
+time_t datetime_to_time_t(char *dt_string)
+{
+    struct tm		tm;
+
+    memset(&tm, 0, sizeof(struct tm));
+    tm.tm_year = atoi(strtok(dt_string, "-")) - 1900;
+    tm.tm_mon  = atoi(strtok(NULL, "-")) - 1;
+    tm.tm_mday = atoi(strtok(NULL, " "));
+    tm.tm_hour = atoi(strtok(NULL, ":"));
+    tm.tm_min  = atoi(strtok(NULL, ":"));
+    tm.tm_sec  = atoi(strtok(NULL, "\0"));
+    tm.tm_isdst = 1;
+
+    return mktime(&tm);
+}
+
+
+
+int bms_mysql_init(void)
+{
+    sys_node_list	*node, *tmpp;
+    sys_fermenter_list	*fermenter, *tmpf;
+    int			ncnt = 0, fcnt = 0;
+
+    con = mysql_init(NULL);
+    if (con == NULL) {
+	syslog(LOG_NOTICE, "MySQL: mysql_init() failed");
+	return 1;
+    }
+
+    if (mysql_real_connect(con, Config.mysql_host, Config.mysql_user, Config.mysql_pass, Config.mysql_database, Config.mysql_port, NULL, 0) == NULL) {
+	syslog(LOG_NOTICE, "MySQL: mysql_real_connect() %s", mysql_error(con));
+	return 2;
+    }
+
+    syslog(LOG_NOTICE, "MySQL: connected to %s:%d database %s", Config.mysql_host, Config.mysql_port, Config.mysql_database);
+    syslog(LOG_NOTICE, "MySQL: %s server info: %s", mysql_get_host_info(con), mysql_get_server_info(con));
+    if (debug)
+	fprintf(stdout, "MySQL: connected\n");
+
+    /*
+     * Restore nodes from the database
+     */
+    if (mysql_query(con, "SELECT * FROM nodes")) {
+	syslog(LOG_NOTICE, "MySQL: SELECT * FROM nodes error %u (%s))", mysql_errno(con), mysql_error(con));
+    } else {
+	res_set = mysql_store_result(con);
+	if (res_set == NULL) {
+	    syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con));
+	} else {
+	    // Process results
+	    while ((row = mysql_fetch_row(res_set)) != NULL) {
+		node = (sys_node_list *)malloc(sizeof(sys_node_list));
+		memset(node, 0, sizeof(sys_node_list));
+		node->next          = NULL;
+		node->uuid          = xstrcpy(row[1]);
+		node->node          = xstrcpy(row[2]);
+		node->online        = false;	// Will be set using MQTT
+		node->group_id      = xstrcpy(row[4]);
+		node->hardwaremake  = xstrcpy(row[5]);
+		node->hardwaremodel = xstrcpy(row[6]);
+		node->os            = xstrcpy(row[7]);
+		node->os_version    = xstrcpy(row[8]);
+		node->firmware      = xstrcpy(row[9]);
+		node->firstseen     = datetime_to_time_t(row[10]);
+		node->lastseen      = datetime_to_time_t(row[11]);
+		node->temperature   = atof(row[12]);
+		node->humidity      = atof(row[13]);
+		node->barometer     = atof(row[14]);
+		node->gps_latitude  = atof(row[15]);
+		node->gps_longitude = atof(row[16]);
+		node->gps_altitude  = atof(row[17]);
+		node->net_address   = xstrcpy(row[18]);
+		node->net_ifname    = xstrcpy(row[19]);
+		node->net_rssi      = atoi(row[20]);
+
+		if (nodes == NULL) {
+		    nodes = node;
+		} else {
+		    for (tmpp = nodes; tmpp; tmpp = tmpp->next) {
+			if (tmpp->next == NULL) {
+			    tmpp->next = node;
+			    break;
+			}
+		    }
+		}
+		ncnt++;
+	    }
+	    mysql_free_result(res_set);
+	}
+    }
+
+    if (mysql_query(con, "SELECT * FROM fermenters")) {
+	syslog(LOG_NOTICE, "MySQL: SELECT * FROM fermenters error %u (%s))", mysql_errno(con), mysql_error(con));
+    } else {
+	res_set = mysql_store_result(con);
+	if (res_set == NULL) {
+	    syslog(LOG_NOTICE, "MySQL: mysq_store_result error %u (%s))", mysql_errno(con), mysql_error(con));
+	} else {
+	    while ((row = mysql_fetch_row(res_set)) != NULL) {
+		fermenter = (sys_fermenter_list *)malloc(sizeof(sys_fermenter_list));  
+		memset(fermenter, 0, sizeof(sys_fermenter_list));
+		fermenter->next     = NULL;
+		fermenter->uuid     = xstrcpy(row[1]);
+		fermenter->alias    = xstrcpy(row[2]);
+		fermenter->node     = xstrcpy(row[3]);
+		fermenter->online   = false;	// Will be set later
+		fermenter->beercode = xstrcpy(row[5]);
+		fermenter->beername = xstrcpy(row[6]);
+		if (strlen(row[7])) {
+		    fermenter->air_address         = xstrcpy(row[7]);
+		    fermenter->air_state           = xstrcpy(row[8]);
+		    fermenter->air_temperature     = atof(row[9]);
+		} 
+		if (strlen(row[10])) {
+		    fermenter->beer_address        = xstrcpy(row[10]);
+		    fermenter->beer_state          = xstrcpy(row[11]);
+		    fermenter->beer_temperature    = atof(row[12]);
+		}
+		if (strlen(row[13])) {
+		    fermenter->chiller_address     = xstrcpy(row[13]);
+		    fermenter->chiller_state       = xstrcpy(row[14]);
+		    fermenter->chiller_temperature = atof(row[15]);
+		}
+		if (strlen(row[16])) {
+		    fermenter->heater_address = xstrcpy(row[16]);
+		    fermenter->heater_state   = atoi(row[17]);
+		    fermenter->heater_usage   = atoi(row[18]);
+		}
+		if (strlen(row[19])) {
+		    fermenter->cooler_address = xstrcpy(row[19]);
+		    fermenter->cooler_state   = atoi(row[20]);
+		    fermenter->cooler_usage   = atoi(row[21]);
+		}
+		if (strlen(row[22])) {
+		    fermenter->fan_address = xstrcpy(row[22]);
+		    fermenter->fan_state   = atoi(row[23]);
+		    fermenter->fan_usage   = atoi(row[24]);
+		}
+		if (strlen(row[25])) {
+		    fermenter->light_address = xstrcpy(row[25]);
+		    fermenter->light_state   = atoi(row[26]);
+		    fermenter->light_usage   = atoi(row[27]);
+		}
+		if (strlen(row[28])) {
+		    fermenter->door_address = xstrcpy(row[28]);
+		    fermenter->door_state   = atoi(row[29]);
+		}
+		if (strlen(row[30])) {
+		    fermenter->psu_address = xstrcpy(row[30]);
+		    fermenter->psu_state   = atoi(row[31]);
+		}
+		fermenter->mode          = xstrcpy(row[32]);
+		fermenter->alarm         = atoi(row[33]);
+		fermenter->setpoint_high = atof(row[34]);
+		fermenter->setpoint_low  = atof(row[35]);
+		if (strlen(row[36])) {
+		    fermenter->profile_uuid          = xstrcpy(row[36]);
+		    fermenter->profile_name          = xstrcpy(row[37]);
+		    fermenter->profile_state         = xstrcpy(row[38]);
+		    fermenter->profile_percent       = atoi(row[39]);
+		    fermenter->profile_inittemp_high = atof(row[40]);
+		    fermenter->profile_inittemp_low  = atof(row[41]);
+		    fermenter->profile_steps         = xstrcpy(row[42]);
+		}
+		fermenter->stage         = xstrcpy(row[43]);
+
+		if (fermenters == NULL) {
+		    fermenters = fermenter;
+		} else {
+		    for (tmpf = fermenters; tmpf; tmpf = tmpf->next) {
+			if (tmpf->next == NULL) {
+			    tmpf->next = fermenter;
+			    break;
+			}
+		    }
+		}
+		fcnt++;
+	    }
+	    mysql_free_result(res_set);
+	}
+    }
+
+    syslog(LOG_NOTICE, "MySQL: loaded %d nodes, %d fermenters", ncnt, fcnt);
+    return 0;
+}
+
+
+
+void bms_mysql_end(void)
+{
+    sys_fermenter_list	*tmpf, *oldtmpf;
+    sys_node_list	*tmpn, *oldtmpn;
+
+    mysql_close(con);
+
+    syslog(LOG_NOTICE, "MySQL: disconnected");
+    if (debug)
+	fprintf(stdout, "MySQL: disconnected\n");
+
+    for (tmpf = fermenters; tmpf; tmpf = oldtmpf) {
+	oldtmpf = tmpf->next;
+	if (tmpf->uuid)
+	    free(tmpf->uuid);
+	if (tmpf->alias)
+	    free(tmpf->alias);
+	if (tmpf->node)
+	    free(tmpf->node);
+	if (tmpf->beercode)
+	    free(tmpf->beercode);
+	if (tmpf->beername)
+	    free(tmpf->beername);
+	if (tmpf->air_address)
+	    free(tmpf->air_address);
+	if (tmpf->air_state)
+	    free(tmpf->air_state);
+	if (tmpf->beer_address)
+	    free(tmpf->beer_address);
+	if (tmpf->beer_state)
+	    free(tmpf->beer_state);
+	if (tmpf->chiller_address)
+	    free(tmpf->chiller_address);
+	if (tmpf->chiller_state)
+	    free(tmpf->chiller_state);
+	if (tmpf->heater_address)
+	    free(tmpf->heater_address);
+	if (tmpf->cooler_address)
+	    free(tmpf->cooler_address);
+	if (tmpf->fan_address)
+	    free(tmpf->fan_address);
+	if (tmpf->light_address)
+	    free(tmpf->light_address);
+	if (tmpf->door_address)
+	    free(tmpf->door_address);
+	if (tmpf->psu_address)
+	    free(tmpf->psu_address);
+	if (tmpf->mode)
+	    free(tmpf->mode);
+	if (tmpf->stage)
+	    free(tmpf->stage);
+	if (tmpf->profile_uuid)
+	    free(tmpf->profile_uuid);
+	if (tmpf->profile_name)
+	    free(tmpf->profile_name);
+	if (tmpf->profile_state)
+	    free(tmpf->profile_state);
+	if (tmpf->profile_steps)
+	    free(tmpf->profile_steps);
+	free(tmpf);
+    }
+    for (tmpn = nodes; tmpn; tmpn = oldtmpn) {
+	oldtmpn = tmpn->next;
+	if (tmpn->uuid)
+	    free(tmpn->uuid);
+	if (tmpn->node)
+	    free(tmpn->node);
+	if (tmpn->group_id)
+	    free(tmpn->group_id);
+	if (tmpn->hardwaremake)
+	    free(tmpn->hardwaremake);
+	if (tmpn->hardwaremodel)
+	    free(tmpn->hardwaremodel);
+	if (tmpn->os)
+	    free(tmpn->os);
+	if (tmpn->os_version)
+	    free(tmpn->os_version);
+	if (tmpn->firmware)
+	    free(tmpn->firmware);
+	if (tmpn->net_address)
+	    free(tmpn->net_address);
+	if (tmpn->net_ifname)
+	    free(tmpn->net_ifname);
+	free(tmpn);
+    }
+}
+
+
+
+void bms_mysql_ping(void)
+{
+}
+
+
+
+void node_mysql_insert(sys_node_list *node)
+{
+    char	*query = malloc(512), first[21], last[21];
+    struct tm	*mytime;
+
+    mytime = localtime(&node->firstseen);
+    snprintf(first, 20, "%04d-%02d-%02d %02d:%02d:%02d", 
+		    mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
+    mytime = localtime(&node->lastseen);
+    snprintf(last, 20, "%04d-%02d-%02d %02d:%02d:%02d",
+		mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
+
+    snprintf(query, 511,
+	"INSERT INTO  nodes SET uuid='%s', node='%s', online='%s', group_id='%s', " \
+        "hardwaremake='%s', hardwaremodel='%s', os='%s', os_version='%s', firmware='%s', firstseen='%s', lastseen='%s', " \
+	"temperature='%.3f', humidity='%.3f', barometer='%.3f', gps_latitude='%.8f', gps_longitude='%.8f', gps_altitude='%.8f', " \
+	"net_address='%s', net_ifname='%s', net_rssi='%d'",
+	node->uuid, node->node, node->online ?"Y":"N", node->group_id, 
+	node->hardwaremake, node->hardwaremodel, node->os, node->os_version, node->firmware, first, last,
+	node->temperature, node->humidity, node->barometer, node->gps_latitude, node->gps_longitude, node->gps_altitude,
+	node->net_address, node->net_ifname, node->net_rssi);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: INSERT INTO nodes error %u (%s))", mysql_errno(con), mysql_error(con));
+    } else {
+	syslog(LOG_NOTICE,  "MySQL: insert new node %s", node->node);
+    }
+
+    free(query);
+}
+
+
+
+void node_mysql_update(sys_node_list *node)
+{
+    char        *query = malloc(512), last[21];
+    struct tm   *mytime;
+
+    mytime = localtime(&node->lastseen);
+    snprintf(last, 20, "%04d-%02d-%02d %02d:%02d:%02d",
+    	mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec);
+
+    snprintf(query, 511,
+	"UPDATE  nodes SET online='%s', hardwaremake='%s', hardwaremodel='%s', os='%s', os_version='%s', firmware='%s', lastseen='%s', " \
+	"temperature='%.3f', humidity='%.3f', barometer='%.3f', gps_latitude='%.8f', gps_longitude='%.8f', gps_altitude='%.8f', " \
+	"net_address='%s', net_ifname='%s', net_rssi='%d' WHERE uuid='%s'",
+	node->online ?"Y":"N", node->hardwaremake, node->hardwaremodel, node->os, node->os_version, node->firmware, last,
+	node->temperature, node->humidity, node->barometer, node->gps_latitude, node->gps_longitude, node->gps_altitude, 
+	node->net_address, node->net_ifname, node->net_rssi, node->uuid);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: UPDATE nodes error %u (%s))", mysql_errno(con), mysql_error(con));
+    }
+
+    free(query);
+}
+
+
+
+void node_mysql_death(char *node)
+{
+    char        *query = malloc(512);
+
+    snprintf(query, 511, "UPDATE  nodes SET online='N' WHERE node='%s'", node);
+//    printf("%s\n", query);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: UPDATE nodes error %u (%s))", mysql_errno(con), mysql_error(con));
+    }
+
+    free(query);
+}
+
+
+
+void fermenter_mysql_insert(sys_fermenter_list *fermenter)
+{
+    char        *query = malloc(2560);
+
+    snprintf(query, 2559,
+	"INSERT INTO fermenters SET uuid='%s', alias='%s', node='%s', online='%s', " \
+	"beercode='%s', beername='%s', " \
+	"air_address='%s', air_state='%s', air_temperature='%.3f', " \
+	"beer_address='%s', beer_state='%s', beer_temperature='%.3f', " \
+	"chiller_address='%s', chiller_state='%s', chiller_temperature='%.3f', " \
+	"heater_address='%s', heater_state='%d', heater_usage='%lu', " \
+	"cooler_address='%s', cooler_state='%d', cooler_usage='%lu', " \
+	"fan_address='%s', fan_state='%d', fan_usage='%lu', " \
+	"light_address='%s', light_state='%d', light_usage='%lu', " \
+	"door_address='%s', door_state='%d', " \
+	"psu_address='%s', psu_state='%d', " \
+	"mode='%s', alarm='%d', setpoint_high='%.3f', setpoint_low='%.3f', " \
+	"profile_uuid='%s', profile_name='%s', profile_state='%s', profile_percent='%d', " \
+	"profile_inittemp_high='%.3f', profile_inittemp_low='%.3f', profile_steps='%s', stage='%s'",
+	fermenter->uuid, fermenter->alias, fermenter->node, fermenter->online ? "Y":"N",
+	fermenter->beercode ? fermenter->beercode : "", fermenter->beername ? fermenter->beername : "",
+	fermenter->air_address ? fermenter->air_address : "", fermenter->air_state ? fermenter->air_state : "", fermenter->air_temperature,
+	fermenter->beer_address ? fermenter->beer_address : "", fermenter->beer_state ? fermenter->beer_state : "", fermenter->beer_temperature,
+     	fermenter->chiller_address ? fermenter->chiller_address : "", fermenter->chiller_state ? fermenter->chiller_state : "", fermenter->chiller_temperature,
+	fermenter->heater_address ? fermenter->heater_address : "", fermenter->heater_state, fermenter->heater_usage,
+	fermenter->cooler_address ? fermenter->cooler_address : "", fermenter->cooler_state, fermenter->cooler_usage,
+	fermenter->fan_address ? fermenter->fan_address : "", fermenter->fan_state, fermenter->fan_usage,
+	fermenter->light_address ? fermenter->light_address : "", fermenter->light_state, fermenter->light_usage,
+	fermenter->door_address ? fermenter->door_address : "", fermenter->door_state,
+	fermenter->psu_address ? fermenter->psu_address : "", fermenter->psu_state,
+	fermenter->mode, fermenter->alarm, fermenter->setpoint_high, fermenter->setpoint_low,
+	fermenter->profile_uuid ? fermenter->profile_uuid : "", fermenter->profile_name ? fermenter->profile_name : "",
+        fermenter->profile_state ? fermenter->profile_state : "", fermenter->profile_percent, 
+	fermenter->profile_inittemp_high, fermenter->profile_inittemp_low,
+	fermenter->profile_steps ? fermenter->profile_steps : "", fermenter->stage);
+
+//    printf("%s\n", query);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: INSERT INTO fermenters error %u (%s))", mysql_errno(con), mysql_error(con));
+    } else {
+	syslog(LOG_NOTICE,  "MySQL: insert new fermenter %s/%s", fermenter->node, fermenter->alias);
+    }
+
+    free(query);
+}
+
+
+void fermenter_mysql_update(sys_fermenter_list *fermenter)
+{
+    char        *query = malloc(2560);
+
+    snprintf(query, 2559,
+	"UPDATE fermenters SET online='%s', beercode='%s', beername='%s', " \
+	"air_address='%s', air_state='%s', air_temperature='%.3f', " \
+	"beer_address='%s', beer_state='%s', beer_temperature='%.3f', " \
+	"chiller_address='%s', chiller_state='%s', chiller_temperature='%.3f', " \
+	"heater_address='%s', heater_state='%d', heater_usage='%lu', " \
+	"cooler_address='%s', cooler_state='%d', cooler_usage='%lu', " \
+	"fan_address='%s', fan_state='%d', fan_usage='%lu', " \
+	"light_address='%s', light_state='%d', light_usage='%lu', " \
+	"door_address='%s', door_state='%d', " \
+	"psu_address='%s', psu_state='%d', " \
+	"mode='%s', alarm='%d', setpoint_high='%.3f', setpoint_low='%.3f', " \
+	"profile_uuid='%s', profile_name='%s', profile_state='%s', profile_percent='%d', " \
+	"profile_inittemp_high='%.3f', profile_inittemp_low='%.3f', profile_steps='%s', stage='%s' WHERE uuid='%s'",
+	fermenter->online ? "Y":"N", fermenter->beercode ? fermenter->beercode : "", fermenter->beername ? fermenter->beername : "",
+	fermenter->air_address ? fermenter->air_address : "", fermenter->air_state ? fermenter->air_state : "", fermenter->air_temperature,
+	fermenter->beer_address ? fermenter->beer_address : "", fermenter->beer_state ? fermenter->beer_state : "", fermenter->beer_temperature,
+	fermenter->chiller_address ? fermenter->chiller_address : "", fermenter->chiller_state ? fermenter->chiller_state : "", fermenter->chiller_temperature,
+	fermenter->heater_address ? fermenter->heater_address : "", fermenter->heater_state, fermenter->heater_usage,
+	fermenter->cooler_address ? fermenter->cooler_address : "", fermenter->cooler_state, fermenter->cooler_usage,
+	fermenter->fan_address ? fermenter->fan_address : "", fermenter->fan_state, fermenter->fan_usage,
+	fermenter->light_address ? fermenter->light_address : "", fermenter->light_state, fermenter->light_usage,
+	fermenter->door_address ? fermenter->door_address : "", fermenter->door_state,
+	fermenter->psu_address ? fermenter->psu_address : "", fermenter->psu_state,
+	fermenter->mode, fermenter->alarm, fermenter->setpoint_high, fermenter->setpoint_low,
+	fermenter->profile_uuid ? fermenter->profile_uuid : "", fermenter->profile_name ? fermenter->profile_name : "",
+	fermenter->profile_state ? fermenter->profile_state : "", fermenter->profile_percent,
+	fermenter->profile_inittemp_high, fermenter->profile_inittemp_low,
+	fermenter->profile_steps ? fermenter->profile_steps : "", fermenter->stage, fermenter->uuid);
+
+//    printf("%s\n", query);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: UPDATE fermenters error %u (%s))", mysql_errno(con), mysql_error(con));
+    }
+
+    free(query);
+}
+
+
+
+void fermenter_mysql_death(char *node, char *alias)
+{
+    char        *query = malloc(512);
+
+    if (alias)
+    	snprintf(query, 511, "UPDATE  fermenters SET online='N' WHERE node='%s' and alias='%s'", node, alias);
+    else
+	snprintf(query, 511, "UPDATE  fermenters SET online='N' WHERE node='%s'", node);
+
+    if (mysql_query(con, query)) {
+	syslog(LOG_NOTICE, "MySQL: UPDATE fermenters error %u (%s))", mysql_errno(con), mysql_error(con));
+    }
+
+    free(query);
+}
+
+
+
+void fermentation_mysql_log(fermentation_log *log)
+{
+    char	*query, buf[65];
+
+    query = xstrcpy((char *)"INSERT INTO log_fermentation SET datetime='");
+    query = xstrcat(query, log->datetime);
+    query = xstrcat(query, (char *)":00");
+    if (log->product_uuid) {
+	query = xstrcat(query, (char *)"', product_uuid='");
+	query = xstrcat(query, log->product_uuid);
+    }
+    if (log->product_code) {
+	query = xstrcat(query, (char *)"', product_code='");
+	query = xstrcat(query, log->product_code);
+    }
+    if (log->product_name) {
+	query = xstrcat(query, (char *)"', product_name='");
+	query = xstrcat(query, log->product_name);
+    }
+    query = xstrcat(query, (char *)"', stage='");
+    query = xstrcat(query, log->stage);
+    query = xstrcat(query, (char *)"', mode='");
+    query = xstrcat(query, log->mode);
+    query = xstrcat(query, (char *)"', temperature_beer='");
+    snprintf(buf, 64, "%.3f", log->temperature_beer);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', temperature_air='");
+    snprintf(buf, 64, "%.3f", log->temperature_air);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', temperature_chiller='");
+    snprintf(buf, 64, "%.3f", log->temperature_chiller);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', temperature_room='");
+    snprintf(buf, 64, "%.3f", log->temperature_room);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', target_low='");
+    snprintf(buf, 64, "%.1f", log->setpoint_low);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', target_high='");
+    snprintf(buf, 64, "%.1f", log->setpoint_high);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', heater_power='");
+    snprintf(buf, 64, "%d", log->heater_power);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', heater_usage='");
+    snprintf(buf, 64, "%ld", log->heater_usage);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', cooler_power='");
+    snprintf(buf, 64, "%d", log->cooler_power);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', cooler_usage='");
+    snprintf(buf, 64, "%ld", log->cooler_usage);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', fan_power='");
+    snprintf(buf, 64, "%d", log->fan_power);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"', fan_usage='");
+    snprintf(buf, 64, "%ld", log->fan_usage);
+    query = xstrcat(query, buf);
+    query = xstrcat(query, (char *)"'");
+    // sg
+    if (log->event) {
+	query = xstrcat(query, (char *)", event='");
+	query = xstrcat(query, log->event);
+	query = xstrcat(query, (char *)"'");
+    }
+    if (log->fermenter_uuid) {
+	query = xstrcat(query, (char *)", fermenter_uuid='");
+	query = xstrcat(query, log->fermenter_uuid);
+	query = xstrcat(query, (char *)"'");
+    }
+    if (log->fermenter_node) {
+	query = xstrcat(query, (char *)", fermenter_node='");
+	query = xstrcat(query, log->fermenter_node);
+	query = xstrcat(query, (char *)"'");
+    }
+    if (log->fermenter_alias) {
+	query = xstrcat(query, (char *)", fermenter_alias='");
+	query = xstrcat(query, log->fermenter_alias);
+	query = xstrcat(query, (char *)"'");
+    }
+
+    if (mysql_real_query(con, query, strlen(query))) {
+	syslog(LOG_NOTICE, "MySQL: `%s' error %u (%s)\n)", query, mysql_errno(con), mysql_error(con));
+    }
+
+    free(query);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/mysql.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,35 @@
+/**
+ * @file mysql.h
+ */
+#ifndef _MYSQL_H
+#define _MYSQL_H
+
+
+/**
+ * @brief Connect to the MySQL server and select the database. All parameters must be
+ *        set in the $HOME/.bms/bms.conf file.
+ * @return 0 if success, any other value if the connection failed.
+ */
+int  bms_mysql_init(void);
+
+/**
+ * @brief Close MySQL connection and free resources.
+ */
+void bms_mysql_end(void);
+
+/**
+ * @brief Ping MySQL connection and try to reconnect if the connection is broken.
+ */
+void bms_mysql_ping(void);
+
+void node_mysql_insert(sys_node_list *node);
+void node_mysql_update(sys_node_list *node);
+void node_mysql_death(char *node);
+
+void fermenter_mysql_insert(sys_fermenter_list *fermenter);
+void fermenter_mysql_update(sys_fermenter_list *fermenter);
+void fermenter_mysql_death(char *node, char *alias);
+
+void fermentation_mysql_log(fermentation_log *log);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/nodes.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,241 @@
+/**
+ * @file nodes.c
+ * @brief Handle nodes status
+ * @author Michiel Broek <mbroek at mbse dot eu>
+ *
+ * Copyright (C) 2018
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+
+#include "bms.h"
+#include "xutil.h"
+#include "nodes.h"
+#include "mysql.h"
+
+
+sys_node_list		*nodes = NULL;
+
+extern int		debug;
+
+
+
+void node_birth_data(char *topic, char *payload)
+{
+    struct json_object	*jobj, *val, *metric, *metric2;
+    sys_node_list	*node, *tmpp;
+    char		*group_id, *message_type, *edge_node;
+    bool		new_node = true;
+
+//    fprintf(stdout, "node_birth: %s %s\n", topic, payload);
+
+    strtok(topic, "/");	// ignore namespace
+    group_id = strtok(NULL, "/");
+    message_type = strtok(NULL, "/");
+    edge_node = strtok(NULL, "/\0");
+
+    /*
+     * Search node record in the memory array and use it if found.
+     */
+    if (nodes) {
+	for (tmpp = nodes; tmpp; tmpp = tmpp->next) {
+	    if ((strcmp(tmpp->group_id, group_id) == 0) && (strcmp(tmpp->node, edge_node) == 0)) {
+		new_node = false;
+		node = tmpp;
+		node->lastseen = time(NULL);
+		node->online = true;
+		break;
+	    }
+	}
+    }
+
+    /*
+     * Allocate new node if not yet known.
+     */
+    if (new_node) {
+	node = (sys_node_list *)malloc(sizeof(sys_node_list));
+    	node->uuid = NULL;
+   	node->next = NULL;
+    	node->group_id = xstrcpy(group_id);
+    	node->node = xstrcpy(edge_node);
+    	node->online = true;
+    	node->hardwaremake = node->hardwaremodel = node->os = node->os_version = node->firmware = NULL;
+    	node->firstseen = node->lastseen = time(NULL);
+    	node->temperature = node->humidity = node->barometer = 0.0;
+    	node->gps_latitude = node->gps_longitude = node->gps_altitude = 0.0;
+	node->net_address = node->net_ifname = NULL;
+	node->net_rssi = 0;
+    }
+
+    /*
+     * Process the JSON formatted payload. 
+     * Update only the fields that are found in the payload.
+     */
+    jobj = json_tokener_parse(payload);
+
+    if (json_object_object_get_ex(jobj, "timestamp", &val)) {
+	if (strcmp((char *)"NDATA", message_type)) {
+	    node->firstseen = json_object_get_int(val);
+	    syslog(LOG_NOTICE, "Online node `%s/%s'", node->group_id, node->node);
+	} else {
+	    node->lastseen = json_object_get_int(val);
+	}
+    }
+
+    /*
+    if (json_object_object_get_ex(jobj, "seq", &val)) {
+	printf("seq: %s\n", json_object_to_json_string_ext(val, 0));	// Do we need it?
+    }
+    */
+
+    if (json_object_object_get_ex(jobj, "metric", &metric)) {
+	if (json_object_object_get_ex(metric, "uuid", &val)) {
+	    if (node->uuid)
+		free(node->uuid);
+	    node->uuid = xstrcpy((char *)json_object_get_string(val));
+	}
+	if (json_object_object_get_ex(metric, "properties", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "hardwaremake", &val)) {
+		if (node->hardwaremake)
+		    free(node->hardwaremake);
+		node->hardwaremake = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "hardwaremodel", &val)) {
+		if (node->hardwaremodel)
+		    free(node->hardwaremodel);
+		node->hardwaremodel = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "os", &val)) {
+		if (node->os)
+		    free(node->os);
+		node->os = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "os_version", &val)) {
+		if (node->os_version)
+		    free(node->os_version);
+		node->os_version = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "FW", &val)) {
+		if (node->firmware)
+		    free(node->firmware);
+		node->firmware = xstrcpy((char *)json_object_get_string(val));
+	    }
+	}
+	if (json_object_object_get_ex(metric, "THB", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "temperature", &val)) {
+		node->temperature = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "humidity", &val)) {
+		node->humidity= json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "barometer", &val)) {
+		node->barometer = json_object_get_double(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "GPS", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "latitude", &val)) {
+		node->gps_latitude = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "longitude", &val)) {
+		node->gps_longitude = json_object_get_double(val);
+	    }
+	    if (json_object_object_get_ex(metric2, "altitude", &val)) {
+		node->gps_altitude = json_object_get_double(val);
+	    }
+	}
+	if (json_object_object_get_ex(metric, "net", &metric2)) {
+	    if (json_object_object_get_ex(metric2, "address", &val)) {
+		if (node->net_address)
+		    free(node->net_address);
+		node->net_address = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "ifname", &val)) {
+		if (node->net_ifname)
+		    free(node->net_ifname);
+		node->net_ifname = xstrcpy((char *)json_object_get_string(val));
+	    }
+	    if (json_object_object_get_ex(metric2, "rssi", &val)) {
+		node->net_rssi = json_object_get_int(val);
+	    }
+	}
+    }
+    json_object_put(jobj);
+
+//    node_dump(node);
+
+    if (new_node) {
+    	if (nodes == NULL) {
+	    nodes = node;
+	} else {
+	    for (tmpp = nodes; tmpp; tmpp = tmpp->next) {
+		if (tmpp->next == NULL) {
+		    tmpp->next = node;
+		    break;
+		}
+	    }
+	}
+	node_mysql_insert(node);
+    } else {
+	node_mysql_update(node);
+    }
+}
+
+
+
+void node_dump(sys_node_list *node)
+{
+    if (debug) {
+	printf("online    %s\n", node->online ? "yes":"no");
+    	printf("uuid      %s\n", node->uuid);
+    	printf("node      %s\n", node->node);
+    	printf("group     %s\n", node->group_id);
+    	printf("hw make   %s  model %s\n", node->hardwaremake, node->hardwaremodel);
+    	printf("os        %s  version %s\n", node->os, node->os_version);
+    	printf("firmware  %s\n", node->firmware);
+    	printf("first     %ld   last %ld\n", node->firstseen, node->lastseen);
+    	printf("THB       %.2f  %.2f  %.2f\n", node->temperature, node->humidity, node->barometer);
+    	printf("GPS       %.5f  %.5f  %.5f\n", node->gps_latitude, node->gps_longitude, node->gps_altitude);
+	printf("net       %s:%s\n", node->net_ifname, node->net_address);
+	printf("rssi      %d\n", node->net_rssi);
+    }
+}
+
+
+
+void node_death(char *topic)
+{
+    char		*group_id, *edge_node;
+    sys_node_list	*tmpp;
+
+    strtok(topic, "/"); // ignore namespace
+    group_id = strtok(NULL, "/");
+    strtok(NULL, "/");	// ignore message_type
+    edge_node = strtok(NULL, "/\0");
+
+    syslog(LOG_NOTICE, "Offline node `%s/%s'", group_id, edge_node);
+    node_mysql_death(edge_node);
+
+    for (tmpp = nodes; tmpp; tmpp = tmpp->next) {
+	if (strcmp(tmpp->node, edge_node) == 0) {
+	    tmpp->online = false;
+	    break;
+	}
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/nodes.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,24 @@
+/**
+ * @file nodes.h
+ */
+
+#ifndef _NODES_H
+#define _NODES_H
+
+void node_dump(sys_node_list *node);
+
+/**
+ * @brief Birth of a node or data update. Create it in the database if 
+ *        never seen before, else just update the database entry.
+ * @param topic The MQTT topic string, contains the node type and name.
+ * @param payload The JSON formatted payload with the node details.
+ */
+void node_birth_data(char *topic, char *payload);
+
+/**
+ * @brief Death of a node. Mark it offline in the database.
+ * @param topic The MQTT topic string, contains the node type and name.
+ */
+void node_death(char *topic);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/rdconfig.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,267 @@
+/*****************************************************************************
+ * Copyright (C) 2017-2018
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "bms.h"
+#include "xutil.h"
+#include "futil.h"
+#include "rdconfig.h"
+
+
+static char	*mypath;
+static char	*k, *v;
+static int	linecnt = 0;
+
+extern int	debug;
+extern char	*Private_Path;
+
+
+sys_config	Config;
+
+
+static int getstr(char **);
+static int getint(char **);
+
+
+key_list keytab[] = {
+    {(char *)"bms_name",		getstr,		(char **)&Config.bms_name},
+    {(char *)"bms_uuid",		getstr,		(char **)&Config.bms_uuid},
+    {(char *)"mysql_host",		getstr,		(char **)&Config.mysql_host},
+    {(char *)"mysql_port",		getint,		(char **)&Config.mysql_port},
+    {(char *)"mysql_user",		getstr,		(char **)&Config.mysql_user},
+    {(char *)"mysql_pass",		getstr,		(char **)&Config.mysql_pass},
+    {(char *)"mysql_database",		getstr,		(char **)&Config.mysql_database},
+    {(char *)"mqtt_host",		getstr,		(char **)&Config.mqtt_host},
+    {(char *)"mqtt_port",		getint,		(char **)&Config.mqtt_port},
+    {(char *)"mqtt_user",		getstr,		(char **)&Config.mqtt_user},
+    {(char *)"mqtt_pass",		getstr,		(char **)&Config.mqtt_pass},
+    {NULL,				NULL,		NULL}
+};
+
+
+
+/*
+ * Kill configuration data
+ */
+void killconfig(void)
+{
+    if (Config.bms_name)
+	free(Config.bms_name);
+    Config.bms_name = NULL;
+    if (Config.bms_uuid)
+	free(Config.bms_uuid);
+    Config.bms_uuid = NULL;
+
+    if (Config.mysql_host)
+	free(Config.mysql_host);
+    Config.mysql_host = NULL;
+    Config.mysql_port = 3306;
+    if (Config.mysql_user)
+	free(Config.mysql_user);
+    Config.mysql_user = NULL;
+    if (Config.mysql_pass)
+	free(Config.mysql_pass);
+    Config.mysql_pass = NULL;
+    if (Config.mysql_database)
+	free(Config.mysql_database);
+    Config.mysql_database = NULL;
+
+    if (Config.mqtt_host)
+	free(Config.mqtt_host);
+    Config.mqtt_host = NULL;
+    Config.mqtt_port = 1883;
+    if (Config.mqtt_user)
+	free(Config.mqtt_user);
+    Config.mqtt_user = NULL;
+    if (Config.mqtt_pass)
+	free(Config.mqtt_pass);
+    Config.mqtt_pass = NULL;
+}
+
+
+
+int wrconfig(void)
+{
+    FILE	*fp;
+
+    if (mypath)
+	free(mypath);
+    mypath = xstrcpy(Private_Path);
+    mypath = xstrcat(mypath, (char *)"/bms.config");
+    if (mkdirs(mypath, 0755) == FALSE)
+	return 1;
+
+    if ((fp = fopen(mypath, "w")) == NULL) {
+	syslog(LOG_NOTICE, "[rdconfig] could not rewrite %s", mypath);
+	return 1;
+    }
+
+    fprintf(fp, "# Configuration file for BMS %s\n", VERSION);
+    fprintf(fp, "#\n");
+    if (Config.bms_name)
+	fprintf(fp, "bms_name              %s\n", Config.bms_name);
+    if (Config.bms_uuid)
+	fprintf(fp, "bms_uuid              %s\n", Config.bms_uuid);
+    fprintf(fp, "#\n");
+
+    if (Config.mysql_host)
+	fprintf(fp, "mysql_host            %s\n", Config.mysql_host);
+    fprintf(fp, "mysql_port            %d\n", Config.mysql_port);
+    if (Config.mysql_user)
+	fprintf(fp, "mysql_user            %s\n", Config.mysql_user);
+    else
+	fprintf(fp, "#mysql_user            <username>\n");
+    if (Config.mysql_pass)
+	fprintf(fp, "mysql_pass             %s\n", Config.mysql_pass);
+    else
+    	fprintf(fp, "#mysql_pass             <passwd>\n");
+    if (Config.mysql_database)
+	fprintf(fp, "mysql_database        %s\n", Config.mysql_database);
+    else
+	fprintf(fp, "#mysql_database        <dbname>\n");
+    fprintf(fp, "#\n");
+
+    if (Config.mqtt_host)
+	fprintf(fp, "mqtt_host             %s\n", Config.mqtt_host);
+    fprintf(fp, "mqtt_port             %d\n", Config.mqtt_port);
+    if (Config.mqtt_user)
+	fprintf(fp, "mqtt_user             %s\n", Config.mqtt_user);
+    else
+	fprintf(fp, "#mqtt_user             <username>\n");
+    if (Config.mqtt_pass)
+	fprintf(fp, "mqtt_pass             %s\n", Config.mqtt_pass);
+    else
+	fprintf(fp, "#mqtt_pwd              <passwd>\n");
+
+    fprintf(fp, "#\n");
+    fprintf(fp, "# End of generated configuration\n");
+    fclose(fp);
+    free(mypath);
+    mypath = NULL;
+    return 0;
+}
+
+
+
+int rdconfig(void)
+{
+    FILE    	*fp;
+    uuid_t	uu;
+    char	buf[256], *p;
+    int		i, rc = 0;
+
+    if (mypath)
+	free(mypath);
+    mypath = xstrcpy(Private_Path);
+    mypath = xstrcat(mypath, (char *)"/bms.config");
+
+    killconfig();
+
+    if (debug)
+	fprintf(stdout, "[rdconfig] reading %s\n", mypath);
+
+    if ((fp = fopen(mypath, "r")) == NULL) {
+	syslog(LOG_NOTICE, "[rdconfig] cannot open %s", mypath);
+	Config.bms_name = xstrcpy((char *)"My Brewery");
+	Config.bms_uuid = malloc(37);
+	uuid_generate(uu);
+	uuid_unparse(uu, Config.bms_uuid);
+	Config.mysql_port = 3306;
+	Config.mysql_host = xstrcpy((char *)"localhost");
+	Config.mqtt_port = 1883;
+	Config.mqtt_host = xstrcpy((char *)"localhost");
+	return wrconfig();
+    }
+
+    linecnt = 0;
+    while (fgets(buf, sizeof(buf) -1, fp)) {
+	linecnt++;
+	if (*(p = buf + strlen(buf) -1) != '\n') {
+	    syslog(LOG_NOTICE, "[rdconfig] %s(%d): \"%s\" - line too long", mypath, linecnt, buf);
+	    rc = 1;
+	    break;
+	}
+	*p-- = '\0';
+	while ((p >= buf) && isspace(*p))
+	    *p-- = '\0';
+	k = buf;
+	while (*k && isspace(*k))
+	    k++;
+	p = k;
+	while (*p && !isspace(*p))
+	    p++;
+	*p++='\0';
+	v = p;
+	while (*v && isspace(*v)) 
+	    v++;
+
+	if ((*k == '\0') || (*k == '#')) {
+	    continue;
+	}
+
+	for (i = 0; keytab[i].key; i++)
+	    if (strcasecmp(k,keytab[i].key) == 0)
+		break;
+
+	if (keytab[i].key == NULL) {
+	    syslog(LOG_NOTICE, "[rdconfig] %s(%d): %s %s - unknown keyword", mypath, linecnt, S(k), S(v));
+	    rc = 1;
+	    break;
+	} else if ((keytab[i].prc(keytab[i].dest))) {
+	    rc = 1;
+	    break;
+	}
+    }
+    fclose(fp);
+
+    free(mypath);
+    mypath = NULL;
+
+    return rc;
+}
+
+
+
+static int getstr(char **dest)
+{
+    if (debug)
+    	fprintf(stdout, "[rdconfig] getstr: %s(%d): %s %s\n", mypath, linecnt, S(k), S(v));
+
+    *dest = xstrcpy(v);
+    return 0;
+}
+
+
+
+static int getint(char **dest)
+{
+    if (debug)
+    	fprintf(stdout, "[rdconfig] getint: %s(%d): %s %s\n", mypath, linecnt, k, v);
+
+    if (strspn(v,"0123456789") != strlen(v)) 
+        syslog(LOG_NOTICE, "[rdconfig] %s(%d): %s %s - bad numeric", mypath, linecnt, S(k), S(v));
+    else 
+        *((int*)dest)=atoi(v);
+    return 0;
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/rdconfig.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,18 @@
+#ifndef	_RDCONFIG_H
+#define	_RDCONFIG_H
+
+#define S(x) (x)?(x):"(null)"
+
+typedef struct _key_list {
+   char                *key;
+   int                 (*prc)(char **);
+   char                **dest;
+} key_list;
+
+
+void killconfig(void);
+int  rdconfig(void);
+int  wrconfig(void);
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/xutil.c	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,73 @@
+/*****************************************************************************
+ * Copyright (C) 2017
+ *   
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of the bms (Brewery Management System)
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * bms is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+#include "bms.h"
+#include "xutil.h"
+
+
+char *xmalloc(size_t size)
+{
+    char *tmp;
+
+    tmp = malloc(size);
+    if (!tmp) 
+	abort();
+			            
+    return tmp;
+}
+
+
+
+char *xstrcpy(char *src)
+{
+    char    *tmp;
+
+    if (src == NULL) 
+	return(NULL);
+    tmp = xmalloc(strlen(src)+1);
+    strcpy(tmp, src);
+    return tmp;
+}
+
+
+
+char *xstrcat(char *src, char *add)
+{
+    char    *tmp;
+    size_t  size = 0;
+
+    if ((add == NULL) || (strlen(add) == 0))
+	return src;
+    if (src)
+	size = strlen(src);
+    size += strlen(add);
+    tmp = xmalloc(size + 1);
+    *tmp = '\0';
+    if (src) {
+	strcpy(tmp, src);
+	free(src);
+    }
+    strcat(tmp, add);
+    return tmp;
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bmsd/xutil.h	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,8 @@
+#ifndef	_XUTIL_H
+#define	_XUTIL_H
+
+char *xmalloc(size_t);
+char *xstrcpy(char *);
+char *xstrcat(char *, char *);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.h.in	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,11 @@
+/* config.h.in.  */
+
+#undef COPYRIGHT
+#undef VERSION
+
+/* Compile experimental code (may not be present) */
+#undef USE_EXPERIMENT
+
+/* According to Sun we MUST define this in the source */
+#define _REENTRANT 1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.log	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,523 @@
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by configure, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  $ ./configure 
+
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = seaport
+uname -m = x86_64
+uname -r = 4.4.144
+uname -s = Linux
+uname -v = #1 SMP Thu Jul 26 12:26:39 CDT 2018
+
+/usr/bin/uname -p = Intel(R) Core(TM) i5-4460  CPU @ 3.20GHz
+/bin/uname -X     = unknown
+
+/bin/arch              = x86_64
+/usr/bin/arch -k       = unknown
+/usr/convex/getsysinfo = unknown
+/usr/bin/hostinfo      = unknown
+/bin/machine           = unknown
+/usr/bin/oslevel       = unknown
+/bin/universe          = unknown
+
+PATH: /home/mbroek/bin
+PATH: /usr/local/bin
+PATH: /usr/bin
+PATH: /bin
+PATH: /usr/games
+PATH: /usr/lib64/java/bin
+PATH: /usr/lib64/java/jre/bin
+PATH: /usr/lib64/kde4/libexec
+PATH: /usr/lib64/qt/bin
+PATH: /usr/share/texmf/bin
+PATH: /home/mbroek/esp/xtensa-esp32-elf/bin
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+configure:2101: checking for gcc
+configure:2117: found /usr/bin/gcc
+configure:2128: result: gcc
+configure:2357: checking for C compiler version
+configure:2366: gcc --version >&5
+gcc (GCC) 5.5.0
+Copyright (C) 2015 Free Software Foundation, Inc.
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+configure:2377: $? = 0
+configure:2366: gcc -v >&5
+Reading specs from /usr/lib64/gcc/x86_64-slackware-linux/5.5.0/specs
+COLLECT_GCC=gcc
+COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-slackware-linux/5.5.0/lto-wrapper
+Target: x86_64-slackware-linux
+Configured with: ../gcc-5.5.0/configure --prefix=/usr --libdir=/usr/lib64 --mandir=/usr/man --infodir=/usr/info --enable-shared --enable-bootstrap --enable-languages=ada,c,c++,fortran,go,java,lto,objc --enable-threads=posix --enable-checking=release --enable-objc-gc --with-system-zlib --with-python-dir=/lib64/python2.7/site-packages --enable-libstdcxx-dual-abi --with-default-libstdcxx-abi=gcc4-compatible --disable-libunwind-exceptions --enable-__cxa_atexit --enable-libssp --enable-lto --disable-install-libiberty --with-gnu-ld --verbose --enable-java-home --with-java-home=/usr/lib64/jvm/jre --with-jvm-root-dir=/usr/lib64/jvm --with-jvm-jar-dir=/usr/lib64/jvm/jvm-exports --with-arch-directory=amd64 --with-antlr-jar=/home/slackware/slackbuilds/gcc-5.5.0/antlr-runtime-3.4.jar --enable-multilib --target=x86_64-slackware-linux --build=x86_64-slackware-linux --host=x86_64-slackware-linux
+Thread model: posix
+gcc version 5.5.0 (GCC) 
+configure:2377: $? = 0
+configure:2366: gcc -V >&5
+gcc: error: unrecognized command line option '-V'
+gcc: fatal error: no input files
+compilation terminated.
+configure:2377: $? = 1
+configure:2366: gcc -qversion >&5
+gcc: error: unrecognized command line option '-qversion'
+gcc: fatal error: no input files
+compilation terminated.
+configure:2377: $? = 1
+configure:2397: checking whether the C compiler works
+configure:2419: gcc    conftest.c  >&5
+configure:2423: $? = 0
+configure:2471: result: yes
+configure:2474: checking for C compiler default output file name
+configure:2476: result: a.out
+configure:2482: checking for suffix of executables
+configure:2489: gcc -o conftest    conftest.c  >&5
+configure:2493: $? = 0
+configure:2515: result: 
+configure:2537: checking whether we are cross compiling
+configure:2545: gcc -o conftest    conftest.c  >&5
+configure:2549: $? = 0
+configure:2556: ./conftest
+configure:2560: $? = 0
+configure:2575: result: no
+configure:2580: checking for suffix of object files
+configure:2602: gcc -c   conftest.c >&5
+configure:2606: $? = 0
+configure:2627: result: o
+configure:2631: checking whether we are using the GNU C compiler
+configure:2650: gcc -c   conftest.c >&5
+configure:2650: $? = 0
+configure:2659: result: yes
+configure:2668: checking whether gcc accepts -g
+configure:2688: gcc -c -g  conftest.c >&5
+configure:2688: $? = 0
+configure:2729: result: yes
+configure:2746: checking for gcc option to accept ISO C89
+configure:2809: gcc  -c -g -O2  conftest.c >&5
+configure:2809: $? = 0
+configure:2822: result: none needed
+configure:2885: checking for ranlib
+configure:2901: found /usr/bin/ranlib
+configure:2912: result: ranlib
+configure:2936: checking for ginstall
+configure:2952: found /usr/bin/ginstall
+configure:2963: result: ginstall
+configure:2973: checking for install
+configure:3000: result: ginstall
+configure:3010: checking for tar
+configure:3026: found /usr/bin/tar
+configure:3037: result: tar
+configure:3070: checking for mosquitto_lib_init in -lmosquitto
+configure:3095: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline   conftest.c -lmosquitto   -lm >&5
+conftest.c:18:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ char mosquitto_lib_init ();
+ ^
+conftest.c:20:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3095: $? = 0
+configure:3104: result: yes
+configure:3119: checking how to run the C preprocessor
+configure:3150: gcc -E  conftest.c
+configure:3150: $? = 0
+configure:3164: gcc -E  conftest.c
+conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory
+compilation terminated.
+configure:3164: $? = 1
+configure: failed program was:
+| /* confdefs.h */
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define PACKAGE_URL ""
+| #define VERSION "0.0.2"
+| #define COPYRIGHT "Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+| /* end confdefs.h.  */
+| #include <ac_nonexistent.h>
+configure:3189: result: gcc -E
+configure:3209: gcc -E  conftest.c
+configure:3209: $? = 0
+configure:3223: gcc -E  conftest.c
+conftest.c:11:28: fatal error: ac_nonexistent.h: No such file or directory
+compilation terminated.
+configure:3223: $? = 1
+configure: failed program was:
+| /* confdefs.h */
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define PACKAGE_URL ""
+| #define VERSION "0.0.2"
+| #define COPYRIGHT "Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+| /* end confdefs.h.  */
+| #include <ac_nonexistent.h>
+configure:3252: checking for grep that handles long lines and -e
+configure:3310: result: /usr/bin/grep
+configure:3315: checking for egrep
+configure:3377: result: /usr/bin/grep -E
+configure:3382: checking for ANSI C header files
+configure:3402: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+conftest.c:17:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3402: $? = 0
+configure:3475: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline   conftest.c  -lm -lmosquitto >&5
+conftest.c:23:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3475: $? = 0
+configure:3475: ./conftest
+configure:3475: $? = 0
+configure:3486: result: yes
+configure:3499: checking for sys/types.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for sys/stat.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for stdlib.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for string.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for memory.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for strings.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for inttypes.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for stdint.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3499: checking for unistd.h
+configure:3499: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3499: $? = 0
+configure:3499: result: yes
+configure:3513: checking mosquitto.h usability
+configure:3513: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3513: $? = 0
+configure:3513: result: yes
+configure:3513: checking mosquitto.h presence
+configure:3513: gcc -E  conftest.c
+configure:3513: $? = 0
+configure:3513: result: yes
+configure:3513: checking for mosquitto.h
+configure:3513: result: yes
+configure:3527: checking for json_object_iter_init_default in -ljson-c
+configure:3552: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline   conftest.c -ljson-c   -lm -lmosquitto >&5
+conftest.c:29:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ char json_object_iter_init_default ();
+ ^
+conftest.c:31:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3552: $? = 0
+configure:3561: result: yes
+configure:3573: checking json-c/json.h usability
+configure:3573: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3573: $? = 0
+configure:3573: result: yes
+configure:3573: checking json-c/json.h presence
+configure:3573: gcc -E  conftest.c
+configure:3573: $? = 0
+configure:3573: result: yes
+configure:3573: checking for json-c/json.h
+configure:3573: result: yes
+configure:3587: checking for mysql_server_init in -lmysqlclient
+configure:3612: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline   conftest.c -lmysqlclient   -lm -lmosquitto -ljson-c >&5
+conftest.c:30:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ char mysql_server_init ();
+ ^
+conftest.c:32:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3612: $? = 0
+configure:3621: result: yes
+configure:3633: checking mysql/mysql.h usability
+configure:3633: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline  conftest.c >&5
+configure:3633: $? = 0
+configure:3633: result: yes
+configure:3633: checking mysql/mysql.h presence
+configure:3633: gcc -E  conftest.c
+configure:3633: $? = 0
+configure:3633: result: yes
+configure:3633: checking for mysql/mysql.h
+configure:3633: result: yes
+configure:3647: checking for xmlParseFile in -lxml2
+configure:3672: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline   conftest.c -lxml2   -lm -lmosquitto -ljson-c -lmysqlclient >&5
+conftest.c:31:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ char xmlParseFile ();
+ ^
+conftest.c:33:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3672: $? = 0
+configure:3681: result: yes
+configure:3694: checking libxml/xmlmemory.h usability
+configure:3694: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2  conftest.c >&5
+configure:3694: $? = 0
+configure:3694: result: yes
+configure:3694: checking libxml/xmlmemory.h presence
+configure:3694: gcc -E  conftest.c
+conftest.c:24:30: fatal error: libxml/xmlmemory.h: No such file or directory
+compilation terminated.
+configure:3694: $? = 1
+configure: failed program was:
+| /* confdefs.h */
+| #define PACKAGE_NAME ""
+| #define PACKAGE_TARNAME ""
+| #define PACKAGE_VERSION ""
+| #define PACKAGE_STRING ""
+| #define PACKAGE_BUGREPORT ""
+| #define PACKAGE_URL ""
+| #define VERSION "0.0.2"
+| #define COPYRIGHT "Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+| #define STDC_HEADERS 1
+| #define HAVE_SYS_TYPES_H 1
+| #define HAVE_SYS_STAT_H 1
+| #define HAVE_STDLIB_H 1
+| #define HAVE_STRING_H 1
+| #define HAVE_MEMORY_H 1
+| #define HAVE_STRINGS_H 1
+| #define HAVE_INTTYPES_H 1
+| #define HAVE_STDINT_H 1
+| #define HAVE_UNISTD_H 1
+| #define HAVE_MOSQUITTO_H 1
+| #define HAVE_JSON_C_JSON_H 1
+| #define HAVE_MYSQL_MYSQL_H 1
+| /* end confdefs.h.  */
+| #include <libxml/xmlmemory.h>
+configure:3694: result: no
+configure:3694: WARNING: libxml/xmlmemory.h: accepted by the compiler, rejected by the preprocessor!
+configure:3694: WARNING: libxml/xmlmemory.h: proceeding with the compiler's result
+configure:3694: checking for libxml/xmlmemory.h
+configure:3694: result: yes
+configure:3708: checking for uuid_generate in -luuid
+configure:3733: gcc -o conftest -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2   conftest.c -luuid   -lm -lmosquitto -ljson-c -lmysqlclient -lxml2 >&5
+conftest.c:32:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ char uuid_generate ();
+ ^
+conftest.c:34:1: warning: function declaration isn't a prototype [-Wstrict-prototypes]
+ main ()
+ ^
+configure:3733: $? = 0
+configure:3742: result: yes
+configure:3755: checking uuid/uuid.h usability
+configure:3755: gcc -c -g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2 -I/usr/include/uuid  conftest.c >&5
+configure:3755: $? = 0
+configure:3755: result: yes
+configure:3755: checking uuid/uuid.h presence
+configure:3755: gcc -E  conftest.c
+configure:3755: $? = 0
+configure:3755: result: yes
+configure:3755: checking for uuid/uuid.h
+configure:3755: result: yes
+configure:3770: checking for ANSI C header files
+configure:3874: result: yes
+configure:4003: creating ./config.status
+
+## ---------------------- ##
+## Running config.status. ##
+## ---------------------- ##
+
+This file was extended by config.status, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = 
+  CONFIG_HEADERS  = 
+  CONFIG_LINKS    = 
+  CONFIG_COMMANDS = 
+  $ ./config.status 
+
+on seaport
+
+config.status:816: creating Makefile.global
+config.status:816: creating config.h
+configure:5172: result:
+-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
+
+  Configuration summary :
+
+    Version : ............ 0.0.2
+    Main directory : ..... /usr/local
+
+
+  Now type 'make' and 'sudo make install'
+
+
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+
+ac_cv_c_compiler_gnu=yes
+ac_cv_env_CC_set=
+ac_cv_env_CC_value=
+ac_cv_env_CFLAGS_set=
+ac_cv_env_CFLAGS_value=
+ac_cv_env_CPPFLAGS_set=
+ac_cv_env_CPPFLAGS_value=
+ac_cv_env_CPP_set=
+ac_cv_env_CPP_value=
+ac_cv_env_LDFLAGS_set=
+ac_cv_env_LDFLAGS_value=
+ac_cv_env_LIBS_set=
+ac_cv_env_LIBS_value=
+ac_cv_env_build_alias_set=
+ac_cv_env_build_alias_value=
+ac_cv_env_host_alias_set=
+ac_cv_env_host_alias_value=
+ac_cv_env_target_alias_set=
+ac_cv_env_target_alias_value=
+ac_cv_header_inttypes_h=yes
+ac_cv_header_json_c_json_h=yes
+ac_cv_header_libxml_xmlmemory_h=yes
+ac_cv_header_memory_h=yes
+ac_cv_header_mosquitto_h=yes
+ac_cv_header_mysql_mysql_h=yes
+ac_cv_header_stdc=yes
+ac_cv_header_stdint_h=yes
+ac_cv_header_stdlib_h=yes
+ac_cv_header_string_h=yes
+ac_cv_header_strings_h=yes
+ac_cv_header_sys_stat_h=yes
+ac_cv_header_sys_types_h=yes
+ac_cv_header_unistd_h=yes
+ac_cv_header_uuid_uuid_h=yes
+ac_cv_lib_json_c_json_object_iter_init_default=yes
+ac_cv_lib_mosquitto_mosquitto_lib_init=yes
+ac_cv_lib_mysqlclient_mysql_server_init=yes
+ac_cv_lib_uuid_uuid_generate=yes
+ac_cv_lib_xml2_xmlParseFile=yes
+ac_cv_objext=o
+ac_cv_path_EGREP='/usr/bin/grep -E'
+ac_cv_path_GREP=/usr/bin/grep
+ac_cv_prog_CPP='gcc -E'
+ac_cv_prog_INSTALL=ginstall
+ac_cv_prog_TAR=tar
+ac_cv_prog_ac_ct_CC=gcc
+ac_cv_prog_ac_ct_RANLIB=ranlib
+ac_cv_prog_cc_c89=
+ac_cv_prog_cc_g=yes
+
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+
+CC='gcc'
+CFLAGS='-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2 -I/usr/include/uuid'
+COPYRIGHT='Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved'
+CPP='gcc -E'
+CPPFLAGS=''
+CYEARS='2016-2018'
+DEFS='-DHAVE_CONFIG_H'
+ECHO_C=''
+ECHO_N='-n'
+ECHO_T=''
+EGREP='/usr/bin/grep -E'
+EXEEXT=''
+GREP='/usr/bin/grep'
+INSTALL='ginstall'
+LDFLAGS=''
+LIBOBJS=''
+LIBS=' -lm -lmosquitto -ljson-c -lmysqlclient -lxml2 -luuid'
+LTLIBOBJS=''
+OBJEXT='o'
+PACKAGE='bms'
+PACKAGE_BUGREPORT=''
+PACKAGE_NAME=''
+PACKAGE_STRING=''
+PACKAGE_TARNAME=''
+PACKAGE_URL=''
+PACKAGE_VERSION=''
+PATH_SEPARATOR=':'
+RANLIB='ranlib'
+SDL_CFLAGS=''
+SDL_LIBS=''
+SHELL='/bin/sh'
+SUBDIRS='bmsd doc tools'
+TAR='tar'
+VERSION='0.0.2'
+ac_ct_CC='gcc'
+bindir='${exec_prefix}/bin'
+build_alias=''
+datadir='${datarootdir}'
+datarootdir='${prefix}/share'
+docdir='${datarootdir}/doc/${PACKAGE}'
+dvidir='${docdir}'
+exec_prefix='${prefix}'
+host_alias=''
+htmldir='${docdir}'
+includedir='${prefix}/include'
+infodir='${datarootdir}/info'
+libdir='${exec_prefix}/lib'
+libexecdir='${exec_prefix}/libexec'
+localedir='${datarootdir}/locale'
+localstatedir='${prefix}/var'
+mandir='${datarootdir}/man'
+oldincludedir='/usr/include'
+pdfdir='${docdir}'
+prefix='/usr/local'
+program_transform_name='s,x,x,'
+psdir='${docdir}'
+sbindir='${exec_prefix}/sbin'
+sharedstatedir='${prefix}/com'
+sysconfdir='${prefix}/etc'
+target_alias=''
+
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+
+/* confdefs.h */
+#define PACKAGE_NAME ""
+#define PACKAGE_TARNAME ""
+#define PACKAGE_VERSION ""
+#define PACKAGE_STRING ""
+#define PACKAGE_BUGREPORT ""
+#define PACKAGE_URL ""
+#define VERSION "0.0.2"
+#define COPYRIGHT "Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+#define STDC_HEADERS 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_STRINGS_H 1
+#define HAVE_INTTYPES_H 1
+#define HAVE_STDINT_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_MOSQUITTO_H 1
+#define HAVE_JSON_C_JSON_H 1
+#define HAVE_MYSQL_MYSQL_H 1
+#define HAVE_LIBXML_XMLMEMORY_H 1
+#define HAVE_UUID_UUID_H 1
+#define STDC_HEADERS 1
+
+configure: exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.status	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,1006 @@
+#! /bin/sh
+# Generated by configure.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+# Files that config.status was made for.
+config_files=" Makefile.global"
+config_headers=" config.h"
+
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to the package provider."
+
+ac_cs_config=""
+ac_cs_version="\
+config.status
+configured by ./configure, generated by GNU Autoconf 2.69,
+  with options \"$ac_cs_config\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='/home/mbroek/MyProjects/bms'
+srcdir='.'
+test -n "$AWK" || AWK=awk
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+if $ac_cs_recheck; then
+  set X /bin/sh './configure'  $ac_configure_extra_args --no-create --no-recursion
+  shift
+  $as_echo "running CONFIG_SHELL=/bin/sh $*" >&6
+  CONFIG_SHELL='/bin/sh'
+  export CONFIG_SHELL
+  exec "$@"
+fi
+
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "Makefile.global") CONFIG_FILES="$CONFIG_FILES Makefile.global" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+cat >>"$ac_tmp/subs1.awk" <<\_ACAWK &&
+S["LTLIBOBJS"]=""
+S["LIBOBJS"]=""
+S["SDL_LIBS"]=""
+S["SDL_CFLAGS"]=""
+S["EGREP"]="/usr/bin/grep -E"
+S["GREP"]="/usr/bin/grep"
+S["CPP"]="gcc -E"
+S["TAR"]="tar"
+S["INSTALL"]="ginstall"
+S["RANLIB"]="ranlib"
+S["OBJEXT"]="o"
+S["EXEEXT"]=""
+S["ac_ct_CC"]="gcc"
+S["CPPFLAGS"]=""
+S["LDFLAGS"]=""
+S["CFLAGS"]="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline -I/usr/include/libxml2 -I/usr/include/u"\
+"uid"
+S["CC"]="gcc"
+S["CYEARS"]="2016-2018"
+S["COPYRIGHT"]="Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+S["VERSION"]="0.0.2"
+S["PACKAGE"]="bms"
+S["SUBDIRS"]="bmsd doc tools"
+S["target_alias"]=""
+S["host_alias"]=""
+S["build_alias"]=""
+S["LIBS"]=" -lm -lmosquitto -ljson-c -lmysqlclient -lxml2 -luuid"
+S["ECHO_T"]=""
+S["ECHO_N"]="-n"
+S["ECHO_C"]=""
+S["DEFS"]="-DHAVE_CONFIG_H"
+S["mandir"]="${datarootdir}/man"
+S["localedir"]="${datarootdir}/locale"
+S["libdir"]="${exec_prefix}/lib"
+S["psdir"]="${docdir}"
+S["pdfdir"]="${docdir}"
+S["dvidir"]="${docdir}"
+S["htmldir"]="${docdir}"
+S["infodir"]="${datarootdir}/info"
+S["docdir"]="${datarootdir}/doc/${PACKAGE}"
+S["oldincludedir"]="/usr/include"
+S["includedir"]="${prefix}/include"
+S["localstatedir"]="${prefix}/var"
+S["sharedstatedir"]="${prefix}/com"
+S["sysconfdir"]="${prefix}/etc"
+S["datadir"]="${datarootdir}"
+S["datarootdir"]="${prefix}/share"
+S["libexecdir"]="${exec_prefix}/libexec"
+S["sbindir"]="${exec_prefix}/sbin"
+S["bindir"]="${exec_prefix}/bin"
+S["program_transform_name"]="s,x,x,"
+S["prefix"]="/usr/local"
+S["exec_prefix"]="${prefix}"
+S["PACKAGE_URL"]=""
+S["PACKAGE_BUGREPORT"]=""
+S["PACKAGE_STRING"]=""
+S["PACKAGE_VERSION"]=""
+S["PACKAGE_TARNAME"]=""
+S["PACKAGE_NAME"]=""
+S["PATH_SEPARATOR"]=":"
+S["SHELL"]="/bin/sh"
+_ACAWK
+cat >>"$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+D["PACKAGE_NAME"]=" \"\""
+D["PACKAGE_TARNAME"]=" \"\""
+D["PACKAGE_VERSION"]=" \"\""
+D["PACKAGE_STRING"]=" \"\""
+D["PACKAGE_BUGREPORT"]=" \"\""
+D["PACKAGE_URL"]=" \"\""
+D["VERSION"]=" \"0.0.2\""
+D["COPYRIGHT"]=" \"Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved\""
+D["STDC_HEADERS"]=" 1"
+D["HAVE_SYS_TYPES_H"]=" 1"
+D["HAVE_SYS_STAT_H"]=" 1"
+D["HAVE_STDLIB_H"]=" 1"
+D["HAVE_STRING_H"]=" 1"
+D["HAVE_MEMORY_H"]=" 1"
+D["HAVE_STRINGS_H"]=" 1"
+D["HAVE_INTTYPES_H"]=" 1"
+D["HAVE_STDINT_H"]=" 1"
+D["HAVE_UNISTD_H"]=" 1"
+D["HAVE_MOSQUITTO_H"]=" 1"
+D["HAVE_JSON_C_JSON_H"]=" 1"
+D["HAVE_MYSQL_MYSQL_H"]=" 1"
+D["HAVE_LIBXML_XMLMEMORY_H"]=" 1"
+D["HAVE_UUID_UUID_H"]=" 1"
+D["STDC_HEADERS"]=" 1"
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+[_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ][_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]*([\t (]|$)/ {
+  line = $ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+  ac_datarootdir_hack='
+  s&@datadir@&${datarootdir}&g
+  s&@docdir@&${datarootdir}/doc/${PACKAGE}&g
+  s&@infodir@&${datarootdir}/info&g
+  s&@localedir@&${datarootdir}/locale&g
+  s&@mandir@&${datarootdir}/man&g
+  s&\${datarootdir}&${prefix}/share&g' ;;
+esac
+ac_sed_extra="/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}
+
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
+  case $ac_file in
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+ ;;
+
+
+  esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,5184 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir/$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+PACKAGE_URL=
+
+ac_unique_file="bmsd/bms.c"
+ac_default_prefix=/usr/local
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='LTLIBOBJS
+LIBOBJS
+SDL_LIBS
+SDL_CFLAGS
+EGREP
+GREP
+CPP
+TAR
+INSTALL
+RANLIB
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+CYEARS
+COPYRIGHT
+VERSION
+PACKAGE
+SUBDIRS
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_debugging
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking ...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-debugging      Compile for debugging
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+	ac_must_keep_next=false # Got value, back to normal.
+      else
+	case $ac_arg in
+	  *=* | --config-cache | -C | -disable-* | --disable-* \
+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+	  | -with-* | --with-* | -without-* | --without-* | --x)
+	    case "$ac_configure_args0 " in
+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+	    esac
+	    ;;
+	  -* ) ac_must_keep_next=true ;;
+	esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	$as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+SUBDIRS="bmsd doc tools"
+
+
+PACKAGE="bms"
+VERSION="0.0.2"
+COPYRIGHT="Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+CYEARS="2016-2018"
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define COPYRIGHT "$COPYRIGHT"
+_ACEOF
+
+TARGET="$target"
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+# Extract the first word of "ginstall", so it can be a program name with args.
+set dummy ginstall; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_INSTALL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$INSTALL"; then
+  ac_cv_prog_INSTALL="$INSTALL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_INSTALL="ginstall"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+INSTALL=$ac_cv_prog_INSTALL
+if test -n "$INSTALL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+# Extract the first word of "install", so it can be a program name with args.
+set dummy install; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_INSTALL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$INSTALL"; then
+  ac_cv_prog_INSTALL="$INSTALL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_INSTALL="install"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+INSTALL=$ac_cv_prog_INSTALL
+if test -n "$INSTALL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+# Extract the first word of "tar", so it can be a program name with args.
+set dummy tar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_TAR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$TAR"; then
+  ac_cv_prog_TAR="$TAR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_TAR="tar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+TAR=$ac_cv_prog_TAR
+if test -n "$TAR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR" >&5
+$as_echo "$TAR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+#
+# Additional commandline switches
+#
+
+# Check whether --enable-debugging was given.
+if test "${enable_debugging+set}" = set; then :
+  enableval=$enable_debugging;  debugging=$enableval
+else
+   debugging=no
+fi
+
+if test "$debugging" = "yes"; then
+  CFLAGS="-O -g -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
+else
+  CFLAGS="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
+fi
+LIBS="$LIBS -lm"
+
+
+#
+# Libraries for bms
+#
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mosquitto_lib_init in -lmosquitto" >&5
+$as_echo_n "checking for mosquitto_lib_init in -lmosquitto... " >&6; }
+if ${ac_cv_lib_mosquitto_mosquitto_lib_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmosquitto  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mosquitto_lib_init ();
+int
+main ()
+{
+return mosquitto_lib_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_mosquitto_mosquitto_lib_init=yes
+else
+  ac_cv_lib_mosquitto_mosquitto_lib_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mosquitto_mosquitto_lib_init" >&5
+$as_echo "$ac_cv_lib_mosquitto_mosquitto_lib_init" >&6; }
+if test "x$ac_cv_lib_mosquitto_mosquitto_lib_init" = xyes; then :
+  result=yes
+else
+  result=no
+fi
+
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lmosquitto"
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in mosquitto.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "mosquitto.h" "ac_cv_header_mosquitto_h" "$ac_includes_default"
+if test "x$ac_cv_header_mosquitto_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MOSQUITTO_H 1
+_ACEOF
+
+fi
+
+done
+
+else
+  as_fn_error $? "mosquitto not found" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for json_object_iter_init_default in -ljson-c" >&5
+$as_echo_n "checking for json_object_iter_init_default in -ljson-c... " >&6; }
+if ${ac_cv_lib_json_c_json_object_iter_init_default+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ljson-c  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char json_object_iter_init_default ();
+int
+main ()
+{
+return json_object_iter_init_default ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_json_c_json_object_iter_init_default=yes
+else
+  ac_cv_lib_json_c_json_object_iter_init_default=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_json_c_json_object_iter_init_default" >&5
+$as_echo "$ac_cv_lib_json_c_json_object_iter_init_default" >&6; }
+if test "x$ac_cv_lib_json_c_json_object_iter_init_default" = xyes; then :
+  result=yes
+else
+  result=no
+fi
+
+if test "$result" = "yes"; then
+  LIBS="$LIBS -ljson-c"
+  for ac_header in json-c/json.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "json-c/json.h" "ac_cv_header_json_c_json_h" "$ac_includes_default"
+if test "x$ac_cv_header_json_c_json_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_JSON_C_JSON_H 1
+_ACEOF
+
+fi
+
+done
+
+else
+  as_fn_error $? "json-c not found" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for mysql_server_init in -lmysqlclient" >&5
+$as_echo_n "checking for mysql_server_init in -lmysqlclient... " >&6; }
+if ${ac_cv_lib_mysqlclient_mysql_server_init+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmysqlclient  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char mysql_server_init ();
+int
+main ()
+{
+return mysql_server_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_mysqlclient_mysql_server_init=yes
+else
+  ac_cv_lib_mysqlclient_mysql_server_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mysqlclient_mysql_server_init" >&5
+$as_echo "$ac_cv_lib_mysqlclient_mysql_server_init" >&6; }
+if test "x$ac_cv_lib_mysqlclient_mysql_server_init" = xyes; then :
+  result=yes
+else
+  result=no
+fi
+
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lmysqlclient"
+  for ac_header in mysql/mysql.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "mysql/mysql.h" "ac_cv_header_mysql_mysql_h" "$ac_includes_default"
+if test "x$ac_cv_header_mysql_mysql_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MYSQL_MYSQL_H 1
+_ACEOF
+
+fi
+
+done
+
+else
+  as_fn_error $? "mysqlclient not found" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for xmlParseFile in -lxml2" >&5
+$as_echo_n "checking for xmlParseFile in -lxml2... " >&6; }
+if ${ac_cv_lib_xml2_xmlParseFile+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lxml2  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char xmlParseFile ();
+int
+main ()
+{
+return xmlParseFile ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_xml2_xmlParseFile=yes
+else
+  ac_cv_lib_xml2_xmlParseFile=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xml2_xmlParseFile" >&5
+$as_echo "$ac_cv_lib_xml2_xmlParseFile" >&6; }
+if test "x$ac_cv_lib_xml2_xmlParseFile" = xyes; then :
+  result=yes
+else
+  result=no
+fi
+
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lxml2"
+  CFLAGS="$CFLAGS $(xml2-config --cflags)"
+  for ac_header in libxml/xmlmemory.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "libxml/xmlmemory.h" "ac_cv_header_libxml_xmlmemory_h" "$ac_includes_default"
+if test "x$ac_cv_header_libxml_xmlmemory_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBXML_XMLMEMORY_H 1
+_ACEOF
+
+fi
+
+done
+
+else
+  as_fn_error $? "libxml2 not found" "$LINENO" 5
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uuid_generate in -luuid" >&5
+$as_echo_n "checking for uuid_generate in -luuid... " >&6; }
+if ${ac_cv_lib_uuid_uuid_generate+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-luuid  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char uuid_generate ();
+int
+main ()
+{
+return uuid_generate ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_uuid_uuid_generate=yes
+else
+  ac_cv_lib_uuid_uuid_generate=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_uuid_uuid_generate" >&5
+$as_echo "$ac_cv_lib_uuid_uuid_generate" >&6; }
+if test "x$ac_cv_lib_uuid_uuid_generate" = xyes; then :
+  result=yes
+else
+  result=no
+fi
+
+if test "$result" = "yes"; then
+  LIBS="$LIBS $(pkg-config --libs uuid)"
+  CFLAGS="$CFLAGS $(pkg-config --cflags uuid)"
+  for ac_header in uuid/uuid.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "uuid/uuid.h" "ac_cv_header_uuid_uuid_h" "$ac_includes_default"
+if test "x$ac_cv_header_uuid_uuid_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UUID_UUID_H 1
+_ACEOF
+
+fi
+
+done
+
+else
+  as_fn_error $? "libuuid not found" "$LINENO" 5
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+
+
+
+
+
+ac_config_files="$ac_config_files Makefile.global"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+	"s/'/'\\\\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    if test "x$cache_file" != "x/dev/null"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+      if test ! -f "$cache_file" || test -h "$cache_file"; then
+	cat confcache >"$cache_file"
+      else
+        case $cache_file in #(
+        */* | ?:*)
+	  mv -f confcache "$cache_file"$$ &&
+	  mv -f "$cache_file"$$ "$cache_file" ;; #(
+        *)
+	  mv -f confcache "$cache_file" ;;
+	esac
+      fi
+    fi
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+U=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.69,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=?*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  --*=)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    '') as_fn_error $? "missing file argument" ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "Makefile.global") CONFIG_FILES="$CONFIG_FILES Makefile.global" ;;
+
+  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp= ac_tmp=
+  trap 'exit_status=$?
+  : "${ac_tmp:=$tmp}"
+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = ""
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
+h
+s///
+s/^/:/
+s/[	 ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[	 ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[	 ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_tt"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    "
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$ac_tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
+	 # because $ac_f cannot contain `:'.
+	 test -f "$ac_f" ||
+	   case $ac_f in
+	   [\\/$]*) false;;
+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+	   esac ||
+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+	`' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$ac_tmp/stdin" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$ac_file" : 'X\(//\)[^/]' \| \
+	 X"$ac_file" : 'X\(//\)$' \| \
+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
+      "$ac_tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined" >&2;}
+
+  rm -f "$ac_tmp/stdin"
+  case $ac_file in
+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+    } >"$ac_tmp/config.h" \
+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$ac_tmp/config.h" "$ac_file" \
+	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error $? "could not create -" "$LINENO" 5
+  fi
+ ;;
+
+
+  esac
+
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result:
+-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
+
+  Configuration summary :
+
+    Version : ............ ${VERSION}
+    Main directory : ..... ${prefix}
+
+
+  Now type 'make' and 'sudo make install'
+" >&5
+$as_echo "
+-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
+
+  Configuration summary :
+
+    Version : ............ ${VERSION}
+    Main directory : ..... ${prefix}
+
+
+  Now type 'make' and 'sudo make install'
+" >&6; }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.ac	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,114 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT(bmsd/bms.c)
+AM_CONFIG_HEADER(config.h)
+SUBDIRS="bmsd doc tools"
+AC_SUBST(SUBDIRS)
+
+dnl General settings
+dnl After changeing the version number, run autoconf!
+PACKAGE="bms"
+VERSION="0.0.2"
+COPYRIGHT="Copyright (C) 2016-2018 Michiel Broek, All Rights Reserved"
+CYEARS="2016-2018"
+AC_SUBST(PACKAGE)
+AC_SUBST(VERSION)
+AC_SUBST(COPYRIGHT)
+AC_SUBST(CYEARS)
+AC_PREFIX_DEFAULT(/usr/local)
+AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
+AC_DEFINE_UNQUOTED(COPYRIGHT, "$COPYRIGHT")
+TARGET="$target"
+
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_RANLIB
+dnl Try to find GNU install
+AC_CHECK_PROG(INSTALL, ginstall, ginstall)
+AC_CHECK_PROG(INSTALL, install, install)
+AC_CHECK_PROG(TAR, tar, tar)
+
+
+#
+# Additional commandline switches
+#
+
+AC_ARG_ENABLE(debugging,   [  --enable-debugging      Compile for debugging], [ debugging=$enableval ], [ debugging=no ])
+if test "$debugging" = "yes"; then
+  CFLAGS="-O -g -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"    
+else
+  CFLAGS="-g -O2 -fomit-frame-pointer -fno-strict-aliasing -Wall -Wshadow -Wwrite-strings -Wstrict-prototypes -Winline"
+fi
+LIBS="$LIBS -lm"
+
+
+#
+# Libraries for bms
+#
+AC_CHECK_LIB(mosquitto,mosquitto_lib_init,result=yes,result=no)
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lmosquitto"
+  AC_CHECK_HEADERS(mosquitto.h)
+else
+  AC_MSG_ERROR(mosquitto not found)
+fi
+
+AC_CHECK_LIB(json-c,json_object_iter_init_default,result=yes,result=no)
+if test "$result" = "yes"; then
+  LIBS="$LIBS -ljson-c"
+  AC_CHECK_HEADERS(json-c/json.h)
+else
+  AC_MSG_ERROR(json-c not found)
+fi
+
+AC_CHECK_LIB(mysqlclient,mysql_server_init,result=yes,result=no)
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lmysqlclient"
+  AC_CHECK_HEADERS(mysql/mysql.h)
+else
+  AC_MSG_ERROR(mysqlclient not found)
+fi
+
+AC_CHECK_LIB(xml2,xmlParseFile,result=yes,result=no)
+if test "$result" = "yes"; then
+  LIBS="$LIBS -lxml2"
+  CFLAGS="$CFLAGS $(xml2-config --cflags)"
+  AC_CHECK_HEADERS(libxml/xmlmemory.h)
+else
+  AC_MSG_ERROR(libxml2 not found)
+fi
+
+AC_CHECK_LIB(uuid,uuid_generate,result=yes,result=no)
+if test "$result" = "yes"; then
+  LIBS="$LIBS $(pkg-config --libs uuid)"
+  CFLAGS="$CFLAGS $(pkg-config --cflags uuid)"
+  AC_CHECK_HEADERS(uuid/uuid.h)
+else
+  AC_MSG_ERROR(libuuid not found)
+fi
+
+
+dnl Checks for header files.
+AC_HEADER_STDC
+
+AC_SUBST(SDL_CFLAGS)
+AC_SUBST(SDL_LIBS)
+
+
+AC_OUTPUT(
+    Makefile.global
+)
+
+AC_MSG_RESULT([
+-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
+
+  Configuration summary :
+
+    Version : ............ ${VERSION}
+    Main directory : ..... ${prefix}
+
+
+  Now type 'make' and 'sudo make install'
+])
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/Makefile	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,39 @@
+# Makefile for the bms documentation.
+# Copyright (c) 2018 by M. Broek.
+
+include ../Makefile.global
+
+SRC		= bms.sgml bms-ch1.sgml bms-ch2.sgml bms-ch3.sgml
+HTML		= bms.html
+PDF		= bms.pdf
+OTHER		= Makefile docbook-utils.dsl 
+
+#############################################################################
+
+.c.o:
+		${CC} ${CFLAGS} ${INCLUDES} ${DEFINES} -c $<
+
+all:		pdf
+
+bms.pdf:	${SRC} docbook-utils.dsl
+		docbook2pdf -d docbook-utils.dsl#print bms.sgml
+
+bms.html:	${SRC} docbook-utils.dsl
+		docbook2html -d docbook-utils.dsl#html -u bms.sgml
+
+pdf:		${PDF}
+
+html:		${HTML}
+
+clean:
+		rm -f *.pdf *.html
+
+install:	all
+
+filelist:	Makefile
+		BASE=`pwd`; \
+		BASE=`basename $${BASE}`; \
+		(for f in ${SRC} ${OTHER} ;do echo ${PACKAGE}-${VERSION}/$${BASE}/$$f; done) >filelist
+
+depend:
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/bms-ch1.sgml	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,11 @@
+<!-- 
+  vim:syntax=docbksgml
+-->
+
+<chapter id="introductie">
+<title>Introductie.</title>
+<para>
+Introductie tekst.
+</para>
+
+</chapter>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/bms-ch2.sgml	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,38 @@
+<!-- 
+  vim:syntax=docbksgml
+-->
+
+<chapter id="design">
+<title>Architectuur.</title>
+<para>
+Het Brouwerij Management Systeem, afgekort <command>bms</command>, is een applicatie
+server die luistert naar MQTT berichten in de <command>mbv1.0</command> basis van het
+topic. Zie de <ulink url="https://en.wikipedia.org/wiki/MQTT">MQTT wiki</ulink> voor
+meer informatie over het MQTT protocol.
+</para>
+
+<para>
+Als bron dienen onder andere vergistings controllers. Deze sturen MQTT berichten naar
+de MQTT server. Deze berichten komen dan in het bms systeem terecht die ze verwerkt.
+De controllers hoeven niet eerst bekend gemaakt te worden, het protocol is zo ontworpen
+dan controllers zichzelf aankondigen en opgenomen worden in de brouwerij. Dit gebeurt door
+het sturen van 'node' berichten. Ongeacht de functie van een controller, iedere controller
+stuurt 'node' berichten. Verder stuurt een vergisting controller een of meer
+gistkasten. Voer iedere kast worden er 'device' berichten gestuurd.
+</para>
+
+<figure><title>BMS architectuur,</title>
+<mediaobject id="bms-flow-config">
+<imageobject>
+<imagedata fileref="bms-flow.png" scale="80" format="png">
+</imageobject>
+</mediaobject>
+</figure>
+
+<para>
+Vanuit de bms applicatie kunnen er via de MQTT server ook commando's naar de controllers worden
+gestuurd. Van een vergisting kast kan bijvoorbeeld de temperatuur ingesteld worden, of kan
+de controller aan of uit gezet worden.
+</para>
+
+</chapter>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/bms-ch3.sgml	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,304 @@
+<!-- 
+  vim:syntax=docbksgml
+-->
+
+<chapter id="protocols">
+<title>Protocollen.</title>
+<para>
+De netwerk protocollen.
+</para>
+
+<sect1 id="prototopic">
+<title>MQTT topic formaat.</title>
+<para>De topics zijn als volgt gedefinieerd:</para>
+<programlisting>
+mbv1.0/<code>group_id</code>/<code>message_type</code>/<code>edge_node</code>/<code>device_id</code>
+</programlisting>
+
+<itemizedlist>
+<listitem><para><code>group_id</code> geeft het type apparaat aan zoals <code>fermenters</code>
+en <code>brewcontrol</code>.</para></listitem>
+<listitem><para><code>message_type</code> geeft het bericht type aan zoals
+<code>NBIRTH</code>, <code>DDATA</code>.</para></listitem>
+<listitem><para><code>edge_node</code> is de hostnaam van de node die het bericht stuurt. Dit is
+de naam zonder domain toevoeging.</para></listitem>
+<listitem><para><code>device_id</code> is de verkorte naam van het apparaat module waarvan dit
+bericht komt zoals de naam van een vergisting controller. Dit is niet aanwezig met NODE berichten.</para></listitem>
+</itemizedlist>
+
+<para>
+De volgende <code>group_id</code> namen zijn gedefinieerd:
+</para>
+<orderedlist>
+<listitem><para>brewery is voor de bms applicatie zelf. Nog uitwerken.</para></listitem>
+<listitem><para>fermenters is voor vergisting controllers.</para></listitem>
+<listitem><para>brewcontrol is een brouw controller. Deze controller kan een deel
+of geheel brouwproces uitvoeren.</para></listitem>
+<listitem><para>pressure is een drukmeter om bijvoorbeeld hergisting op de fles
+te monitoren.</para></listitem>
+</orderedlist>
+
+<para>De volgende <code>message_type</code> namen zijn gedefinieerd:</para>
+<orderedlist>
+<listitem><para>NBIRTH geeft aan wanneer een node opstart en met het netwerk
+verbonden is. Dit is een zogenaamd persistent bericht, het blijft voor nieuwe
+MQTT clients altijd zichtbaar. Bij het starten van een node wordt er een payload
+verzonden, zie het payload formaat voor een node. Als een node afsluit wordt juist geen
+payload verzonden zodat het bericht verdwijnt.</para></listitem>
+<listitem><para>NDATA wordt verstuurd als er veranderingen zijn voor de node,
+maar ook iedere vijf minuten om aan te geven dat de node nog "levend" en aanwezig
+is.</para></listitem>
+<listitem><para>NDEATH wordt verstuurd als een node offline gaat. Maar het kan ook
+ontvangen worden als de MQTT verbinding verbroken wordt met een node, het NDEATH
+bericht is ook het `last will' bericht van een node.</para></listitem>
+<listitem><para>NCMD uitwerken.</para></listitem>
+<listitem><para>DBIRTH is een of meer berichten van een apparaat wat online komt
+en ingeschakeld is. Bij het opstarten van de node is er geen <code>device_id</code>
+omdat alle apparaten is een keer verstuurd worden. Indien er later een enkel apparaat
+ingeschakeld wordt dan is er wel een geldige <code>device_id</code> aanwezig.
+Hier ook weer, er is een payload bij opstarten en geen payload bij afsluiten om het
+persistente bericht goed te houden.</para></listitem>
+<listitem><para>DDATA heeft altijd een payload, maar deze hoeft niet volledig te zijn,
+enkel de gewijzigde data moet in het bericht zitten.</para></listitem>
+<listitem><para>DDEATH wordt verstuurd als een node offline gaat, of als het apparaat
+uitgeschakelt wordt.</para></listitem>
+<listitem><para>DLOG is een data log. Hier bestaat de payload uit gegevens die de
+bms applicatie in de database zet.</para></listitem>
+<listitem><para>DCMD uitwerken.</para></listitem>
+</orderedlist>
+
+</sect1>
+
+
+<sect1 id="payloadnode">
+<title>Netwerk payload formaat voor een node</title>
+<para>
+De payload zoals die door een node verstuurd wordt. Het wordt in json formaat
+verzonder zonder extra spaties en opmaak zoals hieronder is te zien. Het timestamp
+is de unix tijd sinds 1 januari 1970. Het `seq' nummer wordt met ieder bericht met 1
+verhoogd.</para>
+
+<programlisting>
+{
+  "timestamp": 1532201089,
+  "seq": 0,
+  "metric": {
+    "uuid": "b508f01c-1f82-4e8b-b0d2-d88ecfb53031",
+    "properties": {
+      "hardwaremake": "Raspberry",
+      "hardwaremodel": "Unknown",
+      "os": "Linux",
+      "os_version": "4.1.19+",
+      "FW": "0.8.2"
+    },
+    "THB": {
+      "temperature": 20.0,
+      "humidity": 50.0,
+      "barometer": 1002
+    },
+    "GPS": {
+      "latitude": 1.2345,
+      "longitude": 2.3456,
+      "altitude": 20
+    },
+    "net": {
+      "address": "10.126.151.11",
+      "ifname": "eth0",
+      "rssi": 0
+    }
+  }
+}
+</programlisting>
+</sect1>
+
+<sect1 id="cmdnode">
+<title>Netwerk kommando payload formaat voor nodes.</title>
+<para>De volgende kommando's kunnen gestuurd worden naar nodes:</para>
+<programlisting>
+{
+  "timestamp":1532201089,
+  "metric": {
+    "Node Control/Reboot":true
+  }
+}
+
+{
+  "timestamp":1532201089,
+  "metric": {
+    "Node Control/Rebirth":true
+  }
+}
+</programlisting>
+</sect1>
+
+<sect1 id="payloadfermdata">
+<title>Netwerk payload data formaat voor vergisting controllers</title>
+<para>
+Dit is het meest uitgebreide formaat wat getoond is. Indien er bijvoorbeeld geen
+chiller aanwezig is, dan wordt eem `null' gestuurd in plaats van een json blok
+met gegevens. De werkelijke uitvoering van de hardware en de configuratie daarvan
+bepaald dus het uiteindelijke payload formaat.
+</para>
+<programlisting>
+{
+  "uuid": "48c9ae27-3f58-41c9-ae4b-1d57b249c45a",
+  "alias": "unit1",
+  "product": {
+    "code": "CB0063",
+    "name": "Schot voor de boeg"
+  },
+  "product": {
+    "uuid": "1eb0c7bf-bf06-491c-a086-ac5478d521b9",
+    "code": "CB0001",
+    "name": "Hoppy Housebeer"
+  },
+  "air": {
+    "address": "70d60411-3ec8-40ab-998a-81fead83025f",
+    "state": "OK",
+    "temperature": 21.562
+  },
+  "beer": {
+    "address": "8ec36f9d-f382-4e32-a47f-732642e1018d",
+    "state": "OK",
+    "temperature": 22.125
+  },
+  "chiller": {
+    "address": "e81265b8-07f7-4b22-96c1-6f55a4b66a83",
+    "state": "OK",
+    "temperature": 12.437
+  },
+  "heater": {
+    "address": "d2f2d6bc-4d12-4852-9462-95f4c2476034",
+    "state": 0,
+    "usage": 10710793
+  },
+  "cooler": {
+    "address": "a9f30140-812c-4ec1-9e98-3a9d47deff7c",
+    "state": 0,
+    "usage": 920504
+  },
+  "fan": {
+    "address": "ae9f9887-8209-4810-9f58-ddfb34ee142f",
+    "state": 100,
+    "usage": 62889739
+  },
+  "light": {
+    "address": "cc6353cf-9c97-41b9-b6cf-00cea312e478",
+    "state": 0,
+    "usage": 29647290
+  },
+  "door": {
+    "address": "ad8746d1-0549-485a-a215-41e5cdde9e75",
+    "state": 1
+  },
+  "psu": {
+    "address": "e1bb7182-883d-4977-a1c0-76e214072fc5",
+    "state": 1
+  },
+  "stage": "PRIMARY",
+  "mode": "BEER",
+  "setpoint": {
+    "low": 21.0,
+    "high": 21.0
+  },
+  "alarm": 0,
+  "profile": {
+    "uuid": "c93ad1bb-0446-4788-9c43-83990c5f8b82",
+    "name": "Witbier methode Cellis",
+    "state": "OFF",
+    "percent": 0,
+    "inittemp": {
+      "low": 17.9,
+      "high": 18.1
+    },
+    "fridgemode": 0,
+    "steps": [
+      {
+        "resttime": 2,
+        "steptime": 0,
+        "target": {
+          "low": 18.0,
+          "high": 18.0
+        },
+        "fridgemode": 0
+      },
+      {
+        "resttime": 0,
+        "steptime": 24,
+        "target": {
+          "low": 18.0,
+          "high": 22.0
+        },
+        "fridgemode": 0
+      },
+      {
+        "resttime": 48,
+        "steptime": 96,
+        "target": {
+          "low": 26.0,
+          "high": 26.0
+        },
+        "fridgemode": 0
+      }
+    ]
+  }
+}
+</programlisting>
+<para>Temperature states can be: OK, MISSING or ERROR.<para>
+<para>The general `mode' can be: OFF, NONE, FRIDGE, BEER or PROFILE.</para>
+<para>The profile `state' can be: OFF, PAUSE, RUN, DONE or ABORT.</para>
+</sect1>
+
+
+<sect1 id="payloadfermlog">
+<title>Netwerk payload log formaat voor vergisting controllers</title>
+<para>
+Dit is het meest uitgebreide formaat wat getoond is. Indien er bijvoorbeeld geen
+chiller aanwezig is, dan wordt geen data hiervoor verstuurd.
+De werkelijke uitvoering van de hardware en de configuratie daarvan
+bepaald dus het uiteindelijke payload formaat.
+</para>
+<programlisting>
+{
+  "timestamp": 1532201089,
+  "seq": 0,
+  "metric": {
+    "product": {
+      "uuid": "1eb0c7bf-bf06-491c-a086-ac5478d521b9",
+      "code": "CB0001",
+      "name": "Hoppy Housebeer"     
+    },
+    "stage": "PRIMARY",
+    "mode": "BEER",
+    "temperature": {
+      "air": 20.125,
+      "beer": 20.062,
+      "chiller": -3.000,
+      "room": 20.1
+    },
+    "setpoint": {
+      "low": 19.8,
+      "high": 20.1
+    },
+    "heater": {
+      "power": 100,
+      "usage": 1234
+    },
+    "cooler": {
+      "power": 0,
+      "usage": 27273
+    },
+    "fan": {
+      "power": 100,
+      "usage": 8273772
+    },
+    "sg": 1.023,
+    "event": "Something to mark",
+    "fermenter_uuid": "48c9ae27-3f58-41c9-ae4b-1d57b249c45a"
+  }
+}
+</programlisting>
+</sect1>
+
+
+</chapter>
Binary file doc/bms-flow.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/bms.sgml	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,34 @@
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.4//EN" [
+<!ENTITY chapter1 SYSTEM "bms-ch1.sgml">
+<!ENTITY chapter2 SYSTEM "bms-ch2.sgml">
+<!ENTITY chapter3 SYSTEM "bms-ch3.sgml">
+]>
+
+<book lang="nl">
+<bookinfo>
+    <title>Brouwerij Management Systeem handleiding.</title>
+    <authorgroup>
+	<author>
+	    <firstname>Michiel</firstname>
+	    <surname>Broek</surname>
+	</author>
+    </authorgroup>
+
+    <copyright>
+	<year>2018</year>
+	<holder role='mailto:mbse@mbse.eu'>M. Broek</holder>
+    </copyright>
+
+    <releaseinfo>Version 0.0.1</releaseinfo>
+    <abstract>
+	<para>
+	    Documentatie voor het Brouwerij Management Systeem software pakket.
+	</para>
+    </abstract>
+</bookinfo>
+
+&chapter1;
+&chapter2;
+&chapter3;
+
+</book>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/docbook-utils.dsl	Sat Aug 04 21:19:15 2018 +0200
@@ -0,0 +1,975 @@
+<!DOCTYPE style-sheet PUBLIC "-//James Clark//DTD DSSSL Style Sheet//EN" [
+<!ENTITY % html "IGNORE">
+<![%html;[
+<!ENTITY % print "IGNORE">
+<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook HTML Stylesheet//EN" CDATA dsssl>
+]]>
+<!ENTITY % print "INCLUDE">
+<![%print;[
+<!ENTITY docbook.dsl PUBLIC "-//Norman Walsh//DOCUMENT DocBook Print Stylesheet//EN" CDATA dsssl>
+]]>
+]>
+
+<!--
+;;#######################################################################
+;;#                                                                     #
+;;#                 The GNOME Documentation Project's                   #
+;;#                  Custion DocBook Stylesheet Layer                   #
+;;#                    by Dave Mason dcm@redhat.com                     #
+;;#            Based on Norman Walsh's Modular Stylesheets              #
+;;#                                                                     #
+;;#            This is intended as a drop-in replacement for            #
+;;#            the cygnus-both.dsl file in DocBook Tools.               #
+;;#           Just copy it to the location dbtools created              #
+;;#                   and rename it cygnus-both.dsl                     #
+;;#                                                                     #
+;;#                       This is Version 1.0-4                         #
+;;#                  patched to fix RTF output (#49677)                 #
+;;#                patched to work with docbook-dsssl-1.72              #
+;;#                 patched for ADDRESS output (#50605)                 #
+;;#                      removed comment and remark                     #
+;;#                      disabled use-id-as-filename                    #
+;;#               don't define %graphic-default-extension%              #
+;;#######################################################################
+-->
+
+<style-sheet>
+
+
+<style-specification id="print" use="docbook">
+<style-specification-body> 
+
+;;==========================================================================
+;;                               PRINT
+;;==========================================================================
+
+;;======================================
+;;General Options
+;;======================================
+
+;;Do you want to print on both sides of the paper?
+(define %two-side% #t)
+
+;;Do you want enumerated sections? (E.g, 1.1, 1.1.1, 1.2, etc.)
+(define %section-autolabel% #t)
+
+;;Show URL links? If the text of the link and the URL are identical,
+;;the parenthetical URL is suppressed.
+(define %show-ulinks% #t)
+
+;Make Ulinks footnotes to stop bleeding in the edges - this increases
+;'jade --> print' time tremendously keep this in mind before
+;complaining!
+(define %footnote-ulinks% #f)
+
+;;Tex Backend on
+(define tex-backend #t)
+
+;;Define Line Spacing
+(define %line-spacing-factor% 1.1)
+
+;;Define the Paragraph Style
+(define para-style
+  (style
+   font-size: %bf-size%
+   font-weight: 'medium
+   font-posture: 'upright
+   font-family-name: %body-font-family%
+   line-spacing: (* %bf-size% %line-spacing-factor%)))
+
+(define ($object-titles-after$)
+  (list (normalize "figure")))
+
+;;======================================
+;;Book Options
+;;======================================
+
+
+;;Do you want a title page for a Book?
+(define %generate-book-titlepage% #t)
+
+;;Do you want a separate page for the title?
+(define %generate-book-titlepage-on-separate-page% #t)
+
+;;Generate Book TOC?
+(define %generate-book-toc% #t)
+
+;;What depth should the TOC generate?
+;;!Only top level of appendixes!
+(define (toc-depth nd)
+  (if (string=? (gi nd) (normalize "book"))
+      3
+      (if (string=? (gi nd) (normalize "appendix"))
+        0
+        1)))
+
+;;Do you want a TOC for the element part?
+(define %generate-part-toc% #f)
+
+;;Do you want the part toc on the part titlepage or separate?
+(define %generate-part-toc-on-titlepage% #t)
+
+;;Generate Part Title Page?
+(define %generate-part-titlepage% #f)
+
+;;Do you want the Part intro on the part title page?
+(define %generate-partintro-on-titlepage% #t)
+
+;;What elements should have a LOT?
+(define ($generate-book-lot-list$) (list (normalize "equation")))
+
+;;Do you want chapters enumerated?
+(define %chapter-autolabel% #t)
+
+;;Do you want Chapter's and Appendix's 
+;;to have automatic labels?
+(define %chap-app-running-head-autolabel% #t)
+
+
+;;======================================
+;;Article Options
+;;======================================
+
+;;Do you want a title page for an Article?
+(define %generate-article-titlepage% #t)
+
+;;Generate Article TOC?
+(define %generate-article-toc% #t)
+
+;;Do you want a separate page for the title?
+(define %generate-article-titlepage-on-separate-page% #t)
+
+;;Do you want the article toc on the titlepage or separate?
+(define %generate-article-toc-on-titlepage% #t)
+
+;;Do you want to start new page numbers with each article?
+(define %article-page-number-restart% #f)
+
+;;Titlepage Separate?
+(define (chunk-skip-first-element-list) '())
+
+;;Titlepage Not Separate
+;(define (chunk-skip-first-element-list)
+;  (list (normalize "sect1")
+;	(normalize "section")))
+
+;;======================================
+;;Columns
+;;======================================
+
+;;How many columns do you want?
+(define %page-n-columns% 1)
+
+;;How much space between columns?
+(define %page-column-sep% 0.2in)
+
+;;How many Columns on the titlepage?
+(define %titlepage-n-columns% 1)
+
+;;Balance columns?
+(define %page-balance-colums% #t)
+
+;;======================================
+;;Fonts
+;;======================================
+
+;;Defines the general size of the text in the document. normal(10),
+;;presbyopic(12), and large-type(24). 
+(define %visual-acuity% "normal")
+
+;;What font would you like for titles?
+(define %title-font-family% "Helvetica")
+
+;;What font would you like for the body?
+(define %body-font-family% "Palatino")
+
+;;What font would you like for mono-seq?
+(define %mono-font-family% "Courier New")
+
+;;If the base fontsize is 10pt, and '%hsize-bump-factor%' is
+;; 1.2, hsize 1 is 12pt, hsize 2 is 14.4pt, hsize 3 is 17.28pt, etc
+(define %hsize-bump-factor% 1.1)
+
+;;What size do you want the body fonts?
+(define %bf-size%
+ (case %visual-acuity%
+    (("tiny") 8pt)
+    (("normal") 10pt)
+    (("presbyopic") 12pt)
+    (("large-type") 24pt)))
+
+(define-unit em %bf-size%)
+
+;;======================================
+;;Margins
+;;======================================
+
+(define %left-right-margin% 6pi)
+
+;;How much indentation for the body?
+(define %body-start-indent% 4pi)
+
+;;How big is the left margin? (relative to physical page)
+(define %left-margin% 8pi) ;white-paper-column
+
+;;How big is the right margin? (relative to physical page)
+(define %right-margin% 8pi) ;white-paper-column
+
+;;How big do you want the margin at the top?
+(define %top-margin%
+(if (equal? %visual-acuity% "large-type")
+      7.5pi
+      6pi))
+
+;;How big do you want the margin at the bottom?
+(define %bottom-margin% 
+ (if (equal? %visual-acuity% "large-type")
+      7.5pi 
+      5pi))
+
+;;Define the text width. (Change the elements in the formula rather
+;;than the formula itself)
+;(define %text-width% (- %page-width% (* %left-right-margin% 2)))
+(define %text-width%  (- %page-width% (+ %left-margin% %right-margin%)))
+
+;;Define the body width. (Change the elements in the formula rather
+;;than the formula itself)
+(define %body-width% (- %text-width% %body-start-indent%))
+
+;;Define distance between paragraphs
+(define %para-sep% (/ %bf-size% 2.0))
+
+;;Define distance between block elements (figures, tables, etc.).
+(define %block-sep% (* %para-sep% 2.0))
+
+;;Indent block elements?
+(define %block-start-indent% 0pt)
+;0pt
+
+;;======================================
+;;Admon Graphics
+;;======================================
+
+;;Do you want admon graohics on?
+(define %admon-graphics% #f)
+
+;;Where are the admon graphics?
+(define %admon-graphics-path% "../images/")
+
+;;======================================
+;;Quadding
+;;======================================
+
+;;What quadding do you want by default; start, center, justify, or end?
+(define %default-quadding% 'justify)
+
+;;What quadding for component titles(Chapter, Appendix, etc)?
+(define %component-title-quadding% 'start)
+
+;;What quadding for section titles?
+(define %section-title-quadding% 'start)
+
+;;What quadding for section sub-titles?
+(define %section-subtitle-quadding% 'start)
+
+;;What quadding for article title?
+(define %article-title-quadding% 'center)
+
+;;What quadding for article sub-titles?
+(define %article-subtitle-quadding% 'center)
+
+;;What quadding for division subtitles?
+(define %division-subtitle-quadding% 'start)
+
+;;What quadding for component subtitles?
+(define %component-subtitle-quadding% 'start)
+
+
+
+
+;;======================================
+;;Paper Options
+;;======================================
+
+;;What size paper do you need? A4, USletter, USlandscape, or RedHat?
+(define %paper-type% "A4")
+
+;;Now define those paper types' width
+(define %page-width%
+ (case %paper-type%
+    (("A4") 210mm)
+    (("USletter") 8.5in)
+    (("USlandscape") 11in)))
+
+;;Now define those paper types' height
+(define %page-height%
+ (case %paper-type%
+    (("A4") 297mm)
+    (("USletter") 11in)
+    (("USlandscape") 8.5in)))
+
+;;======================================
+;;Functions
+;;======================================
+
+(define (OLSTEP)
+  (case
+   (modulo (length (hierarchical-number-recursive "ORDEREDLIST")) 4)
+	((1) 1.2em)
+	((2) 1.2em)
+	((3) 1.6em)
+	((0) 1.4em)))
+
+(define (ILSTEP) 1.0em)
+
+(define (PROCSTEP ilvl)
+  (if (> ilvl 1) 1.8em 1.4em))
+
+(define (PROCWID ilvl)
+  (if (> ilvl 1) 1.8em 1.4em))
+
+
+(define ($comptitle$)
+  (make paragraph
+	font-family-name: %title-font-family%
+	font-weight: 'bold
+	font-size: (HSIZE 2)
+	line-spacing: (* (HSIZE 2) %line-spacing-factor%)
+	space-before: (* (HSIZE 2) %head-before-factor%)
+	space-after: (* (HSIZE 2) %head-after-factor%)
+	start-indent: 0pt
+	first-line-start-indent: 0pt
+	quadding: 'start
+	keep-with-next?: #t
+	(process-children-trim)))
+
+;;Callouts are confusing in Postscript... fix them.
+(define %callout-fancy-bug% #f)
+
+
+;;By default perils are centered and dropped into a box with a really
+;;big border - I have simply decreased the border thickness -
+;;unfortunately it takes all this to do it - sigh.
+(define ($peril$)
+  (let* ((title     (select-elements 
+		     (children (current-node)) (normalize "title")))
+	 (has-title (not (node-list-empty? title)))
+	 (adm-title (if has-title 
+			(make sequence
+			  (with-mode title-sosofo-mode
+			    (process-node-list (node-list-first title))))
+			(literal
+			 (gentext-element-name 
+			  (current-node)))))
+	 (hs (HSIZE 2)))
+  (if %admon-graphics%
+      ($graphical-admonition$)
+      (make display-group
+	space-before: %block-sep%
+	space-after: %block-sep%
+	font-family-name: %admon-font-family%
+	font-size: (- %bf-size% 1pt)
+	font-weight: 'medium
+	font-posture: 'upright
+	line-spacing: (* (- %bf-size% 1pt) %line-spacing-factor%)
+	(make box
+	  display?: #t
+	  box-type: 'border
+	  line-thickness: .5pt
+	  start-indent: (+ (inherited-start-indent) (* 2 (ILSTEP)) 2pt)
+	  end-indent: (inherited-end-indent)
+	  (make paragraph
+	    space-before: %para-sep%
+	    space-after: %para-sep%
+	    start-indent: 1em
+	    end-indent: 1em
+	    font-family-name: %title-font-family%
+	    font-weight: 'bold
+	    font-size: hs
+	    line-spacing: (* hs %line-spacing-factor%)
+	    quadding: 'center
+	    keep-with-next?: #t
+	    adm-title)
+	  (process-children))))))
+
+
+;;======================================
+;;Non-printing Elements
+;;======================================
+(element TITLEABBREV (empty-sosofo))
+(element SUBTITLE (empty-sosofo))
+(element SETINFO (empty-sosofo))
+(element BOOKINFO (empty-sosofo))
+(element BIBLIOENTRY (empty-sosofo))
+(element BIBLIOMISC (empty-sosofo))
+(element BOOKBIBLIO (empty-sosofo))
+(element SERIESINFO (empty-sosofo))
+(element DOCINFO (empty-sosofo))
+(element ARTHEADER (empty-sosofo))
+;;(element ADDRESS (empty-sosofo))
+
+;;Show comment element?
+(define %show-comments% #t)
+
+;;======================================
+;;Formalpara titles
+;;======================================
+
+
+;;Change the way Formal Paragraph titles are displayed. The commented
+;;out section will run the titles in the paragraphs. 
+(element (formalpara title)
+  ;(make sequence
+  ;font-weight: 'bold
+  ;($runinhead$))
+  ($lowtitle$ 5 7))
+
+;;======================================
+;;Inlines
+;;======================================
+
+(element application ($mono-seq$))
+(element command ($bold-seq$))
+(element filename ($mono-seq$))
+(element function ($mono-seq$))
+(element guibutton ($bold-seq$))
+(element guiicon ($bold-seq$))
+(element guilabel ($italic-seq$))
+(element guimenu ($bold-seq$))
+(element guimenuitem ($bold-seq$))
+(element hardware ($bold-mono-seq$))
+(element keycap ($bold-seq$))
+(element literal ($mono-seq$))
+(element parameter ($italic-mono-seq$))
+(element prompt ($mono-seq$))
+(element symbol ($charseq$))
+(element emphasis ($italic-seq$))
+
+</style-specification-body>
+</style-specification>
+
+
+<!-- 
+;;===========================================================================
+;;                                HTML
+;;===========================================================================
+-->
+
+<style-specification id="html" use="docbook">
+<style-specification-body> 
+
+;; this is necessary because right now jadetex does not understand
+;; symbolic entities, whereas things work well with numeric entities.
+(declare-characteristic preserve-sdata?
+          "UNREGISTERED::James Clark//Characteristic::preserve-sdata?"
+          #f)
+
+
+;;=========================
+;;Header HTML 4.0.1
+;;=========================
+
+(define %html-pubid% "-//W3C//DTD HTML 4.01//EN")
+
+;;=========================
+;;Common Stuff
+;;=========================
+
+;;Should there be a link to the legalnotice?
+(define %generate-legalnotice-link% #t)
+
+;;What graphics extensions allowed?
+(define %graphic-extensions% '("gif" "png" "jpg" "jpeg" "tif" "tiff" "eps" "epsf" ))
+
+;;What is the default extension for images?
+(define %graphic-default-extension% "png")
+
+;;Use element ids as filenames?
+(define %use-id-as-filename% #f)
+
+
+;;=========================
+;;Book Stuff
+;;=========================
+
+;;Do you want a TOC for Books?
+(define %generate-book-toc% #t)
+
+;;What depth should the TOC generate?
+;;!Only top level of appendixes!
+(define (toc-depth nd)
+  (if (string=? (gi nd) (normalize "book"))
+      3
+      (if (string=? (gi nd) (normalize "appendix"))
+        0
+        1)))
+
+;;What elements should have an LOT?
+(define ($generate-book-lot-list$) (list (normalize "equation")))
+
+;;Do you want a title page for your Book?
+(define %generate-book-titlepage% #t)
+
+;;=========================
+;;Part Stuff
+;;=========================
+
+;;Should parts have TOCs?
+(define %generate-part-toc% #t)
+
+;;Should part TOCs be on their titlepages?
+(define %generate-part-toc-on-titlepage% #t)
+
+;;Do you want a title page for your part?
+(define %generate-part-titlepage% #t)
+
+;;Should the Part intro be on the part title page?
+(define %generate-partintro-on-titlepage% #t)
+
+(define %para-autolabel% #t)
+
+;;========================
+;;Chapter Stuff
+;;=======================
+
+;;No TOCs in Chapters
+(define $generate-chapter-toc$ (lambda () #f))
+
+;;=========================
+;;Navigation
+;;=========================
+
+;;Should there be navigation at top?
+(define %header-navigation% #t)
+
+;;Should there be navigation at bottom?
+(define %footer-navigation% #t)
+
+;;Use tables to create the navigation?
+(define %gentext-nav-use-tables% #t)
+
+;;If tables are used for navigation, 
+;;how wide should they be? 
+(define %gentext-nav-tblwidth% "100%")
+
+;;Add arrows to navigation (comment these 
+;;out if you want admon graphics here)
+(define (gentext-en-nav-prev prev) (make sequence (literal "<<< Previous")))
+
+;;Add arrows to navigation (comment these 
+;;out if you want admon graphics here)
+(define (gentext-en-nav-next next) (make sequence (literal "Next >>>")))
+
+
+;;=========================
+;;Tables and Lists
+;;=========================
+
+;;Should Variable lists be tables?
+(define %always-format-variablelist-as-table% #f)
+
+;;What is the length of the 'Term' in a variablelist?
+(define %default-variablelist-termlength% 20)
+
+;;When true | If the terms are shorter than 
+;;the termlength above then the variablelist 
+;;will be formatted as a table.
+(define %may-format-variablelist-as-table% #f)
+
+;;This overrides the tgroup definition 
+;;(copied from 1.20, dbtable.dsl).
+;;It changes the table background color, 
+;;cell spacing and cell padding.
+;;This is based on gtk-doc additions - thanks!
+
+(element tgroup
+  (let* ((wrapper   (parent (current-node)))
+	 (frameattr (attribute-string (normalize "frame") wrapper))
+	 (pgwide    (attribute-string (normalize "pgwide") wrapper))
+	 (footnotes (select-elements (descendants (current-node)) 
+				     (normalize "footnote")))
+	 (border (if (equal? frameattr (normalize "none"))
+		     '(("BORDER" "0"))
+		     '(("BORDER" "1"))))
+	 (bgcolor '(("BGCOLOR" "#E0E0E0")))
+	 (width (if (equal? pgwide "1")
+		    (list (list "WIDTH" ($table-width$)))
+		    '()))
+	 (head (select-elements (children (current-node)) (normalize "thead")))
+	 (body (select-elements (children (current-node)) (normalize "tbody")))
+	 (feet (select-elements (children (current-node)) (normalize "tfoot"))))
+    (make element gi: "TABLE"
+	  attributes: (append
+		       border
+		       width
+		       bgcolor
+		       '(("CELLSPACING" "0"))
+		       '(("CELLPADDING" "4"))
+		       (if %cals-table-class%
+			   (list (list "CLASS" %cals-table-class%))
+			   '()))
+	  (process-node-list head)
+	  (process-node-list body)
+	  (process-node-list feet)
+	  (make-table-endnotes))))
+
+;;===================
+;; Admon Graphics
+;;===================
+
+;;Should Admon Graphics be used?
+(define %admon-graphics% #t)
+
+;;Where are those admon graphics?
+(define %admon-graphics-path% "./stylesheet-images/")
+
+;;Given an admonition node, returns the 
+;;name of the graphic that should
+;;be used for that admonition.
+;;Define admon graphics usage
+;;NOTE these will change to pngs 
+;;soon in the GDP when Tigert gets 
+;;the time to make special ones for us!
+(define ($admon-graphic$ #!optional (nd (current-node)))
+  (cond ((equal? (gi nd) (normalize "tip"))
+	 (string-append %admon-graphics-path% "tip.gif"))
+	((equal? (gi nd) (normalize "note"))
+	 (string-append %admon-graphics-path% "note.gif"))
+	((equal? (gi nd) (normalize "important"))
+	 (string-append %admon-graphics-path% "important.gif"))
+	((equal? (gi nd) (normalize "caution"))
+	 (string-append %admon-graphics-path% "caution.gif"))
+	((equal? (gi nd) (normalize "warning"))
+	 (string-append %admon-graphics-path% "warning.gif"))
+	(else (error (string-append (gi nd) " is not an admonition.")))))
+
+;;Given an admonition node, returns 
+;;the width of the graphic that will
+;;be used for that admonition.
+(define ($admon-graphic-width$ #!optional (nd (current-node))) "25")
+
+;;=========================
+;;Labels
+;;=========================
+
+;;Enumerate Chapters?
+(define %chapter-autolabel% #t)
+
+;;Enumerate Sections?
+(define %section-autolabel% #f)
+
+;;=========================
+;;    HTML Attributes
+;;=========================
+
+;;What attributes should be hung off 
+;;of 'body'?
+(define %body-attr%
+ (list
+   (list "BGCOLOR" "#FFFFFF")
+   (list "TEXT" "#000000")
+   (list "LINK" "#0000FF")
+   (list "VLINK" "#840084")
+   (list "ALINK" "#0000FF")))
+
+;;Default extension for filenames?
+(define %html-ext% ".html")
+
+;;Use a CSS stylesheet?
+;;Which one? Should work on 
+;;this one soon
+;(define %stylesheet% 
+;        "./gnome.css")
+
+;;Use it
+;(define %stylesheet-type% 
+;"text/css")
+
+
+;;========================
+;;Title Pages for Books
+;;=======================
+
+(define (book-titlepage-recto-elements)
+  (list (normalize "title")
+	(normalize "subtitle")
+	(normalize "corpauthor")
+	(normalize "authorgroup")
+	(normalize "author")
+	(normalize "orgname")
+	(normalize "graphic")
+	(normalize "copyright")
+	(normalize "legalnotice")
+	(normalize "releaseinfo")
+	(normalize "publisher")
+	(normalize "isbn")))
+
+;;========================
+;;Title Pages for Articles
+;;========================
+
+;;Should Articles have a TOC?
+(define %generate-article-toc% #t)
+
+;;Which elements should appear 
+;;on title page?
+(define (article-titlepage-recto-elements)
+  (list (normalize "title")
+	(normalize "subtitle")
+        (normalize "authorgroup")
+        (normalize "copyright")
+        (normalize "legalnotice")
+        (normalize "abstract")))
+
+;;How should elements on title page look?
+(mode article-titlepage-recto-mode
+
+;;Author name is too big - change it!
+  (element author
+    (let ((author-name  (author-string))
+	  (author-affil (select-elements (children (current-node)) 
+					 (normalize "affiliation"))))
+      (make sequence      
+	(make element gi: "H4"
+	      attributes: (list (list "CLASS" (gi)))
+	      (make element gi: "A"
+		    attributes: (list (list "NAME" (element-id)))
+		    (literal author-name)))
+	(process-node-list author-affil))))
+
+;;Address?
+  (element address 
+    (make sequence
+      (make element gi: "DIV"
+            attributes: (list (list "CLASS" (gi)))
+            (process-children))))
+
+;;Get rid of spam-producing "mailto" links
+;;and get rid of email indentation  
+  (element email
+    (make sequence
+      (make element gi: "DIV"
+            attributes: (list (list "CLASS" (gi)))
+            (process-children))))
+
+;;Point Abstract to custom table function 
+;;(See $dcm-abstract-object$ below. For default
+;;use $semiformal-object$
+  (element abstract
+    (make element gi: "DIV"
+          ($dcm-abstract-object$)))
+
+  (element (abstract title) (empty-sosofo))
+
+;;subtitle sizing
+(element subtitle 
+  (make element gi: "H4"
+        attributes: (list (list "CLASS" (gi)))
+        (process-children-trim))))
+
+;;=================
+;;    INLINES
+;;=================
+
+;Define my own series of fonts for various elements
+(element application ($mono-seq$))
+(element command ($bold-seq$))
+(element filename ($mono-seq$))
+(element function ($mono-seq$))
+(element guibutton ($bold-seq$))
+(element guiicon ($bold-seq$))
+(element guilabel ($bold-mono-seq$))
+(element guimenu ($bold-seq$))
+(element guimenuitem ($bold-seq$))
+(element guisubmenu ($bold-seq$))
+(element hardware ($bold-mono-seq$))
+(element keycap ($bold-seq$))
+(element literal ($mono-seq$))
+(element parameter ($italic-mono-seq$))
+(element prompt ($mono-seq$))
+(element symbol ($charseq$))
+(element emphasis ($italic-seq$))
+
+;;Show comment element?
+(define %show-comments% #t)
+
+;;====================
+;; General Formatting
+;;====================
+
+;;Formal Paras are ugly by default!
+;;Make the title run in - otherwise 
+;;you should use a sect!
+(element formalpara
+  (make element gi: "DIV"
+	attributes: (list
+		     (list "CLASS" (gi)))
+  	(make element gi: "P"
+	      (process-children))))
+
+;;This is the old one 
+;(element (formalpara title) 
+;($lowtitle$ 5))
+
+;;This is the new one
+(element (formalpara title) 
+  (make element gi: "B"
+	($runinhead$)))
+
+;;Make captions come after objects in the list
+(define ($object-titles-after$)
+  (list (normalize "figure")))
+
+
+;; Handle qanda labelling with Q: A:
+(define (qanda-defaultlabel)
+  (normalize "qanda"))
+
+;;From FreeBSD Sheets (Thanks!) Display Q and A in bigger bolder fonts
+
+(element question
+  (let* ((chlist   (children (current-node)))
+	 (firstch  (node-list-first chlist))
+	 (restch   (node-list-rest chlist)))
+    (make element gi: "DIV"
+	  attributes: (list (list "CLASS" (gi)))
+	  (make element gi: "P" 
+		(make element gi: "BIG"
+		      (make element gi: "A"
+			    attributes: (list
+					 (list "NAME" (element-id)))
+			    (empty-sosofo))
+		      (make element gi: "B"
+			    (literal (question-answer-label
+				      (current-node)) " ")
+			    (process-node-list (children firstch)))))
+	  (process-node-list restch))))
+
+;;Literal Elements
+
+;;Indent Literal layouts?
+(define %indent-literallayout-lines% #f)
+
+;;Indent Programlistings?
+(define %indent-programlisting-lines% #f)
+
+;;Number lines in Programlistings?
+(define %number-programlisting-lines% #f)
+
+;;Should verbatim items be 'shaded' with a table?
+(define %shade-verbatim% #t)
+
+;;Define shade-verbatim attributes
+(define ($shade-verbatim-attr$)
+ (list
+  (list "BORDER" "0")
+  (list "BGCOLOR" "#E0E0E0")
+  (list "WIDTH" ($table-width$))))
+
+;;===================
+;;    Entities
+;;===================
+
+;;Netscape doesn't handle trademark 
+;;entity right at all!! Get rid of it.
+;;Make a TM in a superscipt font.
+(element trademark
+  (make sequence
+    (process-children)
+    (make element gi: "sup"
+    (literal "TM"))))
+
+
+;;===================
+;; New Definitions
+;;==================
+
+(define ($dcm-abstract-object$)
+   (make element gi: "TABLE"
+        attributes: '(("BORDER" "0")
+                      ("BGCOLOR" "#E0E0E0")
+                      ("WIDTH" "50%")
+                      ("CELLSPACING" "0")
+                      ("CELLPADDING" "0")
+                      ("ALIGN" "CENTER"))
+        (make element gi: "TR"
+              (make element gi: "TD"
+                    attributes: '(("VALIGN" "TOP"))
+                    (make element gi: "B"
+                    (literal "Abstract"))))
+        (make element gi: "TR"
+              (make element gi: "TD"
+                    attributes: '(("VALIGN" "TOP"))
+                    (process-children)))))
+
+;;Redefine Titlepage Separator on Articles
+
+(define (article-titlepage-separator side)
+  (make empty-element gi: "HR"
+  attributes: '(("WIDTH" "75%")
+                 ("ALIGN" "CENTER")
+                 ("COLOR" "#000000")
+                 ("SIZE" "1"))))
+
+
+
+
+(define (chunk-element-list)
+  (list (normalize "preface")
+	(normalize "chapter")
+	(normalize "appendix") 
+	(normalize "article")
+	(normalize "glossary")
+	(normalize "bibliography")
+	(normalize "index")
+	(normalize "colophon")
+	(normalize "setindex")
+	(normalize "reference")
+	(normalize "refentry")
+	(normalize "part")
+	(normalize "sect1") 
+	(normalize "section") 
+	(normalize "book") ;; just in case nothing else matches...
+	(normalize "set")  ;; sets are definitely chunks...
+	))
+
+;;Do you want Callouts to be graphics?
+(define %callout-graphics% #f)
+
+
+;;Make Callout graphics PNGs
+(define %callout-graphics-path% "./imagelib/callouts/")
+
+  ;; Redefine $callout-bug$ to support the %callout-graphic-ext%
+  ;; variable.
+  (define ($callout-bug$ conumber)
+    (let ((number (if conumber (format-number conumber "1") "0")))
+      (if conumber
+          (if %callout-graphics%
+              (if (<= conumber %callout-graphics-number-limit%)
+                  (make empty-element gi: "IMG"
+                        attributes: (list (list "SRC"
+                                                (root-rel-path
+                                                 (string-append
+                                                  %callout-graphics-path%
+                                                  number
+                                                  %callout-graphics-ext%)))
+                                          (list "HSPACE" "0")
+                                          (list "VSPACE" "0")
+                                          (list "BORDER" "0")
+                                          (list "ALT"
+                                                (string-append
+                                                 "(" number ")"))))
+                  (make element gi: "B"
+                        (literal "(" (format-number conumber "1") ")")))
+              (make element gi: "B"
+                    (literal "(" (format-number conumber "1") ")")))
+          (make element gi: "B"
+         (literal "(??)")))))
+
+</style-specification-body>
+</style-specification>
+
+<external-specification id="docbook" document="docbook.dsl">
+
+</style-sheet>

mercurial