diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..598b606 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,192 @@ +# +# Copyright 2008, 2009 Free Software Foundation, Inc. +# +# This file is part of GNU Radio +# +# GNU Radio 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 3, or (at your option) +# any later version. +# +# GNU Radio 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., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +David A. Burgess, dburgess@kestrelsp.com: + CLI/CLI.cpp + CLI/CLI.h + CommonLibs/Assert.h + CommonLibs/BitVector.cpp + CommonLibs/BitVectorTest.cpp + CommonLibs/Configuration.cpp + CommonLibs/Configuration.h + CommonLibs/ConfigurationTest.cpp + CommonLibs/Interthread.h + CommonLibs/InterthreadTest.cpp + CommonLibs/LinkedLists.cpp + CommonLibs/LinkedLists.h + CommonLibs/Regexp.h + CommonLibs/RegexpTest.cpp + CommonLibs/Sockets.cpp + CommonLibs/Sockets.h + CommonLibs/SocketsTest.cpp + CommonLibs/Threads.cpp + CommonLibs/Threads.h + CommonLibs/Timeval.cpp + CommonLibs/Timeval.h + CommonLibs/TimevalTest.cpp + CommonLibs/Vector.h + CommonLibs/VectorTest.cpp + Control/CallControl.cpp + Control/ControlCommon.cpp + Control/ControlCommon.h + Control/FACCHDispatch.cpp + Control/MobilityManagement.cpp + Control/PagerTest.cpp + Control/RadioResource.cpp + Control/SDCCHDispatch.cpp + GSM/GSM610Tables.cpp + GSM/GSM610Tables.h + GSM/GSMCommon.cpp + GSM/GSMCommon.h + GSM/GSMConfig.h + GSM/GSML1FEC.cpp + GSM/GSML1FEC.h + GSM/GSML2LAPDm.cpp + GSM/GSML2LAPDm.h + GSM/GSML3CCElements.cpp + GSM/GSML3CCElements.h + GSM/GSML3CCMessages.cpp + GSM/GSML3CCMessages.h + GSM/GSML3CommonElements.cpp + GSM/GSML3CommonElements.h + GSM/GSML3MMElements.cpp + GSM/GSML3MMElements.h + GSM/GSML3MMMessages.cpp + GSM/GSML3MMMessages.h + GSM/GSML3Message.cpp + GSM/GSML3Message.h + GSM/GSML3RRElements.cpp + GSM/GSML3RRElements.h + GSM/GSML3RRMessages.cpp + GSM/GSML3RRMessages.h + GSM/GSMLogicalChannel.h + GSM/GSMTDMA.cpp + GSM/GSMTDMA.h + GSM/GSMTransfer.cpp + GSM/GSMTransfer.h + LICENSEBLOCK + SIP/SIPEngine.h + SIP/SIPInterface.h + SMS/SMSMessages.cpp + SMS/SMSMessages.h + SMS/SMSTransfer.cpp + SMS/SMSTransfer.h + TRXManager/TRXManager.cpp + Transceiver/Complex.h + apps/OpenBTS900.cpp + apps/OpenBTS850.cpp + apps/OpenBTS25c3.cpp + tests/AGCHTest.cpp + tests/BeaconTest.cpp + tests/CallTest.cpp + tests/CallTest2.cpp + tests/LAPDmTest.cpp + tests/LoopbackTest.cpp + tests/RegistrationTest.cpp + tests/TRXSimulator.cpp + +Harvind S. Samra, hssamra@kestrelsp.com: + Control/PagerTest.cpp + Control/RadioResource.cpp + GSM/GSMConfig.h + GSM/GSMTransfer.h + LICENSEBLOCK + Transceiver/ComplexTest.cpp + Transceiver/Transceiver.cpp + Transceiver/Transceiver.h + Transceiver/USRPDevice.cpp + Transceiver/USRPDevice.h + Transceiver/USRPping.cpp + Transceiver/radioInterface.cpp + Transceiver/radioInterface.h + Transceiver/rcvLPF_651.h + Transceiver/runTransceiver.cpp + Transceiver/sendLPF_961.h + Transceiver/sigProcLib.cpp + Transceiver/sigProcLib.h + Transceiver/sigProcLibTest.cpp + Transceiver/sweepGenerator.cpp + Transceiver/testRadio.cpp + +Raffi Sevlian, raffisev@gmail.com: + Control/CallControl.cpp + Control/ControlCommon.cpp + Control/ControlCommon.h + Control/FACCHDispatch.cpp + Control/MobilityManagement.cpp + Control/PagerTest.cpp + Control/RadioResource.cpp + GSM/GSMCommon.h + GSM/GSMConfig.h + GSM/GSML1FEC.h + GSM/GSML3CCElements.cpp + GSM/GSML3CCElements.h + GSM/GSML3CCMessages.cpp + GSM/GSML3CCMessages.h + GSM/GSML3CommonElements.cpp + GSM/GSML3CommonElements.h + GSM/GSML3MMElements.cpp + GSM/GSML3MMElements.h + GSM/GSML3MMMessages.cpp + GSM/GSML3MMMessages.h + GSM/GSML3Message.cpp + GSM/GSML3Message.h + GSM/GSML3RRElements.cpp + GSM/GSML3RRElements.h + GSM/GSML3RRMessages.cpp + GSM/GSML3RRMessages.h + GSM/GSMLogicalChannel.h + GSM/GSMSAPMux.cpp + GSM/GSMSAPMux.h + GSM/GSMTransfer.h + LICENSEBLOCK + SIP/SIPEngine.cpp + SIP/SIPInterface.cpp + SIP/SIPInterface.h + SIP/SIPMessage.cpp + SIP/SIPMessage.h + SIP/SIPUtility.cpp + SIP/SIPUtility.h + SMS/CMMessage.cpp + SMS/CMMessage.h + SMS/CMProcessor.cpp + SMS/CMProcessor.h + SMS/CMTest.cpp + SMS/RLMessage.cpp + SMS/RLMessage.h + SMS/RLProcessor.cpp + SMS/RLProcessor.h + SMS/SMSMessages.cpp + SMS/SMSMessages.h + SMS/SMSProcessors.cpp + SMS/SMSProcessors.h + SMS/SMSTransfer.cpp + SMS/SMSTransfer.h + SMS/TLMessage.cpp + SMS/TLMessage.h + SMS/TLProcessor.cpp + SMS/TLProcessor.h + TRXManager/TRXManager.h + +Alon Levy, alonlevy1@gmail.com + RRLPMessages.cpp + RRLPMessages.h + RRLPTest.cpp + diff --git a/AsteriskConfig/Makefile.am b/AsteriskConfig/Makefile.am new file mode 100644 index 0000000..09ee477 --- /dev/null +++ b/AsteriskConfig/Makefile.am @@ -0,0 +1,33 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +# Install files in this directory +ourdatadir = $(datadir)/OpenBTS/Asterisk + +dist_ourdata_DATA = \ + cdr.conf \ + extensions.conf \ + indications.conf \ + logger.conf \ + modules.conf \ + README.AsteriskConf \ + sip.conf diff --git a/AsteriskConfig/Makefile.in b/AsteriskConfig/Makefile.in new file mode 100644 index 0000000..ad56b05 --- /dev/null +++ b/AsteriskConfig/Makefile.in @@ -0,0 +1,450 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(dist_ourdata_DATA) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = AsteriskConfig +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +am__installdirs = "$(DESTDIR)$(ourdatadir)" +dist_ourdataDATA_INSTALL = $(INSTALL_DATA) +DATA = $(dist_ourdata_DATA) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ + +# Install files in this directory +ourdatadir = $(datadir)/OpenBTS/Asterisk +dist_ourdata_DATA = \ + cdr.conf \ + extensions.conf \ + indications.conf \ + logger.conf \ + modules.conf \ + README.AsteriskConf \ + sip.conf + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu AsteriskConfig/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu AsteriskConfig/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +install-dist_ourdataDATA: $(dist_ourdata_DATA) + @$(NORMAL_INSTALL) + test -z "$(ourdatadir)" || $(mkdir_p) "$(DESTDIR)$(ourdatadir)" + @list='$(dist_ourdata_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_ourdataDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(ourdatadir)/$$f'"; \ + $(dist_ourdataDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(ourdatadir)/$$f"; \ + done + +uninstall-dist_ourdataDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_ourdata_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(ourdatadir)/$$f'"; \ + rm -f "$(DESTDIR)$(ourdatadir)/$$f"; \ + done +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(DATA) +installdirs: + for dir in "$(DESTDIR)$(ourdatadir)"; do \ + test -z "$$dir" || $(mkdir_p) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-dist_ourdataDATA + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dist_ourdataDATA uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dist_ourdataDATA \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ + ps ps-am uninstall uninstall-am uninstall-dist_ourdataDATA \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/AsteriskConfig/README.AsteriskConf b/AsteriskConfig/README.AsteriskConf new file mode 100644 index 0000000..36ee3a0 --- /dev/null +++ b/AsteriskConfig/README.AsteriskConf @@ -0,0 +1,4 @@ +This file contains example Asterisk configuration files for the OpenBTS Asterisk server. + +This file does not contain REAL configuration files, since those would include real IMSIs. + diff --git a/AsteriskConfig/cdr.conf b/AsteriskConfig/cdr.conf new file mode 100644 index 0000000..c2882c1 --- /dev/null +++ b/AsteriskConfig/cdr.conf @@ -0,0 +1,148 @@ +; +; Asterisk Call Detail Record engine configuration +; +; CDR is Call Detail Record, which provides logging services via a variety of +; pluggable backend modules. Detailed call information can be recorded to +; databases, files, etc. Useful for billing, fraud prevention, compliance with +; Sarbanes-Oxley aka The Enron Act, QOS evaluations, and more. +; + +[general] + +; Define whether or not to use CDR logging. Setting this to "no" will override +; any loading of backend CDR modules. Default is "yes". +;enable=yes + +; Define whether or not to log unanswered calls. Setting this to "yes" will +; report every attempt to ring a phone in dialing attempts, when it was not +; answered. For example, if you try to dial 3 extensions, and this option is "yes", +; you will get 3 CDR's, one for each phone that was rung. Default is "no". Some +; find this information horribly useless. Others find it very valuable. Note, in "yes" +; mode, you will see one CDR, with one of the call targets on one side, and the originating +; channel on the other, and then one CDR for each channel attempted. This may seem +; redundant, but cannot be helped. +;unanswered = no + +; Define the CDR batch mode, where instead of posting the CDR at the end of +; every call, the data will be stored in a buffer to help alleviate load on the +; asterisk server. Default is "no". +; +; WARNING WARNING WARNING +; Use of batch mode may result in data loss after unsafe asterisk termination +; ie. software crash, power failure, kill -9, etc. +; WARNING WARNING WARNING +; +;batch=no + +; Define the maximum number of CDRs to accumulate in the buffer before posting +; them to the backend engines. 'batch' must be set to 'yes'. Default is 100. +;size=100 + +; Define the maximum time to accumulate CDRs in the buffer before posting them +; to the backend engines. If this time limit is reached, then it will post the +; records, regardless of the value defined for 'size'. 'batch' must be set to +; 'yes'. Note that time is in seconds. Default is 300 (5 minutes). +;time=300 + +; The CDR engine uses the internal asterisk scheduler to determine when to post +; records. Posting can either occur inside the scheduler thread, or a new +; thread can be spawned for the submission of every batch. For small batches, +; it might be acceptable to just use the scheduler thread, so set this to "yes". +; For large batches, say anything over size=10, a new thread is recommended, so +; set this to "no". Default is "no". +;scheduleronly=no + +; When shutting down asterisk, you can block until the CDRs are submitted. If +; you don't, then data will likely be lost. You can always check the size of +; the CDR batch buffer with the CLI "cdr status" command. To enable blocking on +; submission of CDR data during asterisk shutdown, set this to "yes". Default +; is "yes". +;safeshutdown=yes + +; Normally, CDR's are not closed out until after all extensions are finished +; executing. By enabling this option, the CDR will be ended before executing +; the "h" extension so that CDR values such as "end" and "billsec" may be +; retrieved inside of of this extension. +;endbeforehexten=no + +; +; +; CHOOSING A CDR "BACKEND" (what kind of output to generate) +; +; To choose a backend, you have to make sure either the right category is +; defined in this file, or that the appropriate config file exists, and has the +; proper definitions in it. If there are any problems, usually, the entry will +; silently ignored, and you get no output. +; +; Also, please note that you can generate CDR records in as many formats as you +; wish. If you configure 5 different CDR formats, then each event will be logged +; in 5 different places! In the example config files, all formats are commented +; out except for the cdr-csv format. +; +; Here are all the possible back ends: +; +; csv, custom, manager, odbc, pgsql, radius, sqlite, tds +; (also, mysql is available via the asterisk-addons, due to licensing +; requirements) +; (please note, also, that other backends can be created, by creating +; a new backend module in the source cdr/ directory!) +; +; Some of the modules required to provide these backends will not build or install +; unless some dependency requirements are met. Examples of this are pgsql, odbc, +; etc. If you are not getting output as you would expect, the first thing to do +; is to run the command "make menuselect", and check what modules are available, +; by looking in the "2. Call Detail Recording" option in the main menu. If your +; backend is marked with XXX, you know that the "configure" command could not find +; the required libraries for that option. +; +; To get CDRs to be logged to the plain-jane /var/log/asterisk/cdr-csv/Master.csv +; file, define the [csv] category in this file. No database necessary. The example +; config files are set up to provide this kind of output by default. +; +; To get custom csv CDR records, make sure the cdr_custom.conf file +; is present, and contains the proper [mappings] section. The advantage to +; using this backend, is that you can define which fields to output, and in +; what order. By default, the example configs are set up to mimic the cdr-csv +; output. If you don't make any changes to the mappings, you are basically generating +; the same thing as cdr-csv, but expending more CPU cycles to do so! +; +; To get manager events generated, make sure the cdr_manager.conf file exists, +; and the [general] section is defined, with the single variable 'enabled = yes'. +; +; For odbc, make sure all the proper libs are installed, that "make menuselect" +; shows that the modules are available, and the cdr_odbc.conf file exists, and +; has a [global] section with the proper variables defined. +; +; For pgsql, make sure all the proper libs are installed, that "make menuselect" +; shows that the modules are available, and the cdr_pgsql.conf file exists, and +; has a [global] section with the proper variables defined. +; +; For logging to radius databases, make sure all the proper libs are installed, that +; "make menuselect" shows that the modules are available, and the [radius] +; category is defined in this file, and in that section, make sure the 'radiuscfg' +; variable is properly pointing to an existing radiusclient.conf file. +; +; For logging to sqlite databases, make sure the 'cdr.db' file exists in the log directory, +; which is usually /var/log/asterisk. Of course, the proper libraries should be available +; during the 'configure' operation. +; +; For tds logging, make sure the proper libraries are available during the 'configure' +; phase, and that cdr_tds.conf exists and is properly set up with a [global] category. +; +; Also, remember, that if you wish to log CDR info to a database, you will have to define +; a specific table in that databse to make things work! See the doc directory for more details +; on how to create this table in each database. +; + +[csv] +usegmtime=yes ; log date/time in GMT. Default is "no" +loguniqueid=yes ; log uniqueid. Default is "no +loguserfield=yes ; log user field. Default is "no + +;[radius] +;usegmtime=yes ; log date/time in GMT +;loguniqueid=yes ; log uniqueid +;loguserfield=yes ; log user field +; Set this to the location of the radiusclient-ng configuration file +; The default is /etc/radiusclient-ng/radiusclient.conf +;radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf diff --git a/AsteriskConfig/extensions.conf b/AsteriskConfig/extensions.conf new file mode 100644 index 0000000..7fca0ee --- /dev/null +++ b/AsteriskConfig/extensions.conf @@ -0,0 +1,57 @@ +[globals] + + +[default] +; This is the context for handsets that are allowed to attached via open registration. +; Normally, this context is only used for testing. + +; These are test extensions that you might want to disable after installation. + +; Create an extension, 2600, for evaluating echo latency. +exten => 2600,1,Answer() ; Do the echo test +exten => 2600,n,Echo ; Do the echo test +exten => 2600,n,Hangup + +; The 2101 extension is used for factory testing with zoiper. +exten => 2101,1,Dial(SIP/zoiper) + +; The 2100 extension is for factory testing with the test SIM. +exten => 2100,1,Dial(SIP/IMSI001010000000000) + + + +[outbound-trunk] +; If you had an external trunk, you would dial it here. +exten => _N.,1,Answer() + + + + + +[phones] +; This is the context for handsets provisioned through the realtime database. +; This assumes that OpenBTS units all are running their SIP interfaces on port 5062. +exten => _N.,1,Set(Name=${ODBC_SQL(select dial from dialdata_table where exten = \"${EXTEN}\")}) +exten => _N.,n,GotoIf($["${Name}" = ""] ?outbound-trunk,${EXTEN},1) +exten => _N.,n,Set(IPAddr=${ODBC_SQL(select ipaddr from sip_buddies where name = \"${Name}\")}) +exten => _N.,n,GotoIf($["${IPAddr}" = ""] ?outbound-trunk,${EXTEN},1) +exten => _N.,n,Dial(SIP/${Name}@${IPAddr}:5062) + + + +[sip-local] +; This context is the union of all of the in-network contexts. +include => default +include => phones + + + + +[sip-external] +; This is the top-level context that gives access to out-of-network calling. +; also includes the in-network calling. +include => sip-local +include => outbound-trunk + + + diff --git a/AsteriskConfig/indications.conf b/AsteriskConfig/indications.conf new file mode 100644 index 0000000..03a3fad --- /dev/null +++ b/AsteriskConfig/indications.conf @@ -0,0 +1,733 @@ +; indications.conf +; Configuration file for location specific tone indications +; used by the pbx_indications module. +; +; NOTE: +; When adding countries to this file, please keep them in alphabetical +; order according to the 2-character country codes! +; +; The [general] category is for certain global variables. +; All other categories are interpreted as location specific indications +; +; +[general] +country=us ; default location + + +; [example] +; description = string +; The full name of your country, in English. +; alias = iso[,iso]* +; List of other countries 2-letter iso codes, which have the same +; tone indications. +; ringcadence = num[,num]* +; List of durations the physical bell rings. +; dial = tonelist +; Set of tones to be played when one picks up the hook. +; busy = tonelist +; Set of tones played when the receiving end is busy. +; congestion = tonelist +; Set of tones played when there is some congestion (on the network?) +; callwaiting = tonelist +; Set of tones played when there is a call waiting in the background. +; dialrecall = tonelist +; Not well defined; many phone systems play a recall dial tone after hook +; flash. +; record = tonelist +; Set of tones played when call recording is in progress. +; info = tonelist +; Set of tones played with special information messages (e.g., "number is +; out of service") +; 'name' = tonelist +; Every other variable will be available as a shortcut for the "PlayList" command +; but will not be used automatically by Asterisk. +; +; +; The tonelist itself is defined by a comma-separated sequence of elements. +; Each element consist of a frequency (f) with an optional duration (in ms) +; attached to it (f/duration). The frequency component may be a mixture of two +; frequencies (f1+f2) or a frequency modulated by another frequency (f1*f2). +; The implicit modulation depth is fixed at 90%, though. +; If the list element starts with a !, that element is NOT repeated, +; therefore, only if all elements start with !, the tonelist is time-limited, +; all others will repeat indefinitely. +; +; concisely: +; element = [!]freq[+|*freq2][/duration] +; tonelist = element[,element]* +; +; Please note that SPACES ARE NOT ALLOWED in tone lists! +; + +[at] +description = Austria +ringcadence = 1000,5000 +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +dial = 420 +busy = 420/400,0/400 +ring = 420/1000,0/5000 +congestion = 420/200,0/200 +callwaiting = 420/40,0/1960 +dialrecall = 420 +; RECORDTONE - not specified +record = 1400/80,0/14920 +info = 950/330,1450/330,1850/330,0/1000 +stutter = 380+420 + +[au] +description = Australia +; Reference http://www.acif.org.au/__data/page/3303/S002_2001.pdf +; Normal Ring +ringcadence = 400,200,400,2000 +; Distinctive Ring 1 - Forwarded Calls +; 400,400,200,200,400,1400 +; Distinctive Ring 2 - Selective Ring 2 + Operator + Recall +; 400,400,200,2000 +; Distinctive Ring 3 - Multiple Subscriber Number 1 +; 200,200,400,2200 +; Distinctive Ring 4 - Selective Ring 1 + Centrex +; 400,2600 +; Distinctive Ring 5 - Selective Ring 3 +; 400,400,200,400,200,1400 +; Distinctive Ring 6 - Multiple Subscriber Number 2 +; 200,400,200,200,400,1600 +; Distinctive Ring 7 - Multiple Subscriber Number 3 + Data Privacy +; 200,400,200,400,200,1600 +; Tones +dial = 413+438 +busy = 425/375,0/375 +ring = 413+438/400,0/200,413+438/400,0/2000 +; XXX Congestion: Should reduce by 10 db every other cadence XXX +congestion = 425/375,0/375,420/375,0/375 +callwaiting = 425/200,0/200,425/200,0/4400 +dialrecall = 413+438 +; Record tone used for Call Intrusion/Recording or Conference +record = !425/1000,!0/15000,425/360,0/15000 +info = 425/2500,0/500 +; Other Australian Tones +; The STD "pips" indicate the call is not an untimed local call +std = !525/100,!0/100,!525/100,!0/100,!525/100,!0/100,!525/100,!0/100,!525/100 +; Facility confirmation tone (eg. Call Forward Activated) +facility = 425 +; Message Waiting "stutter" dialtone +stutter = 413+438/100,0/40 +; Ringtone for calls to Telstra mobiles +ringmobile = 400+450/400,0/200,400+450/400,0/2000 + +[bg] +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +description = Bulgaria +ringdance = 1000,4000 +; +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/250,0/250 +callwaiting = 425/150,0/150,425/150,0/4000 +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +record = 1400/425,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +stutter = 425/1500,0/100 + +[br] +description = Brazil +ringcadence = 1000,4000 +dial = 425 +busy = 425/250,0/250 +ring = 425/1000,0/4000 +congestion = 425/250,0/250,425/750,0/250 +callwaiting = 425/50,0/1000 +; Dialrecall not used in Brazil standard (using UK standard) +dialrecall = 350+440 +; Record tone is not used in Brazil, use busy tone +record = 425/250,0/250 +; Info not used in Brazil standard (using UK standard) +info = 950/330,1400/330,1800/330 +stutter = 350+440 + +[be] +description = Belgium +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,3000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/3000 +congestion = 425/167,0/167 +callwaiting = 1400/175,0/175,1400/175,0/3500 +; DIALRECALL - not specified +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440" +; RECORDTONE - not specified +record = 1400/500,0/15000 +info = 900/330,1400/330,1800/330,0/1000 +stutter = 425/1000,0/250 + +[ch] +description = Switzerland +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/200,0/200,425/200,0/4000 +; DIALRECALL - not specified +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +; RECORDTONE - not specified +record = 1400/80,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +stutter = 425+340/1100,0/1100 + +[cl] +description = Chile +; According to specs from Telefonica CTC Chile +ringcadence = 1000,3000 +dial = 400 +busy = 400/500,0/500 +ring = 400/1000,0/3000 +congestion = 400/200,0/200 +callwaiting = 400/250,0/8750 +dialrecall = !400/100,!0/100,!400/100,!0/100,!400/100,!0/100,400 +record = 1400/500,0/15000 +info = 950/333,1400/333,1800/333,0/1000 +stutter = !400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,400 + +[cn] +description = China +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 450 +busy = 450/350,0/350 +ring = 450/1000,0/4000 +congestion = 450/700,0/700 +callwaiting = 450/400,0/4000 +dialrecall = 450 +record = 950/400,0/10000 +info = 450/100,0/100,450/100,0/100,450/100,0/100,450/400,0/400 +; STUTTER - not specified +stutter = 450+425 + +[cz] +description = Czech Republic +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425/330,0/330,425/660,0/660 +busy = 425/330,0/330 +ring = 425/1000,0/4000 +congestion = 425/165,0/165 +callwaiting = 425/330,0/9000 +; DIALRECALL - not specified +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425/330,0/330,425/660,0/660 +; RECORDTONE - not specified +record = 1400/500,0/14000 +info = 950/330,0/30,1400/330,0/30,1800/330,0/1000 +; STUTTER - not specified +stutter = 425/450,0/50 + +[de] +description = Germany +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425 +busy = 425/480,0/480 +ring = 425/1000,0/4000 +congestion = 425/240,0/240 +callwaiting = !425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,!0/5000,!425/200,!0/200,!425/200,0 +; DIALRECALL - not specified +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +; RECORDTONE - not specified +record = 1400/80,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +stutter = 425+400 + +[dk] +description = Denmark +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = !425/200,!0/600,!425/200,!0/3000,!425/200,!0/200,!425/200,0 +; DIALRECALL - not specified +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +; RECORDTONE - not specified +record = 1400/80,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +; STUTTER - not specified +stutter = 425/450,0/50 + +[ee] +description = Estonia +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425 +busy = 425/300,0/300 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +; CALLWAIT not in accordance to ITU +callwaiting = 950/650,0/325,950/325,0/30,1400/1300,0/2600 +; DIALRECALL - not specified +dialrecall = 425/650,0/25 +; RECORDTONE - not specified +record = 1400/500,0/15000 +; INFO not in accordance to ITU +info = 950/650,0/325,950/325,0/30,1400/1300,0/2600 +; STUTTER not specified +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 + +[es] +description = Spain +ringcadence = 1500,3000 +dial = 425 +busy = 425/200,0/200 +ring = 425/1500,0/3000 +congestion = 425/200,0/200,425/200,0/200,425/200,0/600 +callwaiting = 425/175,0/175,425/175,0/3500 +dialrecall = !425/200,!0/200,!425/200,!0/200,!425/200,!0/200,425 +record = 1400/500,0/15000 +info = 950/330,0/1000 +dialout = 500 + + +[fi] +description = Finland +ringcadence = 1000,4000 +dial = 425 +busy = 425/300,0/300 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/150,0/150,425/150,0/8000 +dialrecall = 425/650,0/25 +record = 1400/500,0/15000 +info = 950/650,0/325,950/325,0/30,1400/1300,0/2600 +stutter = 425/650,0/25 + +[fr] +description = France +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1500,3500 +; Dialtone can also be 440+330 +dial = 440 +busy = 440/500,0/500 +ring = 440/1500,0/3500 +; CONGESTION - not specified +congestion = 440/250,0/250 +callwait = 440/300,0/10000 +; DIALRECALL - not specified +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 +; RECORDTONE - not specified +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330 +stutter = !440/100,!0/100,!440/100,!0/100,!440/100,!0/100,!440/100,!0/100,!440/100,!0/100,!440/100,!0/100,440 + +[gr] +description = Greece +ringcadence = 1000,4000 +dial = 425/200,0/300,425/700,0/800 +busy = 425/300,0/300 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/150,0/150,425/150,0/8000 +dialrecall = 425/650,0/25 +record = 1400/400,0/15000 +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0 +stutter = 425/650,0/25 + +[hu] +description = Hungary +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1250,3750 +dial = 425 +busy = 425/300,0/300 +ring = 425/1250,0/3750 +congestion = 425/300,0/300 +callwaiting = 425/40,0/1960 +dialrecall = 425+450 +; RECORDTONE - not specified +record = 1400/400,0/15000 +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0 +stutter = 350+375+400 + +[il] +description = Israel +ringcadence = 1000,3000 +dial = 414 +busy = 414/500,0/500 +ring = 414/1000,0/3000 +congestion = 414/250,0/250 +callwaiting = 414/100,0/100,414/100,0/100,414/600,0/3000 +dialrecall = !414/100,!0/100,!414/100,!0/100,!414/100,!0/100,414 +record = 1400/500,0/15000 +info = 1000/330,1400/330,1800/330,0/1000 +stutter = !414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,!414/160,!0/160,414 + + +[in] +description = India +ringcadence = 400,200,400,2000 +dial = 400*25 +busy = 400/750,0/750 +ring = 400*25/400,0/200,400*25/400,0/2000 +congestion = 400/250,0/250 +callwaiting = 400/200,0/100,400/200,0/7500 +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,0/1000 +stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 + +[it] +description = Italy +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +dial = 425/200,0/200,425/600,0/1000 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/400,0/100,425/250,0/100,425/150,0/14000 +dialrecall = 470/400,425/400 +record = 1400/400,0/15000 +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0 +stutter = 470/400,425/400 + +[lt] +description = Lithuania +ringcadence = 1000,4000 +dial = 425 +busy = 425/350,0/350 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/150,0/150,425/150,0/4000 +; DIALRECALL - not specified +dialrecall = 425/500,0/50 +; RECORDTONE - not specified +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0 +; STUTTER - not specified +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 + +[jp] +description = Japan +ringcadence = 1000,2000 +dial = 400 +busy = 400/500,0/500 +ring = 400+15/1000,0/2000 +congestion = 400/500,0/500 +callwaiting = 400+16/500,0/8000 +dialrecall = !400/200,!0/200,!400/200,!0/200,!400/200,!0/200,400 +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,0 +stutter = !400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,!400/100,!0/100,400 + +[mx] +description = Mexico +ringcadence = 2000,4000 +dial = 425 +busy = 425/250,0/250 +ring = 425/1000,0/4000 +congestion = 425/250,0/250 +callwaiting = 425/200,0/600,425/200,0/10000 +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 +record = 1400/500,0/15000 +info = 950/330,0/30,1400/330,0/30,1800/330,0/1000 +stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 + +[my] +description = Malaysia +ringcadence = 2000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/400,0/200 +congestion = 425/500,0/500 + +[nl] +description = Netherlands +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +ringcadence = 1000,4000 +; Most of these 425's can also be 450's +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/250,0/250 +callwaiting = 425/500,0/9500 +; DIALRECALL - not specified +dialrecall = 425/500,0/50 +; RECORDTONE - not specified +record = 1400/500,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +stutter = 425/500,0/50 + +[no] +description = Norway +ringcadence = 1000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/200,0/200 +callwaiting = 425/200,0/600,425/200,0/10000 +dialrecall = 470/400,425/400 +record = 1400/400,0/15000 +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,0 +stutter = 470/400,425/400 + +[nz] +description = New Zealand +;NOTE - the ITU has different tonesets for NZ, but according to some residents there, +; this is, indeed, the correct way to do it. +ringcadence = 400,200,400,2000 +dial = 400 +busy = 400/250,0/250 +ring = 400+450/400,0/200,400+450/400,0/2000 +congestion = 400/375,0/375 +callwaiting = !400/200,!0/3000,!400/200,!0/3000,!400/200,!0/3000,!400/200 +dialrecall = !400/100!0/100,!400/100,!0/100,!400/100,!0/100,400 +record = 1400/425,0/15000 +info = 400/750,0/100,400/750,0/100,400/750,0/100,400/750,0/400 +stutter = !400/100!0/100,!400/100,!0/100,!400/100,!0/100,!400/100!0/100,!400/100,!0/100,!400/100,!0/100,400 +unobtainable = 400/75,0/100,400/75,0/100,400/75,0/100,400/75,0/400 + +[ph] + +; reference http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf + +description = Philippines +ringcadence = 1000,4000 +dial = 425 +busy = 480+620/500,0/500 +ring = 425+480/1000,0/4000 +congestion = 480+620/250,0/250 +callwaiting = 440/300,0/10000 +; DIALRECALL - not specified +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 +; RECORDTONE - not specified +record = 1400/500,0/15000 +; INFO - not specified +info = !950/330,!1400/330,!1800/330,0 +; STUTTER - not specified +stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 + + +[pl] +description = Poland +ringcadence = 1000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/500,0/500 +callwaiting = 425/150,0/150,425/150,0/4000 +; DIALRECALL - not specified +dialrecall = 425/500,0/50 +; RECORDTONE - not specified +record = 1400/500,0/15000 +; 950/1400/1800 3x0.33 on 1.0 off repeated 3 times +info = !950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000,!950/330,!1400/330,!1800/330,!0/1000 +; STUTTER - not specified +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 + +[pt] +description = Portugal +ringcadence = 1000,5000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/5000 +congestion = 425/200,0/200 +callwaiting = 440/300,0/10000 +dialrecall = 425/1000,0/200 +record = 1400/500,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 + +[ru] +; References: +; http://www.minsvyaz.ru/site.shtml?id=1806 +; http://www.aboutphone.info/lib/gost/45-223-2001.html +description = Russian Federation / ex Soviet Union +ringcadence = 1000,4000 +dial = 425 +busy = 425/350,0/350 +ring = 425/1000,0/4000 +congestion = 425/175,0/175 +callwaiting = 425/200,0/5000 +record = 1400/400,0/15000 +info = 950/330,1400/330,1800/330,0/1000 +dialrecall = 425/400,0/40 +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 + +[se] +description = Sweden +ringcadence = 1000,5000 +dial = 425 +busy = 425/250,0/250 +ring = 425/1000,0/5000 +congestion = 425/250,0/750 +callwaiting = 425/200,0/500,425/200,0/9100 +dialrecall = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +record = 1400/500,0/15000 +info = !950/332,!0/24,!1400/332,!0/24,!1800/332,!0/2024,!950/332,!0/24,!1400/332,!0/24,!1800/332,!0/2024,!950/332,!0/24,!1400/332,!0/24,!1800/332,!0/2024,!950/332,!0/24,!1400/332,!0/24,!1800/332,!0/2024,!950/332,!0/24,!1400/332,!0/24,!1800/332,0 +stutter = !425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,!425/100,!0/100,425 +; stutter = 425/320,0/20 ; Real swedish standard, not used for now + +[sg] +description = Singapore +; Singapore +; Reference: http://www.ida.gov.sg/idaweb/doc/download/I397/ida_ts_pstn1_i4r2.pdf +; Frequency specs are: 425 Hz +/- 20Hz; 24 Hz +/- 2Hz; modulation depth 100%; SIT +/- 50Hz +ringcadence = 400,200,400,2000 +dial = 425 +ring = 425*24/400,0/200,425*24/400,0/2000 ; modulation should be 100%, not 90% +busy = 425/750,0/750 +congestion = 425/250,0/250 +callwaiting = 425*24/300,0/200,425*24/300,0/3200 +stutter = !425/200,!0/200,!425/600,!0/200,!425/200,!0/200,!425/600,!0/200,!425/200,!0/200,!425/600,!0/200,!425/200,!0/200,!425/600,!0/200,425 +info = 950/330,1400/330,1800/330,0/1000 ; not currently in use acc. to reference +dialrecall = 425*24/500,0/500,425/500,0/2500 ; unspecified in IDA reference, use repeating Holding Tone A,B +record = 1400/500,0/15000 ; unspecified in IDA reference, use 0.5s tone every 15s +; additionally defined in reference +nutone = 425/2500,0/500 +intrusion = 425/250,0/2000 +warning = 425/624,0/4376 ; end of period tone, warning +acceptance = 425/125,0/125 +holdinga = !425*24/500,!0/500 ; followed by holdingb +holdingb = !425/500,!0/2500 + +[th] +description = Thailand +ringcadence = 1000,4000 +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +dial = 400*50 +busy = 400/500,0/500 +ring = 420/1000,0/5000 +congestion = 400/300,0/300 +callwaiting = 1000/400,10000/400,1000/400 +; DIALRECALL - not specified - use special dial tone instead. +dialrecall = 400*50/400,0/100,400*50/400,0/100 +; RECORDTONE - not specified +record = 1400/500,0/15000 +; INFO - specified as an announcement - use special information tones instead +info = 950/330,1400/330,1800/330 +; STUTTER - not specified +stutter = !400/200,!0/200,!400/600,!0/200,!400/200,!0/200,!400/600,!0/200,!400/200,!0/200,!400/600,!0/200,!400/200,!0/200,!400/600,!0/200,400 + +[uk] +description = United Kingdom +ringcadence = 400,200,400,2000 +; These are the official tones taken from BT SIN350. The actual tones +; used by BT include some volume differences so sound slightly different +; from Asterisk-generated ones. +dial = 350+440 +; Special dial is the intermittent dial tone heard when, for example, +; you have a divert active on the line +specialdial = 350+440/750,440/750 +; Busy is also called "Engaged" +busy = 400/375,0/375 +; "Congestion" is the Beep-bip engaged tone +congestion = 400/400,0/350,400/225,0/525 +; "Special Congestion" is not used by BT very often if at all +specialcongestion = 400/200,1004/300 +unobtainable = 400 +ring = 400+450/400,0/200,400+450/400,0/2000 +callwaiting = 400/100,0/4000 +; BT seem to use "Special Call Waiting" rather than just "Call Waiting" tones +specialcallwaiting = 400/250,0/250,400/250,0/250,400/250,0/5000 +; "Pips" used by BT on payphones. (Sounds wrong, but this is what BT claim it +; is and I've not used a payphone for years) +creditexpired = 400/125,0/125 +; These two are used to confirm/reject service requests on exchanges that +; don't do voice announcements. +confirm = 1400 +switching = 400/200,0/400,400/2000,0/400 +; This is the three rising tones Doo-dah-dee "Special Information Tone", +; usually followed by the BT woman saying an appropriate message. +info = 950/330,0/15,1400/330,0/15,1800/330,0/1000 +; Not listed in SIN350 +record = 1400/500,0/60000 +stutter = 350+440/750,440/750 + +[us] +description = United States / North America +ringcadence = 2000,4000 +dial = 350+440 +busy = 480+620/500,0/500 +ring = 440+480/2000,0/4000 +congestion = 480+620/250,0/250 +callwaiting = 440/300,0/10000 +dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,0 +stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 + +[us-old] +description = United States Circa 1950/ North America +ringcadence = 2000,4000 +dial = 600*120 +busy = 500*100/500,0/500 +ring = 420*40/2000,0/4000 +congestion = 500*100/250,0/250 +callwaiting = 440/300,0/10000 +dialrecall = !600*120/100,!0/100,!600*120/100,!0/100,!600*120/100,!0/100,600*120 +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,0 +stutter = !600*120/100,!0/100,!600*120/100,!0/100,!600*120/100,!0/100,!600*120/100,!0/100,!600*120/100,!0/100,!600*120/100,!0/100,600*120 + +[tw] +description = Taiwan +; http://nemesis.lonestar.org/reference/telecom/signaling/dialtone.html +; http://nemesis.lonestar.org/reference/telecom/signaling/busy.html +; http://www.iproducts.com.tw/ee/kylink/06ky-1000a.htm +; http://www.pbx-manufacturer.com/ky120dx.htm +; http://www.nettwerked.net/tones.txt +; http://www.cisco.com/univercd/cc/td/doc/product/tel_pswt/vco_prod/taiw_sup/taiw2.htm +; +; busy tone 480+620Hz 0.5 sec. on ,0.5 sec. off +; reorder tone 480+620Hz 0.25 sec. on,0.25 sec. off +; ringing tone 440+480Hz 1 sec. on ,2 sec. off +; +ringcadence = 1000,4000 +dial = 350+440 +busy = 480+620/500,0/500 +ring = 440+480/1000,0/2000 +congestion = 480+620/250,0/250 +callwaiting = 350+440/250,0/250,350+440/250,0/3250 +dialrecall = 300/1500,0/500 +record = 1400/500,0/15000 +info = !950/330,!1400/330,!1800/330,0 +stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440 + +[ve] +; Tone definition source for ve found on +; Reference: http://www.itu.int/ITU-T/inr/forms/files/tones-0203.pdf +description = Venezuela / South America +ringcadence = 1000,4000 +dial = 425 +busy = 425/500,0/500 +ring = 425/1000,0/4000 +congestion = 425/250,0/250 +callwaiting = 400+450/300,0/6000 +dialrecall = 425 +record = 1400/500,0/15000 +info = !950/330,!1440/330,!1800/330,0/1000 + + +[za] +description = South Africa +; http://www.cisco.com/univercd/cc/td/doc/product/tel_pswt/vco_prod/safr_sup/saf02.htm +; (definitions for other countries can also be found there) +; Note, though, that South Africa uses two switch types in their network -- +; Alcatel switches -- mainly in the Western Cape, and Siemens elsewhere. +; The former use 383+417 in dial, ringback etc. The latter use 400*33 +; I've provided both, uncomment the ones you prefer +ringcadence = 400,200,400,2000 +; dial/ring/callwaiting for the Siemens switches: +dial = 400*33 +ring = 400*33/400,0/200,400*33/400,0/2000 +callwaiting = 400*33/250,0/250,400*33/250,0/250,400*33/250,0/250,400*33/250,0/250 +; dial/ring/callwaiting for the Alcatel switches: +; dial = 383+417 +; ring = 383+417/400,0/200,383+417/400,0/2000 +; callwaiting = 383+417/250,0/250,383+417/250,0/250,383+417/250,0/250,383+417/250,0/250 +congestion = 400/250,0/250 +busy = 400/500,0/500 +dialrecall = 350+440 +; XXX Not sure about the RECORDTONE +record = 1400/500,0/10000 +info = 950/330,1400/330,1800/330,0/330 +stutter = !400*33/100,!0/100,!400*33/100,!0/100,!400*33/100,!0/100,!400*33/100,!0/100,!400*33/100,!0/100,!400*33/100,!0/100,400*33 diff --git a/AsteriskConfig/logger.conf b/AsteriskConfig/logger.conf new file mode 100644 index 0000000..0ac424a --- /dev/null +++ b/AsteriskConfig/logger.conf @@ -0,0 +1,69 @@ +; +; Logging Configuration +; +; In this file, you configure logging to files or to +; the syslog system. +; +; "logger reload" at the CLI will reload configuration +; of the logging system. + +[general] +; Customize the display of debug message time stamps +; this example is the ISO 8601 date format (yyyy-mm-dd HH:MM:SS) +; see strftime(3) Linux manual for format specifiers +;dateformat=%F %T +; +; This appends the hostname to the name of the log files. +;appendhostname = yes +; +; This determines whether or not we log queue events to a file +; (defaults to yes). +;queue_log = no +; +; This determines whether or not we log generic events to a file +; (defaults to yes). +;event_log = no +; +; +; For each file, specify what to log. +; +; For console logging, you set options at start of +; Asterisk with -v for verbose and -d for debug +; See 'asterisk -h' for more information. +; +; Directory for log files is configures in asterisk.conf +; option astlogdir +; +[logfiles] +; +; Format is "filename" and then "levels" of debugging to be included: +; debug +; notice +; warning +; error +; verbose +; dtmf +; +; Special filename "console" represents the system console +; +; We highly recommend that you DO NOT turn on debug mode if you are simply +; running a production system. Debug mode turns on a LOT of extra messages, +; most of which you are unlikely to understand without an understanding of +; the underlying code. Do NOT report debug messages as code issues, unless +; you have a specific issue that you are attempting to debug. They are +; messages for just that -- debugging -- and do not rise to the level of +; something that merit your attention as an Asterisk administrator. Debug +; messages are also very verbose and can and do fill up logfiles quickly; +; this is another reason not to have debug mode on a production system unless +; you are in the process of debugging a specific issue. +; +;debug => debug +console => notice,warning,error +;console => notice,warning,error,debug +;messages => notice,warning,error +;full => notice,warning,error,debug,verbose + +;syslog keyword : This special keyword logs to syslog facility +; +;syslog.local0 => notice,warning,error +; diff --git a/AsteriskConfig/modules.conf b/AsteriskConfig/modules.conf new file mode 100644 index 0000000..c2f2ba7 --- /dev/null +++ b/AsteriskConfig/modules.conf @@ -0,0 +1,36 @@ +; +; Asterisk configuration file +; +; Module Loader configuration file +; + +[modules] +autoload=yes +; +; Any modules that need to be loaded before the Asterisk core has been +; initialized (just after the logger has been initialized) can be loaded +; using 'preload'. This will frequently be needed if you wish to map all +; module configuration files into Realtime storage, since the Realtime +; driver will need to be loaded before the modules using those configuration +; files are initialized. +; +; An example of loading ODBC support would be: +;preload => res_odbc.so +;preload => res_config_odbc.so +; +; Uncomment the following if you wish to use the Speech Recognition API +;preload => res_speech.so +; +; If you want, load the GTK console right away. +; +noload => pbx_gtkconsole.so +;load => pbx_gtkconsole.so +; +noload => res_musiconhold.so +;load => res_musiconhold.so +; +; Load either OSS or ALSA, not both +; By default, load OSS only (automatically) and do not load ALSA +; +noload => chan_alsa.so +;noload => chan_oss.so diff --git a/AsteriskConfig/sip.conf b/AsteriskConfig/sip.conf new file mode 100644 index 0000000..bb7a8b9 --- /dev/null +++ b/AsteriskConfig/sip.conf @@ -0,0 +1,91 @@ +[general] +bindport=5060 ; asterisk 1.6 + ; UDP Port to bind to (SIP standard port for unencrypted UDP + ; and TCP sessions is 5060) + ; bindport is the local UDP port that Asterisk will listen on +bindaddr=0.0.0.0 ; asterisk 1.6 + ; IP address to bind UDP listen socket to (0.0.0.0 binds to all) + ; You can specify port here too, like 123.123.123.123:5080 +udpbindaddr=0.0.0.0 ; asterisk 1.8 + ; IP address to bind UDP listen socket to (0.0.0.0 binds to all) + ; Optionally add a port number, 192.168.1.1:5062 (default is port 5060) + +tos_sip=cs3 ; Sets TOS for SIP packets. +tos_audio=ef ; Sets TOS for RTP audio packets. +tos_video=af41 ; Sets TOS for RTP video packets. +tos_text=af41 ; Sets TOS for RTP text packets. + +cos_sip=3 ; Sets 802.1p priority for SIP packets. +cos_audio=5 ; Sets 802.1p priority for RTP audio packets. +cos_video=4 ; Sets 802.1p priority for RTP video packets. +cos_text=3 ; Sets 802.1p priority for RTP text packets. + +maxexpiry=3600 ; Maximum allowed time of incoming registrations + ; and subscriptions (seconds) +minexpiry=60 ; Minimum length of registrations/subscriptions (default 60) +defaultexpiry=3600 ; Default length of incoming/outgoing registration +dynamic_exclude_static=yes ; Disallow all dynamic hosts from registering + ; as any IP address used for staticly defined + ; hosts. This helps avoid the configuration + ; error of allowing your users to register at + ; the same address as a SIP provider. +use_q850_reason=yes ; Set to yes add Reason header and use Reason header if it is available. + +;t1min=100 ; Minimum roundtrip time for messages to monitored hosts + ; Defaults to 100 ms +;timert1=500 ; Default T1 timer + ; Defaults to 500 ms or the measured round-trip + ; time to a peer (qualify=yes). +;timerb=32000 ; Call setup timer. If a provisional response is not received + ; in this amount of time, the call will autocongest + ; Defaults to 64*timert1 +rtptimeout=60 ; Terminate call if 60 seconds of no RTP or RTCP activity + ; on the audio channel + ; when we're not on hold. This is to be able to hangup + ; a call in the case of a phone disappearing from the net, + ; like a powerloss or grandma tripping over a cable. +rtpholdtimeout=300 ; Terminate call if 300 seconds of no RTP or RTCP activity + ; on the audio channel + ; when we're on hold (must be > rtptimeout) + +;allowguest=no ; Allow or reject guest calls (default is yes) +autocreatepeer=yes ; The Autocreatepeer option allows, + ; if set to Yes, any SIP ua to register with your Asterisk PBX as a peer. + ; This peer's settings will be based on global options. + ; The peer's name will be based on the user part of the Contact: header field's URL. + +context=phones ; Default context for incoming calls +allowoverlap=no ; Disable overlap dialing support. (Default is yes) + +disallow=all ; need to disallow=all before we can use allow= +allow=gsm ; GSM +allow=ulaw ; ISDN US +allow=alaw ; ISDN EU + +relaxdtmf=yes ; Relax dtmf handling +dtmfmode=auto ; Set default dtmfmode for sending DTMF. Default: rfc2833 + ; Other options: + ; info : SIP INFO messages (application/dtmf-relay) + ; shortinfo : SIP INFO messages (application/dtmf) + ; inband : Inband audio (requires 64 kbit codec -alaw, ulaw) + ; auto : Use rfc2833 if offered, inband otherwise + + +; Zoiper is used as a fixture for factory testing. +[zoiper] +secret=3078923984 +callerid=2101 +canreinvite=no +type=friend +context=sip-local +host=dynamic +dtmfmode=auto + +; This is a test SIM provided with the BTS. +[IMSI001010000000000] +callerid=2100 +canreinvite=no +type=friend +context=sip-local +host=dynamic + diff --git a/CLI/CLI.cpp b/CLI/CLI.cpp new file mode 100644 index 0000000..0b9b383 --- /dev/null +++ b/CLI/CLI.cpp @@ -0,0 +1,768 @@ +/* +* Copyright 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +// #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "CLI.h" + +#undef WARNING + +using namespace std; +using namespace CommandLine; + +#define SUCCESS 0 +#define BAD_NUM_ARGS 1 +#define BAD_VALUE 2 +#define NOT_FOUND 3 +#define TOO_MANY_ARGS 4 +#define FAILURE 5 + +extern TransceiverManager gTRX; + +/** Standard responses in the CLI, much mach erorrCode enum. */ +static const char* standardResponses[] = { + "success", // 0 + "wrong number of arguments", // 1 + "bad argument(s)", // 2 + "command not found", // 3 + "too many arguments for parser", // 4 + "command failed", // 5 +}; + + + + +int Parser::execute(char* line, ostream& os, istream& is) const +{ + // escape to the shell? + if (line[0]=='!') { + os << endl; + int retVal = system(line+1); + os << endl << "External call returned " << retVal << endl; + return SUCCESS; + } + // tokenize + char *argv[mMaxArgs]; + int argc = 0; + char **ap; + // This is (almost) straight from the man page for strsep. + for (ap=argv; (*ap=strsep(&line," ")) != NULL; ) { + if (**ap != '\0') { + if (++ap >= &argv[mMaxArgs]) break; + else argc++; + } + } + // Blank line? + if (!argc) return SUCCESS; + // Find the command. + ParseTable::const_iterator cfp = mParseTable.find(argv[0]); + if (cfp == mParseTable.end()) { + return NOT_FOUND; + } + int (*func)(int,char**,ostream&,istream&); + func = cfp->second; + // Do it. + int retVal = (*func)(argc,argv,os,is); + // Give hint on bad # args. + if (retVal==BAD_NUM_ARGS) os << help(argv[0]) << endl; + return retVal; +} + + +int Parser::process(const char* line, ostream& os, istream& is) const +{ + char *newLine = strdup(line); + int retVal = execute(newLine,os,is); + free(newLine); + if (retVal>0) os << standardResponses[retVal] << endl; + return retVal; +} + + +const char * Parser::help(const string& cmd) const +{ + HelpTable::const_iterator hp = mHelpTable.find(cmd); + if (hp==mHelpTable.end()) return "no help available"; + return hp->second.c_str(); +} + + + +/**@name Commands for the CLI. */ +//@{ + +// forward refs +int printStats(int argc, char** argv, ostream& os, istream& is); + +/* + A CLI command takes the argument in an array. + It returns 0 on success. +*/ + +/** Display system uptime and current GSM frame number. */ +int uptime(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + os.precision(2); + os << "Unix time " << time(NULL) << endl; + int seconds = gBTS.uptime(); + if (seconds<120) { + os << "uptime " << seconds << " seconds, frame " << gBTS.time() << endl; + return SUCCESS; + } + float minutes = seconds / 60.0F; + if (minutes<120) { + os << "uptime " << minutes << " minutes, frame " << gBTS.time() << endl; + return SUCCESS; + } + float hours = minutes / 60.0F; + if (hours<48) { + os << "uptime " << hours << " hours, frame " << gBTS.time() << endl; + return SUCCESS; + } + float days = hours / 24.0F; + os << "uptime " << days << " days, frame " << gBTS.time() << endl; + return SUCCESS; +} + + +/** Give a list of available commands or describe a specific command. */ +int showHelp(int argc, char** argv, ostream& os, istream& is) +{ + if (argc==2) { + os << argv[1] << " " << gParser.help(argv[1]) << endl; + return SUCCESS; + } + if (argc!=1) return BAD_NUM_ARGS; + ParseTable::const_iterator cp = gParser.begin(); + os << endl << "Type \"help\" followed by the command name for help on that command." << endl << endl; + int c=0; + const int cols = 3; + while (cp != gParser.end()) { + const string& wd = cp->first; + os << wd << '\t'; + if (wd.size()<8) os << '\t'; + ++cp; + c++; + if (c%cols==0) os << endl; + } + if (c%cols!=0) os << endl; + os << endl << "Lines starting with '!' are escaped to the shell." << endl; + os << endl << "Use , to detach from \"screen\", *not* ." << endl << endl; + return SUCCESS; +} + + + +/** A function to return -1, the exit code for the caller. */ +int exit_function(int argc, char** argv, ostream& os, istream& is) +{ + unsigned wait =0; + if (argc>2) return BAD_NUM_ARGS; + if (argc==2) wait = atoi(argv[1]); + + if (wait!=0) + os << "waiting up to " << wait << " seconds for clearing of " + << gBTS.TCHActive() << " active calls" << endl; + + // Block creation of new channels. + gBTS.hold(true); + // Wait up to the timeout for active channels to release. + time_t finish = time(NULL) + wait; + while (time(NULL)0) { + LOG(WARNING) << "dropping " << gBTS.SDCCHActive() << " control transactions on exit"; + loads = true; + } + if (gBTS.TCHActive()>0) { + LOG(WARNING) << "dropping " << gBTS.TCHActive() << " calls on exit"; + loads = true; + } + if (loads) { + os << endl << "exiting with loads:" << endl; + printStats(1,NULL,os,is); + } + os << endl << "exiting..." << endl; + return -1; +} + + + +// Forward ref. +int tmsis(int argc, char** argv, ostream& os, istream& is); + +/** Dump TMSI table to a text file. */ +int dumpTMSIs(const char* filename, istream& is) +{ + ofstream fileout; + fileout.open(filename, ios::out); // erases existing! + // FIXME -- Check that the file really opened. + // Fake an argument list to call printTMSIs. + char* subargv[] = {"tmsis", NULL}; + int subargc = 1; + return tmsis(subargc, subargv, fileout, is); +} + + + + +/** Print or clear the TMSI table. */ +int tmsis(int argc, char** argv, ostream& os, istream& is) +{ + if (argc>=2) { + // Clear? + if (strcmp(argv[1],"clear")==0) { + if (argc!=2) return BAD_NUM_ARGS; + os << "clearing TMSI table" << endl; + gTMSITable.clear(); + return SUCCESS; + } + // Dump? + if (strcmp(argv[1],"dump")==0) { + if (argc!=3) return BAD_NUM_ARGS; + os << "dumping TMSI table to " << argv[2] << endl; + return dumpTMSIs(argv[2],is); + } + return BAD_VALUE; + } + + if (argc!=1) return BAD_NUM_ARGS; + os << "TMSI IMSI age used" << endl; + gTMSITable.dump(os); + return SUCCESS; +} + + +/** Submit an SMS for delivery to an IMSI. */ +int sendsimple(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=3) return BAD_NUM_ARGS; + + os << "enter text to send: "; + char txtBuf[161]; + cin.getline(txtBuf,160,'\n'); + char *IMSI = argv[1]; + char *srcAddr = argv[2]; + + static UDPSocket sock(0,"127.0.0.1",gConfig.getNum("SIP.Local.Port")); + + static const char form[] = + "MESSAGE sip:IMSI%s@127.0.0.1 SIP/2.0\n" + "Via: SIP/2.0/TCP 127.0.0.1;branch=%x\n" + "Max-Forwards: 2\n" + "From: %s ;tag=%d\n" + "To: sip:IMSI%s@127.0.0.1\n" + "Call-ID: %x@127.0.0.1:%d\n" + "CSeq: 1 MESSAGE\n" + "Content-Type: text/plain\nContent-Length: %u\n" + "\n%s\n"; + static char buffer[1500]; + snprintf(buffer,1499,form, + IMSI, (unsigned)random(), srcAddr,srcAddr,sock.port(),(unsigned)random(), IMSI, (unsigned)random(),sock.port(), strlen(txtBuf), txtBuf); + sock.write(buffer); + + +#if 0 + int numRead = sock.read(buffer,10000); + if (numRead>=0) { + buffer[numRead]='\0'; + os << "response: " << buffer << endl; + } else { + os << "timed out waiting for response"; + } +#endif + + return SUCCESS; +} + + +/** Submit an SMS for delivery to an IMSI. */ +int sendsms(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=3) return BAD_NUM_ARGS; + + os << "enter text to send: "; + char txtBuf[161]; + cin.getline(txtBuf,160,'\n'); + char *IMSI = argv[1]; + char *srcAddr = argv[2]; + + Control::TransactionEntry *transaction = new Control::TransactionEntry( + gConfig.getStr("SIP.Proxy.SMS").c_str(), + GSM::L3MobileIdentity(IMSI), + NULL, + GSM::L3CMServiceType::MobileTerminatedShortMessage, + GSM::L3CallingPartyBCDNumber(srcAddr), + GSM::Paging, + txtBuf); + transaction->messageType("text/plain"); + Control::initiateMTTransaction(transaction,GSM::SDCCHType,30000); + os << "message submitted for delivery" << endl; + return SUCCESS; +} + +/** DEBUGGING: Sends a special sms that triggers a RRLP message to an IMSI. */ +int sendrrlp(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=3) return BAD_NUM_ARGS; + + char *IMSI = argv[1]; + + UDPSocket sock(0,"127.0.0.1",gConfig.getNum("SIP.Local.Port")); + unsigned port = sock.port(); + unsigned callID = random(); + + // Just fake out a SIP message. + const char form[] = "MESSAGE sip:IMSI%s@localhost SIP/2.0\nVia: SIP/2.0/TCP localhost;branch=z9hG4bK776sgdkse\nMax-Forwards: 2\nFrom: RRLP@localhost:%d;tag=49583\nTo: sip:IMSI%s@localhost\nCall-ID: %d@127.0.0.1:5063\nCSeq: 1 MESSAGE\nContent-Type: text/plain\nContent-Length: %lu\n\n%s\n"; + + char txtBuf[161]; + snprintf(txtBuf,160,"RRLP%s",argv[2]); + char outbuf[1500]; + snprintf(outbuf,1499,form,IMSI,port,IMSI,callID,strlen(txtBuf),txtBuf); + sock.write(outbuf); + sleep(2); + sock.write(outbuf); + sock.close(); + os << "RRLP Triggering message submitted for delivery" << endl; + + return SUCCESS; +} + + + +/** Print current usage loads. */ +int printStats(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + os << "SDCCH load: " << gBTS.SDCCHActive() << '/' << gBTS.SDCCHTotal() << endl; + os << "TCH/F load: " << gBTS.TCHActive() << '/' << gBTS.TCHTotal() << endl; + os << "AGCH/PCH load: " << gBTS.AGCHLoad() << ',' << gBTS.PCHLoad() << endl; + // paging table size + os << "Paging table size: " << gBTS.pager().pagingEntryListSize() << endl; + os << "Transactions: " << gTransactionTable.size() << endl; + // 3122 timer current value (the number of seconds an MS should hold off the next RACH) + os << "T3122: " << gBTS.T3122() << " ms" << endl; + return SUCCESS; +} + + + +/** Get/Set MCC, MNC, LAC, CI. */ +int cellID(int argc, char** argv, ostream& os, istream& is) +{ + if (argc==1) { + os << "MCC=" << gConfig.getStr("GSM.Identity.MCC") + << " MNC=" << gConfig.getStr("GSM.Identity.MNC") + << " LAC=" << gConfig.getNum("GSM.Identity.LAC") + << " CI=" << gConfig.getNum("GSM.Identity.CI") + << endl; + return SUCCESS; + } + + if (argc!=5) return BAD_NUM_ARGS; + + // Safety check the args!! + char* MCC = argv[1]; + char* MNC = argv[2]; + if (strlen(MCC)!=3) { + os << "MCC must be three digits" << endl; + return BAD_VALUE; + } + int MNCLen = strlen(MNC); + if ((MNCLen<2)||(MNCLen>3)) { + os << "MNC must be two or three digits" << endl; + return BAD_VALUE; + } + gTMSITable.clear(); + gConfig.set("GSM.Identity.MCC",MCC); + gConfig.set("GSM.Identity.MNC",MNC); + gConfig.set("GSM.Identity.LAC",argv[3]); + gConfig.set("GSM.Identity.CI",argv[4]); + return SUCCESS; +} + + + + +/** Print table of current transactions. */ +int calls(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + size_t count = gTransactionTable.dump(os); + os << endl << count << " transactions in table" << endl; + return SUCCESS; +} + + + +/** Print or modify the global configuration table. */ +int config(int argc, char** argv, ostream& os, istream& is) +{ + // no args, just print + if (argc==1) { + gConfig.find("",os); + return SUCCESS; + } + + // one arg, pattern match and print + if (argc==2) { + gConfig.find(argv[1],os); + return SUCCESS; + } + + // >1 args: set new value + string val; + for (int i=2; i3) return BAD_NUM_ARGS; + + unsigned newT3212 = strtol(argv[1],NULL,10); + if ((newT3212<6)||(newT3212>1530)) { + os << "valid T3212 range is 6..1530 minutes" << endl; + return BAD_VALUE; + } + + // By defuault, make SIP registration period 1.5x the GSM registration period. + unsigned SIPRegPeriod = newT3212*90; + if (argc==3) { + SIPRegPeriod = 60*strtol(argv[2],NULL,10); + } + + // Set the values in the table and on the GSM beacon. + gConfig.set("SIP.RegistrationPeriod",SIPRegPeriod); + gConfig.set("GSM.Timer.T3212",newT3212); + // Done. + return SUCCESS; +} + + +/** Print the list of alarms kept by the logger, i.e. the last LOG(ALARM) << */ +int alarms(int argc, char** argv, ostream& os, istream& is) +{ + std::ostream_iterator output( os, "\n" ); + std::list alarms = gGetLoggerAlarms(); + std::copy( alarms.begin(), alarms.end(), output ); + return SUCCESS; +} + + +/** Version string. */ +int version(int argc, char **argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + os << "release " VERSION " built " __DATE__ << endl; + return SUCCESS; +} + +/** Show start-up notices. */ +int notices(int argc, char **argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + os << endl << gOpenBTSWelcome << endl; + return SUCCESS; +} + +int page(int argc, char **argv, ostream& os, istream& is) +{ + if (argc==1) { + gBTS.pager().dump(os); + return SUCCESS; + } + if (argc!=3) return BAD_NUM_ARGS; + char *IMSI = argv[1]; + if (strlen(IMSI)>15) { + os << IMSI << " is not a valid IMSI" << endl; + return BAD_VALUE; + } + Control::TransactionEntry dummy( + gConfig.getStr("SIP.Proxy.SMS").c_str(), + GSM::L3MobileIdentity(IMSI), + NULL, + GSM::L3CMServiceType::UndefinedType, + GSM::L3CallingPartyBCDNumber("0"), + GSM::Paging); + gBTS.pager().addID(GSM::L3MobileIdentity(IMSI),GSM::SDCCHType,dummy,1000*atoi(argv[2])); + return SUCCESS; +} + + + +int endcall(int argc, char **argv, ostream& os, istream& is) +{ + if (argc!=2) return BAD_NUM_ARGS; + unsigned transID = atoi(argv[1]); + Control::TransactionEntry* target = gTransactionTable.find(transID); + if (!target) { + os << transID << " not found in table"; + return BAD_VALUE; + } + target->terminate(); + return SUCCESS; +} + + + + +void printChanInfo(unsigned transID, const GSM::LogicalChannel* chan, ostream& os) +{ + os << setw(2) << chan->CN() << " " << chan->TN(); + os << " " << setw(8) << chan->typeAndOffset(); + os << " " << setw(12) << transID; + char buffer[200]; + snprintf(buffer,199,"%5.2f %4d %5d %4d", + 100.0*chan->FER(), (int)round(chan->RSSI()), + chan->actualMSPower(), chan->actualMSTiming()); + os << " " << buffer; + const GSM::L3MeasurementResults& meas = chan->SACCH()->measurementResults(); + if (!meas.MEAS_VALID()) { + snprintf(buffer,199,"%5d %5.2f", + meas.RXLEV_FULL_SERVING_CELL_dBm(), + 100.0*meas.RXQUAL_FULL_SERVING_CELL_BER()); + os << " " << buffer; + } else { + os << " ----- ------"; + } + os << endl; +} + + + +int chans(int argc, char **argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + + os << "CN TN chan transaction UPFER RSSI TXPWR TXTA DNLEV DNBER" << endl; + os << "CN TN type id pct dB dBm sym dBm pct" << endl; + + //gPhysStatus.dump(os); + //os << endl << "Old data reporting: " << endl; + + // SDCCHs + GSM::SDCCHList::const_iterator sChanItr = gBTS.SDCCHPool().begin(); + while (sChanItr != gBTS.SDCCHPool().end()) { + const GSM::SDCCHLogicalChannel* sChan = *sChanItr; + if (sChan->active()) { + Control::TransactionEntry *trans = gTransactionTable.find(sChan); + if (trans) printChanInfo(trans->ID(),sChan,os); + else printChanInfo(0,sChan,os); + } + ++sChanItr; + } + + // TCHs + GSM::TCHList::const_iterator tChanItr = gBTS.TCHPool().begin(); + while (tChanItr != gBTS.TCHPool().end()) { + const GSM::TCHFACCHLogicalChannel* tChan = *tChanItr; + if (tChan->active()) { + Control::TransactionEntry *trans = gTransactionTable.find(tChan); + if (trans) printChanInfo(trans->ID(),tChan,os); + else printChanInfo(0,tChan,os); + } + ++tChanItr; + } + + os << endl; + + return SUCCESS; +} + + + + +int power(int argc, char **argv, ostream& os, istream& is) +{ + os << "current downlink power " << gBTS.powerManager().power() << " dB wrt full scale" << endl; + os << "current attenuation bounds " + << gConfig.getNum("GSM.Radio.PowerManager.MinAttenDB") + << " to " + << gConfig.getNum("GSM.Radio.PowerManager.MaxAttenDB") + << " dB" << endl; + + if (argc==1) return SUCCESS; + if (argc!=3) return BAD_NUM_ARGS; + + int min = atoi(argv[1]); + int max = atoi(argv[2]); + if (min>max) return BAD_VALUE; + + gConfig.set("GSM.Radio.PowerManager.MinAttenDB",argv[1]); + gConfig.set("GSM.Radio.PowerManager.MaxAttenDB",argv[2]); + + os << "new attenuation bounds " + << gConfig.getNum("GSM.Radio.PowerManager.MinAttenDB") + << " to " + << gConfig.getNum("GSM.Radio.PowerManager.MaxAttenDB") + << " dB" << endl; + + return SUCCESS; +} + + +int rxgain(int argc, char** argv, ostream& os, istream& is) +{ + os << "current RX gain is " << gConfig.getNum("GSM.Radio.RxGain") << " dB" << endl; + if (argc==1) return SUCCESS; + if (argc!=2) return BAD_NUM_ARGS; + + int newGain = gTRX.ARFCN()->setRxGain(atoi(argv[1])); + os << "new RX gain is " << newGain << " dB" << endl; + + gConfig.set("GSM.Radio.RxGain",newGain); + + return SUCCESS; +} + +int noise(int argc, char** argv, ostream& os, istream& is) +{ + if (argc!=1) return BAD_NUM_ARGS; + + int noise = gTRX.ARFCN()->getNoiseLevel(); + os << "noise RSSI is -" << noise << " dB wrt full scale" << endl; + os << "MS RSSI target is " << gConfig.getNum("GSM.Radio.RSSITarget") << " dB wrt full scale" << endl; + + return SUCCESS; +} + + +//@} // CLI commands + + + +Parser::Parser() +{ + // The constructor adds the commands. + addCommand("uptime", uptime, "-- show BTS uptime and BTS frame number."); + addCommand("help", showHelp, "[command] -- list available commands or gets help on a specific command."); + addCommand("exit", exit_function, "[wait] -- exit the application, either immediately, or waiting for existing calls to clear with a timeout in seconds"); + addCommand("tmsis", tmsis, "[\"clear\"] or [\"dump\" filename] -- print/clear the TMSI table or dump it to a file."); + addCommand("sendsms", sendsms, " -- send direct SMS to , addressed from , after prompting."); + addCommand("sendsimple", sendsimple, " -- send SMS to via SIP interface, addressed from , after prompting."); + addCommand("sendrrlp", sendrrlp, " -- send RRLP message to ."); + addCommand("load", printStats, "-- print the current activity loads."); + addCommand("cellid", cellID, "[MCC MNC LAC CI] -- get/set location area identity (MCC, MNC, LAC) and cell ID (CI)"); + addCommand("calls", calls, "-- print the transaction table"); + addCommand("config", config, "[] OR [patt] OR [key val(s)] -- print the current configuration, print configuration values matching a pattern, or set/change a configuration value"); + addCommand("configsave", configsave, " -- write the current configuration to a file"); + addCommand("regperiod", regperiod, "[GSM] [SIP] -- get/set the registration period (GSM T3212), in MINUTES"); + addCommand("alarms", alarms, "-- show latest alarms"); + addCommand("version", version,"-- print the version string"); + addCommand("page", page, "[IMSI time] -- dump the paging table or page the given IMSI for the given period"); + addCommand("chans", chans, "-- report PHY status for active channels"); + addCommand("power", power, "[minAtten maxAtten] -- report current attentuation or set min/max bounds"); + addCommand("rxgain", rxgain, "[newRxgain] -- get/set the RX gain in dB"); + addCommand("noise", noise, "-- report receive noise level in RSSI dB"); + addCommand("unconfig", unconfig, "key -- remove a config value"); + addCommand("notices", notices, "-- show startup copyright and legal notices"); + addCommand("endcall", endcall,"trans# -- terminate the given transaction"); +} + + + + +// vim: ts=4 sw=4 diff --git a/CLI/CLI.h b/CLI/CLI.h new file mode 100644 index 0000000..70a6873 --- /dev/null +++ b/CLI/CLI.h @@ -0,0 +1,76 @@ +/* +* Copyright 2009 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + +#ifndef OPENBTSCLI_H +#define OPENBTSCLI_H + +#include +#include +#include + + +namespace CommandLine { + + +/** A table for matching strings to actions. */ +typedef std::map ParseTable; + +/** The help table. */ +typedef std::map HelpTable; + +class Parser { + + private: + + ParseTable mParseTable; + HelpTable mHelpTable; + static const int mMaxArgs = 10; + + public: + + Parser(); + + /** + Process a command line. + @return 0 on sucess, -1 on exit request, error codes otherwise + */ + int process(const char* line, std::ostream& os, std::istream& is) const; + + /** Add a command to the parsing table. */ + void addCommand(const char* name, int (*func)(int,char**,std::ostream&,std::istream&), const char* helpString) + { mParseTable[name] = func; mHelpTable[name]=helpString; } + + ParseTable::const_iterator begin() const { return mParseTable.begin(); } + ParseTable::const_iterator end() const { return mParseTable.end(); } + + /** Return a help string. */ + const char *help(const std::string& cmd) const; + + private: + + /** Parse and execute a command string. */ + int execute(char* line, std::ostream& os, std::istream& is) const; + +}; + + + +} // CLI + + + +#endif +// vim: ts=4 sw=4 diff --git a/CLI/Makefile.am b/CLI/Makefile.am new file mode 100644 index 0000000..9ed1b27 --- /dev/null +++ b/CLI/Makefile.am @@ -0,0 +1,35 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +EXTRA_DIST = \ + README.CLI + +AM_CXXFLAGS = -Wall +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) + +noinst_LTLIBRARIES = libcli.la + +libcli_la_SOURCES = \ + CLI.cpp + +noinst_HEADERS = \ + CLI.h diff --git a/CLI/Makefile.in b/CLI/Makefile.in new file mode 100644 index 0000000..ae8565b --- /dev/null +++ b/CLI/Makefile.in @@ -0,0 +1,531 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2009 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libcli_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = CLI +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libcli_la_LIBADD = +am_libcli_la_OBJECTS = CLI.lo +libcli_la_OBJECTS = $(am_libcli_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libcli_la_SOURCES) +DIST_SOURCES = $(libcli_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +EXTRA_DIST = \ + README.CLI + +AM_CXXFLAGS = -Wall +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +noinst_LTLIBRARIES = libcli.la +libcli_la_SOURCES = \ + CLI.cpp + +noinst_HEADERS = \ + CLI.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu CLI/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu CLI/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libcli.la: $(libcli_la_OBJECTS) $(libcli_la_DEPENDENCIES) + $(CXXLINK) $(libcli_la_LDFLAGS) $(libcli_la_OBJECTS) $(libcli_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CLI.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/CLI/README.CLI b/CLI/README.CLI new file mode 100644 index 0000000..a9676d6 --- /dev/null +++ b/CLI/README.CLI @@ -0,0 +1,2 @@ +This is the directory for the OpenBTS command line interface. + diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..b5af151 --- /dev/null +++ b/COPYING @@ -0,0 +1,724 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + 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 +them 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey 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; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If 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 convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + 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. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +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. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + 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 +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. + + + + +========================================================================= + +This marks the end of the AGPLv3 text. The following text is appended to the +same file for convience but constituting a distinct document, not part of the +actual AGPL text and not part of an attempt to create a deriviative work based +on the AGPLv3 text. + +========================================================================= + + +ADDITIONAL TERMS TO THE AGPLv3 LICENSE FOR OPENBTS + + +Permissive Terms Supplementing the License + +1. Remote Interaction Through IP Networks. + +OpenBTS includes an implementation of the GSM network cellular air interface, +as well as other interfaces to IP networks. The interaction of cellular +handsets with the OpenBTS software is considered "remote network interaction" +for the purposes of the Affero General Public License and cellular users are +subject to the source code access requirements of Section 13 of AGPLv3 ("Remote +Network Interaction; Use with the GNU General Public License"). + +Remote interactions through interfaces other than the GSM air interface are, at +your option, exempted from the requirements of Section 13 ("Remote Network +Interaction; Use with the GNU General Public License"). This exemption of +interfaces other than the GSM air interface from the requirements of Section 13 +is an additional permission granted to you. + + +Non-Permissive Terms Supplementing The License + +1. Trademarks. + +"OpenBTS" is a trademark of Range Networks, Inc., registered with +the US Patent and Trademark Office. Your use of OpenBTS software under a GPL +license does not include the right to use the OpenBTS trademark in commerce. +This additional non-permissive term is consistent with Section 7 of the AGPLv3 +license. + + +END OF ADDITIONAL TERMS + + + +How to comply with Section 13 of the AGPLv3 license. + +The recommended method for compliance with Section 13 of the AGPLv3 license is +to deliver a text message to each handset that attaches to the OpenBTS cellular +network. At a minimum, that text message should include the string "OpenBTS +AGPLv3" and a URL that can be used to access the OpenBTS source code. This +message need not be delivered to handsets that are denied registration with the +network, since those handsets have been denied service. + +In OpenBTS 2.6, such text messages can be delivered with the "Welcome Message" +feature. See the OpenBTS.config.example file for more information on the use of +this feature for AGPLv3 compliance. + diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/CommonLibs/BitVector.cpp b/CommonLibs/BitVector.cpp new file mode 100644 index 0000000..1d13dec --- /dev/null +++ b/CommonLibs/BitVector.cpp @@ -0,0 +1,603 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "BitVector.h" +#include +#include + +using namespace std; + + +/** + Apply a Galois polymonial to a binary seqeunce. + @param val The input sequence. + @param poly The polynomial. + @param order The order of the polynomial. + @return Single-bit result. +*/ +unsigned applyPoly(uint64_t val, uint64_t poly, unsigned order) +{ + uint64_t prod = val & poly; + unsigned sum = prod; + for (unsigned i=1; i>i; + return sum & 0x01; +} + + + + + + +BitVector::BitVector(const char *valString) + :Vector(strlen(valString)) +{ + uint32_t accum = 0; + for (size_t i=0; i=0; i--) { + accum = (accum<<1) | ((*dp--) & 0x01); + } + return accum; +} + + + + +uint64_t BitVector::readField(size_t& readIndex, unsigned length) const +{ + const uint64_t retVal = peekField(readIndex,length); + readIndex += length; + return retVal; +} + + +uint64_t BitVector::readFieldReversed(size_t& readIndex, unsigned length) const +{ + const uint64_t retVal = peekFieldReversed(readIndex,length); + readIndex += length; + return retVal; +} + + + + + +void BitVector::fillField(size_t writeIndex, uint64_t value, unsigned length) +{ + char *dpBase = mStart + writeIndex; + char *dp = dpBase + length - 1; + assert(dp < mEnd); + while (dp>=dpBase) { + *dp-- = value & 0x01; + value >>= 1; + } +} + + +void BitVector::fillFieldReversed(size_t writeIndex, uint64_t value, unsigned length) +{ + char *dp = mStart + writeIndex; + char *dpEnd = dp + length - 1; + assert(dpEnd < mEnd); + while (dp<=dpEnd) { + *dp++ = value & 0x01; + value >>= 1; + } +} + + + + +void BitVector::writeField(size_t& writeIndex, uint64_t value, unsigned length) +{ + fillField(writeIndex,value,length); + writeIndex += length; +} + + +void BitVector::writeFieldReversed(size_t& writeIndex, uint64_t value, unsigned length) +{ + fillFieldReversed(writeIndex,value,length); + writeIndex += length; +} + + +void BitVector::invert() +{ + for (size_t i=0; i=8); + + char tmp0 = mStart[0]; + mStart[0] = mStart[7]; + mStart[7] = tmp0; + + char tmp1 = mStart[1]; + mStart[1] = mStart[6]; + mStart[6] = tmp1; + + char tmp2 = mStart[2]; + mStart[2] = mStart[5]; + mStart[5] = tmp2; + + char tmp3 = mStart[3]; + mStart[3] = mStart[4]; + mStart[4] = tmp3; +} + + + +void BitVector::LSB8MSB() +{ + if (size()<8) return; + size_t size8 = 8*(size()/8); + size_t iTop = size8 - 8; + for (size_t i=0; i<=iTop; i+=8) segment(i,8).reverse8(); +} + + + +uint64_t BitVector::syndrome(Generator& gen) const +{ + gen.clear(); + const char *dp = mStart; + while (dpiState) << 1; // input state for 0 + const uint32_t iState1 = iState0 | 0x01; // input state for 1 + const uint32_t oStateShifted = (sp->oState) << mIRate; // shifted output + const float cost = sp->cost; + sp++; + // 0 input extension + mCandidates[i].cost = cost; + mCandidates[i].oState = oStateShifted | mGeneratorTable[iState0 & mCMask]; + mCandidates[i].iState = iState0; + // 1 input extension + mCandidates[i+1].cost = cost; + mCandidates[i+1].oState = oStateShifted | mGeneratorTable[iState1 & mCMask]; + mCandidates[i+1].iState = iState1; + } +} + + +void ViterbiR2O4::getSoftCostMetrics(const uint32_t inSample, const float *matchCost, const float *mismatchCost) +{ + const float *cTab[2] = {matchCost,mismatchCost}; + for (unsigned i=0; i>1)&0x01][0]; + } +} + + +void ViterbiR2O4::pruneCandidates() +{ + const vCand* c1 = mCandidates; // 0-prefix + const vCand* c2 = mCandidates + mIStates; // 1-prefix + for (unsigned i=0; i=minCost) continue; + minCost = thisCost; + minIndex=i; + } + return mSurvivors[minIndex]; +} + + +const ViterbiR2O4::vCand& ViterbiR2O4::step(uint32_t inSample, const float *probs, const float *iprobs) +{ + branchCandidates(); + getSoftCostMetrics(inSample,probs,iprobs); + pruneCandidates(); + return minCost(); +} + + +uint64_t Parity::syndrome(const BitVector& receivedCodeword) +{ + return receivedCodeword.syndrome(*this); +} + + +void Parity::writeParityWord(const BitVector& data, BitVector& parityTarget, bool invert) +{ + uint64_t pWord = data.parity(*this); + if (invert) pWord = ~pWord; + parityTarget.fillField(0,pWord,size()); +} + + + + + + + + + +SoftVector::SoftVector(const BitVector& source) +{ + resize(source.size()); + for (size_t i=0; i0.5F) newSig[i]=1; + else newSig[i] = 0; + } + return newSig; +} + + + +void SoftVector::decode(ViterbiR2O4 &decoder, BitVector& target) const +{ + const size_t sz = size(); + const unsigned deferral = decoder.deferral(); + const size_t ctsz = sz + deferral*decoder.iRate(); + assert(sz <= decoder.iRate()*target.size()); + + // Build a "history" array where each element contains the full history. + uint32_t history[ctsz]; + { + BitVector bits = sliced(); + uint32_t accum = 0; + for (size_t i=0; i0.5F) pVal = 1.0F-pVal; + float ipVal = 1.0F-pVal; + // This is a cheap approximation to an ideal cost function. + if (pVal<0.01F) pVal = 0.01; + if (ipVal<0.01F) ipVal = 0.01; + matchCostTable[i] = 0.25F/ipVal; + mismatchCostTable[i] = 0.25F/pVal; + } + + // pad end of table with unknowns + for (size_t i=sz; i=deferral) *op++ = (minCost.iState >> deferral)&0x01; + oCount++; + } + } +} + + + + +ostream& operator<<(ostream& os, const SoftVector& sv) +{ + for (size_t i=0; i0.75) os << "1"; + else os << "-"; + } + return os; +} + + + +void BitVector::pack(unsigned char* targ) const +{ + // Assumes MSB-first packing. + unsigned bytes = size()/8; + for (unsigned i=0; i0) { + if (sscanf(src+digits, "%1x", &val) < 1) { + return false; + } + fillField(whole,val,rem); + } + return true; +} + +// vim: ts=4 sw=4 diff --git a/CommonLibs/BitVector.h b/CommonLibs/BitVector.h new file mode 100644 index 0000000..572e6b4 --- /dev/null +++ b/CommonLibs/BitVector.h @@ -0,0 +1,441 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef FECVECTORS_H +#define FECVECTORS_H + +#include "Vector.h" +#include + + +class BitVector; +class SoftVector; + + + +/** Shift-register (LFSR) generator. */ +class Generator { + + private: + + uint64_t mCoeff; ///< polynomial coefficients. LSB is zero exponent. + uint64_t mState; ///< shift register state. LSB is most recent. + uint64_t mMask; ///< mask for reading state + unsigned mLen; ///< number of bits used in shift register + unsigned mLen_1; ///< mLen - 1 + + public: + + Generator(uint64_t wCoeff, unsigned wLen) + :mCoeff(wCoeff),mState(0), + mMask((1ULL<>(mLen_1)) & 0x01; + mState = (mState<<1) ^ (inBit & 0x01); + if (fb) mState ^= mCoeff; + } + + /** + Update the generator state by one cycle. + This is in the .h for inlining. + */ + void encoderShift(unsigned inBit) + { + const unsigned fb = ((mState>>(mLen_1)) ^ inBit) & 0x01; + mState <<= 1; + if (fb) mState ^= mCoeff; + } + + +}; + + + + +/** Parity (CRC-type) generator and checker based on a Generator. */ +class Parity : public Generator { + + protected: + + unsigned mCodewordSize; + + public: + + Parity(uint64_t wCoefficients, unsigned wParitySize, unsigned wCodewordSize) + :Generator(wCoefficients, wParitySize), + mCodewordSize(wCodewordSize) + { } + + /** Compute the parity word and write it into the target segment. */ + void writeParityWord(const BitVector& data, BitVector& parityWordTarget, bool invert=true); + + /** Compute the syndrome of a received sequence. */ + uint64_t syndrome(const BitVector& receivedCodeword); +}; + + + + +/** + Class to represent convolutional coders/decoders of rate 1/2, memory length 4. + This is the "workhorse" coder for most GSM channels. +*/ +class ViterbiR2O4 { + + private: + /**name Lots of precomputed elements so the compiler can optimize like hell. */ + //@{ + /**@name Core values. */ + //@{ + static const unsigned mIRate = 2; ///< reciprocal of rate + static const unsigned mOrder = 4; ///< memory length of generators + //@} + /**@name Derived values. */ + //@{ + static const unsigned mIStates = 0x01 << mOrder; ///< number of states, number of survivors + static const uint32_t mSMask = mIStates-1; ///< survivor mask + static const uint32_t mCMask = (mSMask<<1) | 0x01; ///< candidate mask + static const uint32_t mOMask = (0x01< { + + + public: + + /**@name Constructors. */ + //@{ + + /**@name Casts of Vector constructors. */ + //@{ + BitVector(char* wData, char* wStart, char* wEnd) + :Vector(wData,wStart,wEnd) + { } + BitVector(size_t len=0):Vector(len) {} + BitVector(const Vector& source):Vector(source) {} + BitVector(Vector& source):Vector(source) {} + BitVector(const Vector& source1, const Vector source2):Vector(source1,source2) {} + //@} + + /** Construct from a string of "0" and "1". */ + BitVector(const char* valString); + //@} + + /** Index a single bit. */ + bool bit(size_t index) const + { + // We put this code in .h for fast inlining. + const char *dp = mStart+index; + assert(dp::segment(start,span)); } + + BitVector head(size_t span) { return segment(0,span); } + const BitVector head(size_t span) const { return segment(0,span); } + BitVector tail(size_t start) { return segment(start,size()-start); } + const BitVector tail(size_t start) const { return segment(start,size()-start); } + //@} + + + void zero() { fill(0); } + + /**@name FEC operations. */ + //@{ + /** Calculate the syndrome of the vector with the given Generator. */ + uint64_t syndrome(Generator& gen) const; + /** Calculate the parity word for the vector with the given Generator. */ + uint64_t parity(Generator& gen) const; + /** Encode the signal with the GSM rate 1/2 convolutional encoder. */ + void encode(const ViterbiR2O4& encoder, BitVector& target); + //@} + + + /** Invert 0<->1. */ + void invert(); + + /**@name Byte-wise operations. */ + //@{ + /** Reverse an 8-bit vector. */ + void reverse8(); + /** Reverse groups of 8 within the vector (byte reversal). */ + void LSB8MSB(); + //@} + + /**@name Serialization and deserialization. */ + //@{ + uint64_t peekField(size_t readIndex, unsigned length) const; + uint64_t peekFieldReversed(size_t readIndex, unsigned length) const; + uint64_t readField(size_t& readIndex, unsigned length) const; + uint64_t readFieldReversed(size_t& readIndex, unsigned length) const; + void fillField(size_t writeIndex, uint64_t value, unsigned length); + void fillFieldReversed(size_t writeIndex, uint64_t value, unsigned length); + void writeField(size_t& writeIndex, uint64_t value, unsigned length); + void writeFieldReversed(size_t& writeIndex, uint64_t value, unsigned length); + //@} + + /** Sum of bits. */ + unsigned sum() const; + + /** Reorder bits, dest[i] = this[map[i]]. */ + void map(const unsigned *map, size_t mapSize, BitVector& dest) const; + + /** Reorder bits, dest[map[i]] = this[i]. */ + void unmap(const unsigned *map, size_t mapSize, BitVector& dest) const; + + /** Pack into a char array. */ + void pack(unsigned char*) const; + + /** Unpack from a char array. */ + void unpack(const unsigned char*); + + /** Make a hexdump string. */ + void hex(std::ostream&) const; + + /** Unpack from a hexdump string. + * @returns true on success, false on error. */ + bool unhex(const char*); + +}; + + + +std::ostream& operator<<(std::ostream&, const BitVector&); + + + + + + +/** + The SoftVector class is used to represent a soft-decision signal. + Values 0..1 represent probabilities that a bit is "true". + */ +class SoftVector: public Vector { + + public: + + /** Build a SoftVector of a given length. */ + SoftVector(size_t wSize=0):Vector(wSize) {} + + /** Construct a SoftVector from a C string of "0", "1", and "X". */ + SoftVector(const char* valString); + + /** Construct a SoftVector from a BitVector. */ + SoftVector(const BitVector& source); + + /** + Wrap a SoftVector around a block of floats. + The block will be delete[]ed upon desctuction. + */ + SoftVector(float *wData, unsigned length) + :Vector(wData,length) + {} + + SoftVector(float* wData, float* wStart, float* wEnd) + :Vector(wData,wStart,wEnd) + { } + + /** + Casting from a Vector. + Note that this is NOT pass-by-reference. + */ + SoftVector(Vector source) + :Vector(source) + {} + + + /**@name Casts and overrides of Vector operators. */ + //@{ + SoftVector segment(size_t start, size_t span) + { + float* wStart = mStart + start; + float* wEnd = wStart + span; + assert(wEnd<=mEnd); + return SoftVector(NULL,wStart,wEnd); + } + + SoftVector alias() + { return segment(0,size()); } + + const SoftVector segment(size_t start, size_t span) const + { return (SoftVector)(Vector::segment(start,span)); } + + SoftVector head(size_t span) { return segment(0,span); } + const SoftVector head(size_t span) const { return segment(0,span); } + SoftVector tail(size_t start) { return segment(start,size()-start); } + const SoftVector tail(size_t start) const { return segment(start,size()-start); } + //@} + + /** Decode soft symbols with the GSM rate-1/2 Viterbi decoder. */ + void decode(ViterbiR2O4 &decoder, BitVector& target) const; + + /** Fill with "unknown" values. */ + void unknown() { fill(0.5F); } + + /** Return a hard bit value from a given index by slicing. */ + bool bit(size_t index) const + { + const float *dp = mStart+index; + assert(dp0.5F; + } + + /** Slice the whole signal into bits. */ + BitVector sliced() const; + +}; + + + +std::ostream& operator<<(std::ostream&, const SoftVector&); + + + + + + +#endif +// vim: ts=4 sw=4 diff --git a/CommonLibs/BitVectorTest.cpp b/CommonLibs/BitVectorTest.cpp new file mode 100644 index 0000000..5e487ad --- /dev/null +++ b/CommonLibs/BitVectorTest.cpp @@ -0,0 +1,88 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "BitVector.h" +#include +#include + +using namespace std; + + +int main(int argc, char *argv[]) +{ + BitVector v1("0000111100111100101011110000"); + cout << v1 << endl; + v1.LSB8MSB(); + cout << v1 << endl; + ViterbiR2O4 vCoder; + BitVector v2(v1.size()*2); + v1.encode(vCoder,v2); + cout << v2 << endl; + SoftVector sv2(v2); + cout << sv2 << endl; + for (unsigned i=0; i +#include +#include +#include + +using namespace std; + + +static const char* createConfigTable = { + "CREATE TABLE IF NOT EXISTS CONFIG (" + "KEYSTRING TEXT UNIQUE NOT NULL, " + "VALUESTRING TEXT, " + "STATIC INTEGER DEFAULT 0, " + "OPTIONAL INTEGER DEFAULT 0, " + "COMMENTS TEXT DEFAULT ''" + ")" +}; + + +ConfigurationTable::ConfigurationTable(const char* filename) +{ + // Connect to the database. + int rc = sqlite3_open(filename,&mDB); + if (rc) { + cerr << "Cannot open configuration database: " << sqlite3_errmsg(mDB); + sqlite3_close(mDB); + mDB = NULL; + return; + } + // Create the table, if needed. + if (!sqlite3_command(mDB,createConfigTable)) { + cerr << "Cannot create configuration table:" << sqlite3_errmsg(mDB); + } +} + + + +bool ConfigurationTable::defines(const string& key) +{ + assert(mDB); + ScopedLock lock(mLock); + + // Check the cache. + checkCacheAge(); + ConfigurationMap::const_iterator where = mCache.find(key); + if (where!=mCache.end()) return where->second.defined(); + + // Check the database. + char *value = NULL; + sqlite3_single_lookup(mDB,"CONFIG","KEYSTRING",key.c_str(),"VALUESTRING",value); + + // Cache the result. + if (value) { + mCache[key] = ConfigurationRecord(value); + free(value); + return true; + } + + mCache[key] = ConfigurationRecord(false); + return false; +} + + +const ConfigurationRecord& ConfigurationTable::lookup(const string& key) +{ + assert(mDB); + checkCacheAge(); + // We assume the caller holds mLock. + // So it is OK to return a reference into the cache. + + // Check the cache. + // This is cheap. + ConfigurationMap::const_iterator where = mCache.find(key); + if (where!=mCache.end()) { + if (where->second.defined()) return where->second; + // Unlock the mutex before throwing the exception. + mLock.unlock(); + syslog(LOG_ALERT, "configuration key %s not found", key.c_str()); + throw ConfigurationTableKeyNotFound(key); + } + + // Check the database. + // This is more expensive. + char *value = NULL; + sqlite3_single_lookup(mDB,"CONFIG", + "KEYSTRING",key.c_str(),"VALUESTRING",value); + + // Nothing defined? + if (!value) { + // Cache the failure. + mCache[key] = ConfigurationRecord(false); + // Unlock the mutex before throwing the exception. + mLock.unlock(); + throw ConfigurationTableKeyNotFound(key); + } + + // Cache the result. + mCache[key] = ConfigurationRecord(value); + free(value); + + // Leave mLock locked. The caller holds it still. + return mCache[key]; +} + + + +bool ConfigurationTable::isStatic(const string& key) const +{ + assert(mDB); + unsigned stat; + bool success = sqlite3_single_lookup(mDB,"CONFIG","KEYSTRING",key.c_str(),"STATIC",stat); + if (success) return (bool)stat; + return false; +} + +bool ConfigurationTable::isRequired(const string& key) const +{ + assert(mDB); + unsigned optional; + bool success = sqlite3_single_lookup(mDB,"CONFIG","KEYSTRING",key.c_str(),"OPTIONAL",optional); + if (success) return !((bool)optional); + return false; +} + + + + +string ConfigurationTable::getStr(const string& key) +{ + // We need the lock because rec is a reference into the cache. + ScopedLock lock(mLock); + return lookup(key).value(); +} + +string ConfigurationTable::getStr(const string& key, const char* defaultValue) +{ + try { + return getStr(key); + } catch (ConfigurationTableKeyNotFound) { + set(key,defaultValue); + return string(defaultValue); + } +} + + +long ConfigurationTable::getNum(const string& key) +{ + // We need the lock because rec is a reference into the cache. + ScopedLock lock(mLock); + return lookup(key).number(); +} + + +long ConfigurationTable::getNum(const string& key, long defaultValue) +{ + try { + return getNum(key); + } catch (ConfigurationTableKeyNotFound) { + set(key,defaultValue); + return defaultValue; + } +} + + + +std::vector ConfigurationTable::getVector(const string& key) +{ + // Look up the string. + mLock.lock(); + const ConfigurationRecord& rec = lookup(key); + char* line = strdup(rec.value().c_str()); + mLock.unlock(); + // Parse the string. + std::vector retVal; + char *lp=line; + while (lp) { + // Watch for multiple or trailing spaces. + while (*lp==' ') lp++; + if (*lp=='\0') break; + retVal.push_back(strtol(lp,NULL,0)); + strsep(&lp," "); + } + free(line); + return retVal; +} + + +bool ConfigurationTable::unset(const string& key) +{ + assert(mDB); + if (!defines(key)) return true; + if (isRequired(key)) return false; + + ScopedLock lock(mLock); + // Clear the cache entry and the database. + ConfigurationMap::iterator where = mCache.find(key); + if (where!=mCache.end()) mCache.erase(where); + // Don't delete it; just set VALUESTRING to NULL. + string cmd = "UPDATE CONFIG SET VALUESTRING=NULL WHERE KEYSTRING=='"+key+"'"; + return sqlite3_command(mDB,cmd.c_str()); +} + + +void ConfigurationTable::find(const string& pat, ostream& os) const +{ + // Prepare the statement. + string cmd = "SELECT KEYSTRING,VALUESTRING FROM CONFIG WHERE KEYSTRING LIKE \"%" + pat + "%\""; + sqlite3_stmt *stmt; + if (sqlite3_prepare_statement(mDB,&stmt,cmd.c_str())) return; + // Read the result. + int src = sqlite3_run_query(mDB,stmt); + while (src==SQLITE_ROW) { + const char* value = (const char*)sqlite3_column_text(stmt,1); + os << sqlite3_column_text(stmt,0) << " "; + if (value) os << value << endl; + else os << "(null)" << endl; + src = sqlite3_run_query(mDB,stmt); + } + sqlite3_finalize(stmt); +} + + +bool ConfigurationTable::set(const string& key, const string& value) +{ + assert(mDB); + ScopedLock lock(mLock); + // Is it there already? + char * oldValue = NULL; + bool exists = sqlite3_single_lookup(mDB,"CONFIG","KEYSTRING",key.c_str(),"VALUESTRING",oldValue); + // Update or insert as appropriate. + string cmd; + if (exists) cmd = "UPDATE CONFIG SET VALUESTRING=\""+value+"\" WHERE KEYSTRING==\""+key+"\""; + else cmd = "INSERT INTO CONFIG (KEYSTRING,VALUESTRING,OPTIONAL) VALUES (\"" + key + "\",\"" + value + "\",1)"; + bool success = sqlite3_command(mDB,cmd.c_str()); + // Cache the result. + if (success) mCache[key] = ConfigurationRecord(value); + return success; +} + +bool ConfigurationTable::set(const string& key, long value) +{ + char buffer[30]; + sprintf(buffer,"%ld",value); + return set(key,buffer); +} + + +bool ConfigurationTable::set(const string& key) +{ + assert(mDB); + ScopedLock lock(mLock); + string cmd = "INSERT INTO CONFIG (KEYSTRING) VALUES (\"" + key + "\")"; + bool success = sqlite3_command(mDB,cmd.c_str()); + if (success) mCache[key] = ConfigurationRecord(true); + return success; +} + + +void ConfigurationTable::checkCacheAge() +{ + // mLock is set by caller + static time_t timeOfLastPurge = 0; + time_t now = time(NULL); + // purge every 3 seconds + // purge period cannot be configuration parameter + if (now - timeOfLastPurge < 3) return; + timeOfLastPurge = now; + // this is purge() without the lock + ConfigurationMap::iterator mp = mCache.begin(); + while (mp != mCache.end()) { + ConfigurationMap::iterator prev = mp; + mp++; + mCache.erase(prev); + } +} + + +void ConfigurationTable::purge() +{ + ScopedLock lock(mLock); + ConfigurationMap::iterator mp = mCache.begin(); + while (mp != mCache.end()) { + ConfigurationMap::iterator prev = mp; + mp++; + mCache.erase(prev); + } +} + + +void ConfigurationTable::setUpdateHook(void(*func)(void *,int ,char const *,char const *,sqlite3_int64)) +{ + assert(mDB); + sqlite3_update_hook(mDB,func,NULL); +} + + + +void HashString::computeHash() +{ + // FIXME -- Someone needs to review this hash function. + const char* cstr = c_str(); + mHash = 0; + for (unsigned i=0; i> 32); + mHash = mHash*127 + cstr[i]; + } +} + + + +// vim: ts=4 sw=4 diff --git a/CommonLibs/Configuration.h b/CommonLibs/Configuration.h new file mode 100644 index 0000000..c9c4cf3 --- /dev/null +++ b/CommonLibs/Configuration.h @@ -0,0 +1,275 @@ +/* +* Copyright 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef CONFIGURATION_H +#define CONFIGURATION_H + + +#include "sqlite3util.h" + +#include +#include + +#include +#include +#include +#include + +#include +#include + + +/** A class for configuration file errors. */ +class ConfigurationTableError {}; + +/** An exception thrown when a given config key isn't found. */ +class ConfigurationTableKeyNotFound : public ConfigurationTableError { + + private: + + std::string mKey; + + public: + + ConfigurationTableKeyNotFound(const std::string& wKey) + :mKey(wKey) + { std::cerr << "cannot find configuration value " << mKey << std::endl; } + + const std::string& key() const { return mKey; } + +}; + + +class ConfigurationRecord { + + private: + + std::string mValue; + long mNumber; + bool mDefined; + + public: + + ConfigurationRecord(bool wDefined=true): + mDefined(wDefined) + { } + + ConfigurationRecord(const std::string& wValue): + mValue(wValue), + mNumber(strtol(wValue.c_str(),NULL,0)), + mDefined(true) + { } + + ConfigurationRecord(const char* wValue): + mValue(std::string(wValue)), + mNumber(strtol(wValue,NULL,0)), + mDefined(true) + { } + + + const std::string& value() const { return mValue; } + long number() const { return mNumber; } + bool defined() const { return mDefined; } + +}; + + +/** A string class that uses a hash function for comparison. */ +class HashString : public std::string { + + + protected: + + uint64_t mHash; + + void computeHash(); + + + public: + + HashString(const char* src) + :std::string(src) + { + computeHash(); + } + + HashString(const std::string& src) + :std::string(src) + { + computeHash(); + } + + HashString() + { + mHash=0; + } + + HashString& operator=(std::string& src) + { + std::string::operator=(src); + computeHash(); + return *this; + } + + HashString& operator=(const char* src) + { + std::string::operator=(src); + computeHash(); + return *this; + } + + bool operator==(const HashString& other) + { + return mHash==other.mHash; + } + + bool operator<(const HashString& other) + { + return mHash(const HashString& other) + { + return mHash ConfigurationMap; + + +/** + A class for maintaining a configuration key-value table, + based on sqlite3 and a local map-based cache. + Thread-safe, too. +*/ +class ConfigurationTable { + + private: + + sqlite3* mDB; ///< database connection + ConfigurationMap mCache; ///< cache of recently access configuration values + mutable Mutex mLock; ///< control for multithreaded access to the cache + + public: + + + ConfigurationTable(const char* filename = ":memory:"); + + /** Return true if the key is used in the table. */ + bool defines(const std::string& key); + + /** Return true if this key is identified as static. */ + bool isStatic(const std::string& key) const; + + /** Return true if this key is identified as required (!optional). */ + bool isRequired(const std::string& key) const; + + /** + Get a string parameter from the table. + Throw ConfigurationTableKeyNotFound if not found. + */ + std::string getStr(const std::string& key); + + + /** + Get a string parameter from the table. + Define the parameter to the default value if not found. + */ + std::string getStr(const std::string& key, const char* defaultValue); + + + /** + Get a numeric parameter from the table. + Throw ConfigurationTableKeyNotFound if not found. + */ + long getNum(const std::string& key); + + /** + Get a numeric parameter from the table. + Define the parameter to the default value if not found. + */ + long getNum(const std::string& key, long defaultValue); + + /** + Get a numeric vector from the table. + */ + std::vector getVector(const std::string& key); + + /** Get length of a vector */ + unsigned getVectorLength(const std::string &key) + { return getVector(key).size(); } + + /** Set or change a value in the table. */ + bool set(const std::string& key, const std::string& value); + + /** Set or change a value in the table. */ + bool set(const std::string& key, long value); + + /** Create an entry in the table, no value though. */ + bool set(const std::string& key); + + /** + Remove a key from the table. + Will not remove static or required values. + @param key The key of the item to be deleted. + @return true if anything was actually removed. + */ + bool unset(const std::string& key); + + /** Search the table, dumping to a stream. */ + void find(const std::string& pattern, std::ostream&) const; + + /** Define the callback to purge the cache whenever the database changes. */ + void setUpdateHook(void(*)(void *,int ,char const *,char const *,sqlite3_int64)); + + /** purege cache if it exceeds a certain age */ + void checkCacheAge(); + + /** Delete all records from the cache. */ + void purge(); + + + private: + + /** + Attempt to lookup a record, cache if needed. + Throw ConfigurationTableKeyNotFound if not found. + Caller should hold mLock because the returned reference points into the cache. + */ + const ConfigurationRecord& lookup(const std::string& key); + +}; + + + +#endif + + +// vim: ts=4 sw=4 diff --git a/CommonLibs/ConfigurationTest.cpp b/CommonLibs/ConfigurationTest.cpp new file mode 100644 index 0000000..ef82601 --- /dev/null +++ b/CommonLibs/ConfigurationTest.cpp @@ -0,0 +1,69 @@ +/* +* Copyright 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "Configuration.h" +#include + +using namespace std; + +ConfigurationTable gConfig("exampleconfig.db"); + +void purgeConfig(void*,int,char const*, char const*, sqlite3_int64) +{ + //cout << "update hook" << endl; + gConfig.purge(); +} + + +int main(int argc, char *argv[]) +{ + + gConfig.setUpdateHook(purgeConfig); + + char *keys[5] = {"key1", "key2", "key3", "key4", "key5"}; + + for (int i=0; i<5; i++) { + gConfig.set(keys[i],i); + } + + for (int i=0; i<5; i++) { + cout << "table[" << keys[i] << "]=" << gConfig.getStr(keys[i]) << endl; + cout << "table[" << keys[i] << "]=" << gConfig.getNum(keys[i]) << endl; + } + + gConfig.unset("key1"); + for (int i=0; i<5; i++) { + cout << "defined table[" << keys[i] << "]=" << gConfig.defines(keys[i]) << endl; + } + + gConfig.set("key5","100 200 300 400"); + std::vector vect = gConfig.getVector("key5"); + cout << "vect length " << vect.size() << ": "; + for (unsigned i=0; i. + +*/ + + +#ifndef F16_H +#define F16_H + +#include +#include + + + +/** Round a float to the appropriate F16 value. */ +inline int32_t _f16_round(float f) +{ + if (f>0.0F) return (int32_t)(f+0.5F); + if (f<0.0F) return (int32_t)(f-0.5F); + return 0; +} + + + +/** A class for F15.16 fixed point arithmetic with saturation. */ +class F16 { + + + private: + + int32_t mV; + + + public: + + F16() {} + + F16(int i) { mV = i<<16; } + F16(float f) { mV = _f16_round(f*65536.0F); } + F16(double f) { mV = _f16_round((float)f*65536.0F); } + + int32_t& raw() { return mV; } + const int32_t& raw() const { return mV; } + + float f() const { return mV/65536.0F; } + + //operator float() const { return mV/65536.0F; } + //operator int() const { return mV>>16; } + + F16 operator=(float f) + { + mV = _f16_round(f*65536.0F); + return *this; + } + + F16 operator=(int i) + { + mV = i<<16; + return *this; + } + + F16 operator=(const F16& other) + { + mV = other.mV; + return mV; + } + + F16 operator+(const F16& other) const + { + F16 retVal; + retVal.mV = mV + other.mV; + return retVal; + } + + F16& operator+=(const F16& other) + { + mV += other.mV; + return *this; + } + + F16 operator-(const F16& other) const + { + F16 retVal; + retVal.mV = mV - other.mV; + return retVal; + } + + F16& operator-=(const F16& other) + { + mV -= other.mV; + return *this; + } + + F16 operator*(const F16& other) const + { + F16 retVal; + int64_t p = (int64_t)mV * (int64_t)other.mV; + retVal.mV = p>>16; + return retVal; + } + + F16& operator*=(const F16& other) + { + int64_t p = (int64_t)mV * (int64_t)other.mV; + mV = p>>16; + return *this; + } + + F16 operator*(float f) const + { + F16 retVal; + retVal.mV = mV * f; + return retVal; + } + + F16& operator*=(float f) + { + mV *= f; + return *this; + } + + F16 operator/(const F16& other) const + { + F16 retVal; + int64_t pV = (int64_t)mV << 16; + retVal.mV = pV / other.mV; + return retVal; + } + + F16& operator/=(const F16& other) + { + int64_t pV = (int64_t)mV << 16; + mV = pV / other.mV; + return *this; + } + + F16 operator/(float f) const + { + F16 retVal; + retVal.mV = mV / f; + return retVal; + } + + F16& operator/=(float f) + { + mV /= f; + return *this; + } + + bool operator>(const F16& other) const + { + return mV>other.mV; + } + + bool operator<(const F16& other) const + { + return mV(float f) const + { + return (mV/65536.0F) > f; + } + + bool operator<(float f) const + { + return (mV/65536.0F) < f; + } + + bool operator==(float f) const + { + return (mV/65536.0F) == f; + } + +}; + + + +inline std::ostream& operator<<(std::ostream& os, const F16& v) +{ + os << v.f(); + return os; +} + +#endif + diff --git a/CommonLibs/F16Test.cpp b/CommonLibs/F16Test.cpp new file mode 100644 index 0000000..7f3c84d --- /dev/null +++ b/CommonLibs/F16Test.cpp @@ -0,0 +1,55 @@ +/* +* Copyright 2009 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "F16.h" + + +#include + +using namespace std; + +int main(int argc, char **argv) +{ + + F16 a = 2.5; + F16 b = 1.5; + F16 c = 2.5 * 1.5; + F16 d = c + a; + F16 e = 10; + cout << a << ' ' << b << ' ' << c << ' ' << d << ' ' << e << endl; + + a *= 3; + b *= 0.3; + c *= e; + cout << a << ' ' << b << ' ' << c << ' ' << d << endl; + + a /= 3; + b /= 0.3; + c = d * 0.05; + cout << a << ' ' << b << ' ' << c << ' ' << d << endl; + + F16 f = a/d; + cout << f << ' ' << f+0.5 << endl; +} diff --git a/CommonLibs/Interthread.h b/CommonLibs/Interthread.h new file mode 100644 index 0000000..023ac14 --- /dev/null +++ b/CommonLibs/Interthread.h @@ -0,0 +1,546 @@ +/* +* Copyright 2008, 2011 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef INTERTHREAD_H +#define INTERTHREAD_H + +#include "Timeval.h" +#include "Threads.h" +#include "LinkedLists.h" +#include +#include +#include + + + + + +/**@defgroup Templates for interthread mechanisms. */ +//@{ + + +/** Pointer FIFO for interthread operations. */ +template class InterthreadQueue { + + protected: + + PointerFIFO mQ; + mutable Mutex mLock; + mutable Signal mWriteSignal; + + + public: + + /** Delete contents. */ + void clear() + { + ScopedLock lock(mLock); + while (mQ.size()>0) delete (T*)mQ.get(); + } + + /** Empty the queue, but don't delete. */ + void flushNoDelete() + { + ScopedLock lock(mLock); + while (mQ.size()>0) mQ.get(); + } + + + ~InterthreadQueue() + { clear(); } + + + size_t size() const + { + ScopedLock lock(mLock); + return mQ.size(); + } + + /** + Blocking read. + @return Pointer to object (will not be NULL). + */ + T* read() + { + ScopedLock lock(mLock); + T* retVal = (T*)mQ.get(); + while (retVal==NULL) { + mWriteSignal.wait(mLock); + retVal = (T*)mQ.get(); + } + return retVal; + } + + /** + Blocking read with a timeout. + @param timeout The read timeout in ms. + @return Pointer to object or NULL on timeout. + */ + T* read(unsigned timeout) + { + if (timeout==0) return readNoBlock(); + Timeval waitTime(timeout); + ScopedLock lock(mLock); + while ((mQ.size()==0) && (!waitTime.passed())) + mWriteSignal.wait(mLock,waitTime.remaining()); + T* retVal = (T*)mQ.get(); + return retVal; + } + + /** + Non-blocking read. + @return Pointer to object or NULL if FIFO is empty. + */ + T* readNoBlock() + { + ScopedLock lock(mLock); + return (T*)mQ.get(); + } + + /** Non-blocking write. */ + void write(T* val) + { + ScopedLock lock(mLock); + mQ.put(val); + mWriteSignal.signal(); + } + + +}; + + + +/** Pointer FIFO for interthread operations. */ +template class InterthreadQueueWithWait { + + protected: + + PointerFIFO mQ; + mutable Mutex mLock; + mutable Signal mWriteSignal; + mutable Signal mReadSignal; + + virtual void freeElement(T* element) const { delete element; }; + + public: + + /** Delete contents. */ + void clear() + { + ScopedLock lock(mLock); + while (mQ.size()>0) freeElement((T*)mQ.get()); + mReadSignal.signal(); + } + + + + virtual ~InterthreadQueueWithWait() + { clear(); } + + + size_t size() const + { + ScopedLock lock(mLock); + return mQ.size(); + } + + /** + Blocking read. + @return Pointer to object (will not be NULL). + */ + T* read() + { + ScopedLock lock(mLock); + T* retVal = (T*)mQ.get(); + while (retVal==NULL) { + mWriteSignal.wait(mLock); + retVal = (T*)mQ.get(); + } + mReadSignal.signal(); + return retVal; + } + + /** + Blocking read with a timeout. + @param timeout The read timeout in ms. + @return Pointer to object or NULL on timeout. + */ + T* read(unsigned timeout) + { + if (timeout==0) return readNoBlock(); + Timeval waitTime(timeout); + ScopedLock lock(mLock); + while ((mQ.size()==0) && (!waitTime.passed())) + mWriteSignal.wait(mLock,waitTime.remaining()); + T* retVal = (T*)mQ.get(); + if (retVal!=NULL) mReadSignal.signal(); + return retVal; + } + + /** + Non-blocking read. + @return Pointer to object or NULL if FIFO is empty. + */ + T* readNoBlock() + { + ScopedLock lock(mLock); + T* retVal = (T*)mQ.get(); + if (retVal!=NULL) mReadSignal.signal(); + return retVal; + } + + /** Non-blocking write. */ + void write(T* val) + { + ScopedLock lock(mLock); + mQ.put(val); + mWriteSignal.signal(); + } + + /** Wait until the queue falls below a low water mark. */ + void wait(size_t sz=0) + { + ScopedLock lock(mLock); + while (mQ.size()>sz) mReadSignal.wait(mLock); + } + +}; + + + + + +/** Thread-safe map of pointers to class D, keyed by class K. */ +template class InterthreadMap { + +protected: + + typedef std::map Map; + Map mMap; + mutable Mutex mLock; + Signal mWriteSignal; + +public: + + void clear() + { + // Delete everything in the map. + ScopedLock lock(mLock); + typename Map::iterator iter = mMap.begin(); + while (iter != mMap.end()) { + delete iter->second; + ++iter; + } + mMap.clear(); + } + + ~InterthreadMap() { clear(); } + + /** + Non-blocking write. + @param key The index to write to. + @param wData Pointer to data, not to be deleted until removed from the map. + */ + void write(const K &key, D * wData) + { + ScopedLock lock(mLock); + typename Map::iterator iter = mMap.find(key); + if (iter!=mMap.end()) { + delete iter->second; + iter->second = wData; + } else { + mMap[key] = wData; + } + mWriteSignal.broadcast(); + } + + /** + Non-blocking read with element removal. + @param key Key to read from. + @return Pointer at key or NULL if key not found, to be deleted by caller. + */ + D* getNoBlock(const K& key) + { + ScopedLock lock(mLock); + typename Map::iterator iter = mMap.find(key); + if (iter==mMap.end()) return NULL; + D* retVal = iter->second; + mMap.erase(iter); + return retVal; + } + + /** + Blocking read with a timeout and element removal. + @param key The key to read from. + @param timeout The blocking timeout in ms. + @return Pointer at key or NULL on timeout, to be deleted by caller. + */ + D* get(const K &key, unsigned timeout) + { + if (timeout==0) return getNoBlock(key); + Timeval waitTime(timeout); + ScopedLock lock(mLock); + typename Map::iterator iter = mMap.find(key); + while ((iter==mMap.end()) && (!waitTime.passed())) { + mWriteSignal.wait(mLock,waitTime.remaining()); + iter = mMap.find(key); + } + if (iter==mMap.end()) return NULL; + D* retVal = iter->second; + mMap.erase(iter); + return retVal; + } + + /** + Blocking read with and element removal. + @param key The key to read from. + @return Pointer at key, to be deleted by caller. + */ + D* get(const K &key) + { + ScopedLock lock(mLock); + typename Map::iterator iter = mMap.find(key); + while (iter==mMap.end()) { + mWriteSignal.wait(mLock); + iter = mMap.find(key); + } + D* retVal = iter->second; + mMap.erase(iter); + return retVal; + } + + + /** + Remove an entry and delete it. + @param key The key of the entry to delete. + @return True if it was actually found and deleted. + */ + bool remove(const K &key ) + { + D* val = getNoBlock(key); + if (!val) return false; + delete val; + return true; + } + + + /** + Non-blocking read. + @param key Key to read from. + @return Pointer at key or NULL if key not found. + */ + D* readNoBlock(const K& key) const + { + D* retVal=NULL; + ScopedLock lock(mLock); + typename Map::const_iterator iter = mMap.find(key); + if (iter!=mMap.end()) retVal = iter->second; + return retVal; + } + + /** + Blocking read with a timeout. + @param key The key to read from. + @param timeout The blocking timeout in ms. + @return Pointer at key or NULL on timeout. + */ + D* read(const K &key, unsigned timeout) const + { + if (timeout==0) return readNoBlock(key); + ScopedLock lock(mLock); + Timeval waitTime(timeout); + typename Map::const_iterator iter = mMap.find(key); + while ((iter==mMap.end()) && (!waitTime.passed())) { + mWriteSignal.wait(mLock,waitTime.remaining()); + iter = mMap.find(key); + } + if (iter==mMap.end()) return NULL; + D* retVal = iter->second; + return retVal; + } + + /** + Blocking read. + @param key The key to read from. + @return Pointer at key. + */ + D* read(const K &key) const + { + ScopedLock lock(mLock); + typename Map::const_iterator iter = mMap.find(key); + while (iter==mMap.end()) { + mWriteSignal.wait(mLock); + iter = mMap.find(key); + } + D* retVal = iter->second; + return retVal; + } + +}; + + + + + + + +/** This class is used to provide pointer-based comparison in priority_queues. */ +template class PointerCompare { + + public: + + /** Compare the objects pointed to, not the pointers themselves. */ + bool operator()(const T *v1, const T *v2) + { return (*v1)>(*v2); } + +}; + + + +/** + Priority queue for interthread operations. + Passes pointers to objects. +*/ +template , class Cmp = PointerCompare > class InterthreadPriorityQueue { + + protected: + + std::priority_queue mQ; + mutable Mutex mLock; + mutable Signal mWriteSignal; + + public: + + + /** Clear the FIFO. */ + void clear() + { + ScopedLock lock(mLock); + while (mQ.size()>0) { + T* ptr = mQ.top(); + mQ.pop(); + delete ptr; + } + } + + + ~InterthreadPriorityQueue() + { + clear(); + } + + size_t size() const + { + ScopedLock lock(mLock); + return mQ.size(); + } + + + /** Non-blocking read. */ + T* readNoBlock() + { + ScopedLock lock(mLock); + T* retVal = NULL; + if (mQ.size()!=0) { + retVal = mQ.top(); + mQ.pop(); + } + return retVal; + } + + /** Blocking read. */ + T* read() + { + ScopedLock lock(mLock); + T* retVal; + while (mQ.size()==0) mWriteSignal.wait(mLock); + retVal = mQ.top(); + mQ.pop(); + return retVal; + } + + /** Non-blocking write. */ + void write(T* val) + { + ScopedLock lock(mLock); + mQ.push(val); + mWriteSignal.signal(); + } + +}; + + + + + +class Semaphore { + + private: + + bool mFlag; + Signal mSignal; + mutable Mutex mLock; + + public: + + Semaphore() + :mFlag(false) + { } + + void post() + { + ScopedLock lock(mLock); + mFlag=true; + mSignal.signal(); + } + + void get() + { + ScopedLock lock(mLock); + while (!mFlag) mSignal.wait(mLock); + mFlag=false; + } + + bool semtry() + { + ScopedLock lock(mLock); + bool retVal = mFlag; + mFlag = false; + return retVal; + } + +}; + + + + + +//@} + + + + +#endif +// vim: ts=4 sw=4 diff --git a/CommonLibs/InterthreadTest.cpp b/CommonLibs/InterthreadTest.cpp new file mode 100644 index 0000000..1712689 --- /dev/null +++ b/CommonLibs/InterthreadTest.cpp @@ -0,0 +1,114 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "Threads.h" +#include "Interthread.h" +#include + +using namespace std; + + +InterthreadQueue gQ; +InterthreadMap gMap; + +void* qWriter(void*) +{ + int *p; + for (int i=0; i<20; i++) { + p = new int; + *p = i; + COUT("queue write " << *p); + gQ.write(p); + if (random()%2) sleep(1); + } + p = new int; + *p = -1; + gQ.write(p); + return NULL; +} + +void* qReader(void*) +{ + bool done = false; + while (!done) { + int *p = gQ.read(); + COUT("queue read " << *p); + if (*p<0) done=true; + delete p; + } + return NULL; +} + + +void* mapWriter(void*) +{ + int *p; + for (int i=0; i<20; i++) { + p = new int; + *p = i; + COUT("map write " << *p); + gMap.write(i,p); + if (random()%2) sleep(1); + } + return NULL; +} + +void* mapReader(void*) +{ + for (int i=0; i<20; i++) { + int *p = gMap.read(i); + COUT("map read " << *p); + delete p; + } + return NULL; +} + + + + + + +int main(int argc, char *argv[]) +{ + Thread qReaderThread; + qReaderThread.start(qReader,NULL); + Thread mapReaderThread; + mapReaderThread.start(mapReader,NULL); + + Thread qWriterThread; + qWriterThread.start(qWriter,NULL); + Thread mapWriterThread; + mapWriterThread.start(mapWriter,NULL); + + qReaderThread.join(); + qWriterThread.join(); + mapReaderThread.join(); + mapWriterThread.join(); +} + + +// vim: ts=4 sw=4 diff --git a/CommonLibs/LinkedLists.cpp b/CommonLibs/LinkedLists.cpp new file mode 100644 index 0000000..ba0f0cc --- /dev/null +++ b/CommonLibs/LinkedLists.cpp @@ -0,0 +1,77 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "LinkedLists.h" + + + + +void PointerFIFO::put(void* val) +{ + ListNode *node = allocate(); + node->data(val); + node->next(NULL); + if (mTail!=NULL) mTail->next(node); + mTail=node; + if (mHead==NULL) mHead=node; + mSize++; +} + +/** Take an item from the FIFO. */ +void* PointerFIFO::get() +{ + // empty list? + if (mHead==NULL) return NULL; + // normal case + ListNode* next = mHead->next(); + void* retVal = mHead->data(); + release(mHead); + mHead = next; + if (next==NULL) mTail=NULL; + mSize--; + return retVal; +} + + + +ListNode *PointerFIFO::allocate() +{ + if (mFreeList==NULL) return new ListNode; + ListNode* retVal = mFreeList; + mFreeList = mFreeList->next(); + return retVal; +} + +void PointerFIFO::release(ListNode* wNode) +{ + wNode->next(mFreeList); + mFreeList = wNode; +} + + + diff --git a/CommonLibs/LinkedLists.h b/CommonLibs/LinkedLists.h new file mode 100644 index 0000000..4ca27e6 --- /dev/null +++ b/CommonLibs/LinkedLists.h @@ -0,0 +1,100 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#ifndef LINKEDLISTS_H +#define LINKEDLISTS_H + +#include + + + +/** This node class is used to build singly-linked lists. */ +class ListNode { + + private: + + ListNode* mNext; + void* mData; + + public: + + ListNode* next() { return mNext; } + void next(ListNode* wNext) { mNext=wNext; } + + void* data() { return mData; } + void data(void* wData) { mData=wData; } +}; + + + + +/** A fast FIFO for pointer-based storage. */ +class PointerFIFO { + + private: + + ListNode* mHead; ///< points to next item out + ListNode* mTail; ///< points to last item in + ListNode* mFreeList; ///< pool of previously-allocated nodes + unsigned mSize; ///< number of items in the FIFO + + public: + + PointerFIFO() + :mHead(NULL),mTail(NULL),mFreeList(NULL), + mSize(0) + {} + + unsigned size() const { return mSize; } + + /** Put an item into the FIFO. */ + void put(void* val); + + /** + Take an item from the FIFO. + Returns NULL for empty list. + */ + void* get(); + + + private: + + /** Allocate a new node to extend the FIFO. */ + ListNode *allocate(); + + /** Release a node to the free pool after removal from the FIFO. */ + void release(ListNode* wNode); + +}; + + + + + +#endif +// vim: ts=4 sw=4 diff --git a/CommonLibs/LogTest.cpp b/CommonLibs/LogTest.cpp new file mode 100644 index 0000000..e9f73b0 --- /dev/null +++ b/CommonLibs/LogTest.cpp @@ -0,0 +1,70 @@ +/* +* Copyright 2009 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include + +#include "Logger.h" +#include "Configuration.h" + +ConfigurationTable gConfig; +//ConfigurationTable gConfig("example.config"); + +void printAlarms() +{ + std::ostream_iterator output( std::cout, "\n" ); + std::list alarms = gGetLoggerAlarms(); + std::cout << "#alarms = " << alarms.size() << std::endl; + std::copy( alarms.begin(), alarms.end(), output ); +} + +int main(int argc, char *argv[]) +{ + gLogInit("LogTest","NOTICE",LOG_LOCAL7); + + LOG(EMERG) << " testing the logger."; + LOG(ALERT) << " testing the logger."; + LOG(CRIT) << " testing the logger."; + LOG(ERR) << " testing the logger."; + LOG(WARNING) << " testing the logger."; + LOG(NOTICE) << " testing the logger."; + LOG(INFO) << " testing the logger."; + LOG(DEBUG) << " testing the logger."; + std::cout << "\n\n\n"; + std::cout << "testing Alarms\n"; + LOG(ALERT) << " testing the logger alarm."; + std::cout << "you should see three lines:" << std::endl; + printAlarms(); + std::cout << "----------- generating 20 alarms ----------" << std::endl; + for (int i = 0 ; i < 20 ; ++i) { + LOG(ALERT) << i; + } + std::cout << "you should see ten lines with the numbers 10..19:" << std::endl; + printAlarms(); +} + + + diff --git a/CommonLibs/Logger.cpp b/CommonLibs/Logger.cpp new file mode 100644 index 0000000..57d2bff --- /dev/null +++ b/CommonLibs/Logger.cpp @@ -0,0 +1,197 @@ +/* +* Copyright 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include +#include +#include + +#include "Configuration.h" +#include "Logger.h" + + +using namespace std; + +// Reference to a global config table, used all over the system. +extern ConfigurationTable gConfig; + + +/**@ The global alarms table. */ +//@{ +Mutex alarmsLock; +list alarmsList; +void addAlarm(const string&); +//@} + + + + +/** Names of the logging levels. */ +const char *levelNames[] = { + "EMERG", "ALERT", "CRIT", "ERR", "WARNING", "NOTICE", "INFO", "DEBUG" +}; +int numLevels = 8; + + +/** Given a string, return the corresponding level name. */ +int lookupLevel(const string& name) +{ + // Reverse search, since the numerically larger levels are more common. + for (int i=numLevels-1; i>=0; i--) { + if (name == levelNames[i]) return i; + } + // This should never be called with a bogus name. + LOG(ERR) << "undefined logging level " << name << "defaulting to ERR"; + return LOG_ERR; +} + + +int getLoggingLevel(const char* filename) +{ + // Default level? + if (!filename) return lookupLevel(gConfig.getStr("Log.Level")); + + // This can afford to be inefficient since it is not called that often. + const string keyName = string("Log.Level.") + string(filename); + if (gConfig.defines(keyName)) return lookupLevel(gConfig.getStr(keyName)); + return lookupLevel(gConfig.getStr("Log.Level")); +} + + + +int gGetLoggingLevel(const char* filename) +{ + // This is called a lot and needs to be efficient. + + static Mutex sLogCacheLock; + static map sLogCache; + static unsigned sCacheCount; + static const unsigned sCacheRefreshCount = 1000; + + if (filename==NULL) return gGetLoggingLevel(""); + + HashString hs(filename); + uint64_t key = hs.hash(); + + sLogCacheLock.lock(); + // Time for a cache flush? + if (sCacheCount>sCacheRefreshCount) { + sLogCache.clear(); + sCacheCount=0; + } + // Is it cached already? + map::const_iterator where = sLogCache.find(key); + sCacheCount++; + if (where!=sLogCache.end()) { + int retVal = where->second; + sLogCacheLock.unlock(); + return retVal; + } + // Look it up in the config table and cache it. + // FIXME: Figure out why unlock and lock below fix the config table deadlock. + sLogCacheLock.unlock(); + int level = getLoggingLevel(filename); + sLogCacheLock.lock(); + sLogCache.insert(pair(key,level)); + sLogCacheLock.unlock(); + return level; +} + + + + + +// copies the alarm list and returns it. list supposed to be small. +list gGetLoggerAlarms() +{ + alarmsLock.lock(); + list ret; + // excuse the "complexity", but to use std::copy with a list you need + // an insert_iterator - copy technically overwrites, doesn't insert. + insert_iterator< list > ii(ret, ret.begin()); + copy(alarmsList.begin(), alarmsList.end(), ii); + alarmsLock.unlock(); + return ret; +} + +/** Add an alarm to the alarm list. */ +void addAlarm(const string& s) +{ + alarmsLock.lock(); + alarmsList.push_back(s); + unsigned maxAlarms = gConfig.getNum("Log.Alarms.Max"); + while (alarmsList.size() > maxAlarms) alarmsList.pop_front(); + alarmsLock.unlock(); +} + + +Log::~Log() +{ + // Anything at or above LOG_CRIT is an "alarm". + // Save alarms in the local list and echo them to stderr. + if (mPriority <= LOG_CRIT) { + addAlarm(mStream.str().c_str()); + cerr << mStream.str() << endl; + } + // Current logging level was already checked by the macro. + // So just log. + syslog(mPriority, "%s", mStream.str().c_str()); +} + + +ostringstream& Log::get() +{ + assert(mPriority. + +*/ + + +#ifndef LOGGER_H +#define LOGGER_H + +#include +#include +#include +#include +#include +#include +#include +#include "Threads.h" + + +#define _LOG(level) \ + Log(LOG_##level).get() << pthread_self() \ + << " " __FILE__ ":" << __LINE__ << ":" << __FUNCTION__ << ": " +#define LOG(wLevel) \ + if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) +#define OBJLOG(wLevel) \ + if (gGetLoggingLevel(__FILE__)>=LOG_##wLevel) _LOG(wLevel) << "obj: " << this << ' ' + +#define LOG_ASSERT(x) { if (!(x)) LOG(EMERG) << "assertion " #x " failed"; } assert(x); + + +#define DEFAULT_MAX_ALARMS 10 + + +/** + A C++ stream-based thread-safe logger. + Derived from Dr. Dobb's Sept. 2007 issue. + Updated to use syslog. + This object is NOT the global logger; + every log record is an object of this class. +*/ +class Log { + + public: + + protected: + + std::ostringstream mStream; ///< This is where we buffer up the log entry. + int mPriority; ///< Priority of current repot. + + public: + + Log(int wPriority) + :mPriority(wPriority) + { } + + // Most of the work is in the desctructor. + /** The destructor actually generates the log entry. */ + ~Log(); + + std::ostringstream& get(); +}; + + + +std::list gGetLoggerAlarms(); ///< Get a copy of the recent alarm list. + + +/**@ Global control and initialization of the logging system. */ +//@{ +/** Initialize the global logging system. */ +void gLogInit(const char* name, const char* level=NULL, int facility=LOG_USER); +/** Get the logging level associated with a given file. */ +int gGetLoggingLevel(const char *filename=NULL); +//@} + + +#endif + +// vim: ts=4 sw=4 diff --git a/CommonLibs/Makefile.am b/CommonLibs/Makefile.am new file mode 100644 index 0000000..52c965c --- /dev/null +++ b/CommonLibs/Makefile.am @@ -0,0 +1,93 @@ +# +# Copyright 2008, 2009 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -ldl -O3 -g -lpthread + +noinst_LTLIBRARIES = libcommon.la + +libcommon_la_SOURCES = \ + BitVector.cpp \ + LinkedLists.cpp \ + Sockets.cpp \ + Threads.cpp \ + Timeval.cpp \ + Logger.cpp \ + URLEncode.cpp \ + Configuration.cpp + +noinst_PROGRAMS = \ + BitVectorTest \ + InterthreadTest \ + SocketsTest \ + TimevalTest \ + RegexpTest \ + VectorTest \ + ConfigurationTest \ + LogTest \ + F16Test + +noinst_HEADERS = \ + BitVector.h \ + Interthread.h \ + LinkedLists.h \ + Sockets.h \ + Threads.h \ + Timeval.h \ + Regexp.h \ + Vector.h \ + URLEncode.h \ + Configuration.h \ + F16.h \ + Logger.h + +BitVectorTest_SOURCES = BitVectorTest.cpp +BitVectorTest_LDADD = libcommon.la + +InterthreadTest_SOURCES = InterthreadTest.cpp +InterthreadTest_LDADD = libcommon.la +InterthreadTest_LDFLAGS = -lpthread + +SocketsTest_SOURCES = SocketsTest.cpp +SocketsTest_LDADD = libcommon.la +SocketsTest_LDFLAGS = -lpthread + +TimevalTest_SOURCES = TimevalTest.cpp +TimevalTest_LDADD = libcommon.la + +VectorTest_SOURCES = VectorTest.cpp +VectorTest_LDADD = libcommon.la + +RegexpTest_SOURCES = RegexpTest.cpp +RegexpTest_LDADD = libcommon.la + +ConfigurationTest_SOURCES = ConfigurationTest.cpp +ConfigurationTest_LDADD = libcommon.la $(SQLITE_LA) + +LogTest_SOURCES = LogTest.cpp +LogTest_LDADD = libcommon.la $(SQLITE_LA) + +F16Test_SOURCES = F16Test.cpp + +MOSTLYCLEANFILES += testSource testDestination + + diff --git a/CommonLibs/Makefile.in b/CommonLibs/Makefile.in new file mode 100644 index 0000000..9970b71 --- /dev/null +++ b/CommonLibs/Makefile.in @@ -0,0 +1,658 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008, 2009 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + + +SOURCES = $(libcommon_la_SOURCES) $(BitVectorTest_SOURCES) $(ConfigurationTest_SOURCES) $(F16Test_SOURCES) $(InterthreadTest_SOURCES) $(LogTest_SOURCES) $(RegexpTest_SOURCES) $(SocketsTest_SOURCES) $(TimevalTest_SOURCES) $(VectorTest_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +noinst_PROGRAMS = BitVectorTest$(EXEEXT) InterthreadTest$(EXEEXT) \ + SocketsTest$(EXEEXT) TimevalTest$(EXEEXT) RegexpTest$(EXEEXT) \ + VectorTest$(EXEEXT) ConfigurationTest$(EXEEXT) \ + LogTest$(EXEEXT) F16Test$(EXEEXT) +subdir = CommonLibs +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libcommon_la_LIBADD = +am_libcommon_la_OBJECTS = BitVector.lo LinkedLists.lo Sockets.lo \ + Threads.lo Timeval.lo Logger.lo URLEncode.lo Configuration.lo +libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS) +PROGRAMS = $(noinst_PROGRAMS) +am_BitVectorTest_OBJECTS = BitVectorTest.$(OBJEXT) +BitVectorTest_OBJECTS = $(am_BitVectorTest_OBJECTS) +BitVectorTest_DEPENDENCIES = libcommon.la +am_ConfigurationTest_OBJECTS = ConfigurationTest.$(OBJEXT) +ConfigurationTest_OBJECTS = $(am_ConfigurationTest_OBJECTS) +am__DEPENDENCIES_1 = $(top_builddir)/sqlite3/libsqlite.la +ConfigurationTest_DEPENDENCIES = libcommon.la $(am__DEPENDENCIES_1) +am_F16Test_OBJECTS = F16Test.$(OBJEXT) +F16Test_OBJECTS = $(am_F16Test_OBJECTS) +F16Test_LDADD = $(LDADD) +am_InterthreadTest_OBJECTS = InterthreadTest.$(OBJEXT) +InterthreadTest_OBJECTS = $(am_InterthreadTest_OBJECTS) +InterthreadTest_DEPENDENCIES = libcommon.la +am_LogTest_OBJECTS = LogTest.$(OBJEXT) +LogTest_OBJECTS = $(am_LogTest_OBJECTS) +LogTest_DEPENDENCIES = libcommon.la $(am__DEPENDENCIES_1) +am_RegexpTest_OBJECTS = RegexpTest.$(OBJEXT) +RegexpTest_OBJECTS = $(am_RegexpTest_OBJECTS) +RegexpTest_DEPENDENCIES = libcommon.la +am_SocketsTest_OBJECTS = SocketsTest.$(OBJEXT) +SocketsTest_OBJECTS = $(am_SocketsTest_OBJECTS) +SocketsTest_DEPENDENCIES = libcommon.la +am_TimevalTest_OBJECTS = TimevalTest.$(OBJEXT) +TimevalTest_OBJECTS = $(am_TimevalTest_OBJECTS) +TimevalTest_DEPENDENCIES = libcommon.la +am_VectorTest_OBJECTS = VectorTest.$(OBJEXT) +VectorTest_OBJECTS = $(am_VectorTest_OBJECTS) +VectorTest_DEPENDENCIES = libcommon.la +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libcommon_la_SOURCES) $(BitVectorTest_SOURCES) \ + $(ConfigurationTest_SOURCES) $(F16Test_SOURCES) \ + $(InterthreadTest_SOURCES) $(LogTest_SOURCES) \ + $(RegexpTest_SOURCES) $(SocketsTest_SOURCES) \ + $(TimevalTest_SOURCES) $(VectorTest_SOURCES) +DIST_SOURCES = $(libcommon_la_SOURCES) $(BitVectorTest_SOURCES) \ + $(ConfigurationTest_SOURCES) $(F16Test_SOURCES) \ + $(InterthreadTest_SOURCES) $(LogTest_SOURCES) \ + $(RegexpTest_SOURCES) $(SocketsTest_SOURCES) \ + $(TimevalTest_SOURCES) $(VectorTest_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ testSource testDestination +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -ldl -O3 -g -lpthread +noinst_LTLIBRARIES = libcommon.la +libcommon_la_SOURCES = \ + BitVector.cpp \ + LinkedLists.cpp \ + Sockets.cpp \ + Threads.cpp \ + Timeval.cpp \ + Logger.cpp \ + URLEncode.cpp \ + Configuration.cpp + +noinst_HEADERS = \ + BitVector.h \ + Interthread.h \ + LinkedLists.h \ + Sockets.h \ + Threads.h \ + Timeval.h \ + Regexp.h \ + Vector.h \ + URLEncode.h \ + Configuration.h \ + F16.h \ + Logger.h + +BitVectorTest_SOURCES = BitVectorTest.cpp +BitVectorTest_LDADD = libcommon.la +InterthreadTest_SOURCES = InterthreadTest.cpp +InterthreadTest_LDADD = libcommon.la +InterthreadTest_LDFLAGS = -lpthread +SocketsTest_SOURCES = SocketsTest.cpp +SocketsTest_LDADD = libcommon.la +SocketsTest_LDFLAGS = -lpthread +TimevalTest_SOURCES = TimevalTest.cpp +TimevalTest_LDADD = libcommon.la +VectorTest_SOURCES = VectorTest.cpp +VectorTest_LDADD = libcommon.la +RegexpTest_SOURCES = RegexpTest.cpp +RegexpTest_LDADD = libcommon.la +ConfigurationTest_SOURCES = ConfigurationTest.cpp +ConfigurationTest_LDADD = libcommon.la $(SQLITE_LA) +LogTest_SOURCES = LogTest.cpp +LogTest_LDADD = libcommon.la $(SQLITE_LA) +F16Test_SOURCES = F16Test.cpp +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu CommonLibs/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu CommonLibs/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libcommon.la: $(libcommon_la_OBJECTS) $(libcommon_la_DEPENDENCIES) + $(CXXLINK) $(libcommon_la_LDFLAGS) $(libcommon_la_OBJECTS) $(libcommon_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +BitVectorTest$(EXEEXT): $(BitVectorTest_OBJECTS) $(BitVectorTest_DEPENDENCIES) + @rm -f BitVectorTest$(EXEEXT) + $(CXXLINK) $(BitVectorTest_LDFLAGS) $(BitVectorTest_OBJECTS) $(BitVectorTest_LDADD) $(LIBS) +ConfigurationTest$(EXEEXT): $(ConfigurationTest_OBJECTS) $(ConfigurationTest_DEPENDENCIES) + @rm -f ConfigurationTest$(EXEEXT) + $(CXXLINK) $(ConfigurationTest_LDFLAGS) $(ConfigurationTest_OBJECTS) $(ConfigurationTest_LDADD) $(LIBS) +F16Test$(EXEEXT): $(F16Test_OBJECTS) $(F16Test_DEPENDENCIES) + @rm -f F16Test$(EXEEXT) + $(CXXLINK) $(F16Test_LDFLAGS) $(F16Test_OBJECTS) $(F16Test_LDADD) $(LIBS) +InterthreadTest$(EXEEXT): $(InterthreadTest_OBJECTS) $(InterthreadTest_DEPENDENCIES) + @rm -f InterthreadTest$(EXEEXT) + $(CXXLINK) $(InterthreadTest_LDFLAGS) $(InterthreadTest_OBJECTS) $(InterthreadTest_LDADD) $(LIBS) +LogTest$(EXEEXT): $(LogTest_OBJECTS) $(LogTest_DEPENDENCIES) + @rm -f LogTest$(EXEEXT) + $(CXXLINK) $(LogTest_LDFLAGS) $(LogTest_OBJECTS) $(LogTest_LDADD) $(LIBS) +RegexpTest$(EXEEXT): $(RegexpTest_OBJECTS) $(RegexpTest_DEPENDENCIES) + @rm -f RegexpTest$(EXEEXT) + $(CXXLINK) $(RegexpTest_LDFLAGS) $(RegexpTest_OBJECTS) $(RegexpTest_LDADD) $(LIBS) +SocketsTest$(EXEEXT): $(SocketsTest_OBJECTS) $(SocketsTest_DEPENDENCIES) + @rm -f SocketsTest$(EXEEXT) + $(CXXLINK) $(SocketsTest_LDFLAGS) $(SocketsTest_OBJECTS) $(SocketsTest_LDADD) $(LIBS) +TimevalTest$(EXEEXT): $(TimevalTest_OBJECTS) $(TimevalTest_DEPENDENCIES) + @rm -f TimevalTest$(EXEEXT) + $(CXXLINK) $(TimevalTest_LDFLAGS) $(TimevalTest_OBJECTS) $(TimevalTest_LDADD) $(LIBS) +VectorTest$(EXEEXT): $(VectorTest_OBJECTS) $(VectorTest_DEPENDENCIES) + @rm -f VectorTest$(EXEEXT) + $(CXXLINK) $(VectorTest_LDFLAGS) $(VectorTest_OBJECTS) $(VectorTest_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitVector.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitVectorTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Configuration.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigurationTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/F16Test.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InterthreadTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LinkedLists.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RegexpTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sockets.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SocketsTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Threads.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timeval.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimevalTest.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/URLEncode.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VectorTest.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/CommonLibs/Regexp.h b/CommonLibs/Regexp.h new file mode 100644 index 0000000..3ff1e97 --- /dev/null +++ b/CommonLibs/Regexp.h @@ -0,0 +1,64 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef REGEXPW_H +#define REGEXPW_H + +#include +#include +#include + + + +class Regexp { + + private: + + regex_t mRegex; + + + public: + + Regexp(const char* regexp, int flags=REG_EXTENDED) + { + int result = regcomp(&mRegex, regexp, flags); + if (result) { + char msg[256]; + regerror(result,&mRegex,msg,255); + std::cerr << "Regexp compilation of " << regexp << " failed: " << msg << std::endl; + abort(); + } + } + + ~Regexp() + { regfree(&mRegex); } + + bool match(const char *text, int flags=0) const + { return regexec(&mRegex, text, 0, NULL, flags)==0; } + +}; + + +#endif diff --git a/CommonLibs/RegexpTest.cpp b/CommonLibs/RegexpTest.cpp new file mode 100644 index 0000000..748be49 --- /dev/null +++ b/CommonLibs/RegexpTest.cpp @@ -0,0 +1,48 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "Regexp.h" +#include + +using namespace std; + + +int main(int argc, char *argv[]) +{ + + Regexp email("^[[:graph:]]+@[[:graph:]]+ "); + Regexp simple("^dburgess@"); + + const char text1[] = "dburgess@jcis.net test message"; + const char text2[] = "no address text message"; + + cout << email.match(text1) << " " << text1 << endl; + cout << email.match(text2) << " " << text2 << endl; + + cout << simple.match(text1) << " " << text1 << endl; + cout << simple.match(text2) << " " << text2 << endl; +} diff --git a/CommonLibs/Sockets.cpp b/CommonLibs/Sockets.cpp new file mode 100644 index 0000000..f24b495 --- /dev/null +++ b/CommonLibs/Sockets.cpp @@ -0,0 +1,302 @@ +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include +#include +#include +#include + +#include "Threads.h" +#include "Sockets.h" +#include +#include +#include + +#include +#include + + + + + + +bool resolveAddress(struct sockaddr_in *address, const char *hostAndPort) +{ + assert(address); + assert(hostAndPort); + char *copy = strdup(hostAndPort); + char *colon = strchr(copy,':'); + if (!colon) return false; + *colon = '\0'; + char *host = copy; + unsigned port = strtol(colon+1,NULL,10); + bool retVal = resolveAddress(address,host,port); + free(copy); + return retVal; +} + +bool resolveAddress(struct sockaddr_in *address, const char *host, unsigned short port) +{ + assert(address); + assert(host); + // FIXME -- Need to ignore leading/trailing spaces in hostname. + struct hostent *hp = gethostbyname(host); + if (hp==NULL) { + CERR("WARNING -- gethostbyname() failed for " << host << ", " << hstrerror(h_errno)); + return false; + } + address->sin_family = AF_INET; + bcopy(hp->h_addr, &(address->sin_addr), hp->h_length); + address->sin_port = htons(port); + return true; +} + + + +DatagramSocket::DatagramSocket() +{ + bzero(mDestination,sizeof(mDestination)); +} + + + + + +void DatagramSocket::nonblocking() +{ + fcntl(mSocketFD,F_SETFL,O_NONBLOCK); +} + +void DatagramSocket::blocking() +{ + fcntl(mSocketFD,F_SETFL,0); +} + +void DatagramSocket::close() +{ + ::close(mSocketFD); +} + + +DatagramSocket::~DatagramSocket() +{ + close(); +} + + + + + +int DatagramSocket::write( const char * message, size_t length ) +{ + assert(length<=MAX_UDP_LENGTH); + int retVal = sendto(mSocketFD, message, length, 0, + (struct sockaddr *)mDestination, addressSize()); + if (retVal == -1 ) perror("DatagramSocket::write() failed"); + return retVal; +} + +int DatagramSocket::writeBack( const char * message, size_t length ) +{ + assert(length<=MAX_UDP_LENGTH); + int retVal = sendto(mSocketFD, message, length, 0, + (struct sockaddr *)mSource, addressSize()); + if (retVal == -1 ) perror("DatagramSocket::write() failed"); + return retVal; +} + + + +int DatagramSocket::write( const char * message) +{ + size_t length=strlen(message)+1; + return write(message,length); +} + +int DatagramSocket::writeBack( const char * message) +{ + size_t length=strlen(message)+1; + return writeBack(message,length); +} + + + +int DatagramSocket::send(const struct sockaddr* dest, const char * message, size_t length ) +{ + assert(length<=MAX_UDP_LENGTH); + int retVal = sendto(mSocketFD, message, length, 0, dest, addressSize()); + if (retVal == -1 ) perror("DatagramSocket::send() failed"); + return retVal; +} + +int DatagramSocket::send(const struct sockaddr* dest, const char * message) +{ + size_t length=strlen(message)+1; + return send(dest,message,length); +} + + + + + +int DatagramSocket::read(char* buffer) +{ + socklen_t temp_len = sizeof(mSource); + int length = recvfrom(mSocketFD, (void*)buffer, MAX_UDP_LENGTH, 0, + (struct sockaddr*)&mSource,&temp_len); + if ((length==-1) && (errno!=EAGAIN)) { + perror("DatagramSocket::read() failed"); + throw SocketError(); + } + return length; +} + + +int DatagramSocket::read(char* buffer, unsigned timeout) +{ + fd_set fds; + FD_SET(mSocketFD,&fds); + struct timeval tv; + tv.tv_sec = timeout/1000; + tv.tv_usec = (timeout%1000)*1000; + int sel = select(mSocketFD+1,&fds,NULL,NULL,&tv); + if (sel<0) { + perror("DatagramSocket::read() select() failed"); + throw SocketError(); + } + if (sel==0) return -1; + return read(buffer); +} + + + + + + +UDPSocket::UDPSocket(unsigned short wSrcPort) + :DatagramSocket() +{ + open(wSrcPort); +} + + +UDPSocket::UDPSocket(unsigned short wSrcPort, + const char * wDestIP, unsigned short wDestPort ) + :DatagramSocket() +{ + open(wSrcPort); + destination(wDestPort, wDestIP); +} + + + +void UDPSocket::destination( unsigned short wDestPort, const char * wDestIP ) +{ + resolveAddress((sockaddr_in*)mDestination, wDestIP, wDestPort ); +} + + +void UDPSocket::open(unsigned short localPort) +{ + // create + mSocketFD = socket(AF_INET,SOCK_DGRAM,0); + if (mSocketFD<0) { + perror("socket() failed"); + throw SocketError(); + } + + // bind + struct sockaddr_in address; + size_t length = sizeof(address); + bzero(&address,length); + address.sin_family = AF_INET; + address.sin_addr.s_addr = INADDR_ANY; + address.sin_port = htons(localPort); + if (bind(mSocketFD,(struct sockaddr*)&address,length)<0) { + perror("bind() failed"); + throw SocketError(); + } +} + + + +unsigned short UDPSocket::port() const +{ + struct sockaddr_in name; + socklen_t nameSize = sizeof(name); + int retVal = getsockname(mSocketFD, (struct sockaddr*)&name, &nameSize); + if (retVal==-1) throw SocketError(); + return ntohs(name.sin_port); +} + + + + + +UDDSocket::UDDSocket(const char* localPath, const char* remotePath) + :DatagramSocket() +{ + if (localPath!=NULL) open(localPath); + if (remotePath!=NULL) destination(remotePath); +} + + + +void UDDSocket::open(const char* localPath) +{ + // create + mSocketFD = socket(AF_UNIX,SOCK_DGRAM,0); + if (mSocketFD<0) { + perror("socket() failed"); + throw SocketError(); + } + + // bind + struct sockaddr_un address; + size_t length = sizeof(address); + bzero(&address,length); + address.sun_family = AF_UNIX; + strcpy(address.sun_path,localPath); + unlink(localPath); + if (bind(mSocketFD,(struct sockaddr*)&address,length)<0) { + perror("bind() failed"); + throw SocketError(); + } +} + + + +void UDDSocket::destination(const char* remotePath) +{ + struct sockaddr_un* unAddr = (struct sockaddr_un*)mDestination; + strcpy(unAddr->sun_path,remotePath); +} + + + + +// vim:ts=4:sw=4 diff --git a/CommonLibs/Sockets.h b/CommonLibs/Sockets.h new file mode 100644 index 0000000..c79f79a --- /dev/null +++ b/CommonLibs/Sockets.h @@ -0,0 +1,193 @@ +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef SOCKETS_H +#define SOCKETS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + + + +#define MAX_UDP_LENGTH 1500 + +/** A function to resolve IP host names. */ +bool resolveAddress(struct sockaddr_in *address, const char *host, unsigned short port); + +/** Resolve an address of the form ":". */ +bool resolveAddress(struct sockaddr_in *address, const char *hostAndPort); + +/** An exception to throw when a critical socket operation fails. */ +class SocketError {}; +#define SOCKET_ERROR {throw SocketError(); } + +/** Abstract class for connectionless sockets. */ +class DatagramSocket { + +protected: + + int mSocketFD; ///< underlying file descriptor + char mDestination[256]; ///< address to which packets are sent + char mSource[256]; ///< return address of most recent received packet + +public: + + /** An almost-does-nothing constructor. */ + DatagramSocket(); + + virtual ~DatagramSocket(); + + /** Return the address structure size for this socket type. */ + virtual size_t addressSize() const = 0; + + /** + Send a binary packet. + @param buffer The data bytes to send to mDestination. + @param length Number of bytes to send, or strlen(buffer) if defaulted to -1. + @return number of bytes written, or -1 on error. + */ + int write( const char * buffer, size_t length); + + /** + Send a C-style string packet. + @param buffer The data bytes to send to mDestination. + @return number of bytes written, or -1 on error. + */ + int write( const char * buffer); + + /** + Send a binary packet. + @param buffer The data bytes to send to mSource. + @param length Number of bytes to send, or strlen(buffer) if defaulted to -1. + @return number of bytes written, or -1 on error. + */ + int writeBack(const char * buffer, size_t length); + + /** + Send a C-style string packet. + @param buffer The data bytes to send to mSource. + @return number of bytes written, or -1 on error. + */ + int writeBack(const char * buffer); + + + /** + Receive a packet. + @param buffer A char[MAX_UDP_LENGTH] procured by the caller. + @return The number of bytes received or -1 on non-blocking pass. + */ + int read(char* buffer); + + /** + Receive a packet with a timeout. + @param buffer A char[MAX_UDP_LENGTH] procured by the caller. + @param maximum wait time in milliseconds + @return The number of bytes received or -1 on timeout. + */ + int read(char* buffer, unsigned timeout); + + + /** Send a packet to a given destination, other than the default. */ + int send(const struct sockaddr *dest, const char * buffer, size_t length); + + /** Send a C-style string to a given destination, other than the default. */ + int send(const struct sockaddr *dest, const char * buffer); + + /** Make the socket non-blocking. */ + void nonblocking(); + + /** Make the socket blocking (the default). */ + void blocking(); + + /** Close the socket. */ + void close(); + +}; + + + +/** UDP/IP User Datagram Socket */ +class UDPSocket : public DatagramSocket { + +public: + + /** Open a USP socket with an OS-assigned port and no default destination. */ + UDPSocket( unsigned short localPort=0); + + /** Given a full specification, open the socket and set the dest address. */ + UDPSocket( unsigned short localPort, + const char * remoteIP, unsigned short remotePort); + + /** Set the destination port. */ + void destination( unsigned short wDestPort, const char * wDestIP ); + + /** Return the actual port number in use. */ + unsigned short port() const; + + /** Open and bind the UDP socket to a local port. */ + void open(unsigned short localPort=0); + + /** Give the return address of the most recently received packet. */ + const struct sockaddr_in* source() const { return (const struct sockaddr_in*)mSource; } + + size_t addressSize() const { return sizeof(struct sockaddr_in); } + +}; + + +/** Unix Domain Datagram Socket */ +class UDDSocket : public DatagramSocket { + +public: + + UDDSocket(const char* localPath=NULL, const char* remotePath=NULL); + + void destination(const char* remotePath); + + void open(const char* localPath); + + /** Give the return address of the most recently received packet. */ + const struct sockaddr_un* source() const { return (const struct sockaddr_un*)mSource; } + + size_t addressSize() const { return sizeof(struct sockaddr_un); } + +}; + + +#endif + + + +// vim:ts=4:sw=4 diff --git a/CommonLibs/SocketsTest.cpp b/CommonLibs/SocketsTest.cpp new file mode 100644 index 0000000..9a4997b --- /dev/null +++ b/CommonLibs/SocketsTest.cpp @@ -0,0 +1,103 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "Sockets.h" +#include "Threads.h" +#include +#include + + +static const int gNumToSend = 10; + + +void *testReaderIP(void *) +{ + UDPSocket readSocket(5934, "localhost", 5061); + readSocket.nonblocking(); + int rc = 0; + while (rc0) { + COUT("read: " << buf); + rc++; + } else { + sleep(2); + } + } + return NULL; +} + + + +void *testReaderUnix(void *) +{ + UDDSocket readSocket("testDestination"); + readSocket.nonblocking(); + int rc = 0; + while (rc0) { + COUT("read: " << buf); + rc++; + } else { + sleep(2); + } + } + return NULL; +} + + +int main(int argc, char * argv[] ) +{ + + Thread readerThreadIP; + readerThreadIP.start(testReaderIP,NULL); + Thread readerThreadUnix; + readerThreadUnix.start(testReaderUnix,NULL); + + UDPSocket socket1(5061, "127.0.0.1",5934); + UDDSocket socket1U("testSource","testDestination"); + + COUT("socket1: " << socket1.port()); + + // give the readers time to open + sleep(1); + + for (int i=0; i. + +*/ + + + + + +#include "Threads.h" +#include "Timeval.h" + + +using namespace std; + + + + +Mutex gStreamLock; ///< Global lock to control access to cout and cerr. + +void lockCout() +{ + gStreamLock.lock(); + Timeval entryTime; + cout << entryTime << " " << pthread_self() << ": "; +} + + +void unlockCout() +{ + cout << dec << endl << flush; + gStreamLock.unlock(); +} + + +void lockCerr() +{ + gStreamLock.lock(); + Timeval entryTime; + cerr << entryTime << " " << pthread_self() << ": "; +} + +void unlockCerr() +{ + cerr << dec << endl << flush; + gStreamLock.unlock(); +} + + + + + + + +Mutex::Mutex() +{ + bool res; + res = pthread_mutexattr_init(&mAttribs); + assert(!res); + res = pthread_mutexattr_settype(&mAttribs,PTHREAD_MUTEX_RECURSIVE); + assert(!res); + res = pthread_mutex_init(&mMutex,&mAttribs); + assert(!res); +} + + +Mutex::~Mutex() +{ + pthread_mutex_destroy(&mMutex); + bool res = pthread_mutexattr_destroy(&mAttribs); + assert(!res); +} + + + + +/** Block for the signal up to the cancellation timeout. */ +void Signal::wait(Mutex& wMutex, unsigned timeout) const +{ + Timeval then(timeout); + struct timespec waitTime = then.timespec(); + pthread_cond_timedwait(&mSignal,&wMutex.mMutex,&waitTime); +} + + +void Thread::start(void *(*task)(void*), void *arg) +{ + assert(mThread==((pthread_t)0)); + bool res; + res = pthread_attr_init(&mAttrib); + assert(!res); + res = pthread_attr_setstacksize(&mAttrib, mStackSize); + assert(!res); + res = pthread_create(&mThread, &mAttrib, task, arg); + assert(!res); +} + + + +// vim: ts=4 sw=4 diff --git a/CommonLibs/Threads.h b/CommonLibs/Threads.h new file mode 100644 index 0000000..c1cfc75 --- /dev/null +++ b/CommonLibs/Threads.h @@ -0,0 +1,176 @@ +/* +* Copyright 2008, 2011 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef THREADS_H +#define THREADS_H + +#include +#include +#include + +class Mutex; + + +/**@name Multithreaded access for standard streams. */ +//@{ + +/**@name Functions for gStreamLock. */ +//@{ +extern Mutex gStreamLock; ///< global lock for cout and cerr +void lockCerr(); ///< call prior to writing cerr +void unlockCerr(); ///< call after writing cerr +void lockCout(); ///< call prior to writing cout +void unlockCout(); ///< call after writing cout +//@} + +/**@name Macros for standard messages. */ +//@{ +#define COUT(text) { lockCout(); std::cout << text; unlockCout(); } +#define CERR(text) { lockCerr(); std::cerr << __FILE__ << ":" << __LINE__ << ": " << text; unlockCerr(); } +#ifdef NDEBUG +#define DCOUT(text) {} +#define OBJDCOUT(text) {} +#else +#define DCOUT(text) { COUT(__FILE__ << ":" << __LINE__ << " " << text); } +#define OBJDCOUT(text) { DCOUT(this << " " << text); } +#endif +//@} +//@} + + + +/**@defgroup C++ wrappers for pthread mechanisms. */ +//@{ + +/** A class for recursive mutexes based on pthread_mutex. */ +class Mutex { + + private: + + pthread_mutex_t mMutex; + pthread_mutexattr_t mAttribs; + + public: + + Mutex(); + + ~Mutex(); + + void lock() { pthread_mutex_lock(&mMutex); } + + void unlock() { pthread_mutex_unlock(&mMutex); } + + friend class Signal; + +}; + + +class ScopedLock { + + private: + Mutex& mMutex; + + public: + ScopedLock(Mutex& wMutex) :mMutex(wMutex) { mMutex.lock(); } + ~ScopedLock() { mMutex.unlock(); } + +}; + + + + +/** A C++ interthread signal based on pthread condition variables. */ +class Signal { + + private: + + mutable pthread_cond_t mSignal; + + public: + + Signal() { int s = pthread_cond_init(&mSignal,NULL); assert(!s); } + + ~Signal() { pthread_cond_destroy(&mSignal); } + + /** + Block for the signal up to the cancellation timeout. + Under Linux, spurious returns are possible. + */ + void wait(Mutex& wMutex, unsigned timeout) const; + + /** + Block for the signal. + Under Linux, spurious returns are possible. + */ + void wait(Mutex& wMutex) const + { pthread_cond_wait(&mSignal,&wMutex.mMutex); } + + void signal() { pthread_cond_signal(&mSignal); } + + void broadcast() { pthread_cond_broadcast(&mSignal); } + +}; + + + +#define START_THREAD(thread,function,argument) \ + thread.start((void *(*)(void*))function, (void*)argument); + +/** A C++ wrapper for pthread threads. */ +class Thread { + + private: + + pthread_t mThread; + pthread_attr_t mAttrib; + // FIXME -- Can this be reduced now? + size_t mStackSize; + + + public: + + /** Create a thread in a non-running state. */ + Thread(size_t wStackSize = (65536*4)):mThread((pthread_t)0) { mStackSize=wStackSize;} + + /** + Destroy the Thread. + It should be stopped and joined. + */ + ~Thread() { pthread_attr_destroy(&mAttrib); } + + + /** Start the thread on a task. */ + void start(void *(*task)(void*), void *arg); + + /** Join a thread that will stop on its own. */ + void join() { int s = pthread_join(mThread,NULL); assert(!s); } + +}; + + + + +#endif +// vim: ts=4 sw=4 diff --git a/CommonLibs/Timeval.cpp b/CommonLibs/Timeval.cpp new file mode 100644 index 0000000..47eebc4 --- /dev/null +++ b/CommonLibs/Timeval.cpp @@ -0,0 +1,98 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "Timeval.h" + +using namespace std; + +void Timeval::future(unsigned offset) +{ + now(); + unsigned sec = offset/1000; + unsigned msec = offset%1000; + mTimeval.tv_usec += msec*1000; + mTimeval.tv_sec += sec; + if (mTimeval.tv_usec>1000000) { + mTimeval.tv_usec -= 1000000; + mTimeval.tv_sec += 1; + } +} + + +struct timespec Timeval::timespec() const +{ + struct timespec retVal; + retVal.tv_sec = mTimeval.tv_sec; + retVal.tv_nsec = 1000 * (long)mTimeval.tv_usec; + return retVal; +} + + +bool Timeval::passed() const +{ + Timeval nowTime; + if (nowTime.mTimeval.tv_sec < mTimeval.tv_sec) return false; + if (nowTime.mTimeval.tv_sec > mTimeval.tv_sec) return true; + if (nowTime.mTimeval.tv_usec > mTimeval.tv_usec) return true; + return false; +} + +double Timeval::seconds() const +{ + return ((double)mTimeval.tv_sec) + 1e-6*((double)mTimeval.tv_usec); +} + + + +long Timeval::delta(const Timeval& other) const +{ + // 2^31 milliseconds is just over 4 years. + long deltaS = other.sec() - sec(); + long deltaUs = other.usec() - usec(); + return 1000*deltaS + deltaUs/1000; +} + + + + +ostream& operator<<(ostream& os, const Timeval& tv) +{ + os.setf( ios::fixed, ios::floatfield ); + os << tv.seconds(); + return os; +} + + +ostream& operator<<(ostream& os, const struct timespec& ts) +{ + os << ts.tv_sec << "," << ts.tv_nsec; + return os; +} + + + +// vim: ts=4 sw=4 diff --git a/CommonLibs/Timeval.h b/CommonLibs/Timeval.h new file mode 100644 index 0000000..c2a2617 --- /dev/null +++ b/CommonLibs/Timeval.h @@ -0,0 +1,104 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#ifndef TIMEVAL_H +#define TIMEVAL_H + +#include +#include "sys/time.h" +#include + + + +/** A wrapper on usleep to sleep for milliseconds. */ +inline void msleep(long v) { usleep(v*1000); } + + +/** A C++ wrapper for struct timeval. */ +class Timeval { + + private: + + struct timeval mTimeval; + + public: + + /** Set the value to gettimeofday. */ + void now() { gettimeofday(&mTimeval,NULL); } + + /** Set the value to gettimeofday plus an offset. */ + void future(unsigned ms); + + //@{ + Timeval(unsigned sec, unsigned usec) + { + mTimeval.tv_sec = sec; + mTimeval.tv_usec = usec; + } + + Timeval(const struct timeval& wTimeval) + :mTimeval(wTimeval) + {} + + /** + Create a Timeval offset into the future. + @param offset milliseconds + */ + Timeval(unsigned offset=0) { future(offset); } + //@} + + /** Convert to a struct timespec. */ + struct timespec timespec() const; + + /** Return total seconds. */ + double seconds() const; + + uint32_t sec() const { return mTimeval.tv_sec; } + uint32_t usec() const { return mTimeval.tv_usec; } + + /** Return differnce from other (other-self), in ms. */ + long delta(const Timeval& other) const; + + /** Elapsed time in ms. */ + long elapsed() const { return delta(Timeval()); } + + /** Remaining time in ms. */ + long remaining() const { return -elapsed(); } + + /** Return true if the time has passed, as per gettimeofday. */ + bool passed() const; + + /** Add a given number of minutes to the time. */ + void addMinutes(unsigned minutes) { mTimeval.tv_sec += minutes*60; } + +}; + +std::ostream& operator<<(std::ostream& os, const Timeval&); + +std::ostream& operator<<(std::ostream& os, const struct timespec&); + + +#endif +// vim: ts=4 sw=4 diff --git a/CommonLibs/TimevalTest.cpp b/CommonLibs/TimevalTest.cpp new file mode 100644 index 0000000..b4746f2 --- /dev/null +++ b/CommonLibs/TimevalTest.cpp @@ -0,0 +1,45 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "Timeval.h" +#include + +using namespace std; + +int main(int argc, char *argv[]) +{ + + Timeval then(10000); + cout << then.elapsed() << endl; + + while (!then.passed()) { + cout << "now: " << Timeval() << " then: " << then << " remaining: " << then.remaining() << endl; + usleep(500000); + } + cout << "now: " << Timeval() << " then: " << then << " remaining: " << then.remaining() << endl; +} diff --git a/CommonLibs/URLEncode.cpp b/CommonLibs/URLEncode.cpp new file mode 100644 index 0000000..870db33 --- /dev/null +++ b/CommonLibs/URLEncode.cpp @@ -0,0 +1,51 @@ +/* +* Copyright 2011 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include +#include +#include + +using namespace std; + +//based on javascript encodeURIComponent() +string URLEncode(const string &c) +{ + static const char *digits = "01234567890ABCDEF"; + string retVal=""; + for (int i=0; i>4) & 0x0f]; + retVal += digits[ch & 0x0f]; + } + } + return retVal; +} + diff --git a/CommonLibs/URLEncode.h b/CommonLibs/URLEncode.h new file mode 100644 index 0000000..558ced9 --- /dev/null +++ b/CommonLibs/URLEncode.h @@ -0,0 +1,30 @@ +/* +* Copyright 2011 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +# include + +std::string URLEncode(const std::string&); diff --git a/CommonLibs/Vector.h b/CommonLibs/Vector.h new file mode 100644 index 0000000..62cb6fb --- /dev/null +++ b/CommonLibs/Vector.h @@ -0,0 +1,268 @@ +/**@file Simplified Vector template with aliases. */ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#ifndef VECTOR_H +#define VECTOR_H + +#include +#include +#include + + +/** + A simplified Vector template with aliases. + Unlike std::vector, this class does not support dynamic resizing. + Unlike std::vector, this class does support "aliases" and subvectors. +*/ +template class Vector { + + // TODO -- Replace memcpy calls with for-loops. + + public: + + /**@name Iterator types. */ + //@{ + typedef T* iterator; + typedef const T* const_iterator; + //@} + + protected: + + T* mData; ///< allocated data block, if any + T* mStart; ///< start of useful data + T* mEnd; ///< end of useful data + 1 + + public: + + /** Return the size of the Vector. */ + size_t size() const + { + assert(mStart>=mData); + assert(mEnd>=mStart); + return mEnd - mStart; + } + + /** Return size in bytes. */ + size_t bytes() const { return size()*sizeof(T); } + + /** Change the size of the Vector, discarding content. */ + void resize(size_t newSize) + { + if (mData!=NULL) delete[] mData; + if (newSize==0) mData=NULL; + else mData = new T[newSize]; + mStart = mData; + mEnd = mStart + newSize; + } + + /** Release memory and clear pointers. */ + void clear() { resize(0); } + + + /** Copy data from another vector. */ + void clone(const Vector& other) + { + resize(other.size()); + memcpy(mData,other.mStart,other.bytes()); + } + + + + + //@{ + + /** Build an empty Vector of a given size. */ + Vector(size_t wSize=0):mData(NULL) { resize(wSize); } + + /** Build a Vector by shifting the data block. */ + Vector(Vector& other) + :mData(other.mData),mStart(other.mStart),mEnd(other.mEnd) + { other.mData=NULL; } + + /** Build a Vector by copying another. */ + Vector(const Vector& other):mData(NULL) { clone(other); } + + /** Build a Vector with explicit values. */ + Vector(T* wData, T* wStart, T* wEnd) + :mData(wData),mStart(wStart),mEnd(wEnd) + { } + + /** Build a vector from an existing block, NOT to be deleted upon destruction. */ + Vector(T* wStart, size_t span) + :mData(NULL),mStart(wStart),mEnd(wStart+span) + { } + + /** Build a Vector by concatenation. */ + Vector(const Vector& other1, const Vector& other2) + :mData(NULL) + { + resize(other1.size()+other2.size()); + memcpy(mStart, other1.mStart, other1.bytes()); + memcpy(mStart+other1.size(), other2.mStart, other2.bytes()); + } + + //@} + + /** Destroy a Vector, deleting held memory. */ + ~Vector() { clear(); } + + + + + //@{ + + /** Assign from another Vector, shifting ownership. */ + void operator=(Vector& other) + { + clear(); + mData=other.mData; + mStart=other.mStart; + mEnd=other.mEnd; + other.mData=NULL; + } + + /** Assign from another Vector, copying. */ + void operator=(const Vector& other) { clone(other); } + + //@} + + + //@{ + + /** Return an alias to a segment of this Vector. */ + Vector segment(size_t start, size_t span) + { + T* wStart = mStart + start; + T* wEnd = wStart + span; + assert(wEnd<=mEnd); + return Vector(NULL,wStart,wEnd); + } + + /** Return an alias to a segment of this Vector. */ + const Vector segment(size_t start, size_t span) const + { + T* wStart = mStart + start; + T* wEnd = wStart + span; + assert(wEnd<=mEnd); + return Vector(NULL,wStart,wEnd); + } + + Vector head(size_t span) { return segment(0,span); } + const Vector head(size_t span) const { return segment(0,span); } + Vector tail(size_t start) { return segment(start,size()-start); } + const Vector tail(size_t start) const { return segment(start,size()-start); } + + /** + Copy part of this Vector to a segment of another Vector. + @param other The other vector. + @param start The start point in the other vector. + @param span The number of elements to copy. + */ + void copyToSegment(Vector& other, size_t start, size_t span) const + { + T* base = other.mStart + start; + assert(base+span<=other.mEnd); + assert(mStart+span<=mEnd); + memcpy(base,mStart,span*sizeof(T)); + } + + /** Copy all of this Vector to a segment of another Vector. */ + void copyToSegment(Vector& other, size_t start=0) const { copyToSegment(other,start,size()); } + + void copyTo(Vector& other) const { copyToSegment(other,0,size()); } + + /** + Copy a segment of this vector into another. + @param other The other vector (to copt into starting at 0.) + @param start The start point in this vector. + @param span The number of elements to copy. + */ + void segmentCopyTo(Vector& other, size_t start, size_t span) const + { + const T* base = mStart + start; + assert(base+span<=mEnd); + assert(other.mStart+span<=other.mEnd); + memcpy(other.mStart,base,span*sizeof(T)); + } + + void fill(const T& val) + { + T* dp=mStart; + while (dp +std::ostream& operator<<(std::ostream& os, const Vector& v) +{ + for (unsigned i=0; i. + +*/ + + + +#include "Vector.h" +#include + +using namespace std; + +typedef Vector TestVector; + +int main(int argc, char *argv[]) +{ + TestVector test1(5); + for (int i=0; i<5; i++) test1[i]=i; + TestVector test2(5); + for (int i=0; i<5; i++) test2[i]=10+i; + + cout << test1 << endl; + cout << test2 << endl; + + { + TestVector testC(test1,test2); + cout << testC << endl; + cout << testC.head(3) << endl; + cout << testC.tail(3) << endl; + testC.fill(8); + cout << testC << endl; + test1.copyToSegment(testC,3); + cout << testC << endl; + + TestVector testD(testC.segment(4,3)); + cout << testD << endl; + testD.fill(9); + cout << testC << endl; + cout << testD << endl; + } + + return 0; +} diff --git a/Control/CallControl.cpp b/Control/CallControl.cpp new file mode 100644 index 0000000..d71f09b --- /dev/null +++ b/Control/CallControl.cpp @@ -0,0 +1,1054 @@ +/**@file GSM/SIP Call Control -- GSM 04.08, ISDN ITU-T Q.931, SIP IETF RFC-3261, RTP IETF RFC-3550. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +/* + Abbreviations: + MTC -- Mobile Terminated Connect (someone calling the mobile) + MOC -- Mobile Originated Connect (mobile calling out) + MTD -- Mobile Terminated Disconnect (other party hangs up) + MOD -- Mobile Originated Disconnect (mobile hangs up) +*/ + + +#include + +#include "ControlCommon.h" +#include "TransactionTable.h" +#include "MobilityManagement.h" +#include "SMSControl.h" +#include "CallControl.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#undef WARNING + +using namespace std; +using namespace Control; + + + + + + +/** + Return an even UDP port number for the RTP even/odd pair. +*/ +unsigned allocateRTPPorts() +{ + // FIXME -- We need a real port allocator. + const unsigned base = gConfig.getNum("RTP.Start"); + const unsigned range = gConfig.getNum("RTP.Range"); + const unsigned top = base+range; + static Mutex lock; + // Pick a random starting point. + static unsigned port = base + 2*(random()%(range/2)); + lock.lock(); + unsigned retVal = port; + port += 2; + if (port>=top) port=base; + lock.unlock(); + return retVal; +} + + + +/** + Force clearing on the GSM side. + @param transaction The call transaction record. + @param LCH The logical channel. + @param cause The L3 abort cause. +*/ +void forceGSMClearing(TransactionEntry *transaction, GSM::LogicalChannel *LCH, const GSM::L3Cause& cause) +{ + LOG(INFO) << "Q.931 state " << transaction->GSMState(); + // Already cleared? + if (transaction->GSMState()==GSM::NullState) return; + // Clearing not started? Start it. + if (!transaction->clearingGSM()) LCH->send(GSM::L3Disconnect(transaction->L3TI(),cause)); + // Force the rest. + LCH->send(GSM::L3ReleaseComplete(transaction->L3TI())); + LCH->send(GSM::L3ChannelRelease()); + transaction->resetTimers(); + transaction->GSMState(GSM::NullState); + LCH->send(GSM::RELEASE); +} + + +/** + Force clearing on the SIP side. + @param transaction The call transaction record. +*/ +void forceSIPClearing(TransactionEntry *transaction) +{ + SIP::SIPState state = transaction->SIPState(); + LOG(INFO) << "SIP state " << state; + if (state==SIP::Cleared) return; + if (state!=SIP::MODClearing) { + // This also changes the SIP state to "clearing". + transaction->MODSendBYE(); + } else { + transaction->MODResendBYE(); + } + transaction->MODWaitForOK(); +} + + + +/** + Abort the call. Does not remove the transaction from the table. + @param transaction The call transaction record. + @param LCH The logical channel. + @param cause The L3 abort cause. +*/ +void abortCall(TransactionEntry *transaction, GSM::LogicalChannel *LCH, const GSM::L3Cause& cause) +{ + LOG(INFO) << "cause: " << cause << ", transction: " << *transaction; + if (LCH) forceGSMClearing(transaction,LCH,cause); + forceSIPClearing(transaction); +} + + +/** + Abort the call and remove the transaction. + @param transaction The call transaction record. + @param LCH The logical channel. + @param cause The L3 abort cause. +*/ +void abortAndRemoveCall(TransactionEntry *transaction, GSM::LogicalChannel *LCH, const GSM::L3Cause& cause) +{ + abortCall(transaction,LCH,cause); + gTransactionTable.remove(transaction); +} + + + + +/** + Allocate a TCH and clean up any failure. + @param DCCH The DCCH that will be used to send the assignment. + @return A pointer to the TCH or NULL on failure. +*/ +GSM::TCHFACCHLogicalChannel *allocateTCH(GSM::LogicalChannel *DCCH) +{ + GSM::TCHFACCHLogicalChannel *TCH = gBTS.getTCH(); + if (!TCH) { + LOG(WARNING) << "congestion, no TCH available for assignment"; + // Cause 0x16 is "congestion". + DCCH->send(GSM::L3CMServiceReject(0x16)); + DCCH->send(GSM::L3ChannelRelease()); + } + return TCH; +} + + + + + +/** + Assign a full rate traffic channel and clean up any failures. + @param DCCH The DCCH on which to send the assignment. + @param TCH The TCH to be assigned. + @bool True on successful transfer. +*/ +bool assignTCHF(TransactionEntry *transaction, GSM::LogicalChannel *DCCH, GSM::TCHFACCHLogicalChannel *TCH) +{ + TCH->open(); + TCH->setPhy(*DCCH); + + // Send the assignment. + transaction->channel(TCH); + LOG(DEBUG) << "updated transaction " << *transaction; + LOG(INFO) << "sending AssignmentCommand for " << *TCH << " on " << *DCCH; + DCCH->send(GSM::L3AssignmentCommand(TCH->channelDescription(),GSM::L3ChannelMode(GSM::L3ChannelMode::SpeechV1))); + + // This read is SUPPOSED to time out if the assignment was successful. + // Pad the timeout just in case there's a large latency somewhere. + GSM::L3Frame *result = DCCH->recv(GSM::T3107ms+2000); + if (result==NULL) { + LOG(INFO) << "sucessful assignment; exiting normally"; + DCCH->send(GSM::HARDRELEASE); + return true; + } + + // If we got here, the assignment failed. + LOG(NOTICE) << "received " << *result; + delete result; + + // Turn off the TCH. + TCH->send(GSM::RELEASE); + + // Dissociate channel from the transaction. + // The tranaction no longer has a channel. + transaction->channel(NULL); + + // RR Cause 0x04 -- "abnormal release, no activity on the radio path" + DCCH->send(GSM::L3ChannelRelease(0x04)); + // Shut down the SIP side of the call. + forceSIPClearing(transaction); + // Indicate failure. + return false; +} + + + + +/** + Process a message received from the phone during a call. + This function processes all deviations from the "call connected" state. + For now, we handle call clearing and politely reject everything else. + @param transaction The transaction record for this call. + @param LCH The logical channel for the transaction. + @param message A pointer to the receiver message. + @return true If the call has been cleared and the channel released. +*/ +bool callManagementDispatchGSM(TransactionEntry *transaction, GSM::LogicalChannel* LCH, const GSM::L3Message *message) +{ + LOG(DEBUG) << "from " << transaction->subscriber() << " message " << *message; + + // FIXME -- This dispatch section should be something more efficient with PD and MTI swtiches. + + // Actually check state before taking action. + //if (transaction->SIPState()==SIP::Cleared) return true; + //if (transaction->GSMState()==GSM::NullState) return true; + + // Call connection steps. + + // Connect Acknowledge + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Connect Acknowledge " << *transaction; + transaction->resetTimers(); + transaction->GSMState(GSM::Active); + return false; + } + + // Connect + // GSM 04.08 5.2.2.5 and 5.2.2.6 + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Connect " << *transaction; + transaction->resetTimers(); + transaction->GSMState(GSM::Active); + return false; + } + + // Call Confirmed + // GSM 04.08 5.2.2.3.2 + // "Call Confirmed" is the GSM MTC counterpart to "Call Proceeding" + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Call Confirmed " << *transaction; + transaction->resetTimer("303"); + transaction->setTimer("301"); + transaction->GSMState(GSM::MTCConfirmed); + return false; + } + + // Alerting + // GSM 04.08 5.2.2.3.2 + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Alerting " << *transaction; + transaction->resetTimer("310"); + transaction->setTimer("301"); + transaction->GSMState(GSM::CallReceived); + return false; + } + + // Call clearing steps. + // Good diagrams in GSM 04.08 7.3.4 + + // FIXME -- We should be checking TI values against the transaction object. + + // Disconnect (1st step of MOD) + // GSM 04.08 5.4.3.2 + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Disconnect " << *transaction; + transaction->resetTimers(); + LCH->send(GSM::L3Release(transaction->L3TI())); + transaction->setTimer("308"); + transaction->GSMState(GSM::ReleaseRequest); + // FIXME -- Maybe we need to send CANCEL. See ticket #172. + transaction->MODSendBYE(); + return false; + } + + // Release (2nd step of MTD) + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Release " << *transaction; + transaction->resetTimers(); + LCH->send(GSM::L3ReleaseComplete(transaction->L3TI())); + LCH->send(GSM::L3ChannelRelease()); + transaction->GSMState(GSM::NullState); + transaction->MTDSendOK(); + return true; + } + + // Release Complete (3nd step of MOD) + // GSM 04.08 5.4.3.4 + if (dynamic_cast(message)) { + LOG(INFO) << "GSM Release Complete " << *transaction; + transaction->resetTimers(); + LCH->send(GSM::L3ChannelRelease()); + transaction->GSMState(GSM::NullState); + transaction->MODWaitForOK(); + return true; + } + + // IMSI Detach -- the phone is shutting off. + if (const GSM::L3IMSIDetachIndication* detach = dynamic_cast(message)) { + // The IMSI detach procedure will release the LCH. + LOG(INFO) << "GSM IMSI Detach " << *transaction; + IMSIDetachController(detach,LCH); + forceSIPClearing(transaction); + return true; + } + + // Start DTMF + // Transalate to RFC-2967 or RFC-2833. + if (const GSM::L3StartDTMF* startDTMF = dynamic_cast(message)) { + char key = startDTMF->key().IA5(); + LOG(INFO) << "DMTF key=" << key << ' ' << *transaction; + bool success = false; + if (gConfig.defines("SIP.DTMF.RFC2833")) { + bool s = transaction->startDTMF(key); + if (!s) LOG(ERR) << "DTMF RFC-28333 failed."; + success |= s; + } + if (gConfig.defines("SIP.DTMF.RFC2967")) { + unsigned bcd = GSM::encodeBCDChar(key); + bool s = transaction->sendINFOAndWaitForOK(bcd); + if (!s) LOG(ERR) << "DTMF RFC-2967 failed."; + success |= s; + } + if (success) { + LCH->send(GSM::L3StartDTMFAcknowledge(transaction->L3TI(),startDTMF->key())); + } else { + LOG (CRIT) << "DTMF sending attempt failed; is any DTMF method defined?"; + // Cause 0x3f means "service or option not available". + LCH->send(GSM::L3StartDTMFReject(transaction->L3TI(),0x3f)); + } + return false; + } + + // Stop DTMF + // RFC-2967 or RFC-2833 + if (dynamic_cast(message)) { + transaction->stopDTMF(); + LCH->send(GSM::L3StopDTMFAcknowledge(transaction->L3TI())); + return false; + } + + // CM Service Request + if (const GSM::L3CMServiceRequest *cmsrq = dynamic_cast(message)) { + // SMS submission? The rest will happen on the SACCH. + if (cmsrq->serviceType().type() == GSM::L3CMServiceType::ShortMessage) { + LOG (INFO) << "in call SMS submission on " << *LCH; + InCallMOSMSStarter(transaction); + LCH->send(GSM::L3CMServiceAccept()); + return false; + } + // For now, we are rejecting anything else. + LOG(NOTICE) << "cannot accept additional CM Service Request from " << transaction->subscriber(); + // Cause 0x20 means "serivce not supported". + LCH->send(GSM::L3CMServiceReject(0x20)); + return false; + } + + // Stubs for unsupported features. + // We need to answer the handset so it doesn't hang. + + // Hold + if (dynamic_cast(message)) { + LOG(NOTICE) << "rejecting hold request from " << transaction->subscriber(); + // Default cause is 0x3f, option not available + LCH->send(GSM::L3HoldReject(transaction->L3TI(),0x3f)); + return false; + } + + if (message) { LOG(NOTICE) << "no support for message " << *message << " from " << transaction->subscriber(); } + else { LOG(NOTICE) << "no support for unrecognized message from " << transaction->subscriber(); } + + + // If we got here, we're ignoring the message. + return false; +} + + + + + + +/** + Update vocoder data transfers in both directions. + @param transaction The transaction object for this call. + @param TCH The traffic channel for this call. + @return True if anything was transferred. +*/ +bool updateCallTraffic(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel *TCH) +{ + bool activity = false; + + // Transfer in the downlink direction (RTP->GSM). + // Blocking call. On average returns 1 time per 20 ms. + // Returns non-zero if anything really happened. + // Make the rxFrame buffer big enough for G.711. + unsigned char rxFrame[160]; + if (transaction->rxFrame(rxFrame)) { + activity = true; + TCH->sendTCH(rxFrame); + } + + // Transfer in the uplink direction (GSM->RTP). + // Flush FIFO to limit latency. + unsigned maxQ = gConfig.getNum("GSM.MaxSpeechLatency"); + while (TCH->queueSize()>maxQ) delete[] TCH->recvTCH(); + if (unsigned char *txFrame = TCH->recvTCH()) { + activity = true; + // Send on RTP. + transaction->txFrame(txFrame); + delete[] txFrame; + } + + // Return a flag so the caller will know if anything transferred. + return activity; +} + + + + +/** + Check GSM signalling. + Can block for up to 52 GSM L1 frames (240 ms) because LCH::send is blocking. + @param transaction The call's TransactionEntry. + @param LCH The call's logical channel (TCH/FACCH or SDCCH). + @return true If the call was cleared, but the transaction is still there. +*/ +bool updateGSMSignalling(TransactionEntry *transaction, GSM::LogicalChannel *LCH, unsigned timeout=0) +{ + if (transaction->GSMState()==GSM::NullState) return true; + + // Any Q.931 timer expired? + if (transaction->anyTimerExpired()) { + // Cause 0x66, "recover on timer expiry" + abortCall(transaction,LCH,GSM::L3Cause(0x66)); + return true; + } + + // Look for a control message from MS side. + if (GSM::L3Frame *l3 = LCH->recv(timeout)) { + // Check for lower-layer error. + if (l3->primitive() == GSM::ERROR) return true; + // Parse and dispatch. + GSM::L3Message *l3msg = parseL3(*l3); + delete l3; + bool cleared = false; + if (l3msg) { + LOG(DEBUG) << "received " << *l3msg; + cleared = callManagementDispatchGSM(transaction, LCH, l3msg); + delete l3msg; + } + return cleared; + } + + // If we are here, we have timed out, but assume the call is still running. + return false; +} + + + +/** + Check SIP signalling. + @param transaction The call's TransactionEntry. + @param LCH The call's GSM logical channel (TCH/FACCH or SDCCH). + @param GSMCleared True if the call is already cleared in the GSM domain. + @return true If the call is cleared in the SIP domain. +*/ +bool updateSIPSignalling(TransactionEntry *transaction, GSM::LogicalChannel *LCH, bool GSMCleared) +{ + + // The main purpose of this code is to initiate disconnects from the SIP side. + + if (transaction->SIPState()==SIP::Cleared) return true; + + bool GSMClearedOrClearing = GSMCleared || transaction->clearingGSM(); + + if (transaction->MTDCheckBYE() == SIP::MTDClearing) { + LOG(DEBUG) << "got SIP BYE " << *transaction; + if (!GSMClearedOrClearing) { + // Initiate clearing in the GSM side. + LCH->send(GSM::L3Disconnect(transaction->L3TI())); + transaction->setTimer("305"); + transaction->GSMState(GSM::DisconnectIndication); + } else { + // GSM already cleared? + // Ack the BYE and end the call. + transaction->MTDSendOK(); + } + } + + return transaction->SIPState()==SIP::Cleared; +} + + + +/** + Check SIP and GSM signalling. + Can block for up to 52 GSM L1 frames (240 ms) because LCH::send is blocking. + @param transaction The call's TransactionEntry. + @param LCH The call's logical channel (TCH/FACCH or SDCCH). + @return true If the call is cleared in both domains. +*/ +bool updateSignalling(TransactionEntry *transaction, GSM::LogicalChannel *LCH, unsigned timeout=0) +{ + + bool GSMCleared = (updateGSMSignalling(transaction,LCH,timeout)); + bool SIPCleared = updateSIPSignalling(transaction,LCH,GSMCleared); + return GSMCleared && SIPCleared; +} + + + + +/** + Poll for activity while in a call. + Sleep if needed to prevent fast spinning. + Will block for up to 250 ms. + @param transaction The call's TransactionEntry. + @param TCH The call's TCH+FACCH. + @return true If the call was cleared. +*/ +bool pollInCall(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel *TCH) +{ + // See if the radio link disappeared. + if (TCH->radioFailure()) { + LOG(NOTICE) << "radio link failure, dropped call"; + forceSIPClearing(transaction); + return true; + } + + // Process pending SIP and GSM signalling. + // If this returns true, it means the call is fully cleared. + if (updateSignalling(transaction,TCH)) return true; + + // Did an outside process request a termination? + if (transaction->terminationRequested()) { + // Cause 25 is "pre-emptive clearing". + abortCall(transaction,TCH,25); + // Do the hard release to short-cut the timers. + // If something else is requesting termination, + // it's probably because we need the channel for + // something else (like an emegency call) right away. + //TCH->send(GSM::HARDRELEASE); + return true; + } + + // Transfer vocoder data. + // If anything happened, then the call is still up. + if (updateCallTraffic(transaction,TCH)) return false; + + // If nothing happened, sleep so we don't burn up the CPU cycles. + msleep(50); + return false; +} + + +/** + Pause for a given time while managing the connection. + Returns on timeout or call clearing. + Used for debugging to simulate ringing at terminating end. + @param transaction The transaction record for the call. + @param TCH The TCH+FACCH sed for this call. + @param waitTime_ms The maximum time to wait, in ms. + @return true If the call is cleared during the wait. +*/ +bool waitInCall(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel *TCH, unsigned waitTime_ms) +{ + Timeval targetTime(waitTime_ms); + LOG(DEBUG); + while (!targetTime.passed()) { + if (pollInCall(transaction,TCH)) return true; + } + return false; +} + + + +/** + This is the standard call manangement loop, regardless of the origination type. + This function returns when the call is cleared and the channel is released. + @param transaction The transaction record for this call, will be cleared on exit. + @param TCH The TCH+FACCH for the call. +*/ +void callManagementLoop(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel* TCH) +{ + LOG(INFO) << " call connected " << *transaction; + // poll everything until the call is cleared + while (!pollInCall(transaction,TCH)) { } + gTransactionTable.remove(transaction); +} + + + + +/** + This function starts MOC on the SDCCH to the point of TCH assignment. + @param req The CM Service Request that started all of this. + @param LCH The logical used to initiate call setup. +*/ +void Control::MOCStarter(const GSM::L3CMServiceRequest* req, GSM::LogicalChannel *LCH) +{ + assert(LCH); + assert(req); + LOG(INFO) << *req; + + // Determine if very early assignment already happened. + bool veryEarly = (LCH->type()==GSM::FACCHType); + + // If we got a TMSI, find the IMSI. + // Note that this is a copy, not a reference. + GSM::L3MobileIdentity mobileID = req->mobileID(); + resolveIMSI(mobileID,LCH); + + + // FIXME -- At this point, verify the that subscriber has access to this service. + // If the subscriber isn't authorized, send a CM Service Reject with + // cause code, 0x41, "requested service option not subscribed", + // followed by a Channel Release with cause code 0x6f, "unspecified". + // Otherwise, proceed to the next section of code. + // For now, we are assuming that the phone won't make a call if it didn't + // get registered. + + // Allocate a TCH for the call, if we don't have it already. + GSM::TCHFACCHLogicalChannel *TCH = NULL; + if (!veryEarly) { + TCH = allocateTCH(dynamic_cast(LCH)); + // It's OK to just return on failure; allocateTCH cleaned up already, + // and the SIP side and transaction record don't exist yet. + if (TCH==NULL) return; + } + + // Let the phone know we're going ahead with the transaction. + LOG(INFO) << "sending CMServiceAccept"; + LCH->send(GSM::L3CMServiceAccept()); + + // Get the Setup message. + // GSM 04.08 5.2.1.2 + GSM::L3Message* msg_setup = getMessage(LCH); + const GSM::L3Setup *setup = dynamic_cast(msg_setup); + if (!setup) { + if (msg_setup) { + LOG(WARNING) << "Unexpected message " << *msg_setup; + delete msg_setup; + } + throw UnexpectedMessage(); + } + LOG(INFO) << *setup; + // Pull out the L3 short transaction information now. + // See GSM 04.07 11.2.3.1.3. + // Set the high bit, since this TI came from the MS. + unsigned L3TI = setup->TI() | 0x08; + if (!setup->haveCalledPartyBCDNumber()) { + // FIXME -- This is quick-and-dirty, not following GSM 04.08 5. + LOG(WARNING) << "MOC setup with no number"; + // Cause 0x60 "Invalid mandatory information" + LCH->send(GSM::L3ReleaseComplete(L3TI,0x60)); + LCH->send(GSM::L3ChannelRelease()); + // The SIP side and transaction record don't exist yet. + // So we're done. + delete msg_setup; + return; + } + + LOG(DEBUG) << "SIP start engine"; + // Get the users sip_uri by pulling out the IMSI. + //const char *IMSI = mobileID.digits(); + // Pull out Number user is trying to call and use as the sip_uri. + const char *bcdDigits = setup->calledPartyBCDNumber().digits(); + + // Create a transaction table entry so the TCH controller knows what to do later. + // The transaction on the TCH will be a continuation of this one. + TransactionEntry *transaction = new TransactionEntry( + gConfig.getStr("SIP.Proxy.Speech").c_str(), + mobileID, + LCH, + req->serviceType(), + L3TI, + setup->calledPartyBCDNumber()); + LOG(DEBUG) << "transaction: " << *transaction; + gTransactionTable.add(transaction); + + // At this point, we have enough information start the SIP call setup. + // We also have a SIP side and a transaction that will need to be + // cleaned up on abort or clearing. + + // Now start a call by contacting asterisk. + // Engine methods will return their current state. + // The remote party will start ringing soon. + LOG(DEBUG) << "starting SIP (INVITE) Calling "<MOCSendINVITE(bcdDigits,gConfig.getStr("SIP.Local.IP").c_str(),basePort,SIP::RTPGSM610); + LOG(DEBUG) << "transaction: " << *transaction; + + // Once we can start SIP call setup, send Call Proceeding. + LOG(INFO) << "Sending Call Proceeding"; + LCH->send(GSM::L3CallProceeding(L3TI)); + transaction->GSMState(GSM::MOCProceeding); + // Finally done with the Setup message. + delete msg_setup; + + // The transaction is moving on to the MOCController. + // If we need a TCH assignment, we do it here. + LOG(DEBUG) << "transaction: " << *transaction; + if (veryEarly) { + // For very early assignment, we need a mode change. + static const GSM::L3ChannelMode mode(GSM::L3ChannelMode::SpeechV1); + LCH->send(GSM::L3ChannelModeModify(LCH->channelDescription(),mode)); + GSM::L3Message *msg_ack = getMessage(LCH); + const GSM::L3ChannelModeModifyAcknowledge *ack = + dynamic_cast(msg_ack); + if (!ack) { + if (msg_ack) { + LOG(WARNING) << "Unexpected message " << *msg_ack; + delete msg_ack; + } + throw UnexpectedMessage(transaction->ID()); + } + // Cause 0x06 is "channel unacceptable" + bool modeOK = (ack->mode()==mode); + delete msg_ack; + if (!modeOK) return abortAndRemoveCall(transaction,LCH,GSM::L3Cause(0x06)); + MOCController(transaction,dynamic_cast(LCH)); + } else { + // For late assignment, send the TCH assignment now. + // This dispatcher on the next channel will continue the transaction. + assignTCHF(transaction,LCH,TCH); + } +} + + + + + +/** + Continue MOC process on the TCH. + @param transaction The call state and SIP interface. + @param TCH The traffic channel to be used. +*/ +void Control::MOCController(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel* TCH) +{ + LOG(DEBUG) << "transaction: " << *transaction; + unsigned L3TI = transaction->L3TI(); + assert(L3TI>7); + assert(TCH); + + + // Look for RINGING or OK from the SIP side. + // There's a T310 running on the phone now. + // The phone will initiate clearing if it expires. + // FIXME -- We should also have a SIP.Timer.B timeout on this end. + while (transaction->GSMState()!=GSM::CallReceived) { + + if (updateGSMSignalling(transaction,TCH)) return; + if (transaction->clearingGSM()) return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + + LOG(INFO) << "wait for Ringing or OK"; + SIP::SIPState state = transaction->MOCWaitForOK(); + LOG(DEBUG) << "SIP state="<send(GSM::L3Alerting(L3TI)); + transaction->GSMState(GSM::CallReceived); + break; + case SIP::Active: + LOG(DEBUG) << "SIP:Active, move on"; + transaction->GSMState(GSM::CallReceived); + break; + case SIP::Proceeding: + LOG(DEBUG) << "SIP:Proceeding, send progress"; + TCH->send(GSM::L3Progress(L3TI)); + break; + case SIP::Timeout: + LOG(NOTICE) << "SIP:Timeout, reinvite"; + state = transaction->MOCResendINVITE(); + break; + default: + LOG(NOTICE) << "SIP unexpected state " << state; + break; + } + } + + // There's a question here of what entity is generating the "patterns" + // (ringing, busy signal, etc.) during call set-up. For now, we're ignoring + // that question and hoping the phone will make its own ringing pattern. + + + // Wait for the SIP session to start. + // There's a timer on the phone that will initiate clearing if it expires. + LOG(INFO) << "wait for SIP OKAY"; + SIP::SIPState state = transaction->SIPState(); + while (state!=SIP::Active) { + + LOG(DEBUG) << "wait for SIP session start"; + state = transaction->MOCWaitForOK(); + LOG(DEBUG) << "SIP state "<< state; + + // check GSM state + if (updateGSMSignalling(transaction,TCH)) return; + if (transaction->clearingGSM()) return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + + // parse out SIP state + switch (state) { + case SIP::Busy: + // Should this be possible at this point? + LOG(INFO) << "SIP:Busy, abort"; + return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x11)); + case SIP::Fail: + LOG(INFO) << "SIP:Fail, abort"; + return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + case SIP::Proceeding: + LOG(DEBUG) << "SIP:Proceeding, NOT sending progress"; + //TCH->send(GSM::L3Progress(L3TI)); + break; + // For these cases, do nothing. + case SIP::Timeout: + // FIXME We should abort if this happens too often. + // For now, we are relying on the phone, which may have bugs of its own. + case SIP::Active: + default: + break; + } + } + + // Let the phone know the call is connected. + LOG(INFO) << "sending Connect to handset"; + TCH->send(GSM::L3Connect(L3TI)); + transaction->setTimer("313"); + transaction->GSMState(GSM::ConnectIndication); + + // The call is open. + transaction->MOCInitRTP(); + transaction->MOCSendACK(); + + // FIXME -- We need to watch for a repeated OK in case the ACK got lost. + + // Get the Connect Acknowledge message. + while (transaction->GSMState()!=GSM::Active) { + LOG(DEBUG) << "MOC Q.931 state=" << transaction->GSMState(); + if (updateGSMSignalling(transaction,TCH,T313ms)) return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + } + + // At this point, everything is ready to run the call. + callManagementLoop(transaction,TCH); + + // The radio link should have been cleared with the call. + // So just return. +} + + + + +void Control::MTCStarter(TransactionEntry *transaction, GSM::LogicalChannel *LCH) +{ + assert(LCH); + LOG(INFO) << "MTC on " << LCH->type() << " transaction: "<< *transaction; + + // Determine if very early assigment already happened. + bool veryEarly = false; + if (LCH->type()==GSM::FACCHType) veryEarly=true; + + // Allocate a TCH for the call. + GSM::TCHFACCHLogicalChannel *TCH = NULL; + if (!veryEarly) { + TCH = allocateTCH(dynamic_cast(LCH)); + // It's OK to just return on failure; allocateTCH cleaned up already. + // The orphaned transaction will be cleared automatically later. + if (TCH==NULL) return; + } + + + // Get transaction identifiers. + // This transaction was created by the SIPInterface when it + // processed the INVITE that started this call. + unsigned L3TI = transaction->L3TI(); + assert(L3TI<7); + + // GSM 04.08 5.2.2.1 + LOG(INFO) << "sending GSM Setup to call " << transaction->calling(); + LCH->send(GSM::L3Setup(L3TI,GSM::L3CallingPartyBCDNumber(transaction->calling()))); + transaction->setTimer("303"); + transaction->GSMState(GSM::CallPresent); + + // Wait for Call Confirmed message. + LOG(DEBUG) << "wait for GSM Call Confirmed"; + while (transaction->GSMState()!=GSM::MTCConfirmed) { + if (transaction->MTCSendTrying()==SIP::Fail) { + LOG(NOTICE) << "call failed on SIP side"; + LCH->send(GSM::RELEASE); + // Cause 0x03 is "no route to destination" + return abortAndRemoveCall(transaction,LCH,GSM::L3Cause(0x03)); + } + // FIXME -- What's the proper timeout here? + // It's the SIP TRYING timeout, whatever that is. + if (updateGSMSignalling(transaction,LCH,1000)) { + LOG(INFO) << "Release from GSM side"; + LCH->send(GSM::RELEASE); + return; + } + // Check for SIP cancel, too. + if (transaction->MTCCheckForCancel()==SIP::Fail) { + LOG(NOTICE) << "call cancelled or failed on SIP side"; + // Cause 0x15 is "rejected" + return abortAndRemoveCall(transaction,LCH,GSM::L3Cause(0x15)); + } + } + + // The transaction is moving to the MTCController. + // Once this update happens, don't change the transaction object again in this function. + LOG(DEBUG) << "transaction: " << *transaction; + if (veryEarly) { + // For very early assignment, we need a mode change. + static const GSM::L3ChannelMode mode(GSM::L3ChannelMode::SpeechV1); + LCH->send(GSM::L3ChannelModeModify(LCH->channelDescription(),mode)); + GSM::L3Message* msg_ack = getMessage(LCH); + const GSM::L3ChannelModeModifyAcknowledge *ack = + dynamic_cast(msg_ack); + if (!ack) { + if (msg_ack) { + LOG(WARNING) << "Unexpected message " << *msg_ack; + delete msg_ack; + } + throw UnexpectedMessage(transaction->ID()); + } + // Cause 0x06 is "channel unacceptable" + bool modeOK = (ack->mode()==mode); + delete msg_ack; + if (!modeOK) return abortAndRemoveCall(transaction,LCH,GSM::L3Cause(0x06)); + MTCController(transaction,dynamic_cast(LCH)); + } + else { + // For late assignment, send the TCH assignment now. + // This dispatcher on the next channel will continue the transaction. + assignTCHF(transaction,LCH,TCH); + } +} + + +void Control::MTCController(TransactionEntry *transaction, GSM::TCHFACCHLogicalChannel* TCH) +{ + // Early Assignment Mobile Terminated Call. + // Transaction table in 04.08 7.3.3 figure 7.10a + + LOG(DEBUG) << "transaction: " << *transaction; + unsigned L3TI = transaction->L3TI(); + assert(L3TI<7); + assert(TCH); + + // Get the alerting message. + LOG(INFO) << "waiting for GSM Alerting and Connect"; + while (transaction->GSMState()!=GSM::Active) { + if (updateGSMSignalling(transaction,TCH,1000)) return; + if (transaction->GSMState()==GSM::Active) break; + if (transaction->GSMState()==GSM::CallReceived) { + LOG(DEBUG) << "sending SIP Ringing"; + transaction->MTCSendRinging(); + } + // Check for SIP cancel, too. + if (transaction->MTCCheckForCancel()==SIP::Fail) { + LOG(DEBUG) << "MTCCheckForCancel return Fail"; + return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + } + } + + // FIXME -- We should also have a SIP.Timer.F timeout here. + LOG(INFO) << "allocating port and sending SIP OKAY"; + unsigned RTPPorts = allocateRTPPorts(); + SIP::SIPState state = transaction->MTCSendOK(RTPPorts,SIP::RTPGSM610); + while (state!=SIP::Active) { + LOG(DEBUG) << "wait for SIP OKAY-ACK"; + if (updateGSMSignalling(transaction,TCH)) return; + state = transaction->MTCWaitForACK(); + LOG(DEBUG) << "SIP call state "<< state; + switch (state) { + case SIP::Active: + break; + case SIP::Fail: + return abortAndRemoveCall(transaction,TCH,GSM::L3Cause(0x7F)); + case SIP::Timeout: + state = transaction->MTCSendOK(RTPPorts,SIP::RTPGSM610); + break; + case SIP::Connecting: + break; + default: + LOG(NOTICE) << "SIP unexpected state " << state; + break; + } + } + transaction->MTCInitRTP(); + + // Send Connect Ack to make it all official. + LOG(DEBUG) << "MTC send GSM Connect Acknowledge"; + TCH->send(GSM::L3ConnectAcknowledge(L3TI)); + + // At this point, everything is ready to run for the call. + // The radio link should have been cleared with the call. + callManagementLoop(transaction,TCH); +} + + + + + + + +void Control::initiateMTTransaction(TransactionEntry *transaction, GSM::ChannelType chanType, unsigned pageTime) +{ + gTransactionTable.add(transaction); + transaction->GSMState(GSM::Paging); + gBTS.pager().addID(transaction->subscriber(),chanType,*transaction,pageTime); +} + + + + + +// vim: ts=4 sw=4 diff --git a/Control/CallControl.h b/Control/CallControl.h new file mode 100644 index 0000000..06db4ec --- /dev/null +++ b/Control/CallControl.h @@ -0,0 +1,67 @@ +/**@file GSM/SIP Call Control -- GSM 04.08, ISDN ITU-T Q.931, SIP IETF RFC-3261, RTP IETF RFC-3550. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +#ifndef CALLCONTROL_H +#define CALLCONTROL_H + + +namespace GSM { +class LogicalChannel; +class TCHFACCHLogicalChannel; +class L3CMServiceRequest; +}; + +namespace Control { + +class TransactionEntry; + + + +/**@name MOC */ +//@{ +/** Run the MOC to the point of alerting, doing early assignment if needed. */ +void MOCStarter(const GSM::L3CMServiceRequest*, GSM::LogicalChannel*); +/** Complete the MOC connection. */ +void MOCController(TransactionEntry*, GSM::TCHFACCHLogicalChannel*); +/** Set up an emergency call, assuming very early assignment. */ +void EmergencyCall(const GSM::L3CMServiceRequest*, GSM::LogicalChannel*); +//@} + + +/**@name MTC */ +//@{ +/** Run the MTC to the point of alerting, doing early assignment if needed. */ +void MTCStarter(TransactionEntry*, GSM::LogicalChannel*); +/** Complete the MTC connection. */ +void MTCController(TransactionEntry*, GSM::TCHFACCHLogicalChannel*); +//@} + + +/**@name Test Call */ +//@{ +/** Run the test call. */ +void TestCall(TransactionEntry*, GSM::LogicalChannel*); +//@} + +/** Create a new transaction entry and start paging. */ +void initiateMTTransaction(TransactionEntry* transaction, + GSM::ChannelType chanType, unsigned pageTime); + + +} + + +#endif diff --git a/Control/ControlCommon.cpp b/Control/ControlCommon.cpp new file mode 100644 index 0000000..2c0e2c6 --- /dev/null +++ b/Control/ControlCommon.cpp @@ -0,0 +1,180 @@ +/**@file Common-use functions for the control layer. */ + +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "ControlCommon.h" +#include "TransactionTable.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#undef WARNING + + +using namespace std; +using namespace GSM; +using namespace Control; + + + + + +// FIXME -- getMessage should return an L3Frame, not an L3Message. +// This will mean moving all of the parsing into the control layer. +// FIXME -- This needs an adjustable timeout. + +L3Message* Control::getMessage(LogicalChannel *LCH, unsigned SAPI) +{ + unsigned timeout_ms = LCH->N200() * T200ms; + L3Frame *rcv = LCH->recv(timeout_ms,SAPI); + if (rcv==NULL) { + LOG(NOTICE) << "timeout"; + throw ChannelReadTimeout(); + } + LOG(DEBUG) << "received " << *rcv; + Primitive primitive = rcv->primitive(); + if (primitive!=DATA) { + LOG(NOTICE) << "unexpected primitive " << primitive; + delete rcv; + throw UnexpectedPrimitive(); + } + L3Message *msg = parseL3(*rcv); + delete rcv; + if (msg==NULL) { + LOG(NOTICE) << "unparsed message"; + throw UnsupportedMessage(); + } + return msg; +} + + + + + + +/* Resolve a mobile ID to an IMSI and return TMSI if it is assigned. */ +unsigned Control::resolveIMSI(bool sameLAI, L3MobileIdentity& mobileID, LogicalChannel* LCH) +{ + // Returns known or assigned TMSI. + assert(LCH); + LOG(DEBUG) << "resolving mobile ID " << mobileID << ", sameLAI: " << sameLAI; + + // IMSI already? See if there's a TMSI already, too. + if (mobileID.type()==IMSIType) return gTMSITable.TMSI(mobileID.digits()); + + // IMEI? WTF?! + // FIXME -- Should send MM Reject, cause 0x60, "invalid mandatory information". + if (mobileID.type()==IMEIType) throw UnexpectedMessage(); + + // Must be a TMSI. + // Look in the table to see if it's one we assigned. + unsigned TMSI = mobileID.TMSI(); + char* IMSI = NULL; + if (sameLAI) IMSI = gTMSITable.IMSI(TMSI); + if (IMSI) { + // We assigned this TMSI already; the TMSI/IMSI pair is already in the table. + mobileID = L3MobileIdentity(IMSI); + LOG(DEBUG) << "resolving mobile ID (table): " << mobileID; + free(IMSI); + return TMSI; + } + // Not our TMSI. + // Phones are not supposed to do this, but many will. + // If the IMSI's not in the table, ASK for it. + LCH->send(L3IdentityRequest(IMSIType)); + // FIXME -- This request times out on T3260, 12 sec. See GSM 04.08 Table 11.2. + L3Message* msg = getMessage(LCH); + L3IdentityResponse *resp = dynamic_cast(msg); + if (!resp) { + if (msg) delete msg; + throw UnexpectedMessage(); + } + mobileID = resp->mobileID(); + LOG(INFO) << resp; + delete msg; + LOG(DEBUG) << "resolving mobile ID (requested): " << mobileID; + // FIXME -- Should send MM Reject, cause 0x60, "invalid mandatory information". + if (mobileID.type()!=IMSIType) throw UnexpectedMessage(); + // Return 0 to indicate that we have not yet assigned our own TMSI for this phone. + return 0; +} + + + +/* Resolve a mobile ID to an IMSI. */ +void Control::resolveIMSI(L3MobileIdentity& mobileIdentity, LogicalChannel* LCH) +{ + // Are we done already? + if (mobileIdentity.type()==IMSIType) return; + + // If we got a TMSI, find the IMSI. + if (mobileIdentity.type()==TMSIType) { + char *IMSI = gTMSITable.IMSI(mobileIdentity.TMSI()); + if (IMSI) mobileIdentity = L3MobileIdentity(IMSI); + free(IMSI); + } + + // Still no IMSI? Ask for one. + if (mobileIdentity.type()!=IMSIType) { + LOG(NOTICE) << "MOC with no IMSI or valid TMSI. Reqesting IMSI."; + LCH->send(L3IdentityRequest(IMSIType)); + // FIXME -- This request times out on T3260, 12 sec. See GSM 04.08 Table 11.2. + L3Message* msg = getMessage(LCH); + L3IdentityResponse *resp = dynamic_cast(msg); + if (!resp) { + if (msg) delete msg; + throw UnexpectedMessage(); + } + mobileIdentity = resp->mobileID(); + delete msg; + } + + // Still no IMSI?? + if (mobileIdentity.type()!=IMSIType) { + // FIXME -- This is quick-and-dirty, not following GSM 04.08 5. + LOG(WARNING) << "MOC setup with no IMSI"; + // Cause 0x60 "Invalid mandatory information" + LCH->send(L3CMServiceReject(L3RejectCause(0x60))); + LCH->send(L3ChannelRelease()); + // The SIP side and transaction record don't exist yet. + // So we're done. + return; + } +} + + + + + +// vim: ts=4 sw=4 diff --git a/Control/ControlCommon.h b/Control/ControlCommon.h new file mode 100644 index 0000000..5ea276f --- /dev/null +++ b/Control/ControlCommon.h @@ -0,0 +1,219 @@ +/**@file Declarations for common-use control-layer functions. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef CONTROLCOMMON_H +#define CONTROLCOMMON_H + + +#include +#include + +#include +#include +#include + + +#include +#include +#include +#include +#include + +#include "TMSITable.h" + + +// Enough forward refs to prevent "kitchen sick" includes and circularity. + +namespace GSM { +class L3Message; +class LogicalChannel; +class SDCCHLogicalChannel; +class SACCHLogicalChannel; +class TCHFACCHLogicalChannel; +class L3CMServiceRequest; +}; + + +/**@namespace Control This namepace is for use by the control layer. */ +namespace Control { + +class TransactionEntry; +class TransactionTable; + +/**@name Call control time-out values (in ms) from ITU-T Q.931 Table 9-1 and GSM 04.08 Table 11.4. */ +//@{ +#ifndef RACETEST +const unsigned T301ms=60000; ///< recv ALERT --> recv CONN +const unsigned T302ms=12000; ///< send SETUP ACK --> any progress +const unsigned T303ms=10000; ///< send SETUP --> recv CALL CONF or REL COMP +const unsigned T304ms=20000; ///< recv SETUP ACK --> any progress +const unsigned T305ms=30000; ///< send DISC --> recv REL or DISC +const unsigned T308ms=30000; ///< send REL --> rev REL or REL COMP +const unsigned T310ms=30000; ///< recv CALL CONF --> recv ALERT, CONN, or DISC +const unsigned T313ms=30000; ///< send CONNECT --> recv CONNECT ACK +#else +// These are reduced values to force testing of poor network behavior. +const unsigned T301ms=18000; ///< recv ALERT --> recv CONN +const unsigned T302ms=1200; ///< send SETUP ACK --> any progress +const unsigned T303ms=400; ///< send SETUP --> recv CALL CONF or REL COMP +const unsigned T304ms=2000; ///< recv SETUP ACK --> any progress +const unsigned T305ms=3000; ///< send DISC --> recv REL or DISC +const unsigned T308ms=3000; ///< send REL --> rev REL or REL COMP +const unsigned T310ms=3000; ///< recv CALL CONF --> recv ALERT, CONN, or DISC +const unsigned T313ms=3000; ///< send CONNECT --> recv CONNECT ACK +#endif +//@} + + + + +/**@name Common-use functions from the control layer. */ +//@{ + +/** + Get a message from a LogicalChannel. + Close the channel with abnormal release on timeout. + Caller must delete the returned pointer. + Throws ChannelReadTimeout, UnexpecedPrimitive or UnsupportedMessage on timeout. + @param LCH The channel to receive on. + @param SAPI The service access point. + @return Pointer to message. +*/ +// FIXME -- This needs an adjustable timeout. +GSM::L3Message* getMessage(GSM::LogicalChannel* LCH, unsigned SAPI=0); + + +//@} + + +/**@name Dispatch controllers for specific channel types. */ +//@{ +void FACCHDispatcher(GSM::TCHFACCHLogicalChannel *TCHFACCH); +void SDCCHDispatcher(GSM::SDCCHLogicalChannel *SDCCH); +void DCCHDispatcher(GSM::LogicalChannel *DCCH); +//@} + + + +/** + Resolve a mobile ID to an IMSI. + Returns TMSI, if it is already in the TMSITable. + @param sameLAI True if the mobileID is known to have come from this LAI. + @param mobID A mobile ID, that may be modified by the function. + @param LCH The Dm channel to the mobile. + @return A TMSI value from the TMSITable or zero if non found. +*/ +unsigned resolveIMSI(bool sameLAI, GSM::L3MobileIdentity& mobID, GSM::LogicalChannel* LCH); + +/** + Resolve a mobile ID to an IMSI. + @param mobID A mobile ID, that may be modified by the function. + @param LCH The Dm channel to the mobile. +*/ +void resolveIMSI(GSM::L3MobileIdentity& mobID, GSM::LogicalChannel* LCH); + + + + + + + +/**@name Control-layer exceptions. */ +//@{ + +/** + A control layer excpection includes a pointer to a transaction. + The transaction might require some clean-up action, depending on the exception. +*/ +class ControlLayerException { + + private: + + unsigned mTransactionID; + + public: + + ControlLayerException(unsigned wTransactionID=0) + :mTransactionID(wTransactionID) + {} + + unsigned transactionID() { return mTransactionID; } +}; + +/** Thrown when the control layer gets the wrong message */ +class UnexpectedMessage : public ControlLayerException { + public: + UnexpectedMessage(unsigned wTransactionID=0) + :ControlLayerException(wTransactionID) + {} +}; + +/** Thrown when recvL3 returns NULL */ +class ChannelReadTimeout : public ControlLayerException { + public: + ChannelReadTimeout(unsigned wTransactionID=0) + :ControlLayerException(wTransactionID) + {} +}; + +/** Thrown when L3 can't parse an incoming message */ +class UnsupportedMessage : public ControlLayerException { + public: + UnsupportedMessage(unsigned wTransactionID=0) + :ControlLayerException(wTransactionID) + {} +}; + +/** Thrown when the control layer gets the wrong primitive */ +class UnexpectedPrimitive : public ControlLayerException { + public: + UnexpectedPrimitive(unsigned wTransactionID=0) + :ControlLayerException(wTransactionID) + {} +}; + +/** Thrown when a T3xx expires */ +class Q931TimerExpired : public ControlLayerException { + public: + Q931TimerExpired(unsigned wTransactionID=0) + :ControlLayerException(wTransactionID) + {} +}; + + +//@} + + +} //Control + + + +/**@addtogroup Globals */ +//@{ +/** A single global transaction table in the global namespace. */ +extern Control::TransactionTable gTransactionTable; +//@} + + + +#endif + +// vim: ts=4 sw=4 diff --git a/Control/DCCHDispatch.cpp b/Control/DCCHDispatch.cpp new file mode 100644 index 0000000..ee72496 --- /dev/null +++ b/Control/DCCHDispatch.cpp @@ -0,0 +1,192 @@ +/**@file Idle-mode dispatcher for dedicated control channels. */ + +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "ControlCommon.h" +#include "TransactionTable.h" +#include "RadioResource.h" +#include "MobilityManagement.h" +#include +#include +#include +#include +#include + +#include +#undef WARNING + +using namespace std; +using namespace GSM; +using namespace Control; + + + + +/** + Dispatch the appropriate controller for a Mobility Management message. + @param req A pointer to the initial message. + @param DCCH A pointer to the logical channel for the transaction. +*/ +void DCCHDispatchMM(const L3MMMessage* req, LogicalChannel *DCCH) +{ + assert(req); + L3MMMessage::MessageType MTI = (L3MMMessage::MessageType)req->MTI(); + switch (MTI) { + case L3MMMessage::LocationUpdatingRequest: + LocationUpdatingController(dynamic_cast(req),DCCH); + break; + case L3MMMessage::IMSIDetachIndication: + IMSIDetachController(dynamic_cast(req),DCCH); + break; + case L3MMMessage::CMServiceRequest: + CMServiceResponder(dynamic_cast(req),DCCH); + break; + default: + LOG(NOTICE) << "unhandled MM message " << MTI << " on " << *DCCH; + throw UnsupportedMessage(); + } +} + + +/** + Dispatch the appropriate controller for a Radio Resource message. + @param req A pointer to the initial message. + @param DCCH A pointer to the logical channel for the transaction. +*/ +void DCCHDispatchRR(const L3RRMessage* req, LogicalChannel *DCCH) +{ + LOG(DEBUG) << "checking MTI"<< (L3RRMessage::MessageType)req->MTI(); + + // TODO SMS -- This needs to handle SACCH Measurement Reports. + + assert(req); + L3RRMessage::MessageType MTI = (L3RRMessage::MessageType)req->MTI(); + switch (MTI) { + case L3RRMessage::PagingResponse: + PagingResponseHandler(dynamic_cast(req),DCCH); + break; + case L3RRMessage::AssignmentComplete: + AssignmentCompleteHandler(dynamic_cast(req), + dynamic_cast(DCCH)); + break; + default: + LOG(NOTICE) << "unhandled RR message " << MTI << " on " << *DCCH; + throw UnsupportedMessage(); + } +} + + +void DCCHDispatchMessage(const L3Message* msg, LogicalChannel* DCCH) +{ + // Each protocol has it's own sub-dispatcher. + switch (msg->PD()) { + case L3MobilityManagementPD: + DCCHDispatchMM(dynamic_cast(msg),DCCH); + break; + case L3RadioResourcePD: + DCCHDispatchRR(dynamic_cast(msg),DCCH); + break; + default: + LOG(NOTICE) << "unhandled protocol " << msg->PD() << " on " << *DCCH; + throw UnsupportedMessage(); + } +} + + + + +/** Example of a closed-loop, persistent-thread control function for the DCCH. */ +void Control::DCCHDispatcher(LogicalChannel *DCCH) +{ + while (1) { + try { + // Wait for a transaction to start. + LOG(DEBUG) << "waiting for " << *DCCH << " ESTABLISH"; + DCCH->waitForPrimitive(ESTABLISH); + // Pull the first message and dispatch a new transaction. + const L3Message *message = getMessage(DCCH); + LOG(DEBUG) << *DCCH << " received " << *message; + DCCHDispatchMessage(message,DCCH); + delete message; + } + + // Catch the various error cases. + + catch (ChannelReadTimeout except) { + LOG(NOTICE) << "ChannelReadTimeout"; + // Cause 0x03 means "abnormal release, timer expired". + DCCH->send(L3ChannelRelease(0x03)); + gTransactionTable.remove(except.transactionID()); + } + catch (UnexpectedPrimitive except) { + LOG(NOTICE) << "UnexpectedPrimitive"; + // Cause 0x62 means "message type not not compatible with protocol state". + DCCH->send(L3ChannelRelease(0x62)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + catch (UnexpectedMessage except) { + LOG(NOTICE) << "UnexpectedMessage"; + // Cause 0x62 means "message type not not compatible with protocol state". + DCCH->send(L3ChannelRelease(0x62)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + catch (UnsupportedMessage except) { + LOG(NOTICE) << "UnsupportedMessage"; + // Cause 0x61 means "message type not implemented". + DCCH->send(L3ChannelRelease(0x61)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + catch (Q931TimerExpired except) { + LOG(NOTICE) << "Q.931 T3xx timer expired"; + // Cause 0x03 means "abnormal release, timer expired". + // TODO -- Send diagnostics. + DCCH->send(L3ChannelRelease(0x03)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + catch (SIP::SIPTimeout except) { + // FIXME -- The transaction ID should be an argument here. + LOG(WARNING) << "Uncaught SIPTimeout, will leave a stray transcation"; + // Cause 0x03 means "abnormal release, timer expired". + DCCH->send(L3ChannelRelease(0x03)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + catch (SIP::SIPError except) { + // FIXME -- The transaction ID should be an argument here. + LOG(WARNING) << "Uncaught SIPError, will leave a stray transcation"; + // Cause 0x01 means "abnormal release, unspecified". + DCCH->send(L3ChannelRelease(0x01)); + if (except.transactionID()) gTransactionTable.remove(except.transactionID()); + } + } +} + + + + +// vim: ts=4 sw=4 diff --git a/Control/Makefile.am b/Control/Makefile.am new file mode 100644 index 0000000..17ff70a --- /dev/null +++ b/Control/Makefile.am @@ -0,0 +1,51 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2010 Kestrel Signal Processing, Inc. +# Copyright 2011 Range Networks, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall + +EXTRA_DIST = README.Control + +noinst_LTLIBRARIES = libcontrol.la + +libcontrol_la_SOURCES = \ + TransactionTable.cpp \ + TMSITable.cpp \ + CallControl.cpp \ + SMSControl.cpp \ + ControlCommon.cpp \ + MobilityManagement.cpp \ + RadioResource.cpp \ + DCCHDispatch.cpp + + +noinst_HEADERS = \ + ControlCommon.h \ + SMSControl.h \ + TransactionTable.h \ + TMSITable.h \ + RadioResource.h \ + MobilityManagement.h \ + CallControl.h \ + TMSITable.h diff --git a/Control/Makefile.in b/Control/Makefile.in new file mode 100644 index 0000000..ba4dfda --- /dev/null +++ b/Control/Makefile.in @@ -0,0 +1,554 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2010 Kestrel Signal Processing, Inc. +# Copyright 2011 Range Networks, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libcontrol_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = Control +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libcontrol_la_LIBADD = +am_libcontrol_la_OBJECTS = TransactionTable.lo TMSITable.lo \ + CallControl.lo SMSControl.lo ControlCommon.lo \ + MobilityManagement.lo RadioResource.lo DCCHDispatch.lo +libcontrol_la_OBJECTS = $(am_libcontrol_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libcontrol_la_SOURCES) +DIST_SOURCES = $(libcontrol_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall +EXTRA_DIST = README.Control +noinst_LTLIBRARIES = libcontrol.la +libcontrol_la_SOURCES = \ + TransactionTable.cpp \ + TMSITable.cpp \ + CallControl.cpp \ + SMSControl.cpp \ + ControlCommon.cpp \ + MobilityManagement.cpp \ + RadioResource.cpp \ + DCCHDispatch.cpp + +noinst_HEADERS = \ + ControlCommon.h \ + SMSControl.h \ + TransactionTable.h \ + TMSITable.h \ + RadioResource.h \ + MobilityManagement.h \ + CallControl.h \ + TMSITable.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Control/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Control/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libcontrol.la: $(libcontrol_la_OBJECTS) $(libcontrol_la_DEPENDENCIES) + $(CXXLINK) $(libcontrol_la_LDFLAGS) $(libcontrol_la_OBJECTS) $(libcontrol_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CallControl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ControlCommon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DCCHDispatch.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MobilityManagement.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RadioResource.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SMSControl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TMSITable.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TransactionTable.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/Control/MobilityManagement.cpp b/Control/MobilityManagement.cpp new file mode 100644 index 0000000..468297e --- /dev/null +++ b/Control/MobilityManagement.cpp @@ -0,0 +1,558 @@ +/**@file GSM/SIP Mobility Management, GSM 04.08. */ +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include + +#include "ControlCommon.h" +#include "MobilityManagement.h" +#include "SMSControl.h" +#include "CallControl.h" + +#include +#include +#include +#include +#include + +using namespace std; + +#include +#include +#include +#include +#include + +using namespace SIP; + +#include +#include +#undef WARNING + + +using namespace GSM; +using namespace Control; + + +/** Controller for CM Service requests, dispatches out to multiple possible transaction controllers. */ +void Control::CMServiceResponder(const L3CMServiceRequest* cmsrq, LogicalChannel* DCCH) +{ + assert(cmsrq); + assert(DCCH); + LOG(INFO) << *cmsrq; + switch (cmsrq->serviceType().type()) { + case L3CMServiceType::MobileOriginatedCall: + MOCStarter(cmsrq,DCCH); + break; + case L3CMServiceType::ShortMessage: + MOSMSController(cmsrq,DCCH); + break; + default: + LOG(NOTICE) << "service not supported for " << *cmsrq; + // Cause 0x20 means "serivce not supported". + DCCH->send(L3CMServiceReject(0x20)); + DCCH->send(L3ChannelRelease()); + } + // The transaction may or may not be cleared, + // depending on the assignment type. +} + + + + +/** Controller for the IMSI Detach transaction, GSM 04.08 4.3.4. */ +void Control::IMSIDetachController(const L3IMSIDetachIndication* idi, LogicalChannel* DCCH) +{ + assert(idi); + assert(DCCH); + LOG(INFO) << *idi; + + // The IMSI detach maps to a SIP unregister with the local Asterisk server. + try { + // FIXME -- Resolve TMSIs to IMSIs. + if (idi->mobileID().type()==IMSIType) { + SIPEngine engine(gConfig.getStr("SIP.Proxy.Registration").c_str(), idi->mobileID().digits()); + engine.unregister(); + } + } + catch(SIPTimeout) { + LOG(ALERT) "SIP registration timed out. Is Asterisk running?"; + } + // No reponse required, so just close the channel. + DCCH->send(L3ChannelRelease()); + // Many handsets never complete the transaction. + // So force a shutdown of the channel. + DCCH->send(HARDRELEASE); +} + + + + +/** + Send a given welcome message from a given short code. + @return true if it was sent +*/ +bool sendWelcomeMessage(const char* messageName, const char* shortCodeName, const char *IMSI, LogicalChannel* DCCH, const char *whiteListCode = NULL) +{ + if (!gConfig.defines(messageName)) return false; + LOG(INFO) << "sending " << messageName << " message to handset"; + ostringstream message; + message << gConfig.getStr(messageName) << " IMSI:" << IMSI; + if (whiteListCode) { + message << ", white-list code: " << whiteListCode; + } + // This returns when delivery is acked in L3. + deliverSMSToMS( + gConfig.getStr(shortCodeName).c_str(), + message.str().c_str(), "text/plain", + random()%7,DCCH); + return true; +} + + + +class RRLPServer +{ + public: + RRLPServer(L3MobileIdentity wMobileID, LogicalChannel *wDCCH); + // tell server to send location assistance to mobile + bool assist(); + // tell server to ask mobile for location + bool locate(); + private: + RRLPServer(); // not allowed + string url; + L3MobileIdentity mobileID; + LogicalChannel *DCCH; + string query; + string name; + bool transact(); + bool trouble; +}; + +RRLPServer::RRLPServer(L3MobileIdentity wMobileID, LogicalChannel *wDCCH) +{ + trouble = false; + url = gConfig.getStr("GSM.RRLP.SERVER.URL", ""); + if (url.length() == 0) { + LOG(INFO) << "RRLP not configured"; + trouble = true; + return; + } + mobileID = wMobileID; + DCCH = wDCCH; + // name of subscriber + name = string("IMSI") + mobileID.digits(); + // don't continue if IMSI has a RRLP support flag and it's false + unsigned int supported = 0; + if (sqlite3_single_lookup(gSubscriberRegistry.db(), "sip_buddies", "name", name.c_str(), + "RRLPSupported", supported) && !supported) { + LOG(INFO) << "RRLP not supported for " << name; + trouble = true; + } +} + +bool RRLPServer::assist() +{ + if (trouble) return false; + query = "query=assist"; + return transact(); +} + +bool RRLPServer::locate() +{ + if (trouble) return false; + query = "query=loc"; + return transact(); +} + +void clean(char *line) +{ + char *p = line + strlen(line) - 1; + while (p > line && *p <= ' ') *p-- = 0; +} + +string getConfig() +{ + const char *configs[] = { + "GSM.RRLP.ACCURACY", + "GSM.RRLP.RESPONSETIME", + "GSM.RRLP.ALMANAC.URL", + "GSM.RRLP.EPHEMERIS.URL", + "GSM.RRLP.ALMANAC.REFRESH.TIME", + "GSM.RRLP.EPHEMERIS.REFRESH.TIME", + "GSM.RRLP.SEED.LATITUDE", + "GSM.RRLP.SEED.LONGITUDE", + "GSM.RRLP.SEED.ALTITUDE", + "GSM.RRLP.EPHEMERIS.ASSIST.COUNT", + "GSM.RRLP.ALMANAC.ASSIST.PRESENT", + 0 + }; + string config = ""; + for (const char **p = configs; *p; p++) { + string configValue = gConfig.getStr(*p, ""); + if (configValue.length() == 0) return ""; + config.append("&"); + config.append(*p); + config.append("="); + if (0 == strcmp((*p) + strlen(*p) - 3, "URL")) { + // TODO - better to have urlencode and decode, but then I'd have to look for them + char buf[3]; + buf[2] = 0; + for (const char *q = configValue.c_str(); *q; q++) { + sprintf(buf, "%02x", *q); + config.append(buf); + } + } else { + config.append(configValue); + } + } + return config; +} + +bool RRLPServer::transact() +{ + vector apdus; + while (true) { + // bounce off server + string esc = "'"; + string config = getConfig(); + if (config.length() == 0) return false; + string cmd = "wget -qO- " + esc + url + "?" + query + config + esc; + LOG(INFO) << "*************** " << cmd; + FILE *result = popen(cmd.c_str(), "r"); + if (!result) { + LOG(CRIT) << "popen call \"" << cmd << "\" failed"; + return NULL; + } + // build map of responses, and list of apdus + map response; + size_t nbytes = 1500; + char *line = (char*)malloc(nbytes+1); + while (!feof(result)) { + if (!fgets(line, nbytes, result)) break; + clean(line); + LOG(INFO) << "server return: " << line; + char *p = strchr(line, '='); + if (!p) continue; + string lhs = string(line, 0, p-line); + string rhs = string(line, p+1-line, string::npos); + if (lhs == "apdu") { + apdus.push_back(rhs); + } else { + response[lhs] = rhs; + } + } + free(line); + pclose(result); + + // quit if error + if (response.find("error") != response.end()) { + LOG(INFO) << "error from server: " << response["error"]; + return false; + } + + // quit if ack from assist unless there are more apdu messages + if (response.find("ack") != response.end()) { + LOG(INFO) << "ack from mobile, decoded by server"; + if (apdus.size() == 0) { + return true; + } else { + LOG(INFO) << "more apdu messages"; + } + } + + // quit if location decoded + if (response.find("latitude") != response.end() && response.find("longitude") != response.end() && response.find("positionError") != response.end()) { + ostringstream os; + os << "insert into RRLP (name, latitude, longitude, error, time) values (" << + '"' << name << '"' << "," << + response["latitude"] << "," << + response["longitude"] << "," << + response["positionError"] << "," << + "datetime('now')" + ")"; + LOG(INFO) << os.str(); + if (!sqlite3_command(gSubscriberRegistry.db(), os.str().c_str())) { + LOG(INFO) << "sqlite3_command problem"; + return false; + } + return true; + } + + // bounce off mobile + if (apdus.size() == 0) { + LOG(INFO) << "missing apdu for mobile"; + return false; + } + string apdu = apdus[0]; + apdus.erase(apdus.begin()); + BitVector bv(apdu.size()*4); + if (!bv.unhex(apdu.c_str())) { + LOG(INFO) << "BitVector::unhex problem"; + return false; + } + + DCCH->send(L3ApplicationInformation(bv)); + // Receive an L3 frame with a timeout. Timeout loc req response time max + 2 seconds. + L3Frame* resp = DCCH->recv(130000); + if (!resp) { + return false; + } + LOG(INFO) << "RRLPQuery returned " << *resp; + if (resp->primitive() != DATA) { + LOG(INFO) << "didn't receive data"; + switch (resp->primitive()) { + case ESTABLISH: LOG(INFO) << "channel establihsment"; break; + case RELEASE: LOG(INFO) << "normal channel release"; break; + case DATA: LOG(INFO) << "multiframe data transfer"; break; + case UNIT_DATA: LOG(INFO) << "datagram-type data transfer"; break; + case ERROR: LOG(INFO) << "channel error"; break; + case HARDRELEASE: LOG(INFO) << "forced release after an assignment"; break; + default: LOG(INFO) << "unrecognized primitive response"; break; + } + delete resp; + return false; + } + const unsigned PD_RR = 6; + LOG(INFO) << "resp.pd = " << resp->PD(); + if (resp->PD() != PD_RR) { + LOG(INFO) << "didn't receive an RR message"; + delete resp; + return false; + } + const unsigned MTI_RR_STATUS = 18; + if (resp->MTI() == MTI_RR_STATUS) { + ostringstream os2; + int cause = resp->peekField(16, 8); + delete resp; + switch (cause) { + case 97: + LOG(INFO) << "MS says: message not implemented"; + // flag unsupported in SR so we don't waste time on it again + os2 << "update sip_buddies set RRLPSupported = \"0\" where name = \"" << name << "\""; + if (!sqlite3_command(gSubscriberRegistry.db(), os2.str().c_str())) { + LOG(INFO) << "sqlite3_command problem"; + } + return false; + case 98: + LOG(INFO) << "MS says: message type not compatible with protocol state"; + return false; + default: + LOG(INFO) << "unknown RR_STATUS response, cause = " << cause; + return false; + } + } + const unsigned MTI_RR_APDU = 56; + if (resp->MTI() != MTI_RR_APDU) { + LOG(INFO) << "received unexpected RR Message " << resp->MTI(); + delete resp; + return false; + } + + // looks like a good APDU + BitVector *bv2 = (BitVector*)resp; + BitVector bv3 = bv2->tail(32); + ostringstream os; + bv3.hex(os); + apdu = os.str(); + delete resp; + + // next query for server + query = "query=apdu&apdu=" + apdu; + } + // not reached +} + +/** + Controller for the Location Updating transaction, GSM 04.08 4.4.4. + @param lur The location updating request. + @param DCCH The Dm channel to the MS, which will be released by the function. +*/ +void Control::LocationUpdatingController(const L3LocationUpdatingRequest* lur, LogicalChannel* DCCH) +{ + assert(DCCH); + assert(lur); + LOG(INFO) << *lur; + + // The location updating request gets mapped to a SIP + // registration with the Asterisk server. + + // We also allocate a new TMSI for every handset we encounter. + // If the handset is allow to register it may receive a TMSI reassignment. + + // Resolve an IMSI and see if there's a pre-existing IMSI-TMSI mapping. + // This operation will throw an exception, caught in a higher scope, + // if it fails in the GSM domain. + L3MobileIdentity mobileID = lur->mobileID(); + bool sameLAI = (lur->LAI() == gBTS.LAI()); + unsigned preexistingTMSI = resolveIMSI(sameLAI,mobileID,DCCH); + const char *IMSI = mobileID.digits(); + // IMSIAttach set to true if this is a new registration. + bool IMSIAttach = (preexistingTMSI==0); + + // We assign generate a TMSI for every new phone we see, + // even if we don't actually assign it. + unsigned newTMSI = 0; + if (!preexistingTMSI) newTMSI = gTMSITable.assign(IMSI,lur); + + // Try to register the IMSI. + // This will be set true if registration succeeded in the SIP world. + bool success = false; + try { + SIPEngine engine(gConfig.getStr("SIP.Proxy.Registration").c_str(),IMSI); + LOG(DEBUG) << "waiting for registration of " << IMSI << " on " << gConfig.getStr("SIP.Proxy.Registration"); + success = engine.Register(SIPEngine::SIPRegister); + } + catch(SIPTimeout) { + LOG(ALERT) "SIP registration timed out. Is the proxy running at " << gConfig.getStr("SIP.Proxy.Registration"); + // Reject with a "network failure" cause code, 0x11. + DCCH->send(L3LocationUpdatingReject(0x11)); + // HACK -- wait long enough for a response + // FIXME -- Why are we doing this? + sleep(4); + // Release the channel and return. + DCCH->send(L3ChannelRelease()); + return; + } + + if (gConfig.defines("Control.LUR.QueryRRLP")) { + // Query for RRLP + RRLPServer wRRLPServer(mobileID, DCCH); + if (!wRRLPServer.assist()) { + LOG(INFO) << "RRLPServer::assist problem"; + } + // can still try to check location even if assist didn't work + if (!wRRLPServer.locate()) { + LOG(INFO) << "RRLPServer::locate problem"; + } + } + + // This allows us to configure Open Registration + bool openRegistration = gConfig.defines("Control.LUR.OpenRegistration"); + + // Query for IMEI? + if (IMSIAttach && gConfig.defines("Control.LUR.QueryIMEI")) { + DCCH->send(L3IdentityRequest(IMEIType)); + L3Message* msg = getMessage(DCCH); + L3IdentityResponse *resp = dynamic_cast(msg); + if (!resp) { + if (msg) { + LOG(WARNING) << "Unexpected message " << *msg; + delete msg; + } + throw UnexpectedMessage(); + } + LOG(INFO) << *resp; + if (!gTMSITable.IMEI(IMSI,resp->mobileID().digits())) + LOG(WARNING) << "failed access to TMSITable"; + delete msg; + } + + // Query for classmark? + if (IMSIAttach && gConfig.defines("Control.LUR.QueryClassmark")) { + DCCH->send(L3ClassmarkEnquiry()); + L3Message* msg = getMessage(DCCH); + L3ClassmarkChange *resp = dynamic_cast(msg); + if (!resp) { + if (msg) { + LOG(WARNING) << "Unexpected message " << *msg; + delete msg; + } + throw UnexpectedMessage(); + } + LOG(INFO) << *resp; + const L3MobileStationClassmark2& classmark = resp->classmark(); + if (!gTMSITable.classmark(IMSI,classmark)) + LOG(WARNING) << "failed access to TMSITable"; + delete msg; + } + + // We fail closed unless we're configured otherwise + if (!success && !openRegistration) { + LOG(INFO) << "registration FAILED: " << mobileID; + DCCH->send(L3LocationUpdatingReject(gConfig.getNum("Control.LUR.UnprovisionedRejectCause"))); + if (!preexistingTMSI) { + sendWelcomeMessage( "Control.LUR.FailedRegistration.Message", + "Control.LUR.FailedRegistration.ShortCode", IMSI,DCCH); + } + // Release the channel and return. + DCCH->send(L3ChannelRelease()); + return; + } + + // If success is true, we had a normal registration. + // Otherwise, we are here because of open registration. + // Either way, we're going to register a phone if we arrive here. + + if (success) { + LOG(INFO) << "registration SUCCESS: " << mobileID; + } else { + LOG(INFO) << "registration ALLOWED: " << mobileID; + } + + + // Send the "short name" and time-of-day. + if (IMSIAttach && gConfig.defines("GSM.Identity.ShortName")) { + DCCH->send(L3MMInformation(gConfig.getStr("GSM.Identity.ShortName").c_str())); + } + // Accept. Make a TMSI assignment, too, if needed. + if (preexistingTMSI || !gConfig.defines("Control.LUR.SendTMSIs")) { + DCCH->send(L3LocationUpdatingAccept(gBTS.LAI())); + } else { + assert(newTMSI); + DCCH->send(L3LocationUpdatingAccept(gBTS.LAI(),newTMSI)); + // Wait for MM TMSI REALLOCATION COMPLETE (0x055b). + L3Frame* resp = DCCH->recv(1000); + // FIXME -- Actually check the response type. + if (!resp) { + LOG(NOTICE) << "no response to TMSI assignment"; + } else { + LOG(INFO) << *resp; + } + delete resp; + } + + // If this is an IMSI attach, send a welcome message. + if (IMSIAttach) { + if (success) { + sendWelcomeMessage( "Control.LUR.NormalRegistration.Message", + "Control.LUR.NormalRegistration.ShortCode", IMSI, DCCH); + } else { + sendWelcomeMessage( "Control.LUR.OpenRegistration.Message", + "Control.LUR.OpenRegistration.ShortCode", IMSI, DCCH); + } + } + + // Release the channel and return. + DCCH->send(L3ChannelRelease()); + return; +} + + + + +// vim: ts=4 sw=4 diff --git a/Control/MobilityManagement.h b/Control/MobilityManagement.h new file mode 100644 index 0000000..2f0e296 --- /dev/null +++ b/Control/MobilityManagement.h @@ -0,0 +1,39 @@ +/**@file GSM/SIP Mobility Management, GSM 04.08. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +#ifndef MOBILITYMANAGEMENT_H +#define MOBILITYMANAGEMENT_H + + +namespace GSM { +class LogicalChannel; +class L3CMServiceRequest; +class L3LocationUpdatingRequest; +class L3IMSIDetachIndication; +}; + +namespace Control { + +void CMServiceResponder(const GSM::L3CMServiceRequest* cmsrq, GSM::LogicalChannel* DCCH); + +void IMSIDetachController(const GSM::L3IMSIDetachIndication* idi, GSM::LogicalChannel* DCCH); + +void LocationUpdatingController(const GSM::L3LocationUpdatingRequest* lur, GSM::LogicalChannel* DCCH); + +} + + +#endif diff --git a/Control/README.Control b/Control/README.Control new file mode 100644 index 0000000..918a5e5 --- /dev/null +++ b/Control/README.Control @@ -0,0 +1,25 @@ +This directory contains control-layer functions for the access point. + +Most GSM L3 and VoIP messages terminate here. + +Everything in this directory should be in the Control namespace. + +Components: + +RadioResource -- Functions for RR procedures (paging, access grant) +MobilityManagement -- Functions for MM procedures (CM service, location updating) +CallControl -- Functions for CC (mobile originated, mobile terminated) +SMS -- Funcitons for text messaging. + + + +SIP and RTP UDP/IP Port Assignments + +Component Protocol Port(s) +Asterisk SIP 5060 +Zoiper SIP 5061 +AP/BTS SIP 5062 +Zoiper RTP 16384-16385 +Asterisk RTP 16386-16483 +AP/BTS RTP 16484-16583 + diff --git a/Control/RadioResource.cpp b/Control/RadioResource.cpp new file mode 100644 index 0000000..ee65899 --- /dev/null +++ b/Control/RadioResource.cpp @@ -0,0 +1,509 @@ +/**@file GSM Radio Resource procedures, GSM 04.18 and GSM 04.08. */ + +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include +#include +#include + +#include "ControlCommon.h" +#include "TransactionTable.h" +#include "RadioResource.h" +#include "SMSControl.h" +#include "CallControl.h" + +#include +#include + +#include +#undef WARNING + + + + + +using namespace std; +using namespace GSM; +using namespace Control; + + + + + +/** + Determine the channel type needed. + This is based on GSM 04.08 9.1.8, Table 9.3 and 9.3a. + The following is assumed about the global BTS capabilities: + - We do not support call reestablishment. + - We do not support GPRS. + @param RA The request reference from the channel request message. + @return channel type code, undefined if not a supported service +*/ +ChannelType decodeChannelNeeded(unsigned RA) +{ + // This code is based on GSM 04.08 Table 9.9. + + unsigned RA4 = RA>>4; + unsigned RA5 = RA>>5; + + // Answer to paging, Table 9.9a. + // We don't support TCH/H, so it's wither SDCCH or TCH/F. + // The spec allows for "SDCCH-only" MS. We won't support that here. + // FIXME -- So we probably should not use "any channel" in the paging indications. + if (RA5 == 0x04) return TCHFType; // any channel or any TCH. + if (RA4 == 0x01) return SDCCHType; // SDCCH + if (RA4 == 0x02) return TCHFType; // TCH/F + if (RA4 == 0x03) return TCHFType; // TCH/F + + int NECI = gConfig.getNum("GSM.CellSelection.NECI"); + if (NECI==0) { + if (RA5 == 0x07) return SDCCHType; // MOC or SDCCH procedures + if (RA5 == 0x00) return SDCCHType; // location updating + } else { + assert(NECI==1); + if (gConfig.defines("Control.VEA")) { + // Very Early Assignment + if (RA5 == 0x07) return TCHFType; // MOC for TCH/F + if (RA4 == 0x04) return TCHFType; // MOC, TCH/H sufficient + } else { + // Early Assignment + if (RA5 == 0x07) return SDCCHType; // MOC for TCH/F + if (RA4 == 0x04) return SDCCHType; // MOC, TCH/H sufficient + } + if (RA4 == 0x00) return SDCCHType; // location updating + if (RA4 == 0x01) return SDCCHType; // other procedures on SDCCH + } + + // Anything else falls through to here. + // We are still ignoring data calls, GPRS, LMU. + return UndefinedCHType; +} + + +/** Return true if RA indicates LUR. */ +bool requestingLUR(unsigned RA) +{ + int NECI = gConfig.getNum("GSM.CellSelection.NECI"); + if (NECI==0) return ((RA>>5) == 0x00); + else return ((RA>>4) == 0x00); +} + + + + + +/** Decode RACH bits and send an immediate assignment; may block waiting for a channel. */ +void AccessGrantResponder( + unsigned RA, const GSM::Time& when, + float RSSI, float timingError) +{ + // RR Establishment. + // Immediate Assignment procedure, "Answer from the Network" + // GSM 04.08 3.3.1.1.3. + // Given a request reference, try to allocate a channel + // and send the assignment to the handset on the CCCH. + // This GSM's version of medium access control. + // Papa Legba, open that door... + + // Are we holding off new allocations? + if (gBTS.hold()) { + LOG(NOTICE) << "ignoring RACH due to BTS hold-off"; + return; + } + + // Check "when" against current clock to see if we're too late. + // Calculate maximum number of frames of delay. + // See GSM 04.08 3.3.1.1.2 for the logic here. + static const unsigned txInteger = gConfig.getNum("GSM.RACH.TxInteger"); + static const int maxAge = GSM::RACHSpreadSlots[txInteger] + GSM::RACHWaitSParam[txInteger]; + // Check burst age. + int age = gBTS.time() - when; + LOG(INFO) << "RA=0x" << hex << RA << dec + << " when=" << when << " age=" << age + << " delay=" << timingError << " RSSI=" << RSSI; + if (age>maxAge) { + LOG(WARNING) << "ignoring RACH bust with age " << age; + gBTS.growT3122()/1000; + return; + } + + // Screen for delay. + if (timingError>gConfig.getNum("GSM.MS.TA.Max")) { + LOG(WARNING) << "ignoring RACH burst with delay " << timingError; + return; + } + + // Get an AGCH to send on. + CCCHLogicalChannel *AGCH = gBTS.getAGCH(); + // Someone had better have created a least one AGCH. + assert(AGCH); + // Check AGCH load now. + if (AGCH->load()>gConfig.getNum("GSM.CCCH.AGCH.QMax")) { + LOG(WARNING) "AGCH congestion"; + return; + } + + // Check for location update. + // This gives LUR a lower priority than other services. + if (requestingLUR(RA)) { + if (gBTS.SDCCHAvailable()<=gConfig.getNum("GSM.CCCH.PCH.Reserve")) { + unsigned waitTime = gBTS.growT3122()/1000; + LOG(WARNING) << "LUR congestion, RA=" << RA << " T3122=" << waitTime; + const L3ImmediateAssignmentReject reject(L3RequestReference(RA,when),waitTime); + LOG(DEBUG) << "LUR rejection, sending " << reject; + AGCH->send(reject); + return; + } + } + + // Allocate the channel according to the needed type indicated by RA. + // The returned channel is already open and ready for the transaction. + LogicalChannel *LCH = NULL; + switch (decodeChannelNeeded(RA)) { + case TCHFType: LCH = gBTS.getTCH(); break; + case SDCCHType: LCH = gBTS.getSDCCH(); break; + // If we don't support the service, assign to an SDCCH and we can reject it in L3. + case UndefinedCHType: + LOG(NOTICE) << "RACH burst for unsupported service RA=" << RA; + LCH = gBTS.getSDCCH(); + break; + // We should never be here. + default: assert(0); + } + + // Nothing available? + if (!LCH) { + // Rejection, GSM 04.08 3.3.1.1.3.2. + // But since we recognize SOS calls already, + // we might as well save some AGCH bandwidth. + unsigned waitTime = gBTS.growT3122()/1000; + LOG(WARNING) << "congestion, RA=" << RA << " T3122=" << waitTime; + const L3ImmediateAssignmentReject reject(L3RequestReference(RA,when),waitTime); + LOG(DEBUG) << "rejection, sending " << reject; + AGCH->send(reject); + return; + } + + // Set the channel physical parameters from the RACH burst. + LCH->setPhy(RSSI,timingError); + + // Assignment, GSM 04.08 3.3.1.1.3.1. + // Create the ImmediateAssignment message. + // Woot!! We got a channel! Thanks to Legba! + int initialTA = (int)(timingError + 0.5F); + if (initialTA<0) initialTA=0; + if (initialTA>62) initialTA=62; + const L3ImmediateAssignment assign( + L3RequestReference(RA,when), + LCH->channelDescription(), + L3TimingAdvance(initialTA) + ); + LOG(INFO) << "sending " << assign; + AGCH->send(assign); + + // On successful allocation, shrink T3122. + gBTS.shrinkT3122(); +} + + + +void* Control::AccessGrantServiceLoop(void*) +{ + while (true) { + ChannelRequestRecord *req = gBTS.nextChannelRequest(); + if (!req) continue; + AccessGrantResponder( + req->RA(), req->frame(), + req->RSSI(), req->timingError() + ); + delete req; + } + return NULL; +} + + + + + +void Control::PagingResponseHandler(const L3PagingResponse* resp, LogicalChannel* DCCH) +{ + assert(resp); + assert(DCCH); + LOG(INFO) << *resp; + + // If we got a TMSI, find the IMSI. + L3MobileIdentity mobileID = resp->mobileID(); + if (mobileID.type()==TMSIType) { + char *IMSI = gTMSITable.IMSI(mobileID.TMSI()); + if (IMSI) { + mobileID = L3MobileIdentity(IMSI); + free(IMSI); + } else { + // Don't try too hard to resolve. + // The handset is supposed to respond with the same ID type as in the request. + // This could be the sign of some kind of DOS attack. + LOG(CRIT) << "Paging Reponse with non-valid TMSI"; + // Cause 0x60 "Invalid mandatory information" + DCCH->send(L3ChannelRelease(0x60)); + return; + } + } + + // Delete the Mobile ID from the paging list to free up CCCH bandwidth. + // ... if it was not deleted by a timer already ... + gBTS.pager().removeID(mobileID); + + // Find the transction table entry that was created when the phone was paged. + // We have to look up by mobile ID since the paging entry may have been + // erased before this handler was called. That's too bad. + // HACK -- We also flush stray transactions until we find what we + // are looking for. + TransactionEntry* transaction = gTransactionTable.answeredPaging(mobileID); + if (!transaction) { + LOG(WARNING) << "Paging Reponse with no transaction record for " << mobileID; + // Cause 0x41 means "call already cleared". + DCCH->send(L3ChannelRelease(0x41)); + return; + } + // Set the transaction channel. + transaction->channel(DCCH); + // We are looking for a mobile-terminated transaction. + // The transaction controller will take it from here. + switch (transaction->service().type()) { + case L3CMServiceType::MobileTerminatedCall: + MTCStarter(transaction, DCCH); + return; + case L3CMServiceType::MobileTerminatedShortMessage: + MTSMSController(transaction, DCCH); + return; + default: + // Flush stray MOC entries. + // There should not be any, but... + LOG(ERR) << "non-valid paging-state transaction: " << *transaction; + gTransactionTable.remove(transaction); + // FIXME -- Send a channel release on the DCCH. + } +} + + + +void Control::AssignmentCompleteHandler(const L3AssignmentComplete *confirm, TCHFACCHLogicalChannel *TCH) +{ + // The assignment complete handler is used to + // tie together split transactions across a TCH assignment + // in non-VEA call setup. + + assert(TCH); + assert(confirm); + LOG(DEBUG) << *confirm; + + // Check the transaction table to know what to do next. + TransactionEntry* transaction = gTransactionTable.find(TCH); + if (!transaction) { + LOG(WARNING) << "No transaction matching channel " << *TCH << " (" << TCH << ")."; + throw UnexpectedMessage(); + } + LOG(INFO) << "service="<service().type(); + + // These "controller" functions don't return until the call is cleared. + switch (transaction->service().type()) { + case L3CMServiceType::MobileOriginatedCall: + MOCController(transaction,TCH); + break; + case L3CMServiceType::MobileTerminatedCall: + MTCController(transaction,TCH); + break; + default: + LOG(WARNING) << "unsupported service " << transaction->service(); + throw UnsupportedMessage(transaction->ID()); + } + // If we got here, the call is cleared. +} + + + + + + + + +void Pager::addID(const L3MobileIdentity& newID, ChannelType chanType, + TransactionEntry& transaction, unsigned wLife) +{ + transaction.GSMState(GSM::Paging); + transaction.setTimer("3113",wLife); + // Add a mobile ID to the paging list for a given lifetime. + ScopedLock lock(mLock); + // If this ID is already in the list, just reset its timer. + // Uhg, another linear time search. + // This would be faster if the paging list were ordered by ID. + // But the list should usually be short, so it may not be worth the effort. + for (PagingEntryList::iterator lp = mPageIDs.begin(); lp != mPageIDs.end(); ++lp) { + if (lp->ID()==newID) { + LOG(DEBUG) << newID << " already in table"; + lp->renew(wLife); + mPageSignal.signal(); + return; + } + } + // If this ID is new, put it in the list. + mPageIDs.push_back(PagingEntry(newID,chanType,transaction.ID(),wLife)); + LOG(INFO) << newID << " added to table"; + mPageSignal.signal(); +} + + +unsigned Pager::removeID(const L3MobileIdentity& delID) +{ + // Return the associated transaction ID, or 0 if none found. + LOG(INFO) << delID; + ScopedLock lock(mLock); + for (PagingEntryList::iterator lp = mPageIDs.begin(); lp != mPageIDs.end(); ++lp) { + if (lp->ID()==delID) { + unsigned retVal = lp->transactionID(); + mPageIDs.erase(lp); + return retVal; + } + } + return 0; +} + + + +unsigned Pager::pageAll() +{ + // Traverse the full list and page all IDs. + // Remove expired IDs. + // Return the number of IDs paged. + // This is a linear time operation. + + ScopedLock lock(mLock); + + // Clear expired entries. + PagingEntryList::iterator lp = mPageIDs.begin(); + while (lp != mPageIDs.end()) { + if (!lp->expired()) ++lp; + else { + LOG(INFO) << "erasing " << lp->ID(); + // Non-responsive, dead transaction? + gTransactionTable.removePaging(lp->transactionID()); + // remove from the list + lp=mPageIDs.erase(lp); + } + } + + LOG(INFO) << "paging " << mPageIDs.size() << " mobile(s)"; + + // Page remaining entries, two at a time if possible. + // These PCH send operations are non-blocking. + lp = mPageIDs.begin(); + while (lp != mPageIDs.end()) { + // FIXME -- This completely ignores the paging groups. + // HACK -- So we send every page twice. + // That will probably mean a different Pager for each subchannel. + // See GSM 04.08 10.5.2.11 and GSM 05.02 6.5.2. + const L3MobileIdentity& id1 = lp->ID(); + ChannelType type1 = lp->type(); + ++lp; + if (lp==mPageIDs.end()) { + // Just one ID left? + LOG(DEBUG) << "paging " << id1; + gBTS.getPCH(0)->send(L3PagingRequestType1(id1,type1)); + gBTS.getPCH(0)->send(L3PagingRequestType1(id1,type1)); + break; + } + // Page by pairs when possible. + const L3MobileIdentity& id2 = lp->ID(); + ChannelType type2 = lp->type(); + ++lp; + LOG(DEBUG) << "paging " << id1 << " and " << id2; + gBTS.getPCH(0)->send(L3PagingRequestType1(id1,type1,id2,type2)); + gBTS.getPCH(0)->send(L3PagingRequestType1(id1,type1,id2,type2)); + } + + return mPageIDs.size(); +} + +size_t Pager::pagingEntryListSize() +{ + ScopedLock lock(mLock); + return mPageIDs.size(); +} + +void Pager::start() +{ + if (mRunning) return; + mRunning=true; + mPagingThread.start((void* (*)(void*))PagerServiceLoopAdapter, (void*)this); +} + + + +void* Control::PagerServiceLoopAdapter(Pager *pager) +{ + pager->serviceLoop(); + return NULL; +} + +void Pager::serviceLoop() +{ + while (mRunning) { + + LOG(DEBUG) << "Pager blocking for signal"; + mLock.lock(); + while (mPageIDs.size()==0) mPageSignal.wait(mLock); + mLock.unlock(); + + // page everything + pageAll(); + + // Wait for pending activity to clear the channel. + // This wait is what causes PCH to have lower priority than AGCH. + unsigned load = gBTS.getPCH()->load(); + LOG(DEBUG) << "Pager waiting for " << load << " multiframes"; + if (load) sleepFrames(51*load); + } +} + + + +void Pager::dump(ostream& os) const +{ + ScopedLock lock(mLock); + PagingEntryList::const_iterator lp = mPageIDs.begin(); + while (lp != mPageIDs.end()) { + os << lp->ID() << " " << lp->type() << " " << lp->expired() << endl; + ++lp; + } +} + + + +// vim: ts=4 sw=4 diff --git a/Control/RadioResource.h b/Control/RadioResource.h new file mode 100644 index 0000000..405b838 --- /dev/null +++ b/Control/RadioResource.h @@ -0,0 +1,214 @@ +/**@file GSM Radio Resource procedures, GSM 04.18 and GSM 04.08. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +#ifndef RADIORESOURCE_H +#define RADIORESOURCE_H + +#include +#include + + +namespace GSM { +class Time; +class TCHFACCHLogicalChannel; +class L3PagingResponse; +class L3AssignmentComplete; +}; + +namespace Control { + +class TransactionEntry; + + + + +/** Find and compelte the in-process transaction associated with a paging repsonse. */ +void PagingResponseHandler(const GSM::L3PagingResponse*, GSM::LogicalChannel*); + +/** Find and compelte the in-process transaction associated with a completed assignment. */ +void AssignmentCompleteHandler(const GSM::L3AssignmentComplete*, GSM::TCHFACCHLogicalChannel*); + + +/**@ Access Grant mechanisms */ +//@{ + + +/** Decode RACH bits and send an immediate assignment; may block waiting for a channel. */ +//void AccessGrantResponder( +// unsigned requestReference, const GSM::Time& when, +// float RSSI, float timingError); + + +/** This record carries all of the parameters associated with a RACH burst. */ +class ChannelRequestRecord { + + private: + + unsigned mRA; ///< request reference + GSM::Time mFrame; ///< receive timestamp + float mRSSI; ///< dB wrt full scale + float mTimingError; ///< correlator timing error in symbol periods + + public: + + ChannelRequestRecord( + unsigned wRA, const GSM::Time& wFrame, + float wRSSI, float wTimingError) + :mRA(wRA), mFrame(wFrame), + mRSSI(wRSSI), mTimingError(wTimingError) + { } + + unsigned RA() const { return mRA; } + const GSM::Time& frame() const { return mFrame; } + float RSSI() const { return mRSSI; } + float timingError() const { return mTimingError; } + +}; + + +/** A thread to process contents of the channel request queue. */ +void* AccessGrantServiceLoop(void*); + + +//@} + +/**@ Paging mechanisms */ +//@{ + +/** An entry in the paging list. */ +class PagingEntry { + + private: + + GSM::L3MobileIdentity mID; ///< The mobile ID. + GSM::ChannelType mType; ///< The needed channel type. + unsigned mTransactionID; ///< The associated transaction ID. + Timeval mExpiration; ///< The expiration time for this entry. + + public: + + /** + Create a new entry, with current timestamp. + @param wID The ID to be paged. + @param wLife The number of milliseconds to keep paging. + */ + PagingEntry(const GSM::L3MobileIdentity& wID, GSM::ChannelType wType, + unsigned wTransactionID, unsigned wLife) + :mID(wID),mType(wType),mTransactionID(wTransactionID),mExpiration(wLife) + {} + + /** Access the ID. */ + const GSM::L3MobileIdentity& ID() const { return mID; } + + /** Access the channel type needed. */ + GSM::ChannelType type() const { return mType; } + + unsigned transactionID() const { return mTransactionID; } + + /** Renew the timer. */ + void renew(unsigned wLife) { mExpiration = Timeval(wLife); } + + /** Returns true if the entry is expired. */ + bool expired() const { return mExpiration.passed(); } + +}; + +typedef std::list PagingEntryList; + + +/** + The pager is a global object that generates paging messages on the CCCH. + To page a mobile, add the mobile ID to the pager. + The entry will be deleted automatically when it expires. + All pager operations are linear time. + Not much point in optimizing since the main operation is inherently linear. +*/ +class Pager { + + private: + + PagingEntryList mPageIDs; ///< List of ID's to be paged. + mutable Mutex mLock; ///< Lock for thread-safe access. + Signal mPageSignal; ///< signal to wake the paging loop + Thread mPagingThread; ///< Thread for the paging loop. + volatile bool mRunning; + + public: + + Pager() + :mRunning(false) + {} + + /** Set the output FIFO and start the paging loop. */ + void start(); + + /** + Add a mobile ID to the paging list. + @param addID The mobile ID to be paged. + @param chanType The channel type to be requested. + @param transaction The transaction record, which will be modified. + @param wLife The paging duration in ms, default is SIP Timer B. + */ + void addID( + const GSM::L3MobileIdentity& addID, + GSM::ChannelType chanType, + TransactionEntry& transaction, + unsigned wLife=gConfig.getNum("SIP.Timer.B") + ); + + /** + Remove a mobile ID. + This is used to stop the paging when a phone responds. + @return The transaction ID associated with this entry. + */ + unsigned removeID(const GSM::L3MobileIdentity&); + + private: + + /** + Traverse the paging list, paging all IDs. + @return Number of IDs paged. + */ + unsigned pageAll(); + + /** A loop that repeatedly calls pageAll. */ + void serviceLoop(); + + /** C-style adapter. */ + friend void *PagerServiceLoopAdapter(Pager*); + +public: + + /** return size of PagingEntryList */ + size_t pagingEntryListSize(); + + /** Dump the paging list to an ostream. */ + void dump(std::ostream&) const; +}; + + +void *PagerServiceLoopAdapter(Pager*); + + +//@} // paging mech + +} + + +#endif diff --git a/Control/SMSControl.cpp b/Control/SMSControl.cpp new file mode 100644 index 0000000..f467471 --- /dev/null +++ b/Control/SMSControl.cpp @@ -0,0 +1,584 @@ +/**@file SMS Control (L3), GSM 03.40, 04.11. */ +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +/* + Abbreviations: + MOSMS -- Mobile Originated Short Message Service + MTSMS -- Mobile Terminated Short Message Service + + Verbs: + "send" -- Transfer to the network. + "receive" -- Transfer from the network. + "submit" -- Transfer from the MS. + "deliver" -- Transfer to the MS. + + MOSMS: The MS "submits" a message that OpenBTS then "sends" to the network. + MTSMS: OpenBTS "receives" a message from the network that it then "delivers" to the MS. + +*/ + + +#include +#include +#include +#include +#include "SMSControl.h" +#include "ControlCommon.h" +#include "TransactionTable.h" +#include + + + +using namespace std; +using namespace Control; + +#include "SMSMessages.h" +using namespace SMS; + +#include "SIPInterface.h" +#include "SIPUtility.h" +#include "SIPMessage.h" +#include "SIPEngine.h" +using namespace SIP; + +#include +#undef WARNING + +/** + Read an L3Frame from SAP3. + Throw exception on failure. Will NOT return a NULL pointer. +*/ +GSM::L3Frame* getFrameSMS(GSM::LogicalChannel *LCH, GSM::Primitive primitive=GSM::DATA) +{ + GSM::L3Frame *retVal = LCH->recv(LCH->N200()*LCH->T200(),3); + if (!retVal) { + LOG(NOTICE) << "channel read time out on " << *LCH << " SAP3"; + throw ChannelReadTimeout(); + } + LOG(DEBUG) << "getFrameSMS on " << *LCH << " in frame " << *retVal; + if (retVal->primitive() != primitive) { + LOG(NOTICE) << "unexpected primitive on " << *LCH << ", expecting " << primitive << ", got " << *retVal; + throw UnexpectedPrimitive(); + } + if ((retVal->primitive() == GSM::DATA) && (retVal->PD() != GSM::L3SMSPD)) { + LOG(NOTICE) << "unexpected (non-SMS) protocol on " << *LCH << " in frame " << *retVal; + throw UnexpectedMessage(); + } + return retVal; +} + + +bool sendSIP(TransactionEntry *transaction, const char* address, const char* body, const char* contentType) +{ + // Steps: + // 1 -- Complete transaction record. + // 2 -- Send TL-SUBMIT to the server. + // 3 -- Wait for response or timeout. + // 4 -- Return true for OK or ACCEPTED, false otherwise. + + // Step 1 -- Complete the transaction record. + // Form the TLAddress into a CalledPartyNumber for the transaction. + GSM::L3CalledPartyBCDNumber calledParty(address); + // Attach calledParty and message body to the transaction. + transaction->called(calledParty); + transaction->message(body,strlen(body)); + + // Step 2 -- Send the message to the server. + transaction->MOSMSSendMESSAGE(address,gConfig.getStr("SIP.Local.IP").c_str(),contentType); + + // Step 3 -- Wait for OK or ACCEPTED. + SIPState state = transaction->MOSMSWaitForSubmit(); + + // Step 4 -- Done + return state==SIP::Cleared; +} + +/** + Process the RPDU. + @param mobileID The sender's IMSI. + @param RPDU The RPDU to process. + @return true if successful. +*/ +bool handleRPDU(TransactionEntry *transaction, const RLFrame& RPDU) +{ + LOG(DEBUG) << "SMS: handleRPDU MTI=" << RPDU.MTI(); + switch ((RPMessage::MessageType)RPDU.MTI()) { + case RPMessage::Data: { + string contentType = gConfig.getStr("SMS.MIMEType"); + ostringstream body; + + if (contentType == "text/plain") { + // TODO: Clean this mess up! + RPData data; + data.parse(RPDU); + TLSubmit submit; + submit.parse(data.TPDU()); + + body << submit.UD().decode(); + } else if (contentType == "application/vnd.3gpp.sms") { + RPDU.hex(body); + } else { + LOG(ALERT) << "\"" << contentType << "\" is not a valid SMS payload type"; + } + const char* address = NULL; + if (gConfig.defines("SIP.SMSC")) address = gConfig.getStr("SIP.SMSC").c_str(); + + /* The SMSC is not defined, we are using an older version */ + if (address == NULL) { + RPData data; + data.parse(RPDU); + TLSubmit submit; + submit.parse(data.TPDU()); + + address = submit.DA().digits(); + } + return sendSIP(transaction, address, body.str().data(),contentType.c_str()); + } + case RPMessage::Ack: + case RPMessage::SMMA: + return true; + case RPMessage::Error: + default: + return false; + } +} + + + + +void Control::MOSMSController(const GSM::L3CMServiceRequest *req, GSM::LogicalChannel *LCH) +{ + assert(req); + assert(req->serviceType().type() == GSM::L3CMServiceType::ShortMessage); + assert(LCH); + assert(LCH->type() != GSM::SACCHType); + + LOG(INFO) << "MOSMS, req " << *req; + + // If we got a TMSI, find the IMSI. + // Note that this is a copy, not a reference. + GSM::L3MobileIdentity mobileID = req->mobileID(); + resolveIMSI(mobileID,LCH); + + // Create a transaction record. + TransactionEntry *transaction = new TransactionEntry(gConfig.getStr("SIP.Proxy.SMS").c_str(),mobileID,LCH); + gTransactionTable.add(transaction); + LOG(DEBUG) << "MOSMS: transaction: " << *transaction; + + // See GSM 04.11 Arrow Diagram A5 for the transaction + // Step 1 MS->Network CP-DATA containing RP-DATA + // Step 2 Network->MS CP-ACK + // Step 3 Network->MS CP-DATA containing RP-ACK + // Step 4 MS->Network CP-ACK + + // LAPDm operation, from GSM 04.11, Annex F: + // """ + // Case A: Mobile originating short message transfer, no parallel call: + // The mobile station side will initiate SAPI 3 establishment by a SABM command + // on the DCCH after the cipher mode has been set. If no hand over occurs, the + // SAPI 3 link will stay up until the last CP-ACK is received by the MSC, and + // the clearing procedure is invoked. + // """ + + // FIXME: check provisioning + + // Let the phone know we're going ahead with the transaction. + LOG(INFO) << "sending CMServiceAccept"; + LCH->send(GSM::L3CMServiceAccept()); + // Wait for SAP3 to connect. + // The first read on SAP3 is the ESTABLISH primitive. + delete getFrameSMS(LCH,GSM::ESTABLISH); + + // Step 1 + // Now get the first message. + // Should be CP-DATA, containing RP-DATA. + GSM::L3Frame *CM = getFrameSMS(LCH); + LOG(DEBUG) << "data from MS " << *CM; + if (CM->MTI()!=CPMessage::DATA) { + LOG(NOTICE) << "unexpected SMS CP message with TI=" << CM->MTI(); + throw UnexpectedMessage(); + } + unsigned L3TI = CM->TI() | 0x08; + transaction->L3TI(L3TI); + + // Step 2 + // Respond with CP-ACK. + // This just means that we got the message. + LOG(INFO) << "sending CPAck"; + LCH->send(CPAck(L3TI),3); + + // Parse the message in CM and process RP part. + // This is where we actually parse the message and send it out. + // FIXME -- We need to set the message ref correctly, + // even if the parsing fails. + // The compiler gives a warning here. Let it. It will remind someone to fix it. + unsigned ref; + bool success = false; + try { + CPData data; + data.parse(*CM); + delete CM; + LOG(INFO) << "CPData " << data; + // Transfer out the RPDU -> TPDU -> delivery. + ref = data.RPDU().reference(); + // This handler invokes higher-layer parsers, too. + success = handleRPDU(transaction,data.RPDU()); + } + catch (SMSReadError) { + LOG(WARNING) << "SMS parsing failed (above L3)"; + // Cause 95, "semantically incorrect message". + LCH->send(CPData(L3TI,RPError(95,ref)),3); + throw UnexpectedMessage(); + } + catch (GSM::L3ReadError) { + LOG(WARNING) << "SMS parsing failed (in L3)"; + throw UnsupportedMessage(); + } + + // Step 3 + // Send CP-DATA containing RP-ACK and message reference. + if (success) { + LOG(INFO) << "sending RPAck in CPData"; + LCH->send(CPData(L3TI,RPAck(ref)),3); + } else { + LOG(INFO) << "sending RPError in CPData"; + // Cause 127 is "internetworking error, unspecified". + // See GSM 04.11 Table 8.4. + LCH->send(CPData(L3TI,RPError(127,ref)),3); + } + + // Step 4 + // Get CP-ACK from the MS. + CM = getFrameSMS(LCH); + if (CM->MTI()!=CPMessage::ACK) { + LOG(NOTICE) << "unexpected SMS CP message with TI=" << CM->MTI(); + throw UnexpectedMessage(); + } + LOG(DEBUG) << "ack from MS: " << *CM; + CPAck ack; + ack.parse(*CM); + LOG(INFO) << "CPAck " << ack; + + // Done. + LCH->send(GSM::L3ChannelRelease()); + gTransactionTable.remove(transaction); + LOG(INFO) << "closing the Um channel"; +} + + + + +bool Control::deliverSMSToMS(const char *callingPartyDigits, const char* message, const char* contentType, unsigned L3TI, GSM::LogicalChannel *LCH) +{ + if (!LCH->multiframeMode(3)) { + // Start ABM in SAP3. + LCH->send(GSM::ESTABLISH,3); + // Wait for SAP3 ABM to connect. + // The next read on SAP3 should the ESTABLISH primitive. + // This won't return NULL. It will throw an exception if it fails. + delete getFrameSMS(LCH,GSM::ESTABLISH); + } + +#if 0 + // HACK -- Check for "Easter Eggs" + // TL-PID + unsigned TLPID=0; + if (strncmp(message,"#!TLPID",7)==0) sscanf(message,"#!TLPID%d",&TLPID); + + // Step 1 + // Send the first message. + // CP-DATA, containing RP-DATA. + unsigned reference = random() % 255; + CPData deliver(L3TI, + RPData(reference, + RPAddress(gConfig.getStr("SMS.FakeSrcSMSC").c_str()), + TLDeliver(callingPartyDigits,message,TLPID))); +#else + // TODO: Read MIME Type from smqueue!! + unsigned reference = random() % 255; + RPData rp_data; + + if (strncmp(contentType,"text/plain",10)==0) { + rp_data = RPData(reference, + RPAddress(gConfig.getStr("SMS.FakeSrcSMSC").c_str()), + TLDeliver(callingPartyDigits,message,0)); + } else if (strncmp(contentType,"application/vnd.3gpp.sms",24)==0) { + BitVector RPDUbits(strlen(message)*4); + if (!RPDUbits.unhex(message)) { + LOG(WARNING) << "Hex string parsing failed (in incoming SIP MESSAGE)"; + throw UnexpectedMessage(); + } + + try { + RLFrame RPDU(RPDUbits); + LOG(DEBUG) << "SMS RPDU: " << RPDU; + + rp_data.parse(RPDU); + LOG(DEBUG) << "SMS RP-DATA " << rp_data; + } + catch (SMSReadError) { + LOG(WARNING) << "SMS parsing failed (above L3)"; + // Cause 95, "semantically incorrect message". + LCH->send(CPData(L3TI,RPError(95,reference)),3); + throw UnexpectedMessage(); + } + catch (GSM::L3ReadError) { + LOG(WARNING) << "SMS parsing failed (in L3)"; + // TODO:: send error back to the phone + throw UnsupportedMessage(); + } + } else { + LOG(WARNING) << "Unsupported content type (in incoming SIP MESSAGE) -- type: " << contentType; + throw UnexpectedMessage(); + } + + CPData deliver(L3TI,rp_data); + +#endif + + // Start ABM in SAP3. + //LCH->send(GSM::ESTABLISH,3); + // Wait for SAP3 ABM to connect. + // The next read on SAP3 should the ESTABLISH primitive. + // This won't return NULL. It will throw an exception if it fails. + //delete getFrameSMS(LCH,GSM::ESTABLISH); + + LOG(INFO) << "sending " << deliver; + LCH->send(deliver,3); + + // Step 2 + // Get the CP-ACK. + // FIXME -- Check TI. + LOG(DEBUG) << "MTSMS: waiting for CP-ACK"; + GSM::L3Frame *CM = getFrameSMS(LCH); + LOG(DEBUG) << "MTSMS: ack from MS " << *CM; + if (CM->MTI()!=CPMessage::ACK) { + LOG(WARNING) << "MS rejected our RP-DATA with CP message with TI=" << CM->MTI(); + throw UnexpectedMessage(); + } + + // Step 3 + // Get CP-DATA containing RP-ACK and message reference. + LOG(DEBUG) << "MTSMS: waiting for RP-ACK"; + CM = getFrameSMS(LCH); + LOG(DEBUG) << "MTSMS: data from MS " << *CM; + if (CM->MTI()!=CPMessage::DATA) { + LOG(NOTICE) << "Unexpected SMS CP message with TI=" << CM->MTI(); + throw UnexpectedMessage(); + } + + // FIXME -- Check L3 TI. + + // Parse to check for RP-ACK. + CPData data; + try { + data.parse(*CM); + delete CM; + LOG(DEBUG) << "CPData " << data; + } + catch (SMSReadError) { + LOG(WARNING) << "SMS parsing failed (above L3)"; + // Cause 95, "semantically incorrect message". + LCH->send(CPError(L3TI,95),3); + throw UnexpectedMessage(); + } + catch (GSM::L3ReadError) { + LOG(WARNING) << "SMS parsing failed (in L3)"; + throw UnsupportedMessage(); + } + + // FIXME -- Check SMS reference. + + bool success = true; + if (data.RPDU().MTI()!=RPMessage::Ack) { + LOG(WARNING) << "unexpected RPDU " << data.RPDU(); + success = false; + } + + // Step 4 + // Send CP-ACK to the MS. + LOG(INFO) << "MTSMS: sending CPAck"; + LCH->send(CPAck(L3TI),3); + return success; +} + + + + +void Control::MTSMSController(TransactionEntry *transaction, GSM::LogicalChannel *LCH) +{ + assert(LCH); + assert(transaction); + + // See GSM 04.11 Arrow Diagram A5 for the transaction + // Step 1 Network->MS CP-DATA containing RP-DATA + // Step 2 MS->Network CP-ACK + // Step 3 MS->Network CP-DATA containing RP-ACK + // Step 4 Network->MS CP-ACK + + // LAPDm operation, from GSM 04.11, Annex F: + // """ + // Case B: Mobile terminating short message transfer, no parallel call: + // The network side, i.e. the BSS will initiate SAPI3 establishment by a + // SABM command on the DCCH when the first CP-Data message is received + // from the MSC. If no hand over occurs, the link will stay up until the + // MSC has given the last CP-ack and invokes the clearing procedure. + // """ + + + // Attach the channel to the transaction and update the state. + LOG(DEBUG) << "transaction: "<< *transaction; + transaction->channel(LCH); + transaction->GSMState(GSM::SMSDelivering); + LOG(INFO) << "transaction: "<< *transaction; + + bool success = deliverSMSToMS(transaction->calling().digits(),transaction->message(), + transaction->messageType(),transaction->L3TI(),LCH); + + // Close the Dm channel? + if (LCH->type()!=GSM::SACCHType) { + LCH->send(GSM::L3ChannelRelease()); + LOG(INFO) << "closing the Um channel"; + } + + // Ack in SIP domain. + if (success) transaction->MTSMSSendOK(); + + // Done. + gTransactionTable.remove(transaction); +} + + + + +void Control::InCallMOSMSStarter(TransactionEntry *parallelCall) +{ + GSM::LogicalChannel *hostChan = parallelCall->channel(); + assert(hostChan); + GSM::LogicalChannel *SACCH = hostChan->SACCH(); + assert(SACCH); + + // Create a partial transaction record. + TransactionEntry *newTransaction = new TransactionEntry( + gConfig.getStr("SIP.Proxy.SMS").c_str(), + parallelCall->subscriber(), + SACCH); + gTransactionTable.add(newTransaction); +} + + + +void Control::InCallMOSMSController(const CPData *cpData, TransactionEntry* transaction, GSM::SACCHLogicalChannel *LCH) +{ + LOG(INFO) << *cpData; + + // See GSM 04.11 Arrow Diagram A5 for the transaction + // Step 1 MS->Network CP-DATA containing RP-DATA + // Step 2 Network->MS CP-ACK + // Step 3 Network->MS CP-DATA containing RP-ACK + // Step 4 MS->Network CP-ACK + + // LAPDm operation, from GSM 04.11, Annex F: + // """ + // Case C: Mobile originating short message transfer, parallel call. + // The mobile station will send a SABM command on the SACCH when a CM_SERV_ACC + // message has been received from the network, allowing the short message + // transfer to start. If no hand over occurs the link will stay up until the + // MSC orders a explicit release, or the clearing procedure is invoked. If the + // parallel call is cleared before the short message transfer is finalized, the + // MSC will delay the clearing procedure toward the BSS, i.e. the channel + // release procedure is delayed. + // """ + + // Since there's a parallel call, we will assume correct provisioning. + // And we know that CM and SABM are established. + + // Step 1 already happened in the SACCH service loop. + // Just get the L3 TI and set the high bit since it originated in the MS. + unsigned L3TI = cpData->TI() | 0x08; + transaction->L3TI(L3TI); + + // Step 2 + // Respond with CP-ACK. + // This just means that we got the message. + LOG(INFO) << "sending CPAck"; + LCH->send(CPAck(L3TI),3); + + // Parse the message in CM and process RP part. + // This is where we actually parse the message and send it out. + // FIXME -- We need to set the message ref correctly, + // even if the parsing fails. + // The compiler gives a warning here. Let it. It will remind someone to fix it. + unsigned ref; + bool success = false; + try { + CPData data; + data.parse(*cpData); + LOG(INFO) << "CPData " << data; + // Transfer out the RPDU -> TPDU -> delivery. + ref = data.RPDU().reference(); + // This handler invokes higher-layer parsers, too. + success = handleRPDU(transaction,data.RPDU()); + } + catch (SMSReadError) { + LOG(WARNING) << "SMS parsing failed (above L3)"; + // Cause 95, "semantically incorrect message". + LCH->send(CPData(L3TI,RPError(95,ref)),3); + throw UnexpectedMessage(transaction->ID()); + } + catch (GSM::L3ReadError) { + LOG(WARNING) << "SMS parsing failed (in L3)"; + throw UnsupportedMessage(transaction->ID()); + } + + // Step 3 + // Send CP-DATA containing RP-ACK and message reference. + if (success) { + LOG(INFO) << "sending RPAck in CPData"; + LCH->send(CPData(L3TI,RPAck(ref)),3); + } else { + LOG(INFO) << "sending RPError in CPData"; + // Cause 127 is "internetworking error, unspecified". + // See GSM 04.11 Table 8.4. + LCH->send(CPData(L3TI,RPError(127,ref)),3); + } + + // Step 4 + // Get CP-ACK from the MS. + GSM::L3Frame* CM = getFrameSMS(LCH); + if (CM->MTI()!=CPMessage::ACK) { + LOG(NOTICE) << "unexpected SMS CP message with MTI=" << CM->MTI() << " " << *CM; + throw UnexpectedMessage(transaction->ID()); + } + LOG(DEBUG) << "ack from MS: " << *CM; + CPAck ack; + ack.parse(*CM); + LOG(INFO) << "CPAck " << ack; + + gTransactionTable.remove(transaction); +} + +// vim: ts=4 sw=4 diff --git a/Control/SMSControl.h b/Control/SMSControl.h new file mode 100644 index 0000000..69e61fc --- /dev/null +++ b/Control/SMSControl.h @@ -0,0 +1,65 @@ +/**@file Declarations for common-use control-layer functions. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef SMSCONTROL_H +#define SMSCONTROL_H + +#include + +namespace GSM { +class L3Message; +class LogicalChannel; +class SDCCHLogicalChannel; +class SACCHLogicalChannel; +class TCHFACCHLogicalChannel; +class L3CMServiceRequest; +}; + + +namespace Control { + +/** MOSMS state machine. */ +void MOSMSController(const GSM::L3CMServiceRequest *req, GSM::LogicalChannel *LCH); + +/** MOSMS-with-parallel-call state machine. */ +void InCallMOSMSStarter(TransactionEntry *parallelCall); + +/** MOSMS-with-parallel-call state machine. */ +void InCallMOSMSController(const SMS::CPData *msg, TransactionEntry* transaction, GSM::SACCHLogicalChannel *LCH); +/** + Basic SMS delivery from an established CM. + On exit, SAP3 will be in ABM and LCH will still be open. + Throws exception for failures in connection layer or for parsing failure. + @return true on success in relay layer. +*/ +bool deliverSMSToMS(const char *callingPartyDigits, const char* message, const char* contentType, unsigned TI, GSM::LogicalChannel *LCH); + +/** MTSMS */ +void MTSMSController(TransactionEntry* transaction, GSM::LogicalChannel *LCH); + +} + + + + +#endif + +// vim: ts=4 sw=4 diff --git a/Control/TMSITable.cpp b/Control/TMSITable.cpp new file mode 100644 index 0000000..aa93a85 --- /dev/null +++ b/Control/TMSITable.cpp @@ -0,0 +1,263 @@ +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "TMSITable.h" +#include +#include +#include +#include + +#include + +#include +#include +#include + +using namespace std; +using namespace Control; + + +static const char* createTMSITable = { + "CREATE TABLE IF NOT EXISTS TMSI_TABLE (" + "TMSI INTEGER PRIMARY KEY AUTOINCREMENT, " + "CREATED INTEGER NOT NULL, " // Unix time of record creation + "ACCESSED INTEGER NOT NULL, " // Unix time of last encounter + "APP_FLAGS INTEGER DEFAULT 0, " // Application-specific flags + "IMSI TEXT UNIQUE NOT NULL, " // IMSI + "IMEI TEXT, " // IMEI + "L3TI INTEGER DEFAULT 0," // L3 transaction identifier + "A5_SUPPORT INTEGER, " // encryption support + "POWER_CLASS INTEGER, " // power class + "OLD_TMSI INTEGER, " // previous TMSI in old network + "PREV_MCC INTEGER, " // previous network MCC + "PREV_MNC INTEGER, " // previous network MNC + "PREV_LAC INTEGER, " // previous network LAC + "DEG_LAT FLOAT, " // RRLP result + "DEG_LONG FLOAT " // RRLP result + ")" +}; + + + + +TMSITable::TMSITable(const char* wPath) +{ + int rc = sqlite3_open(wPath,&mDB); + if (rc) { + LOG(EMERG) << "Cannot open TMSITable database at " << wPath << ": " << sqlite3_errmsg(mDB); + sqlite3_close(mDB); + mDB = NULL; + return; + } + if (!sqlite3_command(mDB,createTMSITable)) { + LOG(EMERG) << "Cannot create TMSI table"; + } +} + + + +TMSITable::~TMSITable() +{ + if (mDB) sqlite3_close(mDB); +} + + + + +unsigned TMSITable::assign(const char* IMSI, const GSM::L3LocationUpdatingRequest* lur) +{ + // Create or find an entry based on IMSI. + // Return assigned TMSI. + assert(mDB); + + LOG(DEBUG) << "IMSI=" << IMSI; + // Is there already a record? + unsigned TMSI; + if (sqlite3_single_lookup(mDB,"TMSI_TABLE","IMSI",IMSI,"TMSI",TMSI)) { + LOG(DEBUG) << "found TMSI " << TMSI; + touch(TMSI); + return TMSI; + } + + // Create a new record. + LOG(NOTICE) << "new entry for IMSI " << IMSI; + char query[1000]; + unsigned now = (unsigned)time(NULL); + if (!lur) { + sprintf(query, + "INSERT INTO TMSI_TABLE (IMSI,CREATED,ACCESSED) " + "VALUES ('%s',%u,%u)", + IMSI,now,now); + } else { + const GSM::L3LocationAreaIdentity &lai = lur->LAI(); + const GSM::L3MobileIdentity &mid = lur->mobileID(); + if (mid.type()==GSM::TMSIType) { + sprintf(query, + "INSERT INTO TMSI_TABLE (IMSI,CREATED,ACCESSED,PREV_MCC,PREV_MNC,PREV_LAC,OLD_TMSI) " + "VALUES ('%s',%u,%u,%u,%u,%u,%u)", + IMSI,now,now,lai.MCC(),lai.MNC(),lai.LAC(),mid.TMSI()); + } else { + sprintf(query, + "INSERT INTO TMSI_TABLE (IMSI,CREATED,ACCESSED,PREV_MCC,PREV_MNC,PREV_LAC) " + "VALUES ('%s',%u,%u,%u,%u,%u)", + IMSI,now,now,lai.MCC(),lai.MNC(),lai.LAC()); + } + } + if (!sqlite3_command(mDB,query)) { + LOG(ALERT) << "TMSI creation failed"; + return 0; + } + if (!sqlite3_single_lookup(mDB,"TMSI_TABLE","IMSI",IMSI,"TMSI",TMSI)) { + LOG(ERR) << "TMSI database inconsistancy"; + return 0; + } + return TMSI; +} + + + +void TMSITable::touch(unsigned TMSI) const +{ + // Update timestamp. + char query[100]; + sprintf(query,"UPDATE TMSI_TABLE SET ACCESSED = %u WHERE TMSI == %u", + (unsigned)time(NULL),TMSI); + sqlite3_command(mDB,query); +} + + + +// Returned string must be free'd by the caller. +char* TMSITable::IMSI(unsigned TMSI) const +{ + char* IMSI = NULL; + if (sqlite3_single_lookup(mDB,"TMSI_TABLE","TMSI",TMSI,"IMSI",IMSI)) touch(TMSI); + return IMSI; +} + +unsigned TMSITable::TMSI(const char* IMSI) const +{ + unsigned TMSI=0; + if (sqlite3_single_lookup(mDB,"TMSI_TABLE","IMSI",IMSI,"TMSI",TMSI)) touch(TMSI); + return TMSI; +} + + + +void printAge(unsigned seconds, ostream& os) +{ + static const unsigned k=5; + os << setw(4); + if (seconds + +#include +#include + + +struct sqlite3; + +namespace GSM { +class L3LocationUpdatingRequest; +class L3MobileStationClassmark2; +class L3MobileIdentity; +} + + +namespace Control { + +class TMSITable { + + private: + + sqlite3 *mDB; ///< database connection + + + public: + + TMSITable(const char*wPath); + + ~TMSITable(); + + /** + Create a new entry in the table. + @param IMSI The IMSI to create an entry for. + @param The associated LUR, if any. + @return The assigned TMSI. + */ + unsigned assign(const char* IMSI, const GSM::L3LocationUpdatingRequest* lur=NULL); + + /** + Find an IMSI in the table. + This is a log-time operation. + @param TMSI The TMSI to find. + @return Pointer to IMSI to be freed by the caller, or NULL. + */ + char* IMSI(unsigned TMSI) const; + + /** + Find a TMSI in the table. + This is a linear-time operation. + @param IMSI The IMSI to mach. + @return A TMSI value or zero on failure. + */ + unsigned TMSI(const char* IMSI) const; + + /** Write entries as text to a stream. */ + void dump(std::ostream&) const; + + /** Clear the table completely. */ + void clear(); + + /** Set the IMEI. */ + bool IMEI(const char* IMSI, const char* IMEI); + + /** Set the classmark. */ + bool classmark(const char* IMSI, const GSM::L3MobileStationClassmark2& classmark); + + /** Get the next TI value to use for this IMSI or TMSI. */ + unsigned nextL3TI(const char* IMSI); + + private: + + /** Update the "accessed" time on a record. */ + void touch(unsigned TMSI) const; +}; + + +} + +#endif + +// vim: ts=4 sw=4 diff --git a/Control/TransactionTable.cpp b/Control/TransactionTable.cpp new file mode 100644 index 0000000..9ac189d --- /dev/null +++ b/Control/TransactionTable.cpp @@ -0,0 +1,777 @@ +/**@file TransactionTable and related classes. */ + +/* +* Copyright 2008, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Process, Inc. +* Copyright 2011 Raqnge Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "TransactionTable.h" +#include "ControlCommon.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include +#undef WARNING + + +using namespace std; +using namespace GSM; +using namespace Control; +using namespace SIP; + + + + + + +void TransactionEntry::initTimers() +{ + // Call this only once. + // TODO -- It would be nice if these were all configurable. + assert(mTimers.size()==0); + mTimers["301"] = Z100Timer(T301ms); + mTimers["302"] = Z100Timer(T302ms); + mTimers["303"] = Z100Timer(T303ms); + mTimers["304"] = Z100Timer(T304ms); + mTimers["305"] = Z100Timer(T305ms); + mTimers["308"] = Z100Timer(T308ms); + mTimers["310"] = Z100Timer(T310ms); + mTimers["313"] = Z100Timer(T313ms); + mTimers["3113"] = Z100Timer(gConfig.getNum("GSM.Timer.T3113")); + mTimers["TR1M"] = Z100Timer(TR1Mms); +} + + + + + +// Form for MT transactions. +TransactionEntry::TransactionEntry( + const char* proxy, + const L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const L3CMServiceType& wService, + const L3CallingPartyBCDNumber& wCalling, + GSM::CallState wState, + const char *wMessage) + :mID(gTransactionTable.newID()), + mSubscriber(wSubscriber),mService(wService), + mL3TI(gTMSITable.nextL3TI(wSubscriber.digits())), + mCalling(wCalling), + mSIP(proxy,mSubscriber.digits()), + mGSMState(wState), + mNumSQLTries(gConfig.getNum("Control.NumSQLTries")), + mChannel(wChannel), + mTerminationRequested(false) +{ + if (wMessage) mMessage.assign(wMessage); //strncpy(mMessage,wMessage,160); + else mMessage.assign(""); //mMessage[0]='\0'; + initTimers(); +} + +// Form for MOC transactions. +TransactionEntry::TransactionEntry( + const char* proxy, + const L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const L3CMServiceType& wService, + unsigned wL3TI, + const L3CalledPartyBCDNumber& wCalled) + :mID(gTransactionTable.newID()), + mSubscriber(wSubscriber),mService(wService), + mL3TI(wL3TI), + mCalled(wCalled), + mSIP(proxy,mSubscriber.digits()), + mGSMState(GSM::MOCInitiated), + mNumSQLTries(gConfig.getNum("Control.NumSQLTries")), + mChannel(wChannel), + mTerminationRequested(false) +{ + assert(mSubscriber.type()==GSM::IMSIType); + mMessage.assign(""); //mMessage[0]='\0'; + initTimers(); +} + + +// Form for SOS transactions. +TransactionEntry::TransactionEntry( + const char* proxy, + const L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const L3CMServiceType& wService, + unsigned wL3TI) + :mID(gTransactionTable.newID()), + mSubscriber(wSubscriber),mService(wService), + mL3TI(wL3TI), + mSIP(proxy,mSubscriber.digits()), + mGSMState(GSM::MOCInitiated), + mNumSQLTries(2*gConfig.getNum("Control.NumSQLTries")), + mChannel(wChannel), + mTerminationRequested(false) +{ + mMessage.assign(""); //mMessage[0]='\0'; + initTimers(); +} + + +// Form for MO-SMS transactions. +TransactionEntry::TransactionEntry( + const char* proxy, + const L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const L3CalledPartyBCDNumber& wCalled, + const char* wMessage) + :mID(gTransactionTable.newID()), + mSubscriber(wSubscriber), + mService(GSM::L3CMServiceType::ShortMessage), + mL3TI(7),mCalled(wCalled), + mSIP(proxy,mSubscriber.digits()), + mGSMState(GSM::SMSSubmitting), + mNumSQLTries(gConfig.getNum("Control.NumSQLTries")), + mChannel(wChannel), + mTerminationRequested(false) +{ + assert(mSubscriber.type()==GSM::IMSIType); + if (wMessage!=NULL) mMessage.assign(wMessage); //strncpy(mMessage,wMessage,160); + else mMessage.assign(""); //mMessage[0]='\0'; + initTimers(); +} + +// Form for MO-SMS transactions with parallel call. +TransactionEntry::TransactionEntry( + const char* proxy, + const L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel) + :mID(gTransactionTable.newID()), + mSubscriber(wSubscriber), + mService(GSM::L3CMServiceType::ShortMessage), + mL3TI(7), + mSIP(proxy,mSubscriber.digits()), + mGSMState(GSM::SMSSubmitting), + mNumSQLTries(gConfig.getNum("Control.NumSQLTries")), + mChannel(wChannel), + mTerminationRequested(false) +{ + assert(mSubscriber.type()==GSM::IMSIType); + mMessage[0]='\0'; + initTimers(); +} + + + +TransactionEntry::~TransactionEntry() +{ +} + + +bool TransactionEntry::timerExpired(const char* name) const +{ + TimerTable::const_iterator itr = mTimers.find(name); + assert(itr!=mTimers.end()); + ScopedLock lock(mLock); + return (itr->second).expired(); +} + + +bool TransactionEntry::anyTimerExpired() const +{ + ScopedLock lock(mLock); + TimerTable::const_iterator itr = mTimers.begin(); + while (itr!=mTimers.end()) { + if ((itr->second).expired()) { + LOG(INFO) << itr->first << " expired in " << *this; + return true; + } + ++itr; + } + return false; +} + + +void TransactionEntry::resetTimers() +{ + ScopedLock lock(mLock); + TimerTable::iterator itr = mTimers.begin(); + while (itr!=mTimers.end()) { + (itr->second).reset(); + ++itr; + } +} + + + +bool TransactionEntry::dead() const +{ + ScopedLock lock(mLock); + + // Null state? + if (mGSMState==GSM::NullState && stateAge()>180*1000) return true; + // Stuck in proceeding? + if (mSIP.state()==Proceeding && stateAge()>180*1000) return true; + + // Paging timed out? + if (mGSMState==GSM::Paging) { + TimerTable::const_iterator itr = mTimers.find("3113"); + assert(itr!=mTimers.end()); + return (itr->second).expired(); + } + + return false; +} + + + +ostream& Control::operator<<(ostream& os, const TransactionEntry& entry) +{ + entry.text(os); + return os; +} + + + +void TransactionEntry::text(ostream& os) const +{ + ScopedLock lock(mLock); + os << mID; + if (mChannel) os << " " << *mChannel; + else os << " no chan"; + os << " " << mSubscriber; + os << " L3TI=" << mL3TI; + os << " SIP-call-id=" << mSIP.callID(); + os << " SIP-proxy=" << mSIP.proxyIP() << ":" << mSIP.proxyPort(); + os << " " << mService; + if (mCalled.digits()[0]) os << " to=" << mCalled.digits(); + if (mCalling.digits()[0]) os << " from=" << mCalling.digits(); + os << " GSMState=" << mGSMState; + os << " SIPState=" << mSIP.state(); + os << " (" << (stateAge()+500)/1000 << " sec)"; + if (mMessage[0]) os << " message=\"" << mMessage << "\""; +} + +void TransactionEntry::message(const char *wMessage, size_t length) +{ + /*if (length>520) { + LOG(NOTICE) << "truncating long message: " << wMessage; + length=520; + }*/ + ScopedLock lock(mLock); + //memcpy(mMessage,wMessage,length); + //mMessage[length]='\0'; + mMessage.assign(wMessage, length); +} + +void TransactionEntry::messageType(const char *wContentType) +{ + ScopedLock lock(mLock); + mContentType.assign(wContentType); +} + + + + + +void TransactionEntry::channel(GSM::LogicalChannel* wChannel) +{ + ScopedLock lock(mLock); + mChannel = wChannel; +} + + +void TransactionEntry::GSMState(GSM::CallState wState) +{ + ScopedLock lock(mLock); + mGSMState = wState; + mStateTimer.now(); +} + + +void TransactionEntry::echoSIPState(SIP::SIPState state) const +{ + // Caller should hold mLock. + if (mPrevSIPState==state) return; + mPrevSIPState = state; +} + + + + +SIP::SIPState TransactionEntry::MOCSendINVITE(const char* calledUser, const char* calledDomain, short rtpPort, unsigned codec) +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOCSendINVITE(calledUser,calledDomain,rtpPort,codec); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MOCResendINVITE() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOCResendINVITE(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MOCWaitForOK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOCWaitForOK(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MOCSendACK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOCSendACK(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::SOSSendINVITE(short rtpPort, unsigned codec) +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.SOSSendINVITE(rtpPort,codec); + echoSIPState(state); + return state; +} + + +SIP::SIPState TransactionEntry::MTCSendTrying() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTCSendTrying(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTCSendRinging() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTCSendRinging(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTCWaitForACK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTCWaitForACK(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTCCheckForCancel() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTCCheckForCancel(); + echoSIPState(state); + return state; +} + + +SIP::SIPState TransactionEntry::MTCSendOK(short rtpPort, unsigned codec) +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTCSendOK(rtpPort,codec); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MODSendBYE() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MODSendBYE(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MODResendBYE() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MODResendBYE(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MODWaitForOK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MODWaitForOK(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTDCheckBYE() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTDCheckBYE(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTDSendOK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTDSendOK(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MOSMSSendMESSAGE(const char* calledUser, const char* calledDomain, const char* contentType) +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOSMSSendMESSAGE(calledUser,calledDomain,mMessage.c_str(),contentType); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MOSMSWaitForSubmit() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MOSMSWaitForSubmit(); + echoSIPState(state); + return state; +} + +SIP::SIPState TransactionEntry::MTSMSSendOK() +{ + ScopedLock lock(mLock); + SIP::SIPState state = mSIP.MTSMSSendOK(); + echoSIPState(state); + return state; +} + +bool TransactionEntry::sendINFOAndWaitForOK(unsigned info) +{ + ScopedLock lock(mLock); + return mSIP.sendINFOAndWaitForOK(info); +} + +void TransactionEntry::SIPUser(const char* IMSI) +{ + ScopedLock lock(mLock); + mSIP.user(IMSI); +} + +void TransactionEntry::SIPUser(const char* callID, const char *IMSI , const char *origID, const char *origHost) +{ + ScopedLock lock(mLock); + mSIP.user(callID,IMSI,origID,origHost); +} + +void TransactionEntry::called(const L3CalledPartyBCDNumber& wCalled) +{ + ScopedLock lock(mLock); + mCalled = wCalled; +} + + +void TransactionEntry::L3TI(unsigned wL3TI) +{ + ScopedLock lock(mLock); + mL3TI = wL3TI; +} + + +bool TransactionEntry::terminationRequested() +{ + ScopedLock lock(mLock); + bool retVal = mTerminationRequested; + mTerminationRequested = false; + return retVal; +} + + + +TransactionTable::TransactionTable() + // This assumes the main application uses sdevrandom. + :mIDCounter(random()) +{ +} + + + +TransactionTable::~TransactionTable() +{ + // Don't bother disposing of the memory, + // since this is only invoked when the application exits. + if (mDB) sqlite3_close(mDB); +} + + + + +unsigned TransactionTable::newID() +{ + ScopedLock lock(mLock); + return mIDCounter++; +} + + +void TransactionTable::add(TransactionEntry* value) +{ + LOG(INFO) << "new transaction " << *value; + ScopedLock lock(mLock); + mTable[value->ID()]=value; +} + + + +TransactionEntry* TransactionTable::find(unsigned key) +{ + // Since this is a log-time operation, we don't screw that up by calling clearDeadEntries. + + // ID==0 is a non-valid special case. + LOG(DEBUG) << "by key: " << key; + assert(key); + ScopedLock lock(mLock); + TransactionMap::iterator itr = mTable.find(key); + if (itr==mTable.end()) return NULL; + if (itr->second->dead()) { + innerRemove(itr); + return NULL; + } + return (itr->second); +} + + +void TransactionTable::innerRemove(TransactionMap::iterator itr) +{ + LOG(DEBUG) << "removing transaction: " << *(itr->second); + gSIPInterface.removeCall(itr->second->SIPCallID()); + delete itr->second; + mTable.erase(itr); +} + + +bool TransactionTable::remove(unsigned key) +{ + // ID==0 is a non-valid special case, and it shouldn't be passed here. + if (key==0) { + LOG(ERR) << "called with key==0"; + return false; + } + + ScopedLock lock(mLock); + TransactionMap::iterator itr = mTable.find(key); + if (itr==mTable.end()) return false; + innerRemove(itr); + return true; +} + +bool TransactionTable::removePaging(unsigned key) +{ + // ID==0 is a non-valid special case and should not be passed here. + assert(key); + ScopedLock lock(mLock); + TransactionMap::iterator itr = mTable.find(key); + if (itr==mTable.end()) return false; + if (itr->second->GSMState()!=GSM::Paging) return false; + innerRemove(itr); + return true; +} + + + + +void TransactionTable::clearDeadEntries() +{ + // Caller should hold mLock. + TransactionMap::iterator itr = mTable.begin(); + while (itr!=mTable.end()) { + if (!itr->second->dead()) ++itr; + else { + LOG(DEBUG) << "erasing " << itr->first; + TransactionMap::iterator old = itr; + itr++; + innerRemove(old); + } + } +} + + + + +TransactionEntry* TransactionTable::find(const GSM::LogicalChannel *chan) +{ + LOG(DEBUG) << "by channel: " << *chan << " (" << chan << ")"; + + // Yes, it's linear time. + // Since clearDeadEntries is also linear, do that here, too. + clearDeadEntries(); + + // Brute force search. + ScopedLock lock(mLock); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + const GSM::LogicalChannel* thisChan = itr->second->channel(); + //LOG(DEBUG) << "looking for " << *chan << " (" << chan << ")" << ", found " << *(thisChan) << " (" << thisChan << ")"; + if ((void*)thisChan == (void*)chan) return itr->second; + } + //LOG(DEBUG) << "no match for " << *chan << " (" << chan << ")"; + return NULL; +} + + +TransactionEntry* TransactionTable::find(const L3MobileIdentity& mobileID, GSM::CallState state) +{ + LOG(DEBUG) << "by ID and state: " << mobileID << " in " << state; + + // Yes, it's linear time. + // Since clearDeadEntries is also linear, do that here, too. + clearDeadEntries(); + + // Brtue force search. + ScopedLock lock(mLock); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (itr->second->GSMState() != state) continue; + if (itr->second->subscriber() == mobileID) return itr->second; + } + return NULL; +} + + +TransactionEntry* TransactionTable::find(const L3MobileIdentity& mobileID, const char* callID) +{ + assert(callID); + LOG(DEBUG) << "by ID and call-ID: " << mobileID << ", call " << callID; + + string callIDString = string(callID); + // Yes, it's linear time. + // Since clearDeadEntries is also linear, do that here, too. + clearDeadEntries(); + + // Brtue force search. + ScopedLock lock(mLock); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (itr->second->mSIP.callID() != callIDString) continue; + if (itr->second->subscriber() == mobileID) return itr->second; + } + return NULL; +} + + +TransactionEntry* TransactionTable::answeredPaging(const L3MobileIdentity& mobileID) +{ + // Yes, it's linear time. + // Even in a 6-ARFCN system, it should rarely be more than a dozen entries. + + // Since clearDeadEntries is also linear, do that here, too. + clearDeadEntries(); + + // Brtue force search. + ScopedLock lock(mLock); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (itr->second->GSMState() != GSM::Paging) continue; + if (itr->second->subscriber() == mobileID) { + // Stop T3113 and change the state. + itr->second->GSMState(AnsweredPaging); + itr->second->resetTimer("3113"); + return itr->second; + } + } + return NULL; +} + + +GSM::LogicalChannel* TransactionTable::findChannel(const L3MobileIdentity& mobileID) +{ + // Yes, it's linear time. + // Even in a 6-ARFCN system, it should rarely be more than a dozen entries. + + // Since clearDeadEntries is also linear, do that here, too. + clearDeadEntries(); + + // Brtue force search. + ScopedLock lock(mLock); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (itr->second->subscriber() != mobileID) continue; + GSM::LogicalChannel* chan = itr->second->channel(); + if (!chan) continue; + if (chan->type() == FACCHType) return chan; + if (chan->type() == SDCCHType) return chan; + } + return NULL; +} + + +unsigned TransactionTable::countChan(const GSM::LogicalChannel* chan) +{ + ScopedLock lock(mLock); + clearDeadEntries(); + unsigned count = 0; + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (itr->second->channel() == chan) count++; + } + return count; +} + + + +size_t TransactionTable::dump(ostream& os) const +{ + ScopedLock lock(mLock); + for (TransactionMap::const_iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + os << *(itr->second) << endl; + } + return mTable.size(); +} + + +TransactionEntry* TransactionTable::findLongestCall() +{ + ScopedLock lock(mLock); + clearDeadEntries(); + long longTime = 0; + TransactionMap::iterator longCall = mTable.end(); + for (TransactionMap::iterator itr = mTable.begin(); itr!=mTable.end(); ++itr) { + if (!(itr->second->channel())) continue; + if (itr->second->GSMState() != GSM::Active) continue; + long runTime = itr->second->stateAge(); + if (runTime > longTime) { + runTime = longTime; + longCall = itr; + } + } + if (longCall == mTable.end()) return NULL; + return longCall->second; +} + + + + +// vim: ts=4 sw=4 diff --git a/Control/TransactionTable.h b/Control/TransactionTable.h new file mode 100644 index 0000000..f9f54a2 --- /dev/null +++ b/Control/TransactionTable.h @@ -0,0 +1,433 @@ +/**@file Declarations for TransactionTable and related classes. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef TRANSACTIONTABLE_H +#define TRANSACTIONTABLE_H + + +#include +#include + +#include +#include +#include + + +#include +#include +#include +#include +#include + + + +struct sqlite3; + + +/**@namespace Control This namepace is for use by the control layer. */ +namespace Control { + +typedef std::map TimerTable; + + + + +/** + A TransactionEntry object is used to maintain the state of a transaction + as it moves from channel to channel. + The object itself is not thread safe. +*/ +class TransactionEntry { + + private: + + mutable Mutex mLock; ///< thread-safe control, shared from gTransactionTable + + /**@name Stable variables, fixed in the constructor or written only once. */ + //@{ + unsigned mID; ///< the internal transaction ID, assigned by a TransactionTable + + GSM::L3MobileIdentity mSubscriber; ///< some kind of subscriber ID, preferably IMSI + GSM::L3CMServiceType mService; ///< the associated service type + unsigned mL3TI; ///< the L3 short transaction ID, the version we *send* to the MS + + GSM::L3CalledPartyBCDNumber mCalled; ///< the associated called party number, if known + GSM::L3CallingPartyBCDNumber mCalling; ///< the associated calling party number, if known + + // TODO -- This should be expaned to deal with long messages. + //char mMessage[522]; ///< text messaging payload + std::string mMessage; ///< text message payload + std::string mContentType; ///< text message payload content type + //@} + + SIP::SIPEngine mSIP; ///< the SIP IETF RFC-3621 protocol engine + mutable SIP::SIPState mPrevSIPState; ///< previous SIP state, prior to most recent transactions + GSM::CallState mGSMState; ///< the GSM/ISDN/Q.931 call state + Timeval mStateTimer; ///< timestamp of last state change. + TimerTable mTimers; ///< table of Z100-type state timers + + unsigned mNumSQLTries; ///< number of SQL tries for DB operations + + GSM::LogicalChannel *mChannel; ///< current channel of the transaction + + bool mTerminationRequested; + + public: + + /** This form is used for MTC or MT-SMS with TI generated by the network. */ + TransactionEntry(const char* proxy, + const GSM::L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const GSM::L3CMServiceType& wService, + const GSM::L3CallingPartyBCDNumber& wCalling, + GSM::CallState wState = GSM::NullState, + const char *wMessage = NULL); + + /** This form is used for MOC, setting mGSMState to MOCInitiated. */ + TransactionEntry(const char* proxy, + const GSM::L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const GSM::L3CMServiceType& wService, + unsigned wL3TI, + const GSM::L3CalledPartyBCDNumber& wCalled); + + /** This form is used for SOS calls, setting mGSMState to MOCInitiated. */ + TransactionEntry(const char* proxy, + const GSM::L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const GSM::L3CMServiceType& wService, + unsigned wL3TI); + + /** Form for MO-SMS; sets yet-unknown TI to 7 and GSM state to SMSSubmitting */ + TransactionEntry(const char* proxy, + const GSM::L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel, + const GSM::L3CalledPartyBCDNumber& wCalled, + const char* wMessage); + + /** Form for MO-SMS with a parallel call; sets yet-unknown TI to 7 and GSM state to SMSSubmitting */ + TransactionEntry(const char* proxy, + const GSM::L3MobileIdentity& wSubscriber, + GSM::LogicalChannel* wChannel); + + + /** Delete the database entry upon destruction. */ + ~TransactionEntry(); + + /**@name Accessors. */ + //@{ + unsigned L3TI() const { return mL3TI; } + void L3TI(unsigned wL3TI); + + const GSM::LogicalChannel* channel() const { return mChannel; } + GSM::LogicalChannel* channel() { return mChannel; } + + void channel(GSM::LogicalChannel* wChannel); + + const GSM::L3MobileIdentity& subscriber() const { return mSubscriber; } + + const GSM::L3CMServiceType& service() const { return mService; } + + const GSM::L3CalledPartyBCDNumber& called() const { return mCalled; } + void called(const GSM::L3CalledPartyBCDNumber&); + + const GSM::L3CallingPartyBCDNumber& calling() const { return mCalling; } + + const char* message() const { return mMessage.c_str(); } + void message(const char *wMessage, size_t length); + const char* messageType() const { return mContentType.c_str(); } + void messageType(const char *wContentType); + + unsigned ID() const { return mID; } + + GSM::CallState GSMState() const { ScopedLock lock(mLock); return mGSMState; } + void GSMState(GSM::CallState wState); + + //@} + + + /** Initiate the termination process. */ + void terminate() { ScopedLock lock(mLock); mTerminationRequested=true; } + + bool terminationRequested(); + + /**@name SIP-side operations */ + //@{ + + SIP::SIPState SIPState() { ScopedLock lock(mLock); return mSIP.state(); } + + SIP::SIPState MOCSendINVITE(const char* calledUser, const char* calledDomain, short rtpPort, unsigned codec); + SIP::SIPState MOCResendINVITE(); + SIP::SIPState MOCWaitForOK(); + SIP::SIPState MOCSendACK(); + void MOCInitRTP() { ScopedLock lock(mLock); return mSIP.MOCInitRTP(); } + + SIP::SIPState SOSSendINVITE(short rtpPort, unsigned codec); + SIP::SIPState SOSResendINVITE() { return MOCResendINVITE(); } + SIP::SIPState SOSWaitForOK() { return MOCWaitForOK(); } + SIP::SIPState SOSSendACK() { return MOCSendACK(); } + void SOSInitRTP() { MOCInitRTP(); } + + + SIP::SIPState MTCSendTrying(); + SIP::SIPState MTCSendRinging(); + SIP::SIPState MTCWaitForACK(); + SIP::SIPState MTCCheckForCancel(); + SIP::SIPState MTCSendOK(short rtpPort, unsigned codec); + void MTCInitRTP() { ScopedLock lock(mLock); mSIP.MTCInitRTP(); } + + SIP::SIPState MODSendBYE(); + SIP::SIPState MODResendBYE(); + SIP::SIPState MODWaitForOK(); + + SIP::SIPState MTDCheckBYE(); + SIP::SIPState MTDSendOK(); + + // TODO: Remove contentType from here and use the setter above. + SIP::SIPState MOSMSSendMESSAGE(const char* calledUser, const char* calledDomain, const char* contentType); + SIP::SIPState MOSMSWaitForSubmit(); + + SIP::SIPState MTSMSSendOK(); + + bool sendINFOAndWaitForOK(unsigned info); + + void txFrame(unsigned char* frame) { return mSIP.txFrame(frame); } + int rxFrame(unsigned char* frame) { return mSIP.rxFrame(frame); } + bool startDTMF(char key) { return mSIP.startDTMF(key); } + void stopDTMF() { mSIP.stopDTMF(); } + + void SIPUser(const std::string& IMSI) { SIPUser(IMSI.c_str()); } + void SIPUser(const char* IMSI); + void SIPUser(const char* callID, const char *IMSI , const char *origID, const char *origHost); + + const std::string SIPCallID() const { ScopedLock lock(mLock); return mSIP.callID(); } + + // These are called by SIPInterface. + void saveINVITE(const osip_message_t* invite, bool local) + { ScopedLock lock(mLock); mSIP.saveINVITE(invite,local); } + void saveBYE(const osip_message_t* bye, bool local) + { ScopedLock lock(mLock); mSIP.saveBYE(bye,local); } + + //@} + + unsigned stateAge() const { ScopedLock lock(mLock); return mStateTimer.elapsed(); } + + /**@name Timer access. */ + //@{ + + bool timerExpired(const char* name) const; + + void setTimer(const char* name) + { ScopedLock lock(mLock); return mTimers[name].set(); } + + void setTimer(const char* name, long newLimit) + { ScopedLock lock(mLock); return mTimers[name].set(newLimit); } + + void resetTimer(const char* name) + { ScopedLock lock(mLock); return mTimers[name].reset(); } + + /** Return true if any Q.931 timer is expired. */ + bool anyTimerExpired() const; + + /** Reset all Q.931 timers. */ + void resetTimers(); + + //@} + + /** Return true if clearing is in progress in the GSM side. */ + bool clearingGSM() const + { ScopedLock lock(mLock); return (mGSMState==GSM::ReleaseRequest) || (mGSMState==GSM::DisconnectIndication); } + + /** Retrns true if the transaction is "dead". */ + bool dead() const; + + /** Dump information as text for debugging. */ + void text(std::ostream&) const; + + private: + + friend class TransactionTable; + + /** Create L3 timers from GSM and Q.931 (network side) */ + void initTimers(); + + /** Echo latest SIPSTATE to the database. */ + void echoSIPState(SIP::SIPState state) const; +}; + + +std::ostream& operator<<(std::ostream& os, const TransactionEntry&); + + +/** A map of transactions keyed by ID. */ +class TransactionMap : public std::map {}; + +/** + A table for tracking the states of active transactions. +*/ +class TransactionTable { + + private: + + sqlite3 *mDB; ///< database connection + + TransactionMap mTable; + mutable Mutex mLock; + unsigned mIDCounter; + + public: + + /** + Create a transaction table. + @param path Path fto sqlite3 database file. + */ + TransactionTable(); + + ~TransactionTable(); + + // TransactionTable does not need a destructor. + + /** + Return a new ID for use in the table. + */ + unsigned newID(); + + /** + Insert a new entry into the table; deleted by the table later. + @param value The entry to insert into the table; will be deleted by the table later. + */ + void add(TransactionEntry* value); + + /** + Find an entry and return a pointer into the table. + @param wID The transaction ID to search + @return NULL if ID is not found or was dead + */ + TransactionEntry* find(unsigned wID); + + /** + Find the longest-running non-SOS call. + @return NULL if there are no calls or if all are SOS. + */ + TransactionEntry* findLongestCall(); + + /** + Remove an entry from the table and from gSIPMessageMap. + @param wID The transaction ID to search. + @return True if the ID was really in the table and deleted. + */ + bool remove(unsigned wID); + + bool remove(TransactionEntry* transaction) { return remove(transaction->ID()); } + + /** + Remove an entry from the table and from gSIPMessageMap, + if it is in the Paging state. + @param wID The transaction ID to search. + @return True if the ID was really in the table and deleted. + */ + bool removePaging(unsigned wID); + + + /** + Find an entry by its channel pointer. + Also clears dead entries during search. + @param chan The channel pointer to the first record found. + @return pointer to entry or NULL if no active match + */ + TransactionEntry* find(const GSM::LogicalChannel *chan); + + /** + Find an entry in the given state by its mobile ID. + Also clears dead entries during search. + @param mobileID The mobile to search for. + @return pointer to entry or NULL if no match + */ + TransactionEntry* find(const GSM::L3MobileIdentity& mobileID, GSM::CallState state); + + + /** Find by subscriber and SIP call ID. */ + TransactionEntry* find(const GSM::L3MobileIdentity& mobileID, const char* callID); + + /** + Find an entry in the Paging state by its mobile ID, change state to AnsweredPaging and reset T3113. + Also clears dead entries during search. + @param mobileID The mobile to search for. + @return pointer to entry or NULL if no match + */ + TransactionEntry* answeredPaging(const GSM::L3MobileIdentity& mobileID); + + + /** + Find the channel, if any, used for current transactions by this mobile ID. + @param mobileID The target mobile subscriber. + @return pointer to TCH/FACCH, SDCCH or NULL. + */ + GSM::LogicalChannel* findChannel(const GSM::L3MobileIdentity& mobileID); + + /** Count the number of transactions using a particular channel. */ + unsigned countChan(const GSM::LogicalChannel*); + + size_t size() { ScopedLock lock(mLock); return mTable.size(); } + + size_t dump(std::ostream& os) const; + + + private: + + friend class TransactionEntry; + + /** Accessor to database connection. */ + sqlite3* DB() { return mDB; } + + /** + Remove "dead" entries from the table. + A "dead" entry is a transaction that is no longer active. + The caller should hold mLock. + */ + void clearDeadEntries(); + + /** + Remove and entry from the table and from gSIPInterface. + */ + void innerRemove(TransactionMap::iterator); + +}; + + + + + +} //Control + + + +/**@addtogroup Globals */ +//@{ +/** A single global transaction table in the global namespace. */ +extern Control::TransactionTable gTransactionTable; +//@} + + + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSM610Tables.cpp b/GSM/GSM610Tables.cpp new file mode 100644 index 0000000..fe1933c --- /dev/null +++ b/GSM/GSM610Tables.cpp @@ -0,0 +1,495 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "GSM610Tables.h" + + +/* +RFC 3551 RTP A/V Profile July 2003 + + + Octet Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7 + _____________________________________________________________________ + 0 1 1 0 1 LARc0.0 LARc0.1 LARc0.2 LARc0.3 + 1 LARc0.4 LARc0.5 LARc1.0 LARc1.1 LARc1.2 LARc1.3 LARc1.4 LARc1.5 + 2 LARc2.0 LARc2.1 LARc2.2 LARc2.3 LARc2.4 LARc3.0 LARc3.1 LARc3.2 + 3 LARc3.3 LARc3.4 LARc4.0 LARc4.1 LARc4.2 LARc4.3 LARc5.0 LARc5.1 + 4 LARc5.2 LARc5.3 LARc6.0 LARc6.1 LARc6.2 LARc7.0 LARc7.1 LARc7.2 + 5 Nc0.0 Nc0.1 Nc0.2 Nc0.3 Nc0.4 Nc0.5 Nc0.6 bc0.0 + 6 bc0.1 Mc0.0 Mc0.1 xmaxc00 xmaxc01 xmaxc02 xmaxc03 xmaxc04 + 7 xmaxc05 xmc0.0 xmc0.1 xmc0.2 xmc1.0 xmc1.1 xmc1.2 xmc2.0 + 8 xmc2.1 xmc2.2 xmc3.0 xmc3.1 xmc3.2 xmc4.0 xmc4.1 xmc4.2 + 9 xmc5.0 xmc5.1 xmc5.2 xmc6.0 xmc6.1 xmc6.2 xmc7.0 xmc7.1 + 10 xmc7.2 xmc8.0 xmc8.1 xmc8.2 xmc9.0 xmc9.1 xmc9.2 xmc10.0 + 11 xmc10.1 xmc10.2 xmc11.0 xmc11.1 xmc11.2 xmc12.0 xmc12.1 xcm12.2 + 12 Nc1.0 Nc1.1 Nc1.2 Nc1.3 Nc1.4 Nc1.5 Nc1.6 bc1.0 + 13 bc1.1 Mc1.0 Mc1.1 xmaxc10 xmaxc11 xmaxc12 xmaxc13 xmaxc14 + 14 xmax15 xmc13.0 xmc13.1 xmc13.2 xmc14.0 xmc14.1 xmc14.2 xmc15.0 + 15 xmc15.1 xmc15.2 xmc16.0 xmc16.1 xmc16.2 xmc17.0 xmc17.1 xmc17.2 + 16 xmc18.0 xmc18.1 xmc18.2 xmc19.0 xmc19.1 xmc19.2 xmc20.0 xmc20.1 + 17 xmc20.2 xmc21.0 xmc21.1 xmc21.2 xmc22.0 xmc22.1 xmc22.2 xmc23.0 + 18 xmc23.1 xmc23.2 xmc24.0 xmc24.1 xmc24.2 xmc25.0 xmc25.1 xmc25.2 + 19 Nc2.0 Nc2.1 Nc2.2 Nc2.3 Nc2.4 Nc2.5 Nc2.6 bc2.0 + 20 bc2.1 Mc2.0 Mc2.1 xmaxc20 xmaxc21 xmaxc22 xmaxc23 xmaxc24 + 21 xmaxc25 xmc26.0 xmc26.1 xmc26.2 xmc27.0 xmc27.1 xmc27.2 xmc28.0 + 22 xmc28.1 xmc28.2 xmc29.0 xmc29.1 xmc29.2 xmc30.0 xmc30.1 xmc30.2 + 23 xmc31.0 xmc31.1 xmc31.2 xmc32.0 xmc32.1 xmc32.2 xmc33.0 xmc33.1 + 24 xmc33.2 xmc34.0 xmc34.1 xmc34.2 xmc35.0 xmc35.1 xmc35.2 xmc36.0 + 25 Xmc36.1 xmc36.2 xmc37.0 xmc37.1 xmc37.2 xmc38.0 xmc38.1 xmc38.2 + 26 Nc3.0 Nc3.1 Nc3.2 Nc3.3 Nc3.4 Nc3.5 Nc3.6 bc3.0 + 27 bc3.1 Mc3.0 Mc3.1 xmaxc30 xmaxc31 xmaxc32 xmaxc33 xmaxc34 + 28 xmaxc35 xmc39.0 xmc39.1 xmc39.2 xmc40.0 xmc40.1 xmc40.2 xmc41.0 + 29 xmc41.1 xmc41.2 xmc42.0 xmc42.1 xmc42.2 xmc43.0 xmc43.1 xmc43.2 + 30 xmc44.0 xmc44.1 xmc44.2 xmc45.0 xmc45.1 xmc45.2 xmc46.0 xmc46.1 + 31 xmc46.2 xmc47.0 xmc47.1 xmc47.2 xmc48.0 xmc48.1 xmc48.2 xmc49.0 + 32 xmc49.1 xmc49.2 xmc50.0 xmc50.1 xmc50.2 xmc51.0 xmc51.1 xmc51.2 + + Table 3: GSM payload format +*/ + + +/* + This file encodes a mapping between + GSM 05.03 Table 2 and RFC-3551 Table 3. +*/ + +/* + Naming convention: + xxx_p position (bit index) + xxx_l length (bit field length) + LAR log area ratio + N LTP lag + b LTP gain + M grid + Xmax block amplitude + x RPE pulses +*/ + + +/**@name Lengths of GSM 06.10 fields */ +//@{ +const unsigned int LAR1_l=6; ///< log area ratio +const unsigned int LAR2_l=6; ///< log area ratio +const unsigned int LAR3_l=5; ///< log area ratio +const unsigned int LAR4_l=5; ///< log area ratio +const unsigned int LAR5_l=4; ///< log area ratio +const unsigned int LAR6_l=4; ///< log area ratio +const unsigned int LAR7_l=3; ///< log area ratio +const unsigned int LAR8_l=3; ///< log area ratio +const unsigned int N_l=7; ///< LTP lag +const unsigned int b_l=2; ///< LTP gain +const unsigned int M_l=2; ///< grid position +const unsigned int Xmax_l=6; ///< block amplitude +const unsigned int x_l=3; ///< RPE pulses +//@} + + + +/*@name Indecies of GSM 06.10 fields as they appear in RFC-3551 Table 3. */ +//@{ + +/**@name Log area ratios, apply to whole frame. */ +//@{ +const unsigned int LAR1_p = 0; +const unsigned int LAR2_p = LAR1_p + LAR1_l; +const unsigned int LAR3_p = LAR2_p + LAR2_l; +const unsigned int LAR4_p = LAR3_p + LAR3_l; +const unsigned int LAR5_p = LAR4_p + LAR4_l; +const unsigned int LAR6_p = LAR5_p + LAR5_l; +const unsigned int LAR7_p = LAR6_p + LAR6_l; +const unsigned int LAR8_p = LAR7_p + LAR7_l; +//@} +/**@name Subframe 1 */ +//@{ +const unsigned int N1_p = LAR8_p + LAR8_l; +const unsigned int b1_p = N1_p + N_l; +const unsigned int M1_p = b1_p + b_l; +const unsigned int Xmax1_p = M1_p + M_l; +const unsigned int x1_0_p = Xmax1_p + Xmax_l; +const unsigned int x1_1_p = x1_0_p + x_l; +const unsigned int x1_2_p = x1_1_p + x_l; +const unsigned int x1_3_p = x1_2_p + x_l; +const unsigned int x1_4_p = x1_3_p + x_l; +const unsigned int x1_5_p = x1_4_p + x_l; +const unsigned int x1_6_p = x1_5_p + x_l; +const unsigned int x1_7_p = x1_6_p + x_l; +const unsigned int x1_8_p = x1_7_p + x_l; +const unsigned int x1_9_p = x1_8_p + x_l; +const unsigned int x1_10_p = x1_9_p + x_l; +const unsigned int x1_11_p = x1_10_p + x_l; +const unsigned int x1_12_p = x1_11_p + x_l; +//@} +/**@name Subframe 2 */ +//@{ +const unsigned int N2_p = x1_12_p + x_l; +const unsigned int b2_p = N2_p + N_l; +const unsigned int M2_p = b2_p + b_l; +const unsigned int Xmax2_p = M2_p + M_l; +const unsigned int x2_0_p = Xmax2_p + Xmax_l; +const unsigned int x2_1_p = x2_0_p + x_l; +const unsigned int x2_2_p = x2_1_p + x_l; +const unsigned int x2_3_p = x2_2_p + x_l; +const unsigned int x2_4_p = x2_3_p + x_l; +const unsigned int x2_5_p = x2_4_p + x_l; +const unsigned int x2_6_p = x2_5_p + x_l; +const unsigned int x2_7_p = x2_6_p + x_l; +const unsigned int x2_8_p = x2_7_p + x_l; +const unsigned int x2_9_p = x2_8_p + x_l; +const unsigned int x2_10_p = x2_9_p + x_l; +const unsigned int x2_11_p = x2_10_p + x_l; +const unsigned int x2_12_p = x2_11_p + x_l; +//@} +/**@mame Subframe 3 */ +//@{ +const unsigned int N3_p = x2_12_p + x_l; +const unsigned int b3_p = N3_p + N_l; +const unsigned int M3_p = b3_p + b_l; +const unsigned int Xmax3_p = M3_p + M_l; +const unsigned int x3_0_p = Xmax3_p + Xmax_l; +const unsigned int x3_1_p = x3_0_p + x_l; +const unsigned int x3_2_p = x3_1_p + x_l; +const unsigned int x3_3_p = x3_2_p + x_l; +const unsigned int x3_4_p = x3_3_p + x_l; +const unsigned int x3_5_p = x3_4_p + x_l; +const unsigned int x3_6_p = x3_5_p + x_l; +const unsigned int x3_7_p = x3_6_p + x_l; +const unsigned int x3_8_p = x3_7_p + x_l; +const unsigned int x3_9_p = x3_8_p + x_l; +const unsigned int x3_10_p = x3_9_p + x_l; +const unsigned int x3_11_p = x3_10_p + x_l; +const unsigned int x3_12_p = x3_11_p + x_l; +//@} +/**@name Subframe 4 */ +//@{ +const unsigned int N4_p = x3_12_p + x_l; +const unsigned int b4_p = N4_p + N_l; +const unsigned int M4_p = b4_p + b_l; +const unsigned int Xmax4_p = M4_p + M_l; +const unsigned int x4_0_p = Xmax4_p + Xmax_l; +const unsigned int x4_1_p = x4_0_p + x_l; +const unsigned int x4_2_p = x4_1_p + x_l; +const unsigned int x4_3_p = x4_2_p + x_l; +const unsigned int x4_4_p = x4_3_p + x_l; +const unsigned int x4_5_p = x4_4_p + x_l; +const unsigned int x4_6_p = x4_5_p + x_l; +const unsigned int x4_7_p = x4_6_p + x_l; +const unsigned int x4_8_p = x4_7_p + x_l; +const unsigned int x4_9_p = x4_8_p + x_l; +const unsigned int x4_10_p = x4_9_p + x_l; +const unsigned int x4_11_p = x4_10_p + x_l; +const unsigned int x4_12_p = x4_11_p + x_l; +//@} +//@} + + +/* + This array encodes GSM 05.03 Table 2. + It's also GSM 06.10 Table A2.1a. + This is the order of bits as they appear in + the d[] bits of the GSM TCH/F. + RTP[4+g610BitOrder[i]] <=> GSM[i] +*/ +unsigned int GSM::g610BitOrder[260] = { +/**@name importance class 1 */ +//@{ +/** LAR1:5 */ LAR1_p+LAR1_l-1-5, /* bit 0 */ +/** Xmax1:5 */ Xmax1_p+Xmax_l-1-5, +/** Xmax2:5 */ Xmax2_p+Xmax_l-1-5, +/** Xmax3:5 */ Xmax3_p+Xmax_l-1-5, +/** Xmax4:5 */ Xmax4_p+Xmax_l-1-5, +//@} +/**@name importance class 2 */ +//@{ +/** LAR1:4 */ LAR1_p+LAR1_l-1-4, +/** LAR2:5 */ LAR2_p+LAR2_l-1-5, +/** LAR3:4 */ LAR3_p+LAR3_l-1-4, +//@} +/**@name importance class 3 */ +//@{ +/** LAR1:3 */ LAR1_p+LAR1_l-1-3, +/** LAR2:4 */ LAR2_p+LAR2_l-1-4, +/** LAR3:3 */ LAR3_p+LAR3_l-1-3, /* bit 10 */ +/** LAR4:4 */ LAR4_p+LAR4_l-1-4, +/** N1:6 */ N1_p+N_l-1-6, +/** N2:6 */ N2_p+N_l-1-6, +/** N3:6 */ N3_p+N_l-1-6, +/** N4:6 */ N4_p+N_l-1-6, +/** Xmax1:4 */ Xmax1_p+Xmax_l-1-4, +/** Xmax2:4 */ Xmax2_p+Xmax_l-1-4, +/** Xmax3:4 */ Xmax3_p+Xmax_l-1-4, +/** Xmax4:4 */ Xmax4_p+Xmax_l-1-4, +/** LAR2:3 */ LAR2_p+LAR2_l-1-3, /* bit 20 */ +/** LAR5:3 */ LAR5_p+LAR5_l-1-3, +/** LAR6:3 */ LAR6_p+LAR6_l-1-3, +/** N1:5 */ N1_p+N_l-1-5, +/** N2:5 */ N2_p+N_l-1-5, +/** N3:5 */ N3_p+N_l-1-5, +/** N4:5 */ N4_p+N_l-1-5, +/** N1:4 */ N1_p+N_l-1-4, +/** N2:4 */ N2_p+N_l-1-4, +/** N3:4 */ N3_p+N_l-1-4, +/** N4:4 */ N4_p+N_l-1-4, /* bit 30 */ +/** N1:3 */ N1_p+N_l-1-3, +/** N2:3 */ N2_p+N_l-1-3, +/** N3:3 */ N3_p+N_l-1-3, +/** N4:3 */ N4_p+N_l-1-3, +/** N1:2 */ N1_p+N_l-1-2, +/** N2:2 */ N2_p+N_l-1-2, +/** N3:2 */ N3_p+N_l-1-2, +/** N4:2 */ N4_p+N_l-1-2, +//@} +/**@name importance class 4 */ +//@{ +/** Xmax1:3 */ Xmax1_p+Xmax_l-1-3, +/** Xmax2:3 */ Xmax2_p+Xmax_l-1-3, /* bit 40 */ +/** Xmax3:3 */ Xmax3_p+Xmax_l-1-3, +/** Xmax4:3 */ Xmax4_p+Xmax_l-1-3, +/** LAR1:2 */ LAR1_p+LAR1_l-1-2, +/** LAR4:3 */ LAR4_p+LAR4_l-1-3, +/** LAR7:2 */ LAR7_p+LAR7_l-1-2, +/** N1:1 */ N1_p+N_l-1-1, +/** N2:1 */ N2_p+N_l-1-1, +/** N3:1 */ N3_p+N_l-1-1, +/** N4:1 */ N4_p+N_l-1-1, +/** LAR5:2 */ LAR5_p+LAR5_l-1-2, /* bit 50 */ +/** LAR6:2 */ LAR6_p+LAR6_l-1-2, +/** b1:1 */ b1_p+b_l-1-1, +/** b2:1 */ b2_p+b_l-1-1, +/** b3:1 */ b3_p+b_l-1-1, +/** b4:1 */ b4_p+b_l-1-1, +/** N1:0 */ N1_p+N_l-1-0, +/** N2:0 */ N2_p+N_l-1-0, +/** N3:0 */ N3_p+N_l-1-0, +/** N4:0 */ N4_p+N_l-1-0, +/** M1:1 */ M1_p+M_l-1-1, /* bit 60 */ +/** M2:1 */ M2_p+M_l-1-1, +/** M3:1 */ M3_p+M_l-1-1, +/** M4:1 */ M4_p+M_l-1-1, +//@} +/**@name importance class 5 */ +//@{ +/** LAR1:1 */ LAR1_p+LAR1_l-1-1, +/** LAR2:2 */ LAR2_p+LAR2_l-1-2, +/** LAR3:2 */ LAR3_p+LAR3_l-1-2, +/** LAR8:2 */ LAR8_p+LAR8_l-1-2, +/** LAR4:2 */ LAR4_p+LAR4_l-1-2, +/** LAR5:1 */ LAR5_p+LAR5_l-1-1, +/** LAR7:1 */ LAR7_p+LAR7_l-1-1, /* bit 70 */ +/** b1:0 */ b1_p+b_l-1-0, +/** b2:0 */ b2_p+b_l-1-0, +/** b3:0 */ b3_p+b_l-1-0, +/** b4:0 */ b4_p+b_l-1-0, +/** Xmax1:2 */ Xmax1_p+Xmax_l-1-2, +/** Xmax2:2 */ Xmax2_p+Xmax_l-1-2, +/** Xmax3:2 */ Xmax3_p+Xmax_l-1-2, +/** Xmax4:2 */ Xmax4_p+Xmax_l-1-2, +/** x1_0:2 */ x1_0_p+x_l-1-2, +/** x1_1:2 */ x1_1_p+x_l-1-2, /* bit 80 */ +/** x1_2:2 */ x1_2_p+x_l-1-2, +/** x1_3:2 */ x1_3_p+x_l-1-2, +/** x1_4:2 */ x1_4_p+x_l-1-2, +/** x1_5:2 */ x1_5_p+x_l-1-2, +/** x1_6:2 */ x1_6_p+x_l-1-2, +/** x1_7:2 */ x1_7_p+x_l-1-2, +/** x1_8:2 */ x1_8_p+x_l-1-2, +/** x1_9:2 */ x1_9_p+x_l-1-2, +/** x1_10:2 */ x1_10_p+x_l-1-2, +/** x1_11:2 */ x1_11_p+x_l-1-2, /* bit 90 */ +/** x1_12:2 */ x1_12_p+x_l-1-2, +/** x2_0:2 */ x2_0_p+x_l-1-2, +/** x2_1:2 */ x2_1_p+x_l-1-2, +/** x2_2:2 */ x2_2_p+x_l-1-2, +/** x2_3:2 */ x2_3_p+x_l-1-2, +/** x2_4:2 */ x2_4_p+x_l-1-2, +/** x2_5:2 */ x2_5_p+x_l-1-2, +/** x2_6:2 */ x2_6_p+x_l-1-2, +/** x2_7:2 */ x2_7_p+x_l-1-2, +/** x2_8:2 */ x2_8_p+x_l-1-2, /* bit 100 */ +/** x2_9:2 */ x2_9_p+x_l-1-2, +/** x2_10:2 */ x2_10_p+x_l-1-2, +/** x2_11:2 */ x2_11_p+x_l-1-2, +/** x2_12:2 */ x2_12_p+x_l-1-2, +/** x3_0:2 */ x3_0_p+x_l-1-2, +/** x3_1:2 */ x3_1_p+x_l-1-2, +/** x3_2:2 */ x3_2_p+x_l-1-2, +/** x3_3:2 */ x3_3_p+x_l-1-2, +/** x3_4:2 */ x3_4_p+x_l-1-2, +/** x3_5:2 */ x3_5_p+x_l-1-2, /* bit 110 */ +/** x3_6:2 */ x3_6_p+x_l-1-2, +/** x3_7:2 */ x3_7_p+x_l-1-2, +/** x3_8:2 */ x3_8_p+x_l-1-2, +/** x3_9:2 */ x3_9_p+x_l-1-2, +/** x3_10:2 */ x3_10_p+x_l-1-2, +/** x3_11:2 */ x3_11_p+x_l-1-2, +/** x3_12:2 */ x3_12_p+x_l-1-2, +/** x4_0:2 */ x4_0_p+x_l-1-2, +/** x4_1:2 */ x4_1_p+x_l-1-2, +/** x4_2:2 */ x4_2_p+x_l-1-2, /* bit 120 */ +/** x4_3:2 */ x4_3_p+x_l-1-2, +/** x4_4:2 */ x4_4_p+x_l-1-2, +/** x4_5:2 */ x4_5_p+x_l-1-2, +/** x4_6:2 */ x4_6_p+x_l-1-2, +/** x4_7:2 */ x4_7_p+x_l-1-2, +/** x4_8:2 */ x4_8_p+x_l-1-2, +/** x4_9:2 */ x4_9_p+x_l-1-2, +/** x4_10:2 */ x4_10_p+x_l-1-2, +/** x4_11:2 */ x4_11_p+x_l-1-2, +/** x4_12:2 */ x4_12_p+x_l-1-2, /* bit 130 */ +/** M1:0 */ M1_p+M_l-1-0, +/** M2:0 */ M2_p+M_l-1-0, +/** M3:0 */ M3_p+M_l-1-0, +/** M4:0 */ M4_p+M_l-1-0, +/** Xmax1:1 */ Xmax1_p+Xmax_l-1-1, +/** Xmax2:1 */ Xmax2_p+Xmax_l-1-1, +/** Xmax3:1 */ Xmax3_p+Xmax_l-1-1, +/** Xmax4:1 */ Xmax4_p+Xmax_l-1-1, +/** x1_0:1 */ x1_0_p+x_l-1-1, +/** x1_1:1 */ x1_1_p+x_l-1-1, /* bit 140 */ +/** x1_2:1 */ x1_2_p+x_l-1-1, +/** x1_3:1 */ x1_3_p+x_l-1-1, +/** x1_4:1 */ x1_4_p+x_l-1-1, +/** x1_5:1 */ x1_5_p+x_l-1-1, +/** x1_6:1 */ x1_6_p+x_l-1-1, +/** x1_7:1 */ x1_7_p+x_l-1-1, +/** x1_8:1 */ x1_8_p+x_l-1-1, +/** x1_9:1 */ x1_9_p+x_l-1-1, +/** x1_10:1 */ x1_10_p+x_l-1-1, +/** x1_11:1 */ x1_11_p+x_l-1-1, /* bit 150 */ +/** x1_12:1 */ x1_12_p+x_l-1-1, +/** x2_0:1 */ x2_0_p+x_l-1-1, +/** x2_1:1 */ x2_1_p+x_l-1-1, +/** x2_2:1 */ x2_2_p+x_l-1-1, +/** x2_3:1 */ x2_3_p+x_l-1-1, +/** x2_4:1 */ x2_4_p+x_l-1-1, +/** x2_5:1 */ x2_5_p+x_l-1-1, +/** x2_6:1 */ x2_6_p+x_l-1-1, +/** x2_7:1 */ x2_7_p+x_l-1-1, +/** x2_8:1 */ x2_8_p+x_l-1-1, /* bit 160 */ +/** x2_9:1 */ x2_9_p+x_l-1-1, +/** x2_10:1 */ x2_10_p+x_l-1-1, +/** x2_11:1 */ x2_11_p+x_l-1-1, +/** x2_12:1 */ x2_12_p+x_l-1-1, +/** x3_0:1 */ x3_0_p+x_l-1-1, +/** x3_1:1 */ x3_1_p+x_l-1-1, +/** x3_2:1 */ x3_2_p+x_l-1-1, +/** x3_3:1 */ x3_3_p+x_l-1-1, +/** x3_4:1 */ x3_4_p+x_l-1-1, +/** x3_5:1 */ x3_5_p+x_l-1-1, /* bit 170 */ +/** x3_6:1 */ x3_6_p+x_l-1-1, +/** x3_7:1 */ x3_7_p+x_l-1-1, +/** x3_8:1 */ x3_8_p+x_l-1-1, +/** x3_9:1 */ x3_9_p+x_l-1-1, +/** x3_10:1 */ x3_10_p+x_l-1-1, +/** x3_11:1 */ x3_11_p+x_l-1-1, +/** x3_12:1 */ x3_12_p+x_l-1-1, +/** x4_0:1 */ x4_0_p+x_l-1-1, +/** x4_1:1 */ x4_1_p+x_l-1-1, +/** x4_2:1 */ x4_2_p+x_l-1-1, /* bit 180 */ +/** x4_3:1 */ x4_3_p+x_l-1-1, +//@} +/**@name importance class 6 */ +//@{ +/** x4_4:1 */ x4_4_p+x_l-1-1, +/** x4_5:1 */ x4_5_p+x_l-1-1, +/** x4_6:1 */ x4_6_p+x_l-1-1, +/** x4_7:1 */ x4_7_p+x_l-1-1, +/** x4_8:1 */ x4_8_p+x_l-1-1, +/** x4_9:1 */ x4_9_p+x_l-1-1, +/** x4_10:1 */ x4_10_p+x_l-1-1, +/** x4_11:1 */ x4_11_p+x_l-1-1, +/** x4_12:1 */ x4_12_p+x_l-1-1, /* bit 190 */ +/** LAR1:0 */ LAR1_p+LAR1_l-1-0, +/** LAR2:1 */ LAR2_p+LAR2_l-1-1, +/** LAR3:1 */ LAR3_p+LAR3_l-1-1, +/** LAR6:1 */ LAR6_p+LAR6_l-1-1, +/** LAR7:0 */ LAR7_p+LAR7_l-1-0, +/** LAR8:1 */ LAR8_p+LAR8_l-1-1, +/** LAR8:0 */ LAR8_p+LAR8_l-1-0, +/** LAR3:0 */ LAR3_p+LAR3_l-1-0, +/** LAR4:1 */ LAR4_p+LAR4_l-1-1, +/** LAR4:0 */ LAR4_p+LAR4_l-1-0, +/** LAR5:0 */ LAR5_p+LAR5_l-1-0, +/** Xmax1:0 */ Xmax1_p+Xmax_l-1-0, +/** Xmax2:0 */ Xmax2_p+Xmax_l-1-0, +/** Xmax3:0 */ Xmax3_p+Xmax_l-1-0, +/** Xmax4:0 */ Xmax4_p+Xmax_l-1-0, +/** x1_0:0 */ x1_0_p+x_l-1-0, +/** x1_1:0 */ x1_1_p+x_l-1-0, +/** x1_2:0 */ x1_2_p+x_l-1-0, +/** x1_3:0 */ x1_3_p+x_l-1-0, +/** x1_4:0 */ x1_4_p+x_l-1-0, +/** x1_5:0 */ x1_5_p+x_l-1-0, +/** x1_6:0 */ x1_6_p+x_l-1-0, +/** x1_7:0 */ x1_7_p+x_l-1-0, +/** x1_8:0 */ x1_8_p+x_l-1-0, +/** x1_9:0 */ x1_9_p+x_l-1-0, +/** x1_10:0 */ x1_10_p+x_l-1-0, +/** x1_11:0 */ x1_11_p+x_l-1-0, +/** x1_12:0 */ x1_12_p+x_l-1-0, +/** x2_0:0 */ x2_0_p+x_l-1-0, +/** x2_1:0 */ x2_1_p+x_l-1-0, +/** x2_2:0 */ x2_2_p+x_l-1-0, +/** x2_3:0 */ x2_3_p+x_l-1-0, +/** x2_4:0 */ x2_4_p+x_l-1-0, +/** x2_5:0 */ x2_5_p+x_l-1-0, +/** x2_6:0 */ x2_6_p+x_l-1-0, +/** x2_7:0 */ x2_7_p+x_l-1-0, +/** x2_8:0 */ x2_8_p+x_l-1-0, +/** x2_9:0 */ x2_9_p+x_l-1-0, +/** x2_10:0 */ x2_10_p+x_l-1-0, +/** x2_11:0 */ x2_11_p+x_l-1-0, +/** x2_12:0 */ x2_12_p+x_l-1-0, +/** x3_0:0 */ x3_0_p+x_l-1-0, +/** x3_1:0 */ x3_1_p+x_l-1-0, +/** x3_2:0 */ x3_2_p+x_l-1-0, +/** x3_3:0 */ x3_3_p+x_l-1-0, +/** x3_4:0 */ x3_4_p+x_l-1-0, +/** x3_5:0 */ x3_5_p+x_l-1-0, +/** x3_6:0 */ x3_6_p+x_l-1-0, +/** x3_7:0 */ x3_7_p+x_l-1-0, +/** x3_8:0 */ x3_8_p+x_l-1-0, +/** x3_9:0 */ x3_9_p+x_l-1-0, +/** x3_10:0 */ x3_10_p+x_l-1-0, +/** x3_11:0 */ x3_11_p+x_l-1-0, +/** x3_12:0 */ x3_12_p+x_l-1-0, +/** x4_0:0 */ x4_0_p+x_l-1-0, +/** x4_1:0 */ x4_1_p+x_l-1-0, +/** x4_2:0 */ x4_2_p+x_l-1-0, +/** x4_3:0 */ x4_3_p+x_l-1-0, +/** x4_4:0 */ x4_4_p+x_l-1-0, +/** x4_5:0 */ x4_5_p+x_l-1-0, +/** x4_6:0 */ x4_6_p+x_l-1-0, +/** x4_7:0 */ x4_7_p+x_l-1-0, +/** x4_8:0 */ x4_8_p+x_l-1-0, +/** x4_9:0 */ x4_9_p+x_l-1-0, +/** x4_10:0 */ x4_10_p+x_l-1-0, +/** x4_11:0 */ x4_11_p+x_l-1-0, +/** x4_12:0 */ x4_12_p+x_l-1-0, +/** LAR2:0 */ LAR2_p+LAR2_l-1-0, +/** LAR6:0 */ LAR6_p+LAR6_l-1-0 +//@} +}; + diff --git a/GSM/GSM610Tables.h b/GSM/GSM610Tables.h new file mode 100644 index 0000000..4f634d0 --- /dev/null +++ b/GSM/GSM610Tables.h @@ -0,0 +1,30 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef GSM610TABLES_H +#define GSM610TABLES_H + + + +namespace GSM { + +/** Table #2 from GSM 05.03 */ +extern unsigned int g610BitOrder[260]; + +} + + +#endif diff --git a/GSM/GSMCommon.cpp b/GSM/GSMCommon.cpp new file mode 100644 index 0000000..4e40a1a --- /dev/null +++ b/GSM/GSMCommon.cpp @@ -0,0 +1,396 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "GSMCommon.h" + +using namespace GSM; +using namespace std; + + +const char* GSM::CallStateString(GSM::CallState state) +{ + switch (state) { + case NullState: return "null";; + case Paging: return "paging"; + case AnsweredPaging: return "answered-paging"; + case MOCInitiated: return "MOC-initiated"; + case MOCProceeding: return "MOC-proceeding"; + case MTCConfirmed: return "MTC-confirmed"; + case CallReceived: return "call-received"; + case CallPresent: return "call-present"; + case ConnectIndication: return "connect-indication"; + case Active: return "active"; + case DisconnectIndication: return "disconnect-indication"; + case ReleaseRequest: return "release-request"; + case SMSDelivering: return "SMS-delivery"; + case SMSSubmitting: return "SMS-submission"; + default: return NULL; + } +} + +ostream& GSM::operator<<(ostream& os, GSM::CallState state) +{ + const char* str = GSM::CallStateString(state); + if (str) os << str; + else os << "?" << state << "?"; + return os; +} + + +ostream& GSM::operator<<(ostream& os, L3PD val) +{ + switch (val) { + case L3CallControlPD: os << "Call Control"; break; + case L3MobilityManagementPD: os << "Mobility Management"; break; + case L3RadioResourcePD: os << "Radio Resource"; break; + default: os << hex << "0x" << (int)val << dec; + } + return os; +} + + +const BitVector GSM::gTrainingSequence[] = { + BitVector("00100101110000100010010111"), + BitVector("00101101110111100010110111"), + BitVector("01000011101110100100001110"), + BitVector("01000111101101000100011110"), + BitVector("00011010111001000001101011"), + BitVector("01001110101100000100111010"), + BitVector("10100111110110001010011111"), + BitVector("11101111000100101110111100"), +}; + +const BitVector GSM::gDummyBurst("0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000"); + +const BitVector GSM::gRACHSynchSequence("01001011011111111001100110101010001111000"); + + + +unsigned char GSM::encodeGSMChar(unsigned char ascii) +{ + // Given an ASCII char, return the corresponding GSM char. + // Do it with a lookup table, generated on the first call. + // You might be tempted to replace this init with some more clever NULL-pointer trick. + // -- Don't. This is thread-safe. + static char reverseTable[256]={'?'}; + static volatile bool init = false; + if (!init) { + for (size_t i=0; i='0') && (ascii<='9')) return ascii-'0'; + switch (ascii) { + case '.': return 11; + case '*': return 11; + case '#': return 12; + case 'a': return 13; + case 'b': return 14; + case 'c': return 15; + default: return 15; + } +} + + + + +unsigned GSM::uplinkFreqKHz(GSMBand band, unsigned ARFCN) +{ + switch (band) { + case GSM850: + assert((ARFCN<252)&&(ARFCN>129)); + return 824200+200*(ARFCN-128); + case EGSM900: + if (ARFCN<=124) return 890000+200*ARFCN; + assert((ARFCN>974)&&(ARFCN<1024)); + return 890000+200*(ARFCN-1024); + case DCS1800: + assert((ARFCN>511)&&(ARFCN<886)); + return 1710200+200*(ARFCN-512); + case PCS1900: + assert((ARFCN>511)&&(ARFCN<811)); + return 1850200+200*(ARFCN-512); + default: + assert(0); + } +} + + +unsigned GSM::uplinkOffsetKHz(GSMBand band) +{ + switch (band) { + case GSM850: return 45000; + case EGSM900: return 45000; + case DCS1800: return 95000; + case PCS1900: return 80000; + default: assert(0); + } +} + + +unsigned GSM::downlinkFreqKHz(GSMBand band, unsigned ARFCN) +{ + return uplinkFreqKHz(band,ARFCN) + uplinkOffsetKHz(band); +} + + + + +// See GSM 04.08 Table 10.5.68. +const unsigned GSM::RACHSpreadSlots[16] = +{ + 3,4,5,6, + 7,8,9,10, + 11,12,14,16, + 20,25,32,50 +}; + +// See GSM 04.08 Table 3.1 +const unsigned GSM::RACHWaitSParam[16] = +{ + 55,76,109,163,217, + 55,76,109,163,217, + 55,76,109,163,217, + 55 +}; + + + + +int32_t GSM::FNDelta(int32_t v1, int32_t v2) +{ + static const int32_t halfModulus = gHyperframe/2; + int32_t delta = v1-v2; + if (delta>=halfModulus) delta -= gHyperframe; + else if (delta<-halfModulus) delta += gHyperframe; + return (int32_t) delta; +} + +int GSM::FNCompare(int32_t v1, int32_t v2) +{ + int32_t delta = FNDelta(v1,v2); + if (delta>0) return 1; + if (delta<0) return -1; + return 0; +} + + + + +ostream& GSM::operator<<(ostream& os, const Time& t) +{ + os << t.TN() << ":" << t.FN(); + return os; +} + + + + +void Clock::set(const Time& when) +{ + mLock.lock(); + mBaseTime = Timeval(0); + mBaseFN = when.FN(); + mLock.unlock(); +} + + +int32_t Clock::FN() const +{ + mLock.lock(); + Timeval now; + int32_t deltaSec = now.sec() - mBaseTime.sec(); + int32_t deltaUSec = now.usec() - mBaseTime.usec(); + int64_t elapsedUSec = 1000000LL*deltaSec + deltaUSec; + int64_t elapsedFrames = elapsedUSec / gFrameMicroseconds; + int32_t currentFN = (mBaseFN + elapsedFrames) % gHyperframe; + mLock.unlock(); + return currentFN; +} + + +void Clock::wait(const Time& when) const +{ + int32_t now = FN(); + int32_t target = when.FN(); + int32_t delta = FNDelta(target,now); + if (delta<1) return; + static const int32_t maxSleep = 51*26; + if (delta>maxSleep) delta=maxSleep; + sleepFrames(delta); +} + + + + + + + +ostream& GSM::operator<<(ostream& os, TypeOfNumber type) +{ + switch (type) { + case UnknownTypeOfNumber: os << "unknown"; break; + case InternationalNumber: os << "international"; break; + case NationalNumber: os << "national"; break; + case NetworkSpecificNumber: os << "network-specific"; break; + case ShortCodeNumber: os << "short code"; break; + default: os << "?" << (int)type << "?"; + } + return os; +} + + +ostream& GSM::operator<<(ostream& os, NumberingPlan plan) +{ + switch (plan) { + case UnknownPlan: os << "unknown"; break; + case E164Plan: os << "E.164/ISDN"; break; + case X121Plan: os << "X.121/data"; break; + case F69Plan: os << "F.69/Telex"; break; + case NationalPlan: os << "national"; break; + case PrivatePlan: os << "private"; break; + default: os << "?" << (int)plan << "?"; + } + return os; +} + +ostream& GSM::operator<<(ostream& os, MobileIDType wID) +{ + switch (wID) { + case NoIDType: os << "None"; break; + case IMSIType: os << "IMSI"; break; + case IMEIType: os << "IMEI"; break; + case TMSIType: os << "TMSI"; break; + case IMEISVType: os << "IMEISV"; break; + default: os << "?" << (int)wID << "?"; + } + return os; +} + + +ostream& GSM::operator<<(ostream& os, TypeAndOffset tao) +{ + switch (tao) { + case TDMA_MISC: os << "(misc)"; break; + case TCHF_0: os << "TCH/F"; break; + case TCHH_0: os << "TCH/H-0"; break; + case TCHH_1: os << "TCH/H-1"; break; + case SDCCH_4_0: os << "SDCCH/4-0"; break; + case SDCCH_4_1: os << "SDCCH/4-1"; break; + case SDCCH_4_2: os << "SDCCH/4-2"; break; + case SDCCH_4_3: os << "SDCCH/4-3"; break; + case SDCCH_8_0: os << "SDCCH/8-0"; break; + case SDCCH_8_1: os << "SDCCH/8-1"; break; + case SDCCH_8_2: os << "SDCCH/8-2"; break; + case SDCCH_8_3: os << "SDCCH/8-3"; break; + case SDCCH_8_4: os << "SDCCH/8-4"; break; + case SDCCH_8_5: os << "SDCCH/8-5"; break; + case SDCCH_8_6: os << "SDCCH/8-6"; break; + case SDCCH_8_7: os << "SDCCH/8-7"; break; + case TDMA_BEACON: os << "(beacon)"; break; + default: os << "?" << (int)tao << "?"; + } + return os; +} + +ostream& GSM::operator<<(ostream& os, ChannelType val) +{ + switch (val) { + case UndefinedCHType: os << "undefined"; return os; + case SCHType: os << "SCH"; break; + case FCCHType: os << "FCCH"; break; + case BCCHType: os << "BCCH"; break; + case RACHType: os << "RACH"; break; + case SDCCHType: os << "SDCCH"; break; + case FACCHType: os << "FACCH"; break; + case CCCHType: os << "CCCH"; break; + case SACCHType: os << "SACCH"; break; + case TCHFType: os << "TCH/F"; break; + case TCHHType: os << "TCH/H"; break; + case AnyTCHType: os << "any TCH"; break; + case LoopbackFullType: os << "Loopback Full"; break; + case LoopbackHalfType: os << "Loopback Half"; break; + case AnyDCCHType: os << "any DCCH"; break; + default: os << "?" << (int)val << "?"; + } + return os; +} + + + + +bool Z100Timer::expired() const +{ + assert(mLimitTime!=0); + // A non-active timer does not expire. + if (!mActive) return false; + return mEndTime.passed(); +} + +void Z100Timer::set() +{ + assert(mLimitTime!=0); + mEndTime = Timeval(mLimitTime); + mActive=true; +} + +void Z100Timer::expire() +{ + mEndTime = Timeval(0); + mActive=true; +} + + +void Z100Timer::set(long wLimitTime) +{ + mLimitTime = wLimitTime; + set(); +} + + +long Z100Timer::remaining() const +{ + if (!mActive) return 0; + long rem = mEndTime.remaining(); + if (rem<0) rem=0; + return rem; +} + +void Z100Timer::wait() const +{ + while (!expired()) msleep(remaining()); +} + +// vim: ts=4 sw=4 diff --git a/GSM/GSMCommon.h b/GSM/GSMCommon.h new file mode 100644 index 0000000..2a64261 --- /dev/null +++ b/GSM/GSMCommon.h @@ -0,0 +1,609 @@ +/**@file Common-use GSM declarations, most from the GSM 04.xx and 05.xx series. */ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef GSMCOMMON_H +#define GSMCOMMON_H + +#include +#include +#include +#include + +#include +#include +#include + + + + +namespace GSM { + +/**@namespace GSM This namespace covers L1 FEC, L2 and L3 message translation. */ + + +/* forward references */ +class L1FEC; +class L2LAPDm; +class L3Processor; +class LogicalChannel; +class L2Header; + +/** Call states based on GSM 04.08 5 and ITU-T Q.931 */ +enum CallState { + NullState, + Paging, + AnsweredPaging, + MOCInitiated, + MOCProceeding, + MTCConfirmed, + CallReceived, + CallPresent, + ConnectIndication, + Active, + DisconnectIndication, + ReleaseRequest, + SMSDelivering, + SMSSubmitting, +}; + + +/** Return a human-readable string for a GSM::CallState. */ +const char* CallStateString(CallState state); + +std::ostream& operator<<(std::ostream& os, CallState state); + + +/** A base class for GSM exceptions. */ +class GSMError {}; + +/** Duration ofa GSM frame, in microseconds. */ +const unsigned gFrameMicroseconds = 4615; + + +/** Sleep for a given number of GSM frame periods. */ +inline void sleepFrames(unsigned frames) + { usleep(frames*gFrameMicroseconds); } + +/** Sleep for 1 GSM frame period. */ +inline void sleepFrame() + { usleep(gFrameMicroseconds); } + + + +/** GSM Training sequences from GSM 05.02 5.2.3. */ +extern const BitVector gTrainingSequence[]; + +/** C0T0 filler burst, GSM 05.02, 5.2.6 */ +extern const BitVector gDummyBurst; + +/** Random access burst synch. sequence */ +extern const BitVector gRACHSynchSequence; + +enum GSMAlphabet { + ALPHABET_7BIT, + ALPHABET_8BIT, + ALPHABET_UCS2 +}; + +/**@name Support for GSM 7-bit alphabet, GSM 03.38 6.2.1. */ +//@{ +/** + Indexed by GSM 7-bit, returns ISO-8859-1. + We do not support the extended table, so 0x1B is a space. + FIXME -- ISO-8859-1 doesn't support Greek! +*/ +static const unsigned char gGSMAlphabet[] = "@\243$\245\350\351\371\354\362\347\n\330\370\r\305\345D_FGLOPCSTZ \306\346\337\311 !\"#\244%&\'()*+,-./0123456789:;<=>?\241ABCDEFGHIJKLMNOPQRSTUVWXYZ\304\326\321\334\247\277abcdefghijklmnopqrstuvwxyz\344\366\361\374\341"; +unsigned char encodeGSMChar(unsigned char ascii); +inline unsigned char decodeGSMChar(unsigned char sms) { return gGSMAlphabet[(unsigned)sms]; } +//@} + + +/**@name BCD-ASCII mapping, GMS 04.08 Table 10.5.118. */ +//@{ +/** Indexed by BCD, returns ASCII. */ +static const char gBCDAlphabet[] = "0123456789.#abc"; +char encodeBCDChar(char ascii); +inline char decodeBCDChar(char bcd) { return gBCDAlphabet[(unsigned)bcd]; } +//@} + + +/**@name Globally-fixed GSM timeout values (all in ms). */ +//@{ +/**@name GSM LAPDm timeouts, GSM 04.06 5.8, ITU-T Q.921 5.9 */ +//@{ +const unsigned T200ms = 900; ///< LAPDm ACK timeout, set for typical turnaround time +//@} +/**@name GSM timeouts for radio resource management, GSM 04.08 11.1. */ +//@{ +const unsigned T3101ms = 4000; ///< L1 timeout for SDCCH assignment +const unsigned T3107ms = 3000; ///< L1 timeout for TCH/FACCH assignment +const unsigned T3109ms = 30000; ///< L1 timeout for an existing channel +const unsigned T3111ms = 2*T200ms; ///< L1 timeout for reassignment of a channel +//@} +/**@name GSM timeouts for mobility management, GSM 04.08 11.2. */ +//@{ +const unsigned T3260ms = 12000; ///< ID request timeout +//@} +/**@name GSM timeouts for SMS. GSM 04.11 */ +//@{ +const unsigned TR1Mms = 30000; ///< RP-ACK timeout +//@} +//@} + + + + +/** GSM 04.08 Table 10.5.118 and GSM 03.40 9.1.2.5 */ +enum TypeOfNumber { + UnknownTypeOfNumber = 0, + InternationalNumber = 1, + NationalNumber = 2, + NetworkSpecificNumber = 3, + ShortCodeNumber = 4, + AlphanumericNumber = 5, + AbbreviatedNumber = 6 +}; + +std::ostream& operator<<(std::ostream&, TypeOfNumber); + + +/** GSM 04.08 Table 10.5.118 and GSM 03.40 9.1.2.5 */ +enum NumberingPlan { + UnknownPlan = 0, + E164Plan = 1, + X121Plan = 3, + F69Plan = 4, + NationalPlan = 8, + PrivatePlan = 9, + ERMESPlan = 10 +}; + +std::ostream& operator<<(std::ostream&, NumberingPlan); + + + +/** Codes for GSM band types, GSM 05.05 2. */ +enum GSMBand { + GSM850=850, ///< US cellular + EGSM900=900, ///< extended GSM + DCS1800=1800, ///< worldwide DCS band + PCS1900=1900 ///< US PCS band +}; + + + +/**@name Actual radio carrier frequencies, in kHz, GSM 05.05 2 */ +//@{ +unsigned uplinkFreqKHz(GSMBand wBand, unsigned wARFCN); +unsigned uplinkOffsetKHz(GSMBand); +unsigned downlinkFreqKHz(GSMBand wBand, unsigned wARFCN); +//@} + + +/**@name GSM Logical channel (LCH) types. */ +//@{ +/** Codes for logical channel types. */ +enum ChannelType { + ///@name Non-dedicated control channels. + //@{ + SCHType, ///< sync + FCCHType, ///< frequency correction + BCCHType, ///< broadcast control + CCCHType, ///< common control, a combination of several sub-types + RACHType, ///< random access + SACCHType, ///< slow associated control (acutally dedicated, but...) + //@} + ///@name Dedicated control channels (DCCHs). + //@{ + SDCCHType, ///< standalone dedicated control + FACCHType, ///< fast associated control + //@} + ///@name Traffic channels + //@{ + TCHFType, ///< full-rate traffic + TCHHType, ///< half-rate traffic + AnyTCHType, ///< any TCH type + //@} + ///@name Special internal channel types. + //@{ + LoopbackFullType, ///< loopback testing + LoopbackHalfType, ///< loopback testing + AnyDCCHType, ///< any dedicated control channel + UndefinedCHType, ///< undefined + //@} +}; + + +/** Print channel type name to a stream. */ +std::ostream& operator<<(std::ostream& os, ChannelType val); + + +//@} + + + +/** Mobile identity types, GSM 04.08 10.5.1.4 */ +enum MobileIDType { + NoIDType = 0, + IMSIType = 1, + IMEIType = 2, + IMEISVType = 3, + TMSIType = 4 +}; + +std::ostream& operator<<(std::ostream& os, MobileIDType); + + +/** Type and TDMA offset of a logical channel, from GSM 04.08 10.5.2.5 */ +enum TypeAndOffset { + TDMA_MISC=0, + TCHF_0=1, + TCHH_0=2, TCHH_1=3, + SDCCH_4_0=4, SDCCH_4_1=5, SDCCH_4_2=6, SDCCH_4_3=7, + SDCCH_8_0=8, SDCCH_8_1=9, SDCCH_8_2=10, SDCCH_8_3=11, + SDCCH_8_4=12, SDCCH_8_5=13, SDCCH_8_6=14, SDCCH_8_7=15, + /// An extra one for our internal use. + TDMA_BEACON=255 +}; + +std::ostream& operator<<(std::ostream& os, TypeAndOffset); + + + + + + + + +/** + L3 Protocol Discriminator, GSM 04.08 10.2, GSM 04.07 11.2.3.1.1. +*/ +enum L3PD { + L3GroupCallControlPD=0x00, + L3BroadcastCallControlPD=0x01, + L3PDSS1PD=0x02, + L3CallControlPD=0x03, + L3PDSS2PD=0x04, + L3MobilityManagementPD=0x05, + L3RadioResourcePD=0x06, + L3MobilityManagementGPRSPD=0x08, + L3SMSPD=0x09, + L3GPRSSessionManagementPD=0x0a, + L3NonCallSSPD=0x0b, + L3LocationPD=0x0c, + L3ExtendedPD=0x0e, + L3TestProcedurePD=0x0f, + L3UndefinedPD=-1 +}; + + + +std::ostream& operator<<(std::ostream& os, L3PD val); + + + + +/**@name Tables related to Tx-integer; GSM 04.08 3.3.1.1.2 and 10.5.2.29. */ +//@{ +/** "T" parameter, from GSM 04.08 10.5.2.29. Index is TxInteger. */ +extern const unsigned RACHSpreadSlots[]; +/** "S" parameter, from GSM 04.08 3.3.1.1.2. Index is TxInteger. */ +extern const unsigned RACHWaitSParam[]; +//@} + + + + +/**@name Modulus operations for frame numbers. */ +//@{ +/** The GSM hyperframe is largest time period in the GSM system, GSM 05.02 4.3.3. */ +const uint32_t gHyperframe = 2048UL * 26UL * 51UL; + +/** Get a clock difference, within the modulus, v1-v2. */ +int32_t FNDelta(int32_t v1, int32_t v2); + +/** + Compare two frame clock values. + @return 1 if v1>v2, -1 if v17) { + mTN-=8; + mFN = (mFN+1) % gHyperframe; + } + return *this; + } + + Time& operator+=(int step) + { + // Remember the step might be negative. + mFN += step; + if (mFN<0) mFN+=gHyperframe; + mFN = mFN % gHyperframe; + return *this; + } + + Time operator-(int step) const + { return operator+(-step); } + + Time operator+(int step) const + { + Time newVal = *this; + newVal += step; + return newVal; + } + + Time operator+(const Time& other) const + { + unsigned newTN = (mTN + other.mTN) % 8; + uint64_t newFN = (mFN+other.mFN + (mTN + other.mTN)/8) % gHyperframe; + return Time(newFN,newTN); + } + + int operator-(const Time& other) const + { + return FNDelta(mFN,other.mFN); + } + + //@} + + + /**@name Comparisons. */ + //@{ + + bool operator<(const Time& other) const + { + if (mFN==other.mFN) return (mTN(const Time& other) const + { + if (mFN==other.mFN) return (mTN>other.mTN); + return FNCompare(mFN,other.mFN)>0; + } + + bool operator<=(const Time& other) const + { + if (mFN==other.mFN) return (mTN<=other.mTN); + return FNCompare(mFN,other.mFN)<=0; + } + + bool operator>=(const Time& other) const + { + if (mFN==other.mFN) return (mTN>=other.mTN); + return FNCompare(mFN,other.mFN)>=0; + } + + bool operator==(const Time& other) const + { + return (mFN == other.mFN) && (mTN==other.mTN); + } + + //@} + + + + /**@name Standard derivations. */ + //@{ + + /** GSM 05.02 3.3.2.2.1 */ + unsigned SFN() const { return mFN / (26*51); } + + /** GSM 05.02 3.3.2.2.1 */ + unsigned T1() const { return SFN() % 2048; } + + /** GSM 05.02 3.3.2.2.1 */ + unsigned T2() const { return mFN % 26; } + + /** GSM 05.02 3.3.2.2.1 */ + unsigned T3() const { return mFN % 51; } + + /** GSM 05.02 3.3.2.2.1. */ + unsigned T3p() const { return (T3()-1)/10; } + + /** GSM 05.02 6.3.1.3. */ + unsigned TC() const { return (FN()/51) % 8; } + + /** GSM 04.08 10.5.2.30. */ + unsigned T1p() const { return SFN() % 32; } + + /** GSM 05.02 6.2.3 */ + unsigned T1R() const { return T1() % 64; } + + //@} +}; + + +std::ostream& operator<<(std::ostream& os, const Time& ts); + + + + + + +/** + A class for calculating the current GSM frame number. + Has built-in concurrency protections. +*/ +class Clock { + + private: + + mutable Mutex mLock; + int32_t mBaseFN; + Timeval mBaseTime; + + public: + + Clock(const Time& when = Time(0)) + :mBaseFN(when.FN()) + {} + + /** Set the clock to a value. */ + void set(const Time&); + + /** Read the clock. */ + int32_t FN() const; + + /** Read the clock. */ + Time get() const { return Time(FN()); } + + /** Block until the clock passes a given time. */ + void wait(const Time&) const; +}; + + + + + + + + +/** + CCITT Z.100 activity timer, as described in GSM 04.06 5.1. + All times are in milliseconds. +*/ +class Z100Timer { + + private: + + Timeval mEndTime; ///< the time at which this timer will expire + long mLimitTime; ///< timeout in milliseconds + bool mActive; ///< true if timer is active + + public: + + /** Create a timer with a given timeout in milliseconds. */ + Z100Timer(long wLimitTime) + :mLimitTime(wLimitTime), + mActive(false) + {} + + /** Blank constructor; if you use this object, it will assert. */ + Z100Timer():mLimitTime(0),mActive(false) {} + + /** True if the timer is active and expired. */ + bool expired() const; + + /** Force the timer into an expired state. */ + void expire(); + + /** Start or restart the timer. */ + void set(); + + /** Start or restart the timer, possibly specifying a new limit. */ + void set(long wLimitTime); + + /** Stop the timer. */ + void reset() { assert(mLimitTime!=0); mActive = false; } + + /** Returns true if the timer is active. */ + bool active() const { return mActive; } + + /** + Remaining time until expiration, in milliseconds. + Returns zero if the timer has expired. + */ + long remaining() const; + + /** + Block until the timer expires. + Returns immediately if the timer is not running. + */ + void wait() const; +}; + + + + + +}; // namespace GSM + + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSMConfig.cpp b/GSM/GSMConfig.cpp new file mode 100644 index 0000000..246b320 --- /dev/null +++ b/GSM/GSMConfig.cpp @@ -0,0 +1,337 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "GSMConfig.h" +#include "GSMTransfer.h" +#include "GSMLogicalChannel.h" +#include +#include + + + +using namespace std; +using namespace GSM; + + + +GSMConfig::GSMConfig() + :mBand((GSMBand)gConfig.getNum("GSM.Radio.Band")), + mSI5Frame(UNIT_DATA),mSI6Frame(UNIT_DATA), + mT3122(gConfig.getNum("GSM.Timer.T3122Min")), + mStartTime(::time(NULL)) +{ + regenerateBeacon(); +} + +void GSMConfig::start() +{ + mPowerManager.start(); + // Do not call this until the paging channels are installed. + mPager.start(); + // Do not call this until AGCHs are installed. + mAccessGrantThread.start(Control::AccessGrantServiceLoop,NULL); +} + + + + +void GSMConfig::regenerateBeacon() +{ + // Update everything from the configuration. + LOG(NOTICE) << "regenerating system information messages"; + + // BSIC components + mNCC = gConfig.getNum("GSM.Identity.BSIC.NCC"); + LOG_ASSERT(mNCC<8); + mBCC = gConfig.getNum("GSM.Identity.BSIC.BCC"); + LOG_ASSERT(mBCC<8); + + // MCC/MNC/LAC + mLAI = L3LocationAreaIdentity(); + + // Now regenerate all of the system information messages. + + // SI1 + L3SystemInformationType1 SI1; + LOG(INFO) << SI1; + L3Frame SI1L3(UNIT_DATA); + SI1.write(SI1L3); + L2Header SI1Header(L2Length(SI1L3.L2Length())); + mSI1Frame = L2Frame(SI1Header,SI1L3); + LOG(DEBUG) << "mSI1Frame " << mSI1Frame; + + // SI2 + L3SystemInformationType2 SI2; + LOG(INFO) << SI2; + L3Frame SI2L3(UNIT_DATA); + SI2.write(SI2L3); + L2Header SI2Header(L2Length(SI2L3.L2Length())); + mSI2Frame = L2Frame(SI2Header,SI2L3); + LOG(DEBUG) << "mSI2Frame " << mSI2Frame; + + // SI3 + L3SystemInformationType3 SI3; + LOG(INFO) << SI3; + L3Frame SI3L3(UNIT_DATA); + SI3.write(SI3L3); + L2Header SI3Header(L2Length(SI3L3.L2Length())); + mSI3Frame = L2Frame(SI3Header,SI3L3); + LOG(DEBUG) << "mSI3Frame " << mSI3Frame; + + // SI4 + L3SystemInformationType4 SI4; + LOG(INFO) << SI4; + L3Frame SI4L3(UNIT_DATA); + SI4.write(SI4L3); + L2Header SI4Header(L2Length(SI4L3.L2Length())); + mSI4Frame = L2Frame(SI4Header,SI4L3); + LOG(DEBUG) << "mSI4Frame " << mSI4Frame; + + // SI5 + L3SystemInformationType5 SI5; + LOG(INFO) << SI5; + SI5.write(mSI5Frame); + LOG(DEBUG) << "mSI5Frame " << mSI5Frame; + + // SI6 + L3SystemInformationType6 SI6; + LOG(INFO) << SI6; + SI6.write(mSI6Frame); + LOG(DEBUG) "mSI6Frame " << mSI6Frame; + +} + + + + + +CCCHLogicalChannel* GSMConfig::minimumLoad(CCCHList &chanList) +{ + if (chanList.size()==0) return NULL; + CCCHList::iterator chan = chanList.begin(); + CCCHLogicalChannel *retVal = *chan; + unsigned minLoad = (*chan)->load(); + ++chan; + while (chan!=chanList.end()) { + unsigned thisLoad = (*chan)->load(); + if (thisLoad ChanType* getChan(vector& chanList) +{ + const unsigned sz = chanList.size(); + if (sz==0) return NULL; + // Start the search from a random point in the list. + //unsigned pos = random() % sz; + // HACK -- Try in-order allocation for debugging. + for (unsigned i=0; irecyclable()) return chan; + //pos = (pos+1) % sz; + } + return NULL; +} + + + + + +SDCCHLogicalChannel *GSMConfig::getSDCCH() +{ + ScopedLock lock(mLock); + SDCCHLogicalChannel *chan = getChan(mSDCCHPool); + if (chan) chan->open(); + return chan; +} + + +TCHFACCHLogicalChannel *GSMConfig::getTCH() +{ + ScopedLock lock(mLock); + TCHFACCHLogicalChannel *chan = getChan(mTCHPool); + if (chan) chan->open(); + return chan; +} + + + +template size_t chanAvailable(const vector& chanList) +{ + size_t count = 0; + for (unsigned i=0; irecyclable()) count++; + } + return count; +} + + + +size_t GSMConfig::SDCCHAvailable() const +{ + ScopedLock lock(mLock); + return chanAvailable(mSDCCHPool); +} + +size_t GSMConfig::TCHAvailable() const +{ + ScopedLock lock(mLock); + return chanAvailable(mTCHPool); +} + + +size_t GSMConfig::totalLoad(const CCCHList& chanList) const +{ + size_t total = 0; + for (int i=0; iload(); + } + return total; +} + + + +template unsigned countActive(const vector& chanList) +{ + unsigned active = 0; + const unsigned sz = chanList.size(); + // Start the search from a random point in the list. + for (unsigned i=0; irecyclable()) active++; + } + return active; +} + + +unsigned GSMConfig::SDCCHActive() const +{ + return countActive(mSDCCHPool); +} + +unsigned GSMConfig::TCHActive() const +{ + return countActive(mTCHPool); +} + + +unsigned GSMConfig::T3122() const +{ + ScopedLock lock(mLock); + return mT3122; +} + +unsigned GSMConfig::growT3122() +{ + unsigned max = gConfig.getNum("GSM.Timer.T3122Max"); + ScopedLock lock(mLock); + unsigned retVal = mT3122; + mT3122 += (random() % mT3122) / 2; + if (mT3122>max) mT3122=max; + return retVal; +} + + +unsigned GSMConfig::shrinkT3122() +{ + unsigned min = gConfig.getNum("GSM.Timer.T3122Min"); + ScopedLock lock(mLock); + unsigned retVal = mT3122; + mT3122 -= (random() % mT3122) / 2; + if (mT3122setSlot(TN,0); +} + + +void GSMConfig::createCombinationI(TransceiverManager& TRX, unsigned TN) +{ + LOG_ASSERT(TN!=0); + LOG(NOTICE) << "Configuring combination I on C0T" << TN; + ARFCNManager *radio = TRX.ARFCN(); + radio->setSlot(TN,1); + TCHFACCHLogicalChannel* chan = new TCHFACCHLogicalChannel(TN,gTCHF_T[TN]); + chan->downstream(radio); + Thread* thread = new Thread; + thread->start((void*(*)(void*))Control::DCCHDispatcher,chan); + chan->open(); + gBTS.addTCH(chan); + +} + + +void GSMConfig::createCombinationVII(TransceiverManager& TRX, unsigned TN) +{ + LOG_ASSERT(TN!=0); + LOG(NOTICE) << "Configuring combination VII on C0T" << TN; + ARFCNManager *radio = TRX.ARFCN(); + radio->setSlot(TN,7); + for (int i=0; i<8; i++) { + SDCCHLogicalChannel* chan = new SDCCHLogicalChannel(TN,gSDCCH8[i]); + chan->downstream(radio); + Thread* thread = new Thread; + thread->start((void*(*)(void*))Control::DCCHDispatcher,chan); + chan->open(); + gBTS.addSDCCH(chan); + } +} + + +void GSMConfig::hold(bool val) +{ + ScopedLock lock(mLock); + mHold = val; +} + +bool GSMConfig::hold() const +{ + ScopedLock lock(mLock); + return mHold; +} + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSMConfig.h b/GSM/GSMConfig.h new file mode 100644 index 0000000..bb02e26 --- /dev/null +++ b/GSM/GSMConfig.h @@ -0,0 +1,289 @@ +/* +* Copyright 2008-2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef GSMCONFIG_H +#define GSMCONFIG_H + +#include +#include + +//#include +#include +#include + +#include "GSML3RRElements.h" +#include "GSML3CommonElements.h" +#include "GSML3RRMessages.h" + +#include "TRXManager.h" + + +namespace GSM { + + +class CCCHLogicalChannel; +class SDCCHLogicalChannel; +class TCHFACCHLogicalChannel; + +class CCCHList : public std::vector {}; +class SDCCHList : public std::vector {}; +class TCHList : public std::vector {}; + +/** + This object carries the top-level GSM air interface configuration. + It serves as a central clearinghouse to get access to everything else in the GSM code. +*/ +class GSMConfig { + + private: + + /** The paging mechanism is built-in. */ + Control::Pager mPager; + + PowerManager mPowerManager; + + mutable Mutex mLock; ///< multithread access control + + /**@name Groups of CCCH subchannels -- may intersect. */ + //@{ + CCCHList mAGCHPool; ///< access grant CCCH subchannels + CCCHList mPCHPool; ///< paging CCCH subchannels + //@} + + + /**@name Allocatable channel pools. */ + //@{ + SDCCHList mSDCCHPool; + TCHList mTCHPool; + //@} + + /**@name BSIC. */ + //@{ + unsigned mNCC; ///< network color code + unsigned mBCC; ///< basestation color code + //@} + + GSMBand mBand; ///< BTS operating band + + Clock mClock; ///< local copy of BTS master clock + + /**@name Encoded L2 frames to be sent on the BCCH. */ + //@{ + L2Frame mSI1Frame; + L2Frame mSI2Frame; + L2Frame mSI3Frame; + L2Frame mSI4Frame; + //@} + + /**@name Encoded L3 frames to be sent on the SACCH. */ + //@{ + L3Frame mSI5Frame; + L3Frame mSI6Frame; + //@} + + int mT3122; + + time_t mStartTime; + + L3LocationAreaIdentity mLAI; + + bool mHold; ///< If true, do not respond to RACH bursts. + + InterthreadQueue mChannelRequestQueue; + Thread mAccessGrantThread; + + public: + + + + /** All parameters come from gConfig. */ + GSMConfig(); + + /** Start the internal control loops. */ + void start(); + + /**@name Get references to L2 frames for BCCH SI messages. */ + //@{ + const L2Frame& SI1Frame() const { return mSI1Frame; } + const L2Frame& SI2Frame() const { return mSI2Frame; } + const L2Frame& SI3Frame() const { return mSI3Frame; } + const L2Frame& SI4Frame() const { return mSI4Frame; } + //@} + /**@name Get references to L3 frames for SACCH SI messages. */ + //@{ + const L3Frame& SI5Frame() const { return mSI5Frame; } + const L3Frame& SI6Frame() const { return mSI6Frame; } + //@} + + /** Get the current master clock value. */ + Time time() const { return mClock.get(); } + + /**@name Accessors. */ + //@{ + Control::Pager& pager() { return mPager; } + GSMBand band() const { return mBand; } + unsigned BCC() const { return mBCC; } + unsigned NCC() const { return mNCC; } + GSM::Clock& clock() { return mClock; } + const L3LocationAreaIdentity& LAI() const { return mLAI; } + //@} + + /** Return the BSIC, NCC:BCC. */ + unsigned BSIC() const { return (mNCC<<3) | mBCC; } + + /** + Re-encode the L2Frames for system information messages. + Called whenever a beacon parameter is changed. + */ + void regenerateBeacon(); + + /** + Hold off on channel allocations; don't answer RACH. + @param val true to hold, false to clear hold + */ + void hold(bool val); + + /** + Return true if we are holding off channel allocation. + */ + bool hold() const; + + protected: + + /** Find a minimum-load CCCH from a list. */ + CCCHLogicalChannel* minimumLoad(CCCHList &chanList); + + /** Return the total load of a CCCH list. */ + size_t totalLoad(const CCCHList &chanList) const; + + public: + + size_t AGCHLoad() { return totalLoad(mAGCHPool); } + size_t PCHLoad() { return totalLoad(mPCHPool); } + + /**@name Manage CCCH subchannels. */ + //@{ + + /** The add method is not mutex protected and should only be used during initialization. */ + void addAGCH(CCCHLogicalChannel* wCCCH) { mAGCHPool.push_back(wCCCH); } + + /** The add method is not mutex protected and should only be used during initialization. */ + void addPCH(CCCHLogicalChannel* wCCCH) { mPCHPool.push_back(wCCCH); } + + /** Return a minimum-load AGCH. */ + CCCHLogicalChannel* getAGCH() { return minimumLoad(mAGCHPool); } + + /** Return a minimum-load PCH. */ + CCCHLogicalChannel* getPCH() { return minimumLoad(mPCHPool); } + + /** Return a specific PCH. */ + CCCHLogicalChannel* getPCH(size_t index) + { + assert(index. + +*/ + + + +#include "GSML1FEC.h" +#include "GSMCommon.h" +#include "GSMSAPMux.h" +#include "GSMConfig.h" +#include "GSMTDMA.h" +#include "GSMTAPDump.h" +#include +#include +#include +#include +#include +#include + +#undef WARNING + +using namespace std; +using namespace GSM; + + +/* + + Notes on reading the GSM specifications. + + Every FEC section in GSM 05.03 uses standard names for the bits at + different stages of the encoding/decoding process. + + This is all described formally in GSM 05.03 2.2. + + "d" -- data bits. The actual payloads from L2 and the vocoders. + "p" -- parity bits. These are calculated from d. + "u" -- uncoded bits. A concatenation of d, p and inner tail bits. + "c" -- coded bits. These are the convolutionally encoded from u. + "i" -- interleaved bits. These are the output of the interleaver. + "e" -- "encrypted" bits. These are the channel bits in the radio bursts. + + The "e" bits are call "encrypted" even when encryption is not used. + + The encoding process is: + + L2 -> d -> -> calc p -> u -> c -> i -> e -> radio bursts + + The decoding process is: + + radio bursts -> e -> i -> c -> u -> check p -> d -> L2 + + Bit ordering in d is LSB-first in each octet. + Bit ordering everywhere else in the OpenBTS code is MSB-first + in every field to give contiguous fields across byte boundaries. + We use the BitVector::LSB8MSB() method to translate. + +*/ + + + + + +/**@name Power control utility functions based on GSM 05.05 4.1.1 */ +//@{ + +/** Power control codes for GSM400, GSM850, EGSM900 from GSM 05.05 4.1.1. */ +static const int powerCommandLowBand[32] = +{ + 39, 39, 39, 37, // 0-3 + 35, 33, 31, 29, // 4-7 + 27, 25, 23, 21, // 8-11 + 19, 17, 15, 13, // 12-15 + 11, 9, 7, 5, // 16-19 + 5, 5, 5, 5, // 20-23 + 5, 5, 5, 5, // 24-27 + 5, 5, 5, 5 // 28-31 +}; + +/** Power control codes for DCS1800 from GSM 05.05 4.1.1. */ +static const int powerCommand1800[32] = +{ + 30, 28, 26, 24, // 0-3 + 22, 20, 18, 16, // 4-7 + 14, 12, 10, 8, // 8-11 + 6, 4, 2, 0, // 12-15 + 0, 0, 0, 0, // 16-19 + 0, 0, 0, 0, // 20-23 + 0, 0, 0, 0, // 24-27 + 0, 36, 24, 23 // 28-31 +}; + +/** Power control codes for PCS1900 from GSM 05.05 4.1.1. */ +static const int powerCommand1900[32] = +{ + 30, 28, 26, 24, // 0-3 + 22, 20, 18, 16, // 4-7 + 14, 12, 10, 8, // 8-11 + 6, 4, 2, 0, // 12-15 + 0, 0, 0, 0, // 16-19 + 0, 0, 0, 0, // 20-23 + 0, 0, 0, 0, // 24-27 + 0, 0, 0, 0, // 28-31 +}; + + +const int* pickTable() +{ + switch (gBTS.band()) { + case GSM850: + case EGSM900: + return powerCommandLowBand; + break; + case DCS1800: + return powerCommand1800; + break; + case PCS1900: + return powerCommand1900; + break; + default: return NULL; + } +} + + +int decodePower(unsigned code) +{ + static const int *table = pickTable(); + assert(table); + return table[code]; + +} + + +/** Given a power level in dBm, encode the control code. */ +unsigned encodePower(int power) +{ + static const int *table = pickTable(); + assert(table); + unsigned minErr = abs(power - table[0]); + unsigned code = 0; + for (int i=1; i<32; i++) { + unsigned thisErr = abs(power - table[i]); + if (thisErr==0) return i; + if (thisErrrecyclable()); + return retVal; +} + + +L1Decoder* L1Encoder::sibling() +{ + if (!mParent) return NULL; + return mParent->decoder(); +} + + +const L1Decoder* L1Encoder::sibling() const +{ + if (!mParent) return NULL; + return mParent->decoder(); +} + + +void L1Encoder::resync() +{ + // If the encoder's clock is far from the current BTS clock, + // get it caught up to something reasonable. + Time now = gBTS.time(); + int32_t delta = mNextWriteTime-now; + OBJLOG(DEBUG) << "L1Encoder next=" << mNextWriteTime << " now=" << now << " delta=" << delta; + if ((delta<0) || (delta>(51*26))) { + mNextWriteTime = now; + mNextWriteTime.TN(mTN); + mNextWriteTime.rollForward(mMapping.frameMapping(mTotalBursts),mMapping.repeatLength()); + OBJLOG(DEBUG) <<"L1Encoder RESYNC next=" << mNextWriteTime << " now=" << now; + } +} + + +void L1Encoder::waitToSend() const +{ + // Block until the BTS clock catches up to the + // mostly recently transmitted burst. + gBTS.clock().wait(mPrevWriteTime); +} + + +void L1Encoder::sendIdleFill() +{ + // Send the L1 idle filling pattern, if any. + // For C0, that's the dummy burst. + // For Cn, don't do anything. + resync(); + for (unsigned i=0; iwriteHighSide(mFillerBurst); + rollForward(); + } +} + +unsigned L1Encoder::ARFCN() const +{ + assert(mDownstream); + return mDownstream->ARFCN(); +} + + + +void L1Decoder::open() +{ + ScopedLock lock(mLock); + if (!mRunning) start(); + mFER=0.0F; + mT3111.reset(); + mT3109.reset(); + mT3101.set(); + mActive = true; +} + + +void L1Decoder::close(bool hardRelease) +{ + ScopedLock lock(mLock); + mT3101.reset(); + mT3109.reset(); + // For a hard release, force T3111 to an expired state. + // (At least one of these timers has to be expired for the channel to recycle.) + if (hardRelease) mT3111.expire(); + else mT3111.set(); + mActive = false; +} + +bool L1Decoder::active() const +{ + ScopedLock lock(mLock); + return mActive && !recyclable(); +} + + +bool L1Decoder::recyclable() const +{ + ScopedLock lock(mLock); + return mT3101.expired() || mT3109.expired() || mT3111.expired(); +} + + +L1Encoder* L1Decoder::sibling() +{ + if (!mParent) return NULL; + return mParent->encoder(); +} + + +const L1Encoder* L1Decoder::sibling() const +{ + if (!mParent) return NULL; + return mParent->encoder(); +} + + + + +void L1Decoder::countGoodFrame() +{ + static const float a = 1.0F / ((float)mFERMemory); + static const float b = 1.0F - a; + mFER *= b; + OBJLOG(DEBUG) <<"L1Decoder FER=" << mFER; +} + + +void L1Decoder::countBadFrame() +{ + static const float a = 1.0F / ((float)mFERMemory); + static const float b = 1.0F - a; + mFER = b*mFER + a; + OBJLOG(DEBUG) <<"L1Decoder FER=" << mFER; +} + + + + +void L1FEC::downstream(ARFCNManager* radio) +{ + if (mEncoder) mEncoder->downstream(radio); + if (mDecoder) radio->installDecoder(mDecoder); +} + + +void L1FEC::open() +{ + if (mEncoder) mEncoder->open(); + if (mDecoder) mDecoder->open(); +} + +void L1FEC::close() +{ + if (mEncoder) mEncoder->close(); + if (mDecoder) mDecoder->close(); +} + +bool L1FEC::active() const +{ + // Encode-only channels are always active. + // Otherwise, the decoder is the better indicator. + if (mDecoder) return mDecoder->active(); + else return (mEncoder!=NULL); +} + + + + +void RACHL1Decoder::serviceLoop() +{ + // The service loop pulls RACH bursts from a FIFO + // and sends them to the decoder. + // This loop is in its own thread because + // the allocator can potentially block and we don't + // want the whole receive thread to block. + + while (true) { + RxBurst *rx = mQ.read(); + // Yes, if we wait long enough that read will timeout. + if (rx==NULL) continue; + writeLowSide(*rx); + delete rx; + } +} + + +void *GSM::RACHL1DecoderServiceLoopAdapter(RACHL1Decoder* obj) +{ + obj->serviceLoop(); + return NULL; +} + + +void RACHL1Decoder::start() +{ + // Start the processing thread. + L1Decoder::start(); + mServiceThread.start((void*(*)(void*))RACHL1DecoderServiceLoopAdapter,this); +} + + + +void RACHL1Decoder::writeLowSide(const RxBurst& burst) +{ + // The L1 FEC for the RACH is defined in GSM 05.03 4.6. + + // Decode the burst. + const SoftVector e(burst.segment(49,36)); + e.decode(mVCoder,mU); + + // To check validity, we have 4 tail bits and 6 parity bits. + // False alarm rate for random inputs is 1/1024. + + // Check the tail bits -- should all the zero. + if (mU.peekField(14,4)) { + countBadFrame(); + return; + } + + // Check the parity. + // The parity word is XOR'd with the BSIC. (GSM 05.03 4.6.) + unsigned sentParity = ~mU.peekField(8,6); + unsigned checkParity = mD.parity(mParity); + unsigned encodedBSIC = (sentParity ^ checkParity) & 0x03f; + if (encodedBSIC != gBTS.BSIC()) { + countBadFrame(); + return; + } + + // We got a valid RACH burst. + // The "payload" is an 8-bit field, "RA", defined in GSM 04.08 9.1.8. + // The channel assignment procedure is in GSM 04.08 3.3.1.1.3. + // It requires knowledge of the RA value and the burst receive time. + // The RACH L2 is so thin that we don't even need code for it. + // Just pass the required information directly to the control layer. + + countGoodFrame(); + mD.LSB8MSB(); + unsigned RA = mD.peekField(0,8); + OBJLOG(INFO) <<"RACHL1Decoder received RA=" << RA << " at time " << burst.time() + << " with RSSI=" << burst.RSSI() << " timingError=" << burst.timingError(); + gBTS.channelRequest(new Control::ChannelRequestRecord(RA,burst.time(),burst.RSSI(),burst.timingError())); +} + + + + + + + +/* + XCCHL1Encoder and Decoder methods. + The "XCCH" L1 components are based on GSM 05.03 4.1. + These are the most commonly used control channel L1 format + in GSM and are offer here as examples. +*/ + + + + +XCCHL1Decoder::XCCHL1Decoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent) + :L1Decoder(wTN,wMapping,wParent), + mBlockCoder(0x10004820009ULL, 40, 224), + mC(456), mU(228), + mP(mU.segment(184,40)),mDP(mU.head(224)),mD(mU.head(184)) +{ + for (int i=0; i<4; i++) { + mI[i] = SoftVector(114); + // Fill with zeros just to make Valgrind happy. + mI[i].fill(.0); + } +} + + + +void XCCHL1Decoder::writeLowSide(const RxBurst& inBurst) +{ + OBJLOG(DEBUG) <<"XCCHL1Decoder " << inBurst; + // If the channel is closed, ignore the burst. + if (!active()) { + OBJLOG(DEBUG) <<"XCCHL1Decoder not active, ignoring input"; + return; + } + // Accept the burst into the deinterleaving buffer. + // Return true if we are ready to interleave. + if (!processBurst(inBurst)) return; + deinterleave(); + if (decode()) { + countGoodFrame(); + mD.LSB8MSB(); + handleGoodFrame(); + } else { + countBadFrame(); + } +} + + +bool XCCHL1Decoder::processBurst(const RxBurst& inBurst) +{ + OBJLOG(DEBUG) <<"XCCHL1Decoder " << inBurst; + // Accept the burst into the deinterleaving buffer. + // Return true if we are ready to interleave. + + // TODO -- One quick test of burst validity is to look at the tail bits. + // We could do that as a double-check against putting garbage into + // the interleaver or accepting bad parameters. + + // The reverse index runs 0..3 as the bursts arrive. + // It is the "B" index of GSM 05.03 4.1.4 and 4.1.5. + int B = mMapping.reverseMapping(inBurst.time().FN()) % 4; + // A negative value means that the demux is misconfigured. + assert(B>=0); + + // Pull the data fields (e-bits) out of the burst and put them into i[B][]. + // GSM 05.03 4.1.5 + inBurst.data1().copyToSegment(mI[B],0); + inBurst.data2().copyToSegment(mI[B],57); + + // If the burst index is 3, then this is the last burst in the L2 frame. + // Return true to indicate that we are ready to deinterleave. + return B==3; + + // TODO -- This is sub-optimal because it ignores the case + // where the B==3 burst is simply missing, even though the soft decoder + // might actually be able to recover the frame. + // It also allows for the mixing of bursts from different frames. + // If we were more clever, we'd be watching for B to roll over as well. +} + + + + +void XCCHL1Decoder::deinterleave() +{ + // Deinterleave i[][] to c[]. + // This comes directly from GSM 05.03, 4.1.4. + for (int k=0; k<456; k++) { + int B = k%4; + int j = 2*((49*k) % 57) + ((k%8)/4); + mC[k] = mI[B][j]; + // Mark this i[][] bit as unknown now. + // This makes it possible for the soft decoder to work around + // a missing burst. + mI[B][j] = 0.5F; + } +} + + +bool XCCHL1Decoder::decode() +{ + // Apply the convolutional decoder and parity check. + // Return true if we recovered a good L2 frame. + + // Convolutional decoding c[] to u[]. + // GSM 05.03 4.1.3 + OBJLOG(DEBUG) <<"XCCHL1Decoder << mC"; + mC.decode(mVCoder,mU); + OBJLOG(DEBUG) <<"XCCHL1Decoder << mU"; + + // The GSM L1 u-frame has a 40-bit parity field. + // False detections are EXTREMELY rare. + // Parity check of u[]. + // GSM 05.03 4.1.2. + mP.invert(); // parity is inverted + // The syndrome should be zero. + OBJLOG(DEBUG) <<"XCCHL1Decoder d[]:p[]=" << mDP; + unsigned syndrome = mBlockCoder.syndrome(mDP); + OBJLOG(DEBUG) <<"XCCHL1Decoder syndrome=" << hex << syndrome << dec; + return (syndrome==0); +} + + + +void XCCHL1Decoder::handleGoodFrame() +{ + OBJLOG(DEBUG) <<"XCCHL1Decoder u[]=" << mU; + + { + ScopedLock lock(mLock); + // Keep T3109 from timing out. + mT3109.set(); + // If this is the first good frame of a new transaction, + // stop T3101 and tell L2 we're alive down here. + if (mT3101.active()) { + mT3101.reset(); + if (mUpstream!=NULL) mUpstream->writeLowSide(L2Frame(ESTABLISH)); + } + } + + // Get the d[] bits, the actual payload in the radio channel. + // Undo GSM's LSB-first octet encoding. + OBJLOG(DEBUG) <<"XCCHL1Decoder d[]=" << mD; + + if (mUpstream) { + // Build an L2 frame and pass it up. + const BitVector L2Part(mD.tail(headerOffset())); + OBJLOG(DEBUG) <<"XCCHL1Decoder L2=" << L2Part; + mUpstream->writeLowSide(L2Frame(L2Part,DATA)); + } else { + OBJLOG(ERR) << "XCCHL1Decoder with no uplink connected."; + } +} + + +float SACCHL1Decoder::RSSI() const +{ + float sum=mRSSI[0]+mRSSI[1]+mRSSI[2]+mRSSI[3]; + return 0.25F*sum; +} + +float SACCHL1Decoder::timingError() const +{ + float sum=mTimingError[0]+mTimingError[1]+mTimingError[2]+mTimingError[3]; + return 0.25F*sum; +} + + + +bool SACCHL1Decoder::processBurst(const RxBurst& inBurst) +{ + // TODO -- One quick test of burst validity is to look at the tail bits. + // We could do that as a double-check against putting garbage into + // the interleaver or accepting bad parameters. + + // Get the physical parameters of the burst. + // The actual phone settings change every 4 bursts, + // so average over all 4. + // RSSI is dB wrt full scale. + mRSSI[mRSSICounter] = inBurst.RSSI(); + // Timing error is a float in symbol intervals. + mTimingError[mRSSICounter] = inBurst.timingError(); + + OBJLOG(INFO) << "SACCHL1Decoder " << " RSSI=" << inBurst.RSSI() + << " timingError=" << inBurst.timingError(); + + mRSSICounter++; + if (mRSSICounter>3) mRSSICounter=0; + + return XCCHL1Decoder::processBurst(inBurst); +} + + +void SACCHL1Decoder::handleGoodFrame() +{ + // GSM 04.04 7 + OBJLOG(DEBUG) << "SACCHL1Decoder phy header " << mU.head(16); + mActualMSPower = decodePower(mU.peekField(3,5)); + int TAField = mU.peekField(9,7); + if (TAField<64) mActualMSTiming = TAField; + OBJLOG(INFO) << "SACCHL1Decoder actuals pow=" << mActualMSPower << " TA=" << mActualMSTiming; + XCCHL1Decoder::handleGoodFrame(); +} + + + + + + +XCCHL1Encoder::XCCHL1Encoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC* wParent) + :L1Encoder(wTN,wMapping,wParent), + mBlockCoder(0x10004820009ULL, 40, 224), + mC(456), mU(228), + mD(mU.head(184)),mP(mU.segment(184,40)) +{ + // Set up the interleaving buffers. + for(int k = 0; k<4; k++) { + mI[k] = BitVector(114); + // Fill with zeros just to make Valgrind happy. + mI[k].fill(0); + } + + mFillerBurst = TxBurst(gDummyBurst); + + // Set up the training sequence and stealing bits + // since they'll be the same for all bursts. + + // stealing bits for a control channel, GSM 05.03 4.2.5, 05.02 5.2.3. + mBurst.Hl(1); + mBurst.Hu(1); + // training sequence, GSM 05.02 5.2.3 + gTrainingSequence[mTSC].copyToSegment(mBurst,61); + + // zero out u[] to take care of tail fields + mU.zero(); +} + + +void XCCHL1Encoder::writeHighSide(const L2Frame& frame) +{ + switch (frame.primitive()) { + case DATA: + // Encode and send data. + if (!active()) { LOG(INFO) << "XCCHL1Encoder::writeHighSide sending on non-active channel"; } + resync(); + sendFrame(frame); + break; + case ESTABLISH: + // Open both sides of the link. + // The phone is waiting to see the idle pattern. + open(); + if (sibling()) sibling()->open(); + return; + case RELEASE: + // Normally, we get here after a DISC-DM handshake in L2. + // Close both sides of the link, knowing that the phone will do the same. + close(); + if (sibling()) sibling()->close(); + break; + case HARDRELEASE: + // This means that a higher layer released the link, + // with certainty that is has been cleared of activity. + close(); + if (sibling()) sibling()->close(true); + break; + case ERROR: + // If we got here, it means the link failed in L2 after several ack timeouts. + // Close the tx side and just let the receiver L1 time out on its own. + // Otherwise, we risk recycling the channel while the phone's still active. + close(); + break; + default: + LOG(ERR) << "unhandled primitive " << frame.primitive() << " in L2->L1"; + assert(0); + } +} + + + +void XCCHL1Encoder::sendFrame(const L2Frame& frame) +{ + OBJLOG(DEBUG) << "XCCHL1Encoder " << frame; + // Make sure there's something down there to take the busts. + if (mDownstream==NULL) { + LOG(WARNING) << "XCCHL1Encoder with no downstream"; + return; + } + + // This comes from GSM 05.03 4.1 + + // Copy the L2 frame into u[] for processing. + // GSM 05.03 4.1.1. + //assert(mD.size()==headerOffset()+frame.size()); + frame.copyToSegment(mU,headerOffset()); + OBJLOG(DEBUG) << "XCCHL1Encoder d[]=" << mD; + mD.LSB8MSB(); + OBJLOG(DEBUG) << "XCCHL1Encoder d[]=" << mD; + encode(); // Encode u[] to c[], GSM 05.03 4.1.2 and 4.1.3. + interleave(); // Interleave c[] to i[][], GSM 05.03 4.1.4. + transmit(); // Send the bursts to the radio, GSM 05.03 4.1.5. + // FIXME: is this FN OK, or do we need to back it up by 4? + gWriteGSMTAP(ARFCN(),mTN,mPrevWriteTime.FN(),frame); +} + + + +void XCCHL1Encoder::encode() +{ + // Perform the FEC encoding of GSM 05.03 4.1.2 and 4.1.3 + + // GSM 05.03 4.1.2 + // Generate the parity bits. + mBlockCoder.writeParityWord(mD,mP); + OBJLOG(DEBUG) << "XCCHL1Encoder u[]=" << mU; + // GSM 05.03 4.1.3 + // Apply the convolutional encoder. + mU.encode(mVCoder,mC); + OBJLOG(DEBUG) << "XCCHL1Encoder c[]=" << mC; +} + + + +void XCCHL1Encoder::interleave() +{ + // GSM 05.03, 4.1.4. Verbatim. + for (int k=0; k<456; k++) { + int B = k%4; + int j = 2*((49*k) % 57) + ((k%8)/4); + mI[B][j] = mC[k]; + } +} + + + +void XCCHL1Encoder::transmit() +{ + // Format the bits into the bursts. + // GSM 05.03 4.1.5, 05.02 5.2.3 + + waitToSend(); // Don't get too far ahead of the clock. + + if (!mDownstream) { + // For some testing, we might not have a radio connected. + // That's OK, as long as we know it. + LOG(WARNING) << "XCCHL1Encoder with no radio, dumping frames"; + return; + } + + for (int B=0; B<4; B++) { + mBurst.time(mNextWriteTime); + // Copy in the "encrypted" bits, GSM 05.03 4.1.5, 05.02 5.2.3. + OBJLOG(DEBUG) << "XCCHL1Encoder mI["<writeHighSide(mBurst); + rollForward(); +} + + + + + + +FCCHL1Encoder::FCCHL1Encoder(L1FEC *wParent) + :GeneratorL1Encoder(0,gFCCHMapping,wParent) +{ + mBurst.zero(); + mFillerBurst.zero(); +} + + +void FCCHL1Encoder::generate() +{ + OBJLOG(DEBUG) << "FCCHL1Encoder " << mNextWriteTime; + assert(mDownstream); + resync(); + for (int i=0; i<5; i++) { + mBurst.time(mNextWriteTime); + mDownstream->writeHighSide(mBurst); + rollForward(); + } + sleep(1); +} + + + + +void NDCCHL1Encoder::start() +{ + L1Encoder::start(); + mSendThread.start((void*(*)(void*))NDCCHL1EncoderServiceLoopAdapter,(void*)this); +} + + + +void *GSM::NDCCHL1EncoderServiceLoopAdapter(NDCCHL1Encoder* gen) +{ + gen->serviceLoop(); + // DONTREACH + return NULL; +} + +void NDCCHL1Encoder::serviceLoop() +{ + while (mRunning) { + generate(); + } +} + + + + + +void BCCHL1Encoder::generate() +{ + OBJLOG(DEBUG) << "BCCHL1Encoder " << mNextWriteTime; + // BCCH mapping, GSM 05.02 6.3.1.3 + // Since we're not doing GPRS or VGCS, it's just SI1-4 over and over. + switch (mNextWriteTime.TC()) { + case 0: writeHighSide(gBTS.SI1Frame()); return; + case 1: writeHighSide(gBTS.SI2Frame()); return; + case 2: writeHighSide(gBTS.SI3Frame()); return; + case 3: writeHighSide(gBTS.SI4Frame()); return; + case 4: writeHighSide(gBTS.SI3Frame()); return; + case 5: writeHighSide(gBTS.SI2Frame()); return; + case 6: writeHighSide(gBTS.SI3Frame()); return; + case 7: writeHighSide(gBTS.SI4Frame()); return; + default: assert(0); + } +} + + + + +TCHFACCHL1Decoder::TCHFACCHL1Decoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent) + :XCCHL1Decoder(wTN, wMapping, wParent), + mTCHU(189),mTCHD(260), + mClass1_c(mC.head(378)),mClass1A_d(mTCHD.head(50)),mClass2_c(mC.segment(378,78)), + mTCHParity(0x0b,3,50) +{ + for (int i=0; i<8; i++) { + mI[i] = SoftVector(114); + // Fill with zeros just to make Valgrind happy. + mI[i].fill(.0); + } +} + + + + +void TCHFACCHL1Decoder::writeLowSide(const RxBurst& inBurst) +{ + OBJLOG(DEBUG) << "TCHFACCHL1Decoder " << inBurst; + // If the channel is closed, ignore the burst. + if (!active()) { + OBJLOG(DEBUG) << "TCHFACCHL1Decoder not active, ignoring input"; + return; + } + processBurst(inBurst); +} + + + + + +bool TCHFACCHL1Decoder::processBurst( const RxBurst& inBurst) +{ + // Accept the burst into the deinterleaving buffer. + // Return true if we are ready to interleave. + + // TODO -- One quick test of burst validity is to look at the tail bits. + // We could do that as a double-check against putting garbage into + // the interleaver or accepting bad parameters. + + // The reverse index runs 0..7 as the bursts arrive. + // It is the "B" index of GSM 05.03 3.1.3 and 3.1.4. + int B = mMapping.reverseMapping(inBurst.time().FN()) % 8; + // A negative value means that the demux is misconfigured. + assert(B>=0); + OBJLOG(DEBUG) << "TCHFACCHL1Decoder B=" << B << " " << inBurst; + + // Pull the data fields (e-bits) out of the burst and put them into i[B][]. + // GSM 05.03 3.1.4 + inBurst.data1().copyToSegment(mI[B],0); + inBurst.data2().copyToSegment(mI[B],57); + + // Every 4th frame is the start of a new block. + // So if this isn't a "4th" frame, return now. + if (B%4!=3) return false; + + // Deinterleave according to the diagonal "phase" of B. + // See GSM 05.03 3.1.3. + // Deinterleaves i[] to c[] + if (B==3) deinterleave(4); + else deinterleave(0); + + // See if this was the end of a stolen frame, GSM 05.03 4.2.5. + bool stolen = inBurst.Hl(); + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder Hl=" << inBurst.Hl() << " Hu=" << inBurst.Hu(); + if (stolen) { + if (decode()) { + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder good FACCH frame"; + countGoodFrame(); + mD.LSB8MSB(); + handleGoodFrame(); + } else { + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder bad FACCH frame"; + countBadFrame(); + } + } + + // Always feed the traffic channel, even on a stolen frame. + // decodeTCH will handle the GSM 06.11 bad frmae processing. + bool traffic = decodeTCH(stolen); + if (traffic) { + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder good TCH frame"; + countGoodFrame(); + // Don't let the channel timeout. + ScopedLock lock(mLock); + mT3109.set(); + } + else countBadFrame(); + + return true; +} + + + + +void TCHFACCHL1Decoder::deinterleave(int blockOffset ) +{ + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder blockOffset=" << blockOffset; + for (int k=0; k<456; k++) { + int B = ( k + blockOffset ) % 8; + int j = 2*((49*k) % 57) + ((k%8)/4); + mC[k] = mI[B][j]; + mI[B][j] = 0.5F; + } +} + + + + + +bool TCHFACCHL1Decoder::decodeTCH(bool stolen) +{ + // GSM 05.02 3.1.2, but backwards + + // If the frame wasn't stolen, we'll update this with parity later. + bool good = !stolen; + + // Good or bad, we will be sending *something* to the speech channel. + // Allocate it in this scope. + unsigned char * newFrame = new unsigned char[33]; + + if (!stolen) { + + // 3.1.2.2 + // decode from c[] to u[] + mClass1_c.decode(mVCoder,mTCHU); + + // 3.1.2.2 + // copy class 2 bits c[] to d[] + mClass2_c.sliced().copyToSegment(mTCHD,182); + + // 3.1.2.1 + // copy class 1 bits u[] to d[] + for (unsigned k=0; k<=90; k++) { + mTCHD[2*k] = mTCHU[k]; + mTCHD[2*k+1] = mTCHU[184-k]; + } + + // 3.1.2.1 + // check parity of class 1A + unsigned sentParity = (~mTCHU.peekField(91,3)) & 0x07; + unsigned calcParity = mClass1A_d.parity(mTCHParity) & 0x07; + + // 3.1.2.2 + // Check the tail bits, too. + unsigned tail = mTCHU.peekField(185,4); + + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder c[]=" << mC; + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder u[]=" << mTCHU; + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder d[]=" << mTCHD; + OBJLOG(DEBUG) <<"TCHFACCHL1Decoder sentParity=" << sentParity + << " calcParity=" << calcParity << " tail=" << tail; + good = (sentParity==calcParity) && (tail==0); + if (good) { + // Undo Um's importance-sorted bit ordering. + // See GSM 05.03 3.1 and Table 2. + BitVector payload = mVFrame.payload(); + mTCHD.unmap(g610BitOrder,260,payload); + mVFrame.pack(newFrame); + // Save a copy for bad frame processing. + memcpy(mPrevGoodFrame,newFrame,33); + } + } + + if (!good) { + // Bad frame processing, GSM 06.11. + // Attenuate block amplitudes and andomize grid positions. + char rawByte = mPrevGoodFrame[27]; + unsigned xmaxc = rawByte & 0x01f; + if (xmaxc>2) xmaxc -= 2; + else xmaxc = 0; + for (unsigned i=0; i<4; i++) { + unsigned pos = random() % 4; + mPrevGoodFrame[6+7*i] = (rawByte & 0x80) | pos | xmaxc; + mPrevGoodFrame[7+7*i] &= 0x7F; + } + memcpy(newFrame,mPrevGoodFrame,33); + } + + // Good or bad, we must feed the speech channel. + mSpeechQ.write(newFrame); + + return good; +} + + + + + + + + +void GSM::TCHFACCHL1EncoderRoutine( TCHFACCHL1Encoder * encoder ) +{ + while (1) { + encoder->dispatch(); + } +} + + + + +TCHFACCHL1Encoder::TCHFACCHL1Encoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent) + :XCCHL1Encoder(wTN, wMapping, wParent), + mPreviousFACCH(false),mOffset(0), + mTCHU(189),mTCHD(260), + mClass1_c(mC.head(378)),mClass1A_d(mTCHD.head(50)),mClass2_d(mTCHD.segment(182,78)), + mTCHParity(0x0b,3,50) +{ + for(int k = 0; k<8; k++) { + mI[k] = BitVector(114); + // Fill with zeros just to make Valgrind happy. + mI[k].fill(0); + } +} + + + + +void TCHFACCHL1Encoder::start() +{ + L1Encoder::start(); + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder"; + mEncoderThread.start((void*(*)(void*))TCHFACCHL1EncoderRoutine,(void*)this); +} + + + + +void TCHFACCHL1Encoder::open() +{ + // There was over stuff here at one time to justify overriding the default. + // But it's gone now. + XCCHL1Encoder::open(); +} + + +void TCHFACCHL1Encoder::encodeTCH(const VocoderFrame& vFrame) +{ + // GSM 05.02 3.1.2 + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder"; + + // Reorder bits by importance. + // See GSM 05.03 3.1 and Table 2. + vFrame.payload().map(g610BitOrder,260,mTCHD); + + // 3.1.2.1 -- parity bits + BitVector p = mTCHU.segment(91,3); + mTCHParity.writeParityWord(mClass1A_d,p); + + // 3.1.2.1 -- copy class 1 bits d[] to u[] + for (unsigned k=0; k<=90; k++) { + mTCHU[k] = mTCHD[2*k]; + mTCHU[184-k] = mTCHD[2*k+1]; + } + + // 3.1.2.1 -- tail bits in u[] + // TODO -- This should only be needed once, in the constructor. + for (unsigned k=185; k<=188; k++) mTCHU[k]=0; + + // 3.1.2.2 -- encode u[] to c[] for class 1 + mTCHU.encode(mVCoder,mClass1_c); + + // 3.1.2.2 -- copy class 2 d[] to c[] + mClass2_d.copyToSegment(mC,378); + + // So the encoded speech frame is now in c[] + // and ready for the interleaver. +} + + + + + +void TCHFACCHL1Encoder::sendFrame( const L2Frame& frame ) +{ + OBJLOG(DEBUG) << "TCHFACCHL1Encoder " << frame; + mL2Q.write(new L2Frame(frame)); +} + + + +void TCHFACCHL1Encoder::dispatch() +{ + + // No downstream? That's a problem. + assert(mDownstream); + + // Get right with the system clock. + resync(); + + // If the channel is not active, wait for a multiframe and return. + // Most channels do not need this, becuase they are entirely data-driven + // from above. TCH/FACCH, however, must feed the interleaver on time. + if (!active()) { + mNextWriteTime += 26; + gBTS.clock().wait(mNextWriteTime); + return; + } + + // Let previous data get transmitted. + resync(); + waitToSend(); + + // flag to control stealing bits + bool currentFACCH = false; + + // Speech latency control. + // Since Asterisk is local, latency should be small. + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder speechQ.size=" << mSpeechQ.size(); + int maxQ = gConfig.getNum("GSM.MaxSpeechLatency"); + while (mSpeechQ.size() > maxQ) delete mSpeechQ.read(); + + // Send, by priority: (1) FACCH, (2) TCH, (3) filler. + if (L2Frame *fFrame = mL2Q.readNoBlock()) { + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder FACCH " << *fFrame; + currentFACCH = true; + // Copy the L2 frame into u[] for processing. + // GSM 05.03 4.1.1. + fFrame->LSB8MSB(); + fFrame->copyTo(mU); + // Encode u[] to c[], GSM 05.03 4.1.2 and 4.1.3. + encode(); + delete fFrame; + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder FACCH c[]=" << mC; + // Flush the vocoder FIFO to limit latency. + while (mSpeechQ.size()>0) delete mSpeechQ.read(); + } else if (VocoderFrame *tFrame = mSpeechQ.readNoBlock()) { + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder TCH " << *tFrame; + // Encode the speech frame into c[] as per GSM 05.03 3.1.2. + encodeTCH(*tFrame); + delete tFrame; + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder TCH c[]=" << mC; + } else { + // We have no ready data but must send SOMETHING. + // This filler pattern was captured from a Nokia 3310, BTW. + static const BitVector fillerC("110100001000111100000000111001111101011100111101001111000000000000110111101111111110100110101010101010101010101010101010101010101010010000110000000000000000000000000000000000000000001101001111000000000000000000000000000000000000000000000000111010011010101010101010101010101010101010101010101001000011000000000000000000110100111100000000111001111101101000001100001101001111000000000000000000011001100000000000000000000000000000000000000000000000000000000001"); + fillerC.copyTo(mC); + OBJLOG(DEBUG) <<"TCHFACCHL1Encoder filler FACCH=" << currentFACCH << " c[]=" << mC; + } + + // Interleave c[] to i[]. + interleave(mOffset); + + // "mapping on a burst" + // Map c[] into outgoing normal bursts, marking stealing flags as needed. + // GMS 05.03 3.1.4. + for (int B=0; B<4; B++) { + // set TDMA position + mBurst.time(mNextWriteTime); + // copy in the bits + mI[B+mOffset].segment(0,57).copyToSegment(mBurst,3); + mI[B+mOffset].segment(57,57).copyToSegment(mBurst,88); + // stealing bits + mBurst.Hu(currentFACCH); + mBurst.Hl(mPreviousFACCH); + // send + OBJLOG(DEBUG) <<"TCHFACCHEncoder sending burst=" << mBurst; + mDownstream->writeHighSide(mBurst); + rollForward(); + } + + // Updaet the offset for the next transmission. + if (mOffset==0) mOffset=4; + else mOffset=0; + + // Save the stealing flag. + mPreviousFACCH = currentFACCH; +} + + + +void TCHFACCHL1Encoder::interleave(int blockOffset) +{ + // GSM 05.03, 3.1.3 + for (int k=0; k<456; k++) { + int B = ( k + blockOffset ) % 8; + int j = 2*((49*k) % 57) + ((k%8)/4); + mI[B][j] = mC[k]; + } +} + + +bool TCHFACCHL1Decoder::uplinkLost() const +{ + ScopedLock lock(mLock); + return mT3109.expired(); +} + + + +void SACCHL1FEC::setPhy(const SACCHL1FEC& other) +{ + mSACCHDecoder->setPhy(*other.mSACCHDecoder); + mSACCHEncoder->setPhy(*other.mSACCHEncoder); +} + +void SACCHL1FEC::setPhy(float RSSI, float timingError) +{ + mSACCHDecoder->setPhy(RSSI,timingError); + mSACCHEncoder->setPhy(RSSI,timingError); +} + + + + +void SACCHL1Decoder::open() +{ + OBJLOG(DEBUG) << "SACCHL1Decoder"; + XCCHL1Decoder::open(); + // Set initial defaults for power and timing advance. + // We know the handset sent the RACH burst at max power and 0 timing advance. + mActualMSPower = 33; + mActualMSTiming = 0; + // Measured values should be set after opening with setPhy. +} + + + +void SACCHL1Decoder::setPhy(float wRSSI, float wTimingError) +{ + // Used to initialize L1 phy parameters. + for (int i=0; i<4; i++) mRSSI[i]=wRSSI; + for (int i=0; i<4; i++) mTimingError[i]=wTimingError; + OBJLOG(INFO) << "SACCHL1Decoder RSSI=" << wRSSI << "timingError=" << wTimingError; +} + +void SACCHL1Decoder::setPhy(const SACCHL1Decoder& other) +{ + // Used to initialize a new SACCH L1 phy parameters + // from those of a preexisting established channel. + mActualMSPower = other.mActualMSPower; + mActualMSTiming = other.mActualMSTiming; + for (int i=0; i<4; i++) mRSSI[i]=other.mRSSI[i]; + for (int i=0; i<4; i++) mTimingError[i]=other.mTimingError[i]; + OBJLOG(INFO) << "SACCHL1Decoder actuals RSSI=" << mRSSI[0] << "timingError=" << mTimingError[0] + << " MSPower=" << mActualMSPower << " MSTiming=" << mActualMSTiming; +} + + + +void SACCHL1Encoder::setPhy(float wRSSI, float wTimingError) +{ + // Used to initialize L1 phy parameters. + // This is similar to the code for the closed loop tracking, + // except that there's no damping. + SACCHL1Decoder &sib = *SACCHSibling(); + // RSSI + float RSSI = sib.RSSI(); + float RSSITarget = gConfig.getNum("GSM.Radio.RSSITarget"); + float deltaP = RSSI - RSSITarget; + float actualPower = sib.actualMSPower(); + mOrderedMSPower = actualPower - deltaP; + float maxPower = gConfig.getNum("GSM.MS.Power.Max"); + float minPower = gConfig.getNum("GSM.MS.Power.Min"); + if (mOrderedMSPower>maxPower) mOrderedMSPower=maxPower; + else if (mOrderedMSPowermaxTiming) mOrderedMSTiming=maxTiming; + OBJLOG(INFO) << "SACCHL1Encoder timingError=" << timingError << + " actual=" << actualTiming << " ordered=" << mOrderedMSTiming; +} + + +void SACCHL1Encoder::setPhy(const SACCHL1Encoder& other) +{ + // Used to initialize a new SACCH L1 phy parameters + // from those of a preexisting established channel. + mOrderedMSPower = other.mOrderedMSPower; + mOrderedMSTiming = other.mOrderedMSTiming; + OBJLOG(INFO) << "SACCHL1Encoder orders MSPower=" << mOrderedMSPower << " MSTiming=" << mOrderedMSTiming; +} + + + + + +SACCHL1Encoder::SACCHL1Encoder(unsigned wTN, const TDMAMapping& wMapping, SACCHL1FEC *wParent) + :XCCHL1Encoder(wTN,wMapping,(L1FEC*)wParent), + mSACCHParent(wParent), + mOrderedMSPower(33),mOrderedMSTiming(0) +{ } + + +void SACCHL1Encoder::open() +{ + OBJLOG(INFO) <<"SACCHL1Encoder"; + XCCHL1Encoder::open(); + mOrderedMSPower = 33; + mOrderedMSTiming = 0; +} + + + +SACCHL1Encoder* SACCHL1Decoder::SACCHSibling() +{ + return mSACCHParent->encoder(); +} + +SACCHL1Decoder* SACCHL1Encoder::SACCHSibling() +{ + return mSACCHParent->decoder(); +} + + + +void SACCHL1Encoder::sendFrame(const L2Frame& frame) +{ + OBJLOG(INFO) << "SACCHL1Encoder " << frame; + + // Physical header, GSM 04.04 6, 7.1 + // Power and timing control, GSM 05.08 4, GSM 05.10 5, 6. + + SACCHL1Decoder &sib = *SACCHSibling(); +// if (sib.phyNew()) { + // Power. GSM 05.08 4. + // Power expressed in dBm, RSSI in dB wrt max. + float RSSI = sib.RSSI(); + float RSSITarget = gConfig.getNum("GSM.Radio.RSSITarget"); + float deltaP = RSSI - RSSITarget; + float actualPower = sib.actualMSPower(); + float targetMSPower = actualPower - deltaP; + float powerDamping = gConfig.getNum("GSM.MS.Power.Damping")*0.01F; + mOrderedMSPower = powerDamping*mOrderedMSPower + (1.0F-powerDamping)*targetMSPower; + float maxPower = gConfig.getNum("GSM.MS.Power.Max"); + float minPower = gConfig.getNum("GSM.MS.Power.Min"); + if (mOrderedMSPower>maxPower) mOrderedMSPower=maxPower; + else if (mOrderedMSPowermaxTiming) mOrderedMSTiming=maxTiming; + OBJLOG(DEBUG) << "SACCHL1Encoder timingError=" << timingError + << " actual=" << actualTiming << " ordered=" << mOrderedMSTiming + << " target=" << targetMSTiming; +// } + + // Write physical header into mU and then call base class. + + // SACCH physical header, GSM 04.04 6.1, 7.1. + OBJLOG(INFO) <<"SACCHL1Encoder orders pow=" << mOrderedMSPower << " TA=" << mOrderedMSTiming; + mU.fillField(0,encodePower(mOrderedMSPower),8); + mU.fillField(8,(int)(mOrderedMSTiming+0.5F),8); // timing (GSM 04.04 6.1) + OBJLOG(DEBUG) << "SACCHL1Encoder phy header " << mU.head(16); + + // Encode the rest of the frame. + XCCHL1Encoder::sendFrame(frame); +} + + + + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML1FEC.h b/GSM/GSML1FEC.h new file mode 100644 index 0000000..f936a19 --- /dev/null +++ b/GSM/GSML1FEC.h @@ -0,0 +1,1230 @@ +/* +* Copyright 2008-2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* + + 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. + +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +*/ + + + +#ifndef GSML1FEC_H +#define GSML1FEC_H + +#include "Threads.h" +#include +#include "BitVector.h" + +#include "GSMCommon.h" +#include "GSMTransfer.h" +#include "GSMTDMA.h" + +#include "GSM610Tables.h" + +#include + + +class ARFCNManager; + + +namespace GSM { + + +/* forward refs */ +class GSMConfig; + +class SAPMux; + +class L1FEC; +class L1Encoder; +class L1Decoder; +class GeneratorL1Encoder; +class SACCHL1Encoder; +class SACCHL1Decoder; +class SACCHL1FEC; +class TrafficTranscoder; + + + + +/* + Naming convention for bit vectors follows GSM 05.03 Section 2.2. + d[k] data + u[k] data bits after first encoding step + c[k] data bits after second encoding step + i[B][k] interleaved data bits + e[B][k] bits in a burst +*/ + + + + + +/** + Abstract class for L1 encoders. + In most subclasses, writeHighSide() drives the processing. +*/ +class L1Encoder { + + protected: + + ARFCNManager *mDownstream; + TxBurst mBurst; ///< a preformatted burst template + TxBurst mFillerBurst; ///< the filler burst for this channel + + /**@name Config items that don't change. */ + //@{ + const TDMAMapping& mMapping; ///< multiplexing description + unsigned mTN; ///< timeslot number to use + unsigned mTSC; ///< training sequence for this channel + L1FEC *mParent; ///< a containing L1FEC, if any + //@} + + /**@name Multithread access control and data shared across threads. */ + //@{ + mutable Mutex mLock; + //@} + + /**@ Internal state. */ + //@{ + unsigned mTotalBursts; ///< total bursts sent since last open() + GSM::Time mPrevWriteTime; ///< timestamp of pervious generated burst + GSM::Time mNextWriteTime; ///< timestamp of next generated burst + volatile bool mRunning; ///< true while the service loop is running + bool mActive; ///< true between open() and close() + //@} + + ViterbiR2O4 mVCoder; ///< nearly all GSM channels use the same convolutional code + + char mDescriptiveString[100]; + + public: + + /** + The basic encoder constructor. + @param wTN TDMA timeslot number. + @param wMapping TDMA mapping onto the timeslot -- MUST PERSIST. + @param wParent The containing L1FEC, for sibling access -- may be NULL. + */ + L1Encoder(unsigned wTN, const TDMAMapping& wMapping, L1FEC *wParent); + + virtual ~L1Encoder() {} + + /** Set the transceiver pointer. */ + virtual void downstream(ARFCNManager *wDownstream) + { + assert(mDownstream==NULL); // Don't call this twice. + mDownstream=wDownstream; + } + + /**@name Accessors. */ + //@{ + const TDMAMapping& mapping() const { return mMapping; } + /**@name Components of the channel description. */ + //@{ + unsigned TN() const { return mTN; } + unsigned TSC() const { return mTSC; } + unsigned ARFCN() const; + TypeAndOffset typeAndOffset() const; ///< this comes from mMapping + //@} + //@} + + /** Close the channel after blocking for flush. */ + virtual void close(); + + /** Open the channel for a new transaction. */ + virtual void open(); + + /** + Returns true if the channel is in use by a transaction. + For broadcast and unicast channels this is always true. + For dedicated channels, this is taken from the sibling deocder. + */ + virtual bool active() const; + + /** + Process pending L2 frames and/or generate filler and enqueue the resulting timeslots. + This method may block briefly, up to about 1/2 second. + This method is meaningless for some suclasses. + */ + virtual void writeHighSide(const L2Frame&) { assert(0); } + + /** Start the service loop thread, if there is one. */ + virtual void start() { mRunning=true; } + + const char* descriptiveString() const { return mDescriptiveString; } + + protected: + + /** Roll write times forward to the next positions. */ + void rollForward(); + + /** Return pointer to paired L1 decoder, if any. */ + virtual L1Decoder* sibling(); + + /** Return pointer to paired L1 decoder, if any. */ + virtual const L1Decoder* sibling() const; + + /** Make sure we're consistent with the current clock. */ + void resync(); + + /** Block until the BTS clock catches up to mPrevWriteTime. */ + void waitToSend() const; + + /** + Send the idle filling pattern, if any. + The default is a dummy burst. + */ + virtual void sendIdleFill(); + +}; + + + + +/** + An abstract class for L1 decoders. + writeLowSide() drives the processing. +*/ +class L1Decoder { + + protected: + + SAPMux * mUpstream; + + /**@name Mutex-controlled state information. */ + //@{ + mutable Mutex mLock; ///< access control + /**@name Timers from GSM 04.08 11.1.2 */ + //@{ + Z100Timer mT3101; ///< timer for new channels + Z100Timer mT3109; ///< timer for existing channels + Z100Timer mT3111; ///< timer for reuse of a closed channel + //@} + bool mActive; ///< true between open() and close() + //@} + + /**@name Atomic volatiles, no mutex. */ + // Yes, I realize we're violating our own rules here. -- DAB + //@{ + volatile bool mRunning; ///< true if all required service threads are started + volatile float mFER; ///< current FER estimate + static const int mFERMemory=20; ///< FER decay time, in frames + //@} + + /**@name Parameters fixed by the constructor, not requiring mutex protection. */ + //@{ + unsigned mTN; ///< timeslot number + const TDMAMapping& mMapping; ///< demux parameters + L1FEC* mParent; ///< a containing L1 processor, if any + //@} + + ViterbiR2O4 mVCoder; ///< nearly all GSM channels use the same convolutional code + + + public: + + /** + Constructor for an L1Decoder. + @param wTN The timeslot to decode on. + @param wMapping Demux parameters, MUST BE PERSISTENT. + @param wParent The containing L1FEC, for sibling access. + */ + L1Decoder(unsigned wTN, const TDMAMapping& wMapping, L1FEC* wParent) + :mUpstream(NULL), + mT3101(T3101ms),mT3109(T3109ms),mT3111(T3111ms), + mActive(false), + mRunning(false), + mFER(0.0F), + mTN(wTN), + mMapping(wMapping),mParent(wParent) + { + // Start T3101 so that the channel will + // become recyclable soon. + mT3101.set(); + } + + + virtual ~L1Decoder() { } + + + /** + Clear the decoder for a new transaction. + Start T3101, stop the others. + */ + virtual void open(); + + /** + Call this at the end of a tranaction. + Stop timers. If !hardRelase, start T3111. + */ + virtual void close(bool hardRelease=false); + + /** + Returns true if the channel is in use for a transaction. + Returns true if T3111 is not active. + */ + bool active() const; + + /** Return true if any timer is expired. */ + bool recyclable() const; + + /** Connect the upstream SAPMux and L2. */ + void upstream(SAPMux * wUpstream) + { + assert(mUpstream==NULL); // Only call this once. + mUpstream=wUpstream; + } + + /** Total frame error rate since last open(). */ + float FER() const { return mFER; } + + /** Return the multiplexing parameters. */ + const TDMAMapping& mapping() const { return mMapping; } + + /** Accept an RxBurst and process it into the deinterleaver. */ + virtual void writeLowSide(const RxBurst&) = 0; + + /** Return the decoder timeslot number. */ + unsigned TN() const { return mTN; } + + + protected: + + virtual L1FEC* parent() { return mParent; } + + /** Return pointer to paired L1 encoder, if any. */ + virtual L1Encoder* sibling(); + + /** Return pointer to paired L1 encoder, if any. */ + virtual const L1Encoder* sibling() const; + + /** Mark the decoder as started. */ + virtual void start() { mRunning=true; } + + void countGoodFrame(); + + void countBadFrame(); +}; + + + + + +/** + The L1FEC encapsulates an encoder and decoder. +*/ +class L1FEC { + + protected: + + L1Encoder* mEncoder; + L1Decoder* mDecoder; + + public: + + /** + The L1FEC constructor is over-ridden for different channel types. + But the default has no encoder or decoder. + */ + L1FEC():mEncoder(NULL),mDecoder(NULL) {} + + /** This is no-op because these channels should not be destroyed. */ + virtual ~L1FEC() {}; + + /** Send in an RxBurst for decoding. */ + void writeLowSide(const RxBurst& burst) + { assert(mDecoder); mDecoder->writeLowSide(burst); } + + /** Send in an L2Frame for encoding and transmission. */ + void writeHighSide(const L2Frame& frame) + { assert(mEncoder); mEncoder->writeHighSide(frame); } + + /** Attach L1 to a downstream radio. */ + void downstream(ARFCNManager*); + + /** Attach L1 to an upstream SAPI mux and L2. */ + void upstream(SAPMux* mux) + { if (mDecoder) mDecoder->upstream(mux); } + + /**@name Ganged actions. */ + //@{ + void open(); + void close(); + //@} + + + /**@name Pass-through actions. */ + //@{ + TypeAndOffset typeAndOffset() const + { assert(mEncoder); return mEncoder->typeAndOffset(); } + + unsigned TN() const + { assert(mEncoder); return mEncoder->TN(); } + + unsigned TSC() const + { assert(mEncoder); return mEncoder->TSC(); } + + unsigned ARFCN() const + { assert(mEncoder); return mEncoder->ARFCN(); } + + float FER() const + { assert(mDecoder); return mDecoder->FER(); } + + bool recyclable() const + { assert(mDecoder); return mDecoder->recyclable(); } + + bool active() const; + + const TDMAMapping& txMapping() const + { assert(mEncoder); return mEncoder->mapping(); } + + const TDMAMapping& rcvMapping() const + { assert(mDecoder); return mDecoder->mapping(); } + + const char* descriptiveString() const + { assert(mEncoder); return mEncoder->descriptiveString(); } + + //@} + + + L1Decoder* decoder() { return mDecoder; } + L1Encoder* encoder() { return mEncoder; } +}; + + +/** + The TestL1FEC does loopbacks at each end. +*/ +class TestL1FEC : public L1FEC { + + private: + + SAPMux * mUpstream; + ARFCNManager* mDownstream; + + public: + + void writeLowSide(const RxBurst&); + void writeHighSide(const L2Frame&); + + void downstream(ARFCNManager *wDownstream) { mDownstream=wDownstream; } + void upstream(SAPMux * wUpstream){ mUpstream=wUpstream;} +}; + + +/** L1 decoder for Random Access (RACH). */ +class RACHL1Decoder : public L1Decoder { + + private: + + /**@name FEC state. */ + //@{ + Parity mParity; ///< block coder + BitVector mU; ///< u[], as per GSM 05.03 2.2 + BitVector mD; ///< d[], as per GSM 05.03 2.2 + //@} + + // The RACH channel uses an internal FIFO, + // because the channel allocation process might block + // and we don't want to block the radio receive thread. + RxBurstFIFO mQ; ///< a FIFO to decouple the rx thread + + Thread mServiceThread; ///< a thread to process the FIFO + + + public: + + RACHL1Decoder(const TDMAMapping &wMapping, + L1FEC *wParent) + :L1Decoder(0,wMapping,wParent), + mParity(0x06f,6,8),mU(18),mD(mU.head(8)) + { } + + /** Start the service thread. */ + void start(); + + /** Decode the burst and call the channel allocator. */ + void writeLowSide(const RxBurst&); + + /** A loop to watch the FIFO. */ + void serviceLoop(); + + /** A "C" calling interface for pthreads. */ + friend void *RACHL1DecoderServiceLoopAdapter(RACHL1Decoder*); +}; + +void *RACHL1DecoderServiceLoopAdapter(RACHL1Decoder*); + + + +/** Abstract L1 decoder for most control channels -- GSM 05.03 4.1 */ +class XCCHL1Decoder : public L1Decoder { + + protected: + + /**@name FEC state. */ + //@{ + Parity mBlockCoder; + SoftVector mI[4]; ///< i[][], as per GSM 05.03 2.2 + SoftVector mC; ///< c[], as per GSM 05.03 2.2 + BitVector mU; ///< u[], as per GSM 05.03 2.2 + BitVector mP; ///< p[], as per GSM 05.03 2.2 + BitVector mDP; ///< d[]:p[] (data & parity) + BitVector mD; ///< d[], as per GSM 05.03 2.2 + //@} + + unsigned mRSSIHistory[4]; + + public: + + XCCHL1Decoder(unsigned wTN, const TDMAMapping& wMapping, + L1FEC *wParent); + + protected: + + /** Offset to the start of the L2 header. */ + virtual unsigned headerOffset() const { return 0; } + + /** The channel type. */ + virtual ChannelType channelType() const = 0; + + /** Accept a timeslot for processing and drive data up the chain. */ + virtual void writeLowSide(const RxBurst&); + + /** + Accept a new timeslot for processing and save it in i[]. + This virtual method works for all block-interleaved channels (xCCHs). + A different method is needed for diagonally-interleaved channels (TCHs). + @return true if a new frame is ready for deinterleaving. + */ + virtual bool processBurst(const RxBurst&); + + /** + Deinterleave the i[] to c[]. + This virtual method works for all block-interleaved channels (xCCHs). + A different method is needed for diagonally-interleaved channels (TCHs). + */ + virtual void deinterleave(); + + /** + Decode the frame and send it upstream. + Includes LSB-MSB reversal within each octet. + @return True if frame passed parity check. + */ + bool decode(); + + /** Finish off a properly-received L2Frame in mU and send it up to L2. */ + virtual void handleGoodFrame(); +}; + + + +/** L1 decoder for the SDCCH. */ +class SDCCHL1Decoder : public XCCHL1Decoder { + + public: + + SDCCHL1Decoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent) + :XCCHL1Decoder(wTN,wMapping,wParent) + { } + + ChannelType channelType() const { return SDCCHType; } + +}; + + + + +/** + L1 decoder for the SACCH. + Like any other control channel, but with hooks for power/timing control. +*/ +class SACCHL1Decoder : public XCCHL1Decoder { + + private: + + SACCHL1FEC *mSACCHParent; + unsigned mRSSICounter; + volatile float mRSSI[4]; ///< RSSI history , dB wrt full scale + volatile float mTimingError[4]; ///< Timing error histoty in symbol + volatile int mActualMSPower; ///< actual MS tx power in dBm + volatile int mActualMSTiming; ///< actual MS tx timing advance in symbols + + public: + + SACCHL1Decoder( + unsigned wTN, + const TDMAMapping& wMapping, + SACCHL1FEC *wParent) + :XCCHL1Decoder(wTN,wMapping,(L1FEC*)wParent), + mSACCHParent(wParent), + mRSSICounter(0) + { + for (int i=0; i<4; i++) mRSSI[i]=0.0F; + } + + ChannelType channelType() const { return SACCHType; } + + int actualMSPower() const { return mActualMSPower; } + int actualMSTiming() const { return mActualMSTiming; } + + /** Override open() to set physical parameters with reasonable defaults. */ + void open(); + + /** + Override processBurst to catch the physical parameters. + */ + bool processBurst(const RxBurst&); + + /** Set pyshical parameters for initialization. */ + void setPhy(float wRSSI, float wTimingError); + + void setPhy(const SACCHL1Decoder& other); + + /** RSSI of most recent received burst, in dB wrt full scale. */ + float RSSI() const; + + /** + Timing error of most recent received burst, symbol units. + Positive is late; negative is early. + */ + float timingError() const; + + + protected: + + SACCHL1FEC *SACCHParent() { return mSACCHParent; } + + SACCHL1Encoder* SACCHSibling(); + + /** + This is a wrapper on handleGoodFrame that processes the physical header. + */ + void handleGoodFrame(); + + unsigned headerOffset() const { return 16; } + +}; + + + + +/** L1 encoder used for many control channels -- mostly from GSM 05.03 4.1 */ +class XCCHL1Encoder : public L1Encoder { + + protected: + + /**@name FEC signal processing state. */ + //@{ + Parity mBlockCoder; ///< block coder for this channel + BitVector mI[4]; ///< i[][], as per GSM 05.03 2.2 + BitVector mC; ///< c[], as per GSM 05.03 2.2 + BitVector mU; ///< u[], as per GSM 05.03 2.2 + BitVector mD; ///< d[], as per GSM 05.03 2.2 + BitVector mP; ///< p[], as per GSM 05.03 2.2 + //@} + + public: + + XCCHL1Encoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC* wParent); + + protected: + + /** Process pending incoming messages. */ + virtual void writeHighSide(const L2Frame&); + + /** Offset from the start of mU to the start of the L2 frame. */ + virtual unsigned headerOffset() const { return 0; } + + /** Send a single L2 frame. */ + virtual void sendFrame(const L2Frame&); + + /** + Encode u[] to c[]. + Includes LSB-MSB reversal within each octet. + */ + void encode(); + + /** + Interleave c[] to i[]. + GSM 05.03 4.1.4. + */ + virtual void interleave(); + + /** + Format i[] into timeslots and send them down for transmission. + Set stealing flags assuming a control channel. + Also updates mWriteTime. + GSM 05.03 4.1.5, 05.02 5.2.3. + */ + virtual void transmit(); + +}; + + + +/** L1 encoder used for full rate TCH and FACCH -- mostry from GSM 05.03 3.1 and 4.2 */ +class TCHFACCHL1Encoder : public XCCHL1Encoder { + +private: + + bool mPreviousFACCH; ///< A copy of the previous stealing flag state. + size_t mOffset; ///< Current deinterleaving offset. + + BitVector mI[8]; ///< deinterleaving history, 8 blocks instead of 4 + BitVector mTCHU; ///< u[], but for traffic + BitVector mTCHD; ///< d[], but for traffic + BitVector mClass1_c; ///< the class 1 part of taffic c[] + BitVector mClass1A_d; ///< the class 1A part of taffic d[] + BitVector mClass2_d; ///< the class 2 part of d[] + + BitVector mFillerC; ///< copy of previous c[] for filling dead time + + Parity mTCHParity; + + VocoderFrameFIFO mSpeechQ; ///< input queue for speech frames + + L2FrameFIFO mL2Q; ///< input queue for L2 FACCH frames + + Thread mEncoderThread; + friend void TCHFACCHL1EncoderRoutine( TCHFACCHL1Encoder * encoder ); + +public: + + TCHFACCHL1Encoder(unsigned wTN, + const TDMAMapping& wMapping, + L1FEC* wParent); + + /** Enqueue a traffic frame for transmission. */ + void sendTCH(const unsigned char *frame) + { mSpeechQ.write(new VocoderFrame(frame)); } + + /** Extend open() to set up semaphores. */ + void open(); + +protected: + + /** Interleave c[] to i[]. GSM 05.03 4.1.4. */ + virtual void interleave(int blockOffset); + + /** Encode a FACCH and enqueue it for transmission. */ + void sendFrame(const L2Frame&); + + /** + dispatch called in a while loop. + process reading transcoder and fifo to + interleave and send. + */ + void dispatch(); + + /** Will start the dispatch thread. */ + void start(); + + /** Encode a vocoder frame into c[]. */ + void encodeTCH(const VocoderFrame& vFrame); + +}; + + +/** The C adapter for pthreads. */ +void TCHFACCHL1EncoderRoutine( TCHFACCHL1Encoder * encoder ); + +/** L1 decoder used for full rate TCH and FACCH -- mostly from GSM 05.03 3.1 and 4.2 */ +class TCHFACCHL1Decoder : public XCCHL1Decoder { + + protected: + + SoftVector mI[8]; ///< deinterleaving history, 8 blocks instead of 4 + BitVector mTCHU; ///< u[] (uncoded) in the spec + BitVector mTCHD; ///< d[] (data) in the spec + SoftVector mClass1_c; ///< the class 1 part of c[] + BitVector mClass1A_d; ///< the class 1A part of d[] + SoftVector mClass2_c; ///< the class 2 part of c[] + + VocoderFrame mVFrame; ///< unpacking buffer for vocoder frame + unsigned char mPrevGoodFrame[33]; ///< previous good frame. + + Parity mTCHParity; + + InterthreadQueue mSpeechQ; ///< output queue for speech frames + + + public: + + TCHFACCHL1Decoder(unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent); + + ChannelType channelType() const { return FACCHType; } + + + /** TCH/FACCH has a special-case writeLowSide. */ + void writeLowSide(const RxBurst& inBurst); + + /** + Unlike other DCCHs, TCH/FACCH process burst calls + deinterleave, decode, handleGoodFrame. + */ + bool processBurst( const RxBurst& ); + + /** Deinterleave i[] to c[]. */ + void deinterleave(int blockOffset ); + + void replaceFACCH( int blockOffset ); + + /** + Decode a traffic frame from TCHI[] and enqueue it. + Return true if there's a good frame. + */ + bool decodeTCH(bool stolen); + + /** + Receive a traffic frame. + Non-blocking. Returns NULL if queue is dry. + Caller is responsible for deleting the returned array. + */ + unsigned char *recvTCH() { return mSpeechQ.read(0); } + + /** Return count of internally-queued traffic frames. */ + unsigned queueSize() const { return mSpeechQ.size(); } + + /** Return true if the uplink is dead. */ + bool uplinkLost() const; +}; + + + +/** + This is base class for output-only encoders. + These all have very thin L2/L3 and are driven by a clock instead of a FIFO. +*/ +class GeneratorL1Encoder : public L1Encoder { + + private: + + Thread mSendThread; + + public: + + GeneratorL1Encoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC* wParent) + :L1Encoder(wTN,wMapping,wParent) + { } + + void start(); + + protected: + + /** The generate method actually produces output bursts. */ + virtual void generate() =0; + + /** The core service loop calls generate repeatedly. */ + void serviceLoop(); + + /** Provide a C interface for pthreads. */ + friend void *GeneratorL1EncoderServiceLoopAdapter(GeneratorL1Encoder*); + +}; + + +void *GeneratorL1EncoderServiceLoopAdapter(GeneratorL1Encoder*); + + +/** + The L1 encoder for the sync channel (SCH). + The SCH sends out an encoding of the current BTS clock. + GSM 05.03 4.7. +*/ +class SCHL1Encoder : public GeneratorL1Encoder { + + private: + + Parity mBlockCoder; ///< block parity coder + BitVector mU; ///< u[], as per GSM 05.03 2.2 + BitVector mE; ///< e[], as per GSM 05.03 2.2 + BitVector mD; ///< d[], as per GSM 05.03 2.2 + BitVector mP; ///< p[], as per GSM 05.03 2.2 + BitVector mE1; ///< first half of e[] + BitVector mE2; ///< second half of e[] + + public: + + SCHL1Encoder(L1FEC* wParent); + + protected: + + void generate(); + +}; + + + + +/** + The L1 encoder for the frequency correction channel (FCCH). + The FCCH just sends bursts of zeroes at set points in the TDMA pattern. + See GSM 05.02 5.2.4. +*/ +class FCCHL1Encoder : public GeneratorL1Encoder { + + public: + + FCCHL1Encoder(L1FEC *wParent); + + protected: + + void generate(); +}; + + + + +/** + L1 encoder for repeating non-dedicated control channels (BCCH). + This have generator-like drive loops, but xCCH-like FEC. +*/ +class NDCCHL1Encoder : public XCCHL1Encoder { + + protected: + + Thread mSendThread; + + public: + + + NDCCHL1Encoder( + unsigned wTN, + const TDMAMapping& wMapping, + L1FEC *wParent) + :XCCHL1Encoder(wTN, wMapping, wParent) + { } + + void start(); + + protected: + + virtual void generate() =0; + + /** The core service loop. */ + void serviceLoop(); + + friend void *NDCCHL1EncoderServiceLoopAdapter(NDCCHL1Encoder*); +}; + +void *NDCCHL1EncoderServiceLoopAdapter(NDCCHL1Encoder*); + + + +/** + L1 encoder for the BCCH has generator filling behavior but xCCH-like FEC. +*/ +class BCCHL1Encoder : public NDCCHL1Encoder { + + public: + + BCCHL1Encoder(L1FEC *wParent) + :NDCCHL1Encoder(0,gBCCHMapping,wParent) + {} + + private: + + void generate(); +}; + + + +/** + L1 decoder for the SACCH. + Like any other control channel, but with hooks for power/timing control. + The SI5 and SI5 generation will be handled in higher layers. +*/ +class SACCHL1Encoder : public XCCHL1Encoder { + + private: + + SACCHL1FEC *mSACCHParent; + + /**@name Physical header, GSM 04.04 6, 7.1, 7.2 */ + //@{ + volatile float mOrderedMSPower; ///< ordered MS tx power level, dBm + volatile float mOrderedMSTiming; ///< ordered MS timing advance in symbols + //@} + + public: + + SACCHL1Encoder(unsigned wTN, const TDMAMapping& wMapping, SACCHL1FEC *wParent); + + void orderedMSPower(int power) { mOrderedMSPower = power; } + void orderedMSTiming(int timing) { mOrderedMSTiming = timing; } + + void setPhy(const SACCHL1Encoder&); + void setPhy(float RSSI, float timingError); + + /** Override open() to initialize power and timing. */ + void open(); + + //bool active() const { return true; } + + protected: + + SACCHL1FEC *SACCHParent() { return mSACCHParent; } + + SACCHL1Decoder *SACCHSibling(); + + unsigned headerOffset() const { return 16; } + + /** A warpper to send an L2 frame with a physical header. */ + virtual void sendFrame(const L2Frame&); + +}; + + + +typedef XCCHL1Encoder SDCCHL1Encoder; + + +/** The Common Control Channel (CCCH). Carries the AGCH, NCH, PCH. */ +class CCCHL1Encoder : public XCCHL1Encoder { + + public: + + CCCHL1Encoder(const TDMAMapping& wMapping, + L1FEC* wParent) + :XCCHL1Encoder(0,wMapping,wParent) + {} + +}; + + + + + +class SDCCHL1FEC : public L1FEC { + + public: + + SDCCHL1FEC( + unsigned wTN, + const MappingPair& wMapping) + :L1FEC() + { + mEncoder = new SDCCHL1Encoder(wTN,wMapping.downlink(),this); + mDecoder = new SDCCHL1Decoder(wTN,wMapping.uplink(),this); + } +}; + + + + + + + + + + +class TCHFACCHL1FEC : public L1FEC { + +protected: + + TCHFACCHL1Decoder * mTCHDecoder; + TCHFACCHL1Encoder * mTCHEncoder; + + +public: + + + TCHFACCHL1FEC( + unsigned wTN, + const MappingPair& wMapping) + :L1FEC() + { + mTCHEncoder = new TCHFACCHL1Encoder(wTN, wMapping.downlink(), this ); + mEncoder = mTCHEncoder; + mTCHDecoder = new TCHFACCHL1Decoder(wTN, wMapping.uplink(), this ); + mDecoder = mTCHDecoder; + } + + /** Send a traffic frame. */ + void sendTCH(const unsigned char * frame) + { assert(mTCHEncoder); mTCHEncoder->sendTCH(frame); } + + /** + Receive a traffic frame. + Returns a pointer that must be deleted by calls. + Non-blocking. + Returns NULL is no data available. + */ + unsigned char* recvTCH() + { assert(mTCHDecoder); return mTCHDecoder->recvTCH(); } + + unsigned queueSize() const + { assert(mTCHDecoder); return mTCHDecoder->queueSize(); } + + bool radioFailure() const + { assert(mTCHDecoder); return mTCHDecoder->uplinkLost(); } +}; + + + +class SACCHL1FEC : public L1FEC { + + private: + + SACCHL1Decoder *mSACCHDecoder; + SACCHL1Encoder *mSACCHEncoder; + + public: + + SACCHL1FEC( + unsigned wTN, + const MappingPair& wMapping) + :L1FEC() + { + mSACCHEncoder = new SACCHL1Encoder(wTN,wMapping.downlink(),this); + mEncoder = mSACCHEncoder; + mSACCHDecoder = new SACCHL1Decoder(wTN,wMapping.uplink(),this); + mDecoder = mSACCHDecoder; + } + + SACCHL1Decoder *decoder() { return mSACCHDecoder; } + SACCHL1Encoder *encoder() { return mSACCHEncoder; } + + /**@name Physical parameter access. */ + //@{ + float RSSI() const { return mSACCHDecoder->RSSI(); } + float timingError() const { return mSACCHDecoder->timingError(); } + int actualMSPower() const { return mSACCHDecoder->actualMSPower(); } + int actualMSTiming() const { return mSACCHDecoder->actualMSTiming(); } + void setPhy(const SACCHL1FEC&); + virtual void setPhy(float RSSI, float timingError); + //@} +}; + + + + + + + + +class LoopbackL1FEC : public L1FEC { + + public: + + LoopbackL1FEC(unsigned wTN) + :L1FEC() + { + mEncoder = new XCCHL1Encoder(wTN,gLoopbackTestFullMapping,this); + mDecoder = new SDCCHL1Decoder(wTN,gLoopbackTestFullMapping,this); + } +}; + + + +/** The common control channel (CCCH). */ +class CCCHL1FEC : public L1FEC { + + public: + + CCCHL1FEC(const TDMAMapping& wMapping) + :L1FEC() + { + mEncoder = new CCCHL1Encoder(wMapping,this); + } +}; + + + + +/** + A subclass for channels that have L2 and L3 so thin + that they are handled as special cases. + These are all broadcast and unicast channels. +*/ +class NDCCHL1FEC : public L1FEC { + + public: + + NDCCHL1FEC():L1FEC() {} + + void upstream(SAPMux*){ assert(0);} +}; + + +class FCCHL1FEC : public NDCCHL1FEC { + + public: + + FCCHL1FEC():NDCCHL1FEC() + { + mEncoder = new FCCHL1Encoder(this); + } + +}; + + +class RACHL1FEC : public NDCCHL1FEC { + + public: + + RACHL1FEC(const TDMAMapping& wMapping) + :NDCCHL1FEC() + { + mDecoder = new RACHL1Decoder(wMapping,this); + } +}; + + +class SCHL1FEC : public NDCCHL1FEC { + + public: + + SCHL1FEC():NDCCHL1FEC() + { + mEncoder = new SCHL1Encoder(this); + } +}; + + +class BCCHL1FEC : public NDCCHL1FEC { + + public: + + BCCHL1FEC():NDCCHL1FEC() + { + mEncoder = new BCCHL1Encoder(this); + } +}; + + + + + +}; // namespace GSM + + + + + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSML2LAPDm.cpp b/GSM/GSML2LAPDm.cpp new file mode 100644 index 0000000..b2524a2 --- /dev/null +++ b/GSM/GSML2LAPDm.cpp @@ -0,0 +1,997 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +/* +Many elements follow Daniele Orlandi's vISDN/Q.921 +implementation, although no code is copied directly. +*/ + + + +/* + As a general rule, the caller need not hold + mLock when sending U frames but should hold the + lock when transmitting S or I frames. + + This implementation is for use on the BTS side, + however, some MS functions are included for unit- + testing. For actual use in a BTS, these will need + to be compelted. +*/ + +#include "GSML2LAPDm.h" +#include "GSMSAPMux.h" +#include + +using namespace std; +using namespace GSM; + +//#define NDEBUG + + +ostream& GSM::operator<<(ostream& os, L2LAPDm::LAPDState state) +{ + switch (state) { + case L2LAPDm::LinkReleased: os << "LinkReleased"; break; + case L2LAPDm::AwaitingEstablish: os << "AwaitingEstablish"; break; + case L2LAPDm::AwaitingRelease: os << "AwaitingRelease"; break; + case L2LAPDm::LinkEstablished: os << "LinkEstablished"; break; + case L2LAPDm::ContentionResolution: os << "ContentionResolution"; break; + default: os << "?" << (int)state << "?"; + } + return os; +} + + + + +void CCCHL2::writeHighSide(const GSM::L3Frame& l3) +{ + OBJLOG(DEBUG) <<"CCCHL2::writeHighSide " << l3; + assert(mDownstream); + assert(l3.primitive()==UNIT_DATA); + L2Header header(L2Length(l3.L2Length())); + mDownstream->writeHighSide(L2Frame(header,l3)); +} + + + +L2LAPDm::L2LAPDm(unsigned wC, unsigned wSAPI) + :mRunning(false), + mC(wC),mR(1-wC),mSAPI(wSAPI), + mMaster(NULL), + mT200(T200ms), + mIdleFrame(DATA) +{ + // sanity checks + assert(mC<2); + assert(mSAPI<4); + + clearState(); + + // Set the idle frame as per GSM 04.06 5.4.2.3. + mIdleFrame.fillField(8*0,(mC<<1)|1,8); // address + mIdleFrame.fillField(8*1,3,8); // control + mIdleFrame.fillField(8*2,1,8); // length +} + + +void L2LAPDm::writeL1(const L2Frame& frame) +{ + OBJLOG(DEBUG) <<"L2LAPDm::writeL1 " << frame; + //assert(mDownstream); + if (!mDownstream) return; + ScopedLock lock(mLock); + mDownstream->writeHighSide(frame); +} + + +void L2LAPDm::writeL1NoAck(const L2Frame& frame) +{ + // Caller need not hold mLock. + OBJLOG(DEBUG) <<"L2LAPDm::writeL1NoAck " << frame; + writeL1(frame); +} + + +void L2LAPDm::writeL1Ack(const L2Frame& frame) +{ + // Caller should hold mLock. + // GSM 04.06 5.4.4.2 + OBJLOG(DEBUG) <<"L2LAPDm::writeL1Ack " << frame; + frame.copyTo(mSentFrame); + mSentFrame.primitive(frame.primitive()); + writeL1(frame); + mT200.set(T200()); +} + + + +void L2LAPDm::waitForAck() +{ + // Block until any pending ack is received. + // Caller should hold mLock. + OBJLOG(DEBUG) <<"L2LAPDm::waitForAck state=" << mState << " VS=" << mVS << " VA=" << mVA; + while (true) { + if (mState==LinkReleased) break; + if ((mState==ContentionResolution) && (mVS==mVA)) break; + if ((mState==LinkEstablished) && (mVS==mVA)) break; + // HACK -- We should not need a timeout here. + mAckSignal.wait(mLock,N200()*T200ms); + OBJLOG(DEBUG) <<"L2LAPDm::waitForAck state=" << mState << " VS=" << mVS << " VA=" << mVA; + } +} + + + +void L2LAPDm::releaseLink(Primitive releaseType) +{ + OBJLOG(DEBUG) << "mState=" << mState; + // Caller should hold mLock. + mState = LinkReleased; + mEstablishmentInProgress = false; + mAckSignal.signal(); + if (mSAPI==0) writeL1(releaseType); + mL3Out.write(new L3Frame(releaseType)); +} + + +void L2LAPDm::clearCounters() +{ + OBJLOG(DEBUG) << "mState=" << mState; + // Caller should hold mLock. + // This is called upon establishment or re-establihment of ABM. + mT200.reset(); + mVS = 0; + mVA = 0; + mVR = 0; + mRC = 0; + mIdleCount=0; + mRecvBuffer.clear(); + discardIQueue(); +} + + +void L2LAPDm::clearState(Primitive releaseType) +{ + OBJLOG(DEBUG) << "mState=" << mState; + // Caller should hold mLock. + // Reset the state machine. + clearCounters(); + releaseLink(releaseType); +} + + + +void L2LAPDm::processAck(unsigned NR) +{ + // GSM 04.06 5.5.3, 5.7.2. + // Q.921 5.6.3.2, 5.8.2. + // Equivalent to vISDN datalink.c:lapd_ack_frames, + // but much simpler for LAPDm. + // Caller should hold mLock. + OBJLOG(DEBUG) << "NR=" << NR << " VA=" << mVA << " VS=" << mVS; + mVA=NR; + if (mVA==mVS) { + mRC=0; + mT200.reset(); + } + mAckSignal.signal(); +} + + + +void L2LAPDm::bufferIFrameData(const L2Frame& frame) +{ + // Concatenate I-frames to form the L3 frame. + /* + GSM 04.06 5.5.2 states: + When a data link layer entity is not in an own receiver busy condition + and receives a valid I frame whose send sequence number is equal to the + current receive state variable V(R), the data link layer entity shall: + - if the M bit is set to "0", concatenate it with previously + received frames with the M bit set to "1", if any, and pass the complete + layer 3 message unit to the layer 3 entity using the primitive + DL-DATA-INDICATION; + - if the M bit is set to "1", store the information field of the frame and + concatenate it with previously received frames with the M bit set to "1", + if any (Note: no information is passed to the layer 3 entity); + */ + + OBJLOG(DEBUG) << frame; + if (!frame.M()) { + // The last or only frame. + if (mRecvBuffer.size()==0) { + // The only frame -- just send it up. + OBJLOG(DEBUG) << "single frame message"; + mL3Out.write(new L3Frame(frame)); + return; + } + // The last of several -- concat and send it up. + OBJLOG(DEBUG) << "last frame of message"; + mL3Out.write(new L3Frame(mRecvBuffer,frame.L3Part())); + mRecvBuffer.clear(); + return; + } + + // One segment of many -- concat. + // This is inefficient but simple. + mRecvBuffer = L3Frame(mRecvBuffer,frame.L3Part()); + OBJLOG(DEBUG) <<"buffering recvBuffer=" << mRecvBuffer; +} + + +void L2LAPDm::unexpectedMessage() +{ + OBJLOG(NOTICE) << "mState=" << mState; + // vISDN datalink.c:unexpeced_message + // For LAPD, vISDN just keeps trying. + // For LAPDm, just terminate the link. + // Caller should hold mLock. + abnormalRelease(); +} + + +void L2LAPDm::abnormalRelease() +{ + // Caller should hold mLock. + OBJLOG(INFO) << "state=" << mState; + // GSM 04.06 5.6.4. + // We're cutting a corner here that we'll + // clean up when L3 is more stable. + mL3Out.write(new L3Frame(ERROR)); + sendUFrameDM(true); + writeL1(ERROR); + clearState(); +} + + + +void L2LAPDm::retransmissionProcedure() +{ + // Caller should hold mLock. + // vISDN datalink.c:lapd_invoke_retransmission_procedure + // GSM 04.08 5.5.7, bullet point (a) + OBJLOG(DEBUG) << "VS=" << mVS << " VA=" << mVA << " RC=" << mRC; + mRC++; + writeL1(mSentFrame); + mT200.set(T200()); + mAckSignal.signal(); +} + + + + +void L2LAPDm::open() +{ + OBJLOG(DEBUG); + { + ScopedLock lock(mLock); + if (!mRunning) { + // We can't call this from the constructor, + // since N201 may not be defined yet. + mMaxIPayloadBits = 8*N201(L2Control::IFormat); + mRunning = true; + mUpstreamThread.start((void *(*)(void*))LAPDmServiceLoopAdapter,this); + } + mL3Out.clear(); + mL1In.clear(); + clearCounters(); + mState = LinkReleased; + mAckSignal.signal(); + } + + if (mSAPI==0) sendIdle(); +} + + +void *GSM::LAPDmServiceLoopAdapter(L2LAPDm *lapdm) +{ + lapdm->serviceLoop(); + return NULL; +} + + + +void L2LAPDm::writeHighSide(const L3Frame& frame) +{ + OBJLOG(DEBUG) << frame; + switch (frame.primitive()) { + case UNIT_DATA: + // Send the data in a single U-Frame. + sendUFrameUI(frame); + break; + case DATA: + // Send the data as a series of I-Frames. + mLock.lock(); + sendMultiframeData(frame); + mLock.unlock(); + break; + case ESTABLISH: + // GSM 04.06 5.4.1.2 + // vISDN datalink.c:lapd_establish_datalink_procedure + // The BTS side should never call this in SAP0. + // See note in GSM 04.06 5.4.1.1. + assert(mSAPI!=0 || mC==0); + if (mState==LinkEstablished) break; + mLock.lock(); + clearCounters(); + mState=AwaitingEstablish; + mLock.unlock(); + sendUFrameSABM(); + break; + case RELEASE: + // GSM 04.06 5.4.4.2 + // vISDN datalink.c:lapd_dl_release_request + if (mState==LinkReleased) break; + mLock.lock(); + if (mState==LinkEstablished) waitForAck(); + clearCounters(); + mEstablishmentInProgress=false; + mState=AwaitingRelease; + mT200.set(T200()); // HACK? + // Send DISC and wait for UA. + // Don't return until released. + sendUFrameDISC(); + waitForAck(); + mLock.unlock(); + break; + case ERROR: + // Forced release. + mLock.lock(); + abnormalRelease(); + mLock.unlock(); + break; + case HARDRELEASE: + mLock.lock(); + clearState(HARDRELEASE); + mLock.unlock(); + break; + default: + OBJLOG(ERR) << "unhandled primitive in L3->L2 " << frame; + assert(0); + } +} + + + + + +void L2LAPDm::writeLowSide(const L2Frame& frame) +{ + OBJLOG(DEBUG) << frame; + mL1In.write(new L2Frame(frame)); +} + + + +void L2LAPDm::serviceLoop() +{ + mLock.lock(); + while (mRunning) { + // Block for up to T200 expiration, then check T200. + // Allow other threads to modify state while blocked. + // Add 2 ms to prevent race condition due to roundoff error. + unsigned timeout = mT200.remaining() + 2; + // If SAP0 is released, other SAPs need to release also. + if (mMaster) { + if (mMaster->mState==LinkReleased) mState=LinkReleased; + } + if (!mT200.active()) { + if (mState==LinkReleased) timeout=3600000; + else timeout = T200(); + } + OBJLOG(DEBUG) << "read blocking up to " << timeout << " ms, state=" << mState; + mLock.unlock(); + // FIXME -- If the link is released, there should be no timeout at all. + L2Frame* frame = mL1In.read(timeout); + mLock.lock(); + if (frame!=NULL) { + OBJLOG(DEBUG) << "state=" << mState << " received " << *frame; + receiveFrame(*frame); + delete frame; + } + if (mT200.expired()) T200Expiration(); + } + mLock.unlock(); +} + + + + +void L2LAPDm::T200Expiration() +{ + // Caller should hold mLock. + // vISDN datalink.c:timer_T200. + // GSM 04.06 5.4.1.3, 5.4.4.3, 5.5.7, 5.7.2. + OBJLOG(INFO) << "state=" << mState << " RC=" << mRC; + mT200.reset(); + switch (mState) { + case AwaitingRelease: + releaseLink(); + break; + case ContentionResolution: + case LinkEstablished: + case AwaitingEstablish: + if (mRC>N200()) abnormalRelease(); + else retransmissionProcedure(); + break; + default: + break; + } +} + + + + + + + + + +void L2LAPDm::receiveFrame(const GSM::L2Frame& frame) +{ + OBJLOG(DEBUG) << frame; + + // Caller should hold mLock. + + // Accept and process an incoming frame on the L1->L2 interface. + // See vISDN datalink.c:lapd_dlc_recv for another example. + + // Since LAPDm is a lot simpler than LAPD, there are a lot fewer primitives. + + // FIXME -- This is a HACK to fix channels that get stuck in wierd states. + // But if channels are stuck in wierd states, it means there's a bug somehwere. +/* + if (stuckChannel(frame)) { + OBJLOG(ERR) << "detected stuck channel, releasing in L2"; + abnormalRelease(); + return; + } +*/ + + switch (frame.primitive()) { + case ESTABLISH: + // This primitive means the first L2 frame is on the way. + clearCounters(); + break; + case DATA: + // Dispatch on the frame type. + switch (frame.controlFormat()) { + case L2Control::IFormat: receiveIFrame(frame); break; + case L2Control::SFormat: receiveSFrame(frame); break; + case L2Control::UFormat: receiveUFrame(frame); break; + } + break; + default: + OBJLOG(ERR) << "unhandled primitive in L1->L2 " << frame; + assert(0); + } +} + + +void L2LAPDm::receiveUFrame(const L2Frame& frame) +{ + // Also see vISDN datalink.c:lapd_socket_handle_uframe + OBJLOG(DEBUG) << frame; + switch (frame.UFrameType()) { + case L2Control::SABMFrame: receiveUFrameSABM(frame); break; + case L2Control::DMFrame: receiveUFrameDM(frame); break; + case L2Control::UIFrame: receiveUFrameUI(frame); break; + case L2Control::DISCFrame: receiveUFrameDISC(frame); break; + case L2Control::UAFrame: receiveUFrameUA(frame); break; + default: + OBJLOG(NOTICE) << " could not parse U-Bits " << frame; + unexpectedMessage(); + return; + } +} + + + +void L2LAPDm::receiveUFrameSABM(const L2Frame& frame) +{ + // Caller should hold mLock. + // Process the incoming SABM command. + // GSM 04.06 3.8.2, 5.4.1 + // Q.921 5.5.1.2. + // Also borrows from vISDN datalink.c:lapd_socket_handle_uframe_sabm. + OBJLOG(INFO) << "state=" << mState << " " << frame; + // Ignore frame if P!=1. + // See GSM 04.06 5.4.1.2. + if (!frame.PF()) return; + // Dispatch according to current state. + // BTW, LAPDm can always enter multiframe mode when requested, + // so that's another big simplification over ISDN/LAPD. + switch (mState) { + case LinkReleased: + // GSM 04.06 5.4.5, 5.4.1.2, 5.4.1.4 + clearCounters(); + mEstablishmentInProgress = true; + // Tell L3 what happened. + mL3Out.write(new L3Frame(ESTABLISH)); + if (frame.L()) { + // Presence of an L3 payload indicates contention resolution. + // GSM 04.06 5.4.1.4. + mState=ContentionResolution; + mContentionCheck = frame.sum(); + mL3Out.write(new L3Frame(frame.L3Part(),DATA)); + // Echo back payload. + sendUFrameUA(frame); + } else { + mState=LinkEstablished; + sendUFrameUA(frame.PF()); + } + break; + case ContentionResolution: + // GSM 04.06 5.4.1.4 + // This guards against the remote possibility that two handsets + // are sending on the same channel at the same time. + // vISDN's LAPD doesn't need/do this since peers are hard-wired + if (frame.sum()!=mContentionCheck) break; + mState=LinkEstablished; + sendUFrameUA(frame); + break; + case AwaitingEstablish: + // Huh? This would mean both sides sent SABM at the same time/ + // That should not happen in GSM. + sendUFrameUA(frame.PF()); + OBJLOG(WARNING) << "simulatenous SABM attempts"; + break; + case AwaitingRelease: + // If we are awaiting release, we will not enter ABM. + // So we send DM to indicate that. + sendUFrameDM(frame.PF()); + break; + case LinkEstablished: + // Latency in contention resolution, GSM 04.06 5.4.2.1. + if (mEstablishmentInProgress) { + if (frame.L()) sendUFrameUA(frame); + else sendUFrameUA(frame.PF()); + break; + } + if (frame.L()) { + abnormalRelease(); + break; + } + // Re-establishment procedure, GSM 04.06 5.6.3. + // This basically resets the ack engine. + // We should not actually see this, as of rev 2.4. + OBJLOG(WARNING) << "reestablishment not really supported"; + sendUFrameUA(frame.PF()); + clearCounters(); + break; + default: + unexpectedMessage(); + return; + } +} + + + +void L2LAPDm::receiveUFrameDISC(const L2Frame& frame) +{ + // Caller should hold mLock. + OBJLOG(INFO) << "state=" << mState << " " << frame; + mEstablishmentInProgress = false; + switch (mState) { + case AwaitingEstablish: + clearState(); + break; + case LinkReleased: + // GSM 04.06 5.4.5 + sendUFrameDM(frame.PF()); + clearState(); + break; + case ContentionResolution: + case LinkEstablished: + // Shut down the link and ack with UA. + // GSM 04.06 5.4.4.2. + sendUFrameUA(frame.PF()); + clearState(); + break; + case AwaitingRelease: + // We can arrive here if both ends sent DISC at the same time. + // GSM 04.06 5.4.6.1. + sendUFrameUA(frame.PF()); + break; + default: + unexpectedMessage(); + return; + } +} + + +void L2LAPDm::receiveUFrameUA(const L2Frame& frame) +{ + // Caller should hold mLock. + // GSM 04.06 3.8.8 + // vISDN datalink.c:lapd_socket_handle_uframe_ua + + OBJLOG(INFO) << "state=" << mState << " " << frame; + if (!frame.PF()) { + unexpectedMessage(); + return; + } + + switch (mState) { + case AwaitingEstablish: + // We sent SABM and the peer responded. + clearCounters(); + mState = LinkEstablished; + mAckSignal.signal(); + mL3Out.write(new L3Frame(ESTABLISH)); + break; + case AwaitingRelease: + // We sent DISC and the peer responded. + clearState(); + break; + default: + unexpectedMessage(); + return; + } +} + + +void L2LAPDm::receiveUFrameDM(const L2Frame& frame) +{ + // Caller should hold mLock. + OBJLOG(INFO) << "state=" << mState << " " << frame; + // GSM 04.06 5.4.5 + if (mState==LinkReleased) return; + // GSM 04.06 5.4.6.3 + if (!frame.PF()) return; + + // Because we do not support multiple TEIs in LAPDm, + // and because we should never get DM in response to SABM, + // this procedure is much simpler that in vISDN LAPD. + // Unlike LAPD, there's also no reason for LAPDm to not be + // able to establish ABM, so if we get this message + // we know the channel is screwed up. + + clearState(); +} + + + +void L2LAPDm::receiveUFrameUI(const L2Frame& frame) +{ + // The zero-length frame is the idle frame. + if (frame.L()==0) return; + OBJLOG(INFO) << "state=" << mState << " " << frame; + mL3Out.write(new L3Frame(frame.tail(24),UNIT_DATA)); +} + + + + + + +void L2LAPDm::receiveSFrame(const L2Frame& frame) +{ + // Caller should hold mLock. + // See GSM 04.06 5.4.1.4. + mEstablishmentInProgress = false; + switch (frame.SFrameType()) { + case L2Control::RRFrame: receiveSFrameRR(frame); break; + case L2Control::REJFrame: receiveSFrameREJ(frame); break; + default: unexpectedMessage(); return; + } +} + + +void L2LAPDm::receiveSFrameRR(const L2Frame& frame) +{ + // Caller should hold mLock. + OBJLOG(INFO) << "state=" << mState << " " << frame; + // GSM 04.06 3.8.5. + // Q.921 3.6.6. + // vISDN datalink.c:lapd_handle_sframe_rr + // Again, since LAPDm allows only one outstanding frame + // (k=1), this is a lot simpler than in LAPD. + switch (mState) { + case ContentionResolution: + mState = LinkEstablished; + // continue to next case... + case LinkEstablished: + // "inquiry response procedure" + // Never actually seen that happen in GSM... + if ((frame.CR()!=mC) && (frame.PF())) { + sendSFrameRR(true); + } + processAck(frame.NR()); + break; + default: + // ignore + return; + } +} + +void L2LAPDm::receiveSFrameREJ(const L2Frame& frame) +{ + // Caller should hold mLock. + OBJLOG(INFO) << "state=" << mState << " " << frame; + // GSM 04.06 3.8.6, 5.5.4 + // Q.921 3.7.6, 5.6.4. + // vISDN datalink.c:lapd_handle_s_frame_rej. + switch (mState) { + case ContentionResolution: + mState = LinkEstablished; + // continue to next case... + case LinkEstablished: + // FIXME -- The spec says to do this but it breaks multiframe transmission. + //mVS = mVA = frame.NR(); + processAck(frame.NR()); + if (frame.PF()) { + if (frame.CR()!=mC) sendSFrameRR(true); + else { + unexpectedMessage(); + return; + } + } + // Since k=1, there's really nothing to retransmit, + // other than what was just rejected, so kust stop sending it. + sendIdle(); + break; + default: + // ignore + break; + } + // Send an idle frame to clear any repeating junk on the channel. + sendIdle(); +} + + + +void L2LAPDm::receiveIFrame(const L2Frame& frame) +{ + // Caller should hold mLock. + // See GSM 04.06 5.4.1.4. + mEstablishmentInProgress = false; + OBJLOG(INFO) << "state=" << mState << " NS=" << frame.NS() << " NR=" << frame.NR() << " " << frame; + // vISDN datalink.c:lapd_handle_iframe + // GSM 04.06 5.5.2, 5.7.1 + // Q.921 5.6.2, 5.8.1 + switch (mState) { + case ContentionResolution: + mState=LinkEstablished; + // continue to next case... + case LinkEstablished: + processAck(frame.NR()); + if (frame.NS()==mVR) { + mVR = (mVR+1)%8; + bufferIFrameData(frame); + sendSFrameRR(frame.PF()); + } else { + // GSM 04.06 5.7.1. + // Q.921 5.8.1. + sendSFrameREJ(frame.PF()); + } + case LinkReleased: + // GSM 04.06 5.4.5 + break; + default: + // ignore + break; + } +} + + + +void L2LAPDm::sendSFrameRR(bool FBit) +{ + // GSM 04.06 3.8.5. + // The caller should hold mLock. + OBJLOG(INFO) << "F=" << FBit << " state=" << mState << " VS=" << mVS << " VR=" << mVR; + L2Address address(mR,mSAPI); + L2Control control(L2Control::SFormat,FBit,0); + static const L2Length length; + L2Header header(address,control,length); + header.control().NR(mVR); + writeL1NoAck(L2Frame(header)); +} + + +void L2LAPDm::sendSFrameREJ(bool FBit) +{ + // GSM 04.06 3.8.6. + // The caller should hold mLock. + OBJLOG(INFO) << "F=" << FBit << " state=" << mState; + L2Address address(mR,mSAPI); + L2Control control(L2Control::SFormat,FBit,2); + static const L2Length length; + L2Header header(address,control,length); + header.control().NR(mVR); + writeL1NoAck(L2Frame(header)); +} + + + + +void L2LAPDm::sendUFrameDM(bool FBit) +{ + // The caller need not hold mLock. + OBJLOG(INFO) << "F=" << FBit << " state=" << mState; + L2Address address(mR,mSAPI); + L2Control control(L2Control::UFormat,FBit,0x03); + static const L2Length length; + L2Header header(address,control,length); + writeL1NoAck(L2Frame(header)); +} + + +void L2LAPDm::sendUFrameUA(bool FBit) +{ + // The caller need not hold mLock. + OBJLOG(INFO) << "F=" << FBit << " state=" << mState; + L2Address address(mR,mSAPI); + L2Control control(L2Control::UFormat,FBit,0x0C); + static const L2Length length; + L2Header header(address,control,length); + writeL1NoAck(L2Frame(header)); +} + + +void L2LAPDm::sendUFrameUA(const L2Frame& frame) +{ + // Send UA frame with a echoed payload. + // This is used in the contention resolution procedure. + // GSM 04.06 5.4.1.4. + // The caller need not hold mLock. + OBJLOG(INFO) << "state=" << mState << " " << frame; + L2Address address(mR,mSAPI); + L2Control control(L2Control::UFormat,frame.PF(),0x0C); + L2Length length(frame.L()); + L2Header header(address,control,length); + writeL1NoAck(L2Frame(header,frame.L3Part())); +} + + + + +void L2LAPDm::sendUFrameSABM() +{ + // GMS 04.06 3.8.2, 5.4.1 + // The caller need not hold mLock. + OBJLOG(INFO) << "state=" << mState; + L2Address address(mC,mSAPI); + L2Control control(L2Control::UFormat,1,0x07); + static const L2Length length; + L2Header header(address,control,length); + writeL1Ack(L2Frame(header)); +} + + +void L2LAPDm::sendUFrameDISC() +{ + // GMS 04.06 3.8.3, 5.4.4.2 + // The caller need not hold mLock. + OBJLOG(INFO) << "state=" << mState; + L2Address address(mC,mSAPI); + L2Control control(L2Control::UFormat,1,0x08); + static const L2Length length; + L2Header header(address,control,length); + writeL1Ack(L2Frame(header)); +} + + +void L2LAPDm::sendUFrameUI(const L3Frame& l3) +{ + // GSM 04.06 3.8.4, 5.3.2, not supporting the short header format. + // The caller need not hold mLock. + OBJLOG(INFO) << "state=" << mState << " payload=" << l3; + L2Address address(mC,mSAPI); + L2Control control(L2Control::UFormat,1,0x00); + L2Length length(l3.L2Length()); + L2Header header(address,control,length); + writeL1NoAck(L2Frame(header,l3)); +} + + + + +void L2LAPDm::sendMultiframeData(const L3Frame& l3) +{ + // See GSM 04.06 5.8.5 + assert(l3.length()<=251); + + // Implements GSM 04.06 5.4.2 + // Caller holds mLock. + OBJLOG(INFO) << "state=" << mState << " payload=" << l3; + // HACK -- Sleep before returning to prevent fast spinning + // in SACCH L3 during release. + if (mState==LinkReleased) { + OBJLOG(ERR) << "attempt to send DATA on released LAPm channel"; + abnormalRelease(); + sleepFrames(51); + return; + } + mDiscardIQueue = false; + size_t bitsRemaining = l3.size(); + size_t sendIndex = 0; + OBJLOG(DEBUG) << "sendIndex=" << sendIndex<< " bitsRemaining=" << bitsRemaining; + while (bitsRemaining>0) { + size_t thisChunkSize = bitsRemaining; + bool MBit = false; + if (thisChunkSize==0) break; + if (thisChunkSize>mMaxIPayloadBits) { + thisChunkSize = mMaxIPayloadBits; + MBit = true; + } + // This is the point where we block and allow + // the upstream thread to modify the LAPDm state. + waitForAck(); + // Did we abort multiframe mode while waiting? + if (mDiscardIQueue) { + OBJLOG(DEBUG) <<"aborting (discard)"; + break; + } + if ((mState!=LinkEstablished) && (mState!=ContentionResolution)) { + OBJLOG(DEBUG) << "aborting, state=" << mState; + break; + } + OBJLOG(DEBUG) << "state=" << mState + << " sendIndex=" << sendIndex << " thisChunkSize=" << thisChunkSize + << " bitsRemaining=" << bitsRemaining << " MBit=" << MBit; + sendIFrame(l3.segment(sendIndex,thisChunkSize),MBit); + sendIndex += thisChunkSize; + bitsRemaining -= thisChunkSize; + } +} + + + +void L2LAPDm::sendIFrame(const BitVector& payload, bool MBit) +{ + // Caller should hold mLock. + // GSM 04.06 5.5.1 + OBJLOG(INFO) << "M=" << MBit << " VS=" << mVS << " payload=" << payload; + // Lots of sanity checking. + assert(mState!=LinkReleased); + assert(payload.size() <= mMaxIPayloadBits); + assert(payload.size()%8 == 0); + if (MBit) assert(payload.size()==mMaxIPayloadBits); + // Build the header and send it. + L2Address address(mC,mSAPI); + L2Control control(mVR,mVS,0); + L2Length length(payload.size()/8,MBit); + L2Header header(address,control,length); + mVS = (mVS+1)%8; + writeL1Ack(L2Frame(header,payload)); +} + + +bool L2LAPDm::stuckChannel(const L2Frame& frame) +{ + // Check for excessive idling. + if (frame.DCCHIdle()) mIdleCount++; + else mIdleCount=0; + return mIdleCount > maxIdle(); +} + + + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML2LAPDm.h b/GSM/GSML2LAPDm.h new file mode 100644 index 0000000..3be969e --- /dev/null +++ b/GSM/GSML2LAPDm.h @@ -0,0 +1,527 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + +/* +Many elements follow Daniele Orlandi's vISDN/Q.921 +implementation, although no code is copied directly. +*/ + +#ifndef L2LAPDM_H +#define L2LAPDM_H + +#include "GSMCommon.h" +#include "GSMTransfer.h" + + +namespace GSM { + +// Forward refs. +class SAPMux; + +/**@name L2 Processing Errors */ +//@{ +/** L2 Read Error is thrown if there is an error in the data on the input side. */ +class L2ReadError : public GSMError { }; + #define L2_READ_ERROR {throw L2ReadError();} + +/** L2 Write Error is thrown if there is an error in the data on the output side. */ +class L2WriteError : public GSMError { }; +#define L2_WRITE_ERROR {throw L2WriteError();} +//@} + + + +/** + Skeleton for data link layer (L2) entities. + This is a base class from which the various channel classes are derived. + Many derived classes are "thin" and do not implement full LAPDm. + This is especially true of the downlink-only classes which do not have + equivalents in Q.921 and HDLC. +*/ +class L2DL { + + protected: + + SAPMux *mDownstream; ///< a pointer to the lower layer + + + public: + + L2DL() + :mDownstream(NULL) + { } + + virtual ~L2DL() {} + + + void downstream(SAPMux *wDownstream) + { mDownstream = wDownstream; } + + virtual void open() = 0; + + /** N201 value for a given frame format on this channel, GSM 04.06 5.8.3. */ + virtual unsigned N201(GSM::L2Control::ControlFormat) const = 0; + + /** N200 value for this channel, GSM 04.06 5.8.2. */ + virtual unsigned N200() const = 0; + + /** T200 timeout for this channel, GSM 04.06 5.8.1. */ + virtual unsigned T200() const { return T200ms; } + + /** Check for establishment of multifame mode; only valid for LAPDm. */ + virtual bool multiframeMode() const { assert(0); } + + /** + The L3->L2 interface. + This is a blocking call and does not return until + all of the corresponding radio bursts have been + enqueued for transmission. + That can take up to 1/2 second. + */ + virtual void writeHighSide(const GSM::L3Frame&) = 0; + + + /** The L1->L2 interface */ + virtual void writeLowSide(const GSM::L2Frame&) = 0; + + /** The L2->L3 interface. */ + virtual L3Frame* readHighSide(unsigned timeout=3600000) = 0; + +}; + + + + +/** + A "thin" L2 for CCCH. + This is a downlink-only channel. + It supports only the Bbis L2 frame format (GSM 04.06 2.1). + The "uplink" component of the CCCH is the RACH. + See GSM 04.03 4.1.2. +*/ +class CCCHL2 : public L2DL { + + public: + + unsigned N201(GSM::L2Control::ControlFormat format) const + { assert(format==L2Control::UFormat); return 22; } + + unsigned N200() const { return 0; } + + void open() {} + + void writeLowSide(const GSM::L2Frame&) { assert(0); } + + L3Frame* readHighSide(unsigned timeout=3600000) { assert(0); return NULL; } + + void writeHighSide(const GSM::L3Frame&); + +}; + + + + + +/** + LAPDm transceiver, GSM 04.06, borrows from ITU-T Q.921 (LAPD) and ISO-13239 (HDLC). + Dedicated control channels need full-blown LAPDm. + + LAPDm is best be thought of as lightweight HDLC. + The main differences between LAPDm and HDLC are: + - LAPDm allows no more than one outstanding unacknowledged I-frame (k=1, GSM 04.06 5.8.4). + - LAPDm does not support extended header formats (GSM 04.06 3). + - LAPDm supports only the SABM, DISC, DM, UI and UA U-Frames (GSM 04.06 3.4, 3.8.1). + - LAPDm supports the RR and REJ S-Frames (GSM 04.06 3.4, 3.8.1), but not RNR (GSM 04.06 3.8.7, see Note). + - LAPDm has just one internal timer, T200. + - LAPDm supports only one terminal endpoint, whose TEI is implied. + - LAPDm should always be able to enter ABM when requested. + - LAPDm can never be in a recevier-not-ready condition (GSM 04.06 3.8.7 , see Note). + + In a first release, we can simplify further by: + - not supporting the Bter short header format + - acking each received I-frame with an RR frame, even when outgoing I-frames are pending + - using the Bbis format for L3 messages that use the L2 pseudolength element + - just using independent L2s for each active SAP + - just using independent L2s on each dedicated channel, which works with k=1 +*/ +class L2LAPDm : public L2DL { + + public: + + /** + LAPD states, Q.921 4.3. + We have few states than vISDN LAPD because LAPDm is simpler. + */ + enum LAPDState { + LinkReleased, + AwaitingEstablish, ///< note that the BTS should never be in this state + AwaitingRelease, + LinkEstablished, + ContentionResolution ///< GMS 04.06 5.4.1.4 + }; + + + protected: + + Thread mUpstreamThread; ///< a thread for upstream traffic and T200 timeouts + bool mRunning; ///< true once the service loop starts + L3FrameFIFO mL3Out; ///< we connect L2->L3 through a FIFO + L2FrameFIFO mL1In; ///< we connect L1->L2 through a FIFO + + unsigned mC; ///< the "C" bit for commands, 1 for BTS, 0 for MS + unsigned mR; ///< this "R" bit for commands, 0 for BTS, 1 for MS + + unsigned mSAPI; ///< the service access point indicator for this L2 + + L2LAPDm *mMaster; ///< This points to the SAP0 LAPDm on this channel. + + + + /**@name Mutex-protected state shared by uplink and downlink threads. */ + //@{ + mutable Mutex mLock; + /**@name State variables from GSM 04.06 3.5.2 */ + //@{ + unsigned mVS; ///< GSM 3.5.2.2, Q.921 3.5.2.2, send counter, NS+1 of last sent I-frame + unsigned mVA; ///< GSM 3.5.2.3, Q.921 3.5.2.3, ack counter, NR+1 of last acked I-frame + unsigned mVR; ///< GSM 3.5.2.5, Q.921 3.5.2.5, recv counter, NR+1 of last recvd I-frame + LAPDState mState; ///< current protocol state + Signal mAckSignal; ///< signal used to wake a thread waiting for an ack + //@} + bool mEstablishmentInProgress; ///< flag described in GSM 04.06 5.4.1.4 + /**@name Segmentation and retransmission. */ + //@{ + BitVector mRecvBuffer; ///< buffer to concatenate received I-frames, same role as sk_rcvbuf in vISDN + L2Frame mSentFrame; ///< previous ack-able kept for retransmission, same role as sk_write_queue in vISDN + bool mDiscardIQueue; ///< a flag used to abort I-frame sending + unsigned mContentionCheck; ///< checksum used for contention resolution, GSM 04.06 5.4.1.4. + unsigned mRC; ///< retransmission counter, GSM 04.06 5.4.1-5.4.4 + Z100Timer mT200; ///< retransmission timer, GSM 04.06 5.8.1 + size_t mMaxIPayloadBits; ///< N201*8 for the I-frame + //@} + //@} + + /** A handy idle frame. */ + L2Frame mIdleFrame; + + /** A lock to control multi-threaded access to L1->L2. */ + Mutex mL1Lock; + + /** HACK -- A count of consecutive idle frames. Used to spot stuck channels. */ + unsigned mIdleCount; + + /** HACK -- Return maximum allowed idle count. */ + virtual unsigned maxIdle() const =0; + + public: + + /** + Construct a LAPDm transceiver. + @param wC "Command" bit, "1" for BTS, "0" for MS, + GSM 04.06 3.3.2. + @param wSAPI Service access point indicatior, + GSM 040.6 3.3.3. + */ + L2LAPDm(unsigned wC=1, unsigned wSAPI=0); + + virtual ~L2LAPDm() {} + + + /** Process an uplink L2 frame. */ + void writeLowSide(const GSM::L2Frame&); + + /** + Read the L3 output, with a timeout. + Caller is responsible for deleting returned object. + */ + L3Frame* readHighSide(unsigned timeout=3600000) + { return mL3Out.read(timeout); } + + /** + Process a downlink L3 frame. + This is a blocking call and does not return until + all of the corresponding radio bursts have been + enqueued for transmission. + That can take up to 1/2 second. + */ + void writeHighSide(const GSM::L3Frame&); + + + /** Prepare the channel for a new transaction. */ + virtual void open(); + + /** Set the "master" SAP, SAP0; should be called no more than once. */ + void master(L2LAPDm* wMaster) + { assert(!mMaster); mMaster=wMaster; } + + /** Return true if in multiframe mode. */ + bool multiframeMode() const + { ScopedLock lock(mLock); return mState==LinkEstablished; } + + + protected: + + /** Block until we receive any pending ack. */ + void waitForAck(); + + /** Send an L2Frame on the L2->L1 interface. */ + void writeL1(const L2Frame&); + + void writeL1Ack(const L2Frame&); ///< send an ack-able frame on L2->L1 + void writeL1NoAck(const L2Frame&); ///< send a non-acked frame on L2->L1 + + /** Abort the link. */ + void linkError(); + + /** Clear the state variables to released condition. */ + void clearState(Primitive relesaeType=RELEASE); + + /** Clear the ABM-related state variables. */ + void clearCounters(); + + /** Go to the "link released" state. */ + void releaseLink(Primitive releaseType=RELEASE); + + /** We go here when something goes really wrong. */ + void abnormalRelease(); + + /** Abort link on unexpected message. */ + void unexpectedMessage(); + + /** Process an ack. Also forces state to LinkEstablished. */ + void processAck(unsigned NR); + + /** Retransmit last ackable frame. */ + void retransmissionProcedure(); + + /** Clear any outgoing L3 frame. */ + void discardIQueue() { mDiscardIQueue=true; } + + /** + Accept and concatenate an I-frame data payload. + GSM 04.06 5.5.2 (first 2 bullet points) + */ + void bufferIFrameData(const L2Frame&); + + /**@name Receive-handlers for the various frame types. */ + //@{ + void receiveFrame(const L2Frame&); ///< Top-level frame handler. + /* + We will postpone support for suspension/resumption of multiframe mode (GSM 04.06 5.4.3). + This will greatly simplify the L2 state machine. + */ + void receiveIFrame(const L2Frame&); ///< GSM 04.06 3.8.1, 5.5.2 + /**@name U-Frame handlers */ + //@{ + void receiveUFrame(const L2Frame&); ///< sub-dispatch for all U-Frames + void receiveUFrameSABM(const L2Frame&); ///< GMS 04.06 3.8.2, 5.4.1 + void receiveUFrameDISC(const L2Frame&); ///< GSM 04.06 3.8.3, 5.4.4.2 + void receiveUFrameUI(const L2Frame&); ///< GSM 04.06 3.8.4, 5.2.1 + void receiveUFrameUA(const L2Frame&); ///< GSM 04.06 3.8.8 + void receiveUFrameDM(const L2Frame&); ///< GSM 04.06 3.8.9, 5.4.4.2 + //@} + /**@name S-Frame handlers */ + //@{ + void receiveSFrame(const L2Frame&); ///< sub-dispatch for all S-Frames + void receiveSFrameREJ(const L2Frame&); ///< GSM 04.06 3.8.6, 5.5.3 + void receiveSFrameRR(const L2Frame&); ///< GSM 04.06 3.8.5, 5.5.4 + //@} + //@} + + /**@name Senders for various frame types. */ + //@{ + /* + In vISDN, these are performed with functions + output.c:lapd_send_uframe, datalink.c:lapd_send_sframe, + output.c:lapd_prepare_uframe, output.c:lapd_prepare_iframe. + We've broken these out into a specific function for each + frame type. For example, to send a DISC in vISDN, you call + lapd_send_uframe with arguments that specify the DISC frame. + In OpenBTS, you just call sendUFrameDISC. + */ + void sendMultiframeData(const L3Frame&); ///< send an L3 frame in one or more I-frames + void sendIFrame(const BitVector&, bool); ///< GSM 04.06 3.8.1, 5.5.1, with payload and "M" flag + void sendUFrameSABM(); ///< GMS 04.06 3.8.2, 5.4.1 + void sendUFrameDISC(); ///< GSM 04.06 3.8.3, 5.4.4.2 + void sendUFrameUI(const L3Frame&); ///< GSM 04.06 3.8.4, 5.2.1 + void sendUFrameUA(bool FBit); ///< GSM 04.06 3.8.8, 5.4.1, 5.4.4.2 + void sendUFrameUA(const L2Frame&); ///< GSM 04.06 3.8.8, 5.4.1.4 + void sendUFrameDM(bool FBit); ///< GMS 04.06 3.8.9, 5.4.4.2 + void sendSFrameRR(bool FBit); ///< GSM 04.06 3.8.5, 5.5.2 + void sendSFrameREJ(bool FBit); ///< GSM 04.06 3.8.6, 5.5.2 + //@} + + /** + Handle expiration of T200. + See GSM 04.06 5.8.1 for a definition of T200. + See GSM 04.06 5.4.1.3, 5.4.4.3, 5.5.7, 5.7.2 for actions to take upon expiration of T200. + */ + void T200Expiration(); + + /** + Send the idle frame, GMS 04.06 5.4.2.3. + This sends one idle frame to L1, but that sets up the modulator to start + generating the idle pattern repeatedly. See README.IdleFilling. + - This should be called in SAP0 when a channel is first opened. + - This should be called after sending any frame + when no further outgoing frames are pending. + - This should be called after receiving a REJ frame. + - This need not be called when the channel is closed, + as L1 will generate its own filler pattern that is more + appropriate in this condition. + */ + virtual void sendIdle() { writeL1(mIdleFrame); } + + /** + Increment or clear the idle count based on the current frame. + @return true if we should abort + */ + bool stuckChannel(const L2Frame&); + + /** + The upstream service loop handles incoming L2 frames and T200 timeouts. + */ + void serviceLoop(); + + friend void *LAPDmServiceLoopAdapter(L2LAPDm*); +}; + + +std::ostream& operator<<(std::ostream&, L2LAPDm::LAPDState); + + +/** C-style adapter for LAPDm serice loop. */ +void *LAPDmServiceLoopAdapter(L2LAPDm*); + + + +class SDCCHL2 : public L2LAPDm { + + protected: + + unsigned maxIdle() const { return 50; } + + /** GSM 04.06 5.8.3. We support only A/B formats. */ + unsigned N201(GSM::L2Control::ControlFormat format) const + { assert(format==L2Control::IFormat); return 20; } + + /** GSM 04.06 5.8.2.1 */ + unsigned N200() const { return 23; } + + public: + + /** + Construct the LAPDm part of the SDCCH. + @param wC "Command" bit, "1" for BTS, "0" for MS. + @param wSAPI Service access point indicatior. + */ + SDCCHL2(unsigned wC=1, unsigned wSAPI=0) + :L2LAPDm(wC,wSAPI) + { } + +}; + + + +/** + Link Layer for Slow Associated Control Channel (SACCH). + GSM 04.06 2 states that UI frames on the SACCH use format B4. + However, in GSM 04.08 you see that all messages sent on the SACCH + in the UI mode use an "L2 pseudolength" field. So we can greatly + simplify the SACCH by just using the B format and letting the + length field of the B format stand in for the "L2 pseudolength" + field, since their content is identical. This will work well enough + until we need to support L3 "rest octets" on the SACCH. +*/ +class SACCHL2 : public L2LAPDm { + + protected: + + unsigned maxIdle() const { return 1000; } + + /** GSM 04.06 5.8.3. We support only A/B formats. */ + unsigned N201(GSM::L2Control::ControlFormat format) const + { assert(format==L2Control::IFormat); return 18; } + + /** GSM 04.06 5.8.2.1 */ + unsigned N200() const { return 5; } + + /** T200 timeout for this channel, GSM 04.06 5.8.1. */ + unsigned T200() const { return 4*T200ms; } + + /** SACCH does not use idle frames. */ + void sendIdle() {}; + + public: + + /** + Construct the LAPDm part of the SACCH. + @param wC "Command" bit, "1" for BTS, "0" for MS. + @param wSAPI Service access point indicatior. + */ + SACCHL2(unsigned wC=1, unsigned wSAPI=0) + :L2LAPDm(wC,wSAPI) + { } + +}; + + + +/** + Link Layer for Fast Associated Control Channel (FACCH). +*/ +class FACCHL2 : public L2LAPDm { + + protected: + + unsigned maxIdle() const { return 500; } + + /** GSM 04.06 5.8.3. We support only A/B formats. */ + unsigned N201(GSM::L2Control::ControlFormat format) const + { assert(format==L2Control::IFormat); return 20; } + + /** GSM 04.06 5.8.2.1 */ + unsigned N200() const { return 34; } + + /** FACCH does not need idle frames. */ + void sendIdle() {}; + + public: + + /** + Construct the LAPDm part of the FACCH. + @param wC "Command" bit, "1" for BTS, "0" for MS. + @param wSAPI Service access point indicatior. + */ + FACCHL2(unsigned wC=1, unsigned wSAPI=0) + :L2LAPDm(wC,wSAPI) + { } + +}; + + + + + +}; // namespace GSM + +#endif + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3CCElements.cpp b/GSM/GSML3CCElements.cpp new file mode 100644 index 0000000..9e7cfb0 --- /dev/null +++ b/GSM/GSML3CCElements.cpp @@ -0,0 +1,314 @@ +/**@file @brief Call Control messages, GSM 04.08 9.3 */ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "GSML3CCElements.h" +#include + +using namespace std; +using namespace GSM; + + +void L3BearerCapability::writeV( L3Frame &dest, size_t &wp ) const +{ + // See GSM 10.5.4.5. + // This is a hell of a complex element, inherited from ISDN. + // But we're going to ignore a lot of it. + + // "octet 3" + // We hard code this octet for circuit switched speech. + dest.writeField(wp, 0x04, 8); + + // "octet 3a" + // We hard code for full rate speech v1, the GSM 06.10 codec. + dest.writeField(wp,0x80,8); +} + + +void L3BearerCapability::parseV( const L3Frame& src, size_t &rp, size_t expectedLength ) +{ + // See GSM 10.5.4.5. + // This is a hell of a complex element, inherited from ISDN. + + // But we're just going to assume circuit-switched speech + // with a full rate codec, since every phone supports that. + // So we can just ignore this hideously complex element. + + // Just move the read index and return. + // Shhh. Our little secret. + rp += 8*expectedLength; + +} + + +void L3BearerCapability::text(ostream& os) const +{ + os << "(default)"; +} + + +void L3BCDDigits::parse(const L3Frame& src, size_t &rp, size_t numOctets) +{ + unsigned i=0; + size_t readOctets = 0; + while (readOctets < numOctets) { + unsigned d2 = src.readField(rp,4); + unsigned d1 = src.readField(rp,4); + readOctets++; + mDigits[i++]=d1+'0'; + if (d2!=0x0f) mDigits[i++]=d2+'0'; + if (i>maxDigits) L3_READ_ERROR; + } + mDigits[i++]='\0'; +} + + +void L3BCDDigits::write(L3Frame& dest, size_t &wp) const +{ + unsigned index = 0; + unsigned numDigits = strlen(mDigits); + while (index < numDigits) { + if ((index+1) < numDigits) dest.writeField(wp,mDigits[index+1]-'0',4); + else dest.writeField(wp,0x0f,4); + dest.writeField(wp,mDigits[index]-'0',4); + index += 2; + } +} + + +size_t L3BCDDigits::lengthV() const +{ + unsigned sz = strlen(mDigits); + return (sz/2) + (sz%2); +} + + + +ostream& GSM::operator<<(ostream& os, const L3BCDDigits& digits) +{ + os << digits.digits(); + return os; +} + + + +void L3CalledPartyBCDNumber::writeV( L3Frame &dest, size_t &wp ) const +{ + dest.writeField(wp, 0x01, 1); + dest.writeField(wp, mType, 3); + dest.writeField(wp, mPlan, 4); + mDigits.write(dest,wp); +} + +void L3CalledPartyBCDNumber::parseV( const L3Frame &src, size_t &rp, size_t expectedLength ) +{ + LOG(DEBUG) << "L3CalledPartyBCDNumber::parseV rp="< + + +namespace GSM { + +/** Bearer Capability, GSM 04.08 10.5.4.5 */ +class L3BearerCapability : public L3ProtocolElement { + + // The spec for this is really intimidating. + // But we're just going to assume circuit-switched speech + // with a full rate codec, since every phone supports that. + // So we can just ignore this hideously complex element. + +public: + + L3BearerCapability() : L3ProtocolElement() {} + + size_t lengthV() const { return 2; } + void writeV( L3Frame& dest, size_t &wp ) const; + void parseV( const L3Frame& src, size_t &rp, size_t expectedLength ); + void parseV(const L3Frame&, size_t&) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** A general class for BCD numbers as they normally appear in L3. */ +class L3BCDDigits { + + private: + + static const unsigned maxDigits = 20; + char mDigits[maxDigits+1]; ///< ITU-T E.164 limits address to 15 digits + + public: + + L3BCDDigits() { mDigits[0]='\0'; } + + L3BCDDigits(const char* wDigits) { strncpy(mDigits,wDigits,sizeof(mDigits)-1); mDigits[sizeof(mDigits)-1]='\0'; } + + void parse(const L3Frame& src, size_t &rp, size_t numOctets); + void write(L3Frame& dest, size_t &wp) const; + + /** Return number of octets needed to encode the digits. */ + size_t lengthV() const; + + unsigned size() const { return strlen(mDigits); } + const char* digits() const { return mDigits; } +}; + + +std::ostream& operator<<(std::ostream&, const L3BCDDigits&); + + + + + + + +/** Calling Party BCD Number, GSM 04.08 10.5.4.9 */ +class L3CallingPartyBCDNumber : public L3ProtocolElement { + +private: + + TypeOfNumber mType; + NumberingPlan mPlan; + + L3BCDDigits mDigits; + + /**@name Octet 3a */ + //@{ + bool mHaveOctet3a; + int mPresentationIndicator; + int mScreeningIndicator; + //@} + + +public: + + L3CallingPartyBCDNumber() + :mType(UnknownTypeOfNumber),mPlan(UnknownPlan), + mHaveOctet3a(false) + { } + + L3CallingPartyBCDNumber( const char * wDigits ) + :mType(NationalNumber),mPlan(E164Plan),mDigits(wDigits), + mHaveOctet3a(false) + { } + + + NumberingPlan plan() const { return mPlan; } + TypeOfNumber type() const { return mType; } + const char* digits() const { return mDigits.digits(); } + + size_t lengthV() const; + void writeV( L3Frame& dest, size_t &wp ) const; + void parseV( const L3Frame& src, size_t &rp, size_t expectedLength); + void parseV(const L3Frame&, size_t&) { assert(0); } + void text(std::ostream&) const; +}; + + +/** Called Party BCD Number, GSM 04.08 10.5.4.7 */ +class L3CalledPartyBCDNumber : public L3ProtocolElement { + + +private: + + TypeOfNumber mType; + NumberingPlan mPlan; + L3BCDDigits mDigits; + +public: + + L3CalledPartyBCDNumber() + :mType(UnknownTypeOfNumber), + mPlan(UnknownPlan) + { } + + L3CalledPartyBCDNumber(const char * wDigits) + :mType(NationalNumber),mPlan(E164Plan),mDigits(wDigits) + { } + + L3CalledPartyBCDNumber(const L3CallingPartyBCDNumber& other) + :mType(other.type()),mPlan(other.plan()),mDigits(other.digits()) + { } + + + NumberingPlan plan() const { return mPlan; } + TypeOfNumber type() const { return mType; } + const char* digits() const { return mDigits.digits(); } + + size_t lengthV() const ; + void writeV( L3Frame& dest, size_t &wp ) const; + void parseV( const L3Frame& src, size_t &rp, size_t expectedLength ); + void parseV(const L3Frame&, size_t&) { assert(0); } + void text(std::ostream&) const; +}; + + + + + + + + +/** + Cause, GSM 04.08 10.5.4.11 + Read the spec closely: we only have to support coding standard 3 (GSM), + and that format doesn't carry the "recommendation" field. +*/ + +class L3Cause : public L3ProtocolElement { + +public: + + enum Location { + User=0, + PrivateServingLocal=1, + PublicServingLocal=2, + Transit=3, + PublicServingRemote=4, + PrivateServingRemote=5, + International=7, + BeyondInternetworking=10 + }; + +private: + + Location mLocation; + unsigned mCause; + +public: + + L3Cause(unsigned wCause=0, Location wLocation=PrivateServingLocal) + :L3ProtocolElement(), + mLocation(wLocation),mCause(wCause) + { } + + Location location() const { return mLocation; } + unsigned cause() const { return mCause; } + + // We don't support diagnostics, so length=2. + size_t lengthV() const { return 2; } + + void writeV( L3Frame& dest, size_t &wp) const; + void parseV( const L3Frame& src, size_t &rp , size_t expectedLength ); + void parseV(const L3Frame&, size_t&) { assert(0); } + void text(std::ostream&) const; +}; + + +/** Call State, GSM 04.08 10.5.4.6. */ +class L3CallState : public L3ProtocolElement { + +private: + + unsigned mCallState; + +public: + + /** The default call state is the "Null" state. */ + L3CallState( unsigned wCallState=0 ) + :L3ProtocolElement(), + mCallState(wCallState) + { } + + size_t lengthV()const { return 1;} + void writeV( L3Frame& dest, size_t &wp) const; + void parseV( const L3Frame& src, size_t &rp ); + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void text(std::ostream&) const; + +}; + +/** GSM 04.08 10.5.4.21 */ +class L3ProgressIndicator : public L3ProtocolElement { + + public: + + enum Location { + User=0, + PrivateServingLocal=1, + PublicServingLocal=2, + PublicServingRemote=4, + PrivateServingRemote=5, + BeyondInternetworking=10 + }; + + enum Progress { + Unspecified=0, + NotISDN=1, + DestinationNotISDN=2, + OriginationNotISDN=3, + ReturnedToISDN=4, + InBandAvailable=8, + EndToEndISDN=0x20, + Queuing=0x40 + }; + + private: + + Location mLocation; + Progress mProgress; + + public: + + /** Default values are unspecified progress in the BTS. */ + L3ProgressIndicator(Progress wProgress=Unspecified, Location wLocation=PrivateServingLocal) + :L3ProtocolElement(), + mLocation(wLocation),mProgress(wProgress) + {} + + Location location() const { return mLocation; } + Progress progress() const { return mProgress; } + + size_t lengthV() const { return 2; } + void writeV(L3Frame& dest, size_t &wp ) const; + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void parseV(const L3Frame&, size_t&) { assert(0); } + void text(std::ostream&) const; +}; + + +/** GSM 04.08 10.5.4.17 */ +class L3KeypadFacility : public L3ProtocolElement { + + private: + + char mIA5; + + public: + + L3KeypadFacility(char wIA5=0) + :mIA5(wIA5) + {} + + char IA5() const { return mIA5; } + + size_t lengthV() const { return 1; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void parseV(const L3Frame& src, size_t& rp); + void text(std::ostream&) const; +}; + + +} // GSM + +#endif +// vim: ts=4 sw=4 diff --git a/GSM/GSML3CCMessages.cpp b/GSM/GSML3CCMessages.cpp new file mode 100644 index 0000000..39e899b --- /dev/null +++ b/GSM/GSML3CCMessages.cpp @@ -0,0 +1,479 @@ +/** @file Call Control messags, GSM 04.08 9.3. */ + +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + + +#include +#include "GSML3CCMessages.h" +#include + + + +using namespace std; +using namespace GSM; + + + +ostream& GSM::operator<<(ostream& os, L3CCMessage::MessageType val) +{ + switch (val) { + case L3CCMessage::Alerting: + os << "Alerting"; break; + case L3CCMessage::Connect: + os << "Connect"; break; + case L3CCMessage::Disconnect: + os << "Disconnect"; break; + case L3CCMessage::ConnectAcknowledge: + os << "Connect Acknowledge"; break; + case L3CCMessage::Release: + os << "Release"; break; + case L3CCMessage::ReleaseComplete: + os << "Release Complete"; break; + case L3CCMessage::Setup: + os << "Setup"; break; + case L3CCMessage::EmergencySetup: + os << "Emergency Setup"; break; + case L3CCMessage::CCStatus: + os <<"CC Status"; break; + case L3CCMessage::CallConfirmed: + os <<"Call Confirmed"; break; + case L3CCMessage::CallProceeding: + os <<"Call Proceeding"; break; + case L3CCMessage::StartDTMF: + os << "Start DTMF"; break; + case L3CCMessage::StartDTMFReject: + os << "Start DTMF Reject"; break; + case L3CCMessage::StartDTMFAcknowledge: + os << "Start DTMF Acknowledge"; break; + case L3CCMessage::StopDTMF: + os << "Stop DTMF"; break; + case L3CCMessage::StopDTMFAcknowledge: + os << "Stop DTMF Acknowledge"; break; + case L3CCMessage::Hold: + os << "Hold"; break; + case L3CCMessage::HoldReject: + os << "Hold Reject"; break; + default: os << hex << "0x" << (int)val << dec; + } + return os; +} + + + +L3CCMessage * GSM::L3CCFactory(L3CCMessage::MessageType MTI) +{ + switch (MTI) { + case L3CCMessage::Connect: return new L3Connect(); + case L3CCMessage::Alerting: return new L3Alerting(); + case L3CCMessage::Setup: return new L3Setup(); + case L3CCMessage::EmergencySetup: return new L3EmergencySetup(); + case L3CCMessage::Disconnect: return new L3Disconnect(); + case L3CCMessage::CallProceeding: return new L3CallProceeding(); + case L3CCMessage::Release: return new L3Release(); + case L3CCMessage::ReleaseComplete: return new L3ReleaseComplete(); + case L3CCMessage::ConnectAcknowledge: return new L3ConnectAcknowledge(); + case L3CCMessage::CCStatus: return new L3CCStatus(); + case L3CCMessage::CallConfirmed: return new L3CallConfirmed(); + case L3CCMessage::StartDTMF: return new L3StartDTMF(); + case L3CCMessage::StopDTMF: return new L3StopDTMF(); + case L3CCMessage::Hold: return new L3Hold(); + default: { + LOG(NOTICE) << "no L3 CC factory support for message "<< MTI; + return NULL; + } + } +} + + + + +/* parser for Call control messages, will only parse uplink */ +L3CCMessage * GSM::parseL3CC(const L3Frame& source) +{ + // mask out bit #7 (1011 1111) so use 0xbf, see GSM 04.08 Table 10.3/3. + L3CCMessage::MessageType MTI = (L3CCMessage::MessageType)(0xbf & source.MTI()); + LOG(DEBUG) << "MTI="<TI(source.TI()); + retVal->parse(source); + LOG(DEBUG) << *retVal; + return retVal; +} + + +void L3CCMessage::write(L3Frame& dest) const +{ + // We override L3Message::write for the transaction identifier. + size_t l3len = bitsNeeded(); + if (dest.size()!=l3len) dest.resize(l3len); + size_t wp = 0; + dest.writeField(wp,mTI,4); + dest.writeField(wp,PD(),4); + dest.writeField(wp,MTI(),8); + + writeBody(dest,wp); +} + + + + +void L3CCMessage::text(ostream& os) const +{ + os << "CC " << (MessageType) MTI(); + os << " TI=" << mTI << " "; +} + + +size_t L3Alerting::l2BodyLength() const +{ + size_t sum=0; + if (mHaveProgress) sum += mProgress.lengthTLV(); + return sum; +} + +void L3Alerting::writeBody(L3Frame &dest, size_t &wp) const +{ + if (mHaveProgress) mProgress.writeTLV(0x1E,dest,wp); +} + +void L3Alerting::parseBody(const L3Frame& src, size_t &rp) +{ + skipTLV(0x1C,src,rp); // skip facility + mHaveProgress = mProgress.parseTLV(0x1E,src,rp); + // ignore the rest +} + +void L3Alerting::text(ostream& os) const +{ + L3CCMessage::text(os); + if (mHaveProgress) os << "progress=(" << mProgress << ")"; +} + + +size_t L3CallProceeding::l2BodyLength() const +{ + size_t sum=0; + if (mHaveProgress) sum += mProgress.lengthTLV(); + if( mHaveBearerCapability) sum += mBearerCapability.lengthTLV(); + return sum; +} + + +void L3CallProceeding::writeBody(L3Frame &dest, size_t &wp) const +{ + if( mHaveBearerCapability) mBearerCapability.writeTLV(0x04, dest, wp); + if (mHaveProgress) mProgress.writeTLV(0x1E, dest, wp); + +} + +void L3CallProceeding::parseBody(const L3Frame& src, size_t &rp) +{ + skipTV(0x0D,4,src,rp); // skip repeat indicator + skipTLV(0x04,src,rp); // skip bearer capability 1 + skipTLV(0x04,src,rp); // skip bearer capability 2 + skipTLV(0x1C,src,rp); // skip facility + mHaveProgress = mProgress.parseTLV(0x1E,src,rp); +} + +void L3CallProceeding::text(ostream& os) const +{ + L3CCMessage::text(os); + if (mHaveProgress) os << "progress=(" << mProgress << ")"; +} + + + + + + +size_t L3Connect::l2BodyLength() const +{ + size_t len=0; + if (mHaveProgress) len += mProgress.lengthTLV(); + return len; +} + +void L3Connect::writeBody(L3Frame &dest, size_t &wp) const +{ + if (mHaveProgress) mProgress.writeTLV(0x1E,dest,wp); +} + +void L3Connect::parseBody(const L3Frame& src, size_t &rp) +{ + skipTLV(0x1c,src,rp); // facility + mHaveProgress = mProgress.parseTLV(0x1e,src,rp); + // ignore the rest +} + + +void L3Connect::text(ostream& os) const +{ + L3CCMessage::text(os); + if (mHaveProgress) os << "progress=(" << mProgress << ")"; +} + + + + +size_t L3Release::l2BodyLength() const +{ + size_t sum = 0; + if (mHaveCause) sum += mCause.lengthTLV(); + return sum; +} + + +void L3Release::writeBody(L3Frame& dest, size_t &wp) const +{ + if (mHaveCause) mCause.writeTLV(0x08,dest,wp); +} + + +void L3Release::parseBody(const L3Frame& src, size_t &rp) +{ + mHaveCause = mCause.parseTLV(0x08,src,rp); + // ignore the rest +} + + +void L3Release::text(ostream& os) const +{ + L3CCMessage::text(os); + if (mHaveCause) os << "cause=(" << mCause << ")"; +} + + + +size_t L3ReleaseComplete::l2BodyLength() const +{ + size_t sum = 0; + if (mHaveCause) sum += mCause.lengthTLV(); + return sum; +} + + +void L3ReleaseComplete::writeBody(L3Frame& dest, size_t &wp) const +{ + if (mHaveCause) mCause.writeTLV(0x08,dest,wp); +} + + +void L3ReleaseComplete::parseBody(const L3Frame& src, size_t &rp) +{ + mHaveCause = mCause.parseTLV(0x08,src,rp); + // ignore the rest +} + + +void L3ReleaseComplete::text(ostream& os) const +{ + L3CCMessage::text(os); + if (mHaveCause) os << "cause=(" << mCause << ")"; +} + + + + +void L3Setup::writeBody( L3Frame &dest, size_t &wp ) const +{ + if (mHaveBearerCapability) mBearerCapability.writeTLV(0x04, dest, wp); + if (mHaveCallingPartyBCDNumber) mCallingPartyBCDNumber.writeTLV(0x5C,dest, wp); + if (mHaveCalledPartyBCDNumber) mCalledPartyBCDNumber.writeTLV(0x5E,dest, wp); +} + + + + +void L3Setup::parseBody( const L3Frame &src, size_t &rp ) +{ + skipTV(0x0D,4,src,rp); // skip Repeat Indicator. + skipTLV(0x04,src,rp); // skip Bearer Capability 1. + skipTLV(0x04,src,rp); // skip Bearer Capability 2. + skipTLV(0x1C,src,rp); // skip Facility. + skipTLV(0x1E,src,rp); // skip Progress. + skipTLV(0x34,src,rp); // skip Signal. + mHaveCallingPartyBCDNumber = mCallingPartyBCDNumber.parseTLV(0x5C,src,rp); + skipTLV(0x5D,src,rp); // skip Calling Party Subaddress + mHaveCalledPartyBCDNumber = mCalledPartyBCDNumber.parseTLV(0x5E,src,rp); + // ignore the rest +} + +size_t L3Setup::l2BodyLength() const +{ + int len = 0; + if(mHaveBearerCapability) len += mBearerCapability.lengthTLV(); + if(mHaveCalledPartyBCDNumber) len += mCalledPartyBCDNumber.lengthTLV(); + if(mHaveCallingPartyBCDNumber) len += mCallingPartyBCDNumber.lengthTLV(); + return len; +} + + +void L3Setup::text(ostream& os) const +{ + L3CCMessage::text(os); + if(mHaveCallingPartyBCDNumber) + os <<"CallingPartyBCDNumber=("<. + +*/ + + + + +#include "GSML3CommonElements.h" +#include + + +using namespace std; +using namespace GSM; + + +L3LocationAreaIdentity::L3LocationAreaIdentity(const char*wMCC, const char* wMNC, unsigned wLAC) + :L3ProtocolElement(), + mLAC(wLAC) +{ + // country code + assert(strlen(wMCC)==3); + mMCC[0] = wMCC[0]-'0'; + mMCC[1] = wMCC[1]-'0'; + mMCC[2] = wMCC[2]-'0'; + // network code + assert(strlen(wMNC)<=3); + assert(strlen(wMNC)>=2); + mMNC[0] = wMNC[0]-'0'; + mMNC[1] = wMNC[1]-'0'; + if (wMNC[2]!='\0') mMNC[2]=wMNC[2]-'0'; + else mMNC[2]=0x0f; +} + + +void L3LocationAreaIdentity::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,mMCC[1],4); + dest.writeField(wp,mMCC[0],4); + dest.writeField(wp,mMNC[2],4); + dest.writeField(wp,mMCC[2],4); + dest.writeField(wp,mMNC[1],4); + dest.writeField(wp,mMNC[0],4); + dest.writeField(wp,mLAC,16); +} + +void L3LocationAreaIdentity::parseV( const L3Frame& src, size_t &rp ) +{ + mMCC[1] = src.readField(rp, 4); + mMCC[0] = src.readField(rp, 4); + mMNC[2] = src.readField(rp, 4); + mMCC[2] = src.readField(rp, 4); + mMNC[1] = src.readField(rp, 4); + mMNC[0] = src.readField(rp, 4); + mLAC = src.readField(rp, 16); +} + + +bool L3LocationAreaIdentity::operator==(const L3LocationAreaIdentity& other) const +{ + // MCC + if (mMCC[0]!=other.mMCC[0]) return false; + if (mMCC[1]!=other.mMCC[1]) return false; + if (mMCC[2]!=other.mMCC[2]) return false; + // MNC + if (mMNC[0]!=other.mMNC[0]) return false; + if (mMNC[1]!=other.mMNC[1]) return false; + if (mMNC[2]!=other.mMNC[2]) return false; + // LAC + if (mLAC!=other.mLAC) return false; + // So everything matched. + return true; +} + + +void L3LocationAreaIdentity::text(ostream& os) const +{ + os << "MCC=" << mMCC[0] << mMCC[1] << mMCC[2]; + os << " MNC=" << mMNC[0] << mMNC[1]; + if (mMNC[2]<15) os << mMNC[2]; + os << " LAC=0x" << hex << mLAC << dec; +} + +int L3LocationAreaIdentity::MNC() const +{ + int val = mMNC[0]*10 + mMNC[1]; + if (mMNC[2]<15) val = val*10 + mMNC[2]; + return val; +} + + + + + +void L3CellIdentity::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,mID,16); +} + + +void L3CellIdentity::text(ostream& os) const +{ + os << mID; +} + + + +bool L3MobileIdentity::operator==(const L3MobileIdentity& other) const +{ + if (other.mType!=mType) return false; + if (mType==TMSIType) return (mTMSI==other.mTMSI); + return (strcmp(mDigits,other.mDigits)==0); +} + +bool L3MobileIdentity::operator<(const L3MobileIdentity& other) const +{ + if (other.mType != mType) return mType > other.mType; + if (mType == TMSIType) return mTMSI > other.mTMSI; + return strcmp(mDigits,other.mDigits)>0; +} + + +size_t L3MobileIdentity::lengthV() const +{ + if (mType==NoIDType) return 1; + if (mType==TMSIType) return 5; + return 1 + strlen(mDigits)/2; +} + + +void L3MobileIdentity::writeV(L3Frame& dest, size_t &wp) const +{ + // See GSM 04.08 10.5.1.4. + + if (mType==NoIDType) { + dest.writeField(wp,0x0f0,8); + return; + } + + if (mType==TMSIType) { + dest.writeField(wp,0x0f4,8); + dest.writeField(wp,mTMSI,32); + return; + } + + int numDigits = strlen(mDigits); + assert(numDigits<=15); + + // The first byte. + dest.writeField(wp,mDigits[0]-'0',4); + dest.writeField(wp,(numDigits%2),1); + dest.writeField(wp,mType,3); + + // The other bytes are more regular. + int i=1; + while (i15) L3_READ_ERROR; + } + if (!oddCount) numDigits--; + mDigits[numDigits]='\0'; + break; + default: + LOG(NOTICE) << "non-standard identity type " << (int)mType; + mDigits[0]='\0'; + mType = NoIDType; + } +} + +void L3MobileIdentity::text(ostream& os) const +{ + os << mType << "="; + if (mType==TMSIType) { + os << hex << "0x" << mTMSI << dec; + return; + } + os << mDigits; +} + + + +void L3MobileStationClassmark1::parseV(const L3Frame& src, size_t& rp) +{ + rp++; // spare + mRevisionLevel = src.readField(rp,2); + mES_IND = src.readField(rp,1); + mA5_1 = src.readField(rp,1); + mRFPowerCapability = src.readField(rp,3); +} + +void L3MobileStationClassmark1::text(ostream& os) const +{ + os << "revision=" << mRevisionLevel; + os << " ES-IND=" << mES_IND; + os << " A5/1=" << mA5_1; + os << " powerCap=" << mRFPowerCapability; +} + + + +void L3MobileStationClassmark2::parseV(const L3Frame& src, size_t& rp) +{ + rp++; // spare + mRevisionLevel = src.readField(rp,2); + mES_IND = src.readField(rp,1); + mA5_1 = src.readField(rp,1); + mRFPowerCapability = src.readField(rp,3); + rp++; // spare + mPSCapability = src.readField(rp,1); + mSSScreenIndicator = src.readField(rp,2); + mSMCapability = src.readField(rp,1); + mVBS = src.readField(rp,1); + mVGCS = src.readField(rp,1); + mFC = src.readField(rp,1); + mCM3 = src.readField(rp,1); + rp++; // spare + mLCSVACapability = src.readField(rp,1); + rp++; // spare + mSoLSA = src.readField(rp,1); + mCMSF = src.readField(rp,1); + mA5_3 = src.readField(rp,1); + mA5_2 = src.readField(rp,1); +} + +void L3MobileStationClassmark2::parseV(const L3Frame& src, size_t& rp, size_t len) +{ + // This is sometimes send as LV, with extra bytes. + // FIXME -- Learn to decode those extra bytes. + size_t frp = rp; + parseV(src,frp); + rp += len*8; +} + +void L3MobileStationClassmark2::text(ostream& os) const +{ + os << "revision=" << mRevisionLevel; + os << " ES-IND=" << mES_IND; + os << " A5/1=" << mA5_1; + os << " A5/2=" << mA5_2; + os << " A5/3=" << mA5_3; + os << " powerCap=" << mRFPowerCapability; + os << " PS=" << mPSCapability; + os << " SSScrenInd=" << mSSScreenIndicator; + os << " SM=" << mSMCapability; + os << " VBS=" << mVBS; + os << " VGCS=" << mVGCS; + os << " FC=" << mFC; + os << " CM3=" << mCM3; + os << " LCSVA=" << mLCSVACapability; + os << " SoLSA=" << mSoLSA; + os << " CMSF=" << mCMSF; +} + + + +void L3MobileStationClassmark3::parseV(const L3Frame& src, size_t& rp) +{ + // FIXME -- This is incomplete. + rp+=1; // skip spare bits + unsigned mMultiband = src.readField(rp,3); + switch (mMultiband) { + case 0: + case 5: case 6: + case 1: case 2: case 4: + mA5_7 = src.readField(rp,1); + mA5_6 = src.readField(rp,1); + mA5_5 = src.readField(rp,1); + mA5_4 = src.readField(rp,1); + break; + default: + break; + } +} + +void L3MobileStationClassmark3::parseV(const L3Frame& src, size_t& rp, size_t len) +{ + // We do this because the parser is incomplete. + size_t frp = rp; + parseV(src,frp); + rp += len*8; +} + +void L3MobileStationClassmark3::text(ostream& os) const +{ + os << "multiband=" << mMultiband; + os << " A5/4=" << mA5_4; + os << " A5/5=" << mA5_4; + os << " A5/6=" << mA5_4; + os << " A5/7=" << mA5_4; +} + + + + +void L3CipheringKeySequenceNumber::writeV(L3Frame &dest, size_t& wp) const +{ + dest.writeField(wp,mCIValue,4); +} + +void L3CipheringKeySequenceNumber::text(ostream& os) const +{ + os << mCIValue; +} + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3CommonElements.h b/GSM/GSML3CommonElements.h new file mode 100644 index 0000000..3cb99cc --- /dev/null +++ b/GSM/GSML3CommonElements.h @@ -0,0 +1,277 @@ +/**@file + @brief Common elements for L3 messages, GSM 04.08 10.5.1. +*/ +/* +* Copyright 2008-2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + + +#ifndef GSMCOMMONELEMENTS_H +#define GSMCOMMONELEMENTS_H + +#include "GSML3Message.h" +#include + + +namespace GSM { + + + +/** Cell Identity, GSM 04.08 10.5.1.1 */ +class L3CellIdentity : public L3ProtocolElement { + + private: + + unsigned mID; + + public: + + L3CellIdentity(unsigned wID=gConfig.getNum("GSM.Identity.CI")) + :mID(wID) + { } + + size_t lengthV() const { return 2; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { abort(); } + void parseV(const L3Frame&, size_t&, size_t) { abort(); } + void text(std::ostream&) const; +}; + + + + + +/** LAI, GSM 04.08 10.5.1.3 */ +class L3LocationAreaIdentity : public L3ProtocolElement { + + private: + + unsigned mMCC[3]; ///< mobile country code digits + unsigned mMNC[3]; ///< mobile network code digits + unsigned mLAC; ///< location area code + + + public: + + /** + Initialize the LAI with real values, drawn from gConfig by default. + @param wMCC MCC as a string (3 digits). + @param wMNC MNC as a string (2 or 3 digits). + @param wLAC LAC as a number. + */ + L3LocationAreaIdentity( + const char*wMCC = gConfig.getStr("GSM.Identity.MCC").c_str(), + const char* wMNC = gConfig.getStr("GSM.Identity.MNC").c_str(), + unsigned wLAC = gConfig.getNum("GSM.Identity.LAC") + ); + + /** Sometimes we need to compare these things. */ + bool operator==(const L3LocationAreaIdentity&) const; + + size_t lengthV() const { return 5; } + void parseV(const L3Frame& source, size_t &rp); + void parseV(const L3Frame&, size_t&, size_t) { abort(); } + void writeV(L3Frame& dest, size_t &wp) const; + void text(std::ostream&) const; + + int MCC() const { return mMCC[0]*100 + mMCC[1]*10 + mMCC[2]; } + int MNC() const; + int LAC() const { return mLAC; } +}; + + + + + + +/** Mobile Identity, GSM 04.08, 10.5.1.4 */ +class L3MobileIdentity : public L3ProtocolElement { + + private: + + + MobileIDType mType; ///< IMSI, TMSI, or IMEI? + char mDigits[16]; ///< GSM 03.03 2.2 limits the IMSI or IMEI to 15 digits. + uint32_t mTMSI; ///< GSM 03.03 2.4 specifies the TMSI as 32 bits + + public: + + /** Empty ID */ + L3MobileIdentity() + :L3ProtocolElement(), + mType(NoIDType) + { mDigits[0]='\0'; } + + /** TMSI initializer. */ + L3MobileIdentity(unsigned int wTMSI) + :L3ProtocolElement(), + mType(TMSIType), mTMSI(wTMSI) + { mDigits[0]='\0'; } + + /** IMSI initializer. */ + L3MobileIdentity(const char* wDigits) + :L3ProtocolElement(), + mType(IMSIType) + { assert(strlen(wDigits)<=15); strcpy(mDigits,wDigits); } + + /**@name Accessors. */ + //@{ + MobileIDType type() const { return mType; } + const char* digits() const { assert(mType!=TMSIType); return mDigits; } + unsigned int TMSI() const { assert(mType==TMSIType); return mTMSI; } + //@} + + /** Comparison. */ + bool operator==(const L3MobileIdentity&) const; + + /** Comparison. */ + bool operator!=(const L3MobileIdentity& other) const { return !operator==(other); } + + /** Comparison. */ + bool operator<(const L3MobileIdentity&) const; + + size_t lengthV() const; + void writeV(L3Frame& dest, size_t &wp) const; + void parseV( const L3Frame& src, size_t &rp, size_t expectedLength ); + void parseV(const L3Frame&, size_t&) { abort(); } + void text(std::ostream&) const; +}; + + + +/** + Mobile Station Classmark 1, GSM 04.08 10.5.1.5 +*/ +class L3MobileStationClassmark1 : public L3ProtocolElement { + + protected: + + unsigned mRevisionLevel; + unsigned mES_IND; + unsigned mA5_1; + unsigned mRFPowerCapability; + + public: + + size_t lengthV() const { return 1; } + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame &src, size_t &rp); + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void text(std::ostream&) const; + +}; + +/** + Mobile Station Classmark 2, GSM 04.08 10.5.1.5 +*/ +class L3MobileStationClassmark2 : public L3ProtocolElement { + + protected: + + unsigned mRevisionLevel; + unsigned mES_IND; + unsigned mA5_1; + unsigned mA5_3; + unsigned mA5_2; + unsigned mRFPowerCapability; + unsigned mPSCapability; + unsigned mSSScreenIndicator; + unsigned mSMCapability; + unsigned mVBS; + unsigned mVGCS; + unsigned mFC; + unsigned mCM3; + unsigned mLCSVACapability; + unsigned mSoLSA; + unsigned mCMSF; + + public: + + size_t lengthV() const { return 3; } + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame &src, size_t &rp); + void parseV(const L3Frame&, size_t&, size_t); + void text(std::ostream&) const; + + // These return true if the encryption type is supported. + bool A5_1() const { return mA5_1==0; } + bool A5_2() const { return mA5_2!=0; } + bool A5_3() const { return mA5_3!=0; } + + // Returns the power class, based on power capability encoding. + int powerClass() const { return mRFPowerCapability+1; } +}; + + +/** + Mobile Station Classmark 3, GSM 04.08 10.5.1.7 + FIXME -- We are only parsing the A5/x bits. +*/ +class L3MobileStationClassmark3 : public L3ProtocolElement { + + protected: + + unsigned mMultiband; + unsigned mA5_4; + unsigned mA5_5; + unsigned mA5_6; + unsigned mA5_7; + + public: + + L3MobileStationClassmark3() + :mA5_4(0),mA5_5(0),mA5_6(0),mA5_7(0) + { } + + size_t lengthV() const { return 14; } // HACK -- Return maximum length. + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame &, size_t &); + void parseV(const L3Frame&, size_t&, size_t); + void text(std::ostream&) const; + +}; + + + +class L3CipheringKeySequenceNumber : public L3ProtocolElement { + + protected: + + unsigned mCIValue; + + public: + + L3CipheringKeySequenceNumber(unsigned wCIValue): + mCIValue(wCIValue) + { } + + size_t lengthV() const { return 0; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame &, size_t &) { assert(0); } + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void text(std::ostream&) const; +}; + + + + +} // GSM + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3MMElements.cpp b/GSM/GSML3MMElements.cpp new file mode 100644 index 0000000..4a20b92 --- /dev/null +++ b/GSM/GSML3MMElements.cpp @@ -0,0 +1,251 @@ +/**@file + @brief Elements for Mobility Management messages, GSM 04.08 9.2. +*/ +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include +#include "GSML3MMElements.h" +#include + + +using namespace std; +using namespace GSM; + + +void L3CMServiceType::parseV(const L3Frame& src, size_t &rp) +{ + mType = (TypeCode)src.readField(rp,4); +} + + +ostream& GSM::operator<<(ostream& os, L3CMServiceType::TypeCode code) +{ + switch (code) { + case L3CMServiceType::MobileOriginatedCall: os << "MOC"; break; + case L3CMServiceType::EmergencyCall: os << "Emergency"; break; + case L3CMServiceType::ShortMessage: os << "SMS"; break; + case L3CMServiceType::SupplementaryService: os << "SS"; break; + case L3CMServiceType::VoiceCallGroup: os << "VGCS"; break; + case L3CMServiceType::VoiceBroadcast: os << "VBS"; break; + case L3CMServiceType::LocationService: os << "LCS"; break; + case L3CMServiceType::MobileTerminatedCall: os << "MTC"; break; + case L3CMServiceType::MobileTerminatedShortMessage: os << "MTSMS"; break; + case L3CMServiceType::TestCall: os << "Test"; break; + default: os << "?" << (int)code << "?"; + } + return os; +} + +void L3CMServiceType::text(ostream& os) const +{ + os << mType; +} + +void L3RejectCause::writeV( L3Frame& dest, size_t &wp ) const +{ + dest.writeField(wp, mRejectCause, 8); +} + + +void L3RejectCause::text(ostream& os) const +{ + os <<"0x"<< hex << mRejectCause << dec; +} + + + + + +void L3NetworkName::writeV(L3Frame& dest, size_t &wp) const +{ + unsigned sz = strlen(mName); + // header byte + if (mAlphabet == ALPHABET_UCS2) { + // Ext: 1b, coding scheme: 001b (UCS2), CI, trailing spare bits: 000b (0) + dest.writeField(wp,1,1); // ext bit + dest.writeField(wp,1,3); // coding scheme USC2 + dest.writeField(wp,mCI,1); // show country name? + dest.writeField(wp,0,3); // spare bits in last octet + // the characters + for (unsigned i=0; i + +namespace GSM { + +/** CM Service Type, GSM 04.08 10.5.3.3 */ +class L3CMServiceType : public L3ProtocolElement { + + public: + + enum TypeCode { + UndefinedType=0, + MobileOriginatedCall=1, + EmergencyCall=2, + ShortMessage=4, ///< specifically, MO-SMS + SupplementaryService=8, + VoiceCallGroup=9, + VoiceBroadcast=10, + LocationService=11, + MobileTerminatedCall=100, ///< non-standard code + MobileTerminatedShortMessage=101, ///< non-standard code + TestCall=102, ///< non-standard code + }; + + private: + + TypeCode mType; + + public: + + L3CMServiceType(TypeCode wType=UndefinedType) + :L3ProtocolElement(),mType(wType) + {} + + TypeCode type() const { return mType; } + + bool operator==(const L3CMServiceType& other) const + { return mType == other.mType; } + + size_t lengthV() const { return 0; } + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame &src, size_t &rp); + void parseV(const L3Frame&, size_t&, size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + +std::ostream& operator<<(std::ostream& os, L3CMServiceType::TypeCode code); + + +/** RejectCause, GSM 04.08 10.5.3.6 */ +class L3RejectCause : public L3ProtocolElement { + +private: + + int mRejectCause; + +public: + + L3RejectCause( const int wRejectCause=0 ) + :L3ProtocolElement(),mRejectCause(wRejectCause) + {} + + size_t lengthV() const { return 1; } + void writeV( L3Frame& dest, size_t &wp ) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + + + + +/** + Network Name, GSM 04.08 10.5.3.5a + This class supports UCS2 and 7-bit (default) encodings. +*/ +class L3NetworkName : public L3ProtocolElement { + + +private: + + static const unsigned maxLen=93; + GSMAlphabet mAlphabet; ///< Alphabet to use for encoding + char mName[maxLen+1]; ///< network name as a C string + int mCI; ///< CI (Country Initials) bit value + +public: + + /** Set the network name, taking the default from gConfig. */ + L3NetworkName(const char* wName, + GSMAlphabet alphabet=ALPHABET_7BIT, + int wCI=gConfig.defines("GSM.ShowCountry")) + :L3ProtocolElement(), mAlphabet(alphabet), mCI(wCI) + { strncpy(mName,wName,maxLen); mName[maxLen] = '\0'; } + + size_t lengthV() const + { + if (mAlphabet == ALPHABET_UCS2) + return 1+strlen(mName)*2; + else + return 1+(strlen(mName)*7+7)/8; + } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + +/** + Time & Time Zone, GSM 04.08 10.5.3.9, GSM 03.40 9.2.3.11. + This class is also used in SMS. +*/ +class L3TimeZoneAndTime : public L3ProtocolElement { +public: + enum TimeType { + LOCAL_TIME, ///< Used in SMS. Time is sent as local time. In this case + ///< timezone seems to be ignored by handsets (tested with + ///< Nokia DCT3, Siemens and Windows Mobile 6), but we still + ///< send it. + UTC_TIME ///< Used in MM Info message. Time is sent as UTC time. In + ///< this case phones seem to regard timezone information. + }; + +protected: + + Timeval mTime; + TimeType mType; + +public: + + /** Defaults from the current time. */ + L3TimeZoneAndTime(const Timeval& wTime = Timeval(), TimeType type = LOCAL_TIME) + :L3ProtocolElement(), + mTime(wTime), + mType(type) + {} + + const Timeval& time() const { return mTime; } + void time(const Timeval& wTime) { mTime=wTime; } + + TimeType type() const { return mType; } + void type(TimeType type) { mType=type; } + + size_t lengthV() const { return 7; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame& src, size_t &rp); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + + +/** GSM 04.08 10.5.3.1 */ +class L3RAND : public L3ProtocolElement { + + private: + + uint64_t mRUpper; ///< upper 64 bits + uint64_t mRLower; ///< lower 64 bits + + public: + + L3RAND(uint64_t wRUpper, uint64_t wRLower): + mRUpper(wRUpper),mRLower(wRLower) + { } + + size_t lengthV() const { return 16; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + + +/** GSM 04.08 10.5.3.2 */ +class L3SRES : public L3ProtocolElement { + + private: + + uint32_t mValue; + + public: + + L3SRES(uint32_t wValue): + mValue(wValue) + { } + + L3SRES():mValue(0) {} + + uint32_t value() const { return mValue; } + + size_t lengthV() const { return 4; } + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + + + +} // namespace GSM + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3MMMessages.cpp b/GSM/GSML3MMMessages.cpp new file mode 100644 index 0000000..96c3c2c --- /dev/null +++ b/GSM/GSML3MMMessages.cpp @@ -0,0 +1,347 @@ +/**@file + @brief GSM Mobility Management messages, from GSM 04.08 9.2. +*/ + +/* +* Copyright 2008-2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include + +#include "GSML3CommonElements.h" +#include "GSML3MMMessages.h" +#include + + +using namespace std; +using namespace GSM; + + + +ostream& GSM::operator<<(ostream& os, L3MMMessage::MessageType val) +{ + switch (val) { + case L3MMMessage::IMSIDetachIndication: + os << "IMSI Detach Indication"; break; + case L3MMMessage::CMServiceRequest: + os << "CM Service Request"; break; + case L3MMMessage::CMServiceAccept: + os << "CM Service Accept"; break; + case L3MMMessage::CMServiceReject: + os << "CM Service Reject"; break; + case L3MMMessage::CMServiceAbort: + os << "CM Service Abort"; break; + case L3MMMessage::CMReestablishmentRequest: + os << "CM Re-establishment Request"; break; + case L3MMMessage::IdentityResponse: + os << "Identity Response"; break; + case L3MMMessage::IdentityRequest: + os << "Identity Request"; break; + case L3MMMessage::MMInformation: + os << "MM Information"; break; + case L3MMMessage::LocationUpdatingAccept: + os << "Location Updating Accept"; break; + case L3MMMessage::LocationUpdatingReject: + os << "Location Updating Reject"; break; + case L3MMMessage::LocationUpdatingRequest: + os << "Location Updating Request"; break; + case L3MMMessage::MMStatus: + os << "MM Status"; break; + case L3MMMessage::AuthenticationRequest: + os << "Authentication Request"; break; + case L3MMMessage::AuthenticationResponse: + os << "Authentication Response"; break; + default: os << hex << "0x" << (int)val << dec; + } + return os; +} + + + + +L3MMMessage* GSM::L3MMFactory(L3MMMessage::MessageType MTI) +{ + switch (MTI) { + case L3MMMessage::LocationUpdatingRequest: return new L3LocationUpdatingRequest; + case L3MMMessage::IMSIDetachIndication: return new L3IMSIDetachIndication; + case L3MMMessage::CMServiceRequest: return new L3CMServiceRequest; + // Since we don't support re-establishment, don't bother parsing this. + //case L3MMMessage::CMReestablishmentRequest: return new L3CMReestablishmentRequest; + case L3MMMessage::MMStatus: return new L3MMStatus; + case L3MMMessage::IdentityResponse: return new L3IdentityResponse; + case L3MMMessage::AuthenticationResponse: return new L3AuthenticationResponse; + default: + LOG(WARNING) << "no L3 MM factory support for message " << MTI; + return NULL; + } +} + +L3MMMessage * GSM::parseL3MM(const L3Frame& source) +{ + L3MMMessage::MessageType MTI = (L3MMMessage::MessageType)(0xbf & source.MTI()); + LOG(DEBUG) << "parseL3MM MTI=" << MTI; + + L3MMMessage *retVal = L3MMFactory(MTI); + if (retVal==NULL) return NULL; + + retVal->parse(source); + return retVal; +} + + + +void L3MMMessage::text(ostream& os) const +{ + os << "MM " << (MessageType) MTI() << " "; +} + + +void L3LocationUpdatingRequest::parseBody( const L3Frame &src, size_t &rp ) +{ + // skip updating type + rp += 4; + // skip ciphering ket sequence number + rp += 4; + mLAI.parseV(src,rp); + mClassmark.parseV(src,rp); + mMobileIdentity.parseLV(src, rp); +} + + +void L3LocationUpdatingRequest::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "LAI=("<"; +} + + +size_t L3MMInformation::l2BodyLength() const +{ + size_t len=0; + if (mShortName.lengthV()>1) len += mShortName.lengthTLV(); + len += mTime.lengthTV(); + return len; +} + + +void L3MMInformation::writeBody(L3Frame &dest, size_t &wp) const +{ + if (mShortName.lengthV()>1) mShortName.writeTLV(0x45,dest,wp); + mTime.writeTV(0x47,dest,wp); +} + + +void L3MMInformation::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "short name=(" << mShortName << ")"; + os << " time=(" << mTime << ")"; +} + + +void L3IdentityRequest::writeBody(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,0,4); // spare half octet + dest.writeField(wp,mType,4); +} + + +void L3IdentityRequest::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "type=" << mType; +} + + + +void L3IdentityResponse::parseBody(const L3Frame& src, size_t& rp) +{ + mMobileID.parseLV(src,rp); +} + +void L3IdentityResponse::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "mobile id=" << mMobileID; +} + + + +void L3AuthenticationRequest::writeBody(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,0,4); // spare half octet + mCipheringKeySequenceNumber.writeV(dest,wp); + mRAND.writeV(dest,wp); +} + +void L3AuthenticationRequest::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "cksn=" << mCipheringKeySequenceNumber; + os << " RAND=" << mRAND; +} + + + +void L3AuthenticationResponse::parseBody(const L3Frame& src, size_t& rp) +{ + mSRES.parseV(src,rp); +} + +void L3AuthenticationResponse::text(ostream& os) const +{ + L3MMMessage::text(os); + os << "SRES=" << mSRES; +} + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3MMMessages.h b/GSM/GSML3MMMessages.h new file mode 100644 index 0000000..ea13eb0 --- /dev/null +++ b/GSM/GSML3MMMessages.h @@ -0,0 +1,459 @@ +/**@file @brief Mobility Management messages, GSM 04.08 9.2. */ +/* +* Copyright 2008 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef GSML3MMMESSAGES_H +#define GSML3MMMESSAGES_H + +#include "GSMCommon.h" +#include "GSML3Message.h" +#include "GSML3CommonElements.h" +#include "GSML3MMElements.h" + + + +namespace GSM { + + + +/** + This a virtual class for L3 messages in the Mobility Management protocol. + These messages are defined in GSM 04.08 9.2 +*/ + +class L3MMMessage : public L3Message { + + public: + + /** + Message type codes for mobility management messages in L3, GSM 04.08, Table 10.2. + Note that bit 6 (MSB-less-1) is a "don't care" for these codes. + */ + enum MessageType { + IMSIDetachIndication=0x01, + CMServiceAccept=0x21, + CMServiceReject=0x22, + CMServiceAbort=0x23, + CMServiceRequest=0x24, + CMReestablishmentRequest=0x28, + IdentityResponse=0x19, + IdentityRequest=0x18, + MMInformation=0x32, + LocationUpdatingAccept=0x02, + LocationUpdatingReject=0x04, + LocationUpdatingRequest=0x08, + TMSIReallocationCommand=0x1a, + MMStatus=0x31, + AuthenticationRequest=0x12, + AuthenticationResponse=0x14, + AuthenticationReject=0x11, + Undefined=-1 + }; + + + L3MMMessage():L3Message() {} + + size_t fullBodyLength() const { return l2BodyLength(); } + + /** Return the L3 protocol discriptor. */ + L3PD PD() const { return L3MobilityManagementPD; } + + void text(std::ostream&) const; +}; + + + +std::ostream& operator<<(std::ostream& os, L3MMMessage::MessageType val); + + + +/** + A Factory function to return a L3MMMessage of the specified MTI. + Returns NULL if the MTI is not supported. +*/ +L3MMMessage* L3MMFactory(L3MMMessage::MessageType MTI); + +/** + Parse a complete L3 mobility management message into its object type. + @param source The L3 bits. + @return A pointer to a new message or NULL on failure. +*/ +L3MMMessage* parseL3MM(const L3Frame& source); + + + + +/** GSM 04.08 9.2.15 */ +class L3LocationUpdatingRequest : public L3MMMessage +{ + L3MobileStationClassmark1 mClassmark; + L3MobileIdentity mMobileIdentity; // (LV) 1+len + L3LocationAreaIdentity mLAI; + +public: + L3LocationUpdatingRequest():L3MMMessage() {} + + const L3MobileIdentity& mobileID() const + { return mMobileIdentity; } + const L3LocationAreaIdentity& LAI() const + { return mLAI; } + + int MTI() const { return (int)LocationUpdatingRequest; } + + size_t l2BodyLength() const; + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; +}; + + + +/** GSM 04.08 9.2.13 */ +class L3LocationUpdatingAccept : public L3MMMessage +{ + // LAI = (V) length of 6 + L3LocationAreaIdentity mLAI; + bool mHaveMobileIdentity; + L3MobileIdentity mMobileIdentity; + +public: + + L3LocationUpdatingAccept(const L3LocationAreaIdentity& wLAI) + :L3MMMessage(),mLAI(wLAI), + mHaveMobileIdentity(false) + {} + + L3LocationUpdatingAccept( + const L3LocationAreaIdentity& wLAI, + const L3MobileIdentity& wMobileIdentity) + :L3MMMessage(),mLAI(wLAI), + mHaveMobileIdentity(true), + mMobileIdentity(wMobileIdentity) + {} + + int MTI() const { return (int)LocationUpdatingAccept; } + + size_t l2BodyLength() const; + void writeBody( L3Frame &src, size_t &rp ) const; + void text(std::ostream&) const; + +}; + + +class L3MMStatus : public L3MMMessage +{ + L3RejectCause mRejectCause; + +public: + L3MMStatus() : L3MMMessage(){} + + int MTI() const { return (int) MMStatus; } + + size_t l2BodyLength() const { return 3; } + void parseBody( const L3Frame& src, size_t &rp ); + void text(std::ostream&) const; + +}; + + + + +/** GSM 04.08 9.2.14 */ +class L3LocationUpdatingReject : public L3MMMessage +{ + L3RejectCause mRejectCause; + +public: + + L3LocationUpdatingReject(const L3RejectCause& cause) + :L3MMMessage(),mRejectCause(cause) + {} + + int MTI() const { return (int)LocationUpdatingReject; } + + size_t l2BodyLength() const { return mRejectCause.lengthV(); } + void writeBody( L3Frame &dest, size_t &wp ) const; + void text(std::ostream&) const; + +}; + + + +/** GSM 04.08 9.2.12 */ +class L3IMSIDetachIndication : public L3MMMessage { + + private: + + L3MobileStationClassmark1 mClassmark; + L3MobileIdentity mMobileIdentity; + + public: + + const L3MobileIdentity& mobileID() const + { return mMobileIdentity; } + + int MTI() const { return (int)IMSIDetachIndication; } + + size_t l2BodyLength() const { return 1 + mMobileIdentity.lengthLV(); } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + +}; + + +/** GSM 04.08 9.2.5 */ +class L3CMServiceAccept : public L3MMMessage { + + public: + + int MTI() const { return (int)CMServiceAccept; } + + size_t l2BodyLength() const { return 0; } + void writeBody( L3Frame &dest, size_t &wp ) const {} +}; + + + +/** GSM 04.08 9.2.7 */ +class L3CMServiceAbort : public L3MMMessage { + + public: + + int MTI() const { return (int)CMServiceAbort; } + + size_t l2BodyLength() const { return 0; } + void writeBody( L3Frame &dest, size_t &wp ) const {} + void parseBody( const L3Frame &src, size_t &rp ); +}; + + + +/** GSM 04.08 9.2.6 */ +class L3CMServiceReject : public L3MMMessage { + + private: + + L3RejectCause mCause; + + public: + + L3CMServiceReject(const L3RejectCause& wCause) + :L3MMMessage(), + mCause(wCause) + {} + + int MTI() const { return (int)CMServiceReject; } + + size_t l2BodyLength() const { return mCause.lengthV(); } + void writeBody( L3Frame &dest, size_t &wp ) const; + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.2.9 */ +class L3CMServiceRequest : public L3MMMessage +{ + L3MobileStationClassmark2 mClassmark; + L3MobileIdentity mMobileIdentity; + L3CMServiceType mServiceType; + +public: + + L3CMServiceRequest() + :L3MMMessage(), + mServiceType() + { } + + /** Accessors */ + //@{ + const L3CMServiceType& serviceType() const { return mServiceType; } + + const L3MobileIdentity& mobileID() const + { return mMobileIdentity; } + //@} + + int MTI() const { return (int)CMServiceRequest; } + + // (1/2) + (1/2) + 4 + + size_t l2BodyLength() const { return 5+mMobileIdentity.lengthLV(); } + + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; +}; + + + +/** GSM 04.08 9.2.4 */ +class L3CMReestablishmentRequest : public L3MMMessage { + + private: + + L3MobileStationClassmark2 mClassmark; + L3MobileIdentity mMobileID; + bool mHaveLAI; + L3LocationAreaIdentity mLAI; + + public: + + L3CMReestablishmentRequest() + :L3MMMessage(), + mHaveLAI(false) + {} + + const L3MobileIdentity& mobileID() const { return mMobileID; } + + int MTI() const { return (int)CMReestablishmentRequest; } + + size_t l2BodyLength() const { return 1 + 4 + mMobileID.lengthLV(); } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.2.15a */ +class L3MMInformation : public L3MMMessage { + + private: + + L3NetworkName mShortName; + L3TimeZoneAndTime mTime; + + public: + + /** + Constructor. + @param wShortName Abbreviated network name. + */ + L3MMInformation(const L3NetworkName& wShortName, const L3TimeZoneAndTime& wTime=L3TimeZoneAndTime()) + :L3MMMessage(), + mShortName(wShortName), mTime(wTime) + { + mTime.type(L3TimeZoneAndTime::UTC_TIME); + } + + int MTI() const { return (int)MMInformation; } + + size_t l2BodyLength() const; + void writeBody(L3Frame&,size_t&) const; + void text(std::ostream&) const; +}; + + +/** Identity Request, GSM 04.08 9.2.10 */ +class L3IdentityRequest : public L3MMMessage { + + private: + + MobileIDType mType; + + public: + + L3IdentityRequest(MobileIDType wType) + :L3MMMessage(),mType(wType) + {} + + int MTI() const { return IdentityRequest; } + + size_t l2BodyLength() const { return 1; } + void writeBody(L3Frame& dest, size_t& wp) const; + void text(std::ostream&) const; +}; + + + +/** Identity Response, GSM 04.08 9.2.11 */ +class L3IdentityResponse : public L3MMMessage { + + private : + + L3MobileIdentity mMobileID; + + public: + + int MTI() const { return IdentityResponse; } + + size_t l2BodyLength() const { return mMobileID.lengthLV(); } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + + const L3MobileIdentity& mobileID() const { return mMobileID; } +}; + + +/** GSM 04.08 9.2.2 */ +class L3AuthenticationRequest : public L3MMMessage { + + private: + + L3CipheringKeySequenceNumber mCipheringKeySequenceNumber; + L3RAND mRAND; + + public: + + L3AuthenticationRequest( + const L3CipheringKeySequenceNumber &wCipheringKeySequenceNumber, + const L3RAND &wRAND + ): + mCipheringKeySequenceNumber(wCipheringKeySequenceNumber), + mRAND(wRAND) + { } + + int MTI() const { return AuthenticationRequest; } + + size_t l2BodyLength() const { return 1 + mRAND.lengthV(); } + void writeBody(L3Frame&, size_t &wp) const; + void text(std::ostream&) const; +}; + +/** GSM 04.08 9.2.3 */ +class L3AuthenticationResponse : public L3MMMessage { + + private: + + L3SRES mSRES; + + public: + + int MTI() const { return AuthenticationResponse; } + + const L3SRES& SRES() const { return mSRES; } + + size_t l2BodyLength() const { return mSRES.lengthV(); } + void parseBody(const L3Frame&, size_t &rp); + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.2.1 */ +class L3AuthenticationReject : public L3MMMessage { + + public: + + int MTI() const { return AuthenticationReject; } + + size_t l2BodyLength() const { return 0; } + void writeBody(L3Frame&, size_t &wp) const { } +}; + + + +}; // namespace GSM + +#endif //#ifndef GSML3MM_H + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3Message.cpp b/GSM/GSML3Message.cpp new file mode 100644 index 0000000..89827d5 --- /dev/null +++ b/GSM/GSML3Message.cpp @@ -0,0 +1,264 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "GSML3Message.h" +#include "GSML3RRMessages.h" +#include "GSML3MMMessages.h" +#include "GSML3CCMessages.h" +#include + + +//#include +#include +//using namespace SMS; + + +using namespace std; +using namespace GSM; + + + +// FIXME -- We actually should not be using this anymore. +void L3Message::parse(const L3Frame& source) +{ + size_t rp = 16; + parseBody(source,rp); +} + + +void L3Message::write(L3Frame& dest) const +{ + size_t l3len = bitsNeeded(); + if (dest.size()!=l3len) dest.resize(l3len); + size_t wp = 0; + // write the standard L3 header + dest.writeField(wp,0,4); + dest.writeField(wp,PD(),4); + dest.writeField(wp,MTI(),8); + // write the body + writeBody(dest,wp); + // set the L2 length or pseudolength + dest.L2Length(L2Length()); +} + + +L3Frame* L3Message::frame( Primitive prim ) const +{ + L3Frame *newFrame = new L3Frame(prim, bitsNeeded()); + write(*newFrame); + return newFrame; +} + + + +void L3Message::text(ostream& os) const +{ + os << "PD=" << PD(); + os << " MTI=" << MTI(); +} + + + + + + +size_t GSM::skipLV(const L3Frame& source, size_t& rp) +{ + if (rp==source.size()) return 0; + size_t base = rp; + size_t length = 8 * source.readField(rp,8); + rp += length; + return rp-base; +} + + +size_t GSM::skipTLV(unsigned IEI, const L3Frame& source, size_t& rp) +{ + if (rp==source.size()) return 0; + size_t base = rp; + unsigned thisIEI = source.peekField(rp,8); + if (thisIEI != IEI) return 0; + rp += 8; + size_t length = 8 * source.readField(rp,8); + rp += length; + return rp-base; +} + + +size_t GSM::skipTV(unsigned IEI, size_t numBits, const L3Frame& source, size_t& rp) +{ + if (rp==source.size()) return 0; + size_t base = rp; + size_t IEISize; + if (numBits>4) IEISize=8; + else IEISize=4; + unsigned thisIEI = source.peekField(rp,IEISize); + if (thisIEI != IEI) return 0; + rp += IEISize; + rp += numBits; + return rp-base; +} + + + +ostream& GSM::operator<<(ostream& os, const L3Message& msg) +{ + msg.text(os); + return os; +} + + + + + + + + +GSM::L3Message* GSM::parseL3(const GSM::L3Frame& source) +{ + if (source.size()==0) return NULL; + + LOG(DEBUG) << "GSM::parseL3 "<< source; + L3PD PD = source.PD(); + + L3Message *retVal = NULL; + try { + switch (PD) { + case L3RadioResourcePD: retVal=parseL3RR(source); break; + case L3MobilityManagementPD: retVal=parseL3MM(source); break; + case L3CallControlPD: retVal=parseL3CC(source); break; + case L3SMSPD: retVal=SMS::parseSMS(source); break; + default: + LOG(NOTICE) << "L3 parsing failed for unsupported protocol " << PD; + return NULL; + } + } + catch (L3ReadError) { + LOG(NOTICE) << "L3 parsing failed for " << source; + return NULL; + } + + if (retVal) LOG(INFO) << "L3 recv " << *retVal; + return retVal; +} + + + + + +void L3ProtocolElement::parseLV(const L3Frame& source, size_t &rp) +{ + size_t expectedLength = source.readField(rp,8); + if (expectedLength==0) return; + size_t rpEnd = rp + 8*expectedLength; + parseV(source, rp, expectedLength); + if (rpEnd != rp) { + LOG(NOTICE) << "LV element does not match expected length"; + L3_READ_ERROR; + } +} + + +bool L3ProtocolElement::parseTV(unsigned IEI, const L3Frame& source, size_t &rp) +{ + if (rp==source.size()) return false; + if (lengthV()==0) { + unsigned thisIEI = source.peekField(rp,4); + if (thisIEI!=IEI) return false; + rp += 4; + parseV(source,rp); + return true; + } + + unsigned thisIEI = source.peekField(rp,8); + if (thisIEI!=IEI) return false; + rp += 8; + parseV(source,rp); + return true; +} + + + +bool L3ProtocolElement::parseTLV(unsigned IEI, const L3Frame& source, size_t &rp) +{ + if (rp==source.size()) return false; + unsigned thisIEI = source.peekField(rp,8); + if (thisIEI!=IEI) return false; + rp += 8; + parseLV(source,rp); + return true; +} + + + + +void L3ProtocolElement::writeLV(L3Frame& dest, size_t &wp) const +{ + unsigned len = lengthV(); + dest.writeField(wp, len, 8); + if (len) writeV(dest, wp); +} + +void L3ProtocolElement::writeTLV(unsigned IEI, L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,IEI,8); + writeLV(dest,wp); +} + +void L3ProtocolElement::writeTV(unsigned IEI, L3Frame& dest, size_t &wp) const +{ + if (lengthV()==0) { + dest.writeField(wp,IEI,4); + writeV(dest,wp); + return; + } + dest.writeField(wp,IEI,8); + writeV(dest,wp); +} + + +void L3ProtocolElement::skipExtendedOctets( const L3Frame& source, size_t &rp ) +{ + if (rp==source.size()) return; + int endbit = 0; + while(!endbit){ + endbit = source.readField(rp, 1); + rp += 7; + } +} + + + +ostream& GSM::operator<<(ostream& os, const L3ProtocolElement& elem) +{ + elem.text(os); + return os; +} + + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3Message.h b/GSM/GSML3Message.h new file mode 100644 index 0000000..f17a986 --- /dev/null +++ b/GSM/GSML3Message.h @@ -0,0 +1,302 @@ +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef GSML3MESSAGE_H +#define GSML3MESSAGE_H + +#include "GSMCommon.h" +#include "GSMTransfer.h" + +namespace GSM { + + +/**@name L3 Processing Errors */ +//@{ + +class L3ReadError : public GSMError { + public: + L3ReadError():GSMError() {} +}; +#define L3_READ_ERROR {throw L3ReadError();} + +class L3WriteError : public GSMError { + public: + L3WriteError():GSMError() {} +}; +#define L3_WRITE_ERROR {throw L3WriteError();} + +//@} + + + +/** + This is virtual base class for the messages of GSM's L3 signalling layer. + It defines almost nothing, but is the origination of other classes. +*/ +class L3Message { + + public: + + virtual ~L3Message() {} + + /** Return the expected message body length in bytes, not including L3 header or rest octets. */ + virtual size_t l2BodyLength() const = 0; + + /** + Body length not including header but including rest octets. + In subclasses with no rest octets, this returns l2BodyLength. + */ + virtual size_t fullBodyLength() const =0; + + /** Return the expected message length in bytes, including L3 header, but not including rest octets. */ + size_t L2Length() const { return l2BodyLength()+2; } + + /** Length including header and rest octets. */ + size_t FullLength() const { return fullBodyLength()+2; } + + /** Return number of BITS needed to hold message and header. */ + size_t bitsNeeded() const { return 8*FullLength(); } + + /** + The parse() method reads and decodes L3 message bits. + This method invokes parseBody, assuming that the L3 header + has already been read. + */ + virtual void parse(const L3Frame& source); + + /** + Write message PD, MTI and data bits into a BitVector buffer. + This method invokes writeBody. + This method is overridden in the CC protocol. + */ + virtual void write(L3Frame& dest) const; + + /** + Generate an L3Frame for this message. + The caller is responsible for deleting the memory. + */ + L3Frame* frame(GSM::Primitive prim=DATA) const; + + /** Return the L3 protocol discriptor. */ + virtual GSM::L3PD PD() const =0; + + /** Return the messag type indicator (MTI). */ + virtual int MTI() const =0; + + + protected: + + /** + Write the L3 message body, a method defined in some subclasses. + If not defined, this will assert at runtime. + */ + virtual void writeBody(L3Frame& dest, size_t &writePosition) const; + + /** + The parseBody() method starts processing at the first byte following the + message type octet in the L3 message, which the caller indicates with the + readPosition argument. + If not defined, this will assert at runtime. + */ + virtual void parseBody(const L3Frame& source, size_t &readPosition); + + + public: + + /** Generate a human-readable representation of a message. */ + virtual void text(std::ostream& os) const; + +}; + + + + +/**@name Utility functions for message parsers. */ +//@{ +/** + Skip an unused LV element while parsing. + @return number of bits skipped. +*/ +size_t skipLV(const L3Frame& source, size_t &readPosition); + +/** + Skip an unused TLV element while parsing. + @return number of bits skipped. +*/ +size_t skipTLV(unsigned IEI, const L3Frame& source, size_t &readPosition); + +/** + Skip an unused TV element while parsing. + @return number of bits skipped. +*/ +size_t skipTV(unsigned IEI, size_t numBits, const L3Frame& source, size_t &readPosition); +//@} + + + + +/** + Parse a complete L3 message into its object type. + Caller is responsible for deleting allocated memory. + @param source The L3 bits. + @return A pointer to a new message or NULL on failure. +*/ +L3Message* parseL3(const L3Frame& source); + + +std::ostream& operator<<(std::ostream& os, const GSM::L3Message& msg); + + + + + + +/** + Abstract class used for GSM L3 information elements. + See GSM 04.07 11.2.1.1.4 for a description of TLV element formatting. + To quote the spec, four categories of standard information elements are defined: + - information elements of format V or TV with value part consisting of 1/2 octet (type 1); + - information elements of format T with value part consisting of 0 octets (type 2); + - information elements of format V or TV with value part that has fixed length of at least one octet (type 3); + - information elements of format TLV or LV with value part consisting of zero, one or more octets (type 4); + +*/ +class L3ProtocolElement { + + public: + + virtual ~L3ProtocolElement() {} + + + /** + Return the length of the value part of the element in bytes. + This is the core length method, referenced by all other length methods. + Return zero for 1/2 octet fields (type 1 elements). + */ + virtual size_t lengthV() const =0; + + size_t lengthTV() const { return lengthV() + 1; } + + size_t lengthLV() const { return lengthV() + 1; } + + size_t lengthTLV() const { return lengthLV() + 1; } + + + /** + The parseV method decodes L3 message bits from fixed-length value parts. + This is the core parse method for fixed-length parsable elements and + all other parse methods use it. + @param src The L3Frame to be parsed. + @param rp Bit index of read position (updated by read). + */ + virtual void parseV(const L3Frame& src, size_t &rp ) =0; + + /** + The parseV method decodes L3 message bits from variable-length value parts. + This is the core parse method for variable-length parsable elements and + all other parse methods use it. + @param src The L3Frame to be parsed. + @param rp Bit index of read position (updated by read). + @param expectedLength Length of available field, in bytes. + */ + virtual void parseV(const L3Frame& src, size_t &rp, size_t expectedLength) =0; + + + /** + Parse LV format. + @param src The L3Frame to be parsed. + @param rp Bit index of read position (updated by read). + */ + void parseLV(const L3Frame& src, size_t &rp); + + /** + Parse TV format. + @param IEI The expected T part value. + @param src The L3Frame to be parsed. + @param rp Bit index of read position (updated by read). + @return true if the IEI matched and the element was actually read. + */ + bool parseTV(unsigned IEI, const L3Frame& src, size_t &rp); + + /** + Parse TLV format. + @param IEI The expected T part value. + @param src The L3Frame to be parsed. + @param rp read index (updated by read). + @return true if the IEI matched and the element was actually read. + */ + bool parseTLV(unsigned IEI, const L3Frame& src, size_t &rp); + + /** + Write the V format. + This is the core write method for writable elements and + all other write methods use it. + @param dest The target L3Frame. + @param wp The write index (updated by write). + */ + virtual void writeV(L3Frame& dest, size_t &wp) const =0; + + /** + Write LV format. + @param dest The target L3Frame. + @param wp The write index (updated by write). + */ + void writeLV(L3Frame& dest, size_t &wp) const; + + /** + Write TV format. + @param IEI The "information element identifier", ie, the T part. + @param dest The target buffer. + @param wp The buffer write pointer (updated by write). + */ + void writeTV(unsigned IEI, L3Frame& dest, size_t &wp) const; + + /** + Write TLV format. + @param IEI The "information element identifier", the T part. + @param dest The target L3Frame. + @param wp The write index (updated by write). + */ + void writeTLV(unsigned IEI, L3Frame& dest, size_t &wp) const; + + /** Generate a human-readable form of the element. */ + virtual void text(std::ostream& os) const + { os << "(no text())"; } + + + protected: + + /** + Skip over all unsupported extended octets in elements that use extension bits. + @param src The L3Frame to skip along. + @param rp The read pointer. + */ + void skipExtendedOctets( const L3Frame& src, size_t &rp ); + + +}; + + +std::ostream& operator<<(std::ostream& os, const L3ProtocolElement& elem); + + +}; // GSM + + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSML3RRElements.cpp b/GSM/GSML3RRElements.cpp new file mode 100644 index 0000000..33d4549 --- /dev/null +++ b/GSM/GSML3RRElements.cpp @@ -0,0 +1,715 @@ +/**@file + @brief Radio Resource messages, GSM 04.08 9.1. +*/ + +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include // for L3APDUData::text + +#include "GSML3RRElements.h" + +#include + + + +using namespace std; +using namespace GSM; + + + + +void L3CellOptionsBCCH::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,0,1); + dest.writeField(wp,mPWRC,1); + dest.writeField(wp,mDTX,2); + dest.writeField(wp,mRADIO_LINK_TIMEOUT,4); +} + + + +void L3CellOptionsBCCH::text(ostream& os) const +{ + os << "PWRC=" << mPWRC; + os << " DTX=" << mDTX; + os << " RADIO_LINK_TIMEOUT=" << mRADIO_LINK_TIMEOUT; +} + + + +void L3CellOptionsSACCH::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,(mDTX>>2)&0x01,1); + dest.writeField(wp,mPWRC,1); + dest.writeField(wp,mDTX&0x03,2); + dest.writeField(wp,mRADIO_LINK_TIMEOUT,4); +} + + + +void L3CellOptionsSACCH::text(ostream& os) const +{ + os << "PWRC=" << mPWRC; + os << " DTX=" << mDTX; + os << " RADIO_LINK_TIMEOUT=" << mRADIO_LINK_TIMEOUT; +} + + + +void L3CellSelectionParameters::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,mCELL_RESELECT_HYSTERESIS,3); + dest.writeField(wp,mMS_TXPWR_MAX_CCH,5); + dest.writeField(wp,mACS,1); + dest.writeField(wp,mNECI,1); + dest.writeField(wp,mRXLEV_ACCESS_MIN,6); +} + + + + +void L3CellSelectionParameters::text(ostream& os) const +{ + os << "CELL-RESELECT-HYSTERESIS=" << mCELL_RESELECT_HYSTERESIS; + os << " MS-TXPWR-MAX-CCH=" << mMS_TXPWR_MAX_CCH; + os << " ACS=" << mACS; + os << " NECI=" << mNECI; + os << " RXLEV-ACCESS-MIN=" << mRXLEV_ACCESS_MIN; +} + + + + + + + +void L3ControlChannelDescription::writeV(L3Frame& dest, size_t &wp) const +{ + dest.writeField(wp,0,1); + dest.writeField(wp,mATT,1); + dest.writeField(wp,mBS_AG_BLKS_RES,3); + dest.writeField(wp,mCCCH_CONF,3); + dest.writeField(wp,0,5); + dest.writeField(wp,mBS_PA_MFRMS,3); + dest.writeField(wp,mT3212,8); +} + + + +void L3ControlChannelDescription::text(ostream& os) const +{ + os << "ATT=" << mATT; + os << " BS_AG_BLKS_RES=" << mBS_AG_BLKS_RES; + os << " CCCH_CONF=" << mCCCH_CONF; + os << " BS_PA_MFRMS=" << mBS_PA_MFRMS; + os << " T3212=" << mT3212; +} + + +bool L3FrequencyList::contains(unsigned wARFCN) const +{ + for (unsigned i=0; imax) max=mARFCNs[i]; + } + return max - base(); +} + + +void L3FrequencyList::writeV(L3Frame& dest, size_t &wp) const +{ + // If this were used as Frequency List, it had to be coded + // as the variable bit map format, GSM 04.08 10.5.2.13.7. + // But it is used as Cell Channel Description and is coded + // as the variable bit map format, GSM 04.08 10.5.2.1b.7. + // Difference is in abscence of Length field. + + // The header occupies first 7 most significant bits of + // the first V-part octet and should be 1000111b=0x47 for + // the variable length bitmap. + dest.writeField(wp,0x47,7); + + // base ARFCN + unsigned baseARFCN = base(); + dest.writeField(wp,baseARFCN,10); + // bit map + unsigned delta = spread(); + unsigned numBits = 8*lengthV() - 17; + if (numBits output( os, "" ); + //std::copy( mData.begin(), mData.end(), output ); + for (size_t i = 0 ; i < mData.size() ; ++i) { + os << (mData[i] ? "1" : "0"); + } + +} + + +void L3MeasurementResults::parseV(const L3Frame& frame, size_t &rp) +{ + // GSM 04.08 10.5.2.20 + mBA_USED = frame.readField(rp,1); + mDTX_USED = frame.readField(rp,1); + mRXLEV_FULL_SERVING_CELL = frame.readField(rp,6); + rp++; // spare + mMEAS_VALID = frame.readField(rp,1); + mRXLEV_SUB_SERVING_CELL = frame.readField(rp,6); + rp++; // spare + mRXQUAL_FULL_SERVING_CELL = frame.readField(rp,3); + mRXQUAL_SUB_SERVING_CELL = frame.readField(rp,3); + mNO_NCELL = frame.readField(rp,3); + for (unsigned i=0; i<6; i++) { + mRXLEV_NCELL[i] = frame.readField(rp,6); + mBCCH_FREQ_NCELL[i] = frame.readField(rp,5); + mBSIC_NCELL[i] = frame.readField(rp,6); + } +} + + +void L3MeasurementResults::text(ostream& os) const +{ + // GSM 04.08 10.5.2.20 + os << "BA_USED=" << mBA_USED; + os << " DTX_USED=" << mDTX_USED; + os << " MEAS_VALID=" << mMEAS_VALID; + // Note that the value of the MEAS-VALID bit is reversed + // from what you might expect. + if (mMEAS_VALID) return; + os << " RXLEV_FULL_SERVING_CELL=" << mRXLEV_FULL_SERVING_CELL; + os << " RXLEV_SUB_SERVING_CELL=" << mRXLEV_SUB_SERVING_CELL; + os << " RXQUAL_FULL_SERVING_CELL=" << mRXQUAL_FULL_SERVING_CELL; + os << " RXQUAL_SUB_SERVING_CELL=" << mRXQUAL_SUB_SERVING_CELL; + os << " NO_NCELL=" << mNO_NCELL; + // no measurements? + if (mNO_NCELL==0) return; + // no neighbor list? + if (mNO_NCELL==7) return; + for (unsigned i=0; i + + +namespace GSM { + + +/** Cell Options (BCCH), GSM 04.08 10.5.2.3 */ +class L3CellOptionsBCCH : public L3ProtocolElement { + + private: + + unsigned mPWRC; ///< 1 -> downlink power control may be used + unsigned mDTX; ///< discontinuous transmission state + unsigned mRADIO_LINK_TIMEOUT; ///< timeout to declare dead phy link + + public: + + /** Sets defaults for no use of DTX or downlink power control. */ + L3CellOptionsBCCH() + :L3ProtocolElement() + { + // Values dictated by the current implementation are hard-coded. + mPWRC=0; + mDTX=2; + // Configuarable values. + mRADIO_LINK_TIMEOUT= gConfig.getNum("GSM.RADIO-LINK-TIMEOUT"); + } + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; +}; + + + + +/** Cell Options (SACCH), GSM 04.08 10.5.2.3a */ +class L3CellOptionsSACCH : public L3ProtocolElement { + + private: + + unsigned mPWRC; ///< 1 -> downlink power control may be used + unsigned mDTX; ///< discontinuous transmission state + unsigned mRADIO_LINK_TIMEOUT; ///< timeout to declare dead phy link + + public: + + /** Sets defaults for no use of DTX or downlink power control. */ + L3CellOptionsSACCH() + :L3ProtocolElement() + { + // Values dictated by the current implementation are hard-coded. + mPWRC=0; + mDTX=2; + // Configuarable values. + mRADIO_LINK_TIMEOUT=gConfig.getNum("GSM.RADIO-LINK-TIMEOUT"); + } + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + + +/** Cell Selection Parameters, GSM 04.08 10.5.2.4 */ +class L3CellSelectionParameters : public L3ProtocolElement { + + private: + + unsigned mACS; + unsigned mNECI; + unsigned mCELL_RESELECT_HYSTERESIS; + unsigned mMS_TXPWR_MAX_CCH; + unsigned mRXLEV_ACCESS_MIN; + + public: + + /** Sets defaults to reduce gratuitous handovers. */ + L3CellSelectionParameters() + :L3ProtocolElement() + { + // Values dictated by the current implementation are hard-coded. + mACS=0; // We don't support SI16 & SI17 yet. + // Configurable values. + mNECI=gConfig.getNum("GSM.CellSelection.NECI"); + mMS_TXPWR_MAX_CCH=gConfig.getNum("GSM.CellSelection.MS-TXPWR-MAX-CCH"); + mRXLEV_ACCESS_MIN=gConfig.getNum("GSM.CellSelection.RXLEV-ACCESS-MIN"); + mCELL_RESELECT_HYSTERESIS=gConfig.getNum("GSM.CellSelection.CELL-RESELECT-HYSTERESIS"); + } + + size_t lengthV() const { return 2; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + +/** Control Channel Description, GSM 04.08 10.5.2.11 */ +class L3ControlChannelDescription : public L3ProtocolElement { + + private: + + unsigned mATT; ///< 1 -> IMSI attach/detach + unsigned mBS_AG_BLKS_RES; ///< access grant channel reservation + unsigned mCCCH_CONF; ///< channel combination for CCCH + unsigned mBS_PA_MFRMS; ///< paging channel configuration + unsigned mT3212; ///< periodic updating timeout + + public: + + /** Sets reasonable defaults for a single-ARFCN system. */ + L3ControlChannelDescription():L3ProtocolElement() + { + // Values dictated by the current implementation are hard-coded. + mBS_AG_BLKS_RES=2; // reserve 2 CCCHs for access grant + mBS_PA_MFRMS=0; // minimum PCH spacing + // Configurable values. + mATT=(unsigned)gConfig.defines("Control.LUR.AttachDetach"); + mCCCH_CONF=gConfig.getNum("GSM.CCCH.CCCH-CONF"); + mT3212=gConfig.getNum("GSM.Timer.T3212")/6; + } + + size_t lengthV() const { return 3; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** + A generic frequency list element base class, GSM 04.08 10.5.2.13. + This implementation supports only the "variable bit map" format + (GSM 04.08 10.5.2.13.7). +*/ +class L3FrequencyList : public L3ProtocolElement { + + protected: + + std::vector mARFCNs; ///< ARFCN list to encode/decode + + public: + + /** Default constructor creates an empty list. */ + L3FrequencyList():L3ProtocolElement() {} + + L3FrequencyList(const std::vector& wARFCNs) + :L3ProtocolElement(), + mARFCNs(wARFCNs) + {} + + //void push_back(unsigned ARFCN) { mARFCNs.push_back(ARFCN); } + void ARFCNs(const std::vector& wARFCNs) { mARFCNs=wARFCNs; } + const std::vector& ARFCNs() const { return mARFCNs; } + + size_t lengthV() const { return 16; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + + private: + + /**@name ARFCN set browsing. */ + //@{ + /** Return minimum-numbered ARFCN. */ + unsigned base() const; + + /** Return numeric spread of ARFNs. */ + unsigned spread() const; + + /** Return true if a given ARFCN is in the list. */ + bool contains(unsigned wARFCN) const; + //@} +}; + + + +/** + Cell Channel Description, GSM 04.08 10.5.2.1b. + This element is used to provide the Cell Allocation + for frequency hopping configurations. + It lists the ARFCNs available for hopping and + normally lists all of the ARFCNs for the system. + It is mandatory, even if you don't use hopping. +*/ +class L3CellChannelDescription : public L3FrequencyList { + + public: + + L3CellChannelDescription() + :L3FrequencyList() + {} + + + void writeV(L3Frame& dest, size_t &wp) const; + +}; + + + + + +/** + Neighbor Cells Description, GSM 04.08 10.5.2.22 + (A kind of frequency list.) + This element describes neighboring cells that may be + candidates for handovers. +*/ +class L3NeighborCellsDescription : public L3FrequencyList { + + public: + + L3NeighborCellsDescription() + :L3FrequencyList(gConfig.getVector("GSM.CellSelection.Neighbors")) + {} + + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + + void text(std::ostream&) const; + +}; + + + + +/** NCC Permitted, GSM 04.08 10.5.2.27 */ +class L3NCCPermitted : public L3ProtocolElement { + + private: + + unsigned mPermitted; ///< NCC allowance mask (NCCs 0-7) + + public: + + /** Get default parameters from gConfig. */ + L3NCCPermitted() + :L3ProtocolElement() + { + mPermitted = gConfig.getNum("GSM.CellSelection.NCCsPermitted"); + } + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + +/** RACH Control Parameters GSM 04.08 10.5.2.29 */ +class L3RACHControlParameters : public L3ProtocolElement { + + private: + + unsigned mMaxRetrans; ///< code for 1-7 RACH retransmission attempts + unsigned mTxInteger; ///< code for 3-50 slots to spread transmission + unsigned mCellBarAccess; ///< if true, phones cannot camp + unsigned mRE; ///< if true, call reestablishment is not allowed + uint16_t mAC; ///< mask of barring flags for the 16 access classes + + public: + + /** Default constructor parameters allows all access. */ + L3RACHControlParameters() + :L3ProtocolElement() + { + // Values ditected by imnplementation are hard-coded. + mRE=1; + mCellBarAccess=0; + // Configurable values. + mMaxRetrans = gConfig.getNum("GSM.RACH.MaxRetrans"); + mTxInteger = gConfig.getNum("GSM.RACH.TxInteger"); + mAC = gConfig.getNum("GSM.RACH.AC"); + } + + size_t lengthV() const { return 3; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + + +/** PageMode, GSM 04.08 10.5.2.26 */ +class L3PageMode : public L3ProtocolElement +{ + + + unsigned mPageMode; + +public: + + /** Default mode is "normal paging". */ + L3PageMode(unsigned wPageMode=0) + :L3ProtocolElement(), + mPageMode(wPageMode) + {} + + size_t lengthV() const { return 1; } + void writeV( L3Frame& dest, size_t &wp ) const; + void parseV( const L3Frame &src, size_t &rp ); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** DedicatedModeOrTBF, GSM 04.08 10.5.2.25b */ +class L3DedicatedModeOrTBF : public L3ProtocolElement { + + unsigned mDownlink; ///< Indicates the IA reset octets contain additional information. + unsigned mTMA; ///< This is part of a 2-message assignment. + unsigned mDMOrTBF; ///< Dedicated link (circuit-switched) or temporary block flow (GPRS/pakcet). + + +public: + + L3DedicatedModeOrTBF() + :L3ProtocolElement(), + mDownlink(0), mTMA(0), mDMOrTBF(0) + {} + + size_t lengthV() const { return 1; } + void writeV(L3Frame &dest, size_t &wp ) const; + void parseV( const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** ChannelDescription, GSM 04.08 10.5.2.5 */ +class L3ChannelDescription : public L3ProtocolElement { + + +// Channel Description Format. +// 7 6 5 4 3 2 1 0 +// [ ChannelTypeTDMAOffset[4:0] ][ TN[2:0] ] Octect 1 +// [ TSC ][ H=0 ][ SPARE(0,0)][ ARFCN[9:8] ] Octect 2 +// [ [ H=1 ][ MAIO[5:2] ] Octect 2 +// [ ARFCN[7:0] ] Octect 3 H=0 +// [ MAIO[1:0] ][ HSN[5:0] ] Octect 3 H=1 +// + + // Octet 2. + TypeAndOffset mTypeAndOffset; // 5 bit + unsigned mTN; //3 bit + + // Octet 3 & 4. + unsigned mTSC; // 3 bit + unsigned mHFlag; // 1 bit + unsigned mARFCN; // 10 bit overflows + unsigned mMAIO; // 6 bit overflows + unsigned mHSN; // 6 bit + +public: + + /** Non-hopping initializer. */ + L3ChannelDescription(TypeAndOffset wTypeAndOffset, unsigned wTN, + unsigned wTSC, unsigned wARFCN) + :mTypeAndOffset(wTypeAndOffset),mTN(wTN), + mTSC(wTSC), + mHFlag(0), + mARFCN(wARFCN), + mMAIO(0),mHSN(0) + { } + + /** Blank initializer */ + L3ChannelDescription() + :mTypeAndOffset(TDMA_MISC), + mTN(0),mTSC(0),mHFlag(0),mARFCN(0),mMAIO(0),mHSN(0) + { } + + + size_t lengthV() const { return 3; } + void writeV( L3Frame &dest, size_t &wp ) const; + void parseV(const L3Frame& src, size_t &rp); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + + + + +/** RequestReference, GSM 04.08 10.5.2.30 */ +class L3RequestReference : public L3ProtocolElement +{ + +// Request Reference Format. +// 7 6 5 4 3 2 1 0 +// [ RequestReference [7:0] ] Octet 2 +// [ T1[4:0] ][ T3[5:3] ] Octet 3 +// [ T3[2:0] ][ T2[4:0] ] Octet 4 + + unsigned mRA; ///< random tag from original RACH burst + + /**@name Timestamp of the corresponing RACH burst. */ + //@{ + unsigned mT1p; ///< T1 mod 32 + unsigned mT2; + unsigned mT3; + //@} + +public: + + L3RequestReference() {} + + L3RequestReference(unsigned wRA, const GSM::Time& when) + :mRA(wRA), + mT1p(when.T1()%32),mT2(when.T2()),mT3(when.T3()) + {} + + size_t lengthV() const { return 3; } + void writeV(L3Frame &, size_t &wp ) const; + void parseV( const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** Timing Advance, GSM 04.08 10.5.2.40 */ +class L3TimingAdvance : public L3ProtocolElement +{ +// TimingAdvance +// 7 6 5 4 3 2 1 0 +// [ spare(0,0) ][ TimingAdvance [5:0] ] Octet 1 + + unsigned mTimingAdvance; + +public: + + L3TimingAdvance(unsigned wTimingAdvance=0) + :L3ProtocolElement(), + mTimingAdvance(wTimingAdvance) + {} + + size_t lengthV() const { return 1; } + void writeV(L3Frame&, size_t &wp) const; + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + +/** GSM 04.08 10.5.2.31 */ +class L3RRCause : public L3ProtocolElement +{ + int mCauseValue; + + public: + + /** Constructor cause defaults to "normal event". */ + L3RRCause(int wValue=0) + :L3ProtocolElement() + { mCauseValue=wValue; } + + int causeValue() const { return mCauseValue; } + + size_t lengthV() const { return 1; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + + + +/** GSM 04.08 10.5.2.28 */ +class L3PowerCommand : public L3ProtocolElement +{ + unsigned mCommand; + +public: + + L3PowerCommand(unsigned wCommand=0) + :L3ProtocolElement(), + mCommand(wCommand) + {} + + size_t lengthV() const { return 1; } + void writeV( L3Frame &dest, size_t &wp ) const; + void parseV( const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + + + +/** GSM 04.08 10.5.2.6 */ +class L3ChannelMode : public L3ProtocolElement { + +public: + + enum Mode + { + SignallingOnly=0, + SpeechV1=1, + SpeechV2=2, + SpeechV3=3 + }; + +private: + + Mode mMode; + +public: + + L3ChannelMode(Mode wMode=SignallingOnly) + :L3ProtocolElement(), + mMode(wMode) + {} + + bool operator==(const L3ChannelMode& other) const { return mMode==other.mMode; } + bool operator!=(const L3ChannelMode& other) const { return mMode!=other.mMode; } + + size_t lengthV() const { return 1; } + void writeV(L3Frame&, size_t&) const; + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream&) const; + +}; + +std::ostream& operator<<(std::ostream&, L3ChannelMode::Mode); + + + + +/** GSM 04.08 10.5.2.43 */ +class L3WaitIndication : public L3ProtocolElement { + + private: + + unsigned mValue; ///< T3122 or T3142 value in seconds + + public: + + L3WaitIndication(unsigned seconds) + :L3ProtocolElement(), + mValue(seconds) + {} + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const + { dest.writeField(wp,mValue,8); } + void parseV(const L3Frame&, size_t&) { assert(0); } + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream& os) const { os << mValue; } + +}; + +/** + Application Information Information Elements (encapsulates the RRLP message) + */ + +/** GSM 04.08 10.5.2.48 */ +class L3APDUID : public L3ProtocolElement { + + private: + + unsigned mProtocolIdentifier; + + public: + + /** Default Protocol Identifier is RRLP=0, the only one defined so far (rest are reserved). */ + L3APDUID(unsigned protocolIdentifier=0) + :L3ProtocolElement(), + mProtocolIdentifier(protocolIdentifier) + {} + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream& os) const; + +}; + + +/** GSM 04.08 10.5.2.49 */ +class L3APDUFlags : public L3ProtocolElement { + + private: + + // TODO - use bool for flags? + unsigned mCR; + unsigned mFirstSegment; + unsigned mLastSegment; + // TODO - put enums for CR, FirstSegment, LastSegment + + public: + + /** Default is the flags for a single segment APDU - one that fits in a single + Application Information message **/ + L3APDUFlags(unsigned cr=0, unsigned firstSegment=0, unsigned lastSegment=0) + :L3ProtocolElement(), + mCR(cr), mFirstSegment(firstSegment), mLastSegment(lastSegment) + {} + + size_t lengthV() const { return 1; } + void writeV(L3Frame& dest, size_t &wp) const; + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream& os) const; + +}; + + +/** GSM 04.08 10.5.2.50 */ +class L3APDUData : public L3ProtocolElement { + + private: + + BitVector mData; // will contain a RRLP message + + public: + + virtual ~L3APDUData(); + + /** Default is a zero length APDUData IE */ + L3APDUData(); + L3APDUData(BitVector data); + + size_t lengthV() const + { + // Return number of bytes neede to hold mData + size_t sz = mData.size(); + size_t ln = sz/8; + if (sz % 8) ln++; + return ln; + } + + void writeV(L3Frame& dest, size_t &wp) const; + void parseV( const L3Frame& src, size_t &rp, size_t expectedLength ); + void parseV(const L3Frame&, size_t&) { abort(); } + void text(std::ostream& os) const; + +}; + + + + +/** GSM 04.08 10.5.2.20 */ +class L3MeasurementResults : public L3ProtocolElement { + + private: + + bool mBA_USED; + bool mDTX_USED; + bool mMEAS_VALID; ///< 0 for valid, 1 for non-valid + unsigned mRXLEV_FULL_SERVING_CELL; + unsigned mRXLEV_SUB_SERVING_CELL; + unsigned mRXQUAL_FULL_SERVING_CELL; + unsigned mRXQUAL_SUB_SERVING_CELL; + + unsigned mNO_NCELL; + unsigned mRXLEV_NCELL[6]; + unsigned mBCCH_FREQ_NCELL[6]; + unsigned mBSIC_NCELL[6]; + + public: + + L3MeasurementResults() + :L3ProtocolElement(), + mMEAS_VALID(false), + mNO_NCELL(0) + { } + + size_t lengthV() const { return 16; } + void writeV(L3Frame&, size_t&) const { assert(0); } + void parseV(const L3Frame&, size_t&); + void parseV(const L3Frame&, size_t& , size_t) { assert(0); } + void text(std::ostream& os) const; + + /**@name Accessors. */ + //@{ + + bool BA_USED() const { return mBA_USED; } + bool DTX_USED() const { return mDTX_USED; } + bool MEAS_VALID() const { return mMEAS_VALID; } + unsigned RXLEV_FULL_SERVING_CELL() const { return mRXLEV_FULL_SERVING_CELL; } + unsigned RXLEV_SUB_SERVING_CELL() const { return mRXLEV_SUB_SERVING_CELL; } + unsigned RXQUAL_FULL_SERVING_CELL() const { return mRXQUAL_FULL_SERVING_CELL; } + unsigned RXQUAL_SUB_SERVING_CELL() const { return mRXQUAL_SUB_SERVING_CELL; } + + unsigned NO_NCELL() const { return mNO_NCELL; } + unsigned RXLEV_NCELL(unsigned i) const { assert(i. + +*/ + + + + +#include +#include + +#include "GSML3RRMessages.h" +#include + + +using namespace std; +using namespace GSM; + + + + + +void L3Message::writeBody(L3Frame&,size_t&) const +{ + LOG(ERR) << "not implemented for " << MTI(); + assert(0); +} + +void L3Message::parseBody(const L3Frame&, size_t&) +{ + LOG(ERR) << "not implemented for " << MTI(); + assert(0); +} + + + + + +ostream& GSM::operator<<(ostream& os, L3RRMessage::MessageType val) +{ + switch (val) { + case L3RRMessage::SystemInformationType1: + os << "System Information Type 1"; break; + case L3RRMessage::SystemInformationType2: + os << "System Information Type 2"; break; + case L3RRMessage::SystemInformationType2bis: + os << "System Information Type 2bis"; break; + case L3RRMessage::SystemInformationType2ter: + os << "System Information Type 2ter"; break; + case L3RRMessage::SystemInformationType3: + os << "System Information Type 3"; break; + case L3RRMessage::SystemInformationType4: + os << "System Information Type 4"; break; + case L3RRMessage::SystemInformationType5: + os << "System Information Type 5"; break; + case L3RRMessage::SystemInformationType5bis: + os << "System Information Type 5bis"; break; + case L3RRMessage::SystemInformationType5ter: + os << "System Information Type 5ter"; break; + case L3RRMessage::SystemInformationType6: + os << "System Information Type 6"; break; + case L3RRMessage::SystemInformationType7: + os << "System Information Type 7"; break; + case L3RRMessage::SystemInformationType8: + os << "System Information Type 8"; break; + case L3RRMessage::SystemInformationType9: + os << "System Information Type 9"; break; + case L3RRMessage::SystemInformationType13: + os << "System Information Type 13"; break; + case L3RRMessage::SystemInformationType16: + os << "System Information Type 16"; break; + case L3RRMessage::SystemInformationType17: + os << "System Information Type 17"; break; + case L3RRMessage::PagingResponse: + os << "Paging Response"; break; + case L3RRMessage::PagingRequestType1: + os << "Paging Request Type 1"; break; + case L3RRMessage::MeasurementReport: + os << "Measurement Report"; break; + case L3RRMessage::AssignmentComplete: + os << "Assignment Complete"; break; + case L3RRMessage::ImmediateAssignment: + os << "Immediate Assignment"; break; + case L3RRMessage::ImmediateAssignmentReject: + os << "Immediate Assignment Reject"; break; + case L3RRMessage::AssignmentCommand: + os << "Assignment Command"; break; + case L3RRMessage::AssignmentFailure: + os << "Assignment Failure"; break; + case L3RRMessage::ChannelRelease: + os << "Channel Release"; break; + case L3RRMessage::ChannelModeModify: + os << "Channel Mode Modify"; break; + case L3RRMessage::ChannelModeModifyAcknowledge: + os << "Channel Mode Modify Acknowledge"; break; + case L3RRMessage::GPRSSuspensionRequest: + os << "GPRS Suspension Request"; break; + case L3RRMessage::ClassmarkEnquiry: + os << "Classmark Enquiry"; break; + case L3RRMessage::ClassmarkChange: + os << "Classmark Change"; break; + case L3RRMessage::RRStatus: + os << "RR Status"; break; + case L3RRMessage::ApplicationInformation: + os << "Application Information"; break; + default: os << hex << "0x" << (int)val << dec; + } + return os; +} + + +void L3RRMessage::text(ostream& os) const +{ + os << "RR " << (MessageType) MTI() << " "; +} + + + +L3RRMessage* GSM::L3RRFactory(L3RRMessage::MessageType MTI) +{ + switch (MTI) { + case L3RRMessage::ChannelRelease: return new L3ChannelRelease(); + case L3RRMessage::AssignmentComplete: return new L3AssignmentComplete(); + case L3RRMessage::AssignmentFailure: return new L3AssignmentFailure(); + case L3RRMessage::RRStatus: return new L3RRStatus(); + case L3RRMessage::PagingResponse: return new L3PagingResponse(); + case L3RRMessage::ChannelModeModifyAcknowledge: return new L3ChannelModeModifyAcknowledge(); + case L3RRMessage::ClassmarkChange: return new L3ClassmarkChange(); + case L3RRMessage::ClassmarkEnquiry: return new L3ClassmarkEnquiry(); + case L3RRMessage::MeasurementReport: return new L3MeasurementReport(); + case L3RRMessage::ApplicationInformation: return new L3ApplicationInformation(); + // Partial support just to get along with some phones. + case L3RRMessage::GPRSSuspensionRequest: return new L3GPRSSuspensionRequest(); + default: + LOG(WARNING) << "no L3 RR factory support for " << MTI; + return NULL; + } +} + +L3RRMessage* GSM::parseL3RR(const L3Frame& source) +{ + L3RRMessage::MessageType MTI = (L3RRMessage::MessageType)source.MTI(); + LOG(DEBUG) << "parseL3RR MTI="<parse(source); + return retVal; +} + + + +/** +This is a local function to map the GSM::ChannelType enum +to one of the codes from GMS 04.08 10.5.2.8. +*/ +unsigned channelNeededCode(ChannelType wType) +{ + switch (wType) { + case AnyDCCHType: return 0; + case SDCCHType: return 1; + case TCHFType: return 2; + case AnyTCHType: return 3; + default: assert(0); + } +} + + + +size_t L3PagingRequestType1::l2BodyLength() const +{ + int sz = mMobileIDs.size(); + assert(sz<=2); + size_t sum=1; + sum += mMobileIDs[0].lengthLV(); + if (sz>1) sum += mMobileIDs[1].lengthTLV(); + return sum; +} + + + +void L3PagingRequestType1::writeBody(L3Frame& dest, size_t &wp) const +{ + // See GSM 04.08 9.1.22. + // Page Mode Page Mode M V 1/2 10.5.2.26 + // Channels Needed M V 1/2 + // Mobile Identity 1 M LV 2-9 10.5.1.4 + // 0x17 Mobile Identity 2 O TLV 3-10 10.5.1.4 + + int sz = mMobileIDs.size(); + assert(sz<=2); + // Remember to reverse orders of 1/2-octet fields. + // Because GSM transmits LSB-first within each byte. + // channel needed codes + dest.writeField(wp,channelNeededCode(mChannelsNeeded[1]),2); + dest.writeField(wp,channelNeededCode(mChannelsNeeded[0]),2); + // "normal paging", GSM 04.08 Table 10.5.63 + dest.writeField(wp,0x0,4); + // the actual mobile IDs + mMobileIDs[0].writeLV(dest,wp); + if (sz>1) mMobileIDs[1].writeTLV(0x17,dest,wp); +} + + +void L3PagingRequestType1::text(ostream& os) const +{ + L3RRMessage::text(os); + os << " mobileIDs=("; + for (unsigned i=0; i8-bit codes to avoid conflicts + //@{ + SynchronizationChannelInformation=0x100, + ChannelRequest=0x101, + //@} + ///@name application information - used for RRLP + //@{ + ApplicationInformation=0x38, + //@} + }; + + + L3RRMessage():L3Message() { } + + /** Return the L3 protocol discriptor. */ + L3PD PD() const { return L3RadioResourcePD; } + + void text(std::ostream&) const; +}; + +std::ostream& operator<<(std::ostream& os, L3RRMessage::MessageType); + + + +/** Subclass for L3 RR Messages with no rest octets. */ +class L3RRMessageNRO : public L3RRMessage { + + public: + + L3RRMessageNRO():L3RRMessage() { } + + size_t fullBodyLength() const { return l2BodyLength(); } + +}; + +/** Subclass for L3 RR messages with rest octets */ +class L3RRMessageRO : public L3RRMessage { + + public: + + L3RRMessageRO():L3RRMessage() { } + + virtual size_t restOctetsLength() const =0; + + size_t fullBodyLength() const { return l2BodyLength() + restOctetsLength(); } + +}; + + +/** + A Factory function to return a L3RRMessage of the specified MTI. + Returns NULL if the MTI is not supported. +*/ +L3RRMessage* L3RRFactory(L3RRMessage::MessageType MTI); + +/** + Parse a complete L3 radio resource message into its object type. + @param source The L3 bits. + @return A pointer to a new message or NULL on failure. +*/ +L3RRMessage* parseL3RR(const L3Frame& source); + + +/** Paging Request Type 1, GSM 04.08 9.1.22 */ +class L3PagingRequestType1 : public L3RRMessageNRO { + + private: + + std::vector mMobileIDs; + ChannelType mChannelsNeeded[2]; + + + public: + + L3PagingRequestType1() + :L3RRMessageNRO() + { + // The empty paging request is a single untyped mobile ID. + mMobileIDs.push_back(L3MobileIdentity()); + mChannelsNeeded[0]=AnyDCCHType; + mChannelsNeeded[1]=AnyDCCHType; + } + + L3PagingRequestType1(const L3MobileIdentity& wId, ChannelType wType) + :L3RRMessageNRO() + { + mMobileIDs.push_back(wId); + mChannelsNeeded[0]=wType; + mChannelsNeeded[1]=AnyDCCHType; + } + + L3PagingRequestType1(const L3MobileIdentity& wId1, ChannelType wType1, + const L3MobileIdentity& wId2, ChannelType wType2) + :L3RRMessageNRO() + { + mMobileIDs.push_back(wId1); + mChannelsNeeded[0]=wType1; + mMobileIDs.push_back(wId2); + mChannelsNeeded[1]=wType2; + } + + unsigned chanCode(ChannelType) const; + + int MTI() const { return PagingRequestType1; } + + size_t l2BodyLength() const; + void writeBody(L3Frame& dest, size_t& wp) const; + void text(std::ostream&) const; +}; + + + + +/** Paging Response, GSM 04.08 9.1.25 */ +class L3PagingResponse : public L3RRMessageNRO { + + private: + + L3MobileStationClassmark2 mClassmark; + L3MobileIdentity mMobileID; + + public: + + const L3MobileIdentity& mobileID() const { return mMobileID; } + + int MTI() const { return PagingResponse; } + + size_t l2BodyLength() const; + void parseBody(const L3Frame& source, size_t &rp); + void text(std::ostream&) const; + +}; + + + + + + + +/** + System Information Message Type 1, GSM 04.08 9.1.31 + - Cell Channel Description 10.5.2.1b M V 16 + - RACH Control Parameters 10.5.2.29 M V 3 +*/ +class L3SystemInformationType1 : public L3RRMessageNRO { + + private: + + L3FrequencyList mCellChannelDescription; + L3RACHControlParameters mRACHControlParameters; + + public: + + L3SystemInformationType1():L3RRMessageNRO() {} + + void RACHControlParameters(const L3RACHControlParameters& wRACHControlParameters) + { mRACHControlParameters = wRACHControlParameters; } + + void cellChannelDescription(const L3FrequencyList& wCellChannelDescription) + { mCellChannelDescription = wCellChannelDescription; } + + int MTI() const { return (int)SystemInformationType1; } + + size_t l2BodyLength() const { return 19; } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + + + +/** + System Information Type 2, GSM 04.08 9.1.32. + - BCCH Frequency List 10.5.2.22 M V 16 + - NCC Permitted 10.5.2.27 M V 1 + - RACH Control Parameter 10.5.2.29 M V 3 +*/ +class L3SystemInformationType2 : public L3RRMessageNRO { + + private: + + L3NeighborCellsDescription mBCCHFrequencyList; + L3NCCPermitted mNCCPermitted; + L3RACHControlParameters mRACHControlParameters; + + public: + + L3SystemInformationType2():L3RRMessageNRO() {} + + void BCCHFrequencyList(const L3NeighborCellsDescription& wBCCHFrequencyList) + { mBCCHFrequencyList = wBCCHFrequencyList; } + + void NCCPermitted(const L3NCCPermitted& wNCCPermitted) + { mNCCPermitted = wNCCPermitted; } + + void RACHControlParameters(const L3RACHControlParameters& wRACHControlParameters) + { mRACHControlParameters = wRACHControlParameters; } + + int MTI() const { return (int)SystemInformationType2; } + + size_t l2BodyLength() const { return 20; } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + + +/** + System Information Type 3, GSM 04.08 9.1.35 + - Cell Identity 10.5.1.1 M V 2 + - Location Area Identification 10.5.1.3 M V 5 + - Control Channel Description 10.5.2.11 M V 3 + - Cell Options (BCCH) 10.5.2.3 M V 1 + - Cell Selection Parameters 10.5.2.4 M V 2 + - RACH Control Parameters 10.5.2.29 M V 3 +*/ +class L3SystemInformationType3 : public L3RRMessageRO { + + private: + + L3CellIdentity mCI; + L3LocationAreaIdentity mLAI; + L3ControlChannelDescription mControlChannelDescription; + L3CellOptionsBCCH mCellOptions; + L3CellSelectionParameters mCellSelectionParameters; + L3RACHControlParameters mRACHControlParameters; + + bool mHaveRestOctets; + L3SI3RestOctets mRestOctets; + + public: + + L3SystemInformationType3() + :L3RRMessageRO(), + mHaveRestOctets(gConfig.defines("GSM.SI3RO")) + { } + + void CI(const L3CellIdentity& wCI) { mCI = wCI; } + + void LAI(const L3LocationAreaIdentity& wLAI) { mLAI = wLAI; } + + void controlChannelDescription(const L3ControlChannelDescription& wControlChannelDescription) + { mControlChannelDescription = wControlChannelDescription; } + + void cellOptions(const L3CellOptionsBCCH& wCellOptions) + { mCellOptions = wCellOptions; } + + void cellSelectionParameters (const L3CellSelectionParameters& wCellSelectionParameters) + { mCellSelectionParameters = wCellSelectionParameters; } + + void RACHControlParameters(const L3RACHControlParameters& wRACHControlParameters) + { mRACHControlParameters = wRACHControlParameters; } + + int MTI() const { return (int)SystemInformationType3; } + + size_t l2BodyLength() const { return 16; } + size_t restOctetsLength() const { return mRestOctets.lengthV(); } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + + + +/** + System Information Type 4, GSM 04.08 9.1.36 + - Location Area Identification 10.5.1.3 M V 5 + - Cell Selection Parameters 10.5.2.4 M V 2 + - RACH Control Parameters 10.5.2.29 M V 3 +*/ +class L3SystemInformationType4 : public L3RRMessageNRO { + + private: + + L3LocationAreaIdentity mLAI; + L3CellSelectionParameters mCellSelectionParameters; + L3RACHControlParameters mRACHControlParameters; + + public: + + L3SystemInformationType4(); + + //void LAI(const L3LocationAreaIdentity& wLAI) { mLAI = wLAI; } + + //void cellSelectionParameters (const L3CellSelectionParameters& wCellSelectionParameters) +// { mCellSelectionParameters = wCellSelectionParameters; } + +// void RACHControlParameters(const L3RACHControlParameters& wRACHControlParameters) +// { mRACHControlParameters = wRACHControlParameters; } + + int MTI() const { return (int)SystemInformationType4; } + + size_t l2BodyLength() const; + + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + +/** + System Information Type 5, GSM 04.08 9.1.37 + - BCCH Frequency List 10.5.2.22 M V 16 +*/ +class L3SystemInformationType5 : public L3RRMessageNRO { + + private: + + L3NeighborCellsDescription mBCCHFrequencyList; + + public: + + L3SystemInformationType5():L3RRMessageNRO() { } + + void BCCHFrequencyList(const L3NeighborCellsDescription& wBCCHFrequencyList) + { mBCCHFrequencyList = wBCCHFrequencyList; } + + int MTI() const { return (int)SystemInformationType5; } + + size_t l2BodyLength() const { return 16; } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + + +/** + System Information Type 6, GSM 04.08 9.1.40 + - Cell Identity 10.5.1.11 M V 2 + - Location Area Identification 10.5.1.3 M V 5 + - Cell Options (SACCH) 10.5.2.3 M V 1 + - NCC Permitted 10.5.2.27 M V 1 +*/ +class L3SystemInformationType6 : public L3RRMessageNRO { + + private: + + L3CellIdentity mCI; + L3LocationAreaIdentity mLAI; + L3CellOptionsSACCH mCellOptions; + L3NCCPermitted mNCCPermitted; + + public: + + L3SystemInformationType6():L3RRMessageNRO() {} + + void CI(const L3CellIdentity& wCI) { mCI = wCI; } + + void LAI(const L3LocationAreaIdentity& wLAI) { mLAI = wLAI; } + + void cellOptions(const L3CellOptionsSACCH& wCellOptions) + { mCellOptions = wCellOptions; } + + void NCCPermitted(const L3NCCPermitted& wNCCPermitted) + { mNCCPermitted = wNCCPermitted; } + + int MTI() const { return (int)SystemInformationType6; } + + size_t l2BodyLength() const { return 9; } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + + + +/** Immediate Assignment, GSM 04.08 9.1.18 */ +class L3ImmediateAssignment : public L3RRMessageNRO { + +private: + + L3PageMode mPageMode; + L3DedicatedModeOrTBF mDedicatedModeOrTBF; + L3RequestReference mRequestReference; + L3ChannelDescription mChannelDescription; + L3TimingAdvance mTimingAdvance; + +public: + + + L3ImmediateAssignment( + const L3RequestReference& wRequestReference, + const L3ChannelDescription& wChannelDescription, + const L3TimingAdvance& wTimingAdvance = L3TimingAdvance(0)) + :L3RRMessageNRO(), + mRequestReference(wRequestReference), + mChannelDescription(wChannelDescription), + mTimingAdvance(wTimingAdvance) + {} + + int MTI() const { return (int)ImmediateAssignment; } + size_t l2BodyLength() const { return 9; } + + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; + +}; + + + +/** Immediate Assignment Reject, GSM 04.08 9.1.20 */ +class L3ImmediateAssignmentReject : public L3RRMessageNRO { + +private: + + L3PageMode mPageMode; + std::vector mRequestReference; + L3WaitIndication mWaitIndication; ///< All entries get the same wait indication. + +public: + + + L3ImmediateAssignmentReject(const L3RequestReference& wRequestReference, unsigned seconds) + :L3RRMessageNRO(), + mWaitIndication(seconds) + { mRequestReference.push_back(wRequestReference); } + + int MTI() const { return (int)ImmediateAssignmentReject; } + + size_t l2BodyLength() const { return 17; } + void writeBody(L3Frame &dest, size_t &wp) const; + void text(std::ostream&) const; + +}; + + + + + + +/** GSM 04.08 9.1.7 */ +class L3ChannelRelease : public L3RRMessageNRO { + +private: + + L3RRCause mRRCause; + +public: + + /** The default cause is 0x0, "normal event". */ + L3ChannelRelease(const L3RRCause& cause = L3RRCause(0x0)) + :L3RRMessageNRO(),mRRCause(cause) + {} + + int MTI() const { return (int) ChannelRelease; } + + size_t l2BodyLength() const { return mRRCause.lengthV(); } + void writeBody( L3Frame &dest, size_t &wp ) const; + void text(std::ostream&) const; +}; + + + + +/** + GSM 04.08 9.1.8 + The channel request message is special because the timestamp + is implied by the receive time but not actually present in + the message. + This messages has no parse or write methods, but is used to + transfer information from L1 to the control layer. +*/ +class L3ChannelRequest : public L3RRMessageNRO { + + private: + + unsigned mRA; ///< request reference + GSM::Time mTime; ///< receive timestamp + + public: + + L3ChannelRequest(unsigned wRA, const GSM::Time& wTime) + :L3RRMessageNRO(), + mRA(wRA), mTime(wTime) + {} + + /**@name Accessors. */ + //@{ + unsigned RA() const { return mRA; } + const GSM::Time& time() const { return mTime; } + //@} + + int MTI() const { return (int)ChannelRequest; } + + size_t l2BodyLength() const { return 0; } + void writeBody( L3Frame &dest, size_t &wp ) const; + void parseBody(const L3Frame&, size_t&); + void text(std::ostream&) const; +}; + + + + + +/** GSM 04.08 9.1.2 */ +class L3AssignmentCommand : public L3RRMessageNRO { + +private: + + L3ChannelDescription mChannelDescription; + L3PowerCommand mPowerCommand; + + bool mHaveMode1; + L3ChannelMode mMode1; + +public: + + L3AssignmentCommand(const L3ChannelDescription& wChannelDescription, + const L3ChannelMode& wMode1 ) + :L3RRMessageNRO(), + mChannelDescription(wChannelDescription), + mHaveMode1(true),mMode1(wMode1) + {} + + L3AssignmentCommand(const L3ChannelDescription& wChannelDescription) + :L3RRMessageNRO(), + mChannelDescription(wChannelDescription), + mHaveMode1(false) + {} + + + + int MTI() const { return (int) AssignmentCommand; } + + size_t l2BodyLength() const; + void writeBody( L3Frame &dest, size_t &wp ) const; + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.1.3 */ +class L3AssignmentComplete : public L3RRMessageNRO { + + private: + + L3RRCause mCause; + + public: + + ///@name Accessors. + //@{ + const L3RRCause& cause() const { return mCause; } + //@} + + int MTI() const { return (int) AssignmentComplete; } + + size_t l2BodyLength() const { return 1; } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + +}; + + +/** GSM 04.08 9.1.3 */ +class L3AssignmentFailure : public L3RRMessageNRO { + + private: + + L3RRCause mCause; + + public: + + ///@name Accessors. + //@{ + const L3RRCause& cause() const { return mCause; } + //@} + + int MTI() const { return (int) AssignmentFailure; } + + size_t l2BodyLength() const { return 1; } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + +}; + + +/** GSM 04.08 9.1.29 */ +class L3RRStatus : public L3RRMessageNRO { + + private: + + L3RRCause mCause; + + public: + + ///@name Accessors. + //@{ + const L3RRCause& cause() const { return mCause; } + //@} + + int MTI() const { return (int) RRStatus; } + + size_t l2BodyLength() const { return 1; } + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + +}; + + + +/** GSM 04.08 9.1.5 */ +class L3ChannelModeModify : public L3RRMessageNRO { + + private: + + L3ChannelDescription mDescription; + L3ChannelMode mMode; + + public: + + L3ChannelModeModify(const L3ChannelDescription& wDescription, + const L3ChannelMode& wMode) + :L3RRMessageNRO(), + mDescription(wDescription), + mMode(wMode) + {} + + int MTI() const { return (int) ChannelModeModify; } + + size_t l2BodyLength() const + { return mDescription.lengthV() + mMode.lengthV(); } + + void writeBody(L3Frame&, size_t&) const; + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.1.6 */ +class L3ChannelModeModifyAcknowledge : public L3RRMessageNRO { + + private: + + L3ChannelDescription mDescription; + L3ChannelMode mMode; + + public: + + const L3ChannelDescription& description() const { return mDescription; } + const L3ChannelMode& mode() const { return mMode; } + + int MTI() const { return (int) ChannelModeModifyAcknowledge; } + + size_t l2BodyLength() const + { return mDescription.lengthV() + mMode.lengthV(); } + + void parseBody(const L3Frame&, size_t&); + void text(std::ostream&) const; +}; + + +/** GSM 04.08 9.1.21 */ +class L3MeasurementReport : public L3RRMessageNRO { + + private: + // This is a placeholder. We don't really parse anything yet. + L3MeasurementResults mResults; + + public: + + int MTI() const { return (int) MeasurementReport; } + size_t l2BodyLength() const { return mResults.lengthV(); } + + void parseBody(const L3Frame&, size_t&); + void text(std::ostream&) const; + + const L3MeasurementResults results() const { return mResults; } + +}; + + +/** GSM 04.08 9.1.53 */ +class L3ApplicationInformation : public L3RRMessageNRO { + + private: + + L3APDUID mID; + L3APDUFlags mFlags; + L3APDUData mData; + + public: + + ~L3ApplicationInformation(); + + L3ApplicationInformation(); + // data is the first argument to allow the rest to default, since that is the common case, + // sending a single (cr=0, first=0, last=0) RRLP (id=0) APDU wrapped in a ApplicationInformation L3 packet. + L3ApplicationInformation(BitVector& data, unsigned protocolIdentifier=0, + unsigned cr=0, unsigned firstSegment=0, unsigned lastSegment=0); + + ///@name Accessors. + //@{ + const L3APDUID& id() const { return mID; } + const L3APDUFlags& flags() const { return mFlags; } + const L3APDUData& data() const { return mData; } + //@} + + int MTI() const { return (int) ApplicationInformation; } + + size_t l2BodyLength() const; + void writeBody( L3Frame&, size_t&) const; + void parseBody( const L3Frame &src, size_t &rp ); + void text(std::ostream&) const; + +}; + + +/** GSM 04.08 9.1.13b */ +class L3GPRSSuspensionRequest : public L3RRMessageNRO { + + public: + + int MTI() const { return (int) GPRSSuspensionRequest; } + + size_t l2BodyLength() const { return 11; } + + void parseBody(const L3Frame&, size_t&); +}; + + +/** GSM 04.08 9.1.12 */ +class L3ClassmarkEnquiry : public L3RRMessageNRO { + + public: + + int MTI() const { return (int) ClassmarkEnquiry; } + + size_t l2BodyLength() const { return 0; } + void writeBody(L3Frame&, size_t&) const {} +}; + + +/** GSM 04.08 9.1.11 */ +class L3ClassmarkChange : public L3RRMessageNRO { + + protected: + + L3MobileStationClassmark2 mClassmark; + bool mHaveAdditionalClassmark; + L3MobileStationClassmark3 mAdditionalClassmark; + + public: + + int MTI() const { return (int) ClassmarkChange; } + + size_t l2BodyLength() const; + void parseBody(const L3Frame&, size_t&); + void text(std::ostream&) const; + + const L3MobileStationClassmark2& classmark() const { return mClassmark; } +}; + + +} // GSM + + + +#endif +// vim: ts=4 sw=4 diff --git a/GSM/GSMLogicalChannel.cpp b/GSM/GSMLogicalChannel.cpp new file mode 100644 index 0000000..15772d1 --- /dev/null +++ b/GSM/GSMLogicalChannel.cpp @@ -0,0 +1,412 @@ +/**@file Logical Channel. */ + +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "GSML3RRElements.h" +#include "GSML3Message.h" +#include "GSML3RRMessages.h" +#include "GSMLogicalChannel.h" +#include "GSMConfig.h" + +#include +#include +#include + +#include +#undef WARNING + +using namespace std; +using namespace GSM; + + + +void LogicalChannel::open() +{ + LOG(INFO); + if (mSACCH) mSACCH->open(); + if (mL1) mL1->open(); + for (int s=0; s<4; s++) { + if (mL2[s]) mL2[s]->open(); + } + // Empty any stray transactions in the FIFO from the SIP layer. + while (true) { + Control::TransactionEntry *trans = mTransactionFIFO.readNoBlock(); + if (!trans) break; + LOG(WARNING) << "flushing stray transaction " << *trans; + } +} + + +void LogicalChannel::connect() +{ + mMux.downstream(mL1); + if (mL1) mL1->upstream(&mMux); + for (int s=0; s<4; s++) { + mMux.upstream(mL2[s],s); + if (mL2[s]) mL2[s]->downstream(&mMux); + } +} + + +void LogicalChannel::downstream(ARFCNManager* radio) +{ + assert(mL1); + mL1->downstream(radio); + if (mSACCH) mSACCH->downstream(radio); +} + + + +// Serialize and send an L3Message with a given primitive. +void LogicalChannel::send(const L3Message& msg, + const GSM::Primitive& prim, + unsigned SAPI) +{ + LOG(INFO) << "L3 SAP" << SAPI << " sending " << msg; + send(L3Frame(msg,prim), SAPI); +} + + + + +CCCHLogicalChannel::CCCHLogicalChannel(const TDMAMapping& wMapping) + :mRunning(false) +{ + mL1 = new CCCHL1FEC(wMapping); + mL2[0] = new CCCHL2; + connect(); +} + + +void CCCHLogicalChannel::open() +{ + LogicalChannel::open(); + if (!mRunning) { + mRunning=true; + mServiceThread.start((void*(*)(void*))CCCHLogicalChannelServiceLoopAdapter,this); + } +} + + +void CCCHLogicalChannel::serviceLoop() +{ + // build the idle frame + static const L3PagingRequestType1 filler; + static const L3Frame idleFrame(filler,UNIT_DATA); + // prime the first idle frame + LogicalChannel::send(idleFrame); + // run the loop + while (true) { + L3Frame* frame = mQ.read(); + if (frame) { + LogicalChannel::send(*frame); + OBJLOG(DEBUG) << "CCCHLogicalChannel::serviceLoop sending " << *frame; + delete frame; + } + if (mQ.size()==0) { + LogicalChannel::send(idleFrame); + OBJLOG(DEBUG) << "CCCHLogicalChannel::serviceLoop sending idle frame"; + } + } +} + + +void *GSM::CCCHLogicalChannelServiceLoopAdapter(CCCHLogicalChannel* chan) +{ + chan->serviceLoop(); + return NULL; +} + + + +L3ChannelDescription LogicalChannel::channelDescription() const +{ + // In some debug cases, L1 may not exist, so we fake this information. + if (mL1==NULL) return L3ChannelDescription(TDMA_MISC,0,0,0); + + // In normal cases, we get this information from L1. + return L3ChannelDescription( + mL1->typeAndOffset(), + mL1->TN(), + mL1->TSC(), + mL1->ARFCN() + ); +} + + + + +SDCCHLogicalChannel::SDCCHLogicalChannel( + unsigned wTN, + const CompleteMapping& wMapping) +{ + mL1 = new SDCCHL1FEC(wTN,wMapping.LCH()); + // SAP0 is RR/MM/CC, SAP3 is SMS + // SAP1 and SAP2 are not used. + L2LAPDm *SAP0L2 = new SDCCHL2(1,0); + L2LAPDm *SAP3L2 = new SDCCHL2(1,3); + LOG(DEBUG) << "LAPDm pairs SAP0=" << SAP0L2 << " SAP3=" << SAP3L2; + SAP3L2->master(SAP0L2); + mL2[0] = SAP0L2; + mL2[3] = SAP3L2; + mSACCH = new SACCHLogicalChannel(wTN,wMapping.SACCH()); + connect(); +} + + + + + +SACCHLogicalChannel::SACCHLogicalChannel( + unsigned wTN, + const MappingPair& wMapping) + : mRunning(false) +{ + mSACCHL1 = new SACCHL1FEC(wTN,wMapping); + mL1 = mSACCHL1; + // SAP0 is RR, SAP3 is SMS + // SAP1 and SAP2 are not used. + mL2[0] = new SACCHL2(1,0); + mL2[3] = new SACCHL2(1,3); + connect(); + assert(mSACCH==NULL); +} + + +void SACCHLogicalChannel::open() +{ + LogicalChannel::open(); + if (!mRunning) { + mRunning=true; + mServiceThread.start((void*(*)(void*))SACCHLogicalChannelServiceLoopAdapter,this); + } +} + + + +L3Message* processSACCHMessage(L3Frame *l3frame) +{ + if (!l3frame) return NULL; + LOG(DEBUG) << *l3frame; + Primitive prim = l3frame->primitive(); + if ((prim!=DATA) && (prim!=UNIT_DATA)) { + LOG(INFO) << "non-data primitive " << prim; + return NULL; + } + // FIXME -- Why, again, do we need to do this? +// L3Frame realFrame = l3frame->segment(24, l3frame->size()-24); + L3Message* message = parseL3(*l3frame); + if (!message) { + LOG(WARNING) << "SACCH recevied unparsable L3 frame " << *l3frame; + } + return message; +} + + +void SACCHLogicalChannel::serviceLoop() +{ + // run the loop + unsigned count = 0; + while (true) { + + // Throttle back if not active. + if (!active()) { + OBJLOG(DEBUG) << "SACCH sleeping"; + sleepFrames(51); + continue; + } + + // TODO SMS -- Check to see if the tx queues are empty. If so, send SI5/6, + // otherwise sleep and continue; + + // Send alternating SI5/SI6. + OBJLOG(DEBUG) << "sending SI5/6 on SACCH"; + if (count%2) LogicalChannel::send(gBTS.SI5Frame()); + else LogicalChannel::send(gBTS.SI6Frame()); + count++; + + // Receive inbound messages. + // This read loop flushes stray reports quickly. + while (true) { + + OBJLOG(DEBUG) << "polling SACCH for inbound messages"; + bool nothing = true; + + // Process SAP0 -- RR Measurement reports + L3Frame *rrFrame = LogicalChannel::recv(0,0); + if (rrFrame) nothing=false; + L3Message* rrMessage = processSACCHMessage(rrFrame); + delete rrFrame; + if (rrMessage) { + L3MeasurementReport* measurement = dynamic_cast(rrMessage); + if (measurement) { + mMeasurementResults = measurement->results(); + OBJLOG(DEBUG) << "SACCH measurement report " << mMeasurementResults; + // Add the measurement results to the table + // Note that the typeAndOffset of a SACCH match the host channel. + gPhysStatus.setPhysical(this, mMeasurementResults); + } else { + OBJLOG(NOTICE) << "SACCH SAP0 sent unaticipated message " << rrMessage; + } + delete rrMessage; + } + + // Process SAP3 -- SMS + L3Frame *smsFrame = LogicalChannel::recv(0,3); + if (smsFrame) nothing=false; + L3Message* smsMessage = processSACCHMessage(smsFrame); + delete smsFrame; + if (smsMessage) { + const SMS::CPData* cpData = dynamic_cast(smsMessage); + if (cpData) { + OBJLOG(INFO) << "SMS CPDU " << *cpData; + Control::TransactionEntry *transaction = gTransactionTable.find(this); + try { + if (transaction) { + Control::InCallMOSMSController(cpData,transaction,this); + } else { + OBJLOG(WARNING) << "in-call MOSMS CP-DATA with no corresponding transaction"; + } + } catch (Control::ControlLayerException e) { + //LogicalChannel::send(RELEASE,3); + gTransactionTable.remove(e.transactionID()); + } + } else { + OBJLOG(NOTICE) << "SACCH SAP3 sent unaticipated message " << rrMessage; + } + delete smsMessage; + } + + // Anything from the SIP side? + // MTSMS (delivery from SIP to the MS) + Control::TransactionEntry *sipTransaction = mTransactionFIFO.readNoBlock(); + if (sipTransaction) { + OBJLOG(INFO) << "SIP-side transaction: " << sipTransaction; + assert(sipTransaction->service() == L3CMServiceType::MobileTerminatedShortMessage); + try { + Control::MTSMSController(sipTransaction,this); + } catch (Control::ControlLayerException e) { + //LogicalChannel::send(RELEASE,3); + gTransactionTable.remove(e.transactionID()); + } + } + + // Nothing happened? + if (nothing) break; + } + + } +} + + +void *GSM::SACCHLogicalChannelServiceLoopAdapter(SACCHLogicalChannel* chan) +{ + chan->serviceLoop(); + return NULL; +} + + +// These have to go into the .cpp file to prevent an illegal forward reference. +void LogicalChannel::setPhy(float wRSSI, float wTimingError) + { assert(mSACCH); mSACCH->setPhy(wRSSI,wTimingError); } +void LogicalChannel::setPhy(const LogicalChannel& other) + { assert(mSACCH); mSACCH->setPhy(*other.SACCH()); } +float LogicalChannel::RSSI() const + { assert(mSACCH); return mSACCH->RSSI(); } +float LogicalChannel::timingError() const + { assert(mSACCH); return mSACCH->timingError(); } +int LogicalChannel::actualMSPower() const + { assert(mSACCH); return mSACCH->actualMSPower(); } +int LogicalChannel::actualMSTiming() const + { assert(mSACCH); return mSACCH->actualMSTiming(); } + + + +TCHFACCHLogicalChannel::TCHFACCHLogicalChannel( + unsigned wTN, + const CompleteMapping& wMapping) +{ + mTCHL1 = new TCHFACCHL1FEC(wTN,wMapping.LCH()); + mL1 = mTCHL1; + // SAP0 is RR/MM/CC, SAP3 is SMS + // SAP1 and SAP2 are not used. + mL2[0] = new FACCHL2(1,0); + mL2[3] = new FACCHL2(1,3); + mSACCH = new SACCHLogicalChannel(wTN,wMapping.SACCH()); + connect(); +} + + + + + + +bool LogicalChannel::waitForPrimitive(Primitive primitive, unsigned timeout_ms) +{ + bool waiting = true; + while (waiting) { + L3Frame *req = recv(timeout_ms); + if (req==NULL) { + LOG(NOTICE) << "timeout at uptime " << gBTS.uptime() << " frame " << gBTS.time(); + return false; + } + waiting = (req->primitive()!=primitive); + delete req; + } + return true; +} + + +void LogicalChannel::waitForPrimitive(Primitive primitive) +{ + bool waiting = true; + while (waiting) { + L3Frame *req = recv(); + if (req==NULL) continue; + waiting = (req->primitive()!=primitive); + delete req; + } +} + + +ostream& GSM::operator<<(ostream& os, const LogicalChannel& chan) +{ + os << chan.descriptiveString(); + return os; +} + + +void LogicalChannel::addTransaction(Control::TransactionEntry *transaction) +{ + assert(transaction->channel()==this); + mTransactionFIFO.write(transaction); +} + +// vim: ts=4 sw=4 + diff --git a/GSM/GSMLogicalChannel.h b/GSM/GSMLogicalChannel.h new file mode 100644 index 0000000..6c39c18 --- /dev/null +++ b/GSM/GSMLogicalChannel.h @@ -0,0 +1,548 @@ +/**@file Logical Channel. */ + +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + + +#ifndef LOGICALCHANNEL_H +#define LOGICALCHANNEL_H + +#include +#include + +#include + +#include "GSML1FEC.h" +#include "GSMSAPMux.h" +#include "GSML2LAPDm.h" +#include "GSML3RRElements.h" +#include "GSMTDMA.h" +#include + +#include + +class ARFCNManager; +class UDPSocket; + + +//namespace Control { +//class TransactionEntry; +//}; + + +namespace GSM { + +typedef InterthreadQueue TransactionFIFO; + +class SACCHLogicalChannel; +class L3Message; +class L3RRMessage; + + +/** + A complete logical channel. + Includes processors for L1, L2, L3, as needed. + The layered structure of GSM is defined in GSM 04.01 7, as well as many other places. + The concept of the logical channel and the channel types are defined in GSM 04.03. + This is virtual class; specific channel types are subclasses. +*/ +class LogicalChannel { + +protected: + + /**@name Contained layer processors. */ + //@{ + L1FEC *mL1; ///< L1 forward error correction + SAPMux mMux; ///< service access point multiplex + L2DL *mL2[4]; ///< data link layer state machines, one per SAP + //@} + + SACCHLogicalChannel *mSACCH; ///< The associated SACCH, if any. + + /** + A FIFO of inbound transactions intiated in the SIP layers on an already-active channel. + Unlike most interthread FIFOs, do *NOT* delete the pointers that come out of it. + */ + TransactionFIFO mTransactionFIFO; + +public: + + /** + Blank initializer just nulls the pointers. + Specific sub-class initializers allocate new components as needed. + */ + LogicalChannel() + :mL1(NULL),mSACCH(NULL) + { + for (int i=0; i<4; i++) mL2[i]=NULL; + } + + + + /** The destructor doesn't do anything since logical channels should not be destroyed. */ + virtual ~LogicalChannel() {}; + + + /**@name Accessors. */ + //@{ + SACCHLogicalChannel* SACCH() { return mSACCH; } + const SACCHLogicalChannel* SACCH() const { return mSACCH; } + L3ChannelDescription channelDescription() const; + //@} + + + /**@name Pass-throughs. */ + //@{ + + /** Set L1 physical parameters from a RACH or pre-exsting channel. */ + virtual void setPhy(float wRSSI, float wTimingError); + + /* Set L1 physical parameters from an existing logical channel. */ + virtual void setPhy(const LogicalChannel&); + + /**@name L3 interfaces */ + //@{ + + /** + Read an L3Frame from SAP0 uplink, blocking, with timeout. + The caller is responsible for deleting the returned pointer. + The default 15 second timeout works for most L3 operations. + @param timeout_ms A read timeout in milliseconds. + @param SAPI The service access point indicator from which to read. + @return A pointer to an L3Frame, to be deleted by the caller, or NULL on timeout. + */ + virtual L3Frame * recv(unsigned timeout_ms = 15000, unsigned SAPI=0) + { assert(mL2[SAPI]); return mL2[SAPI]->readHighSide(timeout_ms); } + + /** + Send an L3Frame on downlink. + This method will block until the message is transferred to the transceiver. + @param frame The L3Frame to be sent. + @param SAPI The service access point indicator. + */ + virtual void send(const L3Frame& frame, unsigned SAPI=0) + { + assert(mL2[SAPI]); + LOG(DEBUG) << "SAP"<< SAPI << " " << frame; + mL2[SAPI]->writeHighSide(frame); + } + + /** + Send "naked" primitive down the channel. + @param prim The primitive to send. + @pram SAPI The service access point on which to send. + */ + virtual void send(const GSM::Primitive& prim, unsigned SAPI=0) + { assert(mL2[SAPI]); mL2[SAPI]->writeHighSide(L3Frame(prim)); } + + /** + Initiate a transaction from the SIP side on an already-active channel. + (*/ + virtual void addTransaction(Control::TransactionEntry* transaction); + + /** + Serialize and send an L3Message with a given primitive. + @param msg The L3 message. + @param prim The primitive to use. + */ + virtual void send(const L3Message& msg, + const GSM::Primitive& prim=DATA, + unsigned SAPI=0); + + /** + Block on a channel until a given primitive arrives. + Any payload is discarded. Block indefinitely, no timeout. + @param primitive The primitive to wait for. + */ + void waitForPrimitive(GSM::Primitive primitive); + + /** + Block on a channel until a given primitive arrives. + Any payload is discarded. Block indefinitely, no timeout. + @param primitive The primitive to wait for. + @param timeout_ms The timeout in milliseconds. + @return True on success, false on timeout. + */ + bool waitForPrimitive(GSM::Primitive primitive, unsigned timeout_ms); + + + + //@} // L3 + + /**@name L1 interfaces */ + //@{ + + /** Write a received radio burst into the "low" side of the channel. */ + virtual void writeLowSide(const RxBurst& burst) { assert(mL1); mL1->writeLowSide(burst); } + + /** Return true if the channel is safely abandoned (closed or orphaned). */ + bool recyclable() const { assert(mL1); return mL1->recyclable(); } + + /** Return true if the channel is active. */ + bool active() const { assert(mL1); return mL1->active(); } + + /** The TDMA parameters for the transmit side. */ + const TDMAMapping& txMapping() const { assert(mL1); return mL1->txMapping(); } + + /** The TDMAParameters for the receive side. */ + const TDMAMapping& rcvMapping() const { assert(mL1); return mL1->rcvMapping(); } + + /** GSM 04.08 10.5.2.5 type and offset code. */ + TypeAndOffset typeAndOffset() const { assert(mL1); return mL1->typeAndOffset(); } + + /** ARFCN */ /* TODO: Use this, or when obtaining the physical info use ARFCN from a diff location? */ + unsigned ARFCN() const { assert(mL1); return mL1->ARFCN(); } + + /**@name Channel stats from the physical layer */ + //@{ + /** Carrier index. */ + unsigned CN() const { return 0; } + /** Slot number. */ + unsigned TN() const { assert(mL1); return mL1->TN(); } + /** Receive FER. */ + float FER() const { assert(mL1); return mL1->FER(); } + /** RSSI wrt full scale. */ + virtual float RSSI() const; + /** Uplink timing error. */ + virtual float timingError() const; + /** Actual MS uplink power. */ + virtual int actualMSPower() const; + /** Actual MS uplink timing advance. */ + virtual int actualMSTiming() const; + //@} + + //@} // L1 + + /**@name L2 passthroughs */ + //@{ + unsigned N200() const { assert(mL2[0]); return mL2[0]->N200(); } + unsigned T200() const { assert(mL2[0]); return mL2[0]->T200(); } + bool multiframeMode(unsigned SAPI) const + { assert(mL2[SAPI]); return mL2[SAPI]->multiframeMode(); } + //@} + + //@} // passthrough + + + /** Connect an ARFCN manager to link L1FEC to the radio. */ + void downstream(ARFCNManager* radio); + + /** Return the channel type. */ + virtual ChannelType type() const =0; + + /** + Make the channel ready for a new transaction. + The channel is closed with primitives from L3. + */ + virtual void open(); + + /**@ Debuging functions: will give access to all intermediate layers. */ + //@{ + L2DL * debugGetL2(unsigned sapi){ return mL2[sapi]; } + L1FEC * debugGetL1(){ return mL1; } + //@} + + const char* descriptiveString() const { return mL1->descriptiveString(); } + + protected: + + /** + Make the normal inter-layer connections. + Should be called from inside the constructor after + the channel components are created. + */ + virtual void connect(); + +}; + + +std::ostream& operator<<(std::ostream&, const LogicalChannel&); + + +/** + Standalone dedicated control channel. + GSM 04.06 4.1.3: "A dedicated control channel (DCCH) is a point-to-point + bi-directional or uni-directional control channel. ... A SDCCH (Stand-alone + DCCH) is a bi-directional DCCH whose allocation is not linked to the + allocation of a TCH. The bit rate of a SDCCH is 598/765 kbit/s. +" +*/ +class SDCCHLogicalChannel : public LogicalChannel { + + public: + + SDCCHLogicalChannel( + unsigned wTN, + const CompleteMapping& wMapping); + + ChannelType type() const { return SDCCHType; } +}; + + + + + +/** + Logical channel for NDCCHs that use Bbis format and a pseudolength. + This is a virtual base class this is extended for CCCH & BCCH. + See GSM 04.06 4.1.1, 4.1.3. +*/ +class NDCCHLogicalChannel : public LogicalChannel { + + public: + + /** This channel only sends RR protocol messages. */ + virtual void send(const L3RRMessage& msg) + { LogicalChannel::send((const L3Message&)msg,UNIT_DATA); } + + /** This channel only sends RR protocol messages. */ + void send(const L3Message&) { assert(0); } + +}; + + + + + + +/** + Slow associated control channel. + + GSM 04.06 4.1.3: "A SACCH (Slow Associated DCCH) is either a bi-directional or + uni-directional DCCH of rate 115/300 or a bi- directional DCCH of rate + 299/765 kbit/s. An independent SACCH is always allocated together with a TCH + or a SDCCH. The co-allocated TCH and SACCH shall be either both bi-directional + or both uni-directional." + + We're going to cut a corner for the moment and give the SAACH a "thin" L2 that + supports only the UNIT_DATA_* primitives (ie, no multiframe mode). This is OK + until we need to transfer SMS for an in-progress call. + + The main role of the SACCH, for now, will be to send SI5 and SI6 messages and + to accept uplink mesaurement reports. +*/ +class SACCHLogicalChannel : public LogicalChannel { + + protected: + + SACCHL1FEC *mSACCHL1; + Thread mServiceThread; ///< a thread for the service loop + bool mRunning; ///< true is the service loop is started + + /** MeasurementResults from the MS. They are caught in serviceLoop, accessed + for recording along with GPS and other data in MobilityManagement.cpp */ + L3MeasurementResults mMeasurementResults; + + public: + + SACCHLogicalChannel( + unsigned wTN, + const MappingPair& wMapping); + + ChannelType type() const { return SACCHType; } + + void open(); + + friend void *SACCHLogicalChannelServiceLoopAdapter(SACCHLogicalChannel*); + + /**@name Pass-through accoessors to L1. */ + //@{ + float RSSI() const { return mSACCHL1->RSSI(); } + float timingError() const { return mSACCHL1->timingError(); } + int actualMSPower() const { return mSACCHL1->actualMSPower(); } + int actualMSTiming() const { return mSACCHL1->actualMSTiming(); } + void setPhy(float RSSI, float timingError) { mSACCHL1->setPhy(RSSI,timingError); } + void setPhy(const SACCHLogicalChannel& other) { mSACCHL1->setPhy(*other.mSACCHL1); } + //@} + + /**@name Channel and neighbour cells stats as reported from MS */ + //@{ + const L3MeasurementResults& measurementResults() const { return mMeasurementResults; } + //@} + + protected: + + /** Read and process a measurement report, called from the service loop. */ + void getReport(); + + /** This is a loop in its own thread that sends SI5 and SI6. */ + void serviceLoop(); + +}; + +/** A C interface for the SACCHLogicalChannel embedded loop. */ +void *SACCHLogicalChannelServiceLoopAdapter(SACCHLogicalChannel*); + + + + + +/** + Common control channel. + The "uplink" component of the CCCH is the RACH. + See GSM 04.03 4.1.2: "A common control channel is a point-to-multipoint + bi-directional control channel. Common control channels are physically + sub-divided into the common control channel (CCCH), the packet common control + channel (PCCCH), and the Compact packet common control channel (CPCCCH)." +*/ +class CCCHLogicalChannel : public NDCCHLogicalChannel { + + protected: + + /* + Because the CCCH is written by multiple threads, + we funnel all of the outgoing messages into a FIFO + and empty that FIFO with a service loop. + */ + + Thread mServiceThread; ///< a thread for the service loop + L3FrameFIFO mQ; ///< because the CCCH is written by multiple threads + bool mRunning; ///< a flag to indication that the service loop is running + + public: + + CCCHLogicalChannel(const TDMAMapping& wMapping); + + void open(); + + void send(const L3RRMessage& msg) + { mQ.write(new L3Frame((const L3Message&)msg,UNIT_DATA)); } + + void send(const L3Message&) { assert(0); } + + /** This is a loop in its own thread that empties mQ. */ + void serviceLoop(); + + /** Return the number of messages waiting for transmission. */ + unsigned load() const { return mQ.size(); } + + ChannelType type() const { return CCCHType; } + + friend void *CCCHLogicalChannelServiceLoopAdapter(CCCHLogicalChannel*); + +}; + +/** A C interface for the CCCHLogicalChannel embedded loop. */ +void *CCCHLogicalChannelServiceLoopAdapter(CCCHLogicalChannel*); + + + +class TCHFACCHLogicalChannel : public LogicalChannel { + + protected: + + TCHFACCHL1FEC * mTCHL1; + + /**@name Sockets for RTP traffic, must be non-blocking. */ + //@{ + UDPSocket * mRTPSocket; ///< RTP traffic + UDPSocket * mRTCPSocket; ///< RTP control + //@} + + public: + + TCHFACCHLogicalChannel( + unsigned wTN, + const CompleteMapping& wMapping); + + UDPSocket * RTPSocket() { return mRTPSocket; } + UDPSocket * RTCPSocket() { return mRTCPSocket; } + + ChannelType type() const { return FACCHType; } + + void sendTCH(const unsigned char* frame) + { assert(mTCHL1); mTCHL1->sendTCH(frame); } + + unsigned char* recvTCH() + { assert(mTCHL1); return mTCHL1->recvTCH(); } + + unsigned queueSize() const + { assert(mTCHL1); return mTCHL1->queueSize(); } + + bool radioFailure() const + { assert(mTCHL1); return mTCHL1->radioFailure(); } +}; + + + + + +/**@name Test channels, not actually used in GSM. */ +//@{ + +/** + A logical channel that loops L3Frames from input to output. + Use a pair of these for control layer testing. +*/ +class L3LoopbackLogicalChannel : public LogicalChannel { + + private: + + L3FrameFIFO mL3Q[4]; ///< a queue used for the loopback + + public: + + L3LoopbackLogicalChannel(); + + /** Fake the SDCCH channel type because that makes sense for most tests. */ + ChannelType type() const { return SDCCHType; } + + /** L3 Loopback */ + void send(const L3Frame& frame, unsigned SAPI=0) + { mL3Q[SAPI].write(new L3Frame(frame)); } + + /** L3 Loopback */ + void send(const GSM::Primitive prim, unsigned SAPI=0) + { mL3Q[SAPI].write(new L3Frame(prim)); } + + /** L3 Loopback */ + L3Frame* recv(unsigned timeout_ms = 15000, unsigned SAPI=0) + { return mL3Q[SAPI].read(timeout_ms); } + +}; + + + +class SDCCHLogicalChannel_LB : public SDCCHLogicalChannel +{ + public : + SDCCHLogicalChannel_LB( + unsigned wTN, + const CompleteMapping& wMapping); +}; + + +class TCHFACCHLogicalChannel_UPLINK : public TCHFACCHLogicalChannel +{ +public: + /** Custom constructor, L2 is Uplink instead of downlink. */ + TCHFACCHLogicalChannel_UPLINK( + unsigned wTN, + const CompleteMapping& wMapping); + +}; + +//@} + +}; // GSM + +#endif + + +// vim: ts=4 sw=4 diff --git a/GSM/GSMSAPMux.cpp b/GSM/GSMSAPMux.cpp new file mode 100644 index 0000000..2113981 --- /dev/null +++ b/GSM/GSMSAPMux.cpp @@ -0,0 +1,101 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include "GSMSAPMux.h" +#include "GSMTransfer.h" +#include "GSML1FEC.h" +#include "GSML2LAPDm.h" + +#include + + +using namespace GSM; + + +void SAPMux::writeHighSide(const L2Frame& frame) +{ + // The SAP may or may not be present, depending on the channel type. + OBJLOG(DEBUG) << frame; + ScopedLock lock(mLock); + mDownstream->writeHighSide(frame); +} + + + +void SAPMux::writeLowSide(const L2Frame& frame) +{ + OBJLOG(DEBUG) << frame.SAPI() << " " << frame; + unsigned SAPI = frame.SAPI(); + bool data = frame.primitive()==DATA; + if (data && (!mUpstream[SAPI])) { + LOG(WARNING) << "received DATA for unsupported SAP " << SAPI; + return; + } + if (data) { + mUpstream[SAPI]->writeLowSide(frame); + } else { + // If this is a non-data primitive, copy it out to every SAP. + for (int i=0; i<4; i++) { + if (mUpstream[i]) mUpstream[i]->writeLowSide(frame); + } + } +} + + + +void LoopbackSAPMux::writeHighSide(const L2Frame& frame) +{ + OBJLOG(DEBUG) << "Loopback " << frame; + // Substitute primitive + L2Frame newFrame(frame); + unsigned SAPI = frame.SAPI(); + switch (frame.primitive()) { + case ERROR: SAPI=0; break; + case RELEASE: return; + default: break; + } + // Because this is a test fixture, as assert here. + // If this were not a text fixture, we would print a warning + // and ignore the frame. + assert(mUpstream[SAPI]); + ScopedLock lock(mLock); + mUpstream[SAPI]->writeLowSide(newFrame); +} + + + +void LoopbackSAPMux::writeLowSide(const L2Frame& frame) +{ + assert(mDownstream); + L2Frame newFrame(frame); + mDownstream->writeHighSide(newFrame); +} + + + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSMSAPMux.h b/GSM/GSMSAPMux.h new file mode 100644 index 0000000..a4ac44d --- /dev/null +++ b/GSM/GSMSAPMux.h @@ -0,0 +1,124 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef SAPMUX_H +#define SAPMUX_H + +#include "GSMTransfer.h" +#include "GSML1FEC.h" + +#include + +namespace GSM { + +class L2DL; + + +/** + A SAPMux is a multipexer the connects a single L1 to multiple L2s. + A "service access point" in GSM/ISDN is analogous to port number in IP. + GSM allows up to 4 SAPs, although only two are presently used. + See GSM 04.05 5.2 for an introduction. +*/ +class SAPMux { + + protected: + + mutable Mutex mLock; + L2DL * mUpstream[4]; ///< one L2 for each SAP, GSM 04.05 5.3 + L1FEC * mDownstream; ///< a single L1 + + public: + + SAPMux(){ + mUpstream[0] = NULL; + mUpstream[1] = NULL; + mUpstream[2] = NULL; + mUpstream[3] = NULL; + mDownstream = NULL; + } + + virtual ~SAPMux() {} + + virtual void writeHighSide(const L2Frame& frame); + virtual void writeLowSide(const L2Frame& frame); + + void upstream( L2DL * wUpstream, unsigned wSAPI=0 ) + { assert(mUpstream[wSAPI]==NULL); mUpstream[wSAPI]=wUpstream; } + void downstream( L1FEC * wDownstream ) + { assert(mDownstream==NULL); mDownstream=wDownstream; } + +}; + + + + +/** + The LoopbackSAPMux is a test fixture. + Writes to the high side are eachoed back to the high side. + Writes to the low side are echoed back to the low side. +*/ +class LoopbackSAPMux : public SAPMux { + + public: + + LoopbackSAPMux():SAPMux() {} + + void writeHighSide(const L2Frame& frame); + void writeLowSide(const L2Frame& frame); + +}; + + +/** + The L1TestPointSAPMux is a test fixture. + Writes to the high side pass through to the low side. + Writes to the low side are dumped to cout. +*/ +class L1TestPointSAPMux : public SAPMux { + + public: + + L1TestPointSAPMux():SAPMux() {} + ~L1TestPointSAPMux() {} + + // These are defined in the .h so that we + // don't have to link in all of L2 to + // use them. + + void writeHighSide(const L2Frame& frame) + { + assert(mDownstream); + mLock.lock(); + mDownstream->writeHighSide(frame); + mLock.unlock(); + } + + void writeLowSide(const L2Frame& frame) + { + LOG(DEBUG) << "SAPMux::writeLowSide frame=" << frame; + } + +}; + + + + +} // namespace GSM + + +#endif +// vim: ts=4 sw=4 diff --git a/GSM/GSMTAPDump.cpp b/GSM/GSMTAPDump.cpp new file mode 100644 index 0000000..0dad35e --- /dev/null +++ b/GSM/GSMTAPDump.cpp @@ -0,0 +1,52 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "GSMTAPDump.h" +#include "GSMTransfer.h" +#include +#include + +UDPSocket GSMTAPSocket; + +void gWriteGSMTAP(unsigned ARFCN, unsigned TS, unsigned FN, const GSM::L2Frame& frame) +{ + if (!gConfig.defines("GSMTAP.TargetIP")) return; + + unsigned port = GSMTAP_UDP_PORT; // default port for GSM-TAP + if (gConfig.defines("GSMTAP.TargetPort")) + port = gConfig.getNum("GSMTAP.TargetPort"); + + // Write a GSMTAP packet to the configured destination. + GSMTAPSocket.destination(port,gConfig.getStr("GSMTAP.TargetIP").c_str()); + char buffer[MAX_UDP_LENGTH]; + gsmtap_hdr header(ARFCN,TS,FN); + memcpy(buffer,&header,sizeof(header)); + frame.pack((unsigned char*)buffer+sizeof(header)); + GSMTAPSocket.write(buffer, sizeof(header) + frame.size()/8); +} + + + +// vim: ts=4 sw=4 diff --git a/GSM/GSMTAPDump.h b/GSM/GSMTAPDump.h new file mode 100644 index 0000000..ae2ea8d --- /dev/null +++ b/GSM/GSMTAPDump.h @@ -0,0 +1,29 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* + 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. + +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + +*/ + + + +#ifndef GSMTAPDUMP_H +#define GSMTAPDUMP_H + +#include "gsmtap.h" +#include "GSMTransfer.h" + + +void gWriteGSMTAP(unsigned ARFCN, unsigned TS, unsigned FN, const GSM::L2Frame& frame); + + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/GSMTDMA.cpp b/GSM/GSMTDMA.cpp new file mode 100644 index 0000000..018b277 --- /dev/null +++ b/GSM/GSMTDMA.cpp @@ -0,0 +1,352 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "GSMTDMA.h" + + +using namespace GSM; + + + + +TDMAMapping::TDMAMapping(TypeAndOffset + wTypeAndOffset, bool wDownlink, bool wUplink, char wAllowedSlots, bool wC0Only, + unsigned wRepeatLength, unsigned wNumFrames, const unsigned *wFrameMapping) + :mTypeAndOffset(wTypeAndOffset), + mDownlink(wDownlink),mUplink(wUplink),mAllowedSlots(wAllowedSlots),mC0Only(wC0Only), + mRepeatLength(wRepeatLength),mNumFrames(wNumFrames),mFrameMapping(wFrameMapping) +{ + // Sanity check. + assert(mRepeatLength<=mMaxRepeatLength); + + // Default, -1, means a non-occupied position. + for (unsigned i=0; i. + +*/ + + + + +#include + +#include "GSMTransfer.h" +#include "GSML3Message.h" + + +using namespace std; +using namespace GSM; + + +ostream& GSM::operator<<(ostream& os, const L2Frame& frame) +{ + os << "primitive=" << frame.primitive(); + os << " raw=("; + frame.hex(os); + os << ")"; + return os; +} + + +ostream& GSM::operator<<(ostream& os, const L3Frame& frame) +{ + os << "primitive=" << frame.primitive(); + os << " raw=("; + frame.hex(os); + os << ")"; + return os; +} + + +ostream& GSM::operator<<(ostream& os, const L2Header::FrameFormat val) +{ + switch (val) { + case L2Header::FmtA: os << "A"; break; + case L2Header::FmtB: os << "B"; break; + case L2Header::FmtBbis: os << "Bbis"; break; + case L2Header::FmtBter: os << "Bter"; break; + case L2Header::FmtB4: os << "B4"; break; + case L2Header::FmtC: os << "C"; break; + default: os << "?" << (int)val << "?"; + } + return os; +} + + + +size_t N201(ChannelType wChanType, L2Header::FrameFormat wFormat) +{ + // Number of payload bytes in the L2Frame. + // GSM 04.06 5.8.3 + switch (wFormat) { + case L2Header::FmtA: + case L2Header::FmtB: + switch (wChanType) { + case SACCHType: return 18; + case FACCHType: + case SDCCHType: return 20; + default: abort(); + } + case L2Header::FmtBbis: + // We count L2 pseudolength as part of the header. + switch (wChanType) { + case BCCHType: + case CCCHType: return 22; + default: abort(); + } + case L2Header::FmtBter: + switch (wChanType) { + case SACCHType: return 21; + case FACCHType: + case SDCCHType: return 23; + default: abort(); + } + case L2Header::FmtB4: + switch (wChanType) { + case SACCHType: return 19; + default: abort(); + } + default: + abort(); + } +} + + + + + + + +size_t L2Header::bitsNeeded() const +{ + // number of BITS to encode the header + // GSM 04.06 2.1 + switch (mFormat) { + case FmtA: + case FmtB: return 3*8; + case FmtBbis: return 8; + case FmtBter: return 0; + case FmtB4: return 2*8; + case FmtC: return 0; + default: abort(); + } +} + + + +size_t L2Header::write(L2Frame& frame) const +{ + size_t wp=0; + switch (mFormat) { + case FmtA: + case FmtB: + mAddress.write(frame,wp); + mControl.write(frame,wp); + mLength.write(frame,wp); + break; + case FmtBbis: + mLength.write(frame,wp); + break; + case FmtBter: + break; + case FmtB4: + mAddress.write(frame,wp); + mControl.write(frame,wp); + break; + case FmtC: + break; + default: + assert(0); + } + return wp; +} + + + + + + +void L2Control::write(L2Frame& frame, size_t& wp) const +{ + // GSM 04.06 Table 3 + + switch (mFormat) { + case IFormat: { + frame.writeField(wp,mNR,3); + frame.writeField(wp,mPF,1); + frame.writeField(wp,mNS,3); + frame.writeField(wp,0,1); + break; + } + case SFormat:{ + frame.writeField(wp,mNR,3); + frame.writeField(wp,mPF,1); + frame.writeField(wp,mSBits,2); + frame.writeField(wp,1,2); + break; + } + case UFormat:{ + const unsigned U1 = mUBits >> 2; + const unsigned U2 = mUBits & 0x03; + frame.writeField(wp,U1,3); + frame.writeField(wp,mPF,1); + frame.writeField(wp,U2,2); + frame.writeField(wp,3,2); + break; + } + default: + abort(); + } +} + +void L2Length::write(L2Frame& frame, size_t& wp) const +{ + // GSM 04.06 3.6 + assert(mL<64); + frame.writeField(wp,mL,6); + frame.writeField(wp,mM,1); + frame.writeField(wp,1,1); +} + + + + +void L2Frame::idleFill() +{ + // GSM 04.06 2.2 + static const int pattern[8] = {0,0,1,0,1,0,1,1}; + for (size_t i=0; isize()); + bits.copyTo(*this); +} + + +L2Frame::L2Frame(const L2Header& header, const BitVector& l3) + :BitVector(23*8),mPrimitive(DATA) +{ + idleFill(); + assert((header.bitsNeeded()+l3.size())<=this->size()); + size_t wp = header.write(*this); + l3.copyToSegment(*this,wp); +} + + +L2Frame::L2Frame(const L2Header& header) + :BitVector(23*8),mPrimitive(DATA) +{ + idleFill(); + header.write(*this); +} + + + +unsigned L2Frame::SAPI() const +{ + // Get the service access point indicator, + // assuming frame format A or B. + // See GSM 04.06 2.1, 2.3, 3.2. + // This assumes MSB-first field packing. + return peekField(3,3); +} + + +unsigned L2Frame::LPD() const +{ + // This assumes MSB-first field packing. + // See GSM 04.06 3.2, GSM 04.12 3.3.1. + return peekField(1,2); +} + + +L2Control::ControlFormat L2Frame::controlFormat() const +{ + // Determine the LAPDm frame type. + // See GSM 04.06 Table 3. + // The control field is in the second octet. + if (bit(8+7)==0) return L2Control::IFormat; + if (bit(8+6)==0) return L2Control::SFormat; + return L2Control::UFormat; +} + +L2Control::FrameType L2Frame::UFrameType() const +{ + // Determine U-frame command type. + // GSM 04.06 Table 4. + // TODO -- This would be more efficient as an array. + char upper = peekField(8+0,3); + char lower = peekField(8+4,2); + char uBits = upper<<2 | lower; + switch (uBits) { + case 0x07: return L2Control::SABMFrame; + case 0x03: return L2Control::DMFrame; + case 0x00: return L2Control::UIFrame; + case 0x08: return L2Control::DISCFrame; + case 0x0c: return L2Control::UAFrame; + default: return L2Control::BogusFrame; + } +} + + +L2Control::FrameType L2Frame::SFrameType() const +{ + // Determine S-frame command type. + // GSM 04.06 Table 4. + char sBits = peekField(8+4,2); + static const L2Control::FrameType type[] = { + L2Control::RRFrame, L2Control::RNRFrame, + L2Control::REJFrame, L2Control::BogusFrame }; + return type[(int)sBits]; +} + + + + + + +ostream& GSM::operator<<(ostream& os, const TxBurst& ts) +{ + os << "time=" << ts.time() << " data=(" << (const BitVector&)ts << ")" ; + return os; +} + +ostream& GSM::operator<<(ostream& os, const RxBurst& ts) +{ + os << "time=" << ts.time(); + os << " RSSI=" << ts.RSSI() << " timing=" << ts.timingError(); + os << " data=(" << (const SoftVector&)ts << ")" ; + return os; +} + + + + +// We put this in the .cpp file to avoid a circular dependency. +TxBurst::TxBurst(const RxBurst& rx) + :BitVector((const BitVector&)rx),mTime(rx.time()) +{} + +// We put this in the .cpp file to avoid a circular dependency. +RxBurst::RxBurst(const TxBurst& source, float wTimingError, int wRSSI) + :SoftVector((const BitVector&) source),mTime(source.time()), + mTimingError(wTimingError),mRSSI(wRSSI) +{ } + + + +// Methods for the L2 address field. + +void L2Address::write(L2Frame& frame, size_t& wp) const +{ + // GSM 04.06 3.2, 3.3 + frame.writeField(wp,0,1); // spare bit + frame.writeField(wp,mLPD,2); + frame.writeField(wp,mSAPI,3); + frame.writeField(wp,mCR,1); + frame.writeField(wp,1,1); // no extension +} + + + + + +ostream& GSM::operator<<(ostream& os, const L2Address& address) +{ + os << "SAPI=" << address.SAPI() << " CR=" << address.CR(); + return os; +} + + +ostream& GSM::operator<<(ostream& os,L2Control::ControlFormat format) +{ + switch (format) { + case L2Control::IFormat: os << "I"; break; + case L2Control::SFormat: os << "S"; break; + case L2Control::UFormat: os << "U"; break; + default: os << "?" << (int)format << "?"; break; + } + return os; +} + + +ostream& GSM::operator<<(ostream& os, const L2Control& control) +{ + os << "fmt=" << control.format() << " "; + switch (control.format()) { + case L2Control::IFormat: + os << "NR=" << control.NR() << " PF=" << control.PF() << " NS=" << control.NS(); + break; + case L2Control::SFormat: + os << "NR=" << control.NR() << " PF=" << control.PF(); + os << hex << " Sbits=0x" << control.SBits() << dec; + break; + case L2Control::UFormat: + os << "PF=" << control.PF(); + os << hex << " Ubits=0x" << control.UBits() << dec; + break; + default: + os << "??"; + } + return os; +} + + +ostream& GSM::operator<<(ostream& os, const L2Length& length) +{ + os << "L=" << length.L() << " M=" << length.M(); + return os; +} + + +ostream& GSM::operator<<(ostream& os, const L2Header& header) +{ + os << "fmt=" << header.format(); + os << " addr=(" << header.address() << ")"; + os << " cntrl=(" << header.control() << ")"; + os << " len=(" << header.length() << ")"; + return os; +} + + + + +ostream& GSM::operator<<(ostream& os, L2Control::FrameType cmd) +{ + switch (cmd) { + case L2Control::UIFrame: os << "UI"; break; + case L2Control::SABMFrame: os << "SABM"; break; + case L2Control::UAFrame: os << "UA"; break; + case L2Control::DMFrame: os << "DM"; break; + case L2Control::DISCFrame: os << "DISC"; break; + case L2Control::RRFrame: os << "RR"; break; + case L2Control::RNRFrame: os << "RNR"; break; + case L2Control::REJFrame: os << "REJ"; break; + case L2Control::IFrame: os << "I"; break; + default: os << "?" << (int)cmd << "?"; + } + return os; +} + + +ostream& GSM::operator<<(ostream& os, Primitive prim) +{ + switch (prim) { + case ESTABLISH: os << "ESTABLISH"; break; + case RELEASE: os << "RELEASE"; break; + case DATA: os << "DATA"; break; + case UNIT_DATA: os << "UNIT_DATA"; break; + case ERROR: os << "ERROR"; break; + case HARDRELEASE: os << "HARDRELEASE"; break; + default: os << "?" << (int)prim << "?"; + } + return os; +} + + + + +L3Frame::L3Frame(const L3Message& msg, Primitive wPrimitive) + :BitVector(msg.bitsNeeded()),mPrimitive(wPrimitive), + mL2Length(msg.L2Length()) +{ + msg.write(*this); +} + + + +L3Frame::L3Frame(const char* hexString) + :mPrimitive(DATA) +{ + size_t len = strlen(hexString); + mL2Length = len/2; + resize(len*4); + size_t wp=0; + for (size_t i=0; i9) v = c - 'a' + 10; + writeField(wp,v,4); + } +} + + +L3Frame::L3Frame(const char* binary, size_t len) + :mPrimitive(DATA) +{ + mL2Length = len; + resize(len*8); + size_t wp=0; + for (size_t i=0; i(const TxBurst& other) const + { return mTime > other.mTime; } + + /** Set upper stealing bit. */ + void Hu(bool HuVal) { mData[gHuIndex] = HuVal; } + + /** Set lower stealing bit. */ + void Hl(bool HlVal) { mData[gHlIndex] = HlVal; } + + friend std::ostream& operator<<(std::ostream& os, const TxBurst& ts); + +}; + + + + + +std::ostream& operator<<(std::ostream& os, const TxBurst& ts); + +typedef InterthreadQueue TxBurstFIFO; + +/** The InterthreadPriorityQueue accepts Timeslots and sorts them by Timestamp. */ +class TxBurstQueue : public InterthreadPriorityQueue { + + public: + + /** Get the framenumber of the next outgoing burst. Blocks if queue is empty. */ + Time nextTime() const; + +}; + + + + + +/** + Class to represent one timeslot of channel bits with soft encoding. +*/ +class RxBurst : public SoftVector { + + private: + + Time mTime; ///< timeslot and frame on which this was received + float mTimingError; ///< Timing error in symbol steps, <0 means early. + float mRSSI; ///< RSSI estimate associated with the slot, dB wrt full scale. + + + public: + + /** Initialize an RxBurst from a hard Timeslot. Note the funny cast. */ + RxBurst(const TxBurst& source, float wTimingError=0, int wRSSI=0); + + /** Wrap an RxBurst around an existing float array. */ + RxBurst(float* wData, const Time &wTime, float wTimingError, int wRSSI) + :SoftVector(wData,gSlotLen),mTime(wTime), + mTimingError(wTimingError),mRSSI(wRSSI) + { } + + + Time time() const { return mTime; } + + void time(const Time& wTime) { mTime = wTime; } + + float RSSI() const { return mRSSI; } + + float timingError() const { return mTimingError; } + + /** Return a SoftVector alias to the first data field. */ + const SoftVector data1() const { return segment(3, 57); } + + /** Return a SoftVector alias to the second data field. */ + const SoftVector data2() const { return segment(88, 57); } + + /** Return upper stealing bit. */ + bool Hu() const { return bit(gHuIndex); } + + /** Return lower stealing bit. */ + bool Hl() const { return bit(gHlIndex); } + + /** Mark even bits as unkmnown. */ + void clearEven(); + + /** Mark odd bits as unknown. */ + void clearOdd(); + + friend std::ostream& operator<<(std::ostream& os, const RxBurst& ts); +}; + +std::ostream& operator<<(std::ostream& os, const RxBurst& ts); + + + +typedef InterthreadQueue RxBurstFIFO; + + + +class L2Frame; +class L3Frame; + + + + + +/** L2 Address as per GSM 04.06 3.2 */ +class L2Address { + + private: + + unsigned mSAPI; ///< service access point indicator + unsigned mCR; ///< command/response flag + unsigned mLPD; ///< link protocol discriminator + + public: + + L2Address(unsigned wCR=0, unsigned wSAPI=0, unsigned wLPD=0) + :mSAPI(wSAPI),mCR(wCR),mLPD(wLPD) + { + assert(wSAPI<4); + } + + /**@name Obvious accessors. */ + //@{ + unsigned SAPI() const { return mSAPI; } + unsigned CR() const { return mCR; } + unsigned LPD() const { return mLPD; } + //@} + + /** Write attributes to an L2 frame. */ + void write(L2Frame& target, size_t& writeIndex) const; + +}; + + +std::ostream& operator<<(std::ostream& os, const L2Address& address); + + + + + +/** The L2 header control field, as per GSM 04.06 3.4 */ +class L2Control { + + public: + + /** Control field format types, GSM 04.06 3.4. */ + enum ControlFormat { IFormat, SFormat, UFormat }; + + /** LAPDm frame types, GSM 04.06 3.8.1. */ + enum FrameType { + UIFrame, + SABMFrame, + UAFrame, + DMFrame, + DISCFrame, + RRFrame, + RNRFrame, + REJFrame, + IFrame, + BogusFrame ///< a return code used when parsing fails + }; + + + private: + + ControlFormat mFormat; ///< control field format + unsigned mNR; ///< receive sequence number + unsigned mNS; ///< transmit sequence number + unsigned mPF; ///< poll/final bit + unsigned mSBits; ///< supervisory bits + unsigned mUBits; ///< unnumbered function bits + + + public: + + /** Initialize a U or S frame. */ + L2Control(ControlFormat wFormat=UFormat, unsigned wPF=0, unsigned bits=0) + :mFormat(wFormat),mPF(wPF),mSBits(bits),mUBits(bits) + { + assert(mFormat!=IFormat); + assert(mPF<2); + if (mFormat==UFormat) assert(mUBits<0x20); + if (mFormat==SFormat) assert(mSBits<0x04); + } + + /** Initialize an I frame. */ + L2Control(unsigned wNR, unsigned wNS, unsigned wPF) + :mFormat(IFormat),mNR(wNR),mNS(wNS),mPF(wPF) + { + assert(mNR<8); + assert(mNS<8); + assert(mPF<2); + } + + + /**@name Obvious accessors. */ + //@{ + ControlFormat format() const { return mFormat; } + unsigned NR() const { assert(mFormat!=UFormat); return mNR; } + void NR(unsigned wNR) { assert(mFormat!=UFormat); mNR=wNR; } + unsigned NS() const { assert(mFormat==IFormat); return mNS; } + void NS(unsigned wNS) { assert(mFormat==IFormat); mNS=wNS; } + unsigned PF() const { assert(mFormat!=IFormat); return mPF; } + unsigned P() const { assert(mFormat==IFormat); return mPF; } + unsigned SBits() const { assert(mFormat==SFormat); return mSBits; } + unsigned UBits() const { assert(mFormat==UFormat); return mUBits; } + //@} + + + void write(L2Frame& target, size_t& writeIndex) const; + + /** decode frame type */ + FrameType decodeFrameType() const; +}; + + + + + +std::ostream& operator<<(std::ostream& os, L2Control::ControlFormat fmt); +std::ostream& operator<<(std::ostream& os, L2Control::FrameType cmd); +std::ostream& operator<<(std::ostream& os, const L2Control& control); + + +/** L2 frame length field, GSM 04.06 3.6 */ +class L2Length { + + private: + + unsigned mL; ///< payload length in the frame + unsigned mM; ///< more data flag ("1" indicates segmentation) + + + public: + + L2Length(unsigned wL=0, bool wM=0) + :mL(wL),mM(wM) + { } + + /**@name Obvious accessors. */ + //@{ + unsigned L() const { return mL; } + void L(unsigned wL) { mL=wL; } + + unsigned M() const { return mM; } + void M(unsigned wM) { mM=wM; } + //@} + + void write(L2Frame& target, size_t &writeIndex) const; + +}; + + +std::ostream& operator<<(std::ostream&, const L2Length&); + + + + + +/** The total L2 header, as per GSM 04.06 3 */ +class L2Header { + + public: + + /** LAPDm frame format types, GSM 04.06 2.1 */ + enum FrameFormat { + FmtA, ///< full header (just use B instead) + FmtB, ///< full header + FmtBbis, ///< no header (actually, a pseudolength header) + FmtBter, ///< "short header" (which we don't use) + FmtB4, ///< addesss and control only, implied length + FmtC, ///< RACH (which we don't use) + }; + + + + private: + + FrameFormat mFormat; ///< format to use in the L2 frame + L2Address mAddress; ///< GSM 04.06 2.3 + L2Control mControl; ///< GSM 04.06 2.4 + L2Length mLength; ///< GSM 04.06 2.5 + + public: + + + /** Parse the header from an L2Frame, assuming DCCH uplink. */ + L2Header(FrameFormat wFormat, const L2Frame& source); + + /** Format A or B. */ + L2Header(const L2Address& wAddress, const L2Control& wControl, const L2Length& wLength, + FrameFormat wFormat=FmtB) + :mFormat(wFormat), + mAddress(wAddress), mControl(wControl), mLength(wLength) + { } + + /** Format B4. */ + L2Header(const L2Address& wAddress, const L2Control& wControl) + :mFormat(FmtB4), + mAddress(wAddress), mControl(wControl) + { } + + /** Pseudolength case, used on non-dedicated control channels. */ + L2Header(const L2Length& wLength) + :mFormat(FmtBbis), + mLength(wLength) + { } + + /** + Write the header into an L2Frame at a given offset. + @param frame The frame to write to. + @return number of bits written. + */ + size_t write(L2Frame& target) const; + + /** Determine the header's LAPDm operation. */ + L2Control::FrameType decodeFrameType() const { return mControl.decodeFrameType(); } + + /**@name Obvious accessors. */ + //@{ + FrameFormat format() const { return mFormat; } + void format(FrameFormat wFormat) { mFormat=wFormat; } + + const L2Address& address() const { return mAddress; } + L2Address& address() { return mAddress; } + void address(const L2Address& wAddress) { mAddress=wAddress; } + + const L2Control& control() const { return mControl; } + L2Control& control() { return mControl; } + void control(const L2Control& wControl) { mControl=wControl; } + + const L2Length& length() const { return mLength; } + L2Length& length() { return mLength; } + void length(const L2Length& wLength) { mLength=wLength; } + //@} + + /** Return the number of bits needed to encode the header. */ + size_t bitsNeeded() const; +}; + + +std::ostream& operator<<(std::ostream& os, const L2Header& header); +std::ostream& operator<<(std::ostream& os, const L2Header::FrameFormat val); + +/** N201, the maximum payload size of an L2 frame in bytes, GSM 04.06 5.8.3. */ +unsigned N201(ChannelType, L2Header::FrameFormat); + + + + + +/** + The bits of an L2Frame + Bit ordering is MSB-first in each octet. +*/ +class L2Frame : public BitVector { + + private: + + GSM::Primitive mPrimitive; + + public: + + /** Fill the frame with the GSM idle pattern, GSM 04.06 2.2. */ + void idleFill(); + + /** Build an empty frame with a given primitive. */ + L2Frame(GSM::Primitive wPrimitive=UNIT_DATA) + :BitVector(23*8), + mPrimitive(wPrimitive) + { idleFill(); } + + /** Make a new L2 frame by copying an existing one. */ + L2Frame(const L2Frame& other) + :BitVector((const BitVector&)other), + mPrimitive(other.mPrimitive) + { } + + /** + Make an L2Frame from a block of bits. + BitVector must fit in the L2Frame. + */ + L2Frame(const BitVector&, GSM::Primitive); + + /** + Make an L2Frame from a payload using a given header. + The L3Frame must fit in the L2Frame. + The primitive is DATA. + */ + L2Frame(const L2Header&, const BitVector&); + + /** + Make an L2Frame from a header with no payload. + The primitive is DATA. + */ + L2Frame(const L2Header&); + + /** Get the LPD from the L2 header. Assumes address byte is first. */ + unsigned LPD() const; + + /** + Look into the LAPDm header and get the SAPI, see GSM 04.06 2 and 3.2. + This method assumes frame format A or B, GSM 04.06 2.1. + */ + unsigned SAPI() const; + + + /**@name Decoding methods that assume A/B header format. */ + //@{ + + /** Look into the LAPDm header and get the control format. */ + L2Control::ControlFormat controlFormat() const; + + /** Look into the LAPDm header and decode the U-frame type. */ + L2Control::FrameType UFrameType() const; + + /** Look into the LAPDm header and decode the S-frame type. */ + L2Control::FrameType SFrameType() const; + + /** Look into the LAPDm header and get the P/F bit. */ + bool PF() const { return mStart[8+3] & 0x01; } + + /** Set/clear the PF bit. */ + void PF(bool wPF) { mStart[8+3]=wPF; } + + /** Look into the header and get the length of the payload. */ + unsigned L() const { return peekField(8*2,6); } + + /** Get the "more data" bit (M). */ + bool M() const { return mStart[8*2+6] & 0x01; } + + /** Return the L3 payload part. Assumes A or B header format. */ + BitVector L3Part() const { return segment(8*3,8*L()); } + + /** Return NR sequence number, GSM 04.06 3.5.2.4. Assumes A or B header. */ + unsigned NR() const { return peekField(8*1+0,3); } + + /** Return NS sequence number, GSM 04.06 3.5.2.5. Assumes A or B header. */ + unsigned NS() const { return peekField(8*1+4,3); } + + /** Return the CR bit, GSM 04.06 3.3.2. Assumes A or B header. */ + bool CR() const { return mStart[6] & 0x01; } + + /** Return truw if this a DCCH idle frame. */ + bool DCCHIdle() const + { + return peekField(0,32)==0x0103012B; + } + + //@} + + Primitive primitive() const { return mPrimitive; } + + /** This is used only for testing. */ + void primitive(Primitive wPrimitive) { mPrimitive=wPrimitive; } + +}; + +std::ostream& operator<<(std::ostream& os, const L2Frame& msg); + + +typedef InterthreadQueueWithWait L2FrameFIFO; + + + +/** + Representation of a GSM L3 message in a bit vector. + Bit ordering is MSB-first in each octet. + NOTE: This is for the GSM message bits, not the message content. See L3Message. +*/ +class L3Frame : public BitVector { + + private: + + Primitive mPrimitive; + size_t mL2Length; ///< length, or L2 pseudo-length, as appropriate + + public: + + /** Empty frame with a primitive. */ + L3Frame(Primitive wPrimitive=DATA, size_t len=0) + :BitVector(len),mPrimitive(wPrimitive),mL2Length(len) + { } + + /** Put raw bits into the frame. */ + L3Frame(const BitVector& source, Primitive wPrimitive=DATA) + :BitVector(source),mPrimitive(wPrimitive),mL2Length(source.size()/8) + { if (source.size()%8) mL2Length++; } + + /** Concatenate 2 L3Frames */ + L3Frame(const L3Frame& f1, const L3Frame& f2) + :BitVector(f1,f2),mPrimitive(DATA), + mL2Length(f1.mL2Length + f2.mL2Length) + {} + + /** Build from an L2Frame. */ + L3Frame(const L2Frame& source) + :BitVector(source.L3Part()),mPrimitive(DATA), + mL2Length(source.L()) + { } + + /** Serialize a message into the frame. */ + L3Frame(const L3Message& msg, Primitive wPrimitive=DATA); + + /** Get a frame from a hex string. */ + L3Frame(const char*); + + /** Get a frame from raw binary. */ + L3Frame(const char*, size_t len); + + /** Protocol Discriminator, GSM 04.08 10.2. */ + L3PD PD() const { return (L3PD)peekField(4,4); } + + /** Message Type Indicator, GSM 04.08 10.4. */ + unsigned MTI() const { return peekField(8,8); } + + /** TI value, GSM 04.07 11.2.3.1.3. */ + unsigned TI() const { return peekField(0,4); } + + /** Return the associated primitive. */ + GSM::Primitive primitive() const { return mPrimitive; } + + /** Return frame length in BYTES. */ + size_t length() const { return size()/8; } + + /** Length, or L2 pseudolength, as appropriate */ + size_t L2Length() const { return mL2Length; } + + void L2Length(size_t wL2Length) { mL2Length=wL2Length; } + + // Methods for writing H/L bits into rest octets. + void writeH(size_t& wp); + void writeL(size_t& wp); +}; + + + +std::ostream& operator<<(std::ostream& os, const L3Frame&); + +typedef InterthreadQueue L3FrameFIFO; + + + +/** A vocoder frame for use in GSM/SIP contexts. */ +class VocoderFrame : public BitVector { + + public: + + VocoderFrame() + :BitVector(264) + { fillField(0,0x0d,4); } + + /** Construct by unpacking a char[33]. */ + VocoderFrame(const unsigned char *src) + :BitVector(264) + { unpack(src); } + + BitVector payload() { return tail(4); } + const BitVector payload() const { return tail(4); } + +}; + + +typedef InterthreadQueue VocoderFrameFIFO; + +}; // namespace GSM + + + +#endif + + +// vim: ts=4 sw=4 diff --git a/GSM/Makefile.am b/GSM/Makefile.am new file mode 100644 index 0000000..dc4f6dc --- /dev/null +++ b/GSM/Makefile.am @@ -0,0 +1,72 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +#AM_CXXFLAGS = -O2 -g + +noinst_LTLIBRARIES = libGSM.la + +libGSM_la_SOURCES = \ + GSM610Tables.cpp \ + GSMCommon.cpp \ + GSMConfig.cpp \ + GSML1FEC.cpp \ + GSML2LAPDm.cpp \ + GSML3CCElements.cpp \ + GSML3CCMessages.cpp \ + GSML3CommonElements.cpp \ + GSML3Message.cpp \ + GSML3MMElements.cpp \ + GSML3MMMessages.cpp \ + GSML3RRElements.cpp \ + GSML3RRMessages.cpp \ + GSMLogicalChannel.cpp \ + GSMSAPMux.cpp \ + GSMTDMA.cpp \ + GSMTransfer.cpp \ + GSMTAPDump.cpp \ + PowerManager.cpp\ + PhysicalStatus.cpp + +noinst_HEADERS = \ + GSM610Tables.h \ + GSMCommon.h \ + GSMConfig.h \ + GSML1FEC.h \ + GSML2LAPDm.h \ + GSML3CCElements.h \ + GSML3CCMessages.h \ + GSML3CommonElements.h \ + GSML3Message.h \ + GSML3MMElements.h \ + GSML3MMMessages.h \ + GSML3RRElements.h \ + GSML3RRMessages.h \ + GSMLogicalChannel.h \ + GSMSAPMux.h \ + GSMTDMA.h \ + GSMTransfer.h \ + PowerManager.h \ + GSMTAPDump.h \ + gsmtap.h \ + PhysicalStatus.h + diff --git a/GSM/Makefile.in b/GSM/Makefile.in new file mode 100644 index 0000000..9c1a38f --- /dev/null +++ b/GSM/Makefile.in @@ -0,0 +1,592 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libGSM_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = GSM +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libGSM_la_LIBADD = +am_libGSM_la_OBJECTS = GSM610Tables.lo GSMCommon.lo GSMConfig.lo \ + GSML1FEC.lo GSML2LAPDm.lo GSML3CCElements.lo \ + GSML3CCMessages.lo GSML3CommonElements.lo GSML3Message.lo \ + GSML3MMElements.lo GSML3MMMessages.lo GSML3RRElements.lo \ + GSML3RRMessages.lo GSMLogicalChannel.lo GSMSAPMux.lo \ + GSMTDMA.lo GSMTransfer.lo GSMTAPDump.lo PowerManager.lo \ + PhysicalStatus.lo +libGSM_la_OBJECTS = $(am_libGSM_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libGSM_la_SOURCES) +DIST_SOURCES = $(libGSM_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +#AM_CXXFLAGS = -O2 -g +noinst_LTLIBRARIES = libGSM.la +libGSM_la_SOURCES = \ + GSM610Tables.cpp \ + GSMCommon.cpp \ + GSMConfig.cpp \ + GSML1FEC.cpp \ + GSML2LAPDm.cpp \ + GSML3CCElements.cpp \ + GSML3CCMessages.cpp \ + GSML3CommonElements.cpp \ + GSML3Message.cpp \ + GSML3MMElements.cpp \ + GSML3MMMessages.cpp \ + GSML3RRElements.cpp \ + GSML3RRMessages.cpp \ + GSMLogicalChannel.cpp \ + GSMSAPMux.cpp \ + GSMTDMA.cpp \ + GSMTransfer.cpp \ + GSMTAPDump.cpp \ + PowerManager.cpp\ + PhysicalStatus.cpp + +noinst_HEADERS = \ + GSM610Tables.h \ + GSMCommon.h \ + GSMConfig.h \ + GSML1FEC.h \ + GSML2LAPDm.h \ + GSML3CCElements.h \ + GSML3CCMessages.h \ + GSML3CommonElements.h \ + GSML3Message.h \ + GSML3MMElements.h \ + GSML3MMMessages.h \ + GSML3RRElements.h \ + GSML3RRMessages.h \ + GSMLogicalChannel.h \ + GSMSAPMux.h \ + GSMTDMA.h \ + GSMTransfer.h \ + PowerManager.h \ + GSMTAPDump.h \ + gsmtap.h \ + PhysicalStatus.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu GSM/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu GSM/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libGSM.la: $(libGSM_la_OBJECTS) $(libGSM_la_DEPENDENCIES) + $(CXXLINK) $(libGSM_la_LDFLAGS) $(libGSM_la_OBJECTS) $(libGSM_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSM610Tables.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMCommon.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMConfig.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML1FEC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML2LAPDm.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3CCElements.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3CCMessages.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3CommonElements.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3MMElements.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3MMMessages.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3Message.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3RRElements.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSML3RRMessages.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMLogicalChannel.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMSAPMux.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMTAPDump.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMTDMA.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GSMTransfer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PhysicalStatus.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PowerManager.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/GSM/PhysicalStatus.cpp b/GSM/PhysicalStatus.cpp new file mode 100644 index 0000000..e4dbe62 --- /dev/null +++ b/GSM/PhysicalStatus.cpp @@ -0,0 +1,180 @@ +/**@file Declarations for PhysicalStatus and related classes. */ + +/* +* Copyright 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include "PhysicalStatus.h" +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +using namespace std; +using namespace GSM; + + +static const char* createPhysicalStatus = { + "CREATE TABLE IF NOT EXISTS PHYSTATUS (" + "CN_TN_TYPE_AND_OFFSET STRING PRIMARY KEY, " // CnTn - + "ARFCN INTEGER DEFAULT NULL, " // actual ARFCN + "ACCESSED INTEGER DEFAULT 0, " // Unix time of last update + "RXLEV_FULL_SERVING_CELL INTEGER DEFAULT NULL, " // from the most recent measurement report + "RXLEV_SUB_SERVING_CELL INTEGER DEFAULT NULL, " // from the most recent measurement report + "RXQUAL_FULL_SERVING_CELL_BER FLOAT DEFAULT NULL, " // from the most recent measurement report + "RXQUAL_SUB_SERVING_CELL_BER FLOAT DEFAULT NULL, " // from the most recent measurement report + "RSSI FLOAT DEFAULT NULL, " // RSSI relative to full scale input + "TIME_ERR FLOAT DEFAULT NULL, " // timing advance error in symbol periods + "TRANS_PWR INTEGER DEFAULT NULL, " // handset tx power in dBm + "TIME_ADVC INTEGER DEFAULT NULL, " // handset timing advance in symbol periods + "FER FLOAT DEFAULT NULL " // uplink FER + ")" +}; + +PhysicalStatus::PhysicalStatus(const char* wPath) +{ + int rc = sqlite3_open(wPath, &mDB); + if (rc) { + LOG(EMERG) << "Cannot open PhysicalStatus database at " << wPath << ": " << sqlite3_errmsg(mDB); + sqlite3_close(mDB); + mDB = NULL; + return; + } + if (!sqlite3_command(mDB, createPhysicalStatus)) { + LOG(EMERG) << "Cannot create TMSI table"; + } +} + +PhysicalStatus::~PhysicalStatus() +{ + if (mDB) sqlite3_close(mDB); +} + +bool PhysicalStatus::createEntry(const LogicalChannel* chan) +{ + assert(mDB); + assert(chan); + + ScopedLock lock(mLock); + + const char* chanString = chan->descriptiveString(); + LOG(DEBUG) << chan->descriptiveString(); + + /* Check to see if the key exists. */ + if (!sqlite3_exists(mDB, "PHYSTATUS", "CN_TN_TYPE_AND_OFFSET", chanString)) { + /* No? Ok, it should now. */ + char query[500]; + sprintf(query, "INSERT INTO PHYSTATUS (CN_TN_TYPE_AND_OFFSET, ACCESSED) VALUES " + "(\"%s\", %u)", + chanString, (unsigned)time(NULL)); + return sqlite3_command(mDB, query); + } + + return false; +} + +bool PhysicalStatus::setPhysical(const LogicalChannel* chan, + const L3MeasurementResults& measResults) +{ + // TODO -- It would be better if the argument what just the channel + // and the key was just the descriptiveString. + + assert(mDB); + assert(chan); + + ScopedLock lock(mLock); + + createEntry(chan); + + char query[500]; + sprintf(query, + "UPDATE PHYSTATUS SET " + "RXLEV_FULL_SERVING_CELL=%d, " + "RXLEV_SUB_SERVING_CELL=%d, " + "RXQUAL_FULL_SERVING_CELL_BER=%f, " + "RXQUAL_SUB_SERVING_CELL_BER=%f, " + "RSSI=%f, " + "TIME_ERR=%f, " + "TRANS_PWR=%u, " + "TIME_ADVC=%u, " + "FER=%f, " + "ACCESSED=%u, " + "ARFCN=%u " + "WHERE CN_TN_TYPE_AND_OFFSET==\"%s\"", + measResults.RXLEV_FULL_SERVING_CELL_dBm(), + measResults.RXLEV_SUB_SERVING_CELL_dBm(), + measResults.RXQUAL_FULL_SERVING_CELL_BER(), + measResults.RXQUAL_SUB_SERVING_CELL_BER(), + chan->RSSI(), chan->timingError(), + chan->actualMSPower(), chan->actualMSTiming(), + chan->FER(), + (unsigned)time(NULL), + chan->ARFCN(), + chan->descriptiveString()); + + LOG(DEBUG) << "Query: " << query; + + return sqlite3_command(mDB, query); +} + +#if 0 +void PhysicalStatus::dump(ostream& os) const +{ + sqlite3_stmt *stmt; + sqlite3_prepare_statement(mDB, &stmt, + "SELECT CN,TN,TYPE_AND_OFFSET,FER,RSSI,TRANS_PWR,TIME_ADVC,RXLEV_FULL_SERVING_CELL,RXQUAL_FULL_SERVING_CELL_BER FROM PHYSTATUS"); + + while (sqlite3_run_query(mDB,stmt) == SQLITE_ROW) { + os << setw(2) << sqlite3_column_int(stmt, 0) << " " << sqlite3_column_int(stmt, 1); + os << " " << setw(9) << (TypeAndOffset)sqlite3_column_int(stmt, 2); + + char buffer[1024]; + sprintf(buffer, "%10d %5.2f %4d %5d %4d", + sqlite3_column_int(stmt, 3), + 100.0*sqlite3_column_double(stmt, 4), (int)round(sqlite3_column_double(stmt, 5)), + sqlite3_column_int(stmt, 6), sqlite3_column_int(stmt, 7)); + os << " " << buffer; + + sprintf(buffer, "%5d %5.2f", + sqlite3_column_int(stmt, 8), 100.0*sqlite3_column_double(stmt, 9)); + os << " " << buffer; + + os << endl; + } + sqlite3_finalize(stmt); +} +#endif + + +// vim: ts=4 sw=4 diff --git a/GSM/PhysicalStatus.h b/GSM/PhysicalStatus.h new file mode 100644 index 0000000..e628edd --- /dev/null +++ b/GSM/PhysicalStatus.h @@ -0,0 +1,89 @@ +/**@file Declarations for PhysicalStatus and related classes. */ +/* +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef PHYSICALSTATUS_H +#define PHYSICALSTATUS_H + +#include + +#include +#include + + +struct sqlite3; + + +namespace GSM { + +class L3MeasurementResults; +class LogicalChannel; + +/** + A table for tracking the state of channels. +*/ +class PhysicalStatus { + +private: + + Mutex mLock; ///< to reduce the load on the filesystem locking + sqlite3 *mDB; ///< database connection + +public: + + /** + Create a physical status reporting table. + @param path Path fto sqlite3 database file. + */ + PhysicalStatus(const char*wPath); + + ~PhysicalStatus(); + + /** + Add reporting information associated with a channel to the table. + @param chan The channel to report. + @param measResults The measurement report. + @return The result of the SQLite query: true for the query being executed successfully, false otherwise. + */ + bool setPhysical(const LogicalChannel* chan, const L3MeasurementResults& measResults); + + /** + Dump the physical status table to the output stream. + @param os The output stream to dump the channel information to. + */ +// void dump(std::ostream& os) const; + + private: + + /** + Create entry in table. This is for the initial creation. + @param chan The channel to create an entry for. + @return The result of the SQLite query: true for the query being executed successfully, false otherwise. + */ + bool createEntry(const LogicalChannel* chan); + + +}; + + +} + +#endif + +// vim: ts=4 sw=4 diff --git a/GSM/PowerManager.cpp b/GSM/PowerManager.cpp new file mode 100644 index 0000000..ef1882b --- /dev/null +++ b/GSM/PowerManager.cpp @@ -0,0 +1,133 @@ +/* +* Copyright 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "PowerManager.h" +#include +#include +#include +#include +#include + +extern TransceiverManager gTRX; + +using namespace GSM; + + + +void PowerManager::increasePower() +{ + int maxAtten = gConfig.getNum("GSM.Radio.PowerManager.MaxAttenDB"); + int minAtten = gConfig.getNum("GSM.Radio.PowerManager.MinAttenDB"); + if (mAtten==minAtten) { + LOG(DEBUG) << "power already at maximum"; + return; + } + mAtten--; // raise power by reducing attenuation + if (mAttenmaxAtten) mAtten=maxAtten; + LOG(INFO) << "power increased to -" << mAtten << " dB"; + mRadio->setPower(mAtten); +} + +void PowerManager::reducePower() +{ + int maxAtten = gConfig.getNum("GSM.Radio.PowerManager.MaxAttenDB"); + int minAtten = gConfig.getNum("GSM.Radio.PowerManager.MinAttenDB"); + if (mAtten==maxAtten) { + LOG(DEBUG) << "power already at minimum"; + return; + } + mAtten++; // reduce power be increasing attenuation + if (mAttenmaxAtten) mAtten=maxAtten; + LOG(INFO) << "power decreased to -" << mAtten << " dB"; + mRadio->setPower(mAtten); +} + + +// internal method, does the control step +void PowerManager::internalControlStep() +{ + unsigned target = gConfig.getNum("GSM.Radio.PowerManager.TargetT3122"); + LOG(DEBUG) << "Avg T3122 " << mAveragedT3122 << ", target " << target; + // Adapt the power. + if (mAveragedT3122 > target) reducePower(); + else increasePower(); +} + + +void PowerManager::sampleT3122() +{ + // Tweak it down a little just in case there's no activity. + mSamples[mNextSampleIndex] = gBTS.shrinkT3122(); + unsigned numSamples = gConfig.getNum("GSM.Radio.PowerManager.NumSamples"); + mNextSampleIndex = (mNextSampleIndex + 1) % numSamples; + long sum = 0; + for (unsigned i=0; iserviceLoop(); + return NULL; +} + + +void PowerManager::start() +{ + mRadio = gTRX.ARFCN(); + mRadio->setPower(mAtten); + mThread.start((void*(*)(void*))PowerManagerServiceLoopAdapter,this); +} + + +// vim: ts=4 sw=4 diff --git a/GSM/PowerManager.h b/GSM/PowerManager.h new file mode 100644 index 0000000..2af1024 --- /dev/null +++ b/GSM/PowerManager.h @@ -0,0 +1,80 @@ +/* +* Copyright 2009 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +#ifndef __POWER_CONTROL__ +#define __POWER_CONTROL__ + +#include + +#include +#include + +// forward declaration +//class Timeval; + +// Make it all inline for now - no change to automake + +class ARFCNManager; + + +namespace GSM { + + +class PowerManager { + +private: + + Thread mThread; + ARFCNManager* mRadio; + unsigned mAveragedT3122; ///< averaged over the last NumSamples taken SamplePeriod apart kept in mSamples + volatile unsigned mAtten; ///< current attenuation - either set by ourselves or by setPower + Timeval mLast; ///< when controller operated last time + unsigned mSamples[100]; + unsigned mNextSampleIndex; + + + + void increasePower(); + void reducePower(); + + // internal method, does the control step + void internalControlStep(); + + void sampleT3122(); + + void serviceLoop(); + +public: + + PowerManager(); + + void start(); + + int power() { return -mAtten; } + + friend void* PowerManagerServiceLoopAdapter(PowerManager *pm); + +}; + + +void *PowerManagerServiceLoopAdapter(PowerManager *pm); + + + +} // namespace GSM + + +#endif // __POWER_CONTROL__ + +// vim: ts=4 sw=4 diff --git a/GSM/gsmtap.h b/GSM/gsmtap.h new file mode 100644 index 0000000..fcba386 --- /dev/null +++ b/GSM/gsmtap.h @@ -0,0 +1,81 @@ +#ifndef _GSMTAP_H +#define _GSMTAP_H + +/* gsmtap header, pseudo-header in front of the actua GSM payload*/ + +#include +#ifdef __linux__ +# include +#endif + +#define GSMTAP_VERSION 0x01 + +#define GSMTAP_TYPE_UM 0x01 /* A Layer 2 MAC block (23 bytes) */ +#define GSMTAP_TYPE_ABIS 0x02 +#define GSMTAP_TYPE_UM_BURST 0x03 /* raw burst bits */ + +#define GSMTAP_BURST_UNKNOWN 0x00 +#define GSMTAP_BURST_FCCH 0x01 +#define GSMTAP_BURST_PARTIAL_SCH 0x02 +#define GSMTAP_BURST_SCH 0x03 +#define GSMTAP_BURST_CTS_SCH 0x04 +#define GSMTAP_BURST_COMPACT_SCH 0x05 +#define GSMTAP_BURST_NORMAL 0x06 +#define GSMTAP_BURST_DUMMY 0x07 +#define GSMTAP_BURST_ACCESS 0x08 +#define GSMTAP_BURST_NONE 0x09 + +#define GSMTAP_UDP_PORT 4729 /* officially registered with IANA */ + +struct gsmtap_hdr { + u_int8_t version; /* version, set to 0x01 currently */ + u_int8_t hdr_len; /* length in number of 32bit words */ + u_int8_t type; /* see GSMTAP_TYPE_* */ + u_int8_t timeslot; /* timeslot (0..7 on Um) */ + + u_int16_t arfcn; /* ARFCN (frequency). + * highest bit 1 == uplink */ + u_int8_t noise_db; /* noise figure in dB */ + u_int8_t signal_db; /* signal level in dB */ + + u_int32_t frame_number; /* GSM Frame Number (FN) */ + + u_int8_t burst_type; /* Type of burst, see above */ + u_int8_t antenna_nr; /* Antenna Number */ + u_int16_t res; /* reserved for future use (RFU) */ + + gsmtap_hdr(unsigned ARFCN, unsigned TS, unsigned FN) + { + version = GSMTAP_VERSION; + type = GSMTAP_TYPE_UM; + burst_type = GSMTAP_BURST_NONE; + antenna_nr = 0; + noise_db = 0; + signal_db = 0; + + timeslot = TS; + arfcn = htons(ARFCN); + frame_number = htonl(FN); + } + +} __attribute__((packed)); + + +/* PCAP related definitions */ +#define TCPDUMP_MAGIC 0xa1b2c3d4 +#ifndef LINKTYPE_GSMTAP +#define LINKTYPE_GSMTAP 2342 +#endif +struct pcap_timeval { + int32_t tv_sec; + int32_t tv_usec; +}; + +struct pcap_sf_pkthdr { + struct pcap_timeval ts; /* time stamp */ + u_int32_t caplen; /* lenght of portion present */ + u_int32_t len; /* length of this packet */ +}; + + +#endif /* _GSMTAP_H */ diff --git a/Globals/Globals.cpp b/Globals/Globals.cpp new file mode 100644 index 0000000..66e2d4a --- /dev/null +++ b/Globals/Globals.cpp @@ -0,0 +1,69 @@ +/**@file Global system parameters. */ +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "config.h" +#include +#include +#include +#include + + +const char* gOpenBTSWelcome = + //23456789123456789223456789323456789423456789523456789623456789723456789 + "OpenBTS\n" + "Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc.\n" + "Copyright 2010 Kestrel Signal Processing, Inc.\n" + "Copyright 2011 Range Networks, Inc.\n" + "Release " VERSION " formal build date " __DATE__ "\n" + "\"OpenBTS\" is a trademark of Range Networks, Inc.\n" + "\nContributors:\n" + " Range Networks, Inc.:\n" + " David Burgess, Harvind Samra, Donald Kirker, Doug Brown\n" + " Kestrel Signal Processing, Inc.:\n" + " David Burgess, Harvind Samra, Raffi Sevlian, Roshan Baliga\n" + " GNU Radio:\n" + " Johnathan Corgan\n" + " Others:\n" + " Anne Kwong, Jacob Appelbaum, Joshua Lackey, Alon Levy\n" + " Alexander Chemeris, Alberto Escudero-Pascual\n" + "Incorporated GPL libraries and components:\n" + " libosip2 (LGPL), liportp2 (LGPL)" +#ifdef HAVE_LIBREADLINE + ", readline" +#endif + "\n" + "\nThis program comes with ABSOLUTELY NO WARRANTY.\n" + "\nUse of this software may be subject to other legal restrictions,\n" + "including patent licsensing and radio spectrum licensing.\n" + "All users of this software are expected to comply with applicable\n" + "regulations and laws. See the LEGAL file in the source code for\n" + "more information." +; + + +CommandLine::Parser gParser; + diff --git a/Globals/Globals.h b/Globals/Globals.h new file mode 100644 index 0000000..fac0d18 --- /dev/null +++ b/Globals/Globals.h @@ -0,0 +1,58 @@ +/**@file Global system parameters. */ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +/* + This file keeps global system parameters. +*/ + +#ifndef GLOBALS_H +#define GLOBALS_H + +#include +#include +#include +#include +#include + + + +/** Date-and-time string, defined in OpenBTS.cpp. */ +extern const char* gDateTime; + +/** + Just about everything goes into the configuration table. + This should be defined in the main body of the top-level application. +*/ +extern ConfigurationTable gConfig; + +/** The OpenBTS welcome message. */ +extern const char* gOpenBTSWelcome; + +/** The central parser. */ +extern CommandLine::Parser gParser; + +/** The global TMSI table. */ +extern Control::TMSITable gTMSITable; + +/** The physical status reporting table */ +extern GSM::PhysicalStatus gPhysStatus; + +/** The subscriber registry */ +extern SubscriberRegistry gSubscriberRegistry; + +#endif diff --git a/Globals/Makefile.am b/Globals/Makefile.am new file mode 100644 index 0000000..46d1f50 --- /dev/null +++ b/Globals/Makefile.am @@ -0,0 +1,32 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall + +noinst_LTLIBRARIES = libglobals.la + +libglobals_la_SOURCES = Globals.cpp + +noinst_PROGRAMS = + +noinst_HEADERS = Globals.h diff --git a/Globals/Makefile.in b/Globals/Makefile.in new file mode 100644 index 0000000..998e624 --- /dev/null +++ b/Globals/Makefile.in @@ -0,0 +1,534 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + + +SOURCES = $(libglobals_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +noinst_PROGRAMS = +subdir = Globals +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libglobals_la_LIBADD = +am_libglobals_la_OBJECTS = Globals.lo +libglobals_la_OBJECTS = $(am_libglobals_la_OBJECTS) +PROGRAMS = $(noinst_PROGRAMS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libglobals_la_SOURCES) +DIST_SOURCES = $(libglobals_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall +noinst_LTLIBRARIES = libglobals.la +libglobals_la_SOURCES = Globals.cpp +noinst_HEADERS = Globals.h +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Globals/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Globals/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libglobals.la: $(libglobals_la_OBJECTS) $(libglobals_la_DEPENDENCIES) + $(CXXLINK) $(libglobals_la_LDFLAGS) $(libglobals_la_OBJECTS) $(libglobals_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Globals.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/INSTALLATION b/INSTALLATION new file mode 100644 index 0000000..3e35d7e --- /dev/null +++ b/INSTALLATION @@ -0,0 +1,33 @@ +Installation Requirements + + + +OpenBTS compiles to a simple Unix binary and does not require special +installation. + +One some systems (Ubuntu), you will need to define LIBS = -lpthread prior to +running configure. + +To run OpenBTS, the following should be installed: + + Asterisk (http://www.asterisk.org), running SIP on port 5060. + + libosip2 (http://www.gnu.org/software/osip/) + + libortp (http://freshmeat.net/projects/ortp/) + + libusrp (http://gnuradio.org). + This is part of the GNURadio installation. + It is the only part used by OpenBTS. + + +OpenBTS logs to syslogd as facility LOG_LOCAL7. Please set your /etc/syslog.conf +accordingly. + + +For information on specific executables, see tests/README.tests and +apps/README.apps. + +See http://gnuradio.org/redmine/wiki/gnuradio/OpenBTS/BuildingAndRunning for more +information. + diff --git a/LEGAL b/LEGAL new file mode 100644 index 0000000..87917e1 --- /dev/null +++ b/LEGAL @@ -0,0 +1,73 @@ +OpenBTS + +Most parts copyright 2008-2011 Free Software Foundation. +Some parts copyright 2010 Kestrel Signal Processing, Inc. +Some parts copyright 2011 Range Networks, Inc. + + +Patent Laws + +The use of this software to provide GSM services may result in the use of +patented technologies. The user of this software is required to take whatever +actions are necessary to avoid patent infringement. + + +Trademark + +"OpenBTS" is a registered trademark of Range Networks, Inc. (Range), a +California corporation. Range reserves the right to control the use of this +trademark. Do not use this trademark in commerce without permission and do not +rebrand OpenBTS under a different trademark. + + +Telecom and Radio Spectrum Laws + +The primary function of OpenBTS is the provision of telecommunications service +over a radio link. This activity is heavily regulated nearly everywhere in +the world. Users of this software are expected to comply with local and national +regulations in the jurisdictions where this sortware is used with radio equipment. + + +Legal Summary + +The user of this software is expected to comply with all applicable laws and +regulations, including patent laws, copyright laws, and telecommunications +regulations. + +The legal restrictions listed here are not necessarily exhaustive. + + +Note to US Government Users + +The OpenBTS software applications and associated documentation are "Commercial +Item(s)," as that term is defined at 48 C.F.R. Section 2.101, consisting of +"Commercial Computer Software" and "Commercial Computer Software Documentation," +as such terms are used in 48 C.F.R. 12.212 or 48 C.F.R. 227.7202, as +applicable. Consistent with 48 C.F.R. 12.212 or 48 C.F.R. Sections 227.7202-1 +through 227.7202-4, as applicable, the Commercial Computer Software and +Commercial Computer Software Documentation are being licensed to U.S. Government +end users (a) only as Commercial Items and (b) with only those rights as are +granted to all other end users pursuant to the terms and conditions of GPLv3 +and AGPLv3. + + +Note to US Government Contractors + +GPL is not compatible with "government purpose rights" (GPR). If you receive +OpenBTS software under a GPL and deliver it under GPR, you will be in violation +of GPL and possibly subject to enforcement actions by the original authors and +copyright holders, including the Free Software Foundation, Inc. + + +Software Licensing and Distribution + +A subset of OpenBTS is distributed publicly under AGPLv3. Range reserves the right to +distribute most of this source code other licenses as well. See the COPYING file +for more information on the license for this distribution. + +GPL releases of OpenBTS use the following GPL components that must be +licensed, removed or replaced for non-GPL distributions: readline. + +GPL releases of OpenBTS use the following LGPL components that must be +licensed or linked dynamically for non-GPL distributions: libosip2, liportp2. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..e507168 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,58 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(USB_INCLUDES) $(WITH_INCLUDES) +AM_CXXFLAGS = -Wall -pthread -ldl +#AM_CXXFLAGS = -Wall -O2 -NDEBUG -pthread -ldl +#AM_CFLAGS = -Wall -O2 -NDEBUG -pthread -ldl + +# Order must be preserved +SUBDIRS = \ + config \ + AsteriskConfig \ + sqlite3 \ + CommonLibs \ + Globals \ + SR \ + CLI \ + SIP \ + GSM \ + SMS \ + TransceiverRAD1 \ + TRXManager \ + Control \ + apps \ + doc \ + tools + +EXTRA_DIST = \ + Transceiver52M \ + INSTALLATION \ + LEGAL \ + COPYING \ + README + + +dox: FORCE + doxygen doxconfig + +FORCE: diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..9a875dc --- /dev/null +++ b/Makefile.common @@ -0,0 +1,55 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR + +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la + +MOSTLYCLEANFILES = *~ diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..2ebb5a3 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,728 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(srcdir)/config.h.in \ + $(top_srcdir)/Makefile.common $(top_srcdir)/configure AUTHORS \ + COPYING ChangeLog INSTALL NEWS config.guess config.sub depcomp \ + install-sh ltmain.sh missing +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ + configure.lineno configure.status.lineno +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ + html-recursive info-recursive install-data-recursive \ + install-exec-recursive install-info-recursive \ + install-recursive installcheck-recursive installdirs-recursive \ + pdf-recursive ps-recursive uninstall-info-recursive \ + uninstall-recursive +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(USB_INCLUDES) $(WITH_INCLUDES) +AM_CXXFLAGS = -Wall -pthread -ldl +#AM_CXXFLAGS = -Wall -O2 -NDEBUG -pthread -ldl +#AM_CFLAGS = -Wall -O2 -NDEBUG -pthread -ldl + +# Order must be preserved +SUBDIRS = \ + config \ + AsteriskConfig \ + sqlite3 \ + CommonLibs \ + Globals \ + SR \ + CLI \ + SIP \ + GSM \ + SMS \ + TransceiverRAD1 \ + TRXManager \ + Control \ + apps \ + doc \ + tools + +EXTRA_DIST = \ + Transceiver52M \ + INSTALLATION \ + LEGAL \ + COPYING \ + README + +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + echo ' $(SHELL) ./config.status'; \ + $(SHELL) ./config.status;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(MAKE) stamp-h1; \ + else :; fi + +stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h1 + cd $(top_builddir) && $(SHELL) ./config.status config.h +$(srcdir)/config.h.in: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $$MAKEFLAGS; amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done +ctags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(am__remove_distdir) + mkdir $(distdir) + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -d "$(distdir)/$$subdir" \ + || $(mkdir_p) "$(distdir)/$$subdir" \ + || exit 1; \ + distdir=`$(am__cd) $(distdir) && pwd`; \ + top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$top_distdir" \ + distdir="$$distdir/$$subdir" \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist-gzip: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__remove_distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + case '$(DIST_ARCHIVES)' in \ + *.tar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(DISTCHECK_CONFIGURE_FLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ + distuninstallcheck \ + && chmod -R a-w "$$dc_install_base" \ + && ({ \ + (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ + && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ + distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ + } || { rm -rf "$$dc_destdir"; exit 1; }) \ + && rm -rf "$$dc_destdir" \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && rm -rf $(DIST_ARCHIVES) \ + && $(MAKE) $(AM_MAKEFLAGS) distcleancheck + $(am__remove_distdir) + @(echo "$(distdir) archives ready for distribution: "; \ + list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ + sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' +distuninstallcheck: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { echo "ERROR: files left after uninstall:" ; \ + if test -n "$(DESTDIR)"; then \ + echo " (check DESTDIR support)"; \ + fi ; \ + $(distuninstallcheck_listfiles) ; \ + exit 1; } >&2 +distcleancheck: distclean + @if test '$(srcdir)' = . ; then \ + echo "ERROR: distcleancheck can only run from a VPATH build" ; \ + exit 1 ; \ + fi + @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ + || { echo "ERROR: files left in build directory after distclean:" ; \ + $(distcleancheck_listfiles) ; \ + exit 1; } >&2 +check-am: all-am +check: check-recursive +all-am: Makefile config.h +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-hdr \ + distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf $(top_srcdir)/autom4te.cache + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ + check-am clean clean-generic clean-libtool clean-recursive \ + ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ + dist-shar dist-tarZ dist-zip distcheck distclean \ + distclean-generic distclean-hdr distclean-libtool \ + distclean-recursive distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-libtool mostlyclean-recursive pdf pdf-am ps ps-am \ + tags tags-recursive uninstall uninstall-am uninstall-info-am + + +dox: FORCE + doxygen doxconfig + +FORCE: +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..31f8e19 --- /dev/null +++ b/README @@ -0,0 +1,173 @@ +Welcome to the OpenBTS source code. + + +For free support, please subscribe to openbts-discuss@lists.sourceforge.net. +See http://sourceforge.net/mailarchive/forum.php?forum_name=openbts-discuss +and https://lists.sourceforge.net/lists/listinfo/openbts-discuss for details. + +For additional information, refer to http://openbts.org. + + +These are the directories: + +AsteriskConfig Asterisk configuration files for use with OpenBTS. +CommonLib Common-use libraries, mostly C++ wrappers for basic facilities. +Control Control-layer functions for the protocols of GSM 04.08 and SIP. +GSM The GSM stack. +RRLP Radio Resource Location Protocol +SIP Components of the SIP state machines ued by the control layer. +SMS The SMS stack. +SR The subscriber registry. +TRXManager The interface between the GSM stack and the radio. +Transceiver The software transceiver and specific installation tests. +apps OpenBTS application binaries. +doc Project documentation. +tests Test fixtures for subsets of OpenBTS components. +smqueue RFC-3428 store-and-forward server for SMS + + + +By default, OpenBTS assumes the following UDP port assignments: + +5060 -- Asterisk SIP interface +5061 -- local SIP softphone +5062 -- OpenBTS SIP interface +5063 -- smqueue SIP interface +5064 -- subscriber registry SIP interface +5700-range -- OpenBTS-transceiver interface + +These can be controlled in the CONFIG table in /etc/OpenBTS.db. + +Standrd paths: +/OpenBTS -- Binary installation and authorization keys. +/etc/OpenBTS -- Configuration databases. +/var/run/OpenBTS -- Real-time reporting databases. + +The script apps/setUpFiles.sh will create these directories and install the +correct files in them. + + +Releases 2.5 and later include the smqueue SMS server. It is NOT part of the +normal GNU build process with the rest of OpenBTS. To build smqueue, go +into the smqueue directory and just type "make -f Makefile.standalone". + + + +Release history: + +Release Name SVN Reposiory SVN Rev Comments + +1.0 (none) SF.net ?? completed L1, L2 + +1.1 Arnaudville GNU Radio r10019 (trunk) + +1.2 Breaux Bridge GNU Radio r10088 (trunk) GNU Build, very early assignment + +1.3 Carencro KSP r1 (trunk) first post-injunction release + +1.4 Donaldsonville KSP r23 (trunk) fixed Ubuntu build error + +1.5 Eunice KSP r39 (trunk) fixed L2 bugs related to segmentation + removed incomplete SMS directory + moved "abort" calls into L3 subclasses + +1.6 New Iberia KSP r130 (trunk) import of all 2.2 improvements to non-SMS release + + +2.0 St. Francisville KSP r54 (smswork) SMS support + file-based configuration + +2.1 Grand Coteau KSP r70 (smswork) DTMF support + fixed more Linux-related build errors + -lpthread + TLMessage constructor + expanded stack to prevent overflows in Linux + moved gSIPInterface to main app + fixed iterator bug in Pager + +2.2 Houma KSP r122 (smswork) added LEGAL notice + removed Assert classes + stop paging on page response + fixed Pager-spin bug + fixed Transceiver spin bugs + fixed 2^32 microsecond rollover bug + reduced stack footprints in Transceiver + fixed SMS timestamps + check LAI before using TMSI in LUR + reduced memory requirement by 75% + removed PagerTest + fixed stale-transaction bug in paging handler + fixed USRP clock rollover bug + faster call connection + new USRPDevice design + +2.3 Jean Lafitte KSP r190? (trunk) check for out-of-date RACH bursts + better TRX-GSM clock sync + formal logging system + command line interface + emergency call setup + +2.4 Kinder KSP r208? (trunk) fixed BCCH neighbor list bug + support for neighbor lists + fixed support for non-local Asterisk servers + cleaner configuration management + more realtime control of BCCH parameters + proper rejection of Hold messages + fixed L3 hanging bug in MTDCheckBYE + +2.4.1 Kinder KSP r462 fixed lots of valgrind errors + +2.4.2 Kinder KSP r482 zero-length calling party number bug + g++ 4.4 #includes + +2.5 Lacassine KSP r551 imported Joshua Lackey patches + SIP fixes from Anne Kwong + SIP fixes from testing with SMS server + L3 TI handling fixes + SMS server support + GNU Radio 3.2 compatibility + configurable max range and LU-reject cause + "page" & "testcall" CLI features + +2.5.1 Lacassine KSP r595 fixed some build bugs for some Linux distros + +2.5.2 Lacassine KSP r630 fixed channel assignment bug for Nokia DCT4+ handsets + +2.5.3 Lacassine KSP r756 merged fix for transceiver startup crash + due to use of uninitialized variables (r646) + merged fix for fusb bug from trunk (r582) + +2.5.4 Lacassine KSP r812 merged fixes to build under latest Fedora and + to build with git GnuRadio (r814) + +2.6 Mamou KSP r886 fixed infamous fusb bug (r582) + fixed idle-filling table size bug + smoother uplink power control + load-limiting downlink power control + new "config" features (optional, static) + IMEI interrogation + fixed MOD "missing FIFO" bug + configurable short code features + fixed transceiver startup crash (r646) + readline support is back + fixed timing advance bug (r844) + added CLI "chans" command + track time-of-use in TMSI table (r844) + added CLI "noise" command (r844) + added CLI "rxpower" command (r844) + added CLI "unconfig" command + +2.7 Natchitoches Range rxxx (never released publicly) + converted TMSITable to sqlite3 (r902) + sqlite3-based configuration (r???) + converted Logger to syslogd (r903) + added support for rest octets (r1022) + external database for transaction reporting (r1184) + external database for channel status reporting (r1203) + in-call delivery and submission of text messages (r1231) + RFC-2833 DMTF (r1249) + +2.8 Opelousas Range rxxx move databases to /etc and /var + RRLP aiding support + + diff --git a/SIP/Makefile.am b/SIP/Makefile.am new file mode 100644 index 0000000..0ce482f --- /dev/null +++ b/SIP/Makefile.am @@ -0,0 +1,40 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \ + -I$(OSIP_INCLUDEDIR) $(OSIP_CPPFLAGS) \ + -I$(ORTP_INCLUDEDIR) $(ORTP_CPPFLAGS) +AM_CXXFLAGS = -Wall -Wextra + +noinst_LTLIBRARIES = libSIP.la + +libSIP_la_SOURCES = \ + SIPEngine.cpp \ + SIPInterface.cpp \ + SIPMessage.cpp \ + SIPUtility.cpp + +noinst_HEADERS = \ + SIPEngine.h \ + SIPInterface.h \ + SIPMessage.h \ + SIPUtility.h diff --git a/SIP/Makefile.in b/SIP/Makefile.in new file mode 100644 index 0000000..d0f05c9 --- /dev/null +++ b/SIP/Makefile.in @@ -0,0 +1,541 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libSIP_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = SIP +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libSIP_la_LIBADD = +am_libSIP_la_OBJECTS = SIPEngine.lo SIPInterface.lo SIPMessage.lo \ + SIPUtility.lo +libSIP_la_OBJECTS = $(am_libSIP_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libSIP_la_SOURCES) +DIST_SOURCES = $(libSIP_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) \ + -I$(OSIP_INCLUDEDIR) $(OSIP_CPPFLAGS) \ + -I$(ORTP_INCLUDEDIR) $(ORTP_CPPFLAGS) + +AM_CXXFLAGS = -Wall -Wextra +noinst_LTLIBRARIES = libSIP.la +libSIP_la_SOURCES = \ + SIPEngine.cpp \ + SIPInterface.cpp \ + SIPMessage.cpp \ + SIPUtility.cpp + +noinst_HEADERS = \ + SIPEngine.h \ + SIPInterface.h \ + SIPMessage.h \ + SIPUtility.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu SIP/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu SIP/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libSIP.la: $(libSIP_la_OBJECTS) $(libSIP_la_DEPENDENCIES) + $(CXXLINK) $(libSIP_la_LDFLAGS) $(libSIP_la_OBJECTS) $(libSIP_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SIPEngine.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SIPInterface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SIPMessage.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SIPUtility.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/SIP/SIPEngine.cpp b/SIP/SIPEngine.cpp new file mode 100644 index 0000000..2e59006 --- /dev/null +++ b/SIP/SIPEngine.cpp @@ -0,0 +1,1023 @@ +/**@file SIP Call Control -- SIP IETF RFC-3261, RTP IETF RFC-3550. */ +/* +* Copyright 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include + +#include "SIPInterface.h" +#include "SIPUtility.h" +#include "SIPMessage.h" +#include "SIPEngine.h" + +#undef WARNING + +using namespace std; +using namespace SIP; +using namespace Control; + + + + +const char* SIP::SIPStateString(SIPState s) +{ + switch(s) + { + case NullState: return "Null"; + case Timeout: return "Timeout"; + case Starting: return "Starting"; + case Proceeding: return "Proceeding"; + case Ringing: return "Ringing"; + case Connecting: return "Connecting"; + case Active: return "Active"; + case Fail: return "Fail"; + case Busy: return "Busy"; + case MODClearing: return "MODClearing"; + case MTDClearing: return "MTDClearing"; + case Cleared: return "Cleared"; + case MessageSubmit: return "SMS-Submit"; + default: return NULL; + } +} + +ostream& SIP::operator<<(ostream& os, SIPState s) +{ + const char* str = SIPStateString(s); + if (str) os << str; + else os << "?" << s << "?"; + return os; +} + + + +SIPEngine::SIPEngine(const char* proxy, const char* IMSI) + :mCSeq(random()%1000), + mMyToFromHeader(NULL), mRemoteToFromHeader(NULL), + mCallIDHeader(NULL), + mSIPPort(gConfig.getNum("SIP.Local.Port")), + mSIPIP(gConfig.getStr("SIP.Local.IP")), + mINVITE(NULL), mLastResponse(NULL), mBYE(NULL), + mSession(NULL),mTxTime(0), mRxTime(0), + mState(NullState), + mDTMF('\0'),mDTMFDuration(0) +{ + assert(proxy); + if (IMSI) user(IMSI); + if (!resolveAddress(&mProxyAddr,proxy)) { + LOG(ALERT) << "cannot resolve IP address for " << proxy; + return; + } + char host[256]; + const char* ret = inet_ntop(AF_INET,&(mProxyAddr.sin_addr),host,255); + if (!ret) { + LOG(ALERT) << "cannot translate proxy IP address"; + return; + } + mProxyIP = string(host); + mProxyPort = ntohs(mProxyAddr.sin_port); + + // generate a tag now + char tmp[50]; + make_tag(tmp); + mMyTag=tmp; + // set our CSeq in case we need one + mCSeq = random()%600; +} + + +SIPEngine::~SIPEngine() +{ + if (mINVITE!=NULL) osip_message_free(mINVITE); + if (mLastResponse!=NULL) osip_message_free(mLastResponse); + if (mBYE!=NULL) osip_message_free(mBYE); + // FIXME -- Do we need to dispose of the RtpSesion *mSesison? +} + + + +void SIPEngine::saveINVITE(const osip_message_t *INVITE, bool mine) +{ + // Instead of cloning, why not just keep the old one? + // Because that doesn't work in all calling contexts. + // This simplifies the call-handling logic. + if (mINVITE!=NULL) osip_message_free(mINVITE); + osip_message_clone(INVITE,&mINVITE); + + mCallIDHeader = mINVITE->call_id; + + // If this our own INVITE? Did we initiate the transaciton? + if (mine) { + mMyToFromHeader = mINVITE->from; + mRemoteToFromHeader = mINVITE->to; + return; + } + + // It's not our own. The From: is the remote party. + mMyToFromHeader = mINVITE->to; + mRemoteToFromHeader = mINVITE->from; + + // We need to set our tag, too. + osip_from_set_tag(mMyToFromHeader, strdup(mMyTag.c_str())); +} + + + +void SIPEngine::saveResponse(osip_message_t *response) +{ + if (mLastResponse!=NULL) osip_message_free(mLastResponse); + osip_message_clone(response,&mLastResponse); + + // The To: is the remote party and might have an new tag. + mRemoteToFromHeader = mLastResponse->to; +} + + + +void SIPEngine::saveBYE(const osip_message_t *BYE, bool mine) +{ + // Instead of cloning, why not just keep the old one? + // Because that doesn't work in all calling contexts. + // This simplifies the call-handling logic. + if (mBYE!=NULL) osip_message_free(mBYE); + osip_message_clone(BYE,&mBYE); +} + + + +void SIPEngine::user( const char * IMSI ) +{ + LOG(DEBUG) << "IMSI=" << IMSI; + unsigned id = random(); + char tmp[20]; + sprintf(tmp, "%u", id); + mCallID = tmp; + // IMSI gets prefixed with "IMSI" to form a SIP username + mSIPUsername = string("IMSI") + IMSI; +} + + + +void SIPEngine::user( const char * wCallID, const char * IMSI, const char *origID, const char *origHost) +{ + LOG(DEBUG) << "IMSI=" << IMSI << " " << wCallID << " " << origID << "@" << origHost; + mSIPUsername = string("IMSI") + IMSI; + mCallID = string(wCallID); + mRemoteUsername = string(origID); + mRemoteDomain = string(origHost); +} + + +bool SIPEngine::Register( Method wMethod ) +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState << " " << wMethod << " callID " << mCallID; + + // Before start, need to add mCallID + gSIPInterface.addCall(mCallID); + + // Initial configuration for sip message. + // Make a new from tag and new branch. + // make new mCSeq. + + // Generate SIP Message + // Either a register or unregister. Only difference + // is expiration period. + osip_message_t * reg; + if (wMethod == SIPRegister ){ + reg = sip_register( mSIPUsername.c_str(), + 60*gConfig.getNum("SIP.RegistrationPeriod"), + mSIPPort, mSIPIP.c_str(), + mProxyIP.c_str(), mMyTag.c_str(), + mViaBranch.c_str(), mCallID.c_str(), mCSeq + ); + } else if (wMethod == SIPUnregister ) { + reg = sip_register( mSIPUsername.c_str(), + 0, + mSIPPort, mSIPIP.c_str(), + mProxyIP.c_str(), mMyTag.c_str(), + mViaBranch.c_str(), mCallID.c_str(), mCSeq + ); + } else { assert(0); } + + LOG(DEBUG) << "writing registration " << reg; + gSIPInterface.write(&mProxyAddr,reg); + + bool success = false; + osip_message_t *msg = NULL; + Timeval timeout(gConfig.getNum("SIP.Timer.F")); + while (!timeout.passed()) { + try { + // SIPInterface::read will throw SIPTIimeout if it times out. + // It should not return NULL. + msg = gSIPInterface.read(mCallID, gConfig.getNum("SIP.Timer.E")); + } catch (SIPTimeout) { + // send again + gSIPInterface.write(&mProxyAddr,reg); + continue; + } + + assert(msg); + int status = msg->status_code; + LOG(INFO) << "received status " << msg->status_code << " " << msg->reason_phrase; + // specific status + if (status==200) { + LOG(INFO) << "REGISTER success"; + success = true; + break; + } + if (status==401) { + LOG(INFO) << "REGISTER fail -- unauthorized"; + break; + } + if (status==404) { + LOG(INFO) << "REGISTER fail -- not found"; + break; + } + if (status>=200) { + LOG(NOTICE) << "REGISTER unexpected response " << status; + break; + } + } + + if (!msg) { + LOG(ALERT) << "SIP REGISTER timed out; is the registration server " << mProxyIP << ":" << mProxyPort << " OK?"; + throw SIPTimeout(); + } + + osip_message_free(reg); + osip_message_free(msg); + gSIPInterface.removeCall(mCallID); + return success; +} + + + +const char* geoprivTemplate = +"\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "\n" + "%s\n" + "\n" + "\n" + "\n" + "\n" + "no\n" + "\n" + "\n" + "\n" + "\n" + "\n"; + +SIPState SIPEngine::SOSSendINVITE(short wRtp_port, unsigned wCodec) +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + // Before start, need to add mCallID + gSIPInterface.addCall(mCallID); + + // Set Invite params. + // new CSEQ and codec + char tmp[50]; + make_branch(tmp); + mViaBranch = tmp; + mCodec = wCodec; + mCSeq++; + + mRemoteDomain = gConfig.getStr("Control.Emergency.Destination.Host"); + mRemoteUsername = gConfig.getStr("Control.Emergency.Destination.User"); + + mRTPPort= wRtp_port; + + LOG(DEBUG) << "To: " << mRemoteUsername << "@" << mRemoteDomain; + LOG(DEBUG) << "From: " << mSIPUsername << "@" << mSIPIP; + + osip_message_t *invite; + if (gConfig.defines("Control.Emergency.RFC5031")) { + invite = sip_invite5031( + mRTPPort, mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), + mMyTag.c_str(), mViaBranch.c_str(), mCallID.c_str(), mCSeq, mCodec); + } else { + invite = sip_invite( + mRemoteUsername.c_str(), mRTPPort, mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), + mMyTag.c_str(), mViaBranch.c_str(), mCallID.c_str(), mCSeq, mCodec); + } + + // Add IMS emergency call headers with osip_message_set_header. + + // P-Access-Network-Info + // See 3GPP 24.229 7.2. + char cgi_3gpp[50]; + sprintf(cgi_3gpp,"3GPP-GERAN; cgi-3gpp=%s%s%04x%04x", + gConfig.getStr("GSM.Identity.MCC").c_str(),gConfig.getStr("GSM.Identity.MNC").c_str(), + (unsigned)gConfig.getNum("GSM.Identity.LAC"),(unsigned)gConfig.getNum("GSM.Identity.CI")); + osip_message_set_header(invite,"P-Access-Network-Info",cgi_3gpp); + + // P-Preferred-Identity + // See RFC-3325. + char pref_id[50]; + sprintf(pref_id,"", + mSIPUsername.c_str(), + gConfig.getStr("Control.Emergency.GatewaySwitch").c_str()); + osip_message_set_header(invite,"P-Preferred-Identity",pref_id); + + // FIXME -- Use the subscriber registry to look up the E.164 + // and make a second P-Preferred-Identity header. + + // Add RFC-4119 geolocation XML to content area, if available. + if (gConfig.defines("Control.Emergency.Geolocation")) { + char xml[strlen(geoprivTemplate) + 100]; + sprintf(xml,geoprivTemplate, + mSIPUsername.c_str(), gConfig.getStr("Control.Emergency.GatewaySwitch").c_str(), + gConfig.getStr("Control.Emergency.Geolocation").c_str()); + osip_message_set_content_type(invite, strdup("application/pidf+xml")); + char tmp[20]; + sprintf(tmp,"%u",strlen(xml)); + osip_message_set_content_length(invite, strdup(tmp)); + osip_message_set_body(invite,xml,strlen(xml)); + } + + // Send Invite to Asterisk. + gSIPInterface.write(&mProxyAddr,invite); + saveINVITE(invite,true); + osip_message_free(invite); + mState = Starting; + return mState; +}; + + +SIPState SIPEngine::MOCSendINVITE( const char * wCalledUsername, + const char * wCalledDomain , short wRtp_port, unsigned wCodec) +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + // Before start, need to add mCallID + gSIPInterface.addCall(mCallID); + + // Set Invite params. + // new CSEQ and codec + char tmp[50]; + make_branch(tmp); + mViaBranch = tmp; + mCodec = wCodec; + mCSeq++; + + mRemoteUsername = wCalledUsername; + mRemoteDomain = wCalledDomain; + mRTPPort= wRtp_port; + + LOG(DEBUG) << "mRemoteUsername=" << mRemoteUsername; + LOG(DEBUG) << "mSIPUsername=" << mSIPUsername; + + osip_message_t * invite = sip_invite( + mRemoteUsername.c_str(), mRTPPort, mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), + mMyTag.c_str(), mViaBranch.c_str(), mCallID.c_str(), mCSeq, mCodec); + + // P-Access-Network-Info + // See 3GPP 24.229 7.2. + char cgi_3gpp[50]; + sprintf(cgi_3gpp,"3GPP-GERAN; cgi-3gpp=%s%s%04x%04x", + gConfig.getStr("GSM.Identity.MCC").c_str(),gConfig.getStr("GSM.Identity.MNC").c_str(), + (unsigned)gConfig.getNum("GSM.Identity.LAC"),(unsigned)gConfig.getNum("GSM.Identity.CI")); + osip_message_set_header(invite,"P-Access-Network-Info",cgi_3gpp); + + + // Send Invite. + gSIPInterface.write(&mProxyAddr,invite); + saveINVITE(invite,true); + osip_message_free(invite); + mState = Starting; + return mState; +}; + + +SIPState SIPEngine::MOCResendINVITE() +{ + assert(mINVITE); + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + gSIPInterface.write(&mProxyAddr,mINVITE); + return mState; +} + +SIPState SIPEngine::MOCWaitForOK() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + + osip_message_t * msg; + + // Read off the fifo. if time out will + // clean up and return false. + try { + msg = gSIPInterface.read(mCallID, gConfig.getNum("SIP.Timer.A")); + } + catch (SIPTimeout& e) { + LOG(DEBUG) << "timeout"; + mState = Timeout; + return mState; + } + + int status = msg->status_code; + LOG(DEBUG) << "received status " << status; + saveResponse(msg); + switch (status) { + case 100: // Trying + case 183: // Progress + mState = Proceeding; + break; + case 180: // Ringing + mState = Ringing; + break; + case 200: // OK + // Save the response and update the state, + // but the ACK doesn't happen until the call connects. + mState = Active; + break; + // Anything 400 or above terminates the call, so we ACK. + // FIXME -- It would be nice to save more information about the + // specific failure cause. + case 486: + case 503: + mState = Busy; + MOCSendACK(); + break; + default: + LOG(NOTICE) << "unhandled status code " << status; + mState = Fail; + MOCSendACK(); + } + osip_message_free(msg); + LOG(DEBUG) << " new state: " << mState; + return mState; +} + + +SIPState SIPEngine::MOCSendACK() +{ + assert(mLastResponse); + + // new branch + char tmp[50]; + make_branch(tmp); + mViaBranch = tmp; + + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + + osip_message_t* ack = sip_ack( mRemoteDomain.c_str(), + mRemoteUsername.c_str(), + mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), + mMyToFromHeader, mRemoteToFromHeader, + mViaBranch.c_str(), mCallIDHeader, mCSeq + ); + + gSIPInterface.write(&mProxyAddr,ack); + osip_message_free(ack); + + return mState; +} + + +SIPState SIPEngine::MODSendBYE() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + assert(mINVITE); + char tmp[50]; + make_branch(tmp); + mViaBranch = tmp; + mCSeq++; + + osip_message_t * bye = sip_bye(mRemoteDomain.c_str(), mRemoteUsername.c_str(), + mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), mProxyPort, + mMyToFromHeader, mRemoteToFromHeader, + mViaBranch.c_str(), mCallIDHeader, mCSeq ); + + gSIPInterface.write(&mProxyAddr,bye); + saveBYE(bye,true); + osip_message_free(bye); + mState = MODClearing; + return mState; +} + +SIPState SIPEngine::MODResendBYE() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + assert(mState==MODClearing); + assert(mBYE); + gSIPInterface.write(&mProxyAddr,mBYE); + return mState; +} + +SIPState SIPEngine::MODWaitForOK() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + bool responded = false; + Timeval byeTimeout(gConfig.getNum("SIP.Timer.F")); + while (!byeTimeout.passed()) { + try { + osip_message_t * ok = gSIPInterface.read(mCallID, gConfig.getNum("SIP.Timer.E")); + responded = true; + unsigned code = ok->status_code; + saveResponse(ok); + osip_message_free(ok); + if (code!=200) { + LOG(WARNING) << "unexpected " << code << " response to BYE, from proxy " << mProxyIP << ":" << mProxyPort; + } + break; + } + catch (SIPTimeout& e) { + LOG(NOTICE) << "response timeout, resending BYE"; + MODResendBYE(); + } + } + + if (!responded) { LOG(ALERT) << "lost contact with proxy " << mProxyIP << ":" << mProxyPort; } + + // However we got here, the SIP side of the call is cleared now. + mState = Cleared; + return mState; +} + + + +SIPState SIPEngine::MTDCheckBYE() +{ + //LOG(DEBUG) << "user " << mSIPUsername << " state " << mState; + // If the call is not active, there should be nothing to check. + if (mState!=Active) return mState; + + // Need to check size of osip_message_t* fifo, + // so need to get fifo pointer and get size. + // HACK -- reach deep inside to get damn thing + int fifoSize = gSIPInterface.fifoSize(mCallID); + + + // Size of -1 means the FIFO does not exist. + // Treat the call as cleared. + if (fifoSize==-1) { + LOG(NOTICE) << "MTDCheckBYE attempt to check BYE on non-existant SIP FIFO"; + mState=Cleared; + return mState; + } + + // If no messages, there is no change in state. + if (fifoSize==0) return mState; + + osip_message_t * msg = gSIPInterface.read(mCallID); + + + if ((msg->sip_method!=NULL) && (strcmp(msg->sip_method,"BYE")==0)) { + LOG(DEBUG) << "found msg="<sip_method; + saveBYE(msg,false); + mState = MTDClearing; + } + + // FIXME -- Check for repeated ACK and send OK if needed. + // FIXME -- Check for repeated OK and send ACK if needed. + + osip_message_free(msg); + return mState; +} + + +SIPState SIPEngine::MTDSendOK() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + assert(mBYE); + osip_message_t * okay = sip_b_okay(mBYE); + gSIPInterface.write(&mProxyAddr,okay); + osip_message_free(okay); + mState = Cleared; + return mState; +} + + +SIPState SIPEngine::MTCSendTrying() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + if (mINVITE==NULL) mState=Fail; + if (mState==Fail) return mState; + osip_message_t * trying = sip_trying(mINVITE, mSIPUsername.c_str(), mProxyIP.c_str()); + gSIPInterface.write(&mProxyAddr,trying); + osip_message_free(trying); + mState=Proceeding; + return mState; +} + + +SIPState SIPEngine::MTCSendRinging() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + assert(mINVITE); + + LOG(DEBUG) << "send ringing"; + osip_message_t * ringing = sip_ringing(mINVITE, + mSIPUsername.c_str(), mProxyIP.c_str()); + gSIPInterface.write(&mProxyAddr,ringing); + osip_message_free(ringing); + + mState = Proceeding; + return mState; +} + + + +SIPState SIPEngine::MTCSendOK( short wRTPPort, unsigned wCodec ) +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + assert(mINVITE); + mRTPPort = wRTPPort; + mCodec = wCodec; + LOG(DEBUG) << "port=" << wRTPPort << " codec=" << mCodec; + // Form ack from invite and new parameters. + osip_message_t * okay = sip_okay(mINVITE, mSIPUsername.c_str(), + mSIPIP.c_str(), mSIPPort, mRTPPort, mCodec); + gSIPInterface.write(&mProxyAddr,okay); + osip_message_free(okay); + mState=Connecting; + return mState; +} + +SIPState SIPEngine::MTCWaitForACK() +{ + // wait for ack,set this to timeout of + // of call channel. If want a longer timeout + // period, need to split into 2 handle situation + // like MOC where this fxn if called multiple times. + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + osip_message_t * ack; + + // FIXME -- This is supposed to retransmit BYE on timer I. + try { + ack = gSIPInterface.read(mCallID, gConfig.getNum("SIP.Timer.H")); + } + catch (SIPTimeout& e) { + LOG(NOTICE) << "timeout"; + mState = Timeout; + return mState; + } + catch (SIPError& e) { + LOG(NOTICE) << "read error"; + mState = Fail; + return mState; + } + + if (ack->sip_method==NULL) { + LOG(NOTICE) << "SIP message with no method, status " << ack->status_code; + mState = Fail; + osip_message_free(ack); + return mState; + } + + LOG(INFO) << "received sip_method="<sip_method; + + // check for duplicated INVITE + if( strcmp(ack->sip_method,"INVITE") == 0){ + LOG(NOTICE) << "received duplicate INVITE"; + } + // check for the ACK + else if( strcmp(ack->sip_method,"ACK") == 0){ + LOG(INFO) << "received ACK"; + mState=Active; + } + // check for the CANCEL + else if( strcmp(ack->sip_method,"CANCEL") == 0){ + LOG(INFO) << "received CANCEL"; + mState=Fail; + // FIXME -- Send 200 OK, see ticket #173. + } + // check for strays + else { + LOG(NOTICE) << "unexpected Message "<sip_method; + mState = Fail; + } + + osip_message_free(ack); + return mState; +} + + +SIPState SIPEngine::MTCCheckForCancel() +{ + // wait for ack,set this to timeout of + // of call channel. If want a longer timeout + // period, need to split into 2 handle situation + // like MOC where this fxn if called multiple times. + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + osip_message_t * msg; + + try { + // 1 ms timeout, effectively non-blocking + msg = gSIPInterface.read(mCallID,1); + } + catch (SIPTimeout& e) { + return mState; + } + catch (SIPError& e) { + LOG(NOTICE) << "read error"; + mState = Fail; + return mState; + } + + if (msg->sip_method==NULL) { + LOG(NOTICE) << "SIP message with no method, status " << msg->status_code; + mState = Fail; + osip_message_free(msg); + return mState; + } + + LOG(INFO) << "received sip_method=" << msg->sip_method; + + // check for duplicated INVITE + if (strcmp(msg->sip_method,"INVITE")==0) { + LOG(NOTICE) << "received duplicate INVITE"; + } + // check for the CANCEL + else if (strcmp(msg->sip_method,"CANCEL")==0) { + LOG(INFO) << "received CANCEL"; + mState=Fail; + } + // check for strays + else { + LOG(NOTICE) << "unexpected Message " << msg->sip_method; + mState = Fail; + } + + osip_message_free(msg); + return mState; +} + + +void SIPEngine::InitRTP(const osip_message_t * msg ) +{ + if(mSession == NULL) + mSession = rtp_session_new(RTP_SESSION_SENDRECV); + + bool rfc2833 = gConfig.defines("SIP.DTMF.RFC2833"); + if (rfc2833) { + RtpProfile* profile = rtp_session_get_send_profile(mSession); + int index = gConfig.getNum("SIP.DTMF.RFC2833.PayloadType"); + rtp_profile_set_payload(profile,index,&payload_type_telephone_event); + // Do we really need this next line? + rtp_session_set_send_profile(mSession,profile); + } + + rtp_session_set_blocking_mode(mSession, TRUE); + rtp_session_set_scheduling_mode(mSession, TRUE); + rtp_session_set_connected_mode(mSession, TRUE); + rtp_session_set_symmetric_rtp(mSession, TRUE); + // Hardcode RTP session type to GSM full rate (GSM 06.10). + // FIXME -- Make this work for multiple vocoder types. + rtp_session_set_payload_type(mSession, 3); + + char d_ip_addr[20]; + char d_port[10]; + get_rtp_params(msg, d_port, d_ip_addr); + LOG(DEBUG) << "IP="<status_code==200) || (ok->status_code==202) ) { + mState = Cleared; + LOG(INFO) << "successful"; + } + osip_message_free(ok); + } + + catch (SIPTimeout& e) { + LOG(ALERT) << "SIP MESSAGE timed out; is the SMS server " << mProxyIP << ":" << mProxyPort << " OK?"; + mState = Fail; + } + + return mState; + +} + + + +SIPState SIPEngine::MTSMSSendOK() +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + // If this operation was initiated from the CLI, there was no INVITE. + if (!mINVITE) { + LOG(INFO) << "clearing CLI-generated transaction"; + mState=Cleared; + return mState; + } + // Form ack from invite and new parameters. + osip_message_t * okay = sip_okay_SMS(mINVITE, mSIPUsername.c_str(), + mSIPIP.c_str(), mSIPPort); + gSIPInterface.write(&mProxyAddr,okay); + osip_message_free(okay); + mState=Cleared; + return mState; +} + + + +bool SIPEngine::sendINFOAndWaitForOK(unsigned wInfo) +{ + LOG(INFO) << "user " << mSIPUsername << " state " << mState; + + char tmp[50]; + make_branch(tmp); + mViaBranch = tmp; + mCSeq++; + osip_message_t * info = sip_info( wInfo, + mRemoteUsername.c_str(), mRTPPort, mSIPUsername.c_str(), + mSIPPort, mSIPIP.c_str(), mProxyIP.c_str(), + mMyTag.c_str(), mViaBranch.c_str(), mCallIDHeader, mCSeq); + gSIPInterface.write(&mProxyAddr,info); + osip_message_free(info); + + try { + // This will timeout on failure. It will not return NULL. + osip_message_t *msg = gSIPInterface.read(mCallID, gConfig.getNum("SIP.Timer.A")); + LOG(DEBUG) << "received status " << msg->status_code << " " << msg->reason_phrase; + bool retVal = (msg->status_code==200); + osip_message_free(msg); + if (!retVal) LOG(CRIT) << "DTMF RFC-2967 failed."; + return retVal; + } + catch (SIPTimeout& e) { + LOG(NOTICE) << "timeout"; + return false; + } + +}; + + + + +// vim: ts=4 sw=4 diff --git a/SIP/SIPEngine.h b/SIP/SIPEngine.h new file mode 100644 index 0000000..8baefa5 --- /dev/null +++ b/SIP/SIPEngine.h @@ -0,0 +1,331 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + +#ifndef SIPENGINE_H +#define SIPENGINE_H + +#include +#include +#include +#include + + +#include +#include + +#include +#include + + +namespace SIP { + + +class SIPInterface; + + +enum SIPState { + NullState, + Timeout, + Starting, + Proceeding, + Ringing, + Busy, + Connecting, + Active, + MODClearing, + MTDClearing, + Cleared, + Fail, + MessageSubmit +}; + + +const char* SIPStateString(SIPState s); +std::ostream& operator<<(std::ostream& os, SIPState s); + +class SIPEngine +{ + +public: + + enum Method { SIPRegister =0, SIPUnregister=1 }; + +private: + + + /**@name General SIP tags and ids. */ + //@{ + std::string mRemoteUsername; + std::string mRemoteDomain; + std::string mMyTag; + std::string mCallID; + std::string mViaBranch; + std::string mSIPUsername; ///< our SIP username + unsigned mCSeq; + /**@name Pre-formed headers. These point into mINVITE. */ + //@{ + osip_from_t* mMyToFromHeader; ///< To/From header for us + osip_from_t* mRemoteToFromHeader; ///< To/From header for the remote party + osip_call_id_t *mCallIDHeader; ///< the call ID header for this transaction + //@} + //@} + + /**@name SIP UDP parameters */ + //@{ + unsigned mSIPPort; ///< our local SIP port + std::string mSIPIP; ///< our SIP IP address as seen by the proxy + std::string mProxyIP; ///< IP address of the SIP proxy + unsigned mProxyPort; ///< UDP port number of the SIP proxy + struct ::sockaddr_in mProxyAddr; ///< the ready-to-use UDP address + //@} + + /**@name Saved SIP messages. */ + //@{ + osip_message_t * mINVITE; ///< the INVITE message for this transaction + osip_message_t * mLastResponse; ///< the last response received for this transaction + osip_message_t * mBYE; ///< the BYE message for this transaction + //@} + + /**@name RTP state and parameters. */ + //@{ + short mRTPPort; + unsigned mCodec; + RtpSession * mSession; ///< RTP media session + unsigned int mTxTime; ///< RTP transmission timestamp in 8 kHz samples + unsigned int mRxTime; ///< RTP receive timestamp in 8 kHz samples + //@} + + SIPState mState; ///< current SIP call state + + /**@name RFC-2833 DTMF state. */ + //@{ + char mDTMF; ///< current DTMF digit, \0 if none + unsigned mDTMFDuration; ///< duration of DTMF event so far + unsigned mDTMFStartTime; ///< start time of the DTMF key event + //@} + +public: + + /** + Default constructor. Initialize the object. + @param proxy : + */ + SIPEngine(const char* proxy, const char* IMSI=NULL); + + /** Destroy held message copies. */ + ~SIPEngine(); + + const std::string& callID() const { return mCallID; } + + const std::string& proxyIP() const { return mProxyIP; } + unsigned proxyPort() const { return mProxyPort; } + + /** Return the current SIP call state. */ + SIPState state() const { return mState; } + + /** Set the user to IMSI and generate a call ID; for mobile-originated transactions. */ + void user( const char * IMSI ); + + /** Set the use to IMSI and set the other SIP call parameters; for network-originated transactions. */ + void user( const char * wCallID, const char * IMSI , const char *origID, const char *origHost); + + /**@name Messages for SIP registration. */ + //@{ + + /** + Send sip register and look at return msg. + Can throw SIPTimeout(). + @return True on success. + */ + bool Register(Method wMethod=SIPRegister); + + /** + Send sip unregister and look at return msg. + Can throw SIPTimeout(). + @return True on success. + */ + bool unregister() { return (Register(SIPUnregister)); }; + + //@} + + + /**@name Messages associated with Emegency call (SOS) procedure. */ + //@{ + + /** + Send an invite message. + @param rtpPort UDP port to use for speech (will use this and next port) + @param codec Code for codec to be used. + @return New SIP call state. + */ + SIPState SOSSendINVITE(short rtpPort, unsigned codec); + + //SIPState SOSResendINVITE(); + + //SIPState SOSWaitForOK(); + + //SIPState SOSSendACK(); + + //@} + + + + /**@name Messages associated with MOC procedure. */ + //@{ + + /** + Send an invite message. + @param calledUser SIP userid or E.164 address. + @param calledDomain SIP user's domain. + @param rtpPort UDP port to use for speech (will use this and next port) + @param codec Code for codec to be used. + @return New SIP call state. + */ + SIPState MOCSendINVITE(const char * calledUser, + const char * calledDomain, short rtpPort, unsigned codec); + + SIPState MOCResendINVITE(); + + SIPState MOCWaitForOK(); + + SIPState MOCSendACK(); + + //@} + + /**@name Messages associated with MOSMS procedure. */ + //@{ + + /** + Send an instant message. + @param calledUsername SIP userid or E.164 address. + @param calledDomain SIP user's domain. + @param messageText MESSAGE payload as a C string. + @return New SIP call state. + */ + SIPState MOSMSSendMESSAGE(const char * calledUsername, + const char * calledDomain, const char *messageText, + const char *contentType); + + SIPState MOSMSWaitForSubmit(); + + SIPState MTSMSSendOK(); + + //@} + + + /**@name Messages associated with MTC procedure. */ + //@{ + SIPState MTCSendTrying(); + + SIPState MTCSendRinging(); + + SIPState MTCSendOK(short rtpPort, unsigned codec); + + SIPState MTCWaitForACK(); + + SIPState MTCCheckForCancel(); + //@} + + /**@name Messages associated with MTSMS procedure. */ + //@{ + + SIPState MTCSendOK(); + + //@} + + + + /**@name Messages for MOD procedure. */ + //@{ + SIPState MODSendBYE(); + + SIPState MODResendBYE(); + + SIPState MODWaitForOK(); + //@} + + + /**@name Messages for MTD procedure. */ + //@{ + SIPState MTDCheckBYE(); + + SIPState MTDSendOK(); + //@} + + + /** Set up to start sending RFC2833 DTMF event frames in the RTP stream. */ + bool startDTMF(char key); + + /** Send a DTMF end frame and turn off the DTMF events. */ + void stopDTMF(); + + /** Send a vocoder frame over RTP. */ + void txFrame(unsigned char* frame); + + /** + Receive a vocoder frame over RTP. + @param The vocoder frame + @return new RTP timestamp + */ + int rxFrame(unsigned char* frame); + + void MOCInitRTP(); + void MTCInitRTP(); + + /** In-call Signalling */ + //@{ + + /** + Send a SIP INFO message, usually for DTMF. + Most parameters taken from current SIPEngine state. + This call blocks for the response. + @param wInfo The DTMF signalling code. + @return Success/Fail flag. + */ + bool sendINFOAndWaitForOK(unsigned wInfo); + + //@} + + + /** Save a copy of an INVITE or MESSAGE message in the engine. */ + void saveINVITE(const osip_message_t *INVITE, bool mine); + + /** Save a copy of a response message in the engine. */ + void saveResponse(osip_message_t *respsonse); + + /** Save a copy of a BYE message in the engine. */ + void saveBYE(const osip_message_t *BYE, bool mine); + + + + private: + + /** + Initialize the RTP session. + @param msg A SIP INVITE or 200 OK wth RTP parameters + */ + void InitRTP(const osip_message_t * msg ); + +}; + + +}; + +#endif // SIPENGINE_H +// vim: ts=4 sw=4 diff --git a/SIP/SIPInterface.cpp b/SIP/SIPInterface.cpp new file mode 100644 index 0000000..bdede75 --- /dev/null +++ b/SIP/SIPInterface.cpp @@ -0,0 +1,473 @@ +/* +* Copyright 2008, 2009, 2010m 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include +#include + +#include +#include +#include +#include + +#include + +#include "SIPUtility.h" +#include "SIPInterface.h" + +#include + +#undef WARNING + + + +using namespace std; +using namespace SIP; + +using namespace GSM; +using namespace Control; + + + + +// SIPMessageMap method definitions. + +void SIPMessageMap::write(const std::string& call_id, osip_message_t * msg) +{ + LOG(DEBUG) << "call_id=" << call_id << " msg=" << msg; + OSIPMessageFIFO * fifo = mMap.readNoBlock(call_id); + if( fifo==NULL ) { + // FIXME -- If this write fails, send "call leg non-existent" response on SIP interface. + LOG(NOTICE) << "missing SIP FIFO "<write(msg); +} + +osip_message_t * SIPMessageMap::read(const std::string& call_id, unsigned readTimeout) +{ + LOG(DEBUG) << "call_id=" << call_id; + OSIPMessageFIFO * fifo = mMap.readNoBlock(call_id); + if (!fifo) { + LOG(NOTICE) << "missing SIP FIFO "<read(readTimeout); + if (!msg) throw SIPTimeout(); + return msg; +} + + +bool SIPMessageMap::add(const std::string& call_id, const struct sockaddr_in* returnAddress) +{ + OSIPMessageFIFO * fifo = new OSIPMessageFIFO(returnAddress); + mMap.write(call_id, fifo); + return true; +} + +bool SIPMessageMap::remove(const std::string& call_id) +{ + OSIPMessageFIFO * fifo = mMap.readNoBlock(call_id); + if(fifo == NULL) return false; + mMap.remove(call_id); + return true; +} + + + + + +// SIPInterface method definitions. + +bool SIPInterface::addCall(const string &call_id) +{ + LOG(INFO) << "creating SIP message FIFO callID " << call_id; + return mSIPMap.add(call_id,mSIPSocket.source()); +} + + +bool SIPInterface::removeCall(const string &call_id) +{ + LOG(INFO) << "removing SIP message FIFO callID " << call_id; + return mSIPMap.remove(call_id); +} + +int SIPInterface::fifoSize(const std::string& call_id ) +{ + OSIPMessageFIFO * fifo = mSIPMap.map().read(call_id,0); + if(fifo==NULL) return -1; + return fifo->size(); +} + + + + + +void SIP::driveLoop( SIPInterface * si){ + while (true) { + si->drive(); + } +} + +void SIPInterface::start(){ + // Start all the osip/ortp stuff. + parser_init(); + ortp_init(); + ortp_scheduler_init(); + // FIXME -- Can we coordinate this with the global logger? + //ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR); + mDriveThread.start((void *(*)(void*))driveLoop,this ); +} + + + + +void SIPInterface::write(const struct sockaddr_in* dest, osip_message_t *msg) +{ + char * str; + size_t msgSize; + osip_message_to_str(msg, &str, &msgSize); + if (!str) { + LOG(ERR) << "osip_message_to_str produced a NULL pointer."; + return; + } + char firstLine[100]; + sscanf(str,"%100[^\n]",firstLine); + LOG(INFO) << "write " << firstLine; + LOG(DEBUG) << "write " << str; + + mSocketLock.lock(); + mSIPSocket.send((const struct sockaddr*)dest,str); + mSocketLock.unlock(); + free(str); +} + + + + +void SIPInterface::drive() +{ + // All inbound SIP messages go here for processing. + + LOG(DEBUG) << "blocking on socket"; + int numRead = mSIPSocket.read(mReadBuffer); + if (numRead<0) { + LOG(ALERT) << "cannot read SIP socket."; + return; + } + // FIXME -- Is this +1 offset correct? Check it. + mReadBuffer[numRead] = '\0'; + + // Get the proxy from the inbound message. +#if 0 + const struct sockaddr_in* sourceAddr = mSIPSocket.source(); + char msgHost[256]; + const char* msgHostRet = inet_ntop(AF_INET,&(sourceAddr->sin_addr),msgHost,255); + if (!msgHostRet) { + LOG(ALERT) << "cannot translate SIP source address for " << mReadBuffer; + return; + } + unsigned msgPortNumber = sourceAddr->sin_port; + char msgPort[20]; + sprintf(msgPort,"%u",msgPortNumber); + string proxy = string(msgHost) + string(":") + string(msgPort); +#endif + + char firstLine[101]; + sscanf(mReadBuffer,"%100[^\n]",firstLine); + LOG(INFO) << "read " << firstLine; + LOG(DEBUG) << "read " << mReadBuffer; + + + try { + + // Parse the mesage. + osip_message_t * msg; + int i = osip_message_init(&msg); + LOG(INFO) << "osip_message_init " << i; + int j = osip_message_parse(msg, mReadBuffer, strlen(mReadBuffer)); + // seems like it ought to do something more than display an error, + // but it used to not even do that. + LOG(INFO) << "osip_message_parse " << j; + + if (msg->sip_method) LOG(DEBUG) << "read method " << msg->sip_method; + + // Must check if msg is an invite. + // if it is, handle appropriatly. + // FIXME -- Check return value in case this failed. + // FIXME -- If we support USSD via SIP, we will need to check the map first. + checkInvite(msg); + + // FIXME -- Need to check for early BYE or CANCEL to stop paging. + // If it's a BYE, find the corresponding transaction table entry. + // If the Q931 state is "paging", or T3113 is expired, remove it. + // Otherwise, we will keep paging even though the call has ended. + + // Multiplex out the received SIP message to active calls. + + // If we write to non-existent call_id. + // this is errant message so need to catch + // Internal error excatpion. and give nice + // message (instead of aborting) + // Don't free call_id_num. It points into msg->call_id. + char * call_id_num = osip_call_id_get_number(msg->call_id); + if( call_id_num == NULL ) { + LOG(WARNING) << "message with no call id"; + throw SIPError(); + } + LOG(DEBUG) << "got message " << msg << " with call id " << call_id_num << " and writing it to the map."; + string call_num(call_id_num); + // Don't free msg. Whoever reads the FIFO will do that. + mSIPMap.write(call_num, msg); + } + catch(SIPException) { + LOG(WARNING) << "cannot parse SIP message: " << mReadBuffer; + } +} + + + + +const char* extractIMSI(const osip_message_t *msg) +{ + // Get request username (IMSI) from invite. + // Form of the name is IMSI, and it should always be 18 or 19 char. + const char * IMSI = msg->req_uri->username; + LOG(INFO) << msg->sip_method << " to "<< IMSI; + // IMSIs are 14 or 15 char + "IMSI" prefix + // FIXME -- We need better validity-checking. + unsigned namelen = strlen(IMSI); + if ((namelen>19)||(namelen<18)) { + LOG(WARNING) << "INVITE with malformed username \"" << IMSI << "\""; + return false; + } + // Skip first 4 char "IMSI". + return IMSI+4; +} + + +const char* extractCallID(const osip_message_t* msg) +{ + if (!msg->call_id) return NULL; + return osip_call_id_get_number(msg->call_id); + +} + + + + +bool SIPInterface::checkInvite( osip_message_t * msg) +{ + LOG(DEBUG); + + // This code dispatches new transactions coming from the network-side SIP interface. + // All transactions originating here are going to be mobile-terminated. + // Yes, this method is too long and needs to be broken up into smaller steps. + + // Is there even a method? + const char *method = msg->sip_method; + if (!method) return false; + + // Check for INVITE or MESSAGE methods. + // Check channel availability now, too. + GSM::ChannelType requiredChannel; + bool channelAvailable = false; + GSM::L3CMServiceType serviceType; + string proxy; + if (strcmp(method,"INVITE") == 0) { + // INVITE is for MTC. + // Set the required channel type to match the assignment style. + if (gConfig.defines("Control.VEA")) { + // Very early assignment. + requiredChannel = GSM::TCHFType; + channelAvailable = gBTS.TCHAvailable(); + } else { + // Early assignment + requiredChannel = GSM::SDCCHType; + channelAvailable = gBTS.SDCCHAvailable() && gBTS.TCHAvailable(); + } + serviceType = L3CMServiceType::MobileTerminatedCall; + proxy = gConfig.getStr("SIP.Proxy.Speech"); + } + else if (strcmp(method,"MESSAGE") == 0) { + // MESSAGE is for MTSMS. + requiredChannel = GSM::SDCCHType; + channelAvailable = gBTS.SDCCHAvailable(); + serviceType = L3CMServiceType::MobileTerminatedShortMessage; + proxy = gConfig.getStr("SIP.Proxy.SMS"); + } + else { + // Not a method handled here. + LOG(DEBUG) << "non-initiating SIP method " << method; + return false; + } + + // Get request username (IMSI) from invite. + const char* IMSI = extractIMSI(msg); + if (!IMSI) { + // FIXME -- Send appropriate error (404) on SIP interface. + LOG(WARNING) << "Incoming INVITE/MESSAGE with no IMSI"; + return false; + } + L3MobileIdentity mobileID(IMSI); + + // Get the SIP call ID. + const char * callIDNum = extractCallID(msg); + if (!callIDNum) { + // FIXME -- Send appropriate error on SIP interface. + LOG(WARNING) << "Incoming INVITE/MESSAGE with no call ID"; + return false; + } + + + // Find any active transaction for this IMSI with an assigned TCH or SDCCH. + GSM::LogicalChannel *chan = gTransactionTable.findChannel(mobileID); + if (chan) { + // If the type is TCH and the service is SMS, get the SACCH. + // Otherwise, for now, just say chan=NULL. + if (serviceType==L3CMServiceType::MobileTerminatedShortMessage && chan->type()==FACCHType) { + chan = chan->SACCH(); + } else { + // FIXME -- This will change to support multiple transactions. + chan = NULL; + } + } + + // Check SIP map. Repeated entry? Page again. + if (mSIPMap.map().readNoBlock(callIDNum) != NULL) { + TransactionEntry* transaction= gTransactionTable.find(mobileID,callIDNum); + // There's a FIFO but no trasnaction record? + if (!transaction) { + LOG(WARNING) << "repeated INVITE/MESSAGE with no transaction record"; + // Delete the bogus FIFO. + mSIPMap.remove(callIDNum); + return false; + } + // There is transaction already. Send trying. + transaction->MTCSendTrying(); + // And if no channel is established yet, page again. + if (!chan) { + LOG(INFO) << "repeated SIP INVITE/MESSAGE, repaging for transaction " << *transaction; + gBTS.pager().addID(mobileID,requiredChannel,*transaction); + } + return false; + } + + // So we will need a new channel. + // Check gBTS for channel availability. + if (!chan && !channelAvailable) { + // FIXME -- Send 503 "Service Unavailable" response on SIP interface. + // Don't forget the retry-after header. + LOG(NOTICE) << "MTC CONGESTION, no " << requiredChannel << " availble for assignment"; + return false; + } + if (chan) { LOG(INFO) << "using existing channel " << chan->descriptiveString(); } + else { LOG(INFO) << "set up MTC paging for channel=" << requiredChannel; } + + + // Add an entry to the SIP Map to route inbound SIP messages. + addCall(callIDNum); + LOG(DEBUG) << "callIDNum " << callIDNum << " IMSI " << IMSI; + + // Get the caller ID if it's available. + const char *callerID = ""; + const char *callerHost = ""; + osip_from_t *from = osip_message_get_from(msg); + if (from) { + osip_uri_t* url = osip_contact_get_url(from); + if (url) { + if (url->username) callerID = url->username; + if (url->host) callerHost = url->host; + } + } else { + LOG(NOTICE) << "INVITE with no From: username for " << mobileID; + } + LOG(DEBUG) << "callerID " << callerID << "@" << callerHost; + + + // Build the transaction table entry. + // This constructor sets TI automatically for an MT transaction. + TransactionEntry *transaction = new TransactionEntry(proxy.c_str(),mobileID,chan,serviceType,callerID); + // FIXME -- These parameters should be arguments to the constructor above. + transaction->SIPUser(callIDNum,IMSI,callerID,callerHost); + transaction->saveINVITE(msg,false); + // Tell the sender we are trying. + transaction->MTCSendTrying(); + + // SMS? Get the text message body to deliver. + if (serviceType == L3CMServiceType::MobileTerminatedShortMessage) { + osip_body_t *body; + osip_content_type_t *contentType; + osip_message_get_body(msg,0,&body); + contentType = osip_message_get_content_type(msg); + const char *text = NULL; + char *type = NULL; + if (body) text = body->body; + if (text) transaction->message(text, body->length); + else LOG(NOTICE) << "MTSMS incoming MESSAGE method with no message body for " << mobileID; + /* Ok, so osip does some funny stuff here. The MIME type is split into type and subType. + Basically, text/plain becomes type=text, subType=plain. We need to put those together... + */ + if (contentType) { + type = (char *)malloc(strlen(contentType->type)+strlen(contentType->subtype)+2); + } + if (type) { + strcpy(type,contentType->type); + strcat(type,"/"); + strcat(type,contentType->subtype); + transaction->messageType(type); + free(type); + } + else LOG(NOTICE) << "MTSMS incoming MESSAGE method with no content type (or memory error) for " << mobileID; + } + + LOG(INFO) << "MTC MTSMS make transaction and add to transaction table: "<< *transaction; + gTransactionTable.add(transaction); + + // If there's an existing channel, skip the paging step. + if (!chan) { + // Add to paging list. + LOG(DEBUG) << "MTC MTSMS new SIP invite, initial paging for mobile ID " << mobileID; + gBTS.pager().addID(mobileID,requiredChannel,*transaction); + } else { + // Add a transaction to an existing channel. + chan->addTransaction(transaction); + // FIXME -- We need to write something into the channel to trigger the new transaction. + // We need to send a message into the chan's dispatch loop, + // becasue we can't block this thread to run the transaction. + } + + return true; +} + + + + + +// vim: ts=4 sw=4 diff --git a/SIP/SIPInterface.h b/SIP/SIPInterface.h new file mode 100644 index 0000000..b7630e4 --- /dev/null +++ b/SIP/SIPInterface.h @@ -0,0 +1,207 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; +* see the COPYING file in the main directory for licensing +* information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef SIPINTERFACE_H +#define SIPINTERFACE_H + +#include +#include +#include +#include + +#include + + +namespace GSM { + +class L3MobileIdentity; + +} + + +namespace SIP { + + +typedef InterthreadQueue _OSIPMessageFIFO; + +class OSIPMessageFIFO : public _OSIPMessageFIFO { + + private: + + struct sockaddr_in mReturnAddress; + + virtual void freeElement(osip_message_t* element) const { osip_message_free(element); }; + + public: + + OSIPMessageFIFO(const struct sockaddr_in* wReturnAddress) + :_OSIPMessageFIFO() + { + memcpy(&mReturnAddress,wReturnAddress,sizeof(mReturnAddress)); + } + + virtual ~OSIPMessageFIFO() + { + // We must call clear() here, because if it is called from InterthreadQueue + // destructor, then clear() will call InterthreadQueue's freeElement() which + // is not what we want. This destructor behaviour is intntional, because + // inherited object's data is already destroyed at the time parent's destructor + // is called. + clear(); + } + + const struct sockaddr_in* returnAddress() const { return &mReturnAddress; } + + size_t addressSize() const { return sizeof(mReturnAddress); } + +}; + + + +class OSIPMessageFIFOMap : public InterthreadMap {}; + + +std::ostream& operator<<(std::ostream& os, const OSIPMessageFIFO& m); + + +/** + A Map the keeps a SIP message FIFO for each active SIP transaction. + Keyed by SIP call ID string. + Overall map is thread-safe. Each FIFO is also thread-safe. +*/ +class SIPMessageMap +{ + +private: + + OSIPMessageFIFOMap mMap; + +public: + + /** Write sip message to the map+fifo. used by sip interface. */ + void write(const std::string& call_id, osip_message_t * sip_msg ); + + /** Read sip message out of map+fifo. used by sip engine. */ + osip_message_t * read(const std::string& call_id, unsigned readTimeout=3600000); + + /** Create a new entry in the map. */ + bool add(const std::string& call_id, const struct sockaddr_in* returnAddress); + + /** + Remove a fifo from map (called at the end of a sip interaction). + @param call_id The call_id key string. + @return True if the call_id was there in the first place. + */ + bool remove(const std::string& call_id); + + /** Direct access to the map. */ + // FIXME -- This should probably be replaced with more specific methods. + OSIPMessageFIFOMap& map() {return mMap;} + +}; + +std::ostream& operator<<(std::ostream& os, const SIPMessageMap& m); + + + + +class SIPInterface +{ + +private: + + char mReadBuffer[2048]; ///< buffer for UDP reads + + UDPSocket mSIPSocket; + + Mutex mSocketLock; + Thread mDriveThread; + SIPMessageMap mSIPMap; + +public: + // 2 ways to starte sip interface. + // Ex 1. + // SIPInterface si; + // si.localAdder(port0, ip_str, port1); + // si.open(); + // or Ex 2. + // SIPInterface si(port0, ip_str, port1); + // Then after all that. si.start(); + + + /** + Create the SIP interface to watch for incoming SIP messages. + */ + SIPInterface() + :mSIPSocket(gConfig.getNum("SIP.Local.Port")) + { } + + + /** Start the SIP drive loop. */ + void start(); + + /** Receive, parse and dispatch a single SIP message. */ + void drive(); + + /** + Look for incoming INVITE messages to start MTC. + @param msg The SIP message to check. + @return true if the message is a new INVITE + */ + bool checkInvite( osip_message_t *); + + + /** + Schedule SMS for delivery. + */ + //void deliverSMS(const GSM::L3MobileIdentity& mobile_id, const char* returnAddress, const char* text); + + // To write a msg to outside, make the osip_message_t + // then call si.write(msg); + // to read, you need to have the call_id + // then call si.read(call_id) + + void write(const struct sockaddr_in*, osip_message_t*); + + osip_message_t* read(const std::string& call_id , unsigned readTimeout=3600000) + { return mSIPMap.read(call_id, readTimeout); } + + /** Create a new message FIFO in the SIP interface. */ + bool addCall(const std::string& call_id); + + bool removeCall(const std::string& call_id); + + int fifoSize(const std::string& call_id ); + +}; + +void driveLoop(SIPInterface*); + + +}; // namespace SIP. + + +/*@addtogroup Globals */ +//@{ +/** A single global SIPInterface in the global namespace. */ +extern SIP::SIPInterface gSIPInterface; +//@} + + +#endif // SIPINTERFACE_H +// vim: ts=4 sw=4 diff --git a/SIP/SIPMessage.cpp b/SIP/SIPMessage.cpp new file mode 100644 index 0000000..461a855 --- /dev/null +++ b/SIP/SIPMessage.cpp @@ -0,0 +1,988 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include +#include +#include + +#include +#include +#include + +#include "SIPInterface.h" +#include "SIPUtility.h" +#include "SIPMessage.h" + +using namespace std; +using namespace SIP; + + +#define DEBUG 1 +#define MAX_VIA 10 + + +osip_message_t * SIP::sip_register( const char * sip_username, short timeout, short wlocal_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq) { + + char local_port[10]; + sprintf(local_port,"%i",wlocal_port); + + // Message URI + osip_message_t * request; + osip_message_init(&request); + // FIXME -- Should use the "force_update" function. + request->message_property = 2; // buffer is not synchronized with object + request->sip_method = strdup("REGISTER"); + osip_message_set_version(request, strdup("SIP/2.0")); + osip_uri_init(&request->req_uri); + osip_uri_set_host(request->req_uri, strdup(proxy_ip)); + + + // VIA + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // VIA BRANCH + osip_via_set_branch(via, strdup(via_branch)); + + // MAX FORWARDS + osip_message_set_max_forwards(request, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + char * via_str; + osip_via_to_str(via, &via_str); + osip_message_set_via(request, via_str); + // set via + osip_list_add(&request->vias, via, -1); + + + // FROM + osip_from_init(&request->from); + osip_from_set_displayname(request->from, strdup(sip_username)); + + // FROM TAG + osip_from_set_tag(request->from, strdup(from_tag)); + osip_uri_init(&request->from->url); + osip_uri_set_host(request->from->url, strdup(proxy_ip)); + osip_uri_set_username(request->from->url, strdup(sip_username)); + + // TO + osip_to_init(&request->to); + osip_to_set_displayname(request->to, strdup(sip_username)); + osip_uri_init(&request->to->url); + osip_uri_set_host(request->to->url, strdup(proxy_ip)); + osip_uri_set_username(request->to->url, strdup(sip_username)); + + // CALL ID + osip_call_id_init(&request->call_id); + osip_call_id_set_host(request->call_id, strdup(local_ip)); + osip_call_id_set_number(request->call_id, strdup(call_id)); + + // CSEQ + osip_cseq_init(&request->cseq); + osip_cseq_set_method(request->cseq, strdup("REGISTER")); + char temp_buf[14]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(request->cseq, strdup(temp_buf)); + + // CONTACT + osip_contact_t * con; + osip_to_init(&con); + + // CONTACT URI + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + osip_uri_set_port(con->url, strdup(local_port)); + osip_uri_set_username(con->url, strdup(sip_username)); + char numbuf[10]; + sprintf(numbuf,"%d",timeout); + osip_contact_param_add(con, strdup("expires"), strdup(numbuf) ); + + // add contact + osip_list_add(&request->contacts, con, -1); + + return request; +} + + + +osip_message_t * SIP::sip_message( const char * dialed_number, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, const char* message, const char* content_type) { + + char local_port[10]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * request; + osip_message_init(&request); + // FIXME -- Should use the "force_update" function. + request->message_property = 2; + + // METHOD + request->sip_method = strdup("MESSAGE"); + osip_message_set_version(request, strdup("SIP/2.0")); + + // REQ.URI + osip_uri_init(&request->req_uri); + osip_uri_set_host(request->req_uri, strdup(proxy_ip)); + osip_uri_set_username(request->req_uri, strdup(dialed_number)); + + // VIA + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + osip_via_set_branch(via, strdup(via_branch)); + + // MAX FORWARDS + osip_message_set_max_forwards(request, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + // add via + osip_list_add(&request->vias, via, -1); + + // FROM + osip_from_init(&request->from); + osip_from_set_displayname(request->from, strdup(sip_username)); + osip_uri_init(&request->from->url); + osip_uri_set_host(request->from->url, strdup(proxy_ip)); + osip_uri_set_username(request->from->url, strdup(sip_username)); + // FROM TAG + osip_from_set_tag(request->from, strdup(from_tag)); + + // TO + osip_to_init(&request->to); + osip_to_set_displayname(request->to, strdup(dialed_number)); + osip_uri_init(&request->to->url); + osip_uri_set_host(request->to->url, strdup(proxy_ip)); + osip_uri_set_username(request->to->url, strdup(dialed_number)); + + // CALL ID + osip_call_id_init(&request->call_id); + osip_call_id_set_host(request->call_id, strdup(local_ip)); + osip_call_id_set_number(request->call_id, strdup(call_id)); + + // CSEQ + osip_cseq_init(&request->cseq); + osip_cseq_set_method(request->cseq, strdup("MESSAGE")); + char temp_buf[21]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(request->cseq, strdup(temp_buf)); + + // Content-Type + if (content_type) + { + // Explicit value provided + osip_message_set_content_type(request, strdup(content_type)); + } else { + // Default to text/plain + osip_message_set_content_type(request, strdup("text/plain")); + } + + // Content-Length + sprintf(temp_buf,"%u",strlen(message)); + osip_message_set_content_length(request, strdup(temp_buf)); + + // Payload. + osip_message_set_body(request,message,strlen(message)); + + return request; +} + + +osip_message_t * SIP::sip_invite5031(short rtp_port, const char * sip_username, short wlocal_port, const char * local_ip, const char* proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, unsigned codec) +{ + char local_port[10]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * request; + osip_message_init(&request); + // FIXME -- Should use the "force_update" function. + request->message_property = 2; + request->sip_method = strdup("INVITE"); + osip_message_set_version(request, strdup("SIP/2.0")); + osip_uri_init(&request->req_uri); + osip_uri_set_scheme(request->req_uri, strdup("sip")); + osip_uri_set_username(request->req_uri, strdup("sos")); + osip_uri_set_host(request->req_uri, strdup(proxy_ip)); + + // VIA + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // VIA BRANCH + osip_via_set_branch(via, strdup(via_branch)); + + // MAX FORWARDS + osip_message_set_max_forwards(request, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + // add via + osip_list_add(&request->vias, via, -1); + + // FROM + osip_from_init(&request->from); + osip_from_set_displayname(request->from, strdup(sip_username)); + + // FROM TAG + osip_from_set_tag(request->from, strdup(from_tag)); + + osip_uri_init(&request->from->url); + osip_uri_set_host(request->from->url, strdup(local_ip)); + osip_uri_set_username(request->from->url, strdup(sip_username)); + + // TO + osip_to_init(&request->to); + osip_to_set_displayname(request->to, strdup("")); + osip_uri_init(&request->to->url); + osip_uri_set_host(request->to->url, strdup(gConfig.getStr("Emergency.Destination.Host").c_str())); + osip_uri_set_username(request->to->url, strdup(gConfig.getStr("Emergency.Destination.User").c_str())); + + // If response, we need a to tag. + //osip_uri_param_t * to_tag_param; + //osip_from_get_tag(rsp->to, &to_tag_param); + + // CALL ID + osip_call_id_init(&request->call_id); + osip_call_id_set_host(request->call_id, strdup(local_ip)); + osip_call_id_set_number(request->call_id, strdup(call_id)); + + // CSEQ + osip_cseq_init(&request->cseq); + osip_cseq_set_method(request->cseq, strdup("INVITE")); + char temp_buf[14]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(request->cseq, strdup(temp_buf)); + + // CONTACT + osip_contact_t * con; + osip_to_init(&con); + + // CONTACT URI + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + osip_uri_set_port(con->url, strdup(local_port)); + osip_uri_set_username(con->url, strdup(sip_username)); + osip_contact_param_add(con, strdup("expires"), strdup("3600") ); + + // add contact + osip_list_add(&request->contacts, con, -1); + + sdp_message_t * sdp; + sdp_message_init(&sdp); + sdp_message_v_version_set(sdp, strdup("0")); + sdp_message_o_origin_set(sdp, strdup(sip_username), strdup("0"), + strdup("0"), strdup("IN"), strdup("IP4"), strdup(local_ip)); + + sdp_message_s_name_set(sdp, strdup("Talk Time")); + sdp_message_t_time_descr_add(sdp, strdup("0"), strdup("0") ); + + sprintf(temp_buf,"%i",rtp_port); + sdp_message_m_media_add(sdp, strdup("audio"), + strdup(temp_buf), NULL, strdup("RTP/AVP")); + sdp_message_c_connection_add + (sdp, 0, strdup("IN"), strdup("IP4"), strdup(local_ip),NULL, NULL); + + // FIXME -- This should also be inside the switch? + sdp_message_m_payload_add(sdp,0,strdup("3")); + switch (codec) { + case RTPuLaw: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("0 PCMU/8000")); + break; + case RTPGSM610: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("3 GSM/8000")); + break; + default: assert(0); + }; + + /* + * We construct a sdp_message_t, turn it into a string, and then treat it + * like an osip_body_t. This works, and perhaps is how it is supposed to + * be done, but in any case we're going to have to do the extra processing + * to turn it into a string first. + */ + char * sdp_str; + sdp_message_to_str(sdp, &sdp_str); + osip_message_set_body(request, sdp_str, strlen(sdp_str)); + osip_free(sdp_str); + osip_message_set_content_type(request, strdup("application/sdp")); + + return request; +} + + +osip_message_t * SIP::sip_invite( const char * dialed_number, short rtp_port, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, unsigned codec) { + + char local_port[10]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * request; + osip_message_init(&request); + // FIXME -- Should use the "force_update" function. + request->message_property = 2; + request->sip_method = strdup("INVITE"); + osip_message_set_version(request, strdup("SIP/2.0")); + osip_uri_init(&request->req_uri); + osip_uri_set_host(request->req_uri, strdup(proxy_ip)); + osip_uri_set_username(request->req_uri, strdup(dialed_number)); + + // VIA + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // VIA BRANCH + osip_via_set_branch(via, strdup(via_branch)); + + // MAX FORWARDS + osip_message_set_max_forwards(request, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + // add via + osip_list_add(&request->vias, via, -1); + + // FROM + osip_from_init(&request->from); + osip_from_set_displayname(request->from, strdup(sip_username)); + + // FROM TAG + osip_from_set_tag(request->from, strdup(from_tag)); + + osip_uri_init(&request->from->url); + osip_uri_set_host(request->from->url, strdup(proxy_ip)); + osip_uri_set_username(request->from->url, strdup(sip_username)); + + // TO + osip_to_init(&request->to); + osip_to_set_displayname(request->to, strdup("")); + osip_uri_init(&request->to->url); + osip_uri_set_host(request->to->url, strdup(proxy_ip)); + osip_uri_set_username(request->to->url, strdup(dialed_number)); + + // If response, we need a to tag. + //osip_uri_param_t * to_tag_param; + //osip_from_get_tag(rsp->to, &to_tag_param); + + // CALL ID + osip_call_id_init(&request->call_id); + osip_call_id_set_host(request->call_id, strdup(local_ip)); + osip_call_id_set_number(request->call_id, strdup(call_id)); + + // CSEQ + osip_cseq_init(&request->cseq); + osip_cseq_set_method(request->cseq, strdup("INVITE")); + char temp_buf[14]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(request->cseq, strdup(temp_buf)); + + // CONTACT + osip_contact_t * con; + osip_to_init(&con); + + // CONTACT URI + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + osip_uri_set_port(con->url, strdup(local_port)); + osip_uri_set_username(con->url, strdup(sip_username)); + osip_contact_param_add(con, strdup("expires"), strdup("3600") ); + + // add contact + osip_list_add(&request->contacts, con, -1); + + sdp_message_t * sdp; + sdp_message_init(&sdp); + sdp_message_v_version_set(sdp, strdup("0")); + sdp_message_o_origin_set(sdp, strdup(sip_username), strdup("0"), + strdup("0"), strdup("IN"), strdup("IP4"), strdup(local_ip)); + + sdp_message_s_name_set(sdp, strdup("Talk Time")); + sdp_message_t_time_descr_add(sdp, strdup("0"), strdup("0") ); + + sprintf(temp_buf,"%i",rtp_port); + sdp_message_m_media_add(sdp, strdup("audio"), + strdup(temp_buf), NULL, strdup("RTP/AVP")); + sdp_message_c_connection_add + (sdp, 0, strdup("IN"), strdup("IP4"), strdup(local_ip),NULL, NULL); + + // FIXME -- This should also be inside the switch? + sdp_message_m_payload_add(sdp,0,strdup("3")); + switch (codec) { + case RTPuLaw: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("0 PCMU/8000")); + break; + case RTPGSM610: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("3 GSM/8000")); + break; + default: assert(0); + }; + + /* + * We construct a sdp_message_t, turn it into a string, and then treat it + * like an osip_body_t. This works, and perhaps is how it is supposed to + * be done, but in any case we're going to have to do the extra processing + * to turn it into a string first. + */ + char * sdp_str; + sdp_message_to_str(sdp, &sdp_str); + osip_message_set_body(request, sdp_str, strlen(sdp_str)); + osip_free(sdp_str); + osip_message_set_content_type(request, strdup("application/sdp")); + + return request; +} + + +// Take the authorization produced by an earlier invite message. + +osip_message_t * SIP::sip_ack(const char * req_uri, const char * dialed_number, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, const osip_from_t *from_header, const osip_to_t* to_header, const char * via_branch, const osip_call_id_t* call_id_header, int cseq) { + + char local_port[20]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * ack; + osip_message_init(&ack); + // FIXME -- Should use the "force_update" function. + ack->message_property = 2; + ack->sip_method = strdup("ACK"); + osip_message_set_version(ack, strdup("SIP/2.0")); + + osip_uri_init(&ack->req_uri); + + // If we are Acking a BYE message then need to + // set the req_uri to the owner address thats taken from the 200 Okay. + if( req_uri == NULL ) { + osip_uri_set_host(ack->req_uri, strdup(proxy_ip)); + } else { + osip_uri_set_host(ack->req_uri, strdup(req_uri)); + } + + osip_uri_set_username(ack->req_uri, strdup(dialed_number)); + + // Via + osip_via_t *via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // VIA BRANCH + osip_via_set_branch(via, strdup(via_branch)); + + // MAX FORWARDS + osip_message_set_max_forwards(ack, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + // add via + osip_list_add(&ack->vias, via, -1); + + osip_from_init(&ack->from); + osip_from_set_displayname(ack->from, strdup(sip_username)); + osip_uri_init(&ack->from->url); + osip_uri_set_host(ack->from->url, strdup(proxy_ip)); + osip_uri_set_username(ack->from->url, strdup(sip_username)); + + // from/to headers + osip_from_clone(from_header, &ack->from); + osip_to_clone(to_header, &ack->to); + + // call id + osip_call_id_clone(call_id_header, &ack->call_id); + + osip_cseq_init(&ack->cseq); + osip_cseq_set_method(ack->cseq, strdup("ACK")); + char temp_buf[14]; + sprintf(temp_buf, "%i", cseq); + osip_cseq_set_number(ack->cseq, strdup(temp_buf)); + + return ack; +} + + +osip_message_t * SIP::sip_bye(const char * req_uri, const char * dialed_number, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, short wproxy_port, const osip_from_t* from_header, const osip_to_t* to_header, const char * via_branch, const osip_call_id_t* call_id_header, int cseq) { + + // FIXME -- We really need some NULL-value error checking in here. + + char local_port[10]; + sprintf(local_port,"%i",wlocal_port); + + char proxy_port[10]; + sprintf(proxy_port,"%i",wproxy_port); + + osip_message_t * bye; + osip_message_init(&bye); + // FIXME -- Should use the "force_update" function. + bye->message_property = 2; + bye->sip_method = strdup("BYE"); + osip_message_set_version(bye, strdup("SIP/2.0")); + + //char o_addr[30]; + //get_owner_ip(okay, o_addr); + + osip_uri_init(&bye->req_uri); + osip_uri_set_host(bye->req_uri, strdup(req_uri)); + osip_uri_set_username(bye->req_uri, strdup(dialed_number)); + + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // via branch + max forwards + osip_via_set_branch(via, strdup(via_branch)); + osip_message_set_max_forwards(bye, strdup(gConfig.getStr("SIP.MaxForwards").c_str())); + + // add via + osip_list_add(&bye->vias, via, -1); + + // from/to header + osip_from_clone(from_header, &bye->from); + osip_to_clone(to_header, &bye->to); + + // Call Id Header + osip_call_id_clone(call_id_header, &bye->call_id); + + // Cseq Number + osip_cseq_init(&bye->cseq); + osip_cseq_set_method(bye->cseq, strdup("BYE")); + char temp_buf[12]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(bye->cseq, strdup(temp_buf)); + + // Contact + osip_contact_t * contact; + osip_contact_init(&contact); + osip_contact_set_displayname(contact, strdup(sip_username) ); + osip_uri_init(&contact->url); + osip_uri_set_host(contact->url, strdup(local_ip)); + osip_uri_set_username(contact->url, strdup(sip_username)); + osip_uri_set_port(contact->url, strdup(local_port)); + + // add contact + osip_list_add(&bye->contacts, contact, -1); + + return bye; +} + + +osip_message_t * SIP::sip_okay( osip_message_t * inv, const char * sip_username, const char * local_ip, short wlocal_port, short rtp_port, unsigned audio_codec) +{ + + // Check for consistency. + if(inv==NULL){ return NULL;} + + char local_port[10]; + sprintf(local_port, "%i", wlocal_port); + // k used for error conditions on various osip operations. + + osip_message_t * okay; + osip_message_init(&okay); + // FIXME -- Should use the "force_update" function. + okay->message_property = 2; + + // Set Header stuff. + okay->status_code = 200; + okay->reason_phrase = strdup("OK"); + osip_message_set_version(okay, strdup("SIP/2.0")); + osip_uri_init(&okay->req_uri); + + // Get Record Route. + // FIXME -- Should use _clone() routines. + osip_record_route_t * rr; + char * rr_str; + osip_message_get_record_route(inv, 0, &rr); + osip_record_route_to_str(rr, &rr_str); + osip_message_set_record_route(okay, rr_str); + osip_free(rr_str); + + + // SIP Okay needs to repeat the Via tags from the INVITE Message. + osip_via_t * via; + char * via_str; + osip_message_get_via(inv, 0, &via); + osip_via_to_str(via, &via_str); + osip_message_set_via(okay, via_str); + osip_free(via_str); + + // from/to header + osip_from_clone(inv->from, &okay->from); + osip_to_clone(inv->to, &okay->to); + + // CONTACT URI + osip_contact_t * con; + osip_to_init(&con); + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + osip_uri_set_port(con->url, strdup(local_port)); + osip_uri_set_username(con->url, strdup(sip_username)); + osip_contact_param_add(con, strdup("expires"), strdup("3600") ); + + // add contact + osip_list_add(&okay->contacts, con, -1); + + // Get Call-ID. + osip_call_id_clone(inv->call_id, &okay->call_id); + + // Get Cseq. + osip_cseq_t * cseq; + char * cseq_str; + cseq = osip_message_get_cseq(inv); + osip_cseq_to_str(cseq ,&cseq_str); + osip_message_set_cseq(okay, cseq_str); + osip_free(cseq_str); + + // Session Description Protocol. + sdp_message_t * sdp; + sdp_message_init(&sdp); + sdp_message_v_version_set(sdp, strdup("0")); + sdp_message_o_origin_set(sdp, strdup(sip_username), strdup("0"), + strdup("0"), strdup("IN"), strdup("IP4"), strdup(local_ip)); + + sdp_message_s_name_set(sdp, strdup("Talk Time")); + sdp_message_t_time_descr_add(sdp, strdup("0"), strdup("0") ); + char temp_buf[10]; + sprintf(temp_buf,"%i", rtp_port); + sdp_message_m_media_add(sdp, strdup("audio"), + strdup(temp_buf), NULL, strdup("RTP/AVP")); + sdp_message_c_connection_add + (sdp, 0, strdup("IN"), strdup("IP4"), strdup(local_ip),NULL, NULL); + + // FIXME -- This should also be inside the switch? + sdp_message_m_payload_add(sdp,0,strdup("3")); + switch (audio_codec) { + case RTPuLaw: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("0 PCMU/8000")); + break; + case RTPGSM610: + sdp_message_a_attribute_add(sdp,0,strdup("rtpmap"),strdup("3 GSM/8000")); + break; + default: assert(0); + }; + + char * sdp_str; + sdp_message_to_str(sdp, &sdp_str); + osip_message_set_body(okay, sdp_str, strlen(sdp_str)); + osip_free(sdp_str); + + osip_message_set_content_type(okay, strdup("application/sdp")); + + return okay; +} + + +osip_message_t * SIP::sip_b_okay( osip_message_t * bye ) +{ + // Check for consistency. + if(bye==NULL){ return NULL;} + + // k used for error conditions on various osip operations. + + osip_message_t * okay; + osip_message_init(&okay); + // FIXME -- Should use the "force_update" function. + okay->message_property = 2; + + // Set Header stuff. + okay->status_code = 200; + okay->reason_phrase = strdup("OK"); + osip_message_set_version(okay, strdup("SIP/2.0")); + osip_uri_init(&okay->req_uri); + + // SIP Okay needs to repeat the Via tags from the BYE Message. + osip_via_t * via; + char * via_str; + osip_message_get_via(bye, 0, &via); + osip_via_to_str(via, &via_str); + osip_message_set_via(okay, via_str); + osip_free(via_str); + + // from/to header + osip_from_clone(bye->from, &okay->from); + osip_to_clone(bye->to, &okay->to); + + // Get Call-ID. + osip_call_id_clone(bye->call_id, &okay->call_id); + + // Get Cseq. + osip_cseq_t * cseq; + char * cseq_str; + cseq = osip_message_get_cseq(bye); + osip_cseq_to_str(cseq ,&cseq_str); + osip_message_set_cseq(okay, cseq_str); + osip_free(cseq_str); + + return okay; +} + + +osip_message_t * SIP::sip_trying( osip_message_t * invite, const char * sip_username, const char * local_ip ) +{ + osip_message_t * trying; + osip_message_init(&trying); + // FIXME -- Should use the "force_update" function. + trying->message_property = 2; + + // Set Header stuff. + trying->status_code = 100; + trying->reason_phrase = strdup("Trying"); + osip_message_set_version(trying, strdup("SIP/2.0")); + osip_uri_init(&invite->req_uri); // FIXME? -- Invite rather than trying? + + // Get Record Route. + osip_via_t * via; + char * via_str; + osip_message_get_via(invite, 0, &via); + osip_via_to_str(via, &via_str); + osip_message_set_via(trying, via_str); + osip_free(via_str); + + // from/to header + osip_from_clone(invite->from, &trying->from); + osip_to_clone(invite->to, &trying->to); + + // Get Call-ID. + osip_call_id_clone(invite->call_id, &trying->call_id); + + // Get Cseq. + osip_cseq_t * cseq; + char * cseq_str; + cseq = osip_message_get_cseq(invite); + osip_cseq_to_str(cseq ,&cseq_str); + osip_message_set_cseq(trying, cseq_str); + osip_free(cseq_str); + + // CONTACT URI + osip_contact_t * con; + osip_to_init(&con); + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + //osip_uri_set_port(con->url, strdup(local_port)); // FIXME ?? + osip_uri_set_username(con->url, strdup(sip_username)); + + // add contact + osip_list_add(&trying->contacts, con, -1); + + return trying; +} + + +osip_message_t * SIP::sip_ringing( osip_message_t * invite, const char * sip_username, const char *local_ip) +{ + osip_message_t * ringing; + osip_message_init(&ringing); + // FIXME -- Should use the "force_update" function. + ringing->message_property = 2; + + // Set Header stuff. + ringing->status_code = 180; + ringing->reason_phrase = strdup("Ringing"); + osip_message_set_version(ringing, strdup("SIP/2.0")); + //osip_uri_init(&invite->req_uri); + + // Get Record Route. + osip_via_t * via; + char * via_str; + osip_message_get_via(invite, 0, &via); + osip_via_to_str(via, &via_str); + osip_message_set_via(ringing, via_str); + osip_free(via_str); + + // from/to header + osip_from_clone(invite->from, &ringing->from); + osip_to_clone(invite->to, &ringing->to); + + // Get Call-ID. + osip_call_id_clone(invite->call_id, &ringing->call_id); + + // Get Cseq. + osip_cseq_t * cseq; + char * cseq_str; + cseq = osip_message_get_cseq(invite); + osip_cseq_to_str(cseq ,&cseq_str); + osip_message_set_cseq(ringing, cseq_str); + osip_free(cseq_str); + + // CONTACT URI + osip_contact_t * con; + osip_to_init(&con); + osip_uri_init(&con->url); + osip_uri_set_host(con->url, strdup(local_ip)); + osip_uri_set_username(con->url, strdup(sip_username)); + + // add contact + osip_list_add(&ringing->contacts, con, -1); + + return ringing; +} + + +osip_message_t * SIP::sip_okay_SMS( osip_message_t * inv, const char * sip_username, const char * local_ip, short wlocal_port) +{ + + // Check for consistency. + if(inv==NULL){ return NULL;} + + char local_port[20]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * okay; + osip_message_init(&okay); + // FIXME -- Should use the "force_update" function. + okay->message_property = 2; + + // FIXME -- Do we really need all of this string conversion? + + // Set Header stuff. + okay->status_code = 200; + okay->reason_phrase = strdup("OK"); + osip_message_set_version(okay, strdup("SIP/2.0")); + osip_uri_init(&okay->req_uri); + + // Get Record Route. + osip_record_route_t * rr; + char * rr_str; + osip_message_get_record_route(inv, 0, &rr); + osip_record_route_to_str(rr, &rr_str); + osip_message_set_record_route(okay, rr_str); + osip_free(rr_str); + + // SIP Okay needs to repeat the Via tags from the INVITE Message. +// osip_via_clone(inv->via, &okay->via); + osip_via_t * via; + char * via_str; + osip_message_get_via(inv, 1, &via); + osip_via_to_str(via, &via_str); + osip_message_set_via(okay, via_str); + osip_free(via_str); + + // from/to header + osip_from_clone(inv->from, &okay->from); + osip_to_clone(inv->to, &okay->to); + + // Get Call-ID. + osip_call_id_clone(inv->call_id, &okay->call_id); + + // Get Cseq. + osip_cseq_t * cseq; + char * cseq_str; + cseq = osip_message_get_cseq(inv); + osip_cseq_to_str(cseq ,&cseq_str); + osip_message_set_cseq(okay, cseq_str); + osip_free(cseq_str); + + return okay; +} + + +osip_message_t * SIP::sip_info(unsigned info, const char *dialed_number, short rtp_port, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const osip_call_id_t *call_id_header, int cseq) { + + char local_port[10]; + sprintf(local_port, "%i", wlocal_port); + + osip_message_t * request; + osip_message_init(&request); + // FIXME -- Should use the "force_update" function. + request->message_property = 2; + request->sip_method = strdup("INFO"); + osip_message_set_version(request, strdup("SIP/2.0")); + osip_uri_init(&request->req_uri); + osip_uri_set_host(request->req_uri, strdup(proxy_ip)); + osip_uri_set_username(request->req_uri, strdup(dialed_number)); + + // VIA + osip_via_t * via; + osip_via_init(&via); + via_set_version(via, strdup("2.0")); + via_set_protocol(via, strdup("UDP")); + via_set_host(via, strdup(local_ip)); + via_set_port(via, strdup(local_port)); + + // VIA BRANCH + osip_via_set_branch(via, strdup(via_branch)); + + // add via + osip_list_add(&request->vias, via, -1); + + // FROM + osip_from_init(&request->from); + osip_from_set_displayname(request->from, strdup(sip_username)); + + // FROM TAG + osip_from_set_tag(request->from, strdup(from_tag)); + + osip_uri_init(&request->from->url); + osip_uri_set_host(request->from->url, strdup(proxy_ip)); + osip_uri_set_username(request->from->url, strdup(sip_username)); + + // TO + osip_to_init(&request->to); + osip_to_set_displayname(request->to, strdup("")); + osip_uri_init(&request->to->url); + osip_uri_set_host(request->to->url, strdup(proxy_ip)); + osip_uri_set_username(request->to->url, strdup(dialed_number)); + + // CALL ID + osip_call_id_clone(call_id_header, &request->call_id); + + // CSEQ + osip_cseq_init(&request->cseq); + osip_cseq_set_method(request->cseq, strdup("INFO")); + char temp_buf[21]; + sprintf(temp_buf,"%i",cseq); + osip_cseq_set_number(request->cseq, strdup(temp_buf)); + + osip_message_set_content_type(request, strdup("application/dtmf-relay")); + char message[31]; + // FIXME -- This duration should probably come from a config file. + switch (info) { + case 11: + snprintf(message,sizeof(message),"Signal=*\nDuration=200"); + break; + case 12: + snprintf(message,sizeof(message),"Signal=#\nDuration=200"); + break; + default: + snprintf(message,sizeof(message),"Signal=%i\nDuration=200",info); + } + sprintf(temp_buf,"%lu",strlen(message)); + osip_message_set_content_length(request, strdup(temp_buf)); + + // Payload. + osip_message_set_body(request,message,strlen(message)); + + return request; +} + + + +// vim: ts=4 sw=4 diff --git a/SIP/SIPMessage.h b/SIP/SIPMessage.h new file mode 100644 index 0000000..a6b7d44 --- /dev/null +++ b/SIP/SIPMessage.h @@ -0,0 +1,59 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + + +#ifndef SIP_MESSAGE_H +#define SIP_MESSAGE_H + +namespace SIP { + + + +osip_message_t * sip_register( const char * sip_username, short timeout, short local_port, const char * local_ip, +const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq); + + + +osip_message_t * sip_message( const char * dialed_number, const char * sip_username, short local_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, const char* message, const char* content_type=NULL); + +osip_message_t * sip_invite( const char * dialed_number, short rtp_port,const char * sip_username, short local_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, unsigned codec); + +osip_message_t * sip_invite5031(short rtp_port,const char * sip_username, short local_port, const char * local_ip, const char* proxy_ip, const char * from_tag, const char * via_branch, const char * call_id, int cseq, unsigned codec); + + +osip_message_t * sip_ack( const char * req_uri, const char * dialed_number, const char * sip_username, short wlocal_port, const char * local_ip, const char * proxy_ip, const osip_from_t* from_header, const osip_to_t* to_header, const char * via_branch, const osip_call_id_t* call_id_header, int cseq); + + +osip_message_t * sip_bye( const char * req_uri, const char * dialed_number, const char * sip_username, short local_port, const char * local_ip, const char * proxy_ip, short proxy_port, const osip_from_t *from_header, const osip_to_t * to_header, const char * via_branch, const osip_call_id_t* call_id_header, int cseq); + + +osip_message_t * sip_okay( osip_message_t * inv, const char * sip_username, const char * local_ip, short wlocal_port, short rtp_port, unsigned audio_codecs ); + +osip_message_t * sip_okay_SMS( osip_message_t * inv, const char * sip_username, const char * local_ip, short wlocal_port); + +osip_message_t * sip_info(unsigned info, const char *dialed_number, short rtp_port,const char * sip_username, short local_port, const char * local_ip, const char * proxy_ip, const char * from_tag, const char * via_branch, const osip_call_id_t* call_id_header, int cseq); + +osip_message_t * sip_b_okay( osip_message_t * bye ); + +osip_message_t * sip_trying( osip_message_t * invite, const char * sip_username, const char * local_ip); + +osip_message_t * sip_ringing( osip_message_t * invite, const char * sip_username, const char * local_ip); + + + +}; +#endif + diff --git a/SIP/SIPUtility.cpp b/SIP/SIPUtility.cpp new file mode 100644 index 0000000..d72419d --- /dev/null +++ b/SIP/SIPUtility.cpp @@ -0,0 +1,105 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "SIPInterface.h" +#include "SIPUtility.h" + + +using namespace SIP; +using namespace std; + + + +#define DEBUG 1 + + + + + +bool SIP::get_owner_ip( osip_message_t * msg, char * o_addr ) +{ + osip_body_t * sdp_body = (osip_body_t*)osip_list_get(&msg->bodies, 0); + if (!sdp_body) return false; + char * sdp_str = sdp_body->body; + if (!sdp_str) return false; + + sdp_message_t * sdp; + sdp_message_init(&sdp); + sdp_message_parse(sdp, sdp_str); + strcpy(o_addr, sdp->o_addr); + return true; +} + +bool SIP::get_rtp_params(const osip_message_t * msg, char * port, char * ip_addr ) +{ + osip_body_t * sdp_body = (osip_body_t*)osip_list_get(&msg->bodies, 0); + if (!sdp_body) return false; + char * sdp_str = sdp_body->body; + if (!sdp_str) return false; + + sdp_message_t * sdp; + sdp_message_init(&sdp); + sdp_message_parse(sdp, sdp_str); + + strcpy(port,sdp_message_m_port_get(sdp,0)); + strcpy(ip_addr, sdp->c_connection->c_addr); + return true; +} + +void SIP::make_tag(char * tag) +{ + uint64_t r1 = random(); + uint64_t r2 = random(); + uint64_t val = (r1<<32) + r2; + + // map [0->26] to [a-z] + int k; + for (k=0; k<16; k++) { + tag[k] = val%26+'a'; + val = val >> 4; + } + tag[k] = '\0'; +} + +void SIP::make_branch( char * branch ) +{ + uint64_t r1 = random(); + uint64_t r2 = random(); + uint64_t val = (r1<<32) + r2; + sprintf(branch,"z9hG4bKobts28%llx", val); +} + +// vim: ts=4 sw=4 diff --git a/SIP/SIPUtility.h b/SIP/SIPUtility.h new file mode 100644 index 0000000..ac7df74 --- /dev/null +++ b/SIP/SIPUtility.h @@ -0,0 +1,63 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + + +#ifndef SIP_UTILITY_H +#define SIP_UTILITY_H + + +namespace SIP { + +/**@name SIP-specific exceptions. */ +//@{ +class SIPException { + protected: + unsigned mTransactionID; + + public: + SIPException(unsigned wTransactionID=0) + :mTransactionID(wTransactionID) + { } + + unsigned transactionID() const { return mTransactionID; } +}; + +class SIPError : public SIPException {}; +class SIPTimeout : public SIPException {}; +//@} + + +/** Codec codes, from RFC-3551, Table 4. */ +enum RTPCodec { + RTPuLaw=0, + RTPGSM610=3 +}; + + +/** Get owner IP address; return NULL if none found. */ +bool get_owner_ip( osip_message_t * msg, char * o_addr ); + +/** Get RTP parameters; return NULL if none found. */ +bool get_rtp_params(const osip_message_t * msg, char * port, char * ip_addr ); + +void make_tag( char * tag ); + +void make_branch(char * branch); + + +}; +#endif +// vim: ts=4 sw=4 diff --git a/SMS/Makefile.am b/SMS/Makefile.am new file mode 100644 index 0000000..8d97290 --- /dev/null +++ b/SMS/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall + +noinst_LTLIBRARIES = libSMS.la + +libSMS_la_SOURCES = \ + SMSMessages.cpp \ + SMSTransfer.cpp + +noinst_HEADERS = \ + SMSMessages.h \ + SMSTransfer.h diff --git a/SMS/Makefile.in b/SMS/Makefile.in new file mode 100644 index 0000000..e707a88 --- /dev/null +++ b/SMS/Makefile.in @@ -0,0 +1,531 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libSMS_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = SMS +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libSMS_la_LIBADD = +am_libSMS_la_OBJECTS = SMSMessages.lo SMSTransfer.lo +libSMS_la_OBJECTS = $(am_libSMS_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libSMS_la_SOURCES) +DIST_SOURCES = $(libSMS_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall +noinst_LTLIBRARIES = libSMS.la +libSMS_la_SOURCES = \ + SMSMessages.cpp \ + SMSTransfer.cpp + +noinst_HEADERS = \ + SMSMessages.h \ + SMSTransfer.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu SMS/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu SMS/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libSMS.la: $(libSMS_la_OBJECTS) $(libSMS_la_DEPENDENCIES) + $(CXXLINK) $(libSMS_la_LDFLAGS) $(libSMS_la_OBJECTS) $(libSMS_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SMSMessages.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SMSTransfer.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/SMS/SMSMessages.cpp b/SMS/SMSMessages.cpp new file mode 100644 index 0000000..b8ec77e --- /dev/null +++ b/SMS/SMSMessages.cpp @@ -0,0 +1,767 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include +#include + +#include "SMSMessages.h" +#include + +using namespace std; +using namespace GSM; +using namespace SMS; + + + + +ostream& SMS::operator<<(ostream& os, CPMessage::MessageType val) +{ + switch(val) { + case CPMessage::DATA: os<<"CP-DATA"; break; + case CPMessage::ACK: os<<"CP-ACK"; break; + case CPMessage::ERROR: os<<"CP-ERROR"; break; + default : + os<parse(RPDU); + LOG(DEBUG) << "SMS RP-DATA " << *rp_data; + } + catch (SMSReadError) { + LOG(WARNING) << "SMS parsing failed (above L3)"; + // TODO:: send error back to the phone + delete rp_data; + rp_data = NULL; + } + catch (L3ReadError) { + LOG(WARNING) << "SMS parsing failed (in L3)"; + // TODO:: send error back to the phone + delete rp_data; + rp_data = NULL; + } + + return rp_data; +} + +TLMessage *SMS::parseTPDU(const TLFrame& TPDU) +{ + LOG(DEBUG) << "SMS: parseTPDU MTI=" << TPDU.MTI(); + // Handle just the uplink cases. + switch ((TLMessage::MessageType)TPDU.MTI()) { + case TLMessage::DELIVER_REPORT: + case TLMessage::STATUS_REPORT: + // FIXME -- Not implemented yet. + LOG(WARNING) << "Unsupported TPDU type: " << (TLMessage::MessageType)TPDU.MTI(); + return NULL; + case TLMessage::SUBMIT: { + TLSubmit *submit = new TLSubmit; + submit->parse(TPDU); + LOG(INFO) << "SMS SMS-SUBMIT " << *submit; + return submit; + } + default: + return NULL; + } +} + +void CPMessage::text(ostream& os) const +{ + os << (CPMessage::MessageType)MTI(); + os <<" TI=" << mTI; +} + + + +void CPMessage::write(L3Frame& dest) const +{ + // We override L3Message::write for the transaction identifier. + dest.resize(bitsNeeded()); + size_t wp = 0; + // Note that 1/2-octet fields are reversed relative to Table 7.1. + dest.writeField(wp,mTI,4); + dest.writeField(wp,PD(),4); + dest.writeField(wp,MTI(),8); + writeBody(dest, wp); +} + + +void CPData::parseBody( const L3Frame& src, size_t &rp ) +{ + mData.parseLV(src,rp); +} + +void CPData::writeBody( L3Frame& dest, size_t &wp ) const +{ + mData.writeLV(dest,wp); +} + +void CPData::text(ostream& os) const +{ + CPMessage::text(os); + os << " RPDU=(" << mData << ")"; +} + +void CPError::writeBody( L3Frame& dest, size_t &wp ) const +{ + mCause.writeV(dest,wp); +} + + +void CPUserData::parseV(const L3Frame& src, size_t &rp, size_t expectedLength) +{ + unsigned numBits = expectedLength*8; + mRPDU.resize(numBits); + src.segmentCopyTo(mRPDU,rp,numBits); + rp += numBits; +} + +void CPUserData::writeV(L3Frame& dest, size_t &wp) const +{ + unsigned numBits = mRPDU.size(); + mRPDU.copyToSegment(dest,wp,numBits); + wp += numBits; +} + + + + +ostream& SMS::operator<<(ostream& os, RPMessage::MessageType val) +{ + switch(val) { + case RPMessage::Data: os<<"RP-DATA"; break; + case RPMessage::Ack: os<<"RP-ACK"; break; + case RPMessage::Error: os<<"RP-ERROR"; break; + case RPMessage::SMMA: os<<"RP-SMMA"; break; + default : + os<255) vp=255; + dest.writeField(wp,vp,8); +} + + + +void TLValidityPeriod::text(ostream& os) const +{ + char str[27]; + time_t seconds = mExpiration.sec(); + ctime_r(&seconds,str); + str[24]='\0'; + os << "expiration=(" << str << ")"; +} + +void TLUserData::encode7bit(const char *text) +{ + size_t wp = 0; + + // 1. Prepare. + // Default alphabet (7-bit) + mDCS = 0; + // With 7-bit encoding TP-User-Data-Length count septets, i.e. just number + // of characters. + mLength = strlen(text); + int bytes = (mLength*7+7)/8; + int filler_bits = bytes*8-mLength*7; + mRawData.resize(bytes*8); + + // 2. Write TP-UD + // This tail() works because UD is always the last field in the PDU. + BitVector chars = mRawData.tail(wp); + for (unsigned i=0; i (mRawData.size())) { + LOG(NOTICE) << "badly formatted TL-UD"; + SMS_READ_ERROR; + } + + size_t crp = 0; + unsigned text_length = mLength; + + // Skip User-Data-Header. We don't decode it here. + // User-Data-Header handling is described in GSM 03.40 9.2.3.24 + // and is pictured in GSM 03.40 Figure 9.2.3.24 (a) + if (mUDHI) { + // Length-of-User-Data-Header + unsigned udhl = mRawData.peekFieldReversed(crp,8); + // Calculate UDH length in septets, including fill bits. + unsigned udh_septets = (udhl*8 + 8 + 6) / 7; + // Adjust actual text position and length. + crp += udh_septets * 7; + text_length -= udh_septets; + LOG(DEBUG) << "UDHL(octets)=" << udhl + << " UDHL(septets)=" << udh_septets + << " pointer(bits)=" << crp + << " text_length(septets)=" << text_length; + } + + // Do decoding + text.resize(text_length); + for (unsigned i=0; i (src.size()-rp)) { + LOG(NOTICE) << "badly formatted TL-UD"; + SMS_READ_ERROR; + } + BitVector chars(src.tail(rp)); + chars.LSB8MSB(); + size_t crp=0; + for (unsigned i=0; i +#include "SMSTransfer.h" +#include +#include +#include + + +namespace SMS { + + +class SMSReadError : public GSM::GSMError { + public: + SMSReadError():GSMError() {} +}; +#define SMS_READ_ERROR {throw SMSReadError();} + + + + +/**@name SMS Transport Layer (TL) */ +//@{ + +// FIXME -- All parsers for TL messages and elements should return a success/fail indication. + +/**@name Elements for SMS Transport Layer (TL) */ +//@{ + +/** A base class for elements of GSM 03.40 9.1.2 and 9.2.3 */ +class TLElement { + public: + virtual ~TLElement() {} + virtual size_t length() const =0; + virtual void parse(const TLFrame&, size_t&) =0; + virtual void write(TLFrame&, size_t&) const =0; + virtual void text(std::ostream&) const {} +}; + +std::ostream& operator<<(std::ostream& os, const TLElement& msg); + +/** + GSM 03.40 9.1.2.5 + This is very similar to a Q.931-style BCD number. + Especially since we don't support non-numeric addresses. +*/ +class TLAddress : public TLElement { + +private: + + GSM::TypeOfNumber mType; + GSM::NumberingPlan mPlan; + GSM::L3BCDDigits mDigits; + +public: + + TLAddress():TLElement() {} + + TLAddress(GSM::TypeOfNumber wType, GSM::NumberingPlan wPlan, const char* wDigits) + :TLElement(), + mType(wType),mPlan(wPlan),mDigits(wDigits) + { } + + TLAddress(const char* wDigits) + :TLElement(), + mType(GSM::NationalNumber),mPlan(GSM::E164Plan),mDigits(wDigits) + { } + + const char *digits() const { return mDigits.digits(); } + GSM::TypeOfNumber type() const { return mType; } + GSM::NumberingPlan plan() const { return mPlan; } + + size_t length() const { return 2 + mDigits.lengthV(); } + void parse(const TLFrame&, size_t&); + void write(TLFrame&, size_t&) const; + void text(std::ostream&) const; +}; + + + +/** GSM 03.40 9.2.3.12 */ +class TLValidityPeriod : public TLElement { + +private: + + unsigned mVPF; + Timeval mExpiration; + +public: + + + /** Default validity period of one week, no format specified. */ + TLValidityPeriod(unsigned wVPF=0xFF) + :TLElement(), + mVPF(wVPF), + mExpiration(7*24*60*60*1000) + { } + + void VPF(unsigned wVPF) { mVPF=wVPF; } + + size_t length() const; + void parse(const TLFrame&, size_t&); + void write(TLFrame&, size_t&) const; + void text(std::ostream&) const; +}; + + + +class TLTimestamp : public TLElement { + + private: + + GSM::L3TimeZoneAndTime mTime; + + public: + + const Timeval& time() const { return mTime.time(); } + void time(const Timeval& wTime) { mTime.time(wTime); } + + size_t length() const { return mTime.lengthV(); } + void write(TLFrame& dest, size_t& wp) const { mTime.writeV((GSM::L3Frame&)(BitVector&)dest, wp); } + void parse(const TLFrame& src, size_t& rp) { mTime.parseV((GSM::L3Frame&)(BitVector&)src, rp); } +}; + + + +/** GSM 03.40 9.2.3.24 */ +class TLUserData : public TLElement { + + private: + + unsigned mDCS; ///< data coding scheme + bool mUDHI; ///< header indicator + unsigned mLength; ///< TP-User-Data-Length, see GSM 03.40 Fig. 9.2.3.24(a), + ///< GSM 03.40 Fig. 9.2.3.24(b) and GSM 03.40 9.2.3.16. + BitVector mRawData; ///< raw packed data + + public: + + /** Initialize the DCS with a non-valid value. */ + TLUserData(unsigned wDCS=0x100, bool wUDHI=false) + :TLElement(), + mDCS(wDCS), + mUDHI(wUDHI), + mLength(0) + { + } + + /** Initialize from a raw encoded data. */ + TLUserData(unsigned wDCS, const BitVector wRawData, unsigned wLength, + bool wUDHI=false) + :TLElement(), + mDCS(wDCS), + mUDHI(wUDHI), + mLength(wLength) + { + mRawData.clone(wRawData); + } + + /** Initialize from a simple C string. */ + TLUserData(const char* text, GSM::GSMAlphabet alphabet=GSM::ALPHABET_7BIT, bool wUDHI=false) + :TLElement(), + mDCS(0), + mUDHI(wUDHI), + mLength(0) + { + switch(alphabet) { + case GSM::ALPHABET_7BIT: + encode7bit(text); + break; + case GSM::ALPHABET_8BIT: + case GSM::ALPHABET_UCS2: + default: + //LOG(WARNING) << "Unsupported alphabet: " << alphabet; + break; + } + } + + void DCS(unsigned wDCS) { mDCS=wDCS; } + unsigned DCS() const { return mDCS; } + void UDHI(unsigned wUDHI) { mUDHI=wUDHI; } + unsigned UDHI() const { return mUDHI; } + /** Encode text into this element, using 7-bit alphabet */ + void encode7bit(const char *text); + /** Decode text from this element, using 7-bit alphabet */ + std::string decode() const; + + /** This length includes a byte for the length field. */ + size_t length() const; + + /** Parse, including the initial length byte. */ + void parse(const TLFrame&, size_t&); + + void write(TLFrame&, size_t&) const; + void text(std::ostream&) const; +}; + + + +//@} // SMS TL Elements + +/**@name Messages for SMS Transport Layer (TL) */ +//@{ + +/** GSM 03.40 9.2 */ +class TLMessage { + + protected: + + /**@name Standard TLheader bits from GSM 03.40 9.2.3. + - 0 MTI (9.2.3.1) + - 1 MTI + - 2 MMS (9.2.3.2), RD (9.2.3.25) + - 3 VPF (9.2.3.3) + - 4 VPF + - 5 SRI (9.2.3.4), SRR (9.2.3.5), SRQ (9.2.3.26) + - 6 UDHI (9.2.3.23) + - 7 RP (9.2.3.17) + */ + //@{ + bool mMMS; ///< more messages to send + bool mRD; ///< reject duplicates + unsigned mVPF; ///< validity period format + bool mSRR; ///< status report request + bool mSRI; ///< status report indication + bool mSRQ; ///< status report qualifier + bool mUDHI; ///< user-data header-indicator + bool mRP; ///< reply path + //@} + + public: + + /** Maximum size of user data field. */ + static const unsigned maxData = 160; + + /** GSM 03.40 9.2.3.1 */ + enum MessageType { + DELIVER = 0x0, // SC -> MS + DELIVER_REPORT = 0x0, // MS -> SC + STATUS_REPORT = 0x2, // SC -> MS + COMMAND = 0x02, // MS -> SC + SUBMIT = 0x1, // MS -> SC + SUBMIT_REPORT = 0x1 // SC -> MS + }; + + TLMessage() + :mMMS(false),mSRI(false),mRP(false) + {} + + virtual ~TLMessage(){} + + virtual int MTI() const=0; + + /** The bodtLength is everything beyond the header byte. */ + virtual size_t l2BodyLength() const = 0; + + virtual size_t length() const { return 1+l2BodyLength(); } + + size_t bitsNeeded() const { return length()*8; } + + virtual void parse( const TLFrame& frame ); + virtual void parseBody( const TLFrame& frame, size_t &rp) =0; + + virtual void write( TLFrame& frame ) const; + virtual void writeBody( TLFrame& frame, size_t &rp) const =0; + + virtual void text(std::ostream& os) const + { os << MTI(); } + + protected: + + /**@name Readers and writers for standard header bits. */ + //@{ + // Note that offset is reversed, i'=7-i. + void writeMTI(TLFrame& fm) const { fm.fillField(6,MTI(),2); } + void writeMMS(TLFrame& fm) const { fm[5]=mMMS; } + void parseMMS(const TLFrame& fm) { mMMS=fm[5]; } + void writeRD(TLFrame& fm) const { fm[5]=mRD; } + void parseRD(const TLFrame& fm) { mRD=fm[5]; } + void writeVPF(TLFrame& fm) const { fm.fillField(3,mVPF,2); } + void parseVPF(const TLFrame& fm) { mVPF = fm.peekField(3,2); } + void writeSRR(TLFrame& fm) const { fm[2]=mSRR; } + void parseSRR(const TLFrame& fm) { mSRR=fm[2]; } + void writeSRI(TLFrame& fm) const { fm[2]=mSRI; } + void parseSRI(const TLFrame& fm) { mSRI=fm[2]; } + void writeSRQ(TLFrame& fm) const { fm[2]=mSRQ; } + void parseSRQ(const TLFrame& fm) { mSRQ=fm[2]; } + void writeUDHI(TLFrame& fm, bool udhi) const { fm[1]=udhi; } + bool parseUDHI(const TLFrame& fm) { return fm[1]; } + void writeRP(TLFrame& fm) const { fm[0]=mRP; } + void parseRP(const TLFrame& fm) { mRP=fm[0]; } + void writeUnused(TLFrame& fm) const { fm.fill(0,3,2); } ///< Fill unused bits with 0s + //@} +}; + +std::ostream& operator<<(std::ostream& os, TLMessage::MessageType val); +std::ostream& operator<<(std::ostream& os, const TLMessage& msg); + + + +/** GSM 03.40 9.2.2.2, uplink */ +class TLSubmit : public TLMessage { + + private: + + unsigned mMR; ///< message reference + TLAddress mDA; ///< destination address + unsigned mPI; ///< protocol identifier + unsigned mDCS; ///< data coding scheme + TLValidityPeriod mVP; ///< validity period + TLUserData mUD; ///< user data + + public: + + int MTI() const { return SUBMIT; } + + const TLAddress& DA() const { return mDA; } + const TLUserData& UD() const { return mUD; } + + size_t l2BodyLength() const; + void writeBody(TLFrame&, size_t&) const { assert(0); } + void parseBody(const TLFrame&, size_t&); + virtual void text(std::ostream&) const; +}; + + + +/** GMS 03.40 9.2.2.2a, downlink */ +class TLSubmitReport : public TLMessage +{ + + private: + // We are leaving out the optional fields. + unsigned mFC; ///< failure cause + unsigned mPI; ///< parameter indicator + TLTimestamp mSCTS; ///< service center timestamp + + public: + + size_t l2BodyLength() const { return 1 + 1 + 7; } + void writeBody(TLFrame& frame, size_t& wp ) const; + void parseBody(const TLFrame&, size_t&) { assert(0); } + virtual void text( std::ostream& os ) const; +}; + + +/** GSM 03.40 9.2.2.1, downlink */ +class TLDeliver : public TLMessage { + + private: + + TLAddress mOA; ///< origination address, GSM 03.40 9.3.2.7 + unsigned mPID; ///< TL-PID, GSM 03.40 9.2.3.9 + // DCS is taken from mUD. + TLTimestamp mSCTS; ///< service center timestamp, GSM 03.40 9.2.3.11 + TLUserData mUD; ///< user data + + public: + + TLDeliver(const TLAddress& wOA, const TLUserData& wUD, unsigned wPID=0) + :TLMessage(), + mOA(wOA),mPID(wPID),mUD(wUD) + { } + + TLDeliver(const TLUserData& wUD) + :TLMessage(), + mUD(wUD) + {} + + int MTI() const { return DELIVER; } + + size_t l2BodyLength() const; + void writeBody( TLFrame& frame, size_t& wp ) const; + void parseBody(const TLFrame&, size_t&) { assert(0); } + virtual void text( std::ostream& os ) const; +}; + + +TLMessage * parseTL( const TLFrame& frame ); + + +//@} // SMS TL Messages + + +//@} // SMS TL + + + +/**@name Elements and Messages for SMS RP (RL Layer) */ +//@{ + +/**@name Elements for SMS RP (RL Layer) */ +//@{ + +/** A common class for RP addresses, GSM 04.11 8.2.5 */ +class RPAddress : public GSM::L3CalledPartyBCDNumber { + + public: + + RPAddress():L3CalledPartyBCDNumber() {} + + RPAddress(const char* wDigits) + :L3CalledPartyBCDNumber(wDigits) + {} + + RPAddress(const GSM::L3CallingPartyBCDNumber& other) + :L3CalledPartyBCDNumber(other) + {} + +}; + +/** GSM 04.11 8.2.5.3 */ +class RPUserData : public GSM::L3ProtocolElement { + + private: + + // The BitVector is a placeholder for a higher-layer object. + TLFrame mTPDU; + + public: + + RPUserData() + :L3ProtocolElement(), + mTPDU() + {} + + RPUserData(const TLFrame& wTPDU) + :L3ProtocolElement(), + mTPDU(wTPDU) + {} + + RPUserData(const TLMessage& TLM) + :L3ProtocolElement() + { + TLM.write(mTPDU); + } + + + const TLFrame& TPDU() const { return mTPDU; } + + size_t lengthV() const + { + size_t len = mTPDU.size()/8; + if (mTPDU.size()%8) len++; + return len; + } + + void writeV(GSM::L3Frame& dest, size_t &wp) const; + void parseV(const GSM::L3Frame& src, size_t &rp) { assert(0); } + void parseV(const GSM::L3Frame& src, size_t &rp, size_t expectedLength); + + void text(std::ostream& os) const { mTPDU.hex(os); } +}; + + +/** + GSM 04.11 8.2.5.4. + We ignore the diagnostics field. +*/ +class RPCause : public GSM::L3ProtocolElement { + + + private: + + unsigned mValue; + + public: + + RPCause(unsigned wValue) + :L3ProtocolElement(), + mValue(wValue) + {} + + size_t lengthV() const { return 1; } + + + void writeV(GSM::L3Frame& dest, size_t &wp) const + { dest.writeField(wp,mValue,8); } + + void parseV(const GSM::L3Frame& src, size_t &rp) + { mValue = src.readField(rp,8); } + + void parseV(const GSM::L3Frame& src, size_t &rp, size_t expectedLength) + { mValue = src.peekField(rp,8); rp += 8*expectedLength; } + + void text(std::ostream& os) const + { os << std::hex << "0x" << mValue << std::dec; } +}; + +//@} + + + + + +/**@name Messages for SMS RP (RL Layer) */ +//@{ + +/** The L4 RP message, GSM 04.11 7.3, 8.2. */ +class RPMessage { + + public: + + unsigned mReference; + + /** Table 8.3 GSM 04.11, add 1 for downlink */ + enum MessageType { + Data=0x0, + Ack=0x2, + Error=0x4, + SMMA=0x6 + }; + + RPMessage(unsigned wReference=0) + :mReference(wReference) + {} + + virtual ~RPMessage(){} + + unsigned reference() const { return mReference; } + + virtual int MTI() const=0; + + virtual size_t l2BodyLength() const = 0; + + size_t length() const { return l2BodyLength()+2; } + + size_t bitsNeeded() const { return length()*8; } + + void parse( const RLFrame& frame ); + + virtual void parseBody(const RLFrame& frame, size_t &rp) =0; + + /** For the network side, the write method adds 1 to the MTI. */ + void write( RLFrame& frame ) const; + + virtual void writeBody(RLFrame& frame, size_t &wp) const =0; + + virtual void text(std::ostream& os) const; + +}; + +std::ostream& operator<<(std::ostream&, RPMessage::MessageType); +std::ostream& operator<<(std::ostream& os, const RPMessage& msg); + + + + +/** GSM 04.11 7.3.1 */ +class RPData : public RPMessage { + + private: + + RPAddress mOriginator; ///< originating SMSC + RPAddress mDestination; ///< destination SMSC + RPUserData mUserData; ///< payload + + public: + + RPData():RPMessage() {} + + /** This is a constructor for the downlink version of the message. */ + RPData(unsigned ref, const RPAddress& wOriginator, const TLMessage& TLM) + :RPMessage(ref), + mOriginator(wOriginator),mUserData(TLM) + {} + + const TLFrame& TPDU() const { return mUserData.TPDU(); } + + int MTI() const { return Data; } + void parseBody( const RLFrame& frame, size_t &rp); + void writeBody( RLFrame & frame, size_t &wp ) const; + + size_t l2BodyLength() const + { return mOriginator.lengthLV() + mDestination.lengthLV() + mUserData.lengthLV(); } + + void text(std::ostream&) const; +}; + + +/** GSM 04.11 7.3.2 */ +class RPSMMA : public RPMessage { + + public: + + int MTI() const { return SMMA; } + //void parseBody( const RLFrame& frame, size_t &rp); + //void writeBody( RLFrame & frame, size_t &wp ) const; + + size_t l2BodyLength() const { return 0; } +}; + + +/** GSM 04.11 7.3.3 */ +class RPAck : public RPMessage { + + // We're ignoring the user data field. + + public: + + RPAck(unsigned mReference) + :RPMessage(mReference) + {} + + int MTI() const { return Ack; } + + void writeBody(RLFrame& frame, size_t &wp) const {} + void parseBody( const RLFrame& frame, size_t &rp) {} + + size_t l2BodyLength() const { return 0; } +}; + + +/** GSM 04.11 7.3.4 */ +class RPError : public RPMessage { + + private: + + // Ignore user data for now. + RPCause mCause; + + public: + + RPError(const RPCause& wCause, unsigned mReference) + :RPMessage(mReference), + mCause(wCause) + {} + + int MTI() const { return Error; } + + void writeBody(RLFrame& frame, size_t &wp) const; + void parseBody(const RLFrame& frame, size_t &rp); + + size_t l2BodyLength() const { return mCause.lengthLV(); } + + void text(std::ostream&) const; +}; + + +//@} + +//@} // SMS RL + + + + + +/**@name Elements for SMS CP (CM Layer) */ +//@{ + +/**@name Elements for SMS CP (CM Layer) */ +//@{ + +/** GSM 04.11 8.1.4.2 */ +class CPCause : public GSM::L3ProtocolElement { + + private: + + unsigned mValue; + + public: + + CPCause(unsigned wValue) + :L3ProtocolElement(), + mValue(wValue) + {} + + size_t lengthV() const { return 1; } + + void writeV(GSM::L3Frame& dest, size_t &wp) const + { dest.writeField(wp,mValue,8); } + + void parseV(const GSM::L3Frame& src, size_t &rp, size_t) { assert(0); } + + void parseV(const GSM::L3Frame& src, size_t &rp) + { mValue = src.readField(rp,8); } + + void text(std::ostream& os) const + { os << std::hex << "0x" << mValue << std::dec; } +}; + + +/** GSM 04.11 8.1.4.1 */ +class CPUserData : public GSM::L3ProtocolElement { + + private: + + RLFrame mRPDU; ///< relay-layer protocol data unit + + public: + + CPUserData() + :L3ProtocolElement() + {} + + CPUserData(const RPMessage& RPM) + :L3ProtocolElement(), + mRPDU(RPM.bitsNeeded()) + { + RPM.write(mRPDU); + } + + const RLFrame& RPDU() const { return mRPDU; } + + size_t lengthV() const { return mRPDU.size()/8; } + void writeV(GSM::L3Frame& dest, size_t &wp) const; + void parseV(const GSM::L3Frame& src, size_t &rp, size_t expectedLength); + void parseV(const GSM::L3Frame& src, size_t &rp) { assert(0); } + void text(std::ostream& os) const { mRPDU.hex(os); } +}; + +//@} // CP Elements + + + +/**@name Messages for SMS CP (SMS CM layer) */ +//@{ + +/** + A virtual class for SMS CM-layer messages. + See GSM 04.11 7. + This is probably nearly the same as GSM::L3CCMessage, + but with different message types. +*/ + +class CPMessage : public GSM::L3Message +{ + private: + + /**@name Header information ref. Figure 8. GSM 04.11 */ + //@{ + unsigned mTI; ///< short transaction ID, GSM 04.07 11.2.3.1.3 + //@} + + + public: + + /** Message type defined in GSM 04.11 8.1.3 Table 8.1 */ + enum MessageType { + DATA=0x01, + ACK=0x04, + ERROR=0x10 + }; + + + CPMessage(unsigned wTI) + :L3Message(), + mTI(wTI) + {} + + size_t fullBodyLength() const { return l2BodyLength(); } + + /** Override the write method to include transaction identifiers in header. */ + void write(GSM::L3Frame& dest) const; + + GSM::L3PD PD() const { return GSM::L3SMSPD; } + + unsigned TI() const { return mTI; } + void TI(unsigned wTI){ mTI=wTI; } + + void text(std::ostream&) const; + +}; + + +std::ostream& operator<<(std::ostream& os, CPMessage::MessageType MTI); + +/** + Parse a complete SMS L3 (CM) message. + This is the top-level SMS parser, called along side other L3 parsers. +*/ +CPMessage * parseSMS( const GSM::L3Frame& frame ); + +/** + Parse msgtext from a hex string to RPData struct. + @param hexstring RPData encoded into hex-string. + @return Pointer to parsed RPData or NULL on error. +*/ +RPData *hex2rpdata(const char *hexstring); + +/** + Parse a TPDU. + Currently only SMS-SUBMIT is supported. + @param TPDU The TPDU. + @return Pointer to parsed TLMessage or NULL on error. +*/ +TLMessage *parseTPDU(const TLFrame& TPDU); + +/** A factory method for SMS L3 (CM) messages. */ +CPMessage * CPFactory( CPMessage::MessageType MTI ); + + + +/** GSM 04.11 7.2.1 */ +class CPAck : public CPMessage +{ + public: + + CPAck( unsigned wTI=7) + :CPMessage(wTI) + { } + + int MTI() const { return ACK; } + + size_t l2BodyLength() const { return 0; } + void parseBody(const GSM::L3Frame& dest, size_t &rp) {}; + void writeBody(GSM::L3Frame& dest, size_t &wp) const {}; + + void text(std::ostream& os) const { CPMessage::text(os); } +}; + + + +/** GSM 04.11 7.2.3 */ +class CPError : public CPMessage +{ + private: + + CPCause mCause; + + public: + + CPError(unsigned wTI=7) + :CPMessage(wTI), + mCause(0x7f) + { } + + CPError(unsigned wTI, const CPCause& wCause) + :CPMessage(wTI), + mCause(wCause) + { } + + int MTI() const { return ERROR; } + size_t l2BodyLength() const { return mCause.lengthV(); } + void writeBody(GSM::L3Frame& dest, size_t &wp) const; + void parseBody(const GSM::L3Frame&, size_t&) { assert(0); } +}; + + + +/** GSM 04.11 7.2.1 */ +class CPData : public CPMessage +{ + private: + + CPUserData mData; + + public: + + CPData(unsigned wTI=7) + :CPMessage(wTI) + { } + + CPData(unsigned wTI, const RPMessage& RPM) + :CPMessage(wTI), + mData(RPM) + { } + + const CPUserData& data() const { return mData; } + const RLFrame& RPDU() const { return mData.RPDU(); } + + int MTI() const { return DATA; } + size_t l2BodyLength() const { return mData.lengthLV(); } + void parseBody(const GSM::L3Frame& dest, size_t &rp); + void writeBody(GSM::L3Frame& dest, size_t &wp) const; + void text(std::ostream&) const; +}; + + +//@} // CP messages + +//@} // SMS CP + + + +}; // namespace SMS + +#endif + +// vim: ts=4 sw=4 diff --git a/SMS/SMSTransfer.cpp b/SMS/SMSTransfer.cpp new file mode 100644 index 0000000..2ea7cdc --- /dev/null +++ b/SMS/SMSTransfer.cpp @@ -0,0 +1,77 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +#include +#include "SMSTransfer.h" + +using namespace std; +using namespace SMS; + + + + +ostream& SMS::operator<<(ostream& os, SMSPrimitive prim) +{ + switch(prim) { + + case SM_RL_DATA_REQ: os<<" SM-RL-DATA-REQ"; break; + case SM_RL_DATA_IND: os<<" SM-RL-DATA-IND"; break; + case SM_RL_MEMORY_AVAIL_IND: os<<" SM-RL-MEMORY-AVAIL-IND"; break; + case SM_RL_REPORT_REQ: os<<" SM-RL-REPORT-REQ"; break; + case SM_RL_REPORT_IND: os<<" SM-RL-REPORT-IND"; break; + case MNSMS_ABORT_REQ: os<<" MNSMS-ABORT-REQ"; break; + case MNSMS_DATA_IND: os<<" MNSMS-DATA-IND"; break; + case MNSMS_DATA_REQ: os<<"MNSMS-DATA-REQ "; break; + case MNSMS_EST_REQ: os<<"MNSMS-EST-REQ "; break; + case MNSMS_EST_IND: os<<"MNSMS-EST-IND "; break; + case MNSMS_ERROR_IND: os<<"MNSMS-ERROR-IND "; break; + case MNSMS_REL_REQ: os<<"MNSMS-REL-REQ "; break; + case UNDEFINED_PRIMITIVE: os<<"undefined "; break; + + } + return os; +} + +ostream& SMS::operator<<(ostream& os, const RLFrame& msg) +{ + os<<"primitive="< +#include +#include + +namespace SMS { + + + + +enum SMSPrimitive { + + // Relay layer primitives for network + //side of connection. GSM 04.11 Table 3 + SM_RL_DATA_REQ=0, // MT SMS-TPDU + SM_RL_DATA_IND=1, // MO SMS-TPDU + SM_RL_MEMORY_AVAIL_IND=2, // None (dont know it well ever use + SM_RL_REPORT_REQ=3, + SM_RL_REPORT_IND=4, + + // MNSMS service primitives on the network side, + //as defined in GSM 04.11 3.2.2 table 3.2 + MNSMS_ABORT_REQ=5, // Cause + MNSMS_DATA_IND = 6, // MO RPDU + MNSMS_DATA_REQ = 7, // MT RPDU + MNSMS_EST_REQ=8, // MT RPDU + MNSMS_EST_IND=9, // MO RPDU + MNSMS_ERROR_IND=10, // Cause + MNSMS_REL_REQ=11, // Cause + UNDEFINED_PRIMITIVE=-1 +}; + + +std::ostream& operator<<(std::ostream& os, SMSPrimitive); + + + +class RLFrame : public GSM::L3Frame +{ + + SMSPrimitive mPrimitive; + + public: + + unsigned MTI() const { return peekField(5,3); } + + unsigned reference() const { return peekField(8,8); } + + RLFrame(SMSPrimitive wPrimitive=UNDEFINED_PRIMITIVE, size_t len=0) + :L3Frame(GSM::DATA,len), mPrimitive(wPrimitive) + { } + + RLFrame(const BitVector& source, SMSPrimitive wPrimitive=UNDEFINED_PRIMITIVE) + :L3Frame(source), mPrimitive(wPrimitive) + { } + + SMSPrimitive primitive() const { return mPrimitive; } +}; + +std::ostream& operator<<(std::ostream& os, const RLFrame& ); + + +class TLFrame : public GSM::L3Frame +{ + + SMSPrimitive mPrimitive; + + public: + + unsigned MTI() const { return peekField(6,2); } + + TLFrame(SMSPrimitive wPrimitive=UNDEFINED_PRIMITIVE, size_t len=0) + :L3Frame(GSM::DATA,len), mPrimitive(wPrimitive) + { } + + TLFrame(const BitVector& source, SMSPrimitive wPrimitive=UNDEFINED_PRIMITIVE) + :L3Frame(source), mPrimitive(wPrimitive) + { } + + SMSPrimitive primitive() const { return mPrimitive; } + +}; + + +std::ostream& operator<<( std::ostream& os, const TLFrame& ); + +}; //namespace SMS { + +#endif + diff --git a/SR/Makefile.am b/SR/Makefile.am new file mode 100644 index 0000000..b3a97ee --- /dev/null +++ b/SR/Makefile.am @@ -0,0 +1,34 @@ +# +# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2010 Kestrel Signal Processing, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = $(STD_DEFINES_AND_INCLUDES) -Wall -ldl -lpthread + +noinst_LTLIBRARIES = libSR.la + +libSR_la_SOURCES = \ + SubscriberRegistry.cpp + +noinst_HEADERS = \ + SubscriberRegistry.h + diff --git a/SR/Makefile.in b/SR/Makefile.in new file mode 100644 index 0000000..9344b33 --- /dev/null +++ b/SR/Makefile.in @@ -0,0 +1,529 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2010 Kestrel Signal Processing, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libSR_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = SR +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libSR_la_LIBADD = +am_libSR_la_OBJECTS = SubscriberRegistry.lo +libSR_la_OBJECTS = $(am_libSR_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libSR_la_SOURCES) +DIST_SOURCES = $(libSR_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = $(STD_DEFINES_AND_INCLUDES) -Wall -ldl -lpthread +noinst_LTLIBRARIES = libSR.la +libSR_la_SOURCES = \ + SubscriberRegistry.cpp + +noinst_HEADERS = \ + SubscriberRegistry.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu SR/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu SR/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libSR.la: $(libSR_la_OBJECTS) $(libSR_la_DEPENDENCIES) + $(CXXLINK) $(libSR_la_LDFLAGS) $(libSR_la_OBJECTS) $(libSR_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SubscriberRegistry.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/SR/SubscriberRegistry.cpp b/SR/SubscriberRegistry.cpp new file mode 100644 index 0000000..e8a42c8 --- /dev/null +++ b/SR/SubscriberRegistry.cpp @@ -0,0 +1,378 @@ +/* +* Copyright 2011 Range Networks, Inc. +* Copyright 2011 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "SubscriberRegistry.h" +#include +#include +#include +#include +#include +#include "sqlite3.h" +#include +#include +#include +#include + +extern ConfigurationTable gConfig; + + +using namespace std; + +static const char* createRRLPTable = { + "CREATE TABLE IF NOT EXISTS RRLP (" + "id INTEGER PRIMARY KEY, " + "name VARCHAR(80) not null, " + "latitude real not null, " + "longitude real not null, " + "error real not null, " + "time text not null " + ")" +}; + +static const char* createDDTable = { + "CREATE TABLE IF NOT EXISTS DIALDATA_TABLE (" + "id INTEGER PRIMARY KEY, " + "exten VARCHAR(40) NOT NULL DEFAULT '', " + "dial VARCHAR(128) NOT NULL DEFAULT '' " + ")" +}; + +static const char* createSBTable = { + "CREATE TABLE IF NOT EXISTS SIP_BUDDIES (" + "id integer primary key, " + "name VARCHAR(80) not null, " + "context VARCHAR(80), " + "callingpres VARCHAR(30) DEFAULT 'allowed_not_screened', " + "deny VARCHAR(95), " + "permit VARCHAR(95), " + "secret VARCHAR(80), " + "md5secret VARCHAR(80), " + "remotesecret VARCHAR(250), " + "transport VARCHAR(10), " + "host VARCHAR(31) default '' not null, " + "nat VARCHAR(5) DEFAULT 'no' not null, " + "type VARCHAR(10) DEFAULT 'friend' not null, " + "accountcode VARCHAR(20), " + "amaflags VARCHAR(13), " + "callgroup VARCHAR(10), " + "callerid VARCHAR(80), " + "defaultip VARCHAR(40) DEFAULT '0.0.0.0', " + "dtmfmode VARCHAR(7) DEFAULT 'rfc2833', " + "fromuser VARCHAR(80), " + "fromdomain VARCHAR(80), " + "insecure VARCHAR(4), " + "language CHAR(2), " + "mailbox VARCHAR(50), " + "pickupgroup VARCHAR(10), " + "qualify CHAR(3), " + "regexten VARCHAR(80), " + "rtptimeout CHAR(3), " + "rtpholdtimeout CHAR(3), " + "setvar VARCHAR(100), " + "disallow VARCHAR(100) DEFAULT 'all', " + "allow VARCHAR(100) DEFAULT 'g729;ilbc;gsm;ulaw;alaw' not null, " + "fullcontact VARCHAR(80), " + "ipaddr VARCHAR(45), " + "port int(5) DEFAULT 0, " + "username VARCHAR(80), " + "defaultuser VARCHAR(80), " + "subscribecontext VARCHAR(80), " + "directmedia VARCHAR(3), " + "trustrpid VARCHAR(3), " + "sendrpid VARCHAR(3), " + "progressinband VARCHAR(5), " + "promiscredir VARCHAR(3), " + "useclientcode VARCHAR(3), " + "callcounter VARCHAR(3), " + "busylevel int(11), " + "allowoverlap VARCHAR(3) DEFAULT 'yes', " + "allowsubscribe VARCHAR(3) DEFAULT 'yes', " + "allowtransfer VARCHAR(3) DEFAULT 'yes', " + "ignoresdpversion VARCHAR(3) DEFAULT 'no', " + "template VARCHAR(100), " + "videosupport VARCHAR(6) DEFAULT 'no', " + "maxcallbitrate int(11), " + "rfc2833compensate VARCHAR(3) DEFAULT 'yes', " + "'session-timers' VARCHAR(10) DEFAULT 'accept', " + "'session-expires' int(6) DEFAULT 1800, " + "'session-minse' int(6) DEFAULT 90, " + "'session-refresher' VARCHAR(3) DEFAULT 'uas', " + "t38pt_usertpsource VARCHAR(3), " + "outboundproxy VARCHAR(250), " + "callbackextension VARCHAR(250), " + "registertrying VARCHAR(3) DEFAULT 'yes', " + "timert1 int(6) DEFAULT 500, " + "timerb int(9), " + "qualifyfreq int(6) DEFAULT 120, " + "contactpermit VARCHAR(250), " + "contactdeny VARCHAR(250), " + "lastms int(11) DEFAULT 0 not null, " + "regserver VARCHAR(100), " + "regseconds int(11) DEFAULT 0 not null, " + "useragent VARCHAR(100), " + "cancallforward CHAR(3) DEFAULT 'yes' not null, " + "canreinvite CHAR(3) DEFAULT 'yes' not null, " + "mask VARCHAR(95), " + "musiconhold VARCHAR(100), " + "restrictcid CHAR(3), " + "calllimit int(5), " + "RRLPSupported int(1) default 1 not null, " + "regTime INTEGER default 0 NOT NULL" // Unix time of most recent registration + ")" +}; + + +SubscriberRegistry::SubscriberRegistry() +{ + string ldb = gConfig.getStr("SubscriberRegistry.db"); + int rc = sqlite3_open(ldb.c_str(),&mDB); + if (rc) { + LOG(EMERG) << "Cannot open SubscriberRegistry database: " << sqlite3_errmsg(mDB); + sqlite3_close(mDB); + mDB = NULL; + return; + } + if (!sqlite3_command(mDB,createRRLPTable)) { + LOG(EMERG) << "Cannot create RRLP table"; + } + if (!sqlite3_command(mDB,createDDTable)) { + LOG(EMERG) << "Cannot create DIALDATA_TABLE table"; + } + if (!sqlite3_command(mDB,createSBTable)) { + LOG(EMERG) << "Cannot create SIP_BUDDIES table"; + } +} + + + +SubscriberRegistry::~SubscriberRegistry() +{ + if (mDB) sqlite3_close(mDB); +} + + + + +SubscriberRegistry::Status SubscriberRegistry::sqlLocal(const char *query, char **resultptr) +{ + LOG(INFO) << query; + + if (!resultptr) { + if (!sqlite3_command(db(), query)) return FAILURE; + return SUCCESS; + } + + sqlite3_stmt *stmt; + if (sqlite3_prepare_statement(db(), &stmt, query)) { + LOG(ERR) << "sqlite3_prepare_statement problem"; + return FAILURE; + } + int src = sqlite3_run_query(db(), stmt); + if (src != SQLITE_ROW) { + sqlite3_finalize(stmt); + return FAILURE; + } + char *column = (char*)sqlite3_column_text(stmt, 0); + if (!column) { + LOG(ERR) << "Subscriber registry returned a NULL column."; + sqlite3_finalize(stmt); + return FAILURE; + } + *resultptr = strdup(column); + sqlite3_finalize(stmt); + return SUCCESS; +} + + + +char *SubscriberRegistry::sqlQuery(const char *unknownColumn, const char *table, const char *knownColumn, const char *knownValue) +{ + char *result = NULL; + SubscriberRegistry::Status st; + ostringstream os; + os << "select " << unknownColumn << " from " << table << " where " << knownColumn << " = \"" << knownValue << "\""; + st = sqlLocal(os.str().c_str(), &result); + if (st == SUCCESS) { + LOG(INFO) << "result = " << result; + return result; + } else { + return NULL; + } +} + + + +SubscriberRegistry::Status SubscriberRegistry::sqlUpdate(const char *stmt) +{ + LOG(INFO) << stmt; + return sqlLocal(stmt, NULL); +} + + + +char *SubscriberRegistry::getIMSI(const char *ISDN) +{ + if (!ISDN) { + LOG(WARNING) << "SubscriberRegistry::getIMSI attempting lookup of NULL ISDN"; + return NULL; + } + LOG(INFO) << "getIMSI(" << ISDN << ")"; + return sqlQuery("dial", "dialdata_table", "exten", ISDN); +} + + + +char *SubscriberRegistry::getCLIDLocal(const char* IMSI) +{ + if (!IMSI) { + LOG(WARNING) << "SubscriberRegistry::getCLIDLocal attempting lookup of NULL IMSI"; + return NULL; + } + LOG(INFO) << "getCLIDLocal(" << IMSI << ")"; + return sqlQuery("callerid", "sip_buddies", "name", IMSI); +} + + + +char *SubscriberRegistry::getCLIDGlobal(const char* IMSI) +{ + if (!IMSI) { + LOG(WARNING) << "SubscriberRegistry::getCLIDGlobal attempting lookup of NULL IMSI"; + return NULL; + } + LOG(INFO) << "getCLIDGlobal(" << IMSI << ")"; + return sqlQuery("callerid", "sip_buddies", "name", IMSI); +} + + + +char *SubscriberRegistry::getRegistrationIP(const char* IMSI) +{ + if (!IMSI) { + LOG(WARNING) << "SubscriberRegistry::getRegistrationIP attempting lookup of NULL IMSI"; + return NULL; + } + LOG(INFO) << "getRegistrationIP(" << IMSI << ")"; + return sqlQuery("ipaddr", "sip_buddies", "name", IMSI); +} + + + +SubscriberRegistry::Status SubscriberRegistry::setRegTime(const char* IMSI) +{ + if (!IMSI) { + LOG(WARNING) << "SubscriberRegistry::setRegTime attempting set for NULL IMSI"; + return FAILURE; + } + unsigned now = (unsigned)time(NULL); + ostringstream os; + os << "update sip_buddies set regTime = " << now << " where name = " << '"' << IMSI << '"'; + return sqlUpdate(os.str().c_str()); +} + + + +SubscriberRegistry::Status SubscriberRegistry::addUser(const char* IMSI, const char* CLID) +{ + if (!IMSI) { + LOG(WARNING) << "SubscriberRegistry::addUser attempting add of NULL IMSI"; + return FAILURE; + } + if (!CLID) { + LOG(WARNING) << "SubscriberRegistry::addUser attempting add of NULL CLID"; + return FAILURE; + } + if (getIMSI(CLID) != NULL || getCLIDLocal(IMSI) != NULL) { + LOG(WARNING) << "SubscriberRegistry::addUser attempting user duplication"; + // technically this is a failure, but I don't want it to keep trying + return SUCCESS; + } + LOG(INFO) << "addUser(" << IMSI << "," << CLID << ")"; + ostringstream os; + os << "insert into sip_buddies (name, username, type, context, host, callerid, canreinvite, allow, dtmfmode, ipaddr) values ("; + os << "\"" << IMSI << "\""; + os << ","; + os << "\"" << IMSI << "\""; + os << ","; + os << "\"" << "friend" << "\""; + os << ","; + os << "\"" << "phones" << "\""; + os << ","; + os << "\"" << "dynamic" << "\""; + os << ","; + os << "\"" << CLID << "\""; + os << ","; + os << "\"" << "no" << "\""; + os << ","; + os << "\"" << "gsm" << "\""; + os << ","; + os << "\"" << "info" << "\""; + os << ","; + os << "\"" << "127.0.0.1" << "\""; + os << ")"; + os << ";"; + SubscriberRegistry::Status st = sqlUpdate(os.str().c_str()); + ostringstream os2; + os2 << "insert into dialdata_table (exten, dial) values ("; + os2 << "\"" << CLID << "\""; + os2 << ","; + os2 << "\"" << IMSI << "\""; + os2 << ")"; + SubscriberRegistry::Status st2 = sqlUpdate(os2.str().c_str()); + return st == SUCCESS && st2 == SUCCESS ? SUCCESS : FAILURE; +} + + + +char *SubscriberRegistry::mapCLIDGlobal(const char *local) +{ + if (!local) { + LOG(WARNING) << "SubscriberRegistry::mapCLIDGlobal attempting lookup of NULL local"; + return NULL; + } + LOG(INFO) << "mapCLIDGlobal(" << local << ")"; + char *IMSI = getIMSI(local); + if (!IMSI) return NULL; + char *global = getCLIDGlobal(IMSI); + free(IMSI); + return global; +} + + + +bool SubscriberRegistry::useGateway(const char* ISDN) +{ + // FIXME -- Do something more general in Asterisk. + // This is a hack for Burning Man. + int cmp = strncmp(ISDN,"88351000125",11); + return cmp!=0; +} + + + + + + +// vim: ts=4 sw=4 diff --git a/SR/SubscriberRegistry.h b/SR/SubscriberRegistry.h new file mode 100644 index 0000000..8024208 --- /dev/null +++ b/SR/SubscriberRegistry.h @@ -0,0 +1,163 @@ +/* +* Copyright 2011 Kestrel Signal Processing, Inc. +* Copyright 2011 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#ifndef SubscriberRegistry_H +#define SubscriberRegistry_H + +#include +#include +#include +// #include +// #include +#include +#include +#include "sqlite3.h" + +using namespace std; + +class SubscriberRegistry { + + private: + + sqlite3 *mDB; ///< database connection + + + public: + + SubscriberRegistry(); + ~SubscriberRegistry(); + + typedef enum { + SUCCESS=0, ///< operation successful + FAILURE=1, ///< operation not successful + DELAYED=2, ///< operation successful, but effect delayed + TRYAGAIN=3 ///< operation not attempted, try again later + } Status; + + + sqlite3 *db() + { + return mDB; + } + + + + /** + Resolve an ISDN or other numeric address to an IMSI. + @param ISDN Any numeric address, E.164, local extension, etc. + @return A C-string to be freed by the caller, + NULL if the ISDN cannot be resolved. + */ + char* getIMSI(const char* ISDN); + + /** + Given an IMSI, return the local CLID, which should be a numeric address. + @param IMSI The subscriber IMSI. + @return A C-string to be freed by the caller, + NULL if the IMSI isn't found. + */ + char* getCLIDLocal(const char* IMSI); + + /** + Given an IMSI, return the global CLID, which should be a numeric address. + @param IMSI The subscriber IMSI. + @return A C-string to be freed by the caller, + NULL if the IMSI isn't found. + */ + char* getCLIDGlobal(const char* IMSI); + + /** + Given an IMSI, return the IP address of the most recent registration. + @param IMSI The subscriber IMSI + @return A C-string to be freed by the caller, "111.222.333.444:port", + NULL if the ISMI isn't registered. + */ + char* getRegistrationIP(const char* IMSI); + + /** + Add a new user to the SubscriberRegistry. + @param IMSI The user's IMSI or SIP username. + @param CLID The user's local CLID. + */ + Status addUser(const char* IMSI, const char* CLID); + + + /** + Set the current time as the time of the most recent registration for an IMSI. + @param IMSI The user's IMSI or SIP username. + */ + Status setRegTime(const char* IMSI); + + + char *mapCLIDGlobal(const char *local); + + + bool useGateway(const char* ISDN); + + + private: + + + + /** + Run sql statments locally. + @param stmt The sql statements. + @param resultptr Set this to point to the result of executing the statements. + */ + Status sqlLocal(const char *stmt, char **resultptr); + + + + /** + Run an sql query (select unknownColumn from table where knownColumn = knownValue). + @param unknownColumn The column whose value you want. + @param table The table to look in. + @param knownColumn The column with the value you know. + @param knownValue The known value of knownColumn. + */ + char *sqlQuery(const char *unknownColumn, const char *table, const char *knownColumn, const char *knownValue); + + + + /** + Run an sql update. + @param stmt The update statement. + */ + Status sqlUpdate(const char *stmt); + + + + + + + + +}; + + + +#endif + +// vim: ts=4 sw=4 diff --git a/TRXManager/Makefile.am b/TRXManager/Makefile.am new file mode 100644 index 0000000..b7d741f --- /dev/null +++ b/TRXManager/Makefile.am @@ -0,0 +1,36 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +EXTRA_DIST = \ + README.TRXManager \ + clockdump.sh + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall + +noinst_LTLIBRARIES = libtrxmanager.la + +libtrxmanager_la_SOURCES = \ + TRXManager.cpp + +noinst_HEADERS = \ + TRXManager.h diff --git a/TRXManager/Makefile.in b/TRXManager/Makefile.in new file mode 100644 index 0000000..2b1f5b9 --- /dev/null +++ b/TRXManager/Makefile.in @@ -0,0 +1,532 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libtrxmanager_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = TRXManager +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libtrxmanager_la_LIBADD = +am_libtrxmanager_la_OBJECTS = TRXManager.lo +libtrxmanager_la_OBJECTS = $(am_libtrxmanager_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libtrxmanager_la_SOURCES) +DIST_SOURCES = $(libtrxmanager_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +EXTRA_DIST = \ + README.TRXManager \ + clockdump.sh + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall +noinst_LTLIBRARIES = libtrxmanager.la +libtrxmanager_la_SOURCES = \ + TRXManager.cpp + +noinst_HEADERS = \ + TRXManager.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu TRXManager/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu TRXManager/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libtrxmanager.la: $(libtrxmanager_la_OBJECTS) $(libtrxmanager_la_DEPENDENCIES) + $(CXXLINK) $(libtrxmanager_la_LDFLAGS) $(libtrxmanager_la_OBJECTS) $(libtrxmanager_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TRXManager.Plo@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/TRXManager/README.TRXManager b/TRXManager/README.TRXManager new file mode 100644 index 0000000..502d661 --- /dev/null +++ b/TRXManager/README.TRXManager @@ -0,0 +1,116 @@ +This is the interface to the transcevier. + +Each TRX Manager UDP socket interface represents a single ARFCN. +Each of these per-ARFCN interfaces is a pair of UDP sockets, one for control and one for data. +Give a base port B (5700), the master clock interface is at port P=B. +The TRX-side control interface for C(N) is on port P=B+2N+1 and the data interface is on an odd numbered port P=B+2N+2. +The corresponding core-side interface for every socket is at P+100. +For any given build, the number of ARFCN interfaces can be fixed. + + + +Indications on the Master Clock Interface + +The master clock interface is output only (from the radio). +Messages are "indications". + +CLOCK gives the current value of the transceiver clock to be used by the core. +This message is sent whenever a trasmission packet arrives that is too late or too early. The clock value is NOT the current transceiver time. It is a time setting the the core should use to give better packet arrival times. +IND CLOCK + + + +Commands on the Per-ARFCN Control Interface + +The per-ARFCN control interface uses a command-reponse protocol. +Commands are NULL-terminated ASCII strings, one per UDP socket. +Each command has a corresponding response. +Every command is of the form: + +CMD [params] + +The is the actual command. +Parameters are optional depending on the commands type. +Every response is of the form: + +RSP [result] + +The is 0 for success and a non-zero error code for failure. +Successful responses may include results, depending on the command type. + + +Power Control + +POWEROFF shuts off transmitter power and stops the demodulator. +CMD POWEROFF +RSP POWEROFF + +POWERON starts the transmitter and starts the demodulator. Initial power level is very low. +This command fails if the transmitter and receiver are not yet tuned. +This command fails if the transmit or receive frequency creates a conflict with another ARFCN that is already runnng. +If the transceiver is already on, it response with success to this command. +CMD POWERON +RSP POWERON + +SETPOWER sets output power in dB wrt full scale. +This command fails if the transmitter and receiver are not running. +CMD SETPOWER +RSP SETPOWER + +ADJPOWER adjusts power by the given dB step. Response returns resulting power level wrt full scale. +This command fails if the transmitter and receiver are not running. +CMD ADJPOWER +RSP ADJPOWER + + +Tuning Control + +RXTUNE tunes the receiver to a given frequency in kHz. +This command fails if the receiver is already running. +(To re-tune you stop the radio, re-tune, and restart.) +This command fails if the transmit or receive frequency creates a conflict with another ARFCN that is already runnng. +CMD RXTUNE +RSP RXTUNE + +TXTUNE tunes the transmitter to a given frequency in kHz. +This command fails if the transmitter is already running. +(To re-tune you stop the radio, re-tune, and restart.) +This command fails if the transmit or receive frequency creates a conflict with another ARFCN that is already runnng. +CMD TXTUNE +RSP TXTUNE + + +Timeslot Control + +SETSLOT sets the format of the uplink timeslots in the ARFCN. +The indicates the timeslot of interest. +The indicates the type of channel that occupies the timeslot. +A chantype of zero indicates the timeslot is off. +CMD SETSLOT +RSP SETSLOT + + +Messages on the per-ARFCN Data Interface + +Messages on the data interface carry one radio burst per UDP message. + + +Received Data Burst + +1 byte timeslot index +4 bytes GSM frame number, big endian +1 byte RSSI in -dBm +2 bytes correlator timing offset in 1/256 symbol steps, 2's-comp, big endian +148 bytes soft symbol estimates, 0 -> definite "0", 255 -> definite "1" + + +Transmit Data Burst + +1 byte timeslot index +4 bytes GSM frame number, big endian +1 byte transmit level wrt ARFCN max, -dB (attenuation) +148 bytes output symbol values, 0 & 1 + + + + diff --git a/TRXManager/TRXManager.cpp b/TRXManager/TRXManager.cpp new file mode 100644 index 0000000..026380a --- /dev/null +++ b/TRXManager/TRXManager.cpp @@ -0,0 +1,492 @@ +/* +* Copyright 2008, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + + +#include "TRXManager.h" +#include "GSMCommon.h" +#include "GSMTransfer.h" +#include "GSMLogicalChannel.h" +#include "GSMConfig.h" +#include "GSML1FEC.h" + +#include + +#include +#include +#include + +#undef WARNING + + +using namespace GSM; +using namespace std; + + +TransceiverManager::TransceiverManager(const char* wTRXAddress, int wBasePort) + :mHaveClock(false), + mClockSocket(wBasePort+100) +{ + // set up the ARFCN manager + mARFCN = new ::ARFCNManager(wTRXAddress,wBasePort+1,*this); +} + + + +void TransceiverManager::start() +{ + mClockThread.start((void*(*)(void*))ClockLoopAdapter,this); + mARFCN->start(); +} + + + + + +void* ClockLoopAdapter(TransceiverManager *transceiver) +{ + Timeval nextContact; + while (1) { + transceiver->clockHandler(); + } + return NULL; +} + + + +void TransceiverManager::clockHandler() +{ + char buffer[MAX_UDP_LENGTH]; + int msgLen = mClockSocket.read(buffer,3000); + + // Did the transceiver die?? + if (msgLen<0) { + LOG(ALERT) << "TRX clock interface timed out, assuming TRX is dead."; + abort(); + } + + if (msgLen==0) { + LOG(ALERT) << "read error on TRX clock interface, return " << msgLen; + return; + } + + if (strncmp(buffer,"IND CLOCK",9)==0) { + uint32_t FN; + sscanf(buffer,"IND CLOCK %u", &FN); + LOG(DEBUG) << "CLOCK indication, clock="<TN(); + const TDMAMapping& mapping = wL1d->mapping(); + + // Is this mapping a valid uplink on this slot? + assert(mapping.uplink()); + assert(mapping.allowedSlot(TN)); + + LOG(DEBUG) << "ARFCNManager::installDecoder TN: " << TN << " repeatLength: " << mapping.repeatLength(); + + mTableLock.lock(); + for (unsigned i=0; i>24) & 0x0ff; + *wp++ = (FN>>16) & 0x0ff; + *wp++ = (FN>>8) & 0x0ff; + *wp++ = (FN) & 0x0ff; + // power level + /// FIXME -- We hard-code gain to 0 dB for now. + *wp++ = 0; + // copy data + const char *dp = burst.begin(); + for (unsigned i=0; idriveRx(); + pthread_testcancel(); + } + return NULL; +} + + + + + +int ::ARFCNManager::sendCommandPacket(const char* command, char* response) +{ + int msgLen = 0; + response[0] = '\0'; + + LOG(INFO) << "command " << command; + mControlLock.lock(); + + for (int retry=0; retry<10; retry++) { + mControlSocket.write(command); + msgLen = mControlSocket.read(response,3000); + if (msgLen>0) { + response[msgLen] = '\0'; + break; + } + LOG(WARNING) << "TRX link timeout on attempt " << retry+1; + } + + mControlLock.unlock(); + LOG(DEBUG) << "response " << response; + + if ((msgLen>4) && (strncmp(response,"RSP ",4)==0)) { + return msgLen; + } + + LOG(ALERT) << "lost control link to transceiver"; + SOCKET_ERROR; +} + + + + +int ::ARFCNManager::sendCommand(const char*command, int param, int *responseParam) +{ + // Send command and get response. + char cmdBuf[MAX_UDP_LENGTH]; + char response[MAX_UDP_LENGTH]; + sprintf(cmdBuf,"CMD %s %d", command, param); + int rspLen = sendCommandPacket(cmdBuf,response); + if (rspLen<=0) return -1; + // Parse and check status. + char cmdNameTest[10]; + int status; + cmdNameTest[0]='\0'; + if (!responseParam) + sscanf(response,"RSP %10s %d", cmdNameTest, &status); + else + sscanf(response,"RSP %10s %d %d", cmdNameTest, &status, responseParam); + if (strcmp(cmdNameTest,command)!=0) return -1; + return status; +} + + +int ::ARFCNManager::sendCommand(const char*command, const char* param) +{ + // Send command and get response. + char cmdBuf[MAX_UDP_LENGTH]; + char response[MAX_UDP_LENGTH]; + sprintf(cmdBuf,"CMD %s %s", command, param); + int rspLen = sendCommandPacket(cmdBuf,response); + if (rspLen<=0) return -1; + // Parse and check status. + char cmdNameTest[10]; + int status; + cmdNameTest[0]='\0'; + sscanf(response,"RSP %10s %d", cmdNameTest, &status); + if (strcmp(cmdNameTest,command)!=0) return -1; + return status; +} + + + +int ::ARFCNManager::sendCommand(const char*command) +{ + // Send command and get response. + char cmdBuf[MAX_UDP_LENGTH]; + char response[MAX_UDP_LENGTH]; + sprintf(cmdBuf,"CMD %s", command); + int rspLen = sendCommandPacket(cmdBuf,response); + if (rspLen<=0) return -1; + // Parse and check status. + char cmdNameTest[10]; + int status; + cmdNameTest[0]='\0'; + sscanf(response,"RSP %10s %d", cmdNameTest, &status); + if (strcmp(cmdNameTest,command)!=0) return -1; + return status; +} + + + + +bool ::ARFCNManager::tune(int wARFCN) +{ + // convert ARFCN number to a frequency + unsigned rxFreq = uplinkFreqKHz(gBTS.band(),wARFCN); + unsigned txFreq = downlinkFreqKHz(gBTS.band(),wARFCN); + // tune rx + int status = sendCommand("RXTUNE",rxFreq); + if (status!=0) { + LOG(ALERT) << "RXTUNE failed with status " << status; + return false; + } + // tune tx + status = sendCommand("TXTUNE",txFreq); + if (status!=0) { + LOG(ALERT) << "TXTUNE failed with status " << status; + return false; + } + // done + mARFCN=wARFCN; + return true; +} + + + +bool ::ARFCNManager::tuneLoopback(int wARFCN) +{ + // convert ARFCN number to a frequency + unsigned txFreq = downlinkFreqKHz(gBTS.band(),wARFCN); + // tune rx + int status = sendCommand("RXTUNE",txFreq); + if (status!=0) { + LOG(ALERT) << "RXTUNE failed with status " << status; + return false; + } + // tune tx + status = sendCommand("TXTUNE",txFreq); + if (status!=0) { + LOG(ALERT) << "TXTUNE failed with status " << status; + return false; + } + // done + mARFCN=wARFCN; + return true; +} + + +bool ::ARFCNManager::powerOff() +{ + int status = sendCommand("POWEROFF"); + if (status!=0) { + LOG(ALERT) << "POWEROFF failed with status " << status; + return false; + } + return true; +} + + +bool ::ARFCNManager::powerOn() +{ + int status = sendCommand("POWERON"); + if (status!=0) { + LOG(ALERT) << "POWERON failed with status " << status; + return false; + } + return true; +} + + + + + +bool ::ARFCNManager::setPower(int dB) +{ + int status = sendCommand("SETPOWER",dB); + if (status!=0) { + LOG(ALERT) << "SETPOWER failed with status " << status; + return false; + } + return true; +} + + +bool ::ARFCNManager::setTSC(unsigned TSC) +{ + assert(TSC<8); + int status = sendCommand("SETTSC",TSC); + if (status!=0) { + LOG(ALERT) << "SETTSC failed with status " << status; + return false; + } + return true; +} + + +bool ::ARFCNManager::setSlot(unsigned TN, unsigned combination) +{ + assert(TN<8); + assert(combination<8); + char paramBuf[MAX_UDP_LENGTH]; + sprintf(paramBuf,"%d %d", TN, combination); + int status = sendCommand("SETSLOT",paramBuf); + if (status!=0) { + LOG(ALERT) << "SETSLOT failed with status " << status; + return false; + } + return true; +} + +bool ::ARFCNManager::setMaxDelay(unsigned km) +{ + int status = sendCommand("SETMAXDLY",km); + if (status!=0) { + LOG(ALERT) << "SETMAXDLY failed with status " << status; + return false; + } + return true; +} + +signed ::ARFCNManager::setRxGain(signed rxGain) +{ + signed newRxGain; + int status = sendCommand("SETRXGAIN",rxGain,&newRxGain); + if (status!=0) { + LOG(ALERT) << "SETRXGAIN failed with status " << status; + return false; + } + return newRxGain; +} + +signed ::ARFCNManager::getNoiseLevel(void) +{ + signed noiselevel; + int status = sendCommand("NOISELEV",0,&noiselevel); + if (status!=0) { + LOG(ALERT) << "NOISELEV failed with status " << status; + return false; + } + return noiselevel; +} + +void ::ARFCNManager::receiveBurst(const RxBurst& inBurst) +{ + LOG(DEBUG) << "receiveBurst: " << inBurst; + uint32_t FN = inBurst.time().FN() % maxModulus; + unsigned TN = inBurst.time().TN(); + + mTableLock.lock(); + L1Decoder *proc = mDemuxTable[TN][FN]; + if (proc==NULL) { + LOG(DEBUG) << "ARFNManager::receiveBurst in unconfigured TDMA position TN: " << TN << " FN: " << FN << "."; + mTableLock.unlock(); + return; + } + proc->writeLowSide(inBurst); + mTableLock.unlock(); +} + + +// vim: ts=4 sw=4 diff --git a/TRXManager/TRXManager.h b/TRXManager/TRXManager.h new file mode 100644 index 0000000..81f22f2 --- /dev/null +++ b/TRXManager/TRXManager.h @@ -0,0 +1,261 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#ifndef TRXMANAGER_H +#define TRXMANAGER_H + +#include +#include +#include + +#include "Threads.h" +#include "Sockets.h" +#include "Interthread.h" +#include "GSMCommon.h" +#include "GSMTransfer.h" +#include + + +/* Forward refs into the GSM namespace. */ +namespace GSM { + +class L1Decoder; + +}; + + +class ARFCNManager; + + +/** + The TransceiverManager processes the complete transcevier interface. + There is one of these for each access point. + */ +class TransceiverManager { + + private: + + /// the ARFCN mananger under this TRX + ARFCNManager* mARFCN; + + /// set true when the first CLOCK packet is received + volatile bool mHaveClock; + /// socket for clock management messages + UDPSocket mClockSocket; + /// a thread to monitor the global clock socket + Thread mClockThread; + + + public: + + /** + Construct a TransceiverManager. + @param wTRXAddress IP address of the transceiver. + @param wBasePort The base port for the interface, as defined in README.TRX. + */ + TransceiverManager(const char* wTRXAddress, int wBasePort); + + /**@name Accessors. */ + //@{ + ARFCNManager* ARFCN() { return mARFCN; } + //@} + + /** Start the clock management thread and all ARFCN managers. */ + void start(); + + /** Clock service loop. */ + friend void* ClockLoopAdapter(TransceiverManager*); + + private: + + /** Handler for messages on the clock interface. */ + void clockHandler(); +}; + + + + +void* ClockLoopAdapter(TransceiverManager *TRXm); + + + + +/** + The ARFCN Manager processes transceiver functions for a single ARFCN. + When we do frequency hopping, this will manage a full rate radio channel. +*/ +class ARFCNManager { + + private: + + TransceiverManager &mTransceiver; + + Mutex mDataSocketLock; ///< lock to prevent contentional for the socket + UDPSocket mDataSocket; ///< socket for data transfer + Mutex mControlLock; ///< lock to prevent overlapping transactions + UDPSocket mControlSocket; ///< socket for radio control + + Thread mRxThread; ///< thread to receive data from rx + + /**@name The demux table. */ + //@{ + Mutex mTableLock; + static const unsigned maxModulus=51*26*4; ///< maximum unified repeat period + GSM::L1Decoder* mDemuxTable[8][maxModulus]; ///< the demultiplexing table for received bursts + //@} + + unsigned mARFCN; ///< the current ARFCN + + + public: + + ARFCNManager(const char* wTRXAddress, int wBasePort, TransceiverManager &wTRX); + + /** Start the uplink thread. */ + void start(); + + unsigned ARFCN() const { return mARFCN; } + + void writeHighSide(const GSM::TxBurst& burst); + + + /**@name Transceiver controls. */ + //@{ + + /** + Tune to a given ARFCN. + @param wARFCN Target for tuning. + @return true on success. + */ + bool tune(int wARFCN); + + /** + Tune to a given ARFCN, but with rx and tx on the same (downlink) frequency. + @param wARFCN Target for tuning, using downlink frequeny. + @return true on success. + */ + bool tuneLoopback(int wARFCN); + + /** Turn off the transceiver. */ + bool powerOff(); + + /** Turn on the transceiver. */ + bool powerOn(); + + /** + Set maximum expected delay spread. + @param km Max network range in kilometers. + @return true on success. + */ + bool setMaxDelay(unsigned km); + + /** + Set radio receive gain. + @param new desired gain in dB. + @return new gain in dB. + */ + signed setRxGain(signed dB); + + /** + Get noise level as RSSI. + @return current noise level. + */ + signed getNoiseLevel(void); + + /** + Set power wrt full scale. + @param dB Power level wrt full power. + @return true on success. + */ + bool setPower(int dB); + + /** + Set TSC for all slots on the ARFCN. + @param TSC TSC to use. + @return true on success. + */ + bool setTSC(unsigned TSC); + + /** + Describe the channel combination on a given slot. + @param TN The timeslot number 0..7. + @param combo Channel combination, GSM 05.02 6.4.1, 0 for inactive. + @return true on success. + */ + bool setSlot(unsigned TN, unsigned combo); + + //@} + + + /** Install a decoder on this ARFCN. */ + void installDecoder(GSM::L1Decoder* wL1); + + + + private: + + /** Action for reception. */ + void driveRx(); + + /** Demultiplex and process a received burst. */ + void receiveBurst(const GSM::RxBurst&); + + /** Receiver loop. */ + friend void* ReceiveLoopAdapter(ARFCNManager*); + + /** + Send a command packet and get the response packet. + @param command The NULL-terminated command string to send. + @param response A buffer for the response packet, assumed to be char[MAX_PACKET_LENGTH]. + @return Length of the response or -1 on failure. + */ + int sendCommandPacket(const char* command, char* response); + + /** + Send a command with a parameter. + @param command The command name. + @param param The parameter for the command. + @param responseParam Optional parameter returned + @return The status code, 0 on success, -1 on local failure. + */ + int sendCommand(const char* command, int param, int *responseParam=NULL); + + /** + Send a command with a string parameter. + @param command The command name. + @param param The string parameter(s). + @return The status code, 0 on success, -1 on local failure. + */ + int sendCommand(const char* command, const char* param); + + + /** + Send a command with no parameter. + @param command The command name. + @return The status code, 0 on success, -1 on local failure. + */ + int sendCommand(const char* command); + + +}; + + +/** C interface for ARFCNManager threads. */ +void* ReceiveLoopAdapter(ARFCNManager*); + + +#endif +// vim: ts=4 sw=4 diff --git a/TRXManager/clockdump.sh b/TRXManager/clockdump.sh new file mode 100755 index 0000000..c2a6574 --- /dev/null +++ b/TRXManager/clockdump.sh @@ -0,0 +1,3 @@ +#!/bin/sh +sudo tcpdump -i lo0 -A udp port 5700 + diff --git a/TransceiverRAD1/Complex.h b/TransceiverRAD1/Complex.h new file mode 100644 index 0000000..32eb18f --- /dev/null +++ b/TransceiverRAD1/Complex.h @@ -0,0 +1,267 @@ +/**@file templates for Complex classes +unlike the built-in complex<> templates, these inline most operations for speed +*/ + +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + + +#ifndef COMPLEXCPP_H +#define COMPLEXCPP_H + +#include +#include + + +template class Complex { + +public: + + Real r, i; + + /**@name constructors */ + //@{ + /**@name from real */ + //@{ + Complex(Real real, Real imag) {r=real; i=imag;} // x=complex(a,b) + Complex(Real real) {r=real; i=0;} // x=complex(a) + //@} + /**@name from nothing */ + //@{ + Complex() {r=(Real)0; i=(Real)0;} // x=complex() + //@} + /**@name from other complex */ + //@{ + Complex(const Complex& z) {r=z.r; i=z.i;} // x=complex(z) + Complex(const Complex& z) {r=z.r; i=z.i;} // x=complex(z) + Complex(const Complex& z) {r=z.r; i=z.i;} // x=complex(z) + //@} + //@} + + /**@name casting up from basic numeric types */ + //@{ + Complex& operator=(char a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(int a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(long int a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(short a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(float a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(double a) { r=(Real)a; i=(Real)0; return *this; } + Complex& operator=(long double a) { r=(Real)a; i=(Real)0; return *this; } + //@} + + /**@name arithmetic */ + //@{ + /**@ binary operators */ + //@{ + Complex operator+(const Complex& a) const { return Complex(r+a.r, i+a.i); } + Complex operator+(Real a) const { return Complex(r+a,i); } + Complex operator-(const Complex& a) const { return Complex(r-a.r, i-a.i); } + Complex operator-(Real a) const { return Complex(r-a,i); } + Complex operator*(const Complex& a) const { return Complex(r*a.r-i*a.i, r*a.i+i*a.r); } + Complex operator*(Real a) const { return Complex(r*a, i*a); } + Complex operator/(const Complex& a) const { return operator*(a.inv()); } + Complex operator/(Real a) const { return Complex(r/a, i/a); } + //@} + /*@name component-wise product */ + //@{ + Complex operator&(const Complex& a) const { return Complex(r*a.r, i*a.i); } + //@} + /*@name inplace operations */ + //@{ + Complex& operator+=(const Complex&); + Complex& operator-=(const Complex&); + Complex& operator*=(const Complex&); + Complex& operator/=(const Complex&); + Complex& operator+=(Real); + Complex& operator-=(Real); + Complex& operator*=(Real); + Complex& operator/=(Real); + //@} + //@} + + /**@name comparisons */ + //@{ + bool operator==(const Complex& a) const { return ((i==a.i)&&(r==a.r)); } + bool operator!=(const Complex& a) const { return ((i!=a.i)||(r!=a.r)); } + bool operator<(const Complex& a) const { return norm2()(const Complex& a) const { return norm2()>a.norm2(); } + //@} + + /// reciprocation + Complex inv() const; + + // unary functions -- inlined + /**@name unary functions */ + //@{ + /**@name inlined */ + //@{ + Complex conj() const { return Complex(r,-i); } + Real norm2() const { return i*i+r*r; } + Complex flip() const { return Complex(i,r); } + Real real() const { return r;} + Real imag() const { return i;} + Complex neg() const { return Complex(-r, -i); } + bool isZero() const { return ((r==(Real)0) && (i==(Real)0)); } + //@} + /**@name not inlined due to outside calls */ + //@{ + Real abs() const { return ::sqrt(norm2()); } + Real arg() const { return ::atan2(i,r); } + float dB() const { return 10.0*log10(norm2()); } + Complex exp() const { return expj(i)*(::exp(r)); } + Complex unit() const; ///< unit phasor with same angle + Complex log() const { return Complex(::log(abs()),arg()); } + Complex pow(double n) const { return expj(arg()*n)*(::pow(abs(),n)); } + Complex sqrt() const { return pow(0.5); } + //@} + //@} + +}; + + +/**@name standard Complex manifestations */ +//@{ +typedef Complex complex; +typedef Complex dcomplex; +typedef Complex complex16; +typedef Complex complex32; +//@} + + +template inline Complex Complex::inv() const +{ + Real nVal; + + nVal = norm2(); + return Complex(r/nVal, -i/nVal); +} + +template Complex& Complex::operator+=(const Complex& a) +{ + r += a.r; + i += a.i; + return *this; +} + +template Complex& Complex::operator*=(const Complex& a) +{ + operator*(a); + return *this; +} + +template Complex& Complex::operator-=(const Complex& a) +{ + r -= a.r; + i -= a.i; + return *this; +} + +template Complex& Complex::operator/=(const Complex& a) +{ + operator/(a); + return *this; +} + + +/* op= style operations with reals */ + +template Complex& Complex::operator+=(Real a) +{ + r += a; + return *this; +} + +template Complex& Complex::operator*=(Real a) +{ + r *=a; + i *=a; + return *this; +} + +template Complex& Complex::operator-=(Real a) +{ + r -= a; + return *this; +} + +template Complex& Complex::operator/=(Real a) +{ + r /= a; + i /= a; + return *this; +} + + +template Complex Complex::unit() const +{ + Real absVal = abs(); + return (Complex(r/absVal, i/absVal)); +} + + + +/**@name complex functions outside of the Complex<> class. */ +//@{ + +/** this allows type-commutative multiplication */ +template Complex operator*(Real a, const Complex& z) +{ + return Complex(z.r*a, z.i*a); +} + + +/** this allows type-commutative addition */ +template Complex operator+(Real a, const Complex& z) +{ + return Complex(z.r+a, z.i); +} + + +/** this allows type-commutative subtraction */ +template Complex operator-(Real a, const Complex& z) +{ + return Complex(z.r-a, z.i); +} + + + +/// e^jphi +template Complex expj(Real phi) +{ + return Complex(cos(phi),sin(phi)); +} + +/// phasor expression of a complex number +template Complex phasor(Real C, Real phi) +{ + return (expj(phi)*C); +} + +/// formatted stream output +template std::ostream& operator<<(std::ostream& os, const Complex& z) +{ + os << z.r << ' '; + //os << z.r << ", "; + //if (z.i>=0) { os << "+"; } + os << z.i << "j"; + os << "\n"; + return os; +} + +//@} + + +#endif diff --git a/TransceiverRAD1/DummyLoad.cpp b/TransceiverRAD1/DummyLoad.cpp new file mode 100644 index 0000000..d11226e --- /dev/null +++ b/TransceiverRAD1/DummyLoad.cpp @@ -0,0 +1,146 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + +/* + Compilation Flags + + SWLOOPBACK compile for software loopback testing +*/ + + +#include +#include +#include +#include "Threads.h" +#include "DummyLoad.h" + +#include + + +using namespace std; + + + +int DummyLoad::loadBurst(short *wDummyBurst, int len) { + dummyBurst = wDummyBurst; + dummyBurstSz = len; +} + + +DummyLoad::DummyLoad (double _desiredSampleRate) +{ + LOG(INFO) << "creating USRP device..."; + sampleRate = _desiredSampleRate; +} + +void DummyLoad::updateTime(void) { + gettimeofday(&currTime,NULL); + double timeElapsed = (currTime.tv_sec - startTime.tv_sec)*1.0e6 + + (currTime.tv_usec - startTime.tv_usec); + currstamp = (TIMESTAMP) floor(timeElapsed/(1.0e6/sampleRate)); +} + +bool DummyLoad::make(bool wSkipRx) +{ + + samplesRead = 0; + samplesWritten = 0; + return true; +} + +bool DummyLoad::start() +{ + LOG(INFO) << "starting USRP..."; + underrun = false; + gettimeofday(&startTime,NULL); + dummyBurstCursor = 0; + return true; +} + +bool DummyLoad::stop() +{ + return true; +} + + +// NOTE: Assumes sequential reads +int DummyLoad::readSamples(short *buf, int len, bool *overrun, + TIMESTAMP timestamp, + bool *wUnderrun, + unsigned *RSSI) +{ + updateTime(); + underrunLock.lock(); + *wUnderrun = underrun; + underrunLock.unlock(); + if (currstamp+len < timestamp) { + usleep(100); + return NULL; + } + else if (currstamp < timestamp) { + usleep(100); + return NULL; + } + else if (timestamp+len < currstamp) { + memcpy(buf,dummyBurst+dummyBurstCursor*2,sizeof(short)*2*(dummyBurstSz-dummyBurstCursor)); + int retVal = dummyBurstSz-dummyBurstCursor; + dummyBurstCursor = 0; + return retVal; + } + else if (timestamp + len > currstamp) { + int amount = timestamp + len - currstamp; + if (amount < dummyBurstSz-dummyBurstCursor) { + memcpy(buf,dummyBurst+dummyBurstCursor*2,sizeof(short)*2*amount); + dummyBurstCursor += amount; + return amount; + } + else { + memcpy(buf,dummyBurst+dummyBurstCursor*2,sizeof(short)*2*(dummyBurstSz-dummyBurstCursor)); + int retVal = dummyBurstSz-dummyBurstCursor; + dummyBurstCursor = 0; + return retVal; + } + } + return 0; +} + +int DummyLoad::writeSamples(short *buf, int len, bool *wUnderrun, + unsigned long long timestamp, + bool isControl) +{ + updateTime(); + underrunLock.lock(); + underrun |= (currstamp+len < timestamp); + underrunLock.unlock(); + return len; +} + +bool DummyLoad::updateAlignment(TIMESTAMP timestamp) +{ + return true; +} + +bool DummyLoad::setTxFreq(double wFreq) { return true;}; +bool DummyLoad::setRxFreq(double wFreq) { return true;}; diff --git a/TransceiverRAD1/DummyLoad.h b/TransceiverRAD1/DummyLoad.h new file mode 100644 index 0000000..74a962d --- /dev/null +++ b/TransceiverRAD1/DummyLoad.h @@ -0,0 +1,132 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "radioDevice.h" + + +#include +#include +#include +#include + + +/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */ +class DummyLoad: public RadioDevice { + +private: + + double sampleRate; ///< the desired sampling rate + unsigned long long samplesRead; ///< number of samples read from USRP + unsigned long long samplesWritten; ///< number of samples sent to USRP + + Mutex underrunLock; + + struct timeval startTime, currTime; + + TIMESTAMP currstamp; + short *dummyBurst; + int dummyBurstSz; + int dummyBurstCursor; + bool underrun; + + void updateTime(void); + + public: + + /** Object constructor */ + DummyLoad (double _desiredSampleRate); + + int loadBurst(short *wDummyBurst, int len); + + /** Instantiate the USRP */ + bool make(bool skipRx = false); + + /** Start the USRP */ + bool start(); + + /** Stop the USRP */ + bool stop(); + + /** + Read samples from the USRP. + @param buf preallocated buf to contain read result + @param len number of samples desired + @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough + @param timestamp The timestamp of the first samples to be read + @param underrun Set if USRP does not have data to transmit, e.g. data not being sent fast enough + @param RSSI The received signal strength of the read result + @return The number of samples actually read + */ + int readSamples(short *buf, int len, bool *overrun, + TIMESTAMP timestamp = 0xffffffff, + bool *underrun = NULL, + unsigned *RSSI = NULL); + /** + Write samples to the USRP. + @param buf Contains the data to be written. + @param len number of samples to write. + @param underrun Set if USRP does not have data to transmit, e.g. data not being sent fast enough + @param timestamp The timestamp of the first sample of the data buffer. + @param isControl Set if data is a control packet, e.g. a ping command + @return The number of samples actually written + */ + int writeSamples(short *buf, int len, bool *underrun, + TIMESTAMP timestamp = 0xffffffff, + bool isControl = false); + + /** Update the alignment between the read and write timestamps */ + bool updateAlignment(TIMESTAMP timestamp); + + /** Set the transmitter frequency */ + bool setTxFreq(double wFreq); + + /** Set the receiver frequency */ + bool setRxFreq(double wFreq); + + /** Returns the starting write Timestamp*/ + TIMESTAMP initialWriteTimestamp(void) { return 20000;} + + /** Returns the starting read Timestamp*/ + TIMESTAMP initialReadTimestamp(void) { return 20000;} + + /** returns the full-scale transmit amplitude **/ + double fullScaleInputValue() {return 13500.0;} + + /** returns the full-scale receive amplitude **/ + double fullScaleOutputValue() {return 9450.0;} + + /** Return internal status values */ + inline double getTxFreq() { return 0;} + inline double getRxFreq() { return 0;} + inline double getSampleRate() {return sampleRate;} + inline double numberRead() { return samplesRead; } + inline double numberWritten() { return samplesWritten;} + +}; + diff --git a/TransceiverRAD1/Makefile.am b/TransceiverRAD1/Makefile.am new file mode 100644 index 0000000..a5d9ddd --- /dev/null +++ b/TransceiverRAD1/Makefile.am @@ -0,0 +1,114 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(USB_INCLUDES) $(WITH_INCLUDES) +AM_CXXFLAGS = -DOMNITHREAD_POSIX=1 -lusb-1.0 -ldl -lpthread + +EXTRA_DIST = \ + README \ + README.Talgorithm + +noinst_LTLIBRARIES = libtransceiver.la + +libtransceiver_la_SOURCES = \ + rnrad1Core.cpp \ + fusb.cpp \ + rnrad1Rx.cpp \ + rnrad1Tx.cpp \ + radioInterface.cpp \ + sigProcLib.cpp \ + Transceiver.cpp \ + RAD1Device.cpp \ + DummyLoad.cpp + + +noinst_PROGRAMS = \ + RAD1ping \ + transceiver \ + sigProcLibTest \ + RAD1Cmd \ + RAD1SN \ + RAD1RxRawPower + +noinst_HEADERS = \ + ad9862.h \ + bytesex.h \ + commands.h \ + fusb.h \ + fpga_regs.h \ + ids.h \ + i2c.h \ + interfaces.h \ + spi.h \ + rnrad1Core.h \ + rnrad1.h \ + Complex.h \ + radioInterface.h \ + radioDevice.h \ + sigProcLib.h \ + Transceiver.h \ + RAD1Device.h \ + DummyLoad.h + +RAD1ping_SOURCES = RAD1ping.cpp +RAD1ping_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1RxRawPower_SOURCES = RAD1RxRawPower.cpp +RAD1RxRawPower_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1Cmd_SOURCES = RAD1Cmd.cpp +RAD1Cmd_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1SN_SOURCES = RAD1SN.cpp +RAD1SN_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + + +transceiver_SOURCES = runTransceiver.cpp +transceiver_LDADD = \ + libtransceiver.la \ + $(GSM_LA) \ + $(COMMON_LA) $(SQLITE_LA) + +sigProcLibTest_SOURCES = sigProcLibTest.cpp +sigProcLibTest_LDADD = \ + libtransceiver.la \ + $(GSM_LA) \ + $(COMMON_LA) $(SQLITE_LA) + + + +MOSTLYCLEANFILES += + +#radioInterface.cpp +#ComplexTest.cpp +#sigProcLibTest.cpp +#sweepGenerator.cpp +#testRadio.cpp + diff --git a/TransceiverRAD1/Makefile.in b/TransceiverRAD1/Makefile.in new file mode 100644 index 0000000..a2ba625 --- /dev/null +++ b/TransceiverRAD1/Makefile.in @@ -0,0 +1,674 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + + +SOURCES = $(libtransceiver_la_SOURCES) $(RAD1Cmd_SOURCES) $(RAD1RxRawPower_SOURCES) $(RAD1SN_SOURCES) $(RAD1ping_SOURCES) $(sigProcLibTest_SOURCES) $(transceiver_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +noinst_PROGRAMS = RAD1ping$(EXEEXT) transceiver$(EXEEXT) \ + sigProcLibTest$(EXEEXT) RAD1Cmd$(EXEEXT) RAD1SN$(EXEEXT) \ + RAD1RxRawPower$(EXEEXT) +subdir = TransceiverRAD1 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libtransceiver_la_LIBADD = +am_libtransceiver_la_OBJECTS = rnrad1Core.lo fusb.lo rnrad1Rx.lo \ + rnrad1Tx.lo radioInterface.lo sigProcLib.lo Transceiver.lo \ + RAD1Device.lo DummyLoad.lo +libtransceiver_la_OBJECTS = $(am_libtransceiver_la_OBJECTS) +PROGRAMS = $(noinst_PROGRAMS) +am_RAD1Cmd_OBJECTS = RAD1Cmd.$(OBJEXT) +RAD1Cmd_OBJECTS = $(am_RAD1Cmd_OBJECTS) +am__DEPENDENCIES_1 = $(top_builddir)/CommonLibs/libcommon.la +am__DEPENDENCIES_2 = $(top_builddir)/sqlite3/libsqlite.la +RAD1Cmd_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +am_RAD1RxRawPower_OBJECTS = RAD1RxRawPower.$(OBJEXT) +RAD1RxRawPower_OBJECTS = $(am_RAD1RxRawPower_OBJECTS) +RAD1RxRawPower_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +am_RAD1SN_OBJECTS = RAD1SN.$(OBJEXT) +RAD1SN_OBJECTS = $(am_RAD1SN_OBJECTS) +RAD1SN_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +am_RAD1ping_OBJECTS = RAD1ping.$(OBJEXT) +RAD1ping_OBJECTS = $(am_RAD1ping_OBJECTS) +RAD1ping_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_2) +am_sigProcLibTest_OBJECTS = sigProcLibTest.$(OBJEXT) +sigProcLibTest_OBJECTS = $(am_sigProcLibTest_OBJECTS) +am__DEPENDENCIES_3 = $(top_builddir)/GSM/libGSM.la +sigProcLibTest_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_3) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +am_transceiver_OBJECTS = runTransceiver.$(OBJEXT) +transceiver_OBJECTS = $(am_transceiver_OBJECTS) +transceiver_DEPENDENCIES = libtransceiver.la $(am__DEPENDENCIES_3) \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libtransceiver_la_SOURCES) $(RAD1Cmd_SOURCES) \ + $(RAD1RxRawPower_SOURCES) $(RAD1SN_SOURCES) \ + $(RAD1ping_SOURCES) $(sigProcLibTest_SOURCES) \ + $(transceiver_SOURCES) +DIST_SOURCES = $(libtransceiver_la_SOURCES) $(RAD1Cmd_SOURCES) \ + $(RAD1RxRawPower_SOURCES) $(RAD1SN_SOURCES) \ + $(RAD1ping_SOURCES) $(sigProcLibTest_SOURCES) \ + $(transceiver_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(USB_INCLUDES) $(WITH_INCLUDES) +AM_CXXFLAGS = -DOMNITHREAD_POSIX=1 -lusb-1.0 -ldl -lpthread +EXTRA_DIST = \ + README \ + README.Talgorithm + +noinst_LTLIBRARIES = libtransceiver.la +libtransceiver_la_SOURCES = \ + rnrad1Core.cpp \ + fusb.cpp \ + rnrad1Rx.cpp \ + rnrad1Tx.cpp \ + radioInterface.cpp \ + sigProcLib.cpp \ + Transceiver.cpp \ + RAD1Device.cpp \ + DummyLoad.cpp + +noinst_HEADERS = \ + ad9862.h \ + bytesex.h \ + commands.h \ + fusb.h \ + fpga_regs.h \ + ids.h \ + i2c.h \ + interfaces.h \ + spi.h \ + rnrad1Core.h \ + rnrad1.h \ + Complex.h \ + radioInterface.h \ + radioDevice.h \ + sigProcLib.h \ + Transceiver.h \ + RAD1Device.h \ + DummyLoad.h + +RAD1ping_SOURCES = RAD1ping.cpp +RAD1ping_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1RxRawPower_SOURCES = RAD1RxRawPower.cpp +RAD1RxRawPower_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1Cmd_SOURCES = RAD1Cmd.cpp +RAD1Cmd_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +RAD1SN_SOURCES = RAD1SN.cpp +RAD1SN_LDADD = \ + libtransceiver.la \ + $(COMMON_LA) $(SQLITE_LA) + +transceiver_SOURCES = runTransceiver.cpp +transceiver_LDADD = \ + libtransceiver.la \ + $(GSM_LA) \ + $(COMMON_LA) $(SQLITE_LA) + +sigProcLibTest_SOURCES = sigProcLibTest.cpp +sigProcLibTest_LDADD = \ + libtransceiver.la \ + $(GSM_LA) \ + $(COMMON_LA) $(SQLITE_LA) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu TransceiverRAD1/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu TransceiverRAD1/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libtransceiver.la: $(libtransceiver_la_OBJECTS) $(libtransceiver_la_DEPENDENCIES) + $(CXXLINK) $(libtransceiver_la_LDFLAGS) $(libtransceiver_la_OBJECTS) $(libtransceiver_la_LIBADD) $(LIBS) + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +RAD1Cmd$(EXEEXT): $(RAD1Cmd_OBJECTS) $(RAD1Cmd_DEPENDENCIES) + @rm -f RAD1Cmd$(EXEEXT) + $(CXXLINK) $(RAD1Cmd_LDFLAGS) $(RAD1Cmd_OBJECTS) $(RAD1Cmd_LDADD) $(LIBS) +RAD1RxRawPower$(EXEEXT): $(RAD1RxRawPower_OBJECTS) $(RAD1RxRawPower_DEPENDENCIES) + @rm -f RAD1RxRawPower$(EXEEXT) + $(CXXLINK) $(RAD1RxRawPower_LDFLAGS) $(RAD1RxRawPower_OBJECTS) $(RAD1RxRawPower_LDADD) $(LIBS) +RAD1SN$(EXEEXT): $(RAD1SN_OBJECTS) $(RAD1SN_DEPENDENCIES) + @rm -f RAD1SN$(EXEEXT) + $(CXXLINK) $(RAD1SN_LDFLAGS) $(RAD1SN_OBJECTS) $(RAD1SN_LDADD) $(LIBS) +RAD1ping$(EXEEXT): $(RAD1ping_OBJECTS) $(RAD1ping_DEPENDENCIES) + @rm -f RAD1ping$(EXEEXT) + $(CXXLINK) $(RAD1ping_LDFLAGS) $(RAD1ping_OBJECTS) $(RAD1ping_LDADD) $(LIBS) +sigProcLibTest$(EXEEXT): $(sigProcLibTest_OBJECTS) $(sigProcLibTest_DEPENDENCIES) + @rm -f sigProcLibTest$(EXEEXT) + $(CXXLINK) $(sigProcLibTest_LDFLAGS) $(sigProcLibTest_OBJECTS) $(sigProcLibTest_LDADD) $(LIBS) +transceiver$(EXEEXT): $(transceiver_OBJECTS) $(transceiver_DEPENDENCIES) + @rm -f transceiver$(EXEEXT) + $(CXXLINK) $(transceiver_LDFLAGS) $(transceiver_OBJECTS) $(transceiver_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DummyLoad.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAD1Cmd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAD1Device.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAD1RxRawPower.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAD1SN.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RAD1ping.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Transceiver.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fusb.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radioInterface.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rnrad1Core.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rnrad1Rx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rnrad1Tx.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/runTransceiver.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigProcLib.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sigProcLibTest.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + clean-noinstPROGRAMS mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags uninstall uninstall-am uninstall-info-am + + +#radioInterface.cpp +#ComplexTest.cpp +#sigProcLibTest.cpp +#sweepGenerator.cpp +#testRadio.cpp +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/TransceiverRAD1/RAD1Cmd.cpp b/TransceiverRAD1/RAD1Cmd.cpp new file mode 100644 index 0000000..543f97a --- /dev/null +++ b/TransceiverRAD1/RAD1Cmd.cpp @@ -0,0 +1,327 @@ +/* -*- c++ -*- */ +/* + * USRP - Universal Software Radio Peripheral + * + * Copyright (C) 2003,2004,2009,2011 Free Software Foundation, Inc. + * Copyright 2011 Range Networks, Inc. + * + * 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 3 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., 51 Franklin Street, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +ConfigurationTable gConfig; + +using namespace std; + +#include "rnrad1Core.h" + +char *prog_name; + +static void +set_progname (char *path) +{ + char *p = strrchr (path, '/'); + if (p != 0) + prog_name = p+1; + else + prog_name = path; +} + +static void +usage () +{ + fprintf (stderr, "usage: \n"); + fprintf (stderr, " %s [-v] [-w ] [-x] ...\n", prog_name); + fprintf (stderr, " %s load_standard_bits\n", prog_name); + fprintf (stderr, " %s load_firmware \n", prog_name); + fprintf (stderr, " %s load_fpga \n", prog_name); + fprintf (stderr, " %s write_fpga_reg \n", prog_name); + fprintf (stderr, " %s set_fpga_reset {on|off}\n", prog_name); + fprintf (stderr, " %s set_fpga_tx_enable {on|off}\n", prog_name); + fprintf (stderr, " %s set_fpga_rx_enable {on|off}\n", prog_name); + fprintf (stderr, " ----- diagnostic routines -----\n"); + fprintf (stderr, " %s led0 {on|off}\n", prog_name); + fprintf (stderr, " %s led1 {on|off}\n", prog_name); + fprintf (stderr, " %s set_hash0 \n", prog_name); + fprintf (stderr, " %s get_hash0\n", prog_name); + fprintf (stderr, " %s i2c_read i2c_addr len\n", prog_name); + fprintf (stderr, " %s i2c_write i2c_addr \n", prog_name); + fprintf (stderr, " %s 9862a_write regno value\n", prog_name); + fprintf (stderr, " %s 9862a_read regno\n", prog_name); + exit (1); +} + +#if 0 +static void +die (const char *msg) +{ + fprintf (stderr, "%s (die): %s\n", prog_name, msg); + exit (1); +} +#endif + +static int +hexval (char ch) +{ + if ('0' <= ch && ch <= '9') + return ch - '0'; + + if ('a' <= ch && ch <= 'f') + return ch - 'a' + 10; + + if ('A' <= ch && ch <= 'F') + return ch - 'A' + 10; + + return -1; +} + +static unsigned char * +hex_string_to_binary (const char *string, int *lenptr) +{ + int sl = strlen (string); + if (sl & 0x01){ + fprintf (stderr, "%s: odd number of chars in \n", prog_name); + return 0; + } + + int len = sl / 2; + *lenptr = len; + unsigned char *buf = new unsigned char [len]; + + for (int i = 0; i < len; i++){ + int hi = hexval (string[2 * i]); + int lo = hexval (string[2 * i + 1]); + if (hi < 0 || lo < 0){ + fprintf (stderr, "%s: invalid char in \n", prog_name); + delete [] buf; + return 0; + } + buf[i] = (hi << 4) | lo; + } + return buf; +} + +static void +print_hex (FILE *fp, unsigned char *buf, int len) +{ + for (int i = 0; i < len; i++){ + fprintf (fp, "%02x", buf[i]); + } + fprintf (fp, "\n"); +} + +static void +chk_result (bool ok) +{ + if (!ok){ + fprintf (stderr, "%s: failed\n", prog_name); + exit (1); + } +} + +static bool +get_on_off (const char *s) +{ + if (strcmp (s, "on") == 0) + return true; + + if (strcmp (s, "off") == 0) + return false; + + usage (); // no return + return false; +} + + +int +main (int argc, char **argv) +{ + int ch; + bool verbose = false; + int which_board = 0; + bool fx2_ok_p = false; + + set_progname (argv[0]); + + while ((ch = getopt (argc, argv, "vw:x")) != EOF){ + switch (ch){ + + case 'v': + verbose = true; + break; + + case 'w': + which_board = strtol (optarg, 0, 0); + break; + + case 'x': + fx2_ok_p = true; + break; + + default: + usage (); + } + } + + int nopts = argc - optind; + + if (nopts < 1) + usage (); + + const char *cmd = argv[optind++]; + nopts--; + + gLogInit("openbts",argv[1],LOG_LOCAL7); + + rnrad1Core *core = new rnrad1Core(which_board, + RAD1_CMD_INTERFACE, + RAD1_CMD_ALTINTERFACE, + "","",true); + +#define CHKARGS(n) if (nopts != n) usage (); else + + if (strcmp (cmd, "led0") == 0){ + CHKARGS (1); + bool on = get_on_off (argv[optind]); + chk_result (core->setLed(0, on)); + } + else if (strcmp (cmd, "led1") == 0){ + CHKARGS (1); + bool on = get_on_off (argv[optind]); + chk_result (core->setLed(1, on)); + } + else if (strcmp (cmd, "led2") == 0){ + CHKARGS (1); + bool on = get_on_off (argv[optind]); + chk_result (core->setLed (2, on)); + } + else if (strcmp (cmd, "set_hash0") == 0){ + CHKARGS (1); + char *p = argv[optind]; + unsigned char buf[16]; + + memset (buf, ' ', 16); + for (int i = 0; i < 16 && *p; i++) + buf[i] = *p++; + + chk_result (rad1SetHash (core->getHandle(), 0, buf)); + } + else if (strcmp (cmd, "get_hash0") == 0){ + CHKARGS (0); + unsigned char buf[17]; + memset (buf, 0, 17); + bool r = rad1GetHash (core->getHandle(), 0, buf); + if (r) + printf ("hash: %s\n", buf); + chk_result (r); + } + else if (strcmp (cmd, "load_fpga") == 0){ + CHKARGS (1); + char *filename = argv[optind]; + unsigned char hash[RAD1_HASH_SIZE]; + chk_result (rad1LoadFpga (core->getHandle(), filename, hash)); + } + else if (strcmp (cmd, "load_firmware") == 0){ + CHKARGS (1); + char *filename = argv[optind]; + unsigned char hash[RAD1_HASH_SIZE]; + chk_result (rad1LoadFirmware (core->getHandle(), filename, hash)); + } + else if (strcmp (cmd, "write_fpga_reg") == 0){ + CHKARGS (2); + chk_result (core->writeFpgaReg (strtoul (argv[optind], 0, 0), + strtoul(argv[optind+1], 0, 0))); + } + else if (strcmp (cmd, "set_fpga_reset") == 0){ + CHKARGS (1); + chk_result (usbMsg(core->getHandle(), VRQ_FPGA_SET_RESET, get_on_off (argv[optind]), 0, 0, 0)); + } + else if (strcmp (cmd, "set_fpga_tx_enable") == 0){ + CHKARGS (1); + chk_result (usbMsg(core->getHandle(), VRQ_FPGA_SET_TX_ENABLE, get_on_off (argv[optind]), 0, 0, 0)); + } + else if (strcmp (cmd, "set_fpga_rx_enable") == 0){ + CHKARGS (1); + chk_result (usbMsg(core->getHandle(), VRQ_FPGA_SET_RX_ENABLE, get_on_off (argv[optind]), 0, 0, 0)); + } + else if (strcmp (cmd, "load_standard_bits") == 0){ + CHKARGS (0); + libusb_close(core->getHandle()); + chk_result (rad1_load_standard_bits (which_board, true,"ezusb.ihx","fpga.rbf",core->getContext())); + } + else if (strcmp (cmd, "i2c_read") == 0){ + CHKARGS (2); + int i2c_addr = strtol (argv[optind], 0, 0); + int len = strtol (argv[optind + 1], 0, 0); + if (len < 0) + chk_result (0); + + unsigned char *buf = new unsigned char [len]; + bool result = core->readI2c(i2c_addr, buf, len); + if (!result){ + chk_result (0); + } + print_hex (stdout, buf, len); + } + else if (strcmp (cmd, "i2c_write") == 0){ + CHKARGS (2); + int i2c_addr = strtol (argv[optind], 0, 0); + int len = 0; + char *hex_string = argv[optind + 1]; + unsigned char *buf = hex_string_to_binary (hex_string, &len); + if (buf == 0) + chk_result (0); + + bool result = core->writeI2c(i2c_addr, buf, len); + chk_result (result); + } + else if (strcmp (cmd, "9862a_write") == 0){ + CHKARGS (2); + int regno = strtol (argv[optind], 0, 0); + int value = strtol (argv[optind+1], 0, 0); + chk_result (core->write9862(regno, value)); + } + else if (strcmp (cmd, "9862a_read") == 0){ + CHKARGS (1); + int regno = strtol (argv[optind], 0, 0); + unsigned char value; + bool result = core->read9862(regno, &value); + if (!result){ + chk_result (0); + } + fprintf (stdout, "reg[%d] = 0x%02x\n", regno, value); + } + else { + usage (); + } + + return 0; + + delete core; +} diff --git a/TransceiverRAD1/RAD1Device.cpp b/TransceiverRAD1/RAD1Device.cpp new file mode 100644 index 0000000..7c16d21 --- /dev/null +++ b/TransceiverRAD1/RAD1Device.cpp @@ -0,0 +1,650 @@ +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + +/* + Compilation Flags + + SWLOOPBACK compile for software loopback testing +*/ + + +#include +#include +#include +#include "Threads.h" +#include "RAD1Device.h" + +#include + + +using namespace std; + +unsigned char* write_it(unsigned v, unsigned char *s) { + s[0] = (v>>16) & 0x0ff; + s[1] = (v>>8) & 0x0ff; + s[2] = (v) & 0x0ff; + return s; +} + + +const float RAD1Device::LO_OFFSET = 4.0e6; +const double RAD1Device::masterClockRate = (double) 52.0e6; + +bool RAD1Device::compute_regs(double freq, + unsigned *R, + unsigned *control, + unsigned *N, + double *actual_freq) +{ + if (freq < 1.2e9) { + DIV2 = 1; + freq_mult = 2; + CP1 = 7; + CP2 = 7; + } + else { + DIV2 = 0; + freq_mult = 1; + CP1 = 1; + CP2 = 1; + } + + double phdet_freq = 13.0e6/(double) R_DIV; + int desired_n = (int) round(freq*freq_mult/phdet_freq); + *actual_freq = desired_n * phdet_freq/freq_mult; + + float B = floor(desired_n/16); + float A = desired_n - 16*B; + unsigned B_DIV = int(B); + unsigned A_DIV = int(A); + if (B < A) return false; + *R = (R_RSV<<22) | + (BSC << 20) | + (TEST << 19) | + (LDP << 18) | + (ABP << 16) | + (R_DIV << 2); + *control = (P<<22) | + (PD<<20) | + (CP2 << 17) | + (CP1 << 14) | + (PL << 12) | + (MTLD << 11) | + (CPG << 10) | + (CP3S << 9) | + (PDP << 8) | + (MUXOUT << 5) | + (CR << 4) | + (PC << 2); + *N = (DIVSEL<<23) | + (DIV2<<22) | + (CPGAIN<<21) | + (B_DIV<<8) | + (N_RSV<<7) | + (A_DIV<<2); + return true; +} + + +bool RAD1Device::tx_setFreq(double freq, double *actual_freq) +{ + unsigned R, control, N; + if (!compute_regs(freq, &R, &control, &N, actual_freq)) return false; + if (R==0) return false; + + unsigned char result[3]; + writeLock.lock(); + m_uTx->writeSpi(0,SPI_ENABLE_TX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((R & ~0x3) | 1, result),3); + m_uTx->writeSpi(0,SPI_ENABLE_TX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((control & ~0x3) | 0, result),3); + usleep(10000); + m_uTx->writeSpi(0,SPI_ENABLE_TX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((N & ~0x3) | 2,result),3); + writeLock.unlock(); + + if (m_uTx->readIO() & PLL_LOCK_DETECT) return true; + if (m_uTx->readIO() & PLL_LOCK_DETECT) return true; + return false; +} + + +bool RAD1Device::rx_setFreq(double freq, double *actual_freq) +{ + unsigned R, control, N; + if (!compute_regs(freq, &R, &control, &N, actual_freq)) return false; + if (R==0) return false; + + unsigned char result[3]; + writeLock.lock(); + m_uRx->writeSpi(0,SPI_ENABLE_RX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((R & ~0x3) | 1, result), 3); + m_uRx->writeSpi(0,SPI_ENABLE_RX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((control & ~0x3) | 0, result), 3); + usleep(10000); + m_uRx->writeSpi(0,SPI_ENABLE_RX_A,SPI_FMT_MSB | SPI_FMT_HDR_0, + write_it((N & ~0x3) | 2, result), 3); + writeLock.unlock(); + + usleep(100000); + if (m_uRx->readIO() & PLL_LOCK_DETECT) return true; + if (m_uRx->readIO() & PLL_LOCK_DETECT) return true; + + return true; //return false; +} + + +RAD1Device::RAD1Device (double _desiredSampleRate) +{ + LOG(INFO) << "creating RAD1 device..."; + decimRate = (unsigned int) round(masterClockRate/_desiredSampleRate); + actualSampleRate = masterClockRate/decimRate; + rxGain = 0; + +#ifdef SWLOOPBACK + samplePeriod = 1.0e6/actualSampleRate; + loopbackBufferSize = 0; + gettimeofday(&lastReadTime,NULL); + firstRead = false; +#endif +} + +bool RAD1Device::make(bool wSkipRx) +{ + skipRx = wSkipRx; + + writeLock.unlock(); + + LOG(INFO) << "making RAD1 device.."; +#ifndef SWLOOPBACK + string rbf = "fpga.rbf"; + //string rbf = "inband_1rxhb_1tx.rbf"; + if (!skipRx) { + try { + m_uRx = rnrad1Rx::make(0,decimRate, + rbf,"ezusb.ihx"); + m_uRx->setFpgaMasterClockFreq(masterClockRate); + } + + catch(...) { + LOG(ERR) << "make failed on Rx"; + return false; + } + + if (m_uRx->fpgaMasterClockFreq() != masterClockRate) + { + LOG(ERR) << "WRONG FPGA clock freq = " << m_uRx->fpgaMasterClockFreq() + << ", desired clock freq = " << masterClockRate; + return false; + } + m_uRx->writeOE(0,0xffff); + m_uRx->writeOE((POWER_UP|RX_TXN|ENABLE), 0xffff); + m_uRx->writeIO((POWER_UP|RX_TXN),(POWER_UP|RX_TXN|ENABLE)); + + + } + + try { + m_uTx = rnrad1Tx::make(0,decimRate*2, + rbf,"ezusb.ihx"); + m_uTx->setFpgaMasterClockFreq(masterClockRate); + } + + catch(...) { + LOG(ERR) << "make failed on Tx"; + return false; + } + + m_uTx->writeOE(0,0xffff); + m_uTx->writeOE((POWER_UP|RX_TXN|ENABLE), 0xffff); + m_uTx->writeIO((POWER_UP|RX_TXN),(POWER_UP|RX_TXN|ENABLE)); + + if (m_uTx->fpgaMasterClockFreq() != masterClockRate) + { + LOG(ERR) << "WRONG FPGA clock freq = " << m_uTx->fpgaMasterClockFreq() + << ", desired clock freq = " << masterClockRate; + return false; + } + +#endif + + samplesRead = 0; + samplesWritten = 0; + started = false; + + return true; +} + + + +bool RAD1Device::start() +{ + LOG(INFO) << "starting RAD1..."; +#ifndef SWLOOPBACK + if (!m_uRx && !skipRx) return false; + if (!m_uTx) return false; + + writeLock.lock(); + // power up and configure daughterboards + m_uTx->writeOE(0,0xffff); + m_uTx->writeOE((POWER_UP|RX_TXN|ENABLE), 0xffff); + m_uTx->writeIO((POWER_UP|RX_TXN),(POWER_UP|RX_TXN|ENABLE)); + //m_uTx->writeIO(0,ENABLE,(RX_TXN | ENABLE)); + m_uTx->writeIO((RX_TXN | ENABLE), (RX_TXN | ENABLE));//only for litie + m_uTx->writeFpgaReg(FR_ATR_MASK_0 ,0);//RX_TXN|ENABLE); + m_uTx->writeFpgaReg(FR_ATR_TXVAL_0,0);//,0 |ENABLE); + m_uTx->writeFpgaReg(FR_ATR_RXVAL_0,0);//,RX_TXN|0); + m_uTx->writeFpgaReg(40,0); + m_uTx->writeFpgaReg(42,0); + m_uTx->setPga(0,m_uTx->pgaMax()); // should be 20dB + m_uTx->setPga(1,m_uTx->pgaMax()); + m_uTx->setMux(0x00000098); + LOG(INFO) << "TX pgas: " << m_uTx->pga(0) << ", " << m_uTx->pga(1); + writeLock.unlock(); + + if (!skipRx) { + writeLock.lock(); + m_uRx->writeFpgaReg(FR_ATR_MASK_0 + 1*3,0); + m_uRx->writeFpgaReg(FR_ATR_TXVAL_0 + 1*3,0); + m_uRx->writeFpgaReg(FR_ATR_RXVAL_0 + 1*3,0); + m_uRx->writeFpgaReg(41,0); + m_uRx->writeOE((POWER_UP|RX_TXN|ENABLE), 0xffff); + m_uRx->writeIO((POWER_UP|RX_TXN|ENABLE),(POWER_UP|RX_TXN|ENABLE)); + //m_uRx->writeIO(1,0,RX2_RX1N); // using Tx/Rx/ + m_uRx->writeIO(RX2_RX1N,RX2_RX1N); // using Rx2 + m_uRx->setAdcBufferBypass(0,true); + m_uRx->setAdcBufferBypass(1,true); + m_uRx->setPga(0,m_uRx->pgaMax()); // should be 20dB + m_uRx->setPga(1,m_uRx->pgaMax()); + m_uRx->setMux(0x00000010); + writeLock.unlock(); + // FIXME -- This should be configurable. + setRxGain(47); //maxRxGain()); + } + + data = new short[currDataSize]; + dataStart = 0; + dataEnd = 0; + timeStart = 0; + timeEnd = 0; + timestampOffset = 0; + latestWriteTimestamp = 0; + lastPktTimestamp = 0; + hi32Timestamp = 0; + isAligned = false; + + + if (!skipRx) + started = (m_uRx->start() && m_uTx->start()); + else + started = m_uTx->start(); + + return started; +#else + gettimeofday(&lastReadTime,NULL); + return true; +#endif +} + +bool RAD1Device::stop() +{ +#ifndef SWLOOPBACK + if (!m_uRx) return false; + if (!m_uTx) return false; + + // power down + m_uTx->writeIO((~POWER_UP|RX_TXN),(POWER_UP|RX_TXN|ENABLE)); + m_uRx->writeIO(~POWER_UP,(POWER_UP|ENABLE)); + + delete[] currData; + + started = false; + return !started; +#else + return true; +#endif +} + +double RAD1Device::setTxGain(double dB) { + + writeLock.lock(); + if (dB > maxTxGain()) dB = maxTxGain(); + if (dB < minTxGain()) dB = minTxGain(); + + m_uTx->setPga(0,dB); + m_uTx->setPga(1,dB); + + //LOG(NOTICE) << "Setting TX PGA to " << dB << " dB."; + + writeLock.unlock(); + + return dB; +} + + +double RAD1Device::setRxGain(double dB) { + + writeLock.lock(); + if (dB > maxRxGain()) dB = maxRxGain(); + if (dB < minRxGain()) dB = minRxGain(); + + double dBret = dB; + + dB = dB - minRxGain(); + + double rfMax = 70.0; + if (dB > rfMax) { + m_uRx->setPga(0,dB-rfMax); + m_uRx->setPga(1,dB-rfMax); + dB = rfMax; + } + else { + m_uRx->setPga(0,0); + m_uRx->setPga(1,0); + } + m_uRx->writeAuxDac(0, + (int) ceil((1.2 + 0.02 - (dB/rfMax))*4096.0/3.3)); + + LOG(DEBUG) << "Setting DAC voltage to " << (1.2+0.02 - (dB/rfMax)) << " " << (int) ceil((1.2 + 0.02 - (dB/rfMax))*4096.0/3.3); + + rxGain = dBret; + + writeLock.unlock(); + + return dBret; +} + + +// NOTE: Assumes sequential reads +int RAD1Device::readSamples(short *buf, int len, bool *overrun, + TIMESTAMP timestamp, + bool *underrun, + unsigned *RSSI) +{ +#ifndef SWLOOPBACK + if (!m_uRx) return 0; + + timestamp += timestampOffset; + + if (timestamp + len < timeStart) { + memset(buf,0,len*2*sizeof(short)); + return len; + } + + if (underrun) *underrun = false; + + uint32_t readBuf[20000]; + + while (1) { + //guestimate USB read size + int readLen=0; + { + int numSamplesNeeded = timestamp + len - timeEnd; + if (numSamplesNeeded <=0) break; + readLen = 512 * ((int) ceil((float) numSamplesNeeded/126.0)); + if (readLen > 8000) readLen= (8000/512)*512; + } + + // read USRP packets, parse and save A/D data as needed + readLen = m_uRx->read((void *)readBuf,readLen,overrun); + for(int pktNum = 0; pktNum < (readLen/512); pktNum++) { + // tmpBuf points to start of a USB packet + uint32_t* tmpBuf = (uint32_t *) (readBuf+pktNum*512/4); + TIMESTAMP pktTimestamp = usrp_to_host_u32(tmpBuf[1]); + uint32_t word0 = usrp_to_host_u32(tmpBuf[0]); + uint32_t chan = (word0 >> 16) & 0x1f; + unsigned payloadSz = word0 & 0x1ff; + LOG(DEBUG) << "first two bytes: " << hex << word0 << " " << dec << pktTimestamp; + + bool incrementHi32 = ((lastPktTimestamp & 0x0ffffffffll) > pktTimestamp); + if (incrementHi32 && (timeStart!=0)) { + LOG(DEBUG) << "high 32 increment!!!"; + hi32Timestamp++; + } + pktTimestamp = (((TIMESTAMP) hi32Timestamp) << 32) | pktTimestamp; + lastPktTimestamp = pktTimestamp; + + if (chan == 0x01f) { + // control reply, check to see if its ping reply + uint32_t word2 = usrp_to_host_u32(tmpBuf[2]); + if ((word2 >> 16) == ((0x01 << 8) | 0x02)) { + timestamp -= timestampOffset; + timestampOffset = pktTimestamp - pingTimestamp + PINGOFFSET; + LOG(DEBUG) << "updating timestamp offset to: " << timestampOffset; + timestamp += timestampOffset; + isAligned = true; + } + continue; + } + if (chan != 0) { + LOG(DEBUG) << "chan: " << chan << ", timestamp: " << pktTimestamp << ", sz:" << payloadSz; + continue; + } + if ((word0 >> 28) & 0x04) { + if (underrun) *underrun = true; + LOG(DEBUG) << "UNDERRUN in TRX->USRP interface"; + } + if (RSSI) *RSSI = (word0 >> 21) & 0x3f; + + if (!isAligned) continue; + + unsigned cursorStart = pktTimestamp - timeStart + dataStart; + while (cursorStart*2 > currDataSize) { + cursorStart -= currDataSize/2; + } + if (cursorStart*2 + payloadSz/2 > currDataSize) { + // need to circle around buffer + memcpy(data+cursorStart*2,tmpBuf+2,(currDataSize-cursorStart*2)*sizeof(short)); + memcpy(data,tmpBuf+2+(currDataSize/2-cursorStart),payloadSz-(currDataSize-cursorStart*2)*sizeof(short)); + } + else { + memcpy(data+cursorStart*2,tmpBuf+2,payloadSz); + } + if (pktTimestamp + payloadSz/2/sizeof(short) > timeEnd) + timeEnd = pktTimestamp+payloadSz/2/sizeof(short); + + //LOG(DEBUG) << "timeStart: " << timeStart << ", timeEnd: " << timeEnd << ", pktTimestamp: " << pktTimestamp; + + } + } + + // copy desired data to buf + unsigned bufStart = dataStart+(timestamp-timeStart); + if (bufStart + len < currDataSize/2) { + //LOG(DEBUG) << "bufStart: " << bufStart; + memcpy(buf,data+bufStart*2,len*2*sizeof(short)); + memset(data+bufStart*2,0,len*2*sizeof(short)); + } + else { + //LOG(DEBUG) << "len: " << len << ", currDataSize/2: " << currDataSize/2 << ", bufStart: " << bufStart; + unsigned firstLength = (currDataSize/2-bufStart); + //LOG(DEBUG) << "firstLength: " << firstLength; + memcpy(buf,data+bufStart*2,firstLength*2*sizeof(short)); + memset(data+bufStart*2,0,firstLength*2*sizeof(short)); + memcpy(buf+firstLength*2,data,(len-firstLength)*2*sizeof(short)); + memset(data,0,(len-firstLength)*2*sizeof(short)); + } + dataStart = (bufStart + len) % (currDataSize/2); + timeStart = timestamp + len; + + // do IQ swap here + for (int i = 0; i < len; i++) { + short tmp = usrp_to_host_short(buf[2*i]); + buf[2*i] = usrp_to_host_short(buf[2*i+1]); + buf[2*i+1] = tmp; + } + + return len; + +#else + if (loopbackBufferSize < 2) return 0; + int numSamples = 0; + struct timeval currTime; + gettimeofday(&currTime,NULL); + double timeElapsed = (currTime.tv_sec - lastReadTime.tv_sec)*1.0e6 + + (currTime.tv_usec - lastReadTime.tv_usec); + if (timeElapsed < samplePeriod) {return 0;} + int numSamplesToRead = (int) floor(timeElapsed/samplePeriod); + if (numSamplesToRead < len) return 0; + + if (numSamplesToRead > len) numSamplesToRead = len; + if (numSamplesToRead > loopbackBufferSize/2) { + firstRead =false; + numSamplesToRead = loopbackBufferSize/2; + } + memcpy(buf,loopbackBuffer,sizeof(short)*2*numSamplesToRead); + loopbackBufferSize -= 2*numSamplesToRead; + memcpy(loopbackBuffer,loopbackBuffer+2*numSamplesToRead, + sizeof(short)*loopbackBufferSize); + numSamples = numSamplesToRead; + if (firstRead) { + int new_usec = lastReadTime.tv_usec + (int) round((double) numSamplesToRead * samplePeriod); + lastReadTime.tv_sec = lastReadTime.tv_sec + new_usec/1000000; + lastReadTime.tv_usec = new_usec % 1000000; + } + else { + gettimeofday(&lastReadTime,NULL); + firstRead = true; + } + samplesRead += numSamples; + + return numSamples; +#endif +} + +int RAD1Device::writeSamples(short *buf, int len, bool *underrun, + unsigned long long timestamp, + bool isControl) +{ + writeLock.lock(); + +#ifndef SWLOOPBACK + if (!m_uTx) return 0; + + static uint32_t outData[128*200]; + + for (int i = 0; i < len*2; i++) { + buf[i] = host_to_usrp_short(buf[i]); + } + + int numWritten = 0; + unsigned isStart = 1; + unsigned RSSI = 0; + unsigned CHAN = (isControl) ? 0x01f : 0x00; + len = len*2*sizeof(short); + int numPkts = (int) ceil((float)len/(float)504); + unsigned isEnd = (numPkts < 2); + uint32_t *outPkt = outData; + int pktNum = 0; + while (numWritten < len) { + // pkt is pointer to start of a USB packet + uint32_t *pkt = outPkt + pktNum*128; + isEnd = (len - numWritten <= 504); + unsigned payloadLen = ((len - numWritten) < 504) ? (len-numWritten) : 504; + pkt[0] = (isStart << 12 | isEnd << 11 | (RSSI & 0x3f) << 5 | CHAN) << 16 | payloadLen; + pkt[1] = timestamp & 0x0ffffffffll; + memcpy(pkt+2,buf+(numWritten/sizeof(short)),payloadLen); + numWritten += payloadLen; + timestamp += payloadLen/2/sizeof(short); + isStart = 0; + pkt[0] = host_to_usrp_u32(pkt[0]); + pkt[1] = host_to_usrp_u32(pkt[1]); + pktNum++; + } + m_uTx->write((const void*) outPkt,sizeof(uint32_t)*128*numPkts,NULL); + + samplesWritten += len/2/sizeof(short); + writeLock.unlock(); + + return len/2/sizeof(short); +#else + int retVal = len; + memcpy(loopbackBuffer+loopbackBufferSize,buf,sizeof(short)*2*len); + samplesWritten += retVal; + loopbackBufferSize += retVal*2; + + return retVal; +#endif +} + +bool RAD1Device::updateAlignment(TIMESTAMP timestamp) +{ +#ifndef SWLOOPBACK + short data[] = {0x00,0x02,0x00,0x00}; + uint32_t *wordPtr = (uint32_t *) data; + bool tmpUnderrun; + if (writeSamples((short *) data,1,&tmpUnderrun,timestamp & 0x0ffffffffll,true)) { + pingTimestamp = timestamp; + return true; + } + return false; +#else + return true; +#endif +} + + +#ifndef SWLOOPBACK +bool RAD1Device::setTxFreq(double wFreq, double wAdjFreq) { + // Tune to wFreq+LO_OFFSET, to prevent LO bleedthrough from interfering with transmitted signal. + double actFreq; + unsigned int freq_cal; + freq_cal = (unsigned int) round(wAdjFreq); //128+round(wAdjFreq/wFreq*5.4e6); + m_uRx->writeAuxDac(2,freq_cal << 4); + if (!tx_setFreq(wFreq+1*LO_OFFSET,&actFreq)) return false; + bool retVal = m_uTx->setTxFreq(wFreq-actFreq); + LOG(DEBUG) << "set TX: " << wFreq-actFreq << " actual TX: " << m_uTx->txFreq(); + //printf("set TX: %f, set RX: %f\n", wFreq-actFreq, m_uTx->txFreq()); + //only for litie,set pow to maxim,switch on 1W amp + //m_uRx->writeAuxDac(1,0); + //m_uRx->writeIO(RX_TXN,RX_TXN); + + return retVal; +}; + +bool RAD1Device::setRxFreq(double wFreq, double wAdjFreq) { + // Tune to wFreq-2*LO_OFFSET, to + // 1) prevent LO bleedthrough (as with the setTxFreq method above) + // 2) The extra LO_OFFSET pushes potential transmitter energy (GSM BS->MS transmissions + // are 45Mhz above MS->BS transmissions) into a notch of the baseband lowpass filter + // in front of the ADC. This possibly gives us an extra 10-20dB Tx/Rx isolation. + double actFreq; + unsigned int freq_cal; + freq_cal = (unsigned int) round(wAdjFreq); //128+round(wAdjFreq/wFreq*5.4e6); + m_uRx->writeAuxDac(2,freq_cal << 4); + if (!rx_setFreq(wFreq-2*LO_OFFSET,&actFreq)) return false; + bool retVal = m_uRx->setRxFreq(wFreq-actFreq); + LOG(DEBUG) << "set RX: " << wFreq-actFreq << " actual RX: " << m_uRx->rxFreq(); + + return retVal; +}; + +#else +bool RAD1Device::setTxFreq(double wFreq) { return true;}; +bool RAD1Device::setRxFreq(double wFreq) { return true;}; +#endif + + diff --git a/TransceiverRAD1/RAD1Device.h b/TransceiverRAD1/RAD1Device.h new file mode 100644 index 0000000..378ecce --- /dev/null +++ b/TransceiverRAD1/RAD1Device.h @@ -0,0 +1,255 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + +#ifndef _RAD1_DEVICE_H_ +#define _RAD1_DEVICE_H_ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "radioDevice.h" +#include "rnrad1.h" +#include +#include +#include +#include + +#include "bytesex.h" + +/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */ +class RAD1Device: public RadioDevice { + +private: + + static const double masterClockRate; ///< the USRP clock rate + double desiredSampleRate; ///< the desired sampling rate + rnrad1Rx* m_uRx; ///< the USRP receiver + rnrad1Tx* m_uTx; ///< the USRP transmitter + + double actualSampleRate; ///< the actual USRP sampling rate + unsigned int decimRate; ///< the USRP decimation rate + + unsigned long long samplesRead; ///< number of samples read from USRP + unsigned long long samplesWritten; ///< number of samples sent to USRP + + bool started; ///< flag indicates USRP has started + bool skipRx; ///< set if USRP is transmit-only. + + static const unsigned int currDataSize_log2 = 21; + static const unsigned long currDataSize = (1 << currDataSize_log2); + short *data; + unsigned long dataStart; + unsigned long dataEnd; + TIMESTAMP timeStart; + TIMESTAMP timeEnd; + bool isAligned; + + Mutex writeLock; + + short *currData; ///< internal data buffer when reading from USRP + TIMESTAMP currTimestamp; ///< timestamp of internal data buffer + unsigned currLen; ///< size of internal data buffer + + TIMESTAMP timestampOffset; ///< timestamp offset b/w Tx and Rx blocks + TIMESTAMP latestWriteTimestamp; ///< timestamp of most recent ping command + TIMESTAMP pingTimestamp; ///< timestamp of most recent ping response + static const TIMESTAMP PINGOFFSET = 272; ///< undetermined delay b/w ping response timestamp and true receive timestamp + unsigned long hi32Timestamp; + unsigned long lastPktTimestamp; + + double rxGain; + +#ifdef SWLOOPBACK + short loopbackBuffer[1000000]; + int loopbackBufferSize; + double samplePeriod; + + struct timeval startTime; + struct timeval lastReadTime; + bool firstRead; +#endif + + /** Mess of constants used to control various hardware on the USRP */ + static const unsigned POWER_UP = (1 << 7); + static const unsigned RX_TXN = (1 << 6); + static const unsigned RX2_RX1N = (1 << 6); + static const unsigned ENABLE = (1 << 5); + static const unsigned PLL_LOCK_DETECT = (1 << 2); + + /*static const unsigned SPI_ENABLE_TX_A = 0x10; + static const unsigned SPI_ENABLE_RX_A = 0x20; + static const unsigned SPI_ENABLE_TX_B = 0x40; + static const unsigned SPI_ENABLE_RX_B = 0x80; + + static const unsigned SPI_FMT_MSB = (0 << 7); + static const unsigned SPI_FMT_HDR_0 = (0 << 5); + */ + + static const float LO_OFFSET; + //static const float LO_OFFSET = 4.0e6; + + static const unsigned R_DIV = 13; + static const unsigned P = 1; + unsigned CP2; // 0.62ma reduce loop BW for 1800 + unsigned CP1; + static const unsigned DIVSEL = 0; + unsigned DIV2; // changes with GSM band + unsigned freq_mult; // changes with GSM band + static const unsigned CPGAIN = 0; + + // R-Register Common Values + static const unsigned R_RSV = 0; // bits 23,22 + static const unsigned BSC = 3; // bits 21,20 Div by 8 to be safe + static const unsigned TEST = 0; // bit 19 + static const unsigned LDP = 1; // bit 18 + static const unsigned ABP = 0; // bit 17,16 3ns + + // N-Register Common Values + static const unsigned N_RSV = 0; // bit 7 + + // Control Register Common Values + static const unsigned PD = 0; // bits 21,20 Normal operation + static const unsigned PL = 2; // bits 13,12 7.5mA, -6dbm + static const unsigned MTLD = 1; // bit 11 enabled + static const unsigned CPG = 0; // bit 10 CP setting 1 + static const unsigned CP3S = 0; // bit 9 Normal + static const unsigned PDP = 1; // bit 8 Positive + static const unsigned MUXOUT = 1;// bits 7:5 Digital Lock Detect + static const unsigned CR = 0; // bit 4 Normal + static const unsigned PC = 2; // bits 3,2 Core power 15mA + + // ATR register value + //static const int FR_ATR_MASK_0 = 20; + //static const int FR_ATR_TXVAL_0 = 21; + //static const int FR_ATR_RXVAL_0 = 22; + + /** Compute register values to tune daughterboard to desired frequency */ + bool compute_regs(double freq, + unsigned *R, + unsigned *control, + unsigned *N, + double *actual_freq); + + /** Set the transmission frequency */ + bool tx_setFreq(double freq, double *actual_freq); + + /** Set the receiver frequency */ + bool rx_setFreq(double freq, double *actual_freq); + + public: + + /** Object constructor */ + RAD1Device (double _desiredSampleRate); + + /** Instantiate the USRP */ + bool make(bool skipRx = false); + + /** Start the USRP */ + bool start(); + + /** Stop the USRP */ + bool stop(); + + /** + Read samples from the USRP. + @param buf preallocated buf to contain read result + @param len number of samples desired + @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough + @param timestamp The timestamp of the first samples to be read + @param underrun Set if USRP does not have data to transmit, e.g. data not being sent fast enough + @param RSSI The received signal strength of the read result + @return The number of samples actually read + */ + int readSamples(short *buf, int len, bool *overrun, + TIMESTAMP timestamp = 0xffffffff, + bool *underrun = NULL, + unsigned *RSSI = NULL); + /** + Write samples to the USRP. + @param buf Contains the data to be written. + @param len number of samples to write. + @param underrun Set if USRP does not have data to transmit, e.g. data not being sent fast enough + @param timestamp The timestamp of the first sample of the data buffer. + @param isControl Set if data is a control packet, e.g. a ping command + @return The number of samples actually written + */ + int writeSamples(short *buf, int len, bool *underrun, + TIMESTAMP timestamp = 0xffffffff, + bool isControl = false); + + /** Update the alignment between the read and write timestamps */ + bool updateAlignment(TIMESTAMP timestamp); + + /** Set the transmitter frequency */ + bool setTxFreq(double wFreq, double wAdjFreq = 0); + + /** Set the receiver frequency */ + bool setRxFreq(double wFreq, double wAdjFreq = 0); + + /** Returns the starting write Timestamp*/ + TIMESTAMP initialWriteTimestamp(void) { return 40000;} + + /** Returns the starting read Timestamp*/ + TIMESTAMP initialReadTimestamp(void) { return 40000;} + + /** returns the full-scale transmit amplitude **/ + double fullScaleInputValue() {return 32000.0;} + + /** returns the full-scale receive amplitude **/ + double fullScaleOutputValue() {return 9450.0;} + + /** sets the receive chan gain, returns the gain setting **/ + double setRxGain(double dB); + + /** get the current receive gain */ + double getRxGain(void) {return rxGain;} + + /** return maximum Rx Gain **/ + double maxRxGain(void) {return 97.0;} + + /** return minimum Rx Gain **/ + double minRxGain(void) {return 7.0;} + + /** sets the transmit chan gain, returns the gain setting **/ + double setTxGain(double dB); + + /** return maximum Tx Gain **/ + double maxTxGain(void) {return 0.0;} + + /** return minimum Rx Gain **/ + double minTxGain(void) {return -20.0;} + + + /** Return internal status values */ + inline double getTxFreq() { return 0;} + inline double getRxFreq() { return 0;} + inline double getSampleRate() {return actualSampleRate;} + inline double numberRead() { return samplesRead; } + inline double numberWritten() { return samplesWritten;} + +}; + +#endif // _RAD1_DEVICE_H_ + diff --git a/TransceiverRAD1/RAD1RxRawPower.cpp b/TransceiverRAD1/RAD1RxRawPower.cpp new file mode 100644 index 0000000..e1dadf2 --- /dev/null +++ b/TransceiverRAD1/RAD1RxRawPower.cpp @@ -0,0 +1,89 @@ +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Newtworks, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + + +#include +#include +#include +#include +#include "RAD1Device.h" + +ConfigurationTable gConfig; + +using namespace std; + +int main(int argc, char *argv[]) { + + gLogInit("openbts","INFO",LOG_LOCAL7); + + int whichBoard = 0; + if (argc > 1) whichBoard = atoi(argv[1]); + //if (argc>2) gSetLogFile(argv[2]); + + RAD1Device *rad1 = new RAD1Device(52.0e6/192.0); + + rad1->make(); + + double freq = 0.0; + if (argc > 2) freq = (double) atoi(argv[2]); + + TIMESTAMP timestamp; + + if (!rad1->setRxFreq(freq*1.0e6,118)) printf("RX failed!"); + + rad1->start(); + + rad1->setRxGain(47); + + bool underrun; + + rad1->updateAlignment(20000); + rad1->updateAlignment(21000); + + timestamp = 30000; + double sum = 0.0; + unsigned long num = 0; + + double rcvCeil = rad1->fullScaleOutputValue()*rad1->fullScaleOutputValue(); + + while (1) { + short readBuf[512*2]; + printf("reading data...\n"); + int rd = rad1->readSamples(readBuf,512,&underrun,timestamp); + if (rd) { + LOG(INFO) << "rcvd. data@:" << timestamp; + float pwr = 0; + for (int i = 0; i < 512; i++) { + sum += (readBuf[2*i+1]*readBuf[2*i+1] + readBuf[2*i]*readBuf[2*i]); + pwr += (readBuf[2*i+1]*readBuf[2*i+1] + readBuf[2*i]*readBuf[2*i]); + num++; + if (num % 10000 == 0) printf("RSSI: %f\n",10*log10(rcvCeil/(sum/(double) num))); + } + timestamp += rd; + } + } + +} diff --git a/TransceiverRAD1/RAD1SN.cpp b/TransceiverRAD1/RAD1SN.cpp new file mode 100644 index 0000000..3eb166d --- /dev/null +++ b/TransceiverRAD1/RAD1SN.cpp @@ -0,0 +1,210 @@ +/* -*- c++ -*- */ +/* + * Copyright (C) 2003,2004,2009 Free Software Foundation, Inc. + * Copyright 2011 Range Networks, Inc. + * + * 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 3 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., 51 Franklin Street, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +ConfigurationTable gConfig; + +using namespace std; + +#include "rnrad1Core.h" + +char *prog_name; + +static void +set_progname (char *path) +{ + char *p = strrchr (path, '/'); + if (p != 0) + prog_name = p+1; + else + prog_name = path; +} + +static void +usage () +{ + fprintf (stderr, "usage: \n"); + fprintf (stderr, " %s [-v] [-w ] [-x] serialnumber\n", prog_name); + exit (1); +} + +#if 0 +static void +die (const char *msg) +{ + fprintf (stderr, "%s (die): %s\n", prog_name, msg); + exit (1); +} +#endif + +static int +hexval (char ch) +{ + if ('0' <= ch && ch <= '9') + return ch - '0'; + + if ('a' <= ch && ch <= 'f') + return ch - 'a' + 10; + + if ('A' <= ch && ch <= 'F') + return ch - 'A' + 10; + + return -1; +} + +static unsigned char * +hex_string_to_binary (const char *string, int *lenptr) +{ + int sl = strlen (string); + if (sl & 0x01){ + fprintf (stderr, "%s: odd number of chars in \n", prog_name); + return 0; + } + + int len = sl / 2; + *lenptr = len; + unsigned char *buf = new unsigned char [len]; + + for (int i = 0; i < len; i++){ + int hi = hexval (string[2 * i]); + int lo = hexval (string[2 * i + 1]); + if (hi < 0 || lo < 0){ + fprintf (stderr, "%s: invalid char in \n", prog_name); + delete [] buf; + return 0; + } + buf[i] = (hi << 4) | lo; + } + return buf; +} + +static void +print_hex (FILE *fp, unsigned char *buf, int len) +{ + for (int i = 0; i < len; i++){ + fprintf (fp, "%02x", buf[i]); + } + fprintf (fp, "\n"); +} + +static void +chk_result (bool ok) +{ + if (!ok){ + fprintf (stderr, "%s: failed\n", prog_name); + exit (1); + } +} + +static bool +get_on_off (const char *s) +{ + if (strcmp (s, "on") == 0) + return true; + + if (strcmp (s, "off") == 0) + return false; + + usage (); // no return + return false; +} + + +int +main (int argc, char **argv) +{ + int ch; + bool verbose = false; + int which_board = 0; + bool fx2_ok_p = false; + + set_progname (argv[0]); + + while ((ch = getopt (argc, argv, "vw:x")) != EOF){ + switch (ch){ + + case 'v': + verbose = true; + break; + + case 'w': + which_board = strtol (optarg, 0, 0); + break; + + case 'x': + fx2_ok_p = true; + break; + + default: + fprintf(stderr,"Bad option: %c\n",ch); + usage (); + } + } + + int nopts = argc - optind; + + fprintf(stderr,"nopts: %d",nopts); + + if (nopts < 1) + usage (); + + gLogInit("openbts",argv[1],LOG_LOCAL7); + + rnrad1Core *core = new rnrad1Core(which_board, + RAD1_CMD_INTERFACE, + RAD1_CMD_ALTINTERFACE, + "","",true); + + if (nopts != 1) usage (); + + else { + char *hex_string = argv[optind]; + int len; + unsigned char *buf = (unsigned char *) hex_string; + len = 8; + //hex_string_to_binary (hex_string, &len); + if (buf == 0) + chk_result (0); + + std::string bufStr; + bufStr.assign((const char*) buf,len); + + bool result = core->writeEeprom(0x50, 248, bufStr); + chk_result (result); + + return 0; + } + + delete core; +} diff --git a/TransceiverRAD1/RAD1ping.cpp b/TransceiverRAD1/RAD1ping.cpp new file mode 100644 index 0000000..a73ab00 --- /dev/null +++ b/TransceiverRAD1/RAD1ping.cpp @@ -0,0 +1,105 @@ +/* +* Copyright 2008, 2009, 2011 Free Software Foundation, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + + +#include +#include +#include +#include +#include "RAD1Device.h" + +ConfigurationTable gConfig; + +using namespace std; + +int main(int argc, char *argv[]) { + + // Configure logger. + if (argc>1) gLogInit(argv[1]); + else gLogInit("DEBUG"); + + gLogInit("openbts",argv[1],LOG_LOCAL7); + + + //if (argc>2) gSetLogFile(argv[2]); + + RAD1Device *usrp = new RAD1Device(52.0e6/192.0); + + usrp->make(); + + TIMESTAMP timestamp; + + if (!usrp->setTxFreq(925.2e6,113)) printf("TX failed!"); + if (!usrp->setRxFreq(925.2e6,113)) printf("RX failed!"); + + usrp->start(); + + usrp->setRxGain(57); + + LOG(INFO) << "Looping..."; + bool underrun; + + short data[]={0x00,0x02}; + + usrp->updateAlignment(20000); + usrp->updateAlignment(21000); + + int numpkts = 1; + short data2[512*2*numpkts]; + for (int i = 0; i < 512*numpkts; i++) { + data2[i<<1] = 30000;//4096*cos(2*3.14159*(i % 126)/126); + data2[(i<<1) + 1] = 30000;//4096*sin(2*3.14159*(i % 126)/126); + } + + for (int i = 0; i < 1; i++) + usrp->writeSamples((short*) data2,512*numpkts,&underrun,102000+i*1000); + + timestamp = 19000; + double sum = 0.0; + unsigned long num = 0; + while (1) { + short readBuf[512*2]; + printf("reading data...\n"); + int rd = usrp->readSamples(readBuf,512,&underrun,timestamp); + if (rd) { + LOG(INFO) << "rcvd. data@:" << timestamp; + float pwr = 0; + for (int i = 0; i < 512; i++) { + uint32_t *wordPtr = (uint32_t *) &readBuf[2*i]; + *wordPtr = usrp_to_host_u32(*wordPtr); + printf ("%llu: %d %d\n", timestamp+i,readBuf[2*i],readBuf[2*i+1]); + sum += (readBuf[2*i+1]*readBuf[2*i+1] + readBuf[2*i]*readBuf[2*i]); + pwr += (readBuf[2*i+1]*readBuf[2*i+1] + readBuf[2*i]*readBuf[2*i]); + num++; + //if (num % 10000 == 0) printf("avg pwr: %f\n",sum/num); + } + printf("For %llu to %llu, power is %f\n",timestamp,timestamp+511,pwr); + timestamp += rd; + //usrp->writeSamples((short*) data2,512*numpkts,&underrun,timestamp+1000); + } + } + +} diff --git a/TransceiverRAD1/README b/TransceiverRAD1/README new file mode 100644 index 0000000..491693c --- /dev/null +++ b/TransceiverRAD1/README @@ -0,0 +1,35 @@ +The Transceiver + +The transceiver consists of three modules: + --- transceiver + --- radioInterface + --- USRPDevice + +The USRPDevice module is basically a driver that reads/writes +packets to a USRP with two RFX900 daughterboards, board +A is the Tx chain and board B is the Rx chain. + +The radioInterface module is basically an interface b/w the +transceiver and the USRP. It operates the basestation clock +based upon the sample count of received USRP samples. Packets +from the USRP are queued and segmented into GSM bursts that are +passed up to the transceiver; bursts from the transceiver are +passed down to the USRP. + +The transceiver basically operates "layer 0" of the GSM stack, +performing the modulation, detection, and demodulation of GSM +bursts. It communicates with the GSM stack via three UDP sockets, +one socket for data, one for control messages, and one socket to +pass clocking information. The transceiver contains a priority +queue to sort to-be-transmitted bursts, and a filler table to fill +in timeslots that do not have bursts in the priority queue. The +transceiver tries to stay ahead of the basestation clock, adapting +its latency when underruns are reported by the radioInterface/USRP. +Received bursts (from the radioInterface) pass through a simple +energy detector, a RACH or midamble correlator, and a DFE-based demodulator. + +NOTE: There's a SWLOOPBACK #define statement, where the USRP is replaced +with a memory buffer. In this mode, data written to the USRP is actually stored +in a buffer, and read commands to the USRP simply pull data from this buffer. +This was very useful in early testing, and still may be useful in testing basic +Transceiver and radioInterface functionality. diff --git a/TransceiverRAD1/README.Talgorithm b/TransceiverRAD1/README.Talgorithm new file mode 100644 index 0000000..037d613 --- /dev/null +++ b/TransceiverRAD1/README.Talgorithm @@ -0,0 +1,15 @@ +Basic model: + +Have channel H = {h_0, h_1, ..., h_{K-1}}. +Have received sequence Y = {y_0, ..., y_{K+N}}. +Have transmitted sequence X = {x_0, ..., x_{N-1}}. +Denote state S_n = {x_n, x_{n-1}, ..., x_{n-L}}. + +Define a bag as an unordered collection with two operations, add and take. +We have three bags: + S: a bag of survivors. + F: a bag of available data structures. + +At time n, start with a non-empty bag S of survivors from time n-1. +Take a member out of S, and create all possible branches and their corresponding metrics. If metric ratio is above T, discard branch. Otherwise, check branch against entry in pruning table P. If branch metric is smaller than the existing entry's metric in P, then replace entry with branch. Otherwise, discard branch. +Once all possible branches of S have been created and pruned, S should be empty.Empty pruning table back into S, thus P is now empty. Repeat. diff --git a/TransceiverRAD1/Transceiver.cpp b/TransceiverRAD1/Transceiver.cpp new file mode 100644 index 0000000..c8f8d5e --- /dev/null +++ b/TransceiverRAD1/Transceiver.cpp @@ -0,0 +1,798 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . +*/ + + +/* + Compilation switches + TRANSMIT_LOGGING write every burst on the given slot to a log +*/ + + +#include +#include "Transceiver.h" +#include + + + +Transceiver::Transceiver(int wBasePort, + const char *TRXAddress, + int wSamplesPerSymbol, + GSM::Time wTransmitLatency, + RadioInterface *wRadioInterface) + :mDataSocket(wBasePort+2,TRXAddress,wBasePort+102), + mControlSocket(wBasePort+1,TRXAddress,wBasePort+101), + mClockSocket(wBasePort,TRXAddress,wBasePort+100) +{ + //GSM::Time startTime(0,0); + //GSM::Time startTime(gHyperframe/2 - 4*216*60,0); + GSM::Time startTime(random() % gHyperframe,0); + + mFIFOServiceLoopThread = new Thread(32768); ///< thread to push bursts into transmit FIFO + mControlServiceLoopThread = new Thread(32768); ///< thread to process control messages from GSM core + mTransmitPriorityQueueServiceLoopThread = new Thread(32768);///< thread to process transmit bursts from GSM core + + + mSamplesPerSymbol = wSamplesPerSymbol; + mRadioInterface = wRadioInterface; + mTransmitLatency = wTransmitLatency; + mTransmitDeadlineClock = startTime; + mLastClockUpdateTime = startTime; + mLatencyUpdateTime = startTime; + mRadioInterface->getClock()->set(startTime); + mMaxExpectedDelay = 0; + + // generate pulse and setup up signal processing library + gsmPulse = generateGSMPulse(2,mSamplesPerSymbol); + LOG(DEBUG) << "gsmPulse: " << *gsmPulse; + sigProcLibSetup(mSamplesPerSymbol); + + txFullScale = mRadioInterface->fullScaleInputValue(); + rxFullScale = mRadioInterface->fullScaleOutputValue(); + + // initialize filler tables with dummy bursts, initialize other per-timeslot variables + for (int i = 0; i < 8; i++) { + signalVector* modBurst = modulateBurst(gDummyBurst,*gsmPulse, + 8 + (i % 4 == 0), + mSamplesPerSymbol); + scaleVector(*modBurst,txFullScale); + fillerModulus[i]=26; + for (int j = 0; j < 102; j++) { + fillerTable[j][i] = new signalVector(*modBurst); + } + delete modBurst; + mChanType[i] = NONE; + channelResponse[i] = NULL; + DFEForward[i] = NULL; + DFEFeedback[i] = NULL; + channelEstimateTime[i] = startTime; + } + + mOn = false; + mTxFreq = 0.0; + mRxFreq = 0.0; + mPower = -10; + mEnergyThreshold = 5.0; // based on empirical data + prevFalseDetectionTime = startTime; +} + +Transceiver::~Transceiver() +{ + delete gsmPulse; + sigProcLibDestroy(); + mTransmitPriorityQueue.clear(); +} + + +void Transceiver::addRadioVector(BitVector &burst, + int RSSI, + GSM::Time &wTime) +{ + // modulate and stick into queue + signalVector* modBurst = modulateBurst(burst,*gsmPulse, + 8 + (wTime.TN() % 4 == 0), + mSamplesPerSymbol); + scaleVector(*modBurst,txFullScale * pow(10,-RSSI/10)); + radioVector *newVec = new radioVector(*modBurst,wTime); + mTransmitPriorityQueue.write(newVec); + + delete modBurst; +} + +#ifdef TRANSMIT_LOGGING +void Transceiver::unModulateVector(signalVector wVector) +{ + SoftVector *burst = demodulateBurst(wVector, + *gsmPulse, + mSamplesPerSymbol, + 1.0,0.0); + LOG(DEBUG) << "LOGGED BURST: " << *burst; + +/* + unsigned char burstStr[gSlotLen+1]; + SoftVector::iterator burstItr = burst->begin(); + for (int i = 0; i < gSlotLen; i++) { + // FIXME: Demod bits are inverted! + burstStr[i] = (unsigned char) ((*burstItr++)*255.0); + } + burstStr[gSlotLen]='\0'; + LOG(DEBUG) << "LOGGED BURST: " << burstStr; +*/ + delete burst; +} +#endif + +void Transceiver::pushRadioVector(GSM::Time &nowTime) +{ + + // dump stale bursts, if any + while (radioVector* staleBurst = mTransmitPriorityQueue.getStaleBurst(nowTime)) { + // Even if the burst is stale, put it in the fillter table. + // (It might be an idle pattern.) + LOG(NOTICE) << "dumping STALE burst in TRX->USRP interface"; + const GSM::Time& nextTime = staleBurst->time(); + int TN = nextTime.TN(); + int modFN = nextTime.FN() % fillerModulus[TN]; + delete fillerTable[modFN][TN]; + fillerTable[modFN][TN] = staleBurst; + } + + int TN = nowTime.TN(); + int modFN = nowTime.FN() % fillerModulus[nowTime.TN()]; + + // if queue contains data at the desired timestamp, stick it into FIFO + if (radioVector *next = (radioVector*) mTransmitPriorityQueue.getCurrentBurst(nowTime)) { + LOG(DEBUG) << "transmitFIFO: wrote burst " << next << " at time: " << nowTime; + delete fillerTable[modFN][TN]; + fillerTable[modFN][TN] = new signalVector(*(next)); + mRadioInterface->driveTransmitRadio(*(next),(mChanType[TN]==NONE)); //fillerTable[modFN][TN])); + delete next; +#ifdef TRANSMIT_LOGGING + if (nowTime.TN()==TRANSMIT_LOGGING) { + unModulateVector(*(fillerTable[modFN][TN])); + } +#endif + return; + } + + // otherwise, pull filler data, and push to radio FIFO + mRadioInterface->driveTransmitRadio(*(fillerTable[modFN][TN]),(mChanType[TN]==NONE)); +#ifdef TRANSMIT_LOGGING + if (nowTime.TN()==TRANSMIT_LOGGING) + unModulateVector(*fillerTable[modFN][TN]); +#endif + +} + +void Transceiver::setModulus(int timeslot) +{ + switch (mChanType[timeslot]) { + case NONE: + case I: + case II: + case III: + case FILL: + fillerModulus[timeslot] = 26; + break; + case IV: + case VI: + case V: + fillerModulus[timeslot] = 51; + break; + //case V: + case VII: + fillerModulus[timeslot] = 102; + break; + default: + break; + } +} + + +Transceiver::CorrType Transceiver::expectedCorrType(GSM::Time currTime) +{ + + unsigned burstTN = currTime.TN(); + unsigned burstFN = currTime.FN(); + + switch (mChanType[burstTN]) { + case NONE: + return OFF; + break; + case FILL: + return IDLE; + break; + case I: + return TSC; + /*if (burstFN % 26 == 25) + return IDLE; + else + return TSC;*/ + break; + case II: + if (burstFN % 2 == 1) + return IDLE; + else + return TSC; + break; + case III: + return TSC; + break; + case IV: + case VI: + return RACH; + break; + case V: { + int mod51 = burstFN % 51; + if ((mod51 <= 36) && (mod51 >= 14)) + return RACH; + else if ((mod51 == 4) || (mod51 == 5)) + return RACH; + else if ((mod51 == 45) || (mod51 == 46)) + return RACH; + else + return TSC; + break; + } + case VII: + if ((burstFN % 51 <= 14) && (burstFN % 51 >= 12)) + return IDLE; + else + return TSC; + break; + case LOOPBACK: + if ((burstFN % 51 <= 50) && (burstFN % 51 >=48)) + return IDLE; + else + return TSC; + break; + default: + return OFF; + break; + } + +} + +SoftVector *Transceiver::pullRadioVector(GSM::Time &wTime, + int &RSSI, + int &timingOffset) +{ + bool needDFE = (mMaxExpectedDelay > 1); + + radioVector *rxBurst = (radioVector *) mReceiveFIFO->get(); + + if (!rxBurst) return NULL; + + LOG(DEBUG) << "receiveFIFO: read radio vector at time: " << rxBurst->time() << ", new size: " << mReceiveFIFO->size(); + + int timeslot = rxBurst->time().TN(); + + CorrType corrType = expectedCorrType(rxBurst->time()); + + if ((corrType==OFF) || (corrType==IDLE)) { + delete rxBurst; + return NULL; + } + + // check to see if received burst has sufficient + signalVector *vectorBurst = rxBurst; + complex amplitude = 0.0; + float TOA = 0.0; + float avgPwr = 0.0; + if (!energyDetect(*vectorBurst,20*mSamplesPerSymbol,mEnergyThreshold,&avgPwr)) { + LOG(DEBUG) << "Estimated Energy: " << sqrt(avgPwr) << ", at time " << rxBurst->time(); + double framesElapsed = rxBurst->time()-prevFalseDetectionTime; + if (framesElapsed > 50) { // if we haven't had any false detections for a while, lower threshold + mEnergyThreshold -= 10.0/10.0; + prevFalseDetectionTime = rxBurst->time(); + } + delete rxBurst; + return NULL; + } + LOG(DEBUG) << "Estimated Energy: " << sqrt(avgPwr) << ", at time " << rxBurst->time(); + + // run the proper correlator + bool success = false; + if (corrType==TSC) { + LOG(DEBUG) << "looking for TSC at time: " << rxBurst->time(); + signalVector *channelResp; + double framesElapsed = rxBurst->time()-channelEstimateTime[timeslot]; + bool estimateChannel = false; + if ((framesElapsed > 50) || (channelResponse[timeslot]==NULL)) { + if (channelResponse[timeslot]) delete channelResponse[timeslot]; + if (DFEForward[timeslot]) delete DFEForward[timeslot]; + if (DFEFeedback[timeslot]) delete DFEFeedback[timeslot]; + channelResponse[timeslot] = NULL; + DFEForward[timeslot] = NULL; + DFEFeedback[timeslot] = NULL; + estimateChannel = true; + } + if (!needDFE) estimateChannel = false; + float chanOffset; + success = analyzeTrafficBurst(*vectorBurst, + mTSC, + 3.0, + mSamplesPerSymbol, + &litude, + &TOA, + mMaxExpectedDelay, + estimateChannel, + &channelResp, + &chanOffset); + if (success) { + LOG(DEBUG) << "FOUND TSC!!!!!! " << amplitude << " " << TOA; + mEnergyThreshold -= 1.0F/10.0F; + if (mEnergyThreshold < 0.0) mEnergyThreshold = 0.0; + SNRestimate[timeslot] = amplitude.norm2()/(mEnergyThreshold*mEnergyThreshold+1.0); // this is not highly accurate + if (estimateChannel) { + LOG(DEBUG) << "estimating channel..."; + channelResponse[timeslot] = channelResp; + chanRespOffset[timeslot] = chanOffset; + chanRespAmplitude[timeslot] = amplitude; + scaleVector(*channelResp, complex(1.0,0.0)/amplitude); + designDFE(*channelResp, SNRestimate[timeslot], 7, &DFEForward[timeslot], &DFEFeedback[timeslot]); + channelEstimateTime[timeslot] = rxBurst->time(); + LOG(DEBUG) << "SNR: " << SNRestimate[timeslot] << ", DFE forward: " << *DFEForward[timeslot] << ", DFE backward: " << *DFEFeedback[timeslot]; + } + } + else { + double framesElapsed = rxBurst->time()-prevFalseDetectionTime; + LOG(DEBUG) << "wTime: " << rxBurst->time() << ", pTime: " << prevFalseDetectionTime << ", fElapsed: " << framesElapsed; + mEnergyThreshold += 10.0F/10.0F*exp(-framesElapsed); + prevFalseDetectionTime = rxBurst->time(); + channelResponse[timeslot] = NULL; + } + } + else { + // RACH burst + success = detectRACHBurst(*vectorBurst, + 5.0, // detection threshold + mSamplesPerSymbol, + &litude, + &TOA); + if (success) { + LOG(DEBUG) << "FOUND RACH!!!!!! " << amplitude << " " << TOA; + mEnergyThreshold -= (1.0F/10.0F); + if (mEnergyThreshold < 0.0) mEnergyThreshold = 0.0; + channelResponse[timeslot] = NULL; + } + else { + double framesElapsed = rxBurst->time()-prevFalseDetectionTime; + mEnergyThreshold += (1.0F/10.0F)*exp(-framesElapsed); + prevFalseDetectionTime = rxBurst->time(); + } + } + LOG(DEBUG) << "energy Threshold = " << mEnergyThreshold; + + // demodulate burst + SoftVector *burst = NULL; + if ((rxBurst) && (success)) { + if ((corrType==RACH) || (!needDFE)) { + burst = demodulateBurst(*vectorBurst, + *gsmPulse, + mSamplesPerSymbol, + amplitude,TOA); + } + else { // TSC + scaleVector(*vectorBurst,complex(1.0,0.0)/amplitude); + burst = equalizeBurst(*vectorBurst, + TOA-chanRespOffset[timeslot], + mSamplesPerSymbol, + *DFEForward[timeslot], + *DFEFeedback[timeslot]); + } + wTime = rxBurst->time(); + // FIXME: what is full scale for the USRP? we get more that 12 bits of resolution... + RSSI = (int) floor(20.0*log10(rxFullScale/amplitude.abs())); + LOG(DEBUG) << "RSSI: " << RSSI; + timingOffset = (int) round(TOA*256.0/mSamplesPerSymbol); + } + + //if (burst) LOG(DEBUG) << "burst: " << *burst << '\n'; + + delete rxBurst; + + return burst; +} + +void Transceiver::start() +{ + mControlServiceLoopThread->start((void * (*)(void*))ControlServiceLoopAdapter,(void*) this); +} + +void Transceiver::reset() +{ + mTransmitPriorityQueue.clear(); + //mTransmitFIFO->clear(); + //mReceiveFIFO->clear(); +} + + +void Transceiver::driveControl() +{ + + int MAX_PACKET_LENGTH = 100; + + // check control socket + char buffer[MAX_PACKET_LENGTH]; + int msgLen = -1; + buffer[0] = '\0'; + + msgLen = mControlSocket.read(buffer); + + if (msgLen < 1) { + return; + } + + char cmdcheck[4]; + char command[MAX_PACKET_LENGTH]; + char response[MAX_PACKET_LENGTH]; + + sscanf(buffer,"%3s %s",cmdcheck,command); + + writeClockInterface(); + + if (strcmp(cmdcheck,"CMD")!=0) { + LOG(WARNING) << "bogus message on control interface"; + return; + } + LOG(INFO) << "command is " << buffer; + + if (strcmp(command,"POWEROFF")==0) { + // turn off transmitter/demod + sprintf(response,"RSP POWEROFF 0"); + } + else if (strcmp(command,"POWERON")==0) { + // turn on transmitter/demod + if (!mTxFreq || !mRxFreq) + sprintf(response,"RSP POWERON 1"); + else { + sprintf(response,"RSP POWERON 0"); + if (!mOn) { + // Prepare for thread start + mPower = -20; + mRadioInterface->start(); + generateRACHSequence(*gsmPulse,mSamplesPerSymbol); + + // Start radio interface threads. + mFIFOServiceLoopThread->start((void * (*)(void*))FIFOServiceLoopAdapter,(void*) this); + mTransmitPriorityQueueServiceLoopThread->start((void * (*)(void*))TransmitPriorityQueueServiceLoopAdapter,(void*) this); + writeClockInterface(); + + mOn = true; + } + } + } + else if (strcmp(command,"SETMAXDLY")==0) { + //set expected maximum time-of-arrival + int maxDelay; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&maxDelay); + mMaxExpectedDelay = maxDelay; // 1 GSM symbol is approx. 1 km + sprintf(response,"RSP SETMAXDLY 0 %d",maxDelay); + } + else if (strcmp(command,"SETRXGAIN")==0) { + //set expected maximum time-of-arrival + int newGain; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&newGain); + newGain = mRadioInterface->setRxGain(newGain); + sprintf(response,"RSP SETRXGAIN 0 %d",newGain); + } + else if (strcmp(command,"NOISELEV")==0) { + if (mOn) { + sprintf(response,"RSP NOISELEV 0 %d", + (int) round(20.0*log10(rxFullScale/mEnergyThreshold))); + } + else { + sprintf(response,"RSP NOISELEV 1 0"); + } + } + else if (strcmp(command,"SETPOWER")==0) { + // set output power in dB + int dbPwr; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&dbPwr); + if (!mOn) + sprintf(response,"RSP SETPOWER 1 %d",dbPwr); + else { + mPower = dbPwr; + mRadioInterface->setPowerAttenuation(pow(10.0,dbPwr/10.0)); + sprintf(response,"RSP SETPOWER 0 %d",dbPwr); + } + } + else if (strcmp(command,"ADJPOWER")==0) { + // adjust power in dB steps + int dbStep; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&dbStep); + if (!mOn) + sprintf(response,"RSP ADJPOWER 1 %d",mPower); + else { + mPower += dbStep; + sprintf(response,"RSP ADJPOWER 0 %d",mPower); + } + } +#define FREQOFFSET 0//11.2e3 + else if (strcmp(command,"RXTUNE")==0) { + // tune receiver + int freqKhz; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&freqKhz); + mRxFreq = freqKhz*1.0e3+FREQOFFSET; + if (!mRadioInterface->tuneRx(mRxFreq,128)) { + LOG(ALERT) << "RX failed to tune"; + sprintf(response,"RSP RXTUNE 1 %d",freqKhz); + } + else + sprintf(response,"RSP RXTUNE 0 %d",freqKhz); + } + else if (strcmp(command,"TXTUNE")==0) { + // tune txmtr + int freqKhz; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&freqKhz); + //freqKhz = 890e3; + mTxFreq = freqKhz*1.0e3+FREQOFFSET; + if (!mRadioInterface->tuneTx(mTxFreq,128)) { + LOG(ALERT) << "TX failed to tune"; + sprintf(response,"RSP TXTUNE 1 %d",freqKhz); + } + else + sprintf(response,"RSP TXTUNE 0 %d",freqKhz); + } + else if (strcmp(command,"SETTSC")==0) { + // set TSC + int TSC; + sscanf(buffer,"%3s %s %d",cmdcheck,command,&TSC); + if (mOn) + sprintf(response,"RSP SETTSC 1 %d",TSC); + else { + mTSC = TSC; + generateMidamble(*gsmPulse,mSamplesPerSymbol,TSC); + sprintf(response,"RSP SETTSC 0 %d",TSC); + } + } + else if (strcmp(command,"SETSLOT")==0) { + // set TSC + int corrCode; + int timeslot; + sscanf(buffer,"%3s %s %d %d",cmdcheck,command,×lot,&corrCode); + if ((timeslot < 0) || (timeslot > 7)) { + LOG(WARNING) << "bogus message on control interface"; + sprintf(response,"RSP SETSLOT 1 %d %d",timeslot,corrCode); + return; + } + mChanType[timeslot] = (ChannelCombination) corrCode; + setModulus(timeslot); + sprintf(response,"RSP SETSLOT 0 %d %d",timeslot,corrCode); + + } + else { + LOG(WARNING) << "bogus command " << command << " on control interface."; + } + + mControlSocket.write(response,strlen(response)+1); + +} + +bool Transceiver::driveTransmitPriorityQueue() +{ + + char buffer[gSlotLen+50]; + + // check data socket + size_t msgLen = mDataSocket.read(buffer); + + if (msgLen!=gSlotLen+1+4+1) { + LOG(ERR) << "badly formatted packet on GSM->TRX interface"; + return false; + } + + int timeSlot = (int) buffer[0]; + uint64_t frameNum = 0; + for (int i = 0; i < 4; i++) + frameNum = (frameNum << 8) | (0x0ff & buffer[i+1]); + + /* + if (GSM::Time(frameNum,timeSlot) > mTransmitDeadlineClock + GSM::Time(51,0)) { + // stale burst + //LOG(DEBUG) << "FAST! "<< GSM::Time(frameNum,timeSlot); + //writeClockInterface(); + }*/ + +/* + DAB -- Just let these go through the demod. + if (GSM::Time(frameNum,timeSlot) < mTransmitDeadlineClock) { + // stale burst from GSM core + LOG(NOTICE) << "STALE packet on GSM->TRX interface at time "<< GSM::Time(frameNum,timeSlot); + return false; + } +*/ + + // periodically update GSM core clock + LOG(DEBUG) << "mTransmitDeadlineClock " << mTransmitDeadlineClock + << " mLastClockUpdateTime " << mLastClockUpdateTime; + if (mTransmitDeadlineClock > mLastClockUpdateTime + GSM::Time(216,0)) + writeClockInterface(); + + + LOG(DEBUG) << "rcvd. burst at: " << GSM::Time(frameNum,timeSlot); + + int RSSI = (int) buffer[5]; + static BitVector newBurst(gSlotLen); + BitVector::iterator itr = newBurst.begin(); + char *bufferItr = buffer+6; + while (itr < newBurst.end()) + *itr++ = *bufferItr++; + + GSM::Time currTime = GSM::Time(frameNum,timeSlot); + + addRadioVector(newBurst,RSSI,currTime); + + LOG(DEBUG) "added burst - time: " << currTime << ", RSSI: " << RSSI; // << ", data: " << newBurst; + + return true; + + +} + +void Transceiver::driveReceiveFIFO() +{ + + SoftVector *rxBurst = NULL; + int RSSI; + int TOA; // in 1/256 of a symbol + GSM::Time burstTime; + + mRadioInterface->driveReceiveRadio(); + + rxBurst = pullRadioVector(burstTime,RSSI,TOA); + + if (rxBurst) { + + LOG(DEBUG) << "burst parameters: " + << " time: " << burstTime + << " RSSI: " << RSSI + << " TOA: " << TOA + << " bits: " << *rxBurst; + + char burstString[gSlotLen+10]; + burstString[0] = burstTime.TN(); + for (int i = 0; i < 4; i++) + burstString[1+i] = (burstTime.FN() >> ((3-i)*8)) & 0x0ff; + burstString[5] = RSSI; + burstString[6] = (TOA >> 8) & 0x0ff; + burstString[7] = TOA & 0x0ff; + SoftVector::iterator burstItr = rxBurst->begin(); + + for (unsigned int i = 0; i < gSlotLen; i++) { + burstString[8+i] =(char) round((*burstItr++)*255.0); + } + burstString[gSlotLen+9] = '\0'; + delete rxBurst; + + mDataSocket.write(burstString,gSlotLen+10); + } + +} + +void Transceiver::driveTransmitFIFO() +{ + + /** + Features a carefully controlled latency mechanism, to + assure that transmit packets arrive at the radio/USRP + before they need to be transmitted. + + Deadline clock indicates the burst that needs to be + pushed into the FIFO right NOW. If transmit queue does + not have a burst, stick in filler data. + */ + + + RadioClock *radioClock = (mRadioInterface->getClock()); + + if (mOn) { + //radioClock->wait(); // wait until clock updates + LOG(DEBUG) << "radio clock " << radioClock->get(); + while (radioClock->get() + mTransmitLatency > mTransmitDeadlineClock) { + // if underrun, then we're not providing bursts to radio/USRP fast + // enough. Need to increase latency by one GSM frame. + if (mRadioInterface->isUnderrun()) { + // only do latency update every 10 frames, so we don't over update + if (radioClock->get() > mLatencyUpdateTime + GSM::Time(10,0)) { + mTransmitLatency = mTransmitLatency + GSM::Time(1,0); + LOG(INFO) << "new latency: " << mTransmitLatency; + mLatencyUpdateTime = radioClock->get(); + } + } + else { + // if underrun hasn't occurred in the last sec (216 frames) drop + // transmit latency by a timeslot + if (mTransmitLatency > GSM::Time(1,1)) { + if (radioClock->get() > mLatencyUpdateTime + GSM::Time(216,0)) { + mTransmitLatency.decTN(); + LOG(INFO) << "reduced latency: " << mTransmitLatency; + mLatencyUpdateTime = radioClock->get(); + } + } + } + // time to push burst to transmit FIFO + pushRadioVector(mTransmitDeadlineClock); + mTransmitDeadlineClock.incTN(); + } + + } + // FIXME -- This should not be a hard spin. + // But any delay here causes us to throw omni_thread_fatal. + //else radioClock->wait(); +} + + + +void Transceiver::writeClockInterface() +{ + char command[50]; + // FIXME -- This should be adaptive. + sprintf(command,"IND CLOCK %llu",(unsigned long long) (mTransmitDeadlineClock.FN()+2)); + + LOG(INFO) << "ClockInterface: sending " << command; + + mClockSocket.write(command,strlen(command)+1); + + mLastClockUpdateTime = mTransmitDeadlineClock; + +} + + + + +void *FIFOServiceLoopAdapter(Transceiver *transceiver) +{ + while (1) { + transceiver->driveReceiveFIFO(); + transceiver->driveTransmitFIFO(); + pthread_testcancel(); + } + return NULL; +} + +void *ControlServiceLoopAdapter(Transceiver *transceiver) +{ + while (1) { + transceiver->driveControl(); + pthread_testcancel(); + } + return NULL; +} + +void *TransmitPriorityQueueServiceLoopAdapter(Transceiver *transceiver) +{ + while (1) { + bool stale = false; + // Flush the UDP packets until a successful transfer. + while (!transceiver->driveTransmitPriorityQueue()) { + stale = true; + } + if (stale) { + // If a packet was stale, remind the GSM stack of the clock. + transceiver->writeClockInterface(); + } + pthread_testcancel(); + } + return NULL; +} diff --git a/TransceiverRAD1/Transceiver.h b/TransceiverRAD1/Transceiver.h new file mode 100644 index 0000000..e724c03 --- /dev/null +++ b/TransceiverRAD1/Transceiver.h @@ -0,0 +1,207 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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 3 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, see . + +*/ + + + +/* + Compilation switches + TRANSMIT_LOGGING write every burst on the given slot to a log +*/ + +#include "radioInterface.h" +#include "Interthread.h" +#include "GSMCommon.h" +#include "Sockets.h" + +#include +#include + +/** Define this to be the slot number to be logged. */ +//#define TRANSMIT_LOGGING 1 + +/** The Transceiver class, responsible for physical layer of basestation */ +class Transceiver { + +private: + + GSM::Time mTransmitLatency; ///< latency between basestation clock and transmit deadline clock + GSM::Time mLatencyUpdateTime; ///< last time latency was updated + + UDPSocket mDataSocket; ///< socket for writing to/reading from GSM core + UDPSocket mControlSocket; ///< socket for writing/reading control commands from GSM core + UDPSocket mClockSocket; ///< socket for writing clock updates to GSM core + + VectorQueue mTransmitPriorityQueue; ///< priority queue of transmit bursts received from GSM core + VectorFIFO* mTransmitFIFO; ///< radioInterface FIFO of transmit bursts + VectorFIFO* mReceiveFIFO; ///< radioInterface FIFO of receive bursts + + Thread *mFIFOServiceLoopThread; ///< thread to push/pull bursts into transmit/receive FIFO + Thread *mControlServiceLoopThread; ///< thread to process control messages from GSM core + Thread *mTransmitPriorityQueueServiceLoopThread;///< thread to process transmit bursts from GSM core + + GSM::Time mTransmitDeadlineClock; ///< deadline for pushing bursts into transmit FIFO + GSM::Time mLastClockUpdateTime; ///< last time clock update was sent up to core + + RadioInterface *mRadioInterface; ///< associated radioInterface object + double txFullScale; ///< full scale input to radio + double rxFullScale; ///< full scale output to radio + + /** Codes for burst types of received bursts*/ + typedef enum { + OFF, ///< timeslot is off + TSC, ///< timeslot should contain a normal burst + RACH, ///< timeslot should contain an access burst + IDLE ///< timeslot is an idle (or dummy) burst + } CorrType; + + + /** Codes for channel combinations */ + typedef enum { + FILL, ///< Channel is transmitted, but unused + I, ///< TCH/FS + II, ///< TCH/HS, idle every other slot + III, ///< TCH/HS + IV, ///< FCCH+SCH+CCCH+BCCH, uplink RACH + V, ///< FCCH+SCH+CCCH+BCCH+SDCCH/4+SACCH/4, uplink RACH+SDCCH/4 + VI, ///< CCCH+BCCH, uplink RACH + VII, ///< SDCCH/8 + SACCH/8 + NONE, ///< Channel is inactive, default + LOOPBACK ///< similar go VII, used in loopback testing + } ChannelCombination; + + + /** unmodulate a modulated burst */ +#ifdef TRANSMIT_LOGGING + void unModulateVector(signalVector wVector); +#endif + + /** modulate and add a burst to the transmit queue */ + void addRadioVector(BitVector &burst, + int RSSI, + GSM::Time &wTime); + + /** Push modulated burst into transmit FIFO corresponding to a particular timestamp */ + void pushRadioVector(GSM::Time &nowTime); + + /** Pull and demodulate a burst from the receive FIFO */ + SoftVector *pullRadioVector(GSM::Time &wTime, + int &RSSI, + int &timingOffset); + + /** Set modulus for specific timeslot */ + void setModulus(int timeslot); + + /** return the expected burst type for the specified timestamp */ + CorrType expectedCorrType(GSM::Time currTime); + + /** send messages over the clock socket */ + void writeClockInterface(void); + + signalVector *gsmPulse; ///< the GSM shaping pulse for modulation + + int mSamplesPerSymbol; ///< number of samples per GSM symbol + + bool mOn; ///< flag to indicate that transceiver is powered on + ChannelCombination mChanType[8]; ///< channel types for all timeslots + double mTxFreq; ///< the transmit frequency + double mRxFreq; ///< the receive frequency + int mPower; ///< the transmit power in dB + unsigned mTSC; ///< the midamble sequence code + double mEnergyThreshold; ///< threshold to determine if received data is potentially a GSM burst + GSM::Time prevFalseDetectionTime; ///< last timestamp of a false energy detection + int fillerModulus[8]; ///< modulus values of all timeslots, in frames + signalVector *fillerTable[102][8]; ///< table of modulated filler waveforms for all timeslots + unsigned mMaxExpectedDelay; ///< maximum expected time-of-arrival offset in GSM symbols + + GSM::Time channelEstimateTime[8]; ///< last timestamp of each timeslot's channel estimate + signalVector *channelResponse[8]; ///< most recent channel estimate of all timeslots + float SNRestimate[8]; ///< most recent SNR estimate of all timeslots + signalVector *DFEForward[8]; ///< most recent DFE feedforward filter of all timeslots + signalVector *DFEFeedback[8]; ///< most recent DFE feedback filter of all timeslots + float chanRespOffset[8]; ///< most recent timing offset, e.g. TOA, of all timeslots + complex chanRespAmplitude[8]; ///< most recent channel amplitude of all timeslots + +public: + + /** Transceiver constructor + @param wBasePort base port number of UDP sockets + @param TRXAddress IP address of the TRX manager, as a string + @param wSamplesPerSymbol number of samples per GSM symbol + @param wTransmitLatency initial setting of transmit latency + @param radioInterface associated radioInterface object + */ + Transceiver(int wBasePort, + const char *TRXAddress, + int wSamplesPerSymbol, + GSM::Time wTransmitLatency, + RadioInterface *wRadioInterface); + + /** Destructor */ + ~Transceiver(); + + /** start the Transceiver */ + void start(); + + /** attach the radioInterface receive FIFO */ + void receiveFIFO(VectorFIFO *wFIFO) { mReceiveFIFO = wFIFO;} + + /** attach the radioInterface transmit FIFO */ + void transmitFIFO(VectorFIFO *wFIFO) { mTransmitFIFO = wFIFO;} + + +protected: + + /** drive reception and demodulation of GSM bursts */ + void driveReceiveFIFO(); + + /** drive transmission of GSM bursts */ + void driveTransmitFIFO(); + + /** drive handling of control messages from GSM core */ + void driveControl(); + + /** + drive modulation and sorting of GSM bursts from GSM core + @return true if a burst was transferred successfully + */ + bool driveTransmitPriorityQueue(); + + friend void *FIFOServiceLoopAdapter(Transceiver *); + + friend void *ControlServiceLoopAdapter(Transceiver *); + + friend void *TransmitPriorityQueueServiceLoopAdapter(Transceiver *); + + void reset(); +}; + +/** FIFO thread loop */ +void *FIFOServiceLoopAdapter(Transceiver *); + +/** control message handler thread loop */ +void *ControlServiceLoopAdapter(Transceiver *); + +/** transmit queueing thread loop */ +void *TransmitPriorityQueueServiceLoopAdapter(Transceiver *); + diff --git a/TransceiverRAD1/ad9862.h b/TransceiverRAD1/ad9862.h new file mode 100644 index 0000000..30f03dd --- /dev/null +++ b/TransceiverRAD1/ad9862.h @@ -0,0 +1,199 @@ +#ifndef INCLUDED_AD9862_H +#define INCLUDED_AD9862_H + +/* + * Analog Devices AD9862 registers and some fields + */ + +#define BEGIN_AD9862 namespace ad9862 { +#define END_AD962 } +#define DEF static const int + +BEGIN_AD9862; + +DEF REG_GENERAL = 0; +DEF REG_RX_PWR_DN = 1; +DEF RX_PWR_DN_VREF_DIFF = (1 << 7); +DEF RX_PWR_DN_VREF = (1 << 6); +DEF RX_PWR_DN_RX_DIGIGAL = (1 << 5); +DEF RX_PWR_DN_RX_B = (1 << 4); +DEF RX_PWR_DN_RX_A = (1 << 3); +DEF RX_PWR_DN_BUF_B = (1 << 2); +DEF RX_PWR_DN_BUF_A = (1 << 1); +DEF RX_PWR_DN_ALL = (1 << 0); + +DEF REG_RX_A = 2; // bypass input buffer / RxPGA +DEF REG_RX_B = 3; // pypass input buffer / RxPGA +DEF RX_X_BYPASS_INPUT_BUFFER = (1 << 7); + +DEF REG_RX_MISC = 4; +DEF RX_MISC_HS_DUTY_CYCLE = (1 << 2); +DEF RX_MISC_SHARED_REF = (1 << 1); +DEF RX_MISC_CLK_DUTY = (1 << 0); + +DEF REG_RX_IF = 5; +DEF RX_IF_THREE_STATE = (1 << 4); +DEF RX_IF_USE_CLKOUT1 = (0 << 3); +DEF RX_IF_USE_CLKOUT2 = (1 << 3); // aka Rx Retime +DEF RX_IF_2S_COMP = (1 << 2); +DEF RX_IF_INV_RX_SYNC = (1 << 1); +DEF RX_IF_MUX_OUT = (1 << 0); + +DEF REG_RX_DIGITAL = 6; +DEF RX_DIGITAL_2_CHAN = (1 << 3); +DEF RX_DIGITAL_KEEP_MINUS_VE = (1 << 2); +DEF RX_DIGITAL_HILBERT = (1 << 1); +DEF RX_DIGITAL_DECIMATE = (1 << 0); + +DEF REG_RESERVED_7 = 7; + +DEF REG_TX_PWR_DN = 8; +DEF TX_PWR_DN_ALT_TIMING_MODE = (1 << 5); +DEF TX_PWR_DN_TX_OFF_ENABLE = (1 << 4); +DEF TX_PWR_DN_TX_DIGITAL = (1 << 3); +DEF TX_PWR_DN_TX_ANALOG_B = 0x4; +DEF TX_PWR_DN_TX_ANALOG_A = 0x2; +DEF TX_PWR_DN_TX_ANALOG_BOTH = 0x7; + +DEF REG_RESERVED_9 = 9; + +DEF REG_TX_A_OFFSET_LO = 10; +DEF REG_TX_A_OFFSET_HI = 11; +DEF REG_TX_B_OFFSET_LO = 12; +DEF REG_TX_B_OFFSET_HI = 13; + +DEF REG_TX_A_GAIN = 14; // fine trim for matching +DEF REG_TX_B_GAIN = 15; // fine trim for matching +DEF TX_X_GAIN_COARSE_FULL = (3 << 6); +DEF TX_X_GAIN_COARSE_1_HALF = (1 << 6); +DEF TX_X_GAIN_COARSE_1_ELEVENTH = (0 << 6); + +DEF REG_TX_PGA = 16; // 20 dB continuous gain in 0.1 dB steps + // 0x00 = min gain (-20 dB) + // 0xff = max gain ( 0 dB) + +DEF REG_TX_MISC = 17; +DEF TX_MISC_SLAVE_ENABLE = (1 << 1); +DEF TX_MISC_TX_PGA_FAST = (1 << 0); + +DEF REG_TX_IF = 18; +DEF TX_IF_USE_CLKOUT2 = (0 << 6); +DEF TX_IF_USE_CLKOUT1 = (1 << 6); // aka Tx Retime +DEF TX_IF_I_FIRST = (0 << 5); +DEF TX_IF_Q_FIRST = (1 << 5); +DEF TX_IF_INV_TX_SYNC = (1 << 4); +DEF TX_IF_2S_COMP = (1 << 3); +DEF TX_IF_INVERSE_SAMPLE = (1 << 2); +DEF TX_IF_TWO_EDGES = (1 << 1); +DEF TX_IF_INTERLEAVED = (1 << 0); + +DEF REG_TX_DIGITAL = 19; +DEF TX_DIGITAL_2_DATA_PATHS = (1 << 4); +DEF TX_DIGITAL_KEEP_NEGATIVE = (1 << 3); +DEF TX_DIGITAL_HILBERT = (1 << 2); +DEF TX_DIGITAL_INTERPOLATE_NONE = 0x0; +DEF TX_DIGITAL_INTERPOLATE_2X = 0x1; +DEF TX_DIGITAL_INTERPOLATE_4X = 0x2; + +DEF REG_TX_MODULATOR = 20; +DEF TX_MODULATOR_NEG_FINE_TUNE = (1 << 5); +DEF TX_MODULATOR_DISABLE_NCO = (0 << 4); +DEF TX_MODULATOR_ENABLE_NCO = (1 << 4); // aka Fine Mode +DEF TX_MODULATOR_REAL_MIX_MODE = (1 << 3); +DEF TX_MODULATOR_NEG_COARSE_TUNE = (1 << 2); +DEF TX_MODULATOR_COARSE_MODULATION_NONE = 0x0; +DEF TX_MODULATOR_COARSE_MODULATION_F_OVER_4 = 0x1; +DEF TX_MODULATOR_COARSE_MODULATION_F_OVER_8 = 0x2; +DEF TX_MODULATOR_CM_MASK = 0x7; + + +DEF REG_TX_NCO_FTW_7_0 = 21; +DEF REG_TX_NCO_FTW_15_8 = 22; +DEF REG_TX_NCO_FTW_23_16= 23; + +DEF REG_DLL = 24; +DEF DLL_DISABLE_INTERNAL_XTAL_OSC = (1 << 6); // aka Input Clock Ctrl +DEF DLL_ADC_DIV2 = (1 << 5); +DEF DLL_MULT_1X = (0 << 3); +DEF DLL_MULT_2X = (1 << 3); +DEF DLL_MULT_4X = (2 << 3); +DEF DLL_PWR_DN = (1 << 2); +// undefined bit = (1 << 1); +DEF DLL_FAST = (1 << 0); + +DEF REG_CLKOUT = 25; +DEF CLKOUT2_EQ_DLL = (0 << 6); +DEF CLKOUT2_EQ_DLL_OVER_2 = (1 << 6); +DEF CLKOUT2_EQ_DLL_OVER_4 = (2 << 6); +DEF CLKOUT2_EQ_DLL_OVER_8 = (3 << 6); +DEF CLKOUT_INVERT_CLKOUT2 = (1 << 5); +DEF CLKOUT_DISABLE_CLKOUT2 = (1 << 4); +// undefined bit = (1 << 3); +// undefined bit = (1 << 2); +DEF CLKOUT_INVERT_CLKOUT1 = (1 << 1); +DEF CLKOUT_DISABLE_CLKOUT1 = (1 << 0); + +DEF REG_AUX_ADC_A2_LO = 26; +DEF REG_AUX_ADC_A2_HI = 27; +DEF REG_AUX_ADC_A1_LO = 28; +DEF REG_AUX_ADC_A1_HI = 29; +DEF REG_AUX_ADC_B2_LO = 30; +DEF REG_AUX_ADC_B2_HI = 31; +DEF REG_AUX_ADC_B1_LO = 32; +DEF REG_AUX_ADC_B1_HI = 33; + +DEF REG_AUX_ADC_CTRL = 34; +DEF AUX_ADC_CTRL_AUX_SPI = (1 << 7); +DEF AUX_ADC_CTRL_SELBNOTA = (1 << 6); +DEF AUX_ADC_CTRL_REFSEL_B = (1 << 5); +DEF AUX_ADC_CTRL_SELECT_B2 = (0 << 4); +DEF AUX_ADC_CTRL_SELECT_B1 = (1 << 4); +DEF AUX_ADC_CTRL_START_B = (1 << 3); +DEF AUX_ADC_CTRL_REFSEL_A = (1 << 2); +DEF AUX_ADC_CTRL_SELECT_A2 = (0 << 1); +DEF AUX_ADC_CTRL_SELECT_A1 = (1 << 1); +DEF AUX_ADC_CTRL_START_A = (1 << 0); + +DEF REG_AUX_ADC_CLK = 35; +DEF AUX_ADC_CLK_CLK_OVER_4 = (1 << 0); + +DEF REG_AUX_DAC_A = 36; +DEF REG_AUX_DAC_B = 37; +DEF REG_AUX_DAC_C = 38; + +DEF REG_AUX_DAC_UPDATE = 39; +DEF AUX_DAC_UPDATE_SLAVE_ENABLE = (1 << 7); +DEF AUX_DAC_UPDATE_C = (1 << 2); +DEF AUX_DAC_UPDATE_B = (1 << 1); +DEF AUX_DAC_UPDATE_A = (1 << 0); + +DEF REG_AUX_DAC_PWR_DN = 40; +DEF AUX_DAC_PWR_DN_C = (1 << 2); +DEF AUX_DAC_PWR_DN_B = (1 << 1); +DEF AUX_DAC_PWR_DN_A = (1 << 0); + +DEF REG_AUX_DAC_CTRL = 41; +DEF AUX_DAC_CTRL_INV_C = (1 << 4); +DEF AUX_DAC_CTRL_INV_B = (1 << 2); +DEF AUX_DAC_CTRL_INV_A = (1 << 0); + +DEF REG_SIGDELT_LO = 42; +DEF REG_SIGDELT_HI = 43; + +// 44 to 48 reserved + +DEF REG_ADC_LOW_PWR_LO = 49; +DEF REG_ADC_LOW_PWR_HI = 50; + +// 51 to 62 reserved + +DEF REG_CHIP_ID = 63; + + +END_AD962; + +#undef DEF +#undef BEGIN_AD9862 +#undef END_AD962 + +#endif /* INCLUDED_AD9862_H */ diff --git a/TransceiverRAD1/bytesex.h b/TransceiverRAD1/bytesex.h new file mode 100644 index 0000000..2c545da --- /dev/null +++ b/TransceiverRAD1/bytesex.h @@ -0,0 +1,87 @@ +#ifndef INCLUDED_USRP_BYTESEX_H +#define INCLUDED_USRP_BYTESEX_H + +/*! + * \brief routines for convertering between host and usrp byte order + * + * Prior to including this file, the user must include "config.h" + * which will or won't define WORDS_BIGENDIAN based on the + * result of the AC_C_BIGENDIAN autoconf test. + */ + +#ifdef HAVE_BYTESWAP_H +#include +#else + +#warning Using non-portable code (likely wrong other than ILP32). + +static inline unsigned short int +bswap_16 (unsigned short int x) +{ + return ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)); +} + +static inline unsigned int +bswap_32 (unsigned int x) +{ + return ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) \ + | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)); +} +#endif + + +#ifdef WORDS_BIGENDIAN + +static inline unsigned int +host_to_usrp_u32 (unsigned int x) +{ + return bswap_32(x); +} + +static inline unsigned int +usrp_to_host_u32 (unsigned int x) +{ + return bswap_32(x); +} + +static inline short int +host_to_usrp_short (short int x) +{ + return bswap_16 (x); +} + +static inline short int +usrp_to_host_short (short int x) +{ + return bswap_16 (x); +} + +#else + +static inline unsigned int +host_to_usrp_u32 (unsigned int x) +{ + return x; +} + +static inline unsigned int +usrp_to_host_u32 (unsigned int x) +{ + return x; +} + +static inline short int +host_to_usrp_short (short int x) +{ + return x; +} + +static inline short int +usrp_to_host_short (unsigned short int x) +{ + return x; +} + +#endif + +#endif /* INCLUDED_USRP_BYTESEX_H */ diff --git a/TransceiverRAD1/commands.h b/TransceiverRAD1/commands.h new file mode 100644 index 0000000..924f618 --- /dev/null +++ b/TransceiverRAD1/commands.h @@ -0,0 +1,76 @@ +#ifndef _RAD1_COMMANDS_H_ +#define _RAD1_COMMANDS_H_ + +#define MAX_EP0_PKTSIZE 64 // max size of EP0 packet on FX2 + +// ---------------------------------------------------------------- +// Vendor bmRequestType's +// ---------------------------------------------------------------- + +#define VRT_VENDOR_IN 0xC0 +#define VRT_VENDOR_OUT 0x40 + +// ---------------------------------------------------------------- +// RAD1 Vendor Requests +// +// Note that Cypress reserves [0xA0,0xAF]. +// 0xA0 is the firmware load function. +// ---------------------------------------------------------------- + + +// IN commands + +#define VRQ_GET_STATUS 0x80 +#define GS_TX_UNDERRUN 0 // wIndexL // returns 1 byte +#define GS_RX_OVERRUN 1 // wIndexL // returns 1 byte + +#define VRQ_I2C_READ 0x81 // wValueL: i2c address; length: how much to read + +#define VRQ_SPI_READ 0x82 // wValue: optional header bytes + // wIndexH: enables + // wIndexL: format + // len: how much to read + +// OUT commands + +#define VRQ_SET_LED 0x01 // wValueL off/on {0,1}; wIndexL: which {0,1} + +#define VRQ_FPGA_LOAD 0x02 +# define FL_BEGIN 0 // wIndexL: begin fpga programming cycle. stalls if trouble. +# define FL_XFER 1 // wIndexL: xfer up to 64 bytes of data +# define FL_END 2 // wIndexL: end programming cycle, check for success. + // stalls endpoint if trouble. + +#define VRQ_FPGA_WRITE_REG 0x03 // wIndexL: regno; data: 32-bit regval MSB first +#define VRQ_FPGA_SET_RESET 0x04 // wValueL: {0,1} +#define VRQ_FPGA_SET_TX_ENABLE 0x05 // wValueL: {0,1} +#define VRQ_FPGA_SET_RX_ENABLE 0x06 // wValueL: {0,1} +// see below VRQ_FPGA_SET_{TX,RX}_RESET + +#define VRQ_SET_SLEEP_BITS 0x07 // wValueH: mask; wValueL: bits. set bits given by mask to bits + +# define SLEEP_ADC0 0x01 +# define SLEEP_ADC1 0x02 +# define SLEEP_DAC0 0x04 +# define SLEEP_DAC1 0x08 + +#define VRQ_I2C_WRITE 0x08 // wValueL: i2c address; data: data + +#define VRQ_SPI_WRITE 0x09 // wValue: optional header bytes + // wIndexH: enables + // wIndexL: format + // len: how much to write + +#define VRQ_FPGA_SET_TX_RESET 0x0a // wValueL: {0, 1} +#define VRQ_FPGA_SET_RX_RESET 0x0b // wValueL: {0, 1} + + +// ------------------------------------------------------------------- +// we store the hashes at fixed addresses in the FX2 internal memory + +#define RAD1_HASH_SLOT_0_ADDR 0xe1e0 +#define RAD1_HASH_SLOT_1_ADDR 0xe1f0 + + + +#endif /* _RAD1_COMMANDS_H_ */ diff --git a/TransceiverRAD1/fpga_regs.h b/TransceiverRAD1/fpga_regs.h new file mode 100644 index 0000000..3ac1a3c --- /dev/null +++ b/TransceiverRAD1/fpga_regs.h @@ -0,0 +1,404 @@ +#ifndef INCLUDED_FPGA_REGS_H +#define INCLUDED_FPGA_REGS_H + +// This file defines registers common to all FPGA configurations. +// Registers 0 to 31 are reserved for use in this file. + + +// The FPGA needs to know the rate that samples are coming from and +// going to the A/D's and D/A's. div = 128e6 / sample_rate + +#define FR_TX_SAMPLE_RATE_DIV 0 +#define FR_RX_SAMPLE_RATE_DIV 1 + +// 2 and 3 are defined in the ATR section + +#define FR_MASTER_CTRL 4 // master enable and reset controls +# define bmFR_MC_ENABLE_TX (1 << 0) +# define bmFR_MC_ENABLE_RX (1 << 1) +# define bmFR_MC_RESET_TX (1 << 2) +# define bmFR_MC_RESET_RX (1 << 3) + +// i/o direction registers for pins that go to daughterboards. +// Setting the bit makes it an output from the FPGA to the d'board. +// top 16 is mask, low 16 is value + +#define FR_OE_0 5 // slot 0 +#define FR_OE_1 6 +#define FR_OE_2 7 +#define FR_OE_3 8 + +// i/o registers for pins that go to daughterboards. +// top 16 is a mask, low 16 is value + +#define FR_IO_0 9 // slot 0 +#define FR_IO_1 10 +#define FR_IO_2 11 +#define FR_IO_3 12 + +#define FR_MODE 13 +# define bmFR_MODE_NORMAL 0 +# define bmFR_MODE_LOOPBACK (1 << 0) // enable digital loopback +# define bmFR_MODE_RX_COUNTING (1 << 1) // Rx is counting +# define bmFR_MODE_RX_COUNTING_32BIT (1 << 2) // Rx is counting with a 32 bit counter + // low and high 16 bits are multiplexed across channel I and Q + + +// If the corresponding bit is set, internal FPGA debug circuitry +// controls the i/o pins for the associated bank of daughterboard +// i/o pins. Typically used for debugging FPGA designs. + +#define FR_DEBUG_EN 14 +# define bmFR_DEBUG_EN_TX_A (1 << 0) // debug controls TX_A i/o +# define bmFR_DEBUG_EN_RX_A (1 << 1) // debug controls RX_A i/o +# define bmFR_DEBUG_EN_TX_B (1 << 2) // debug controls TX_B i/o +# define bmFR_DEBUG_EN_RX_B (1 << 3) // debug controls RX_B i/o + + +// If the corresponding bit is set, enable the automatic DC +// offset correction control loop. +// +// The 4 low bits are significant: +// +// ADC0 = (1 << 0) +// ADC1 = (1 << 1) +// ADC2 = (1 << 2) +// ADC3 = (1 << 3) +// +// This control loop works if the attached daugherboard blocks DC. +// Currently all daughterboards do block DC. This includes: +// basic rx, dbs_rx, tv_rx, flex_xxx_rx. + +#define FR_DC_OFFSET_CL_EN 15 // DC Offset Control Loop Enable + + +// offset corrections for ADC's and DAC's (2's complement) + +#define FR_ADC_OFFSET_0 16 +#define FR_ADC_OFFSET_1 17 +#define FR_ADC_OFFSET_2 18 +#define FR_ADC_OFFSET_3 19 + + +// ------------------------------------------------------------------------ +// Automatic Transmit/Receive switching +// +// If automatic transmit/receive (ATR) switching is enabled in the +// FR_ATR_CTL register, the presence or absence of data in the FPGA +// transmit fifo selects between two sets of values for each of the 4 +// banks of daughterboard i/o pins. +// +// Each daughterboard slot has 3 16-bit registers associated with it: +// FR_ATR_MASK_*, FR_ATR_TXVAL_* and FR_ATR_RXVAL_* +// +// FR_ATR_MASK_{0,1,2,3}: +// +// These registers determine which of the daugherboard i/o pins are +// affected by ATR switching. If a bit in the mask is set, the +// corresponding i/o bit is controlled by ATR, else it's output +// value comes from the normal i/o pin output register: +// FR_IO_{0,1,2,3}. +// +// FR_ATR_TXVAL_{0,1,2,3}: +// FR_ATR_RXVAL_{0,1,2,3}: +// +// If the Tx fifo contains data, then the bits from TXVAL that are +// selected by MASK are output. Otherwise, the bits from RXVAL that +// are selected by MASK are output. + +#define FR_ATR_MASK_0 20 // slot 0 +#define FR_ATR_TXVAL_0 21 +#define FR_ATR_RXVAL_0 22 + +#define FR_ATR_MASK_1 23 // slot 1 +#define FR_ATR_TXVAL_1 24 +#define FR_ATR_RXVAL_1 25 + +#define FR_ATR_MASK_2 26 // slot 2 +#define FR_ATR_TXVAL_2 27 +#define FR_ATR_RXVAL_2 28 + +#define FR_ATR_MASK_3 29 // slot 3 +#define FR_ATR_TXVAL_3 30 +#define FR_ATR_RXVAL_3 31 + +// Clock ticks to delay rising and falling edge of T/R signal +#define FR_ATR_TX_DELAY 2 +#define FR_ATR_RX_DELAY 3 + +// Register numbers 0 to 31 are reserved for use in fpga_regs_common.h. +// Registers 64 to 79 are available for custom FPGA builds. + + +// DDC / DUC + +#define FR_INTERP_RATE 32 // [1,1024] +#define FR_DECIM_RATE 33 // [1,256] + +// DDC center freq + +#define FR_RX_FREQ_0 34 +#define FR_RX_FREQ_1 35 +#define FR_RX_FREQ_2 36 +#define FR_RX_FREQ_3 37 + +// See below for DDC Starting Phase + +// ------------------------------------------------------------------------ +// configure FPGA Rx mux +// +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-----------------------+-------+-------+-------+-------+-+-----+ +// | must be zero | Q3| I3| Q2| I2| Q1| I1| Q0| I0|Z| NCH | +// +-----------------------+-------+-------+-------+-------+-+-----+ +// +// There are a maximum of 4 digital downconverters in the the FPGA. +// Each DDC has two 16-bit inputs, I and Q, and two 16-bit outputs, I & Q. +// +// DDC I inputs are specified by the two bit fields I3, I2, I1 & I0 +// +// 0 = DDC input is from ADC 0 +// 1 = DDC input is from ADC 1 +// 2 = DDC input is from ADC 2 +// 3 = DDC input is from ADC 3 +// +// If Z == 1, all DDC Q inputs are set to zero +// If Z == 0, DDC Q inputs are specified by the two bit fields Q3, Q2, Q1 & Q0 +// +// NCH specifies the number of complex channels that are sent across +// the USB. The legal values are 1, 2 or 4, corresponding to 2, 4 or +// 8 16-bit values. + +#define FR_RX_MUX 38 + +// ------------------------------------------------------------------------ +// configure FPGA Tx Mux. +// +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-----------------------+-------+-------+-------+-------+-+-----+ +// | | DAC3 | DAC2 | DAC1 | DAC0 |0| NCH | +// +-----------------------------------------------+-------+-+-----+ +// +// NCH specifies the number of complex channels that are sent across +// the USB. The legal values are 1 or 2, corresponding to 2 or 4 +// 16-bit values. +// +// There are two interpolators with complex inputs and outputs. +// There are four DACs. (We use the DUC in each AD9862.) +// +// Each 4-bit DACx field specifies the source for the DAC and +// whether or not that DAC is enabled. Each subfield is coded +// like this: +// +// 3 2 1 0 +// +-+-----+ +// |E| N | +// +-+-----+ +// +// Where E is set if the DAC is enabled, and N specifies which +// interpolator output is connected to this DAC. +// +// N which interp output +// --- ------------------- +// 0 chan 0 I +// 1 chan 0 Q +// 2 chan 1 I +// 3 chan 1 Q + +#define FR_TX_MUX 39 + +// ------------------------------------------------------------------------ +// REFCLK control +// +// Control whether a reference clock is sent to the daughterboards, +// and what frequency. The refclk is sent on d'board i/o pin 0. +// +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-----------------------------------------------+-+------------+ +// | Reserved (Must be zero) |E| DIVISOR | +// +-----------------------------------------------+-+------------+ + +// +// Bit 7 -- 1 turns on refclk, 0 allows IO use +// Bits 6:0 Divider value + +#define FR_TX_A_REFCLK 40 +#define FR_RX_A_REFCLK 41 +#define FR_TX_B_REFCLK 42 +#define FR_RX_B_REFCLK 43 + +# define bmFR_REFCLK_EN 0x80 +# define bmFR_REFCLK_DIVISOR_MASK 0x7f + +// ------------------------------------------------------------------------ +// DDC Starting Phase + +#define FR_RX_PHASE_0 44 +#define FR_RX_PHASE_1 45 +#define FR_RX_PHASE_2 46 +#define FR_RX_PHASE_3 47 + +// ------------------------------------------------------------------------ +// Tx data format control register +// +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-------------------------------------------------------+-------+ +// | Reserved (Must be zero) | FMT | +// +-------------------------------------------------------+-------+ +// +// FMT values: + +#define FR_TX_FORMAT 48 +# define bmFR_TX_FORMAT_16_IQ 0 // 16-bit I, 16-bit Q + +// ------------------------------------------------------------------------ +// Rx data format control register +// +// 3 2 1 +// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +// +-----------------------------------------+-+-+---------+-------+ +// | Reserved (Must be zero) |B|Q| WIDTH | SHIFT | +// +-----------------------------------------+-+-+---------+-------+ +// +// FMT values: + +#define FR_RX_FORMAT 49 + +# define bmFR_RX_FORMAT_SHIFT_MASK (0x0f << 0) // arithmetic right shift [0, 15] +# define bmFR_RX_FORMAT_SHIFT_SHIFT 0 +# define bmFR_RX_FORMAT_WIDTH_MASK (0x1f << 4) // data width in bits [1, 16] (not all valid) +# define bmFR_RX_FORMAT_WIDTH_SHIFT 4 +# define bmFR_RX_FORMAT_WANT_Q (0x1 << 9) // deliver both I & Q, else just I +# define bmFR_RX_FORMAT_BYPASS_HB (0x1 << 10) // bypass half-band filter + +// The valid combinations currently are: +// +// B Q WIDTH SHIFT +// 0 1 16 0 +// 0 1 8 8 + + +// Possible future values of WIDTH = {4, 2, 1} +// 12 takes a bit more work, since we need to know packet alignment. + +// ------------------------------------------------------------------------ +// FIXME register numbers 50 to 63 are available + +// ------------------------------------------------------------------------ +// Registers 64 to 95 are reserved for user custom FPGA builds. +// The standard RAD1 software will not touch these. + +#define FR_USER_0 64 +#define FR_USER_1 65 +#define FR_USER_2 66 +#define FR_USER_3 67 +#define FR_USER_4 68 +#define FR_USER_5 69 +#define FR_USER_6 70 +#define FR_USER_7 71 +#define FR_USER_8 72 +#define FR_USER_9 73 +#define FR_USER_10 74 +#define FR_USER_11 75 +#define FR_USER_12 76 +#define FR_USER_13 77 +#define FR_USER_14 78 +#define FR_USER_15 79 +#define FR_USER_16 80 +#define FR_USER_17 81 +#define FR_USER_18 82 +#define FR_USER_19 83 +#define FR_USER_20 84 +#define FR_USER_21 85 +#define FR_USER_22 86 +#define FR_USER_23 87 +#define FR_USER_24 88 +#define FR_USER_25 89 +#define FR_USER_26 90 +#define FR_USER_27 91 +#define FR_USER_28 92 +#define FR_USER_29 93 +#define FR_USER_30 94 +#define FR_USER_31 95 + +//Registers needed for multi rad1 master/slave configuration +// +//Rx Master/slave control register (FR_RX_MASTER_SLAVE = FR_USER_0) +// +#define FR_RX_MASTER_SLAVE 64 +#define bitnoFR_RX_SYNC 0 +#define bitnoFR_RX_SYNC_MASTER 1 +#define bitnoFR_RX_SYNC_SLAVE 2 +# define bmFR_RX_SYNC (1 <. + +*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------ +// libusb_transfer allocation, deallocation, and callback +// ------------------------------------------------------------------------ + +static void +free_lut (libusb_transfer *lut) +{ + + // if this was an input transfer, free the buffer + if (lut->endpoint & 0x80) + delete [] ((unsigned char *) lut->buffer); + + libusb_free_transfer(lut); + +} + +/* + * The callback means the libusb_transfer is completed whether sent, cancelled, + * or failed. Move the libusb_transfer from the pending list to the + * completed list. If the cancel is from the destructor then free the + * transfer instead; normally this won't happen since all endpoints should be + * destroyed first leaving the pending list empty. + */ + +static void +generic_callback(struct libusb_transfer *lut) +{ + + // Fish out devhandle from endpoint + fusb_devhandle* dev_handle = + (fusb_devhandle *) ((fusb_ephandle *) lut->user_data)->get_fusb_devhandle(); + + dev_handle->pending_remove(lut); + + if (lut->status == LIBUSB_TRANSFER_CANCELLED && dev_handle->_teardown() == 1) + { + free_lut (lut); + return; + } + + ((fusb_ephandle *) lut->user_data)->completed_list_add(lut); + +} + +static libusb_transfer* +alloc_lut (fusb_ephandle *self, int buffer_length, int endpoint, + bool input_p, unsigned char *write_buffer, + fusb_devhandle *dh) +{ + + struct libusb_transfer* lut = libusb_alloc_transfer(0); + + endpoint = (endpoint & 0x7f) | (input_p ? 0x80 : 0); + + if (input_p) + write_buffer = new unsigned char [buffer_length]; + + // We need the base class libusb_device_handle + libusb_device_handle *dev_handle = dh->get_usb_dev_handle(); + + // Load the libusb_transfer for bulk transfer + libusb_fill_bulk_transfer (lut, // transfer + dev_handle, // dev_handle + endpoint, // endpoint + write_buffer, // buffer + buffer_length, // length + generic_callback, // callback + self, // user_data + 0); // timeout + return lut; +} + +// ------------------------------------------------------------------------ +// device handle +// ------------------------------------------------------------------------ + +fusb_devhandle::fusb_devhandle (libusb_device_handle *udh, + libusb_context *ctx) + : d_udh(udh), d_ctx (ctx), d_teardown (false) +{ + // that's it +} + +fusb_devhandle::~fusb_devhandle () +{ + d_teardown = true; + +} + +fusb_ephandle* +fusb_devhandle::make_ephandle (int endpoint, bool input_p, + int block_size, int nblocks) +{ + return new fusb_ephandle (this, endpoint, input_p, + block_size, nblocks); +} + +/* + * devhandle list manipulators + */ + +void +fusb_devhandle::pending_add (libusb_transfer *lut) +{ + d_pending_rqsts.push_back (lut); +} + + +/* + * Pull from the pending list + */ + +libusb_transfer * +fusb_devhandle::pending_get () +{ + if (d_pending_rqsts.empty ()) + return 0; + + libusb_transfer *lut = d_pending_rqsts.front (); + d_pending_rqsts.pop_front (); + return lut; +} + +/* + * Match libusb_tranfer with the pending list and erase + * Return true if found, false otherwise + */ + +bool +fusb_devhandle::pending_remove (libusb_transfer *lut) +{ + std::list::iterator result; + result = find (d_pending_rqsts.begin (), d_pending_rqsts.end (), lut); + + if (result == d_pending_rqsts.end ()) { + LOG(ERR) << "Failed to find lut in pending_rqsts"; + + return false; + } + d_pending_rqsts.erase (result); + return true; +} + +/* + * Submit the libusb_transfer to libusb + * iff successful, the transfer will be placed on the devhandle pending list. + */ + +bool +fusb_devhandle::_submit_lut (libusb_transfer *lut) +{ + + int ret = libusb_submit_transfer (lut); + if (ret < 0) { + LOG(ERR) << "submit_lut " << ret; + return false; + } + + pending_add(lut); + return true; + +} + + +/* + * Reimplementing _reap for context use and compatibiliy with libusb-0.12. + * + * Returns false on timeout or error, true if an event was handled + * + * If ok_to_block_p is false then handle already pending events and return + * immediately. + * + * If ok_to_block_p is true then call libusb_handle_events_timeout with default + * timeout value of 2 seconds, which waits and returns on event arrival or + * timeout. + */ + +bool +fusb_devhandle::_reap (bool ok_to_block_p) +{ + int ret; + struct timeval tv; + + // Save pending size + int pnd_size = d_pending_rqsts.size(); + + if (ok_to_block_p) { + tv.tv_sec = 2; + tv.tv_usec = 0; + } + else { + tv.tv_sec = 0; + tv.tv_usec = 0; + } + + if ((ret = libusb_handle_events_timeout(d_ctx, &tv)) < 0) { + LOG(ERR) << "libusb_handle_events_timeout returned " << ret; + return false; + } + + // Check that a pending transfer was removed + if (pnd_size > d_pending_rqsts.size()) + return true; + else { + return false; + } +} + +// ------------------------------------------------------------------------ +// endpoint handle +// ------------------------------------------------------------------------ + +fusb_ephandle::fusb_ephandle(fusb_devhandle *dh, + int endpoint, bool input_p, + int block_size, int nblocks) + : d_endpoint(endpoint), d_input_p(input_p), d_block_size(block_size), d_nblocks(nblocks), d_started(false), + d_devhandle (dh), + d_write_work_in_progress (0), d_write_buffer (0), + d_read_work_in_progress (0), d_read_buffer (0), d_read_buffer_end (0) +{ + + if (d_block_size < 0 || d_block_size > MAX_BLOCK_SIZE) + throw std::out_of_range ("fusb_ephandle_libusb1: block_size"); + + if (d_nblocks < 0) + throw std::out_of_range ("fusb_ephandle_libusb1: nblocks"); + + if (d_block_size == 0) + d_block_size = DEFAULT_BLOCK_SIZE; + + if (d_nblocks == 0) + d_nblocks = std::max (1, DEFAULT_BUFFER_SIZE / d_block_size); + + // allocate libusb_transfers + for (int i = 0; i < d_nblocks; i++) + d_free_list.push_back (alloc_lut (this, d_block_size, d_endpoint, + d_input_p, d_write_buffer, d_devhandle)); +} + +fusb_ephandle::~fusb_ephandle () +{ + + libusb_transfer *lut; + + while ((lut = free_list_get ()) != 0) + free_lut (lut); + + while ((lut = completed_list_get ()) != 0) + free_lut (lut); + + if (d_write_work_in_progress) + free_lut (d_write_work_in_progress); + + delete [] d_write_buffer; + + if (d_read_work_in_progress) + free_lut (d_read_work_in_progress); + +} + +bool +fusb_ephandle::start () +{ + if (d_started) + return true; + + d_started = true; + + if (d_input_p) { + libusb_transfer *lut; + + int nerrors = 0; + while ((lut = free_list_get ()) !=0 && nerrors < d_nblocks) { + if (!submit_lut (lut)) + nerrors++; + } + } + + return true; + +} + +/* + * Cancel all transfers in progress or pending and return to initial state + */ + +// ------------------------------------------------------------------------ +// routines for writing +// ------------------------------------------------------------------------ + +int +fusb_ephandle::write (const void *buffer, int nbytes) +{ + if (!d_started) // doesn't matter here, but keeps semantics constant + return -1; + + if (d_input_p) + return -1; + + assert(nbytes % 512 == 0); + + unsigned char *src = (unsigned char *) buffer; + + int n = 0; + while (n < nbytes){ + + struct libusb_transfer *lut = get_write_work_in_progress(); + if (!lut) + return -1; + assert(lut->actual_length == 0); + int m = std::min(nbytes - n, MAX_BLOCK_SIZE); + lut->buffer = src; + lut->length = m; + + n += m; + src += m; + + if (!submit_lut(lut)) + return -1; + + d_write_work_in_progress = 0; + } + + return n; +} + +struct libusb_transfer * +fusb_ephandle::get_write_work_in_progress () +{ + if (d_write_work_in_progress) + return d_write_work_in_progress; + + while (1) { + + reap_complete_writes (); + + struct libusb_transfer *lut = free_list_get (); + + if (lut != 0){ + assert (lut->actual_length == 0); + d_write_work_in_progress = lut; + return lut; + } + + if (!d_devhandle->_reap (true)) + return 0; + } +} + +void +fusb_ephandle::reap_complete_writes () +{ + // take a look at the completed list and xfer to free list after + // checking for errors. + + libusb_transfer *lut; + + while ((lut = completed_list_get ()) != 0) { + + // Check for any errors or short writes that were reporetd in the transfer. + // libusb1 sets status, actual_length. + + if (lut->status != LIBUSB_TRANSFER_COMPLETED) { + LOG(ERR) << "Invalid LUT status " << lut->status; + } + else if (lut->actual_length != lut->length){ + LOG(ERR) << "Improper write of " << lut->actual_length; + } + + free_list_add (lut); + } +} + +// ------------------------------------------------------------------------ +// routines for reading +// ------------------------------------------------------------------------ + +int +fusb_ephandle::read (void *buffer, int nbytes) +{ + if (!d_started) // doesn't matter here, but keeps semantics constant + return -1; + + if (!d_input_p) + return -1; + + unsigned char *dst = (unsigned char *) buffer; + + int n = 0; + while (n < nbytes) { + + if (d_read_buffer >= d_read_buffer_end) + if (!reload_read_buffer ()) + return -1; + + int m = std::min (nbytes - n, (int) (d_read_buffer_end - d_read_buffer)); + + memcpy (&dst[n], d_read_buffer, m); + d_read_buffer += m; + n += m; + } + + return n; + +} + +bool +fusb_ephandle::reload_read_buffer () +{ + assert (d_read_buffer >= d_read_buffer_end); + + libusb_transfer *lut; + + if (d_read_work_in_progress) { + lut = d_read_work_in_progress; + d_read_work_in_progress = 0; + d_read_buffer = 0; + d_read_buffer_end = 0; + lut->actual_length = 0; + if (!submit_lut (lut)) { + LOG(ERR) << "Improper LUT submission"; + return false; + } + } + + while (1) { + + while ((lut = completed_list_get ()) == 0 ) + if (!d_devhandle->_reap(true)) + { + LOG(ERR) << "No libusb events"; + return false; + } + if (lut->status != LIBUSB_TRANSFER_COMPLETED) { + LOG(ERR) << "Improper read status " << lut->status; + lut->actual_length = 0; + free_list_add (lut); + return false; + } + + d_read_work_in_progress = lut; + d_read_buffer = (unsigned char *) lut->buffer; + d_read_buffer_end = d_read_buffer + lut->actual_length; + + return true; + } +} + + +/* + * ephandle list manipulation + */ + + +void +fusb_ephandle::free_list_add (libusb_transfer *lut) +{ + assert ((lut->user_data) == this); + lut->actual_length = 0; + d_free_list.push_back (lut); +} + +libusb_transfer * +fusb_ephandle::free_list_get () +{ + if (d_free_list.empty ()) + return 0; + + libusb_transfer *lut = d_free_list.front (); + d_free_list.pop_front (); + return lut; +} + +void +fusb_ephandle::completed_list_add (libusb_transfer *lut) +{ + assert ((lut->user_data) == this); + d_completed_list.push_back (lut); +} + +libusb_transfer * +fusb_ephandle::completed_list_get () +{ + if (d_completed_list.empty ()) + return 0; + + libusb_transfer *lut = d_completed_list.front (); + d_completed_list.pop_front (); + return lut; +} + +bool +fusb_ephandle::submit_lut (libusb_transfer *lut) +{ + if (!d_devhandle->_submit_lut (lut)) { + LOG(ERR) << "USB submission failed"; + free_list_add (lut); + return false; + } + return true; +} diff --git a/TransceiverRAD1/fusb.h b/TransceiverRAD1/fusb.h new file mode 100644 index 0000000..5e0da02 --- /dev/null +++ b/TransceiverRAD1/fusb.h @@ -0,0 +1,136 @@ +#ifndef _FUSB_H_ +#define _FUSB_H_ + +//#include "libusb_types.h" +#include +#include +#include "Logger.h" + +struct libusb_device; +struct libusb_device_handle; +struct libusb_device_descriptor; + +struct libusb_transfer; +struct libusb_context; +class fusb_ephandle; + +/*! + * \brief abstract usb device handle + */ +class fusb_devhandle { + +private: + std::list d_pending_rqsts; + libusb_context *d_ctx; + + void pending_add (struct libusb_transfer *lut); + struct libusb_transfer * pending_get (); + + bool d_teardown; + +public: + fusb_devhandle (libusb_device_handle *udh, libusb_context *ctx); + ~fusb_devhandle (); + + fusb_ephandle *make_ephandle (int endpoint, bool input_p, + int block_size = 0, int nblocks = 0); + bool _submit_lut (libusb_transfer *); + bool _reap (bool ok_to_block_p); + + bool pending_remove (struct libusb_transfer *lut); + inline bool _teardown() { return d_teardown; } + +protected: + libusb_device_handle *d_udh; + +public: + fusb_devhandle (libusb_device_handle *udh) {d_udh = udh;} + libusb_device_handle *get_usb_dev_handle () const { return d_udh; } +}; + + +/*! + * \brief abstract usb end point handle + */ +class fusb_ephandle { +private: + + // NOT IMPLEMENTED + fusb_ephandle (const fusb_ephandle &rhs); // no copy constructor + fusb_ephandle &operator= (const fusb_ephandle &rhs); // no assignment operator + + +private: + fusb_devhandle *d_devhandle; + std::list d_free_list; + std::list d_completed_list; + libusb_transfer *d_write_work_in_progress; + unsigned char *d_write_buffer; + libusb_transfer *d_read_work_in_progress; + unsigned char *d_read_buffer; + unsigned char *d_read_buffer_end; + + libusb_transfer *get_write_work_in_progress (); + void reap_complete_writes (); + bool reload_read_buffer (); + bool submit_lut (libusb_transfer *lut); + + +protected: + int d_endpoint; + bool d_input_p; + int d_block_size; + int d_nblocks; + bool d_started; + +public: + fusb_ephandle (fusb_devhandle *dh, int endpoint, bool input_p, + int block_size = 0, int nblocks = 0); + ~fusb_ephandle(); + + bool start (); //!< begin streaming i/o + + int write (const void *buffer, int nbytes); + + int read (void *buffer, int nbytes); + + void free_list_add (struct libusb_transfer *lut); + void completed_list_add (struct libusb_transfer *lut); + struct libusb_transfer *free_list_get (); + struct libusb_transfer *completed_list_get (); + + // accessor to work from callback context + fusb_devhandle* get_fusb_devhandle () const { + return d_devhandle; + } + + +public: + fusb_ephandle (int endpoint, bool input_p, + int block_size = 0, int nblocks = 0); + + int block_size () { return d_block_size; }; +}; + +static const int MAX_BLOCK_SIZE = 16 * 1024; // hard limit +static const int DEFAULT_BLOCK_SIZE = 4 * 1024; +static const int DEFAULT_BUFFER_SIZE = 4 * (1L << 20); // 1 MB + +/*! + * \brief factory for creating concrete instances of the appropriate subtype. + */ +class fusb { +public: + static fusb_devhandle *make_devhandle (libusb_device_handle *udh, + libusb_context *ctx = 0) + { return new fusb_devhandle (udh,ctx);} + + static int max_block_size () { return MAX_BLOCK_SIZE;} + + static int default_block_size () { return DEFAULT_BLOCK_SIZE;} + + static int default_buffer_size () { return DEFAULT_BUFFER_SIZE;} + +}; + +#endif /* _FUSB_H_ */ diff --git a/TransceiverRAD1/i2c.h b/TransceiverRAD1/i2c.h new file mode 100644 index 0000000..56f4c88 --- /dev/null +++ b/TransceiverRAD1/i2c.h @@ -0,0 +1,51 @@ +// I2C addresses + +#define I2C_DEV_EEPROM 0x50 // 24LC02[45]: 7-bits 1010xxx + +#define I2C_ADDR_BOOT (I2C_DEV_EEPROM | 0x0) +#define I2C_ADDR_TX_A (I2C_DEV_EEPROM | 0x4) +#define I2C_ADDR_RX_A (I2C_DEV_EEPROM | 0x5) +#define I2C_ADDR_TX_B (I2C_DEV_EEPROM | 0x6) +#define I2C_ADDR_RX_B (I2C_DEV_EEPROM | 0x7) + + +// format of FX2 BOOT EEPROM +// 00: 0xC0 code for ``Read IDs from EEPROM'' +// 01: 0xFE USB Vendor ID (LSB) +// 02: 0xFF USB Vendor ID (MSB) +// 03: 0x02 USB Product ID (LSB) +// 04: 0x00 USB Product ID (MSB) +// 05: 0x01 USB Device ID (LSB) // rev1 +// 06: 0x00 USB Device ID (MSB) // 0 = unconfig'd (no firmware) +// 07: 0x00 option byte + +// format of daughterboard EEPROM +// 00: 0xDB code for ``I'm a daughterboard'' +// 01: .. Daughterboard ID (LSB) +// 02: .. Daughterboard ID (MSB) +// 03: .. io bits 7-0 direction (bit set if it's an output from m'board) +// 04: .. io bits 15-8 direction (bit set if it's an output from m'board) +// 05: .. ADC0 DC offset correction (LSB) +// 06: .. ADC0 DC offset correction (MSB) +// 07: .. ADC1 DC offset correction (LSB) +// 08: .. ADC1 DC offset correction (MSB) +// ... +// 1f: .. negative of the sum of bytes [0x00, 0x1e] + +#define DB_EEPROM_MAGIC 0x00 +#define DB_EEPROM_MAGIC_VALUE 0xDB +#define DB_EEPROM_ID_LSB 0x01 +#define DB_EEPROM_ID_MSB 0x02 +#define DB_EEPROM_OE_LSB 0x03 +#define DB_EEPROM_OE_MSB 0x04 +#define DB_EEPROM_OFFSET_0_LSB 0x05 // offset correction for ADC or DAC 0 +#define DB_EEPROM_OFFSET_0_MSB 0x06 +#define DB_EEPROM_OFFSET_1_LSB 0x07 // offset correction for ADC or DAC 1 +#define DB_EEPROM_OFFSET_1_MSB 0x08 +#define DB_EEPROM_CHKSUM 0x1f + +#define DB_EEPROM_CLEN 0x20 // length of common portion of eeprom + +#define DB_EEPROM_CUSTOM_BASE DB_EEPROM_CLEN // first avail offset for + // daughterboard specific use + diff --git a/TransceiverRAD1/ids.h b/TransceiverRAD1/ids.h new file mode 100644 index 0000000..d3b15ba --- /dev/null +++ b/TransceiverRAD1/ids.h @@ -0,0 +1,36 @@ +#define USB_VID_CYPRESS 0x04b4 +#define USB_PID_CYPRESS_FX2 0x8613 + + +#define USB_VID_FSF 0xfffe // Free Software Folks +#define USB_PID_FSF_EXP_0 0x0000 // Experimental 0 +#define USB_PID_FSF_EXP_1 0x0001 // Experimental 1 +#define USB_PID_FSF_RAD1 0x0002 // Universal Software Radio Peripheral +#define USB_PID_FSF_RAD1_reserved 0x0003 // Universal Software Radio Peripheral +#define USB_PID_FSF_SSRP 0x0004 // Simple Software Radio Peripheral +#define USB_PID_FSF_SSRP_reserved 0x0005 // Simple Software Radio Peripheral +#define USB_PID_FSF_HPSDR 0x0006 // High Performance Software Defined Radio (Internal Boot) +#define USB_PID_FSF_HPSDR_HA 0x0007 // High Performance Software Defined Radio (Host Assisted Boot) +#define USB_PID_FSF_QS1R 0x0008 // QS1R HF receiver +#define USB_PID_FSF_EZDOP 0x0009 // ezdop +#define USB_PID_FSF_BDALE_0 0x000a // Bdale Garbee +#define USB_PID_FSF_BDALE_1 0x000b // Bdale Garbee +#define USB_PID_FSF_BDALE_2 0x000c // Bdale Garbee +#define USB_PID_FSF_BDALE_3 0x000d // Bdale Garbee +#define USB_PID_FSF_BDALE_4 0x000e // Bdale Garbee +#define USB_PID_FSF_BDALE_5 0x000f // Bdale Garbee +#define USB_PID_FSF_BDALE_6 0x0010 // Bdale Garbee +#define USB_PID_FSF_BDALE_7 0x0011 // Bdale Garbee +#define USB_PID_FSF_BDALE_8 0x0012 // Bdale Garbee +#define USB_PID_FSF_BDALE_9 0x0013 // Bdale Garbee +#define USB_PID_FSF_HPSDR_HERMES 0x0014 // HPSDR Hermes +#define USB_PID_FSF_THINKRF 0x0015 // Catalin Patulea +#define USB_PID_FSF_MSA 0x0016 // Hans de Bok Scotty's Modular Spectrum Analyzer + +#define USB_PID_FSF_LBNL_UXO 0x0018 // http://recycle.lbl.gov/~ldoolitt/uxo/ + + +#define USB_DID_RAD1_0 0x0000 // unconfigured rev 0 RAD1 +#define USB_DID_RAD1_1 0x0001 // unconfigured rev 1 RAD1 +#define USB_DID_RAD1_2 0x0002 // unconfigured rev 2 RAD1 + diff --git a/TransceiverRAD1/interfaces.h b/TransceiverRAD1/interfaces.h new file mode 100644 index 0000000..4fd76f1 --- /dev/null +++ b/TransceiverRAD1/interfaces.h @@ -0,0 +1,20 @@ +/* + * We've now split the RAD1 into 3 separate interfaces. + * + * Interface 0 contains only ep0 and is used for command and status. + * Interface 1 is the Tx path and it uses ep2 OUT BULK. + * Interface 2 is the Rx path and it uses ep6 IN BULK. + */ + +#define RAD1_CMD_INTERFACE 0 +#define RAD1_CMD_ALTINTERFACE 0 +#define RAD1_CMD_ENDPOINT 0 + +#define RAD1_TX_INTERFACE 1 +#define RAD1_TX_ALTINTERFACE 0 +#define RAD1_TX_ENDPOINT 2 // streaming data from host to FPGA + +#define RAD1_RX_INTERFACE 2 +#define RAD1_RX_ALTINTERFACE 0 +#define RAD1_RX_ENDPOINT 6 // streaming data from FPGA to host + diff --git a/TransceiverRAD1/radioDevice.h b/TransceiverRAD1/radioDevice.h new file mode 100644 index 0000000..456f278 --- /dev/null +++ b/TransceiverRAD1/radioDevice.h @@ -0,0 +1,115 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + +#ifndef __RADIO_DEVICE_H__ +#define __RADIO_DEVICE_H__ + + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/** a 64-bit virtual timestamp for radio data */ +typedef unsigned long long TIMESTAMP; + +/** A class to handle a USRP rev 4, with a two RFX900 daughterboards */ +class RadioDevice { + + public: + + /** Start the USRP */ + virtual bool start()=0; + + /** Stop the USRP */ + virtual bool stop()=0; + + /** + Read samples from the radio. + @param buf preallocated buf to contain read result + @param len number of samples desired + @param overrun Set if read buffer has been overrun, e.g. data not being read fast enough + @param timestamp The timestamp of the first samples to be read + @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough + @param RSSI The received signal strength of the read result + @return The number of samples actually read + */ + virtual int readSamples(short *buf, int len, bool *overrun, + TIMESTAMP timestamp, + bool *underrun, + unsigned *RSSI=NULL)=0; + /** + Write samples to the radio. + @param buf Contains the data to be written. + @param len number of samples to write. + @param underrun Set if radio does not have data to transmit, e.g. data not being sent fast enough + @param timestamp The timestamp of the first sample of the data buffer. + @param isControl Set if data is a control packet, e.g. a ping command + @return The number of samples actually written + */ + virtual int writeSamples(short *buf, int len, bool *underrun, + TIMESTAMP timestamp, + bool isControl=false)=0; + + /** Update the alignment between the read and write timestamps */ + virtual bool updateAlignment(TIMESTAMP timestamp)=0; + + /** Set the transmitter frequency */ + virtual bool setTxFreq(double wFreq, double wAdjFreq)=0; + + /** Set the receiver frequency */ + virtual bool setRxFreq(double wFreq, double wAdjFreq)=0; + + /** Returns the starting write Timestamp*/ + virtual TIMESTAMP initialWriteTimestamp(void)=0; + + /** Returns the starting read Timestamp*/ + virtual TIMESTAMP initialReadTimestamp(void)=0; + + /** returns the full-scale transmit amplitude **/ + virtual double fullScaleInputValue()=0; + + /** returns the full-scale receive amplitude **/ + virtual double fullScaleOutputValue()=0; + + /** sets the receive chan gain, returns the gain setting **/ + virtual double setRxGain(double dB)=0; + + /** gets the current receive gain **/ + virtual double getRxGain(void)=0; + + /** return maximum Rx Gain **/ + virtual double maxRxGain(void) = 0; + + /** return minimum Rx Gain **/ + virtual double minRxGain(void) = 0; + + /** sets the transmit chan gain, returns the gain setting **/ + virtual double setTxGain(double dB)=0; + + /** return maximum Tx Gain **/ + virtual double maxTxGain(void) = 0; + + /** return minimum Tx Gain **/ + virtual double minTxGain(void) = 0; + + /** Return internal status values */ + virtual double getTxFreq()=0; + virtual double getRxFreq()=0; + virtual double getSampleRate()=0; + virtual double numberRead()=0; + virtual double numberWritten()=0; + +}; + +#endif diff --git a/TransceiverRAD1/radioInterface.cpp b/TransceiverRAD1/radioInterface.cpp new file mode 100644 index 0000000..fa03a03 --- /dev/null +++ b/TransceiverRAD1/radioInterface.cpp @@ -0,0 +1,316 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +//#define NDEBUG +#include "radioInterface.h" +#include + + +GSM::Time VectorQueue::nextTime() const +{ + GSM::Time retVal; + ScopedLock lock(mLock); + while (mQ.size()==0) mWriteSignal.wait(mLock); + return mQ.top()->time(); +} + +radioVector* VectorQueue::getStaleBurst(const GSM::Time& targTime) +{ + ScopedLock lock(mLock); + if ((mQ.size()==0)) { + return NULL; + } + if (mQ.top()->time() < targTime) { + radioVector* retVal = mQ.top(); + mQ.pop(); + return retVal; + } + return NULL; +} + + +radioVector* VectorQueue::getCurrentBurst(const GSM::Time& targTime) +{ + ScopedLock lock(mLock); + if ((mQ.size()==0)) { + return NULL; + } + if (mQ.top()->time() == targTime) { + radioVector* retVal = mQ.top(); + mQ.pop(); + return retVal; + } + return NULL; +} + + + +RadioInterface::RadioInterface(RadioDevice *wRadio, + int wReceiveOffset, + int wRadioOversampling, + int wTransceiverOversampling, + GSM::Time wStartTime) + +{ + underrun = false; + + sendCursor = 0; + rcvCursor = 0; + mOn = false; + + mRadio = wRadio; + receiveOffset = wReceiveOffset; + samplesPerSymbol = wRadioOversampling; + mClock.set(wStartTime); + powerScaling = 1.0; +} + +RadioInterface::~RadioInterface(void) { + if (rcvBuffer!=NULL) delete rcvBuffer; + //mReceiveFIFO.clear(); +} + +double RadioInterface::fullScaleInputValue(void) { + return mRadio->fullScaleInputValue(); +} + +double RadioInterface::fullScaleOutputValue(void) { + return mRadio->fullScaleOutputValue(); +} + + +void RadioInterface::setPowerAttenuation(double dBAtten) +{ + float HWdBAtten = mRadio->setTxGain(-dBAtten); + dBAtten -= (-HWdBAtten); + float linearAtten = powf(10.0F,0.1F*dBAtten); + if (linearAtten < 1.0) + powerScaling = 1.0; + else + powerScaling = 1.0/sqrt(linearAtten); + LOG(INFO) << "setting HW gain to " << HWdBAtten << " and power scaling to " << powerScaling; +} + + +short *RadioInterface::radioifyVector(signalVector &wVector, short *retVector, double scale, bool zeroOut) +{ + + + signalVector::iterator itr = wVector.begin(); + short *shortItr = retVector; + if (zeroOut) { + while (itr < wVector.end()) { + *shortItr++ = 0; + *shortItr++ = 0; + itr++; + } + } + else if (scale != 1.0) { + while (itr < wVector.end()) { + *shortItr++ = (short) (itr->real()*scale); + *shortItr++ = (short) (itr->imag()*scale); + itr++; + } + } + else { + while (itr < wVector.end()) { + *shortItr++ = (short) (itr->real()); + *shortItr++ = (short) (itr->imag()); + itr++; + } + } + + return retVector; + +} + +void RadioInterface::unRadioifyVector(short *shortVector, signalVector& newVector) +{ + + signalVector::iterator itr = newVector.begin(); + short *shortItr = shortVector; + while (itr < newVector.end()) { + *itr++ = Complex(*shortItr,*(shortItr+1)); + //LOG(DEBUG) << (*(itr-1)); + shortItr += 2; + } + +} + + +bool started = false; + +void RadioInterface::pushBuffer(void) { + + if (sendCursor < 2*INCHUNK*samplesPerSymbol) return; + + // send resampleVector + int samplesWritten = mRadio->writeSamples(sendBuffer, + INCHUNK*samplesPerSymbol, + &underrun, + writeTimestamp); + //LOG(DEBUG) << "writeTimestamp: " << writeTimestamp << ", samplesWritten: " << samplesWritten; + + writeTimestamp += (TIMESTAMP) samplesWritten; + + if (sendCursor > 2*samplesWritten) + memcpy(sendBuffer,sendBuffer+samplesWritten*2,sizeof(short)*2*(sendCursor-2*samplesWritten)); + sendCursor = sendCursor - 2*samplesWritten; +} + + +void RadioInterface::pullBuffer(void) +{ + + bool localUnderrun; + + // receive receiveVector + short* shortVector = rcvBuffer+rcvCursor; + //LOG(DEBUG) << "Reading USRP samples at timestamp " << readTimestamp; + int samplesRead = mRadio->readSamples(shortVector,OUTCHUNK*samplesPerSymbol,&overrun,readTimestamp,&localUnderrun); + underrun |= localUnderrun; + readTimestamp += (TIMESTAMP) samplesRead; + while (samplesRead < OUTCHUNK*samplesPerSymbol) { + int oldSamplesRead = samplesRead; + samplesRead += mRadio->readSamples(shortVector+2*samplesRead, + OUTCHUNK*samplesPerSymbol-samplesRead, + &overrun, + readTimestamp, + &localUnderrun); + underrun |= localUnderrun; + readTimestamp += (TIMESTAMP) (samplesRead - oldSamplesRead); + } + //LOG(DEBUG) << "samplesRead " << samplesRead; + + rcvCursor += samplesRead*2; + +} + +bool RadioInterface::tuneTx(double freq, double adjFreq) +{ + return mRadio->setTxFreq(freq, adjFreq); +} + +bool RadioInterface::tuneRx(double freq, double adjFreq) +{ + return mRadio->setRxFreq(freq, adjFreq); +} + + +void RadioInterface::start() +{ + LOG(INFO) << "starting radio interface..."; + mAlignRadioServiceLoopThread.start((void * (*)(void*))AlignRadioServiceLoopAdapter, + (void*)this); + writeTimestamp = mRadio->initialWriteTimestamp(); + readTimestamp = mRadio->initialReadTimestamp(); + mRadio->start(); + LOG(DEBUG) << "Radio started"; + mRadio->updateAlignment(writeTimestamp-10000); + mRadio->updateAlignment(writeTimestamp-10000); + + sendBuffer = new short[2*2*INCHUNK*samplesPerSymbol]; + rcvBuffer = new short[2*2*OUTCHUNK*samplesPerSymbol]; + + mOn = true; + +} + +void *AlignRadioServiceLoopAdapter(RadioInterface *radioInterface) +{ + while (1) { + radioInterface->alignRadio(); + pthread_testcancel(); + } + return NULL; +} + +void RadioInterface::alignRadio() { + sleep(60); + mRadio->updateAlignment(writeTimestamp+ (TIMESTAMP) 10000); +} + +void RadioInterface::driveTransmitRadio(signalVector &radioBurst, bool zeroBurst) { + + if (!mOn) return; + + radioifyVector(radioBurst, sendBuffer+sendCursor, powerScaling, zeroBurst); + + sendCursor += (radioBurst.size()*2); + + pushBuffer(); +} + +void RadioInterface::driveReceiveRadio() { + + if (!mOn) return; + + if (mReceiveFIFO.size() > 8) return; + + pullBuffer(); + + GSM::Time rcvClock = mClock.get(); + rcvClock.decTN(receiveOffset); + unsigned tN = rcvClock.TN(); + int rcvSz = rcvCursor/2; + int readSz = 0; + const int symbolsPerSlot = gSlotLen + 8; + + // while there's enough data in receive buffer, form received + // GSM bursts and pass up to Transceiver + // Using the 157-156-156-156 symbols per timeslot format. + while (rcvSz > (symbolsPerSlot + (tN % 4 == 0))*samplesPerSymbol) { + signalVector rxVector((symbolsPerSlot + (tN % 4 == 0))*samplesPerSymbol); + unRadioifyVector(rcvBuffer+readSz*2,rxVector); + GSM::Time tmpTime = rcvClock; + if (rcvClock.FN() >= 0) { + //LOG(DEBUG) << "FN: " << rcvClock.FN(); + radioVector *rxBurst = NULL; + if (!loadTest) + rxBurst = new radioVector(rxVector,tmpTime); + else { + if (tN % 4 == 0) + rxBurst = new radioVector(*finalVec9,tmpTime); + else + rxBurst = new radioVector(*finalVec,tmpTime); + } + mReceiveFIFO.put(rxBurst); + } + mClock.incTN(); + rcvClock.incTN(); + //if (mReceiveFIFO.size() >= 16) mReceiveFIFO.wait(8); + //LOG(DEBUG) << "receiveFIFO: wrote radio vector at time: " << mClock.get() << ", new size: " << mReceiveFIFO.size() ; + readSz += (symbolsPerSlot+(tN % 4 == 0))*samplesPerSymbol; + rcvSz -= (symbolsPerSlot+(tN % 4 == 0))*samplesPerSymbol; + + tN = rcvClock.TN(); + } + + if (readSz > 0) { + memcpy(rcvBuffer,rcvBuffer+2*readSz,sizeof(short)*2*(rcvCursor-readSz)); + rcvCursor = rcvCursor-2*readSz; + } +} + diff --git a/TransceiverRAD1/radioInterface.h b/TransceiverRAD1/radioInterface.h new file mode 100644 index 0000000..6ec58ae --- /dev/null +++ b/TransceiverRAD1/radioInterface.h @@ -0,0 +1,243 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#include "sigProcLib.h" +#include "GSMCommon.h" +#include "LinkedLists.h" +#include "radioDevice.h" + +/** samples per GSM symbol */ +#define SAMPSPERSYM 1 +#define INCHUNK (625) +#define OUTCHUNK (625) + +/** class used to organize GSM bursts by GSM timestamps */ +class radioVector : public signalVector { + +private: + + GSM::Time mTime; ///< the burst's GSM timestamp + +public: + /** constructor */ + radioVector(const signalVector& wVector, + GSM::Time& wTime): signalVector(wVector),mTime(wTime) {}; + + /** timestamp read and write operators */ + GSM::Time time() const { return mTime;} + void time(const GSM::Time& wTime) { mTime = wTime;} + + /** comparison operator, used for sorting */ + bool operator>(const radioVector& other) const {return mTime > other.mTime;} + +}; + +/** a priority queue of radioVectors, i.e. GSM bursts, sorted so that earliest element is at top */ +class VectorQueue : public InterthreadPriorityQueue { + +public: + + /** the top element of the queue */ + GSM::Time nextTime() const; + + /** + Get stale burst, if any. + @param targTime The target time. + @return Pointer to burst older than target time, removed from queue, or NULL. + */ + radioVector* getStaleBurst(const GSM::Time& targTime); + + /** + Get current burst, if any. + @param targTime The target time. + @return Pointer to burst at the target time, removed from queue, or NULL. + */ + radioVector* getCurrentBurst(const GSM::Time& targTime); + + +}; + +/** a FIFO of radioVectors */ +class VectorFIFO { + +private: + + PointerFIFO mQ; + Mutex mLock; + +public: + + unsigned size() {return mQ.size();} + + void put(radioVector *ptr) {ScopedLock lock(mLock); mQ.put((void*) ptr);} + + radioVector *get() { ScopedLock lock(mLock); return (radioVector*) mQ.get();} + +}; + + +/** the basestation clock class */ +class RadioClock { + +private: + + GSM::Time mClock; + Mutex mLock; + Signal updateSignal; + +public: + + /** Set clock */ + //void set(const GSM::Time& wTime) { ScopedLock lock(mLock); mClock = wTime; updateSignal.signal();} + void set(const GSM::Time& wTime) { ScopedLock lock(mLock); mClock = wTime; updateSignal.broadcast();;} + + /** Increment clock */ + //void incTN() { ScopedLock lock(mLock); mClock.incTN(); updateSignal.signal();} + void incTN() { ScopedLock lock(mLock); mClock.incTN(); updateSignal.broadcast();} + + /** Get clock value */ + GSM::Time get() { ScopedLock lock(mLock); return mClock; } + + /** Wait until clock has changed */ + //void wait() {ScopedLock lock(mLock); updateSignal.wait(mLock,1);} + // FIXME -- If we take away the timeout, a lot of threads don't start. Why? + void wait() {ScopedLock lock(mLock); updateSignal.wait(mLock);} + +}; + + +/** class to interface the transceiver with the USRP */ +class RadioInterface { + +private: + + Thread mAlignRadioServiceLoopThread; ///< thread that synchronizes transmit and receive sections + + VectorFIFO mReceiveFIFO; ///< FIFO that holds receive bursts + + RadioDevice *mRadio; ///< the USRP object + + short *sendBuffer; //[2*2*INCHUNK]; + unsigned sendCursor; + + short *rcvBuffer; //[2*2*OUTCHUNK]; + unsigned rcvCursor; + + bool underrun; ///< indicates writes to USRP are too slow + bool overrun; ///< indicates reads from USRP are too slow + TIMESTAMP writeTimestamp; ///< sample timestamp of next packet written to USRP + TIMESTAMP readTimestamp; ///< sample timestamp of next packet read from USRP + + RadioClock mClock; ///< the basestation clock! + + int samplesPerSymbol; ///< samples per GSM symbol + int receiveOffset; ///< offset b/w transmit and receive GSM timestamps, in timeslots + int mRadioOversampling; + int mTransceiverOversampling; + + bool mOn; ///< indicates radio is on + + double powerScaling; + + bool loadTest; + int mNumARFCNs; + signalVector *finalVec, *finalVec9; + + /** format samples to USRP */ + short *radioifyVector(signalVector &wVector, short *shortVector, double scale, bool zeroOut); + + /** format samples from USRP */ + void unRadioifyVector(short *shortVector, signalVector &wVector); + + /** push GSM bursts into the transmit buffer */ + void pushBuffer(void); + + /** pull GSM bursts from the receive buffer */ + void pullBuffer(void); + +public: + + /** start the interface */ + void start(); + + /** constructor */ + RadioInterface(RadioDevice* wRadio = NULL, + int receiveOffset = 3, + int wRadioOversampling = SAMPSPERSYM, + int wTransceiverOversampling = SAMPSPERSYM, + GSM::Time wStartTime = GSM::Time(0)); + + /** destructor */ + ~RadioInterface(); + + void setSamplesPerSymbol(int wSamplesPerSymbol) {if (!mOn) samplesPerSymbol = wSamplesPerSymbol;} + + int getSamplesPerSymbol() { return samplesPerSymbol;} + + /** check for underrun, resets underrun value */ + bool isUnderrun() { bool retVal = underrun; underrun = false; return retVal;} + + /** attach an existing USRP to this interface */ + void attach(RadioDevice *wRadio, int wRadioOversampling) {if (!mOn) {mRadio = wRadio; mRadioOversampling = SAMPSPERSYM;} } + + /** return the receive FIFO */ + VectorFIFO* receiveFIFO() { return &mReceiveFIFO;} + + /** return the basestation clock */ + RadioClock* getClock(void) { return &mClock;}; + + /** set receive gain */ + double setRxGain(double dB) {if (mRadio) return mRadio->setRxGain(dB); else return -1;} + + /** get receive gain */ + double getRxGain(void) {if (mRadio) return mRadio->getRxGain(); else return -1;} + + + /** set transmit frequency */ + bool tuneTx(double freq, double adjFreq); + + /** set receive frequency */ + bool tuneRx(double freq, double adjFreq); + + /** drive transmission of GSM bursts */ + void driveTransmitRadio(signalVector &radioBurst, bool zeroBurst); + + /** drive reception of GSM bursts */ + void driveReceiveRadio(); + + void setPowerAttenuation(double atten); + + /** returns the full-scale transmit amplitude **/ + double fullScaleInputValue(); + + /** returns the full-scale receive amplitude **/ + double fullScaleOutputValue(); + + +protected: + + /** drive synchronization of Tx/Rx of USRP */ + void alignRadio(); + + /** reset the interface */ + void reset(); + + friend void *AlignRadioServiceLoopAdapter(RadioInterface*); + +}; + +/** synchronization thread loop */ +void *AlignRadioServiceLoopAdapter(RadioInterface*); diff --git a/TransceiverRAD1/rnrad1.h b/TransceiverRAD1/rnrad1.h new file mode 100644 index 0000000..fe46485 --- /dev/null +++ b/TransceiverRAD1/rnrad1.h @@ -0,0 +1,162 @@ +#ifndef RNRAD1_H +#define RNRAD1_H + +class rnrad1Tx; +class rnrad1Rx; + +#include "rnrad1Core.h" + + +class rnrad1Rx : public rnrad1Core +{ + private: + + unsigned int mDecimRate; + int mSwMux; + int mHwMux; + double mRxFreq; + + fusb_devhandle *mDevHandle; + fusb_ephandle *mEndptHandle; + int mBytesSeen; // how many bytes we've seen + bool mFirstRead; + bool mEnabled; + + protected: + + rnrad1Rx (int whichBoard, + unsigned int wDecimRate, + const std::string fpgaFilename, + const std::string firmwareFilename); + + bool writeHwMuxReg(); + bool enable(bool on); + bool enable () const { return mEnabled; } + + bool disable(); // conditional disable, return prev state + void restore(bool on); // conditional set + +public: + + ~rnrad1Rx (); + + static rnrad1Rx* make(int whichBoard, + unsigned int wDecimRate, + const std::string fpgaFilename, + const std::string firmwareFilename); + + bool setDecimRate (unsigned int rate); + + bool setMux (int mux); + + bool setRxFreq (double freq); + + double rxFreq(void) {return mRxFreq;} + + bool start(); + + bool setSampleRateDivisor (unsigned int div); + + int read (void *buf, int len, bool *overrun); + + long adcRate() const { return fpgaMasterClockFreq(); } + + bool setPga (int which_amp, double gain_in_db); + double pga (int which_amp) const; + double pgaMin () const {return 0.0;} + double pgaMax () const {return 20.0;} + double pgaDbPerStep () const {return 20.0/20.0;} + + bool writeOE (int value, int mask); + bool writeIO (int value, int mask); + bool readIO (int *value); + int readIO (void); + bool writeRefClk(int value); + + bool writeAuxDac (int which_dac, int value); + bool readAuxAdc (int which_adc, int *value); + int readAuxAdc (int which_adc); + + int blockSize() const; +}; + + +class rnrad1Tx: public rnrad1Core +{ + + public: + + private: + fusb_devhandle *mDevHandle; + fusb_ephandle *mEndptHandle; + int mBytesSeen; // how many bytes we've seen + bool mFirstWrite; + bool mEnabled; + + unsigned int mInterpRate; + int mSwMux; + int mHwMux; + double mTxFreq; + unsigned char mTxModulatorShadow; + + protected: + + rnrad1Tx (int which_board, + unsigned int wInterpRate, + const std::string fpgaFilename, + const std::string firmwareFilename); + + bool enable (bool on); + bool enable () const { return mEnabled; } + + bool disable(); // conditional disable, return prev state + void restore(bool on); // conditional set + + bool writeHwMuxReg(); + +public: + + bool setSampleRateDivisor (unsigned int div); + + int write (const void *buf, int len, bool *underrun); + + long dacRate() const { return 2*fpgaMasterClockFreq(); } + + bool setPga (int which_amp, double gain_in_db); + double pga (int which_amp) const; + double pgaMin () const {return -20.0;} + double pgaMax () const {return 0.0;} + double pgaDbPerStep () const {return 20.0/255.0;} + + bool writeOE (int value, int mask); + bool writeIO (int value, int mask); + bool readIO (int *value); + int readIO (void); + bool writeRefClk(int value); + + bool writeAuxDac (int which_dac, int value); + bool readAuxAdc (int which_adc, int *value); + int readAuxAdc (int which_adc); + + int blockSize() const; + + ~rnrad1Tx (); + + static rnrad1Tx* make(int which_board, + unsigned int wInterpRate, + const std::string fpga_filename, + const std::string firmware_filename); + + bool setInterpRate (unsigned int rate); + + bool setMux (int mux); + + bool setTxFreq (double freq); + + double txFreq(void) {return mTxFreq;} + + bool start(); +}; + + +#endif diff --git a/TransceiverRAD1/rnrad1Core.cpp b/TransceiverRAD1/rnrad1Core.cpp new file mode 100644 index 0000000..4c6bdef --- /dev/null +++ b/TransceiverRAD1/rnrad1Core.cpp @@ -0,0 +1,963 @@ +/* +* Copyright 2011 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "rnrad1Core.h" + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "fpga_regs.h" +#include +#include +#include +#include "ad9862.h" +#include + +using namespace ad9862; + +static const double POLLING_INTERVAL = 0.1; // seconds + +static const char *_get_usb_error_str (int usb_err) +{ + switch (usb_err) { + case LIBUSB_SUCCESS: return "Success (no error)"; + case LIBUSB_ERROR_IO: return "Input/output error"; + case LIBUSB_ERROR_INVALID_PARAM: return "Invalid parameter"; + case LIBUSB_ERROR_ACCESS: return "Access denied (insufficient permissions)"; + case LIBUSB_ERROR_NO_DEVICE: return "No such device (it may have been disconnected)"; + case LIBUSB_ERROR_NOT_FOUND: return "Entity not found"; + case LIBUSB_ERROR_BUSY: return "Resource busy"; + case LIBUSB_ERROR_TIMEOUT: return "Operation timed out"; + case LIBUSB_ERROR_OVERFLOW: return "Overflow"; + case LIBUSB_ERROR_PIPE: return "Pipe error"; + case LIBUSB_ERROR_INTERRUPTED: return "System call interrupted (perhaps due to signal)"; + case LIBUSB_ERROR_NO_MEM: return "Insufficient memory"; + case LIBUSB_ERROR_NOT_SUPPORTED: return "Operation not supported or unimplemented on this platform"; + case LIBUSB_ERROR_OTHER: return "Unknown error"; + } + + return "Unknown error"; +} + +int usbMsg (struct libusb_device_handle *udh, + int request, int value, int index, + unsigned char *bytes, int len) +{ + int requesttype = (request & 0x80) ? VRT_VENDOR_IN : VRT_VENDOR_OUT; + + int ret = libusb_control_transfer(udh, requesttype, request, value, index, + bytes, len, 1000); + + if (ret < 0) { + // we get EPIPE if the firmware stalls the endpoint. + if (ret != LIBUSB_ERROR_PIPE) { + LOG(ALERT) << "libusb_control_transfer failed: " << _get_usb_error_str(ret); + } + } + + return ret; +} + + +struct libusb_device_handle *rad1OpenInterface (libusb_device *dev, int interface, int altinterface) +{ + libusb_device_handle *udh; + int ret; + + if (libusb_open (dev, &udh) < 0) return NULL; + + if (dev != libusb_get_device (udh)){ + LOG(ERR) << "Can't get USB device"; + exit(0); + } + + if ((ret = libusb_claim_interface (udh, interface)) < 0) { + LOG(ERR) << "Can't claim USB interface: " << interface << " bc: " << _get_usb_error_str(ret); + libusb_close (udh); + return NULL; + } + + if ((ret = libusb_set_interface_alt_setting (udh, interface, + altinterface)) < 0) { + LOG(ERR) << "Can't set USB alt interface: " << altinterface << " bc: " << _get_usb_error_str(ret); + libusb_release_interface (udh, interface); + libusb_close (udh); + return NULL; + } + + return udh; +} + + +static const int FIRMWARE_HASH_SLOT = 0; +static const int FPGA_HASH_SLOT = 1; + +static const int hashSlotAddr[2] = { + RAD1_HASH_SLOT_0_ADDR, + RAD1_HASH_SLOT_1_ADDR +}; + + +bool rad1GetHash (libusb_device_handle *udh, int which, + unsigned char hash[RAD1_HASH_SIZE]) +{ + which &= 1; + + // we use the Cypress firmware upload command to fetch it. + int r = libusb_control_transfer (udh, 0xc0, 0xa0, hashSlotAddr[which], 0, + (unsigned char *) hash, RAD1_HASH_SIZE, 1000); + + if (r < 0) { + LOG(ERR) << "Failed to get hash, USB err: " << _get_usb_error_str(r); + } + + return r == RAD1_HASH_SIZE; +} + +struct libusb_device *rad1FindDevice (int nth, bool allowFx2, libusb_context *ctx) +{ + libusb_device **list; + + struct libusb_device *q; + int nFound = 0; + + size_t cnt = libusb_get_device_list(ctx, &list); + size_t i = 0; + + if (cnt < 0) + LOG(ERR) << "libusb_get_device_list failed: " <<_get_usb_error_str(cnt); + + for (i = 0; i < cnt; i++) { + q = list[i]; + libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(q, &desc); + if (ret < 0) { + LOG(ERR) << "usb_get_device_descriptor failed: " <<_get_usb_error_str(ret); + } + + if ((desc.idVendor == USB_VID_FSF && desc.idProduct == USB_PID_FSF_RAD1) || + (allowFx2 && desc.idVendor == USB_VID_CYPRESS && desc.idProduct == USB_PID_CYPRESS_FX2)) { + if (nFound == nth) // return this one + return q; + nFound++; // keep looking + } + } + + // The list needs to be freed. Right now just release it if nothing is found. + libusb_free_device_list(list, 1); + + return 0; // not found +} + +static libusb_device_handle *openNthCmdInterface (int nth, libusb_context *ctx) +{ + + libusb_device *udev = rad1FindDevice (nth, false, ctx); + if (udev == 0){ + LOG(ERR) << "Failed to find rad1 num " << nth; + return 0; + } + + libusb_device_handle *udh; + + udh = rad1OpenInterface (udev, RAD1_CMD_INTERFACE, RAD1_CMD_ALTINTERFACE); + if (udh == 0){ + LOG(ERR) << "Can't open_cmd_interface"; + return 0; + } + + return udh; +} + +enum rad1LoadStatus { ULS_ERROR = 0, ULS_OK, ULS_ALREADY_LOADED }; + +bool rad1SetHash (libusb_device_handle *udh, int which, + const unsigned char hash[RAD1_HASH_SIZE]) +{ + which &= 1; + + // we use the Cypress firmware down load command to jam it in. + int r = libusb_control_transfer (udh, 0x40, 0xa0, hashSlotAddr[which], 0, + (unsigned char *) hash, RAD1_HASH_SIZE, 1000); + + if (r < 0) { + LOG(ERR) << "Failed to set hash bc: " << _get_usb_error_str(r); + } + + return r == RAD1_HASH_SIZE; +} + +static bool writeRam (libusb_device_handle *udh, unsigned char *buf, + int startAddr, size_t len) +{ + int addr; + int n; + int a; + int quanta = MAX_EP0_PKTSIZE; + + for (addr = startAddr; addr < startAddr + (int) len; addr += quanta){ + n = len + startAddr - addr; + if (n > quanta) + n = quanta; + + a = libusb_control_transfer(udh, 0x40, 0xA0, addr, 0, + (unsigned char*)(buf + (addr - startAddr)), n, 1000); + + if (a < 0){ + LOG(ERR) << "Write to RAM failed bc: " << _get_usb_error_str(a); + return false; + } + } + return true; +} + +// Load intel format file into cypress FX2 (8051) + +bool rad1LoadFirmware (libusb_device_handle *udh, const char *filename, + unsigned char hash[RAD1_HASH_SIZE]) +{ + FILE *f = fopen (filename, "ra"); + if (f == 0){ + perror (filename); + return false; + } + + // hold CPU in reset while loading firmware + unsigned char reset = 1; + if (!writeRam (udh, &reset, 0xE600, 1)) + goto fail; + + + char s[1024]; + int length; + int addr; + int type; + unsigned char data[256]; + unsigned char checksum, a; + unsigned int b; + int i; + + while (!feof(f)){ + fgets(s, sizeof (s), f); /* we should not use more than 263 bytes normally */ + if(s[0]!=':'){ + LOG(ERR) "File " << filename << " has invalid line: " << s; + goto fail; + } + sscanf(s+1, "%02x", &length); + sscanf(s+3, "%04x", &addr); + sscanf(s+7, "%02x", &type); + + if(type==0){ + a=length+(addr &0xff)+(addr>>8)+type; + for(i=0;i 0){ + if (usbMsg (udh, VRQ_FPGA_LOAD, 0, FL_XFER, buf, n) != n) + goto fail; + } + + if (usbMsg (udh, VRQ_FPGA_LOAD, 0, FL_END, 0, 0) != 0) + goto fail; + + fclose (fp); + + if (!rad1SetHash (udh, FPGA_HASH_SLOT, hash)) + LOG(ERR) << "Failed to write FPGA hash"; + + // On the rev1 RAD1, the {tx,rx}_{enable,reset} bits are + // controlled over the serial bus, and hence aren't observed until + // we've got a good fpga bitstream loaded. + usbMsg(udh, VRQ_FPGA_SET_RESET, 0, 0, 0, 0); // fpga out of master reset + + // now these commands will work + ok &= (usbMsg(udh, VRQ_FPGA_SET_TX_ENABLE, 0, 0, 0, 0)!=0); + ok &= (usbMsg(udh, VRQ_FPGA_SET_RX_ENABLE, 0, 0, 0, 0)!=0); + ok &= (usbMsg(udh, VRQ_FPGA_SET_TX_RESET , 1, 0, 0, 0)!=0); + ok &= (usbMsg(udh, VRQ_FPGA_SET_RX_RESET , 1, 0, 0, 0)!=0); + ok &= (usbMsg(udh, VRQ_FPGA_SET_TX_RESET , 0, 0, 0, 0)!=0); + ok &= (usbMsg(udh, VRQ_FPGA_SET_RX_RESET , 0, 0, 0, 0)!=0); + + if (!ok) + LOG(ERR) << "Failed to reset TX/RX path"; + + // Manually reset all regs except master control to zero. + // FIXME may want to remove this when we rework FPGA reset strategy. + // In the mean while, this gets us reproducible behavior. + // FIXME!!! + + for (int i = 0; i < FR_USER_0; i++){ + if (i == FR_MASTER_CTRL) + continue; + buf[0] = (0 >> 24) & 0xff; // MSB first + buf[1] = (0 >> 16) & 0xff; + buf[2] = (0 >> 8) & 0xff; + buf[3] = (0 >> 0) & 0xff; + + usbMsg (udh, VRQ_SPI_WRITE, + 0x00 | (i & 0x7f), + ((SPI_ENABLE_FPGA & 0xff) << 8) | ((SPI_FMT_MSB | SPI_FMT_HDR_1) & 0xff), + buf, 4); + //rad1writeFpgaReg(udh, i, 0); + } + + + usbMsg (udh, VRQ_SET_LED, 1, 0, 0, 0); // led 1 off + + return true; + + fail: + fclose (fp); + return false; +} + +bool computeHash (const char *filename, unsigned char hash[RAD1_HASH_SIZE]) +{ + assert (RAD1_HASH_SIZE == 16); + memset (hash, 0, RAD1_HASH_SIZE); + + FILE *fp = fopen (filename, "rb"); + if (fp == 0){ + perror (filename); + return false; + } + int i = 0; + while (!feof(fp)) {getc(fp);i++;} + sprintf((char *)hash,"%d",i); + //int r = md5_stream (fp, (void*) hash); + fclose (fp); + + return true; +} + +rad1LoadStatus rad1LoadFirmwareNth (int nth, const char *filename, bool force, libusb_context *ctx) +{ + libusb_device_handle *udh = openNthCmdInterface (nth, ctx); + if (udh == 0) + return ULS_ERROR; + + rad1LoadStatus s; + + unsigned char file_hash[RAD1_HASH_SIZE]; + unsigned char rad1_hash[RAD1_HASH_SIZE]; + + if (access (filename, R_OK) != 0){ + perror (filename); + s = ULS_ERROR; + } + else if (!computeHash (filename, file_hash)) + s = ULS_ERROR; + else if (!force + && rad1GetHash (udh, FIRMWARE_HASH_SLOT, rad1_hash) + && memcmp (file_hash, rad1_hash, RAD1_HASH_SIZE) == 0) { + //printf("hash: %s %s\n",file_hash,rad1_hash); + s = ULS_ALREADY_LOADED; + } + else if (!rad1LoadFirmware(udh, filename, file_hash)) + s = ULS_ERROR; + else + s = ULS_OK; + + libusb_close(udh); + + switch (s){ + + case ULS_ALREADY_LOADED: // nothing changed... + return ULS_ALREADY_LOADED; + break; + + case ULS_OK: + // we loaded firmware successfully. + + // It's highly likely that the board will renumerate (simulate a + // disconnect/reconnect sequence), invalidating our current + // handle. + + // FIXME. Turn this into a loop that rescans until we refind ourselves + + sleep(2); + + return ULS_OK; + + default: + case ULS_ERROR: // some kind of problem + return ULS_ERROR; + } +} + +static void load_status_msg (rad1LoadStatus s, const char *type, const char *filename) +{ + switch (s){ + case ULS_ERROR: + LOG(ERR) << "Failed to load " << type << " " << filename; + break; + + case ULS_ALREADY_LOADED: + //LOG(ERR) << "Failed to already loaded " << type << " " << filename; + break; + + case ULS_OK: + break; + } +} + + +bool rad1_load_standard_bits (int nth, bool force, + const std::string fpga_filename, + const std::string firmware_filename, + libusb_context *ctx) +{ + rad1LoadStatus s; + const char *filename; + const char *proto_filename; + int hw_rev; + + // start by loading the firmware + s = rad1LoadFirmwareNth (nth, firmware_filename.data(), force, ctx); + load_status_msg (s, "firmware", firmware_filename.data()); + + if (s == ULS_ERROR) + return false; + + // if we actually loaded firmware, we must reload fpga ... + if (s == ULS_OK) + force = true; + + libusb_device_handle *udh = openNthCmdInterface (nth, ctx); + if (udh == 0) + return false; + + unsigned char file_hash[RAD1_HASH_SIZE]; + unsigned char rad1_hash[RAD1_HASH_SIZE]; + + filename = fpga_filename.data(); + + if (access (filename, R_OK) != 0){ + perror (filename); + s = ULS_ERROR; + } + else if (!computeHash (filename, file_hash)) + s = ULS_ERROR; + else if (!force + && rad1GetHash (udh, FPGA_HASH_SLOT, rad1_hash) + && memcmp (file_hash, rad1_hash, RAD1_HASH_SIZE) == 0) { + s = ULS_ALREADY_LOADED; + //printf("hash: %s %s\n",file_hash,rad1_hash); + } + else if (!rad1LoadFpga(udh, filename, file_hash)) + s = ULS_ERROR; + else + s = ULS_OK; + + libusb_close(udh); + load_status_msg (s, "fpga bitstream", fpga_filename.data()); + + if (s == ULS_ERROR) + return false; + + return true; +} + +rnrad1Core::rnrad1Core (int which_board, + int interface, int altInterface, + const std::string fpga_filename = "", + const std::string firmware_filename = "", + bool skipLoad = false) +{ + mudh = 0; + mctx = 0; + mUsbDataRate = 16000000; + mBytesPerPoll = ((int) POLLING_INTERVAL*mUsbDataRate); + mFpgaMasterClockFreq = 52000000; + + memset (mFpgaShadows, 0, sizeof (mFpgaShadows)); + + if (libusb_init (&mctx) < 0) + LOG(ERR) << "libusb_init failed"; + + if (!skipLoad) { + if (!rad1_load_standard_bits (which_board, false, fpga_filename, + firmware_filename, mctx)) { + LOG(ERR) << "File load failed"; + exit(1); + } + } + + libusb_device *dev = rad1FindDevice (which_board, false, mctx); + if (dev == 0){ + LOG(ERR) << "Can't find RAD1 board " << which_board; + exit(1); + } + + libusb_device_descriptor desc; + int ret = libusb_get_device_descriptor(dev, &desc); + if (ret < 0) { + LOG(ERR) << "usb_get_device_descriptor failed: " <<_get_usb_error_str(ret); + } + + if ((desc.idVendor == USB_VID_FSF && desc.idProduct == USB_PID_FSF_RAD1) && ((desc.bcdDevice & 0xFF00) == 0)) { + fprintf (stderr, "found unconfigured RAD1; needs firmware.\n"); + } + + if (desc.idVendor == USB_VID_CYPRESS && desc.idProduct == USB_PID_CYPRESS_FX2){ + fprintf (stderr, "found unconfigured FX2; needs firmware.\n"); + } + + mudh = rad1OpenInterface (dev, interface, altInterface); + if (mudh == 0) { + LOG(ERR) << "Can't open interfaces"; + exit(1); + } + + // initialize registers that are common to rx and tx + bool result=true; + result &= write9862(REG_GENERAL,0); + result &= write9862(REG_DLL,DLL_DISABLE_INTERNAL_XTAL_OSC | DLL_MULT_2X | DLL_FAST); + result &= write9862(REG_CLKOUT,CLKOUT2_EQ_DLL_OVER_2); + result &= write9862(REG_AUX_ADC_CLK,AUX_ADC_CLK_CLK_OVER_4); + if (!result) { + LOG(ERR) << "Failed to set common MSFE regs"; + exit(1); + } + + writeFpgaReg (FR_MODE, 0); // ensure we're in normal mode + writeFpgaReg (FR_DEBUG_EN, 0); // disable debug outputs + } + + +rnrad1Core::~rnrad1Core () +{ + if (mudh) libusb_close(mudh); + if (mctx) libusb_exit(mctx); +} + +void rnrad1Core::setUsbDataRate (int usb_data_rate) { + mUsbDataRate = usb_data_rate; + mBytesPerPoll = (int) (usb_data_rate*POLLING_INTERVAL); +} + +int rnrad1Core::sendRqst (int request, bool flag) +{ + return usbMsg (mudh, request, flag, 0, 0, 0); +} + +int rnrad1Core::checkUnderrun(unsigned char *status) +{ + return usbMsg (mudh, VRQ_GET_STATUS, 0, GS_TX_UNDERRUN, + status, 1); +} + +int rnrad1Core::checkOverrun(unsigned char *status) +{ + return usbMsg (mudh, VRQ_GET_STATUS, 0, GS_RX_OVERRUN, + status, 1); +} + +bool rnrad1Core::writeI2c (int i2c_addr, unsigned char *buf, int len) +{ + if (len < 1 || len > MAX_EP0_PKTSIZE) + return false; + + return usbMsg (mudh, VRQ_I2C_WRITE, i2c_addr, 0, + buf, len) == len; +} + +bool rnrad1Core::readI2c (int i2c_addr, unsigned char *buf, int len) +{ + if (len <= 0) + return false; + + if (usbMsg (mudh, VRQ_I2C_READ, i2c_addr, 0, + (unsigned char *) buf, len) != len) + return false; + + return true; +} + +bool rnrad1Core::setAdcOffset (int which_adc, int offset) +{ + if (which_adc < 0 || which_adc > 3) + return false; + + return writeFpgaReg (FR_ADC_OFFSET_0 + which_adc, offset); +} + +bool rnrad1Core::setDacOffset (int which_dac, int offset, int offset_pin) +{ + int tx_a = (which_dac & 0x1) == 0; + int lo = ((offset & 0x3) << 6) | (offset_pin & 0x1); + int hi = (offset >> 2); + bool ok; + + if (tx_a){ + ok = write9862 (REG_TX_A_OFFSET_LO, lo); + ok &= write9862 (REG_TX_A_OFFSET_HI, hi); + } + else { + ok = write9862 (REG_TX_B_OFFSET_LO, lo); + ok &= write9862 (REG_TX_B_OFFSET_HI, hi); + } + + return ok; +} + +bool rnrad1Core::setAdcBufferBypass (int which_adc, bool bypass) +{ + if (which_adc < 0 || which_adc > 1) + return false; + + bool useA = (which_adc & 1) == 0; + int reg = useA ? REG_RX_A : REG_RX_B; + + unsigned char cur_rx; + unsigned char cur_pwr_dn; + + // If the input buffer is bypassed, we need to power it down too. + + bool ok = read9862 (reg, &cur_rx); + ok &= read9862 (REG_RX_PWR_DN, &cur_pwr_dn); + if (!ok) + return false; + + if (bypass){ + cur_rx |= RX_X_BYPASS_INPUT_BUFFER; + cur_pwr_dn |= (useA ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B); + } + else { + cur_rx &= ~RX_X_BYPASS_INPUT_BUFFER; + cur_pwr_dn &= ~(useA ? RX_PWR_DN_BUF_A : RX_PWR_DN_BUF_B); + } + + ok &= write9862 (reg, cur_rx); + ok &= write9862 (REG_RX_PWR_DN, cur_pwr_dn); + return ok; +} + +bool rnrad1Core::setDcOffsetClEnable(int bits, int mask) +{ + return writeFpgaReg(FR_DC_OFFSET_CL_EN, + (mFpgaShadows[FR_DC_OFFSET_CL_EN] & ~mask) | (bits & mask)); +} + +bool rnrad1Core::writeAuxDac (int which_dac, int value) +{ + if (!(0 <= which_dac && which_dac < 4)){ + LOG(ERR) << "Write to invalid dac" << which_dac; + return false; + } + + value &= 0x0fff; // mask to 12-bits + + // dac 0, 1, and 2 are really 8 bits. + value = value >> 4; // shift value appropriately + int regno = 36 + which_dac; + + return write9862(regno, value); +} + +bool rnrad1Core::readAuxAdc (bool isTx, int which_adc, int *value) +{ + *value = 0; + + unsigned char aux_adc_control = + AUX_ADC_CTRL_REFSEL_A // on chip reference + | AUX_ADC_CTRL_REFSEL_B; // on chip reference + + int rd_reg = 26; // base address of two regs to read for result + + // program the ADC mux bits + if (isTx) + aux_adc_control |= AUX_ADC_CTRL_SELECT_A2 | AUX_ADC_CTRL_SELECT_B2; + else { + rd_reg += 2; + aux_adc_control |= AUX_ADC_CTRL_SELECT_A1 | AUX_ADC_CTRL_SELECT_B1; + } + + // I'm not sure if we can set the mux and issue a start conversion + // in the same cycle, so let's do them one at a time. + write9862(34, aux_adc_control); + + if (which_adc == 0) + aux_adc_control |= AUX_ADC_CTRL_START_A; + else { + rd_reg += 4; + aux_adc_control |= AUX_ADC_CTRL_START_B; + } + + // start the conversion + write9862(34, aux_adc_control); + + // read the 10-bit result back + unsigned char v_lo = 0; + unsigned char v_hi = 0; + bool r = read9862(rd_reg, &v_lo); + r &= read9862(rd_reg, &v_hi); + + if (r) + *value = ((v_hi << 2) | ((v_lo >> 6) & 0x3)) << 2; // format as 12-bit + + return r; +} + +int rnrad1Core::readAuxAdc (bool isTx, int which_adc) +{ + int value; + if (!readAuxAdc (isTx, which_adc, &value)) + return READ_FAILED; + + return value; +} + + +bool rnrad1Core::writeEeprom (int i2c_addr, int eeprom_offset, const std::string buf) +{ + unsigned char cmd[2]; + const unsigned char *p = (unsigned char *) buf.data(); + + // The simplest thing that could possibly work: + // all writes are single byte writes. + // + // We could speed this up using the page write feature, + // but we write so infrequently, why bother... + + int len = buf.size(); + while (len-- > 0){ + cmd[0] = eeprom_offset++; + cmd[1] = *p++; + bool r = writeI2c (i2c_addr, cmd, 2); + usleep (10*1000); // delay 10ms worst case write time + if (!r) + return false; + } + + return true; +} + +std::string rnrad1Core::readEeprom (int i2c_addr, int eeprom_offset, int len) +{ + if (len <= 0) + return ""; + + char buf[len]; + + unsigned char *p = (unsigned char *) buf; + + // We setup a random read by first doing a "zero byte write". + // Writes carry an address. Reads use an implicit address. + + unsigned char cmd[1]; + cmd[0] = eeprom_offset; + if (!writeI2c(i2c_addr, cmd, 1)) return ""; + + int orig_len = len; + while (len > 0){ + int n = std::min (len, MAX_EP0_PKTSIZE); + if (!readI2c(i2c_addr, p, n)) {return "";} + len -= n; + p += n; + } + + return std::string (buf, orig_len); +} + +bool rnrad1Core::setLed (int which_led, bool on) +{ + int r = usbMsg (mudh, VRQ_SET_LED, on, which_led, 0, 0); + + return r == 0; +} + +bool rnrad1Core::writeFpgaReg (int regno, int value) //< 7-bit regno, 32-bit value +{ + + if (regno >= 0 && regno < MAX_REGS) + mFpgaShadows[regno] = value; + + unsigned char buf[4]; + + buf[0] = (value >> 24) & 0xff; // MSB first + buf[1] = (value >> 16) & 0xff; + buf[2] = (value >> 8) & 0xff; + buf[3] = (value >> 0) & 0xff; + + return writeSpi (0x00 | (regno & 0x7f), + SPI_ENABLE_FPGA, + SPI_FMT_MSB | SPI_FMT_HDR_1, + buf, 4); + +} + +bool rnrad1Core::readFpgaReg (int regno, int *value) //< 7-bit regno, 32-bit value +{ + *value = 0; + unsigned char buf[4]; + + bool ok = readSpi (0x80 | (regno & 0x7f), + SPI_ENABLE_FPGA, + SPI_FMT_MSB | SPI_FMT_HDR_1, + buf, 4); + + if (ok) + *value = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; + + return ok; +} + + +int rnrad1Core::readFpgaReg (int regno) +{ + int value; + if (!readFpgaReg (regno, &value)) + return READ_FAILED; + return value; +} + +bool rnrad1Core::write9862 (int regno, unsigned char value) +{ + unsigned char buf[1]; + + buf[0] = value; + + return writeSpi(0x00 | (regno & 0x3f), + SPI_ENABLE_CODEC_A, + SPI_FMT_MSB | SPI_FMT_HDR_1, + (unsigned char *) buf, 1); +} + +bool rnrad1Core::read9862 (int regno, unsigned char *value) const +{ + + return readSpi(0x80 | (regno & 0x3f), + SPI_ENABLE_CODEC_A, + SPI_FMT_MSB | SPI_FMT_HDR_1, + value, 1); +} + + +int rnrad1Core::read9862 (int regno) const +{ + unsigned char value; + if (!read9862 (regno, &value)) + return READ_FAILED; + return value; +} + + +bool rnrad1Core::writeSpi (int optional_header, int enables, int format, unsigned char *buf, int len) +{ + return (usbMsg (mudh, VRQ_SPI_WRITE, + optional_header, + ((enables & 0xff) << 8) | (format & 0xff), + buf, len) == len); +} + + +bool rnrad1Core::readSpi (int optional_header, int enables, int format, unsigned char *buf, int len) const +{ + if (len <= 0 || len > MAX_EP0_PKTSIZE) + return false; + + if (usbMsg (mudh, VRQ_SPI_READ, + optional_header, + ((enables & 0xff) << 8) | (format & 0xff), + (unsigned char *) buf, len) != len) + { return false;} + + return true; +} + + +bool rnrad1Core::start() +{ + return true; +} + diff --git a/TransceiverRAD1/rnrad1Core.h b/TransceiverRAD1/rnrad1Core.h new file mode 100644 index 0000000..93d328b --- /dev/null +++ b/TransceiverRAD1/rnrad1Core.h @@ -0,0 +1,131 @@ +#ifndef __RNRAD1CORE_H__ +#define __RNRAD1CORE_H__ + +#include "commands.h" +#include "fpga_regs.h" +#include "fusb.h" +#include "interfaces.h" +#include "spi.h" +#include "ids.h" +#include "ad9862.h" + +#include +#include +#include +#include +#include +#include + +#include "Logger.h" + +const int RAD1_HASH_SIZE = 16; + +int usbMsg (struct libusb_device_handle *udh, + int request, int value, int index, + unsigned char *bytes, int len); + +bool rad1GetHash (libusb_device_handle *udh, int which, + unsigned char hash[RAD1_HASH_SIZE]); + +bool rad1SetHash (libusb_device_handle *udh, int which, + const unsigned char hash[RAD1_HASH_SIZE]); + +bool rad1LoadFirmware (libusb_device_handle *udh, const char *filename, + unsigned char hash[RAD1_HASH_SIZE]); + +bool rad1LoadFpga (libusb_device_handle *udh, const char *filename, + unsigned char hash[RAD1_HASH_SIZE]); + +bool rad1_load_standard_bits (int nth, bool force, + const std::string fpga_filename, + const std::string firmware_filename, + libusb_context *ctx); + +class rnrad1Core +{ + +protected: + libusb_device_handle *mudh; + struct libusb_context *mctx; + int mUsbDataRate; // bytes/sec + int mBytesPerPoll; // how often to poll for overruns + long mFpgaMasterClockFreq; + + static const int MAX_REGS = 128; + unsigned int mFpgaShadows[MAX_REGS]; + +public: + rnrad1Core(int which_board, + int interface, + int altinterface, + const std::string fpgaFilename, + const std::string firmwareFilename, + bool skipLoad); + + libusb_device_handle* getHandle() { return mudh;} + + libusb_context* getContext() {return mctx;} + + int sendRqst (int request, bool flag); + + int checkUnderrun (unsigned char *status); + + int checkOverrun (unsigned char *status); + + bool writeAuxDac (int dac, int value); + + bool readAuxAdc (bool isTx, int adc, int *value); + + int readAuxAdc (bool isTx, int adc); + + ~rnrad1Core(); + + long fpgaMasterClockFreq () const { return mFpgaMasterClockFreq; } + + void setFpgaMasterClockFreq (long master_clock) { mFpgaMasterClockFreq = master_clock; } + + int usbDataRate () const { return mUsbDataRate; } + + void setUsbDataRate (int rate); + + static const int READ_FAILED = -99999; + + bool writeEeprom (int i2cAddr, int eepromOffset, const std::string buf); + + std::string readEeprom (int i2cAddr, int eepromOffset, int len); + + bool writeI2c (int i2cAddr, unsigned char *buf, int len); + + bool readI2c (int i2cAddr, unsigned char *buf, int len); + + bool setAdcOffset (int adc, int offset); + + bool setDacOffset (int dac, int offset, int pin); + + bool setAdcBufferBypass (int adc, bool bypass); + + bool setDcOffsetClEnable(int bits, int mask); + + bool setLed (int which_led, bool on); + + bool writeFpgaReg (int regno, int value); //< 7-bit regno, 32-bit value + + bool readFpgaReg (int regno, int *value); //< 7-bit regno, 32-bit value + + int readFpgaReg (int regno); + + bool write9862 (int regno, unsigned char value); + + bool read9862 (int regno, unsigned char *value) const; + + int read9862 (int regno) const; + + bool writeSpi (int optionalHeader, int enables, int format, unsigned char *buf, int len); + + bool readSpi (int optionalHeader, int enables, int format, unsigned char *buf, int len) const; + + bool start (); + +}; + +#endif diff --git a/TransceiverRAD1/rnrad1Rx.cpp b/TransceiverRAD1/rnrad1Rx.cpp new file mode 100644 index 0000000..dc5b14f --- /dev/null +++ b/TransceiverRAD1/rnrad1Rx.cpp @@ -0,0 +1,318 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "rnrad1.h" + +using namespace ad9862; + +rnrad1Rx::rnrad1Rx (int whichBoard, + unsigned int wDecimRate, + const std::string fpgaFilename = "", + const std::string firmwareFilename = "") + : rnrad1Core(whichBoard,RAD1_RX_INTERFACE,RAD1_RX_ALTINTERFACE,fpgaFilename,firmwareFilename,false) +{ + + mDevHandle = 0; + mEndptHandle = 0; + mBytesSeen = 0; + mEnabled = false; + mDecimRate = wDecimRate; + + // initialize rx specific registers + // initialize registers that are common to rx and tx + bool result=true; + result &= write9862(REG_RX_PWR_DN,0); + result &= write9862(REG_RX_A,0); // minimum gain = 0x00 (max gain = 0x14) + result &= write9862(REG_RX_B,0); // minimum gain = 0x00 (max gain = 0x14) + result &= write9862(REG_RX_MISC,RX_MISC_HS_DUTY_CYCLE | RX_MISC_CLK_DUTY); + result &= write9862(REG_RX_IF,RX_IF_USE_CLKOUT1 | RX_IF_2S_COMP); + result &= write9862(REG_RX_DIGITAL,RX_DIGITAL_2_CHAN); + if (!result) { + LOG(ERR) << "Failed to init AD9862 RX regs"; + exit(1); + } + + // Reset the rx path and leave it disabled. + enable (false); + + sendRqst(VRQ_FPGA_SET_RX_RESET, 1); + usleep(10); + sendRqst(VRQ_FPGA_SET_RX_RESET, 0); + + setSampleRateDivisor (2); // usually correct + + setDcOffsetClEnable(0xf, 0xf); // enable DC offset removal control loops + + // check fusb buffering parameters + int blockSize = 4096; //fusb::default_block_size(); + int numBlocks = 128; //std::max (1, fusb::default_buffer_size() / blockSize); + + mDevHandle = fusb::make_devhandle (getHandle(), getContext()); + mEndptHandle = mDevHandle->make_ephandle (RAD1_RX_ENDPOINT, true, + blockSize, numBlocks); + + writeFpgaReg(FR_ATR_MASK_1,0); + writeFpgaReg(FR_ATR_TXVAL_1,0); + writeFpgaReg(FR_ATR_RXVAL_1,0); + writeFpgaReg(FR_ATR_MASK_3,0); + writeFpgaReg(FR_ATR_TXVAL_3,0); + writeFpgaReg(FR_ATR_RXVAL_3,0); + + mSwMux = 0; + mHwMux = 0; + + writeFpgaReg(FR_RX_FORMAT,0x00000300); + writeHwMuxReg(); + setDecimRate(mDecimRate); + unsigned int mux = 0x00000010; + setMux(mux); + writeFpgaReg(FR_MODE, 0); + setRxFreq(0); +} + + +rnrad1Rx::~rnrad1Rx() +{ + enable (false); + + delete mEndptHandle; + delete mDevHandle; + + // initialize registers that are common to rx and tx + bool result= write9862(REG_RX_PWR_DN,0x1); + +} + + +bool rnrad1Rx::writeHwMuxReg() +{ + bool s = disable(); + bool ok = writeFpgaReg (FR_RX_MUX, mHwMux | 1); + restore (s); + return ok; +} + +bool rnrad1Rx::setRxFreq (double freq) +{ + int v = (int) rint (freq / (double) adcRate() * pow (2.0, 32.0)); + mRxFreq = v * (double) adcRate() / pow (2.0, 32.0); + return writeFpgaReg (FR_RX_FREQ_0, v); +} + +rnrad1Rx *rnrad1Rx::make(int whichBoard, + unsigned int wDecimRate, + const std::string fpgaFilename = "", + const std::string firmwareFilename = "") +{ + try { + rnrad1Rx *u = new rnrad1Rx(whichBoard, + wDecimRate, + fpgaFilename, + firmwareFilename); + return u; + } + catch (...) { + return NULL; + } +} + +bool rnrad1Rx::setDecimRate (unsigned int rate) +{ + if ((rate & 0x1) || rate < 4 || rate > 256){ + LOG(ERR) << "decimation rate must be EVEN and in [4, 256]"; + return false; + } + + mDecimRate = rate; + setUsbDataRate ((adcRate()/rate) * (2 * sizeof (short))); + + bool s = disable (); + int v = mDecimRate/2 - 1; + bool ok = writeFpgaReg (FR_DECIM_RATE, v); + restore (s); + return ok; +} + +bool rnrad1Rx::setMux (int mux) +{ + int mHwMux = 0; + for (int i = 0; i < 8; i++){ + int t = (mux >> (4 * i)) & 0x3; + mHwMux |= t << (2 * i + 4); + } + mSwMux = mux; + return writeHwMuxReg (); +} + + +bool rnrad1Rx::start() +{ + if (!rnrad1Core::start ()) // invoke parent's method + return false; + + // fire off reads before asserting rx_enable + + if (!mEndptHandle->start ()){ + LOG(ERR) << "Can't start USB RX stream"; + return false; + } + + if (!enable (true)){ + LOG(ERR) << "Can't enable RX"; + return false; + } + + return true; +} + +bool rnrad1Rx::setSampleRateDivisor (unsigned int div) +{ + return writeFpgaReg (FR_RX_SAMPLE_RATE_DIV, div - 1); +} + +int rnrad1Rx::read (void *buf, int len, bool *overrun) +{ + int r; + + if (overrun) *overrun = false; + + if (len < 0 || (len % 512) != 0){ + LOG(ERR) << "read: invalid length = " << len; + return -1; + } + + r = mEndptHandle->read (buf, len); + if (r > 0) mBytesSeen += r; + + if (overrun != 0 && mBytesSeen >= mBytesPerPoll){ + mBytesSeen = 0; + *overrun = true; + unsigned char status; + if (checkOverrun(&status) != 1) + LOG(ERR) << "Overrun check failed"; + *overrun = status; + } + + return r; +} + +bool rnrad1Rx::enable (bool on) +{ + mEnabled = on; + return (sendRqst(VRQ_FPGA_SET_RX_ENABLE, on) == 0); +} + +// conditional disable, return prev state +bool rnrad1Rx::disable () +{ + bool enabled = enable (); + if (enabled) enable (false); + return enabled; +} + +// conditional set +void rnrad1Rx::restore (bool on) +{ + if (on != enable ()) enable (on); +} + +bool rnrad1Rx::setPga (int amp, double gain) +{ + if (amp < 0 || amp > 1) + return false; + + gain = std::min(pgaMax(), std::max(pgaMin(), gain)); + int intGain = (int) rint((gain - pgaMin()) / pgaDbPerStep()); + int reg = (amp & 1 == 0) ? REG_RX_A : REG_RX_B; + // read current value to get input buffer bypass flag. + unsigned char curRx; + if (!read9862(reg, &curRx)) + return false; + + curRx = (curRx & RX_X_BYPASS_INPUT_BUFFER) | (intGain & 0x7f); + return write9862(reg, curRx); + +} + +double rnrad1Rx::pga (int amp) const +{ + if (amp < 0 || amp > 1) return READ_FAILED; + int reg = (amp & 1 == 0) ? REG_RX_A : REG_RX_B; + unsigned char v; + if (!read9862 (reg, &v)) return READ_FAILED; + return (pgaDbPerStep() * (v & 0x1f)) + pgaMin(); +} + +bool rnrad1Rx::writeOE (int value, int mask) +{ + return writeFpgaReg(FR_OE_1, (mask << 16) | (value & 0xffff)); +} + +bool rnrad1Rx::writeIO (int value, int mask) +{ + return writeFpgaReg(FR_IO_1, (mask << 16) | (value & 0xffff)); +} + +bool rnrad1Rx::readIO (int *value) +{ + int t; + int reg = 0 + 1; // FIXME, *very* magic number (fix in serial_io.v) + if (!readFpgaReg(reg, &t)) return false; + *value = (t >> 16) & 0xffff; // FIXME, more magic + return true; +} + +int rnrad1Rx::readIO (void) +{ + int value; + if (!readIO(&value)) return READ_FAILED; + return value; +} + +bool rnrad1Rx::writeRefClk(int value) +{ + return writeFpgaReg(FR_RX_A_REFCLK, value); +} + +bool rnrad1Rx::writeAuxDac (int dac, int value) +{ + return rnrad1Core::writeAuxDac(dac, value); +} + +bool rnrad1Rx::readAuxAdc (int adc, int *value) +{ + return rnrad1Core::readAuxAdc(false, adc, value); +} + +int rnrad1Rx::readAuxAdc (int adc) +{ + int retVal; + rnrad1Rx::readAuxAdc(adc, &retVal); + return retVal; +} + +int rnrad1Rx::blockSize() const { return mEndptHandle->block_size(); } + + diff --git a/TransceiverRAD1/rnrad1Tx.cpp b/TransceiverRAD1/rnrad1Tx.cpp new file mode 100644 index 0000000..8c351f6 --- /dev/null +++ b/TransceiverRAD1/rnrad1Tx.cpp @@ -0,0 +1,401 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include "rnrad1.h" + +#include "ad9862.h" + +using namespace ad9862; + + +rnrad1Tx::rnrad1Tx (int whichBoard, + unsigned int wInterpRate, + const std::string fpgaFilename = "", + const std::string firmwareFilename = "") + : rnrad1Core(whichBoard, RAD1_TX_INTERFACE, RAD1_TX_ALTINTERFACE, fpgaFilename, firmwareFilename, false) +{ + mSwMux = 0x8; + mHwMux = 0x81; + mInterpRate = wInterpRate; + + mDevHandle = 0; + mEndptHandle = 0; + mBytesSeen = 0; + mEnabled = true; + + // initialize rx specific registers + bool result=true; + result &= write9862(REG_TX_PWR_DN,0); + result &= write9862(REG_TX_A_OFFSET_LO,0); + result &= write9862(REG_TX_A_OFFSET_HI,0); + result &= write9862(REG_TX_B_OFFSET_LO,0); + result &= write9862(REG_TX_B_OFFSET_HI,0); + result &= write9862(REG_TX_A_GAIN,TX_X_GAIN_COARSE_FULL); + result &= write9862(REG_TX_B_GAIN,TX_X_GAIN_COARSE_FULL); + result &= write9862(REG_TX_PGA,0xff); // maximum gain (0 dB) + result &= write9862(REG_TX_MISC,0); + result &= write9862(REG_TX_IF,TX_IF_USE_CLKOUT1 + | TX_IF_I_FIRST + | TX_IF_INV_TX_SYNC + | TX_IF_2S_COMP + | TX_IF_INTERLEAVED); + result &= write9862(REG_TX_DIGITAL,TX_DIGITAL_2_DATA_PATHS + | TX_DIGITAL_INTERPOLATE_4X); + result &= write9862(REG_TX_MODULATOR,TX_MODULATOR_DISABLE_NCO + | TX_MODULATOR_COARSE_MODULATION_NONE), + result &= write9862(REG_TX_NCO_FTW_7_0,0); + result &= write9862(REG_TX_NCO_FTW_15_8,0); + result &= write9862(REG_TX_NCO_FTW_23_16,0); + if (!result) { + LOG(ERR) << "Failed to init AD9862 TX regs"; + exit(1); + } + + // Reset the tx path and leave it disabled. + enable (false); + + sendRqst(VRQ_FPGA_SET_TX_RESET, 1); + usleep(10); + sendRqst(VRQ_FPGA_SET_TX_RESET, 0); + + setSampleRateDivisor (4); // we're using interp x4 + + // check fusb buffering parameters + int blockSize = 4096; //fusb::default_block_size(); + int numBlocks = 128; //std::max (1, fusb::default_buffer_size() / blockSize); + + mDevHandle = fusb::make_devhandle (getHandle(), getContext()); + mEndptHandle = mDevHandle->make_ephandle (RAD1_TX_ENDPOINT, false, + blockSize, numBlocks); + + writeFpgaReg(FR_ATR_MASK_0,0); + writeFpgaReg(FR_ATR_TXVAL_0,0); + writeFpgaReg(FR_ATR_RXVAL_0,0); + writeFpgaReg(FR_ATR_MASK_2,0); + writeFpgaReg(FR_ATR_TXVAL_2,0); + writeFpgaReg(FR_ATR_RXVAL_2,0); + + // initialize registers that are common to rx and tx + result=true; + result &= write9862 (REG_TX_IF,TX_IF_USE_CLKOUT1 | TX_IF_I_FIRST | TX_IF_2S_COMP | TX_IF_INTERLEAVED); + result &= write9862 (REG_TX_DIGITAL, TX_DIGITAL_2_DATA_PATHS | TX_DIGITAL_INTERPOLATE_4X); + if (!result){ + LOG(ERR) << "failed to init AD9862 TX regs"; + exit(1); + } + writeHwMuxReg (); + if (!setInterpRate (mInterpRate)){ + LOG(ERR) << "failed to set interpolation rate"; + exit(1); + } + int mux = 0x00000098; + if (!setMux (mux)){ + LOG(ERR) << "failed to set tx mux"; + exit(1); + } + + mTxModulatorShadow = (TX_MODULATOR_DISABLE_NCO + | TX_MODULATOR_COARSE_MODULATION_NONE); + setTxFreq (0); +} + + +bool rnrad1Tx::enable (bool on) +{ + mEnabled = on; + return (sendRqst(VRQ_FPGA_SET_TX_ENABLE, on) == 0); +} + +bool rnrad1Tx::disable () // conditional disable, return prev state +{ + bool enabled = enable (); + if (enabled) enable (false); + return enabled; +} + +void rnrad1Tx::restore (bool on) // conditional set +{ + if (on != enable ()) enable (on); +} + +bool rnrad1Tx::writeHwMuxReg() +{ + bool s = disable (); + bool ok = writeFpgaReg (FR_TX_MUX, mHwMux | 1); + restore (s); + return ok; +} + +bool rnrad1Tx::setSampleRateDivisor (unsigned int div) +{ + return writeFpgaReg (FR_TX_SAMPLE_RATE_DIV, div - 1); +} + +int rnrad1Tx::write (const void *buf, int len, bool *underrun) +{ + int r; + + if (underrun) + *underrun = false; + + if (len < 0 || (len % 512) != 0) { + LOG(ERR) << "write: invalid length = " << len; + return -1; + } + + r = mEndptHandle->write (buf, len); + if (r > 0) + mBytesSeen += r; + + // NOTE: may get bogus underrun during first write + if (underrun != 0 && mBytesSeen >= mBytesPerPoll){ + mBytesSeen = 0; + *underrun = true; + unsigned char status; + if (checkUnderrun(&status) != 1) + LOG(ERR) << "Underrun check failed"; + *underrun = status; + } + + return r; +} + +bool rnrad1Tx::setPga (int amp, double gain) +{ + if (amp < 0 || amp > 3) + return false; + + gain = std::min(pgaMax(),std::max(pgaMin(), gain)); + + int intGain = (int) rint((gain - pgaMin()) / pgaDbPerStep()); + + // 0 and 1 are same, as are 2 and 3 + return write9862(REG_TX_PGA, intGain); + +} + +double rnrad1Tx::pga (int amp) const +{ + if (amp < 0 || amp > 3) + return READ_FAILED; + + unsigned char v; + bool ok = read9862 (REG_TX_PGA, &v); + if (!ok) + return READ_FAILED; + + return (pgaDbPerStep() * v) + pgaMin(); +} + +bool rnrad1Tx::writeOE (int value, int mask) +{ + return writeFpgaReg(FR_OE_0,(mask << 16) | (value & 0xffff)); +} + +bool rnrad1Tx::writeIO (int value, int mask) +{ + return writeFpgaReg(FR_IO_0,(mask << 16) | (value & 0xffff)); +} + +bool rnrad1Tx::readIO (int *value) +{ + int t; + int reg = 0 + 1; // FIXME, *very* magic number (fix in serial_io.v) + bool ok = readFpgaReg(reg, &t); + if (!ok) + return false; + + *value = t & 0xffff; // FIXME, more magic + return true; +} + +int rnrad1Tx::readIO (void) +{ + int value; + if (!readIO(&value)) + return READ_FAILED; + return value; +} + + +bool rnrad1Tx::writeRefClk(int value) +{ + return writeFpgaReg(FR_TX_A_REFCLK, value); +} + +bool rnrad1Tx::writeAuxDac (int dac, int value) +{ + return rnrad1Core::writeAuxDac(dac, value); +} + +bool rnrad1Tx::readAuxAdc (int adc, int *value) +{ + return rnrad1Core::readAuxAdc(true, adc, value); +} + +int rnrad1Tx::readAuxAdc (int adc) +{ + int retVal; + rnrad1Tx::readAuxAdc(adc, &retVal); + return retVal; +} + +rnrad1Tx::~rnrad1Tx () +{ + delete mEndptHandle; + delete mDevHandle; + + // initialize registers that are common to rx and tx + bool result=true; + result &= write9862(REG_TX_PWR_DN, TX_PWR_DN_TX_DIGITAL | TX_PWR_DN_TX_ANALOG_BOTH); + result &= write9862(REG_TX_MODULATOR, TX_MODULATOR_DISABLE_NCO | TX_MODULATOR_COARSE_MODULATION_NONE); +} + +rnrad1Tx* rnrad1Tx::make(int which_board, + unsigned int wInterpRate, + const std::string fpgaFilename = "", + const std::string firmwareFilename = "") +{ + try { + rnrad1Tx* u = new rnrad1Tx(which_board, wInterpRate, + fpgaFilename, firmwareFilename); + return u; + } + catch (...){ + return NULL; + } +} + + +bool rnrad1Tx::setInterpRate (unsigned int rate) +{ + if ((rate & 0x3) || rate < 4 || rate > 512){ + LOG(ERR) << "interpolation rate must be in [4, 512] and a multiple of 4"; + return false; + } + + mInterpRate = rate; + setUsbDataRate ((dacRate () / rate) * (2 * sizeof (short))); + + // We're using the interp by 4 feature of the 9862 so that we can + // use its fine modulator. Thus, we reduce the FPGA's interpolation rate + // by a factor of 4. + + bool s = disable(); + bool ok = writeFpgaReg (FR_INTERP_RATE, mInterpRate/4 - 1); + restore (s); + return ok; +} + +bool rnrad1Tx::setMux (int mux) +{ + mSwMux = mux; + mHwMux = mux << 4; + return writeHwMuxReg (); +} + +bool rnrad1Tx::setTxFreq (double freq) +{ + + // split freq into fine and coarse components + + double coarse; + + double freq1 = dacRate () / 8; // First coarse frequency + double freq2 = dacRate () / 4; // Second coarse frequency + double limit1 = freq1 / 2; // Midpoint of [0 , freq1] range + double limit2 = (freq1 + freq2) / 2; // Midpoint of [freq1 , freq2] range + double highLimit = (double)44e6; // Highest meaningful frequency + + if ((freq < -highLimit) || (freq > highLimit)) + return false; + + mTxModulatorShadow &= ~TX_MODULATOR_CM_MASK; + if (freq < -limit2) { + coarse = -freq2; + mTxModulatorShadow |= TX_MODULATOR_COARSE_MODULATION_F_OVER_4; + mTxModulatorShadow |= TX_MODULATOR_NEG_COARSE_TUNE; + } + else if (freq < -limit1) { + coarse = -freq1; + mTxModulatorShadow |= TX_MODULATOR_COARSE_MODULATION_F_OVER_8; + mTxModulatorShadow |= TX_MODULATOR_NEG_COARSE_TUNE; + } + else if (freq < limit1) { + coarse = 0; + } + else if (freq < limit2) { + coarse = freq1; + mTxModulatorShadow |= TX_MODULATOR_COARSE_MODULATION_F_OVER_8; + } + else if (freq <= highLimit) { + coarse = freq2; + mTxModulatorShadow |= TX_MODULATOR_COARSE_MODULATION_F_OVER_4; + } + + + double fine = freq - coarse; + double sign = 2.0*(fine > 0.0) - 1.0; + unsigned int v = (int) rint (fabs (fine) / (double) (dacRate()/4) * pow (2.0, 24.0)); + mTxFreq = coarse + v * (double) (dacRate()/4) / pow (2.0, 24.0) * sign; + + bool ok = true; + ok &= write9862 (REG_TX_NCO_FTW_23_16, (unsigned char) ((v >> 16) & 0xff)); + ok &= write9862 (REG_TX_NCO_FTW_15_8, (unsigned char) ((v >> 8) & 0xff)); + ok &= write9862 (REG_TX_NCO_FTW_7_0, (unsigned char) (v & 0xff)); + + mTxModulatorShadow |= TX_MODULATOR_ENABLE_NCO; + + if (fine < 0) + mTxModulatorShadow |= TX_MODULATOR_NEG_FINE_TUNE; + else + mTxModulatorShadow &= ~TX_MODULATOR_NEG_FINE_TUNE; + + ok &= write9862 (REG_TX_MODULATOR, mTxModulatorShadow); + + return ok; +} + + +bool rnrad1Tx::start() +{ + if (!rnrad1Core::start ()) + return false; + + if (!enable (true)){ + LOG(ERR) << "Can't enable TX"; + return false; + } + + if (!mEndptHandle->start ()){ + LOG(ERR) << "Can't start USB TX stream"; + return false; + } + + return true; +} + + + diff --git a/TransceiverRAD1/runTransceiver.cpp b/TransceiverRAD1/runTransceiver.cpp new file mode 100644 index 0000000..04dea50 --- /dev/null +++ b/TransceiverRAD1/runTransceiver.cpp @@ -0,0 +1,88 @@ +/* +* Copyright 2008, 2009 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + +#include + +#include "Transceiver.h" +#include "RAD1Device.h" +#include "DummyLoad.h" + +#include +#include + +#include +#include +#include + +using namespace std; + +ConfigurationTable gConfig("/etc/OpenBTS/OpenBTS.db"); + + +volatile bool gbShutdown = false; +static void ctrlCHandler(int signo) +{ + cout << "Received shutdown signal" << endl;; + gbShutdown = true; +} + + +int main(int argc, char *argv[]) +{ + if ( signal( SIGINT, ctrlCHandler ) == SIG_ERR ) + { + cerr << "Couldn't install signal handler for SIGINT" << endl; + exit(1); + } + + if ( signal( SIGTERM, ctrlCHandler ) == SIG_ERR ) + { + cerr << "Couldn't install signal handler for SIGTERM" << endl; + exit(1); + } + // Configure logger. + gLogInit("transceiver",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7); + + srandom(time(NULL)); + + int mOversamplingRate = 1; + RAD1Device *usrp = new RAD1Device(mOversamplingRate*1625.0e3/6.0); + usrp->make(); + + RadioInterface* radio = new RadioInterface(usrp,3,SAMPSPERSYM,mOversamplingRate,false); + Transceiver *trx = new Transceiver(5700,"127.0.0.1",SAMPSPERSYM,GSM::Time(2,0),radio); + trx->receiveFIFO(radio->receiveFIFO()); + + trx->start(); + //int i = 0; + while(!gbShutdown) { sleep(1); } //i++; if (i==60) exit(1);} + + cout << "Shutting down transceiver..." << endl; + +// trx->stop(); + delete trx; +// delete radio; +} diff --git a/TransceiverRAD1/sigProcLib.cpp b/TransceiverRAD1/sigProcLib.cpp new file mode 100644 index 0000000..3b43401 --- /dev/null +++ b/TransceiverRAD1/sigProcLib.cpp @@ -0,0 +1,1526 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + + + +//#define NDEBUG + +#include "sigProcLib.h" +#include "GSMCommon.h" + +#include + +#define TABLESIZE 1024 + +/** Lookup tables for trigonometric approximation */ +float cosTable[TABLESIZE+1]; // add 1 element for wrap around +float sinTable[TABLESIZE+1]; + +/** Table of sinc waveforms at delays from -1,-0.99,...,0.99,1 samples **/ +#define SINCWAVEFORMSIZE 21 +#define SINCTABLESIZE 2049 +signalVector *sincTable[SINCTABLESIZE]; + + +/** Constants */ +static const float M_PI_F = (float)M_PI; +static const float M_2PI_F = (float)(2.0*M_PI); +static const float M_1_2PI_F = 1/M_2PI_F; + +/** Static vectors that contain a precomputed +/- f_b/4 sinusoid */ +signalVector *GMSKRotation = NULL; +signalVector *GMSKReverseRotation = NULL; + +/** Static ideal RACH and midamble correlation waveforms */ +typedef struct { + signalVector *sequence; + signalVector *sequenceReversedConjugated; + float TOA; + complex gain; +} CorrelationSequence; + +CorrelationSequence *gMidambles[] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; +CorrelationSequence *gRACHSequence = NULL; + +void sigProcLibDestroy(void) { + if (GMSKRotation) { + delete GMSKRotation; + GMSKRotation = NULL; + } + if (GMSKReverseRotation) { + delete GMSKReverseRotation; + GMSKReverseRotation = NULL; + } + for (int i = 0; i < 8; i++) { + if (gMidambles[i]!=NULL) { + if (gMidambles[i]->sequence) delete gMidambles[i]->sequence; + if (gMidambles[i]->sequenceReversedConjugated) delete gMidambles[i]->sequenceReversedConjugated; + delete gMidambles[i]; + gMidambles[i] = NULL; + } + } + if (gRACHSequence) { + if (gRACHSequence->sequence) delete gRACHSequence->sequence; + if (gRACHSequence->sequenceReversedConjugated) delete gRACHSequence->sequenceReversedConjugated; + delete gRACHSequence; + gRACHSequence = NULL; + } +} + + + +// dB relative to 1.0. +// if > 1.0, then return 0 dB +float dB(float x) { + + float arg = 1.0F; + float dB = 0.0F; + + if (x >= 1.0F) return 0.0F; + if (x <= 0.0F) return -200.0F; + + float prevArg = arg; + float prevdB = dB; + float stepSize = 16.0F; + float dBstepSize = 12.0F; + while (stepSize > 1.0F) { + do { + prevArg = arg; + prevdB = dB; + arg /= stepSize; + dB -= dBstepSize; + } while (arg > x); + arg = prevArg; + dB = prevdB; + stepSize *= 0.5F; + dBstepSize -= 3.0F; + } + return ((arg-x)*(dB-3.0F) + (x-arg*0.5F)*dB)/(arg - arg*0.5F); + +} + +// 10^(-dB/10), inverse of dB func. +float dBinv(float x) { + + float arg = 1.0F; + float dB = 0.0F; + + if (x >= 0.0F) return 1.0F; + if (x <= -200.0F) return 0.0F; + + float prevArg = arg; + float prevdB = dB; + float stepSize = 16.0F; + float dBstepSize = 12.0F; + while (stepSize > 1.0F) { + do { + prevArg = arg; + prevdB = dB; + arg /= stepSize; + dB -= dBstepSize; + } while (dB > x); + arg = prevArg; + dB = prevdB; + stepSize *= 0.5F; + dBstepSize -= 3.0F; + } + + return ((dB-x)*(arg*0.5F)+(x-(dB-3.0F))*(arg))/3.0F; + +} + +float vectorNorm2(const signalVector &x) +{ + signalVector::const_iterator xPtr = x.begin(); + float Energy = 0.0; + for (;xPtr != x.end();xPtr++) { + Energy += xPtr->norm2(); + } + return Energy; +} + + +float vectorPower(const signalVector &x) +{ + return vectorNorm2(x)/x.size(); +} + +/** compute cosine via lookup table */ +float cosLookup(const float x) +{ + float arg = x*M_1_2PI_F; + while (arg > 1.0F) arg -= 1.0F; + while (arg < 0.0F) arg += 1.0F; + + const float argT = arg*((float)TABLESIZE); + const int argI = (int)argT; + const float delta = argT-argI; + const float iDelta = 1.0F-delta; + return iDelta*cosTable[argI] + delta*cosTable[argI+1]; +} + +/** compute sine via lookup table */ +float sinLookup(const float x) +{ + float arg = x*M_1_2PI_F; + while (arg > 1.0F) arg -= 1.0F; + while (arg < 0.0F) arg += 1.0F; + + const float argT = arg*((float)TABLESIZE); + const int argI = (int)argT; + const float delta = argT-argI; + const float iDelta = 1.0F-delta; + return iDelta*sinTable[argI] + delta*sinTable[argI+1]; +} + + +/** compute e^(-jx) via lookup table. */ +complex expjLookup(float x) +{ + float arg = x*M_1_2PI_F; + while (arg > 1.0F) arg -= 1.0F; + while (arg < 0.0F) arg += 1.0F; + + const float argT = arg*((float)TABLESIZE); + const int argI = (int)argT; + const float delta = argT-argI; + const float iDelta = 1.0F-delta; + return complex(iDelta*cosTable[argI] + delta*cosTable[argI+1], + iDelta*sinTable[argI] + delta*sinTable[argI+1]); +} + +/** Library setup functions */ +void initTrigTables() { + for (int i = 0; i < TABLESIZE+1; i++) { + cosTable[i] = cos(2.0*M_PI*i/TABLESIZE); + sinTable[i] = sin(2.0*M_PI*i/TABLESIZE); + } +} + +void initGMSKRotationTables(int samplesPerSymbol) { + GMSKRotation = new signalVector(157*samplesPerSymbol); + GMSKReverseRotation = new signalVector(157*samplesPerSymbol); + signalVector::iterator rotPtr = GMSKRotation->begin(); + signalVector::iterator revPtr = GMSKReverseRotation->begin(); + float phase = 0.0; + while (rotPtr != GMSKRotation->end()) { + *rotPtr++ = expjLookup(phase); + *revPtr++ = expjLookup(-phase); + phase += M_PI_F/2.0F/(float) samplesPerSymbol; + } +} + +void initSincTables(void) { + for (int i = 0; i < SINCTABLESIZE; i++) { + float fracOffset = (float)(i-(SINCTABLESIZE/2))/(float) (SINCTABLESIZE/2); + sincTable[i] = new signalVector(SINCWAVEFORMSIZE); + signalVector::iterator sincBurstItr = sincTable[i]->begin(); + for (int j = 0; j < SINCWAVEFORMSIZE; j++) + *sincBurstItr++ = (complex) sinc(M_PI_F*((float)j-(float)(SINCWAVEFORMSIZE/2)-fracOffset)); + sincTable[i]->isRealOnly(true); + } +} + + +void sigProcLibSetup(int samplesPerSymbol) { + initTrigTables(); + initGMSKRotationTables(samplesPerSymbol); + initSincTables(); +} + +signalVector *fetchSincVector(float fracOffset) { + if (fabs(fracOffset) > 1.0) return NULL; + int tableIndex = (int) round( (fracOffset*(float) (SINCTABLESIZE/2)+ (float) (SINCTABLESIZE/2)) ); + return sincTable[tableIndex]; +} + + +void GMSKRotate(signalVector &x) { + signalVector::iterator xPtr = x.begin(); + signalVector::iterator rotPtr = GMSKRotation->begin(); + if (x.isRealOnly()) { + while (xPtr < x.end()) { + *xPtr = *rotPtr++ * (xPtr->real()); + xPtr++; + } + } + else { + while (xPtr < x.end()) { + *xPtr = *rotPtr++ * (*xPtr); + xPtr++; + } + } +} + +void GMSKReverseRotate(signalVector &x) { + signalVector::iterator xPtr= x.begin(); + signalVector::iterator rotPtr = GMSKReverseRotation->begin(); + if (x.isRealOnly()) { + while (xPtr < x.end()) { + *xPtr = *rotPtr++ * (xPtr->real()); + xPtr++; + } + } + else { + while (xPtr < x.end()) { + *xPtr = *rotPtr++ * (*xPtr); + xPtr++; + } + } +} + + +signalVector* convolve(const signalVector *a, + const signalVector *b, + signalVector *c, + ConvType spanType, + unsigned startIx, + unsigned len) +{ + if ((a==NULL) || (b==NULL)) return NULL; + int La = a->size(); + int Lb = b->size(); + + int startIndex; + unsigned int outSize; + switch (spanType) { + case FULL_SPAN: + startIndex = 0; + outSize = La+Lb-1; + break; + case OVERLAP_ONLY: + startIndex = La; + outSize = abs(La-Lb)+1; + break; + case START_ONLY: + startIndex = 0; + outSize = La; + break; + case WITH_TAIL: + startIndex = Lb; + outSize = La; + break; + case NO_DELAY: + if (Lb % 2) + startIndex = Lb/2; + else + startIndex = Lb/2-1; + outSize = La; + break; + case CUSTOM: + startIndex = startIx; + outSize = len; + break; + default: + return NULL; + } + + + if (c==NULL) + c = new signalVector(outSize); + else if (c->size()!=outSize) + return NULL; + + signalVector::const_iterator aStart = a->begin(); + signalVector::const_iterator bStart = b->begin(); + signalVector::const_iterator aEnd = a->end(); + signalVector::const_iterator bEnd = b->end(); + signalVector::iterator cPtr = c->begin(); + int t = startIndex; + int stopIndex = startIndex + outSize; + switch (b->getSymmetry()) { + case NONE: + { + while (t < stopIndex) { + signalVector::const_iterator aP = aStart+t; + signalVector::const_iterator bP = bStart; + if (a->isRealOnly() && b->isRealOnly()) { + float sum = 0.0; + while (bP < bEnd) { + if (aP < aStart) break; + if (aP < aEnd) sum += (aP->real())*(bP->real()); + aP--; + bP++; + } + *cPtr++ = sum; + } + else if (a->isRealOnly()) { + complex sum = 0.0; + while (bP < bEnd) { + if (aP < aStart) break; + if (aP < aEnd) sum += (*bP)*(aP->real()); + aP--; + bP++; + } + *cPtr++ = sum; + } + else if (b->isRealOnly()) { + complex sum = 0.0; + while (bP < bEnd) { + if (aP < aStart) break; + if (aP < aEnd) sum += (*aP)*(bP->real()); + aP--; + bP++; + } + *cPtr++ = sum; + } + else { + complex sum = 0.0; + while (bP < bEnd) { + if (aP < aStart) break; + if (aP < aEnd) sum += (*aP)*(*bP); + aP--; + bP++; + } + *cPtr++ = sum; + } + t++; + } + } + break; + case ABSSYM: + { + complex sum = 0.0; + bool isOdd = (bool) (Lb % 2); + if (isOdd) + bEnd = bStart + (Lb+1)/2; + else + bEnd = bStart + Lb/2; + while (t < stopIndex) { + signalVector::const_iterator aP = aStart+t; + signalVector::const_iterator aPsym = aP-Lb+1; + signalVector::const_iterator bP = bStart; + sum = 0.0; + if (!b->isRealOnly()) { + while (bP < bEnd) { + if (aP < aStart) break; + if (aP == aPsym) + sum+= (*aP)*(*bP); + else if ((aP < aEnd) && (aPsym >= aStart)) + sum+= ((*aP)+(*aPsym))*(*bP); + else if (aP < aEnd) + sum += (*aP)*(*bP); + else if (aPsym >= aStart) + sum += (*aPsym)*(*bP); + aP--; + aPsym++; + bP++; + } + } + else { + while (bP < bEnd) { + if (aP < aStart) break; + if (aP == aPsym) + sum+= (*aP)*(bP->real()); + else if ((aP < aEnd) && (aPsym >= aStart)) + sum+= ((*aP)+(*aPsym))*(bP->real()); + else if (aP < aEnd) + sum += (*aP)*(bP->real()); + else if (aPsym >= aStart) + sum += (*aPsym)*(bP->real()); + aP--; + aPsym++; + bP++; + } + } + *cPtr++ = sum; + t++; + } + } + break; + default: + return NULL; + break; + } + + + return c; +} + + +signalVector* generateGSMPulse(int symbolLength, + int samplesPerSymbol) +{ + + int numSamples = samplesPerSymbol*symbolLength + 1; + signalVector *x = new signalVector(numSamples); + signalVector::iterator xP = x->begin(); + int centerPoint = (numSamples-1)/2; + for (int i = 0; i < numSamples; i++) { + float arg = (float) (i-centerPoint)/(float) samplesPerSymbol; + *xP++ = 0.96*exp(-1.1380*arg*arg-0.527*arg*arg*arg*arg); // GSM pulse approx. + } + + float avgAbsval = sqrtf(vectorNorm2(*x)/samplesPerSymbol); + xP = x->begin(); + for (int i = 0; i < numSamples; i++) + *xP++ /= avgAbsval; + x->isRealOnly(true); + x->setSymmetry(ABSSYM); + return x; +} + +signalVector* frequencyShift(signalVector *y, + signalVector *x, + double freq, + float startPhase, + float *finalPhase) +{ + + if (!x) return NULL; + + if (y==NULL) { + y = new signalVector(x->size()); + y->isRealOnly(x->isRealOnly()); + if (y==NULL) return NULL; + } + + if (y->size() < x->size()) return NULL; + + double phase = startPhase; + signalVector::iterator yP = y->begin(); + signalVector::iterator xPEnd = x->end(); + signalVector::iterator xP = x->begin(); + + if (x->isRealOnly()) { + while (xP < xPEnd) { + (*yP++) = expjLookup(phase)*( (xP++)->real() ); + phase += freq; + } + } + else { + while (xP < xPEnd) { + (*yP++) = (*xP++)*complex(cos(phase),sin(phase));//*expjLookup(phase); + phase += freq; + } + } + + + if (finalPhase) *finalPhase = phase; + + return y; +} + +signalVector* reverseConjugate(signalVector *b) +{ + signalVector *tmp = new signalVector(b->size()); + tmp->isRealOnly(b->isRealOnly()); + signalVector::iterator bP = b->begin(); + signalVector::iterator bPEnd = b->end(); + signalVector::iterator tmpP = tmp->end()-1; + if (!b->isRealOnly()) { + while (bP < bPEnd) { + *tmpP-- = bP->conj(); + bP++; + } + } + else { + while (bP < bPEnd) { + *tmpP-- = bP->real(); + bP++; + } + } + + return tmp; +} + +signalVector* correlate(signalVector *a, + signalVector *b, + signalVector *c, + ConvType spanType, + bool bReversedConjugated, + unsigned startIx, + unsigned len) +{ + signalVector *tmp = NULL; + + if (!bReversedConjugated) { + tmp = reverseConjugate(b); + } + else { + tmp = b; + } + + c = convolve(a,tmp,c,spanType,startIx,len); + + if (!bReversedConjugated) delete tmp; + + return c; +} + + +/* soft output slicer */ +bool vectorSlicer(signalVector *x) +{ + + signalVector::iterator xP = x->begin(); + signalVector::iterator xPEnd = x->end(); + while (xP < xPEnd) { + *xP = (complex) (0.5*(xP->real()+1.0F)); + if (xP->real() > 1.0) *xP = 1.0; + if (xP->real() < 0.0) *xP = 0.0; + xP++; + } + return true; +} + +signalVector *modulateBurst(const BitVector &wBurst, + const signalVector &gsmPulse, + int guardPeriodLength, + int samplesPerSymbol) +{ + + //static complex staticBurst[157]; + + int burstSize = samplesPerSymbol*(wBurst.size()+guardPeriodLength); + //signalVector modBurst((complex *) staticBurst,0,burstSize); + signalVector modBurst(burstSize);// = new signalVector(burstSize); + modBurst.isRealOnly(true); + //memset(staticBurst,0,sizeof(complex)*burstSize); + modBurst.fill(0.0); + signalVector::iterator modBurstItr = modBurst.begin(); + +#if 0 + // if wBurst is already differentially decoded + *modBurstItr = 2.0*(wBurst[0] & 0x01)-1.0; + signalVector::iterator prevVal = modBurstItr; + for (unsigned int i = 1; i < wBurst.size(); i++) { + modBurstItr += samplesPerSymbol; + if (wBurst[i] & 0x01) + *modBurstItr = *prevVal * complex(0.0,1.0); + else + *modBurstItr = *prevVal * complex(0.0,-1.0); + prevVal = modBurstItr; + } +#else + // if wBurst are the raw bits + for (unsigned int i = 0; i < wBurst.size(); i++) { + *modBurstItr = 2.0*(wBurst[i] & 0x01)-1.0; + modBurstItr += samplesPerSymbol; + } + + // shift up pi/2 + // ignore starting phase, since spec allows for discontinuous phase + GMSKRotate(modBurst); +#endif + modBurst.isRealOnly(false); + + // filter w/ pulse shape + signalVector *shapedBurst = convolve(&modBurst,&gsmPulse,NULL,NO_DELAY); + + //delete modBurst; + + return shapedBurst; + +} + +float sinc(float x) +{ + if ((x >= 0.01F) || (x <= -0.01F)) return (sinLookup(x)/x); + return 1.0F; +} + +void delayVector(signalVector &wBurst, + float delay) +{ + + int intOffset = (int) floor(delay); + float fracOffset = delay - intOffset; + + // do fractional shift first, only do it for reasonable offsets + if (fabs(fracOffset) > 1e-2) { + // create sinc function + /*signalVector sincVector(21); + sincVector.isRealOnly(true); + signalVector::iterator sincBurstItr = sincVector.begin(); + for (int i = 0; i < 21; i++) + *sincBurstItr++ = (complex) sinc(M_PI_F*(i-10-fracOffset)); + */ + signalVector *sincVector = fetchSincVector(fracOffset); + + signalVector shiftedBurst(wBurst.size()); + convolve(&wBurst,sincVector,&shiftedBurst,NO_DELAY); + wBurst.clone(shiftedBurst); + } + + if (intOffset < 0) { + intOffset = -intOffset; + signalVector::iterator wBurstItr = wBurst.begin(); + signalVector::iterator shiftedItr = wBurst.begin()+intOffset; + while (shiftedItr < wBurst.end()) + *wBurstItr++ = *shiftedItr++; + while (wBurstItr < wBurst.end()) + *wBurstItr++ = 0.0; + } + else { + signalVector::iterator wBurstItr = wBurst.end()-1; + signalVector::iterator shiftedItr = wBurst.end()-1-intOffset; + while (shiftedItr >= wBurst.begin()) + *wBurstItr-- = *shiftedItr--; + while (wBurstItr >= wBurst.begin()) + *wBurstItr-- = 0.0; + } +} + +signalVector *gaussianNoise(int length, + float variance, + complex mean) +{ + + signalVector *noise = new signalVector(length); + signalVector::iterator nPtr = noise->begin(); + float stddev = sqrtf(variance); + while (nPtr < noise->end()) { + float u1 = (float) rand()/ (float) RAND_MAX; + while (u1==0.0) + u1 = (float) rand()/ (float) RAND_MAX; + float u2 = (float) rand()/ (float) RAND_MAX; + float arg = 2.0*M_PI*u2; + *nPtr = mean + stddev*complex(cos(arg),sin(arg))*sqrtf(-2.0*log(u1)); + nPtr++; + } + + return noise; +} + +complex interpolatePoint(const signalVector &inSig, + float ix) +{ + + float fracOffset = ix - floor(ix); + signalVector *sincVector = fetchSincVector(fracOffset); + signalVector::iterator sincPtr = sincVector->begin(); + + int start = (int) (floor(ix) - SINCWAVEFORMSIZE/2); + if (start < 0) { + sincPtr += (-start); + start = 0; + + } + int end = (int) (floor(ix) + (SINCWAVEFORMSIZE/2)+1); + if ((unsigned) end > inSig.size()-1) end = inSig.size()-1; + + complex pVal = 0.0; + if (!inSig.isRealOnly()) { + for (int i = start; i <= end; i++) { + pVal += inSig[i] * sincPtr->real(); + sincPtr++; + } + } + else { + for (int i = start; i <= end; i++) { + pVal += inSig[i].real() * sincPtr->real(); + sincPtr++; + } + } + + return pVal; +} + + + +complex peakDetect(const signalVector &rxBurst, + float *peakIndex, + float *avgPwr) +{ + + + complex maxVal = 0.0; + float maxIndex = -1; + float sumPower = 0.0; + + for (unsigned int i = 0; i < rxBurst.size(); i++) { + float samplePower = rxBurst[i].norm2(); + if (samplePower > maxVal.real()) { + maxVal = samplePower; + maxIndex = i; + } + sumPower += samplePower; + } + + // interpolate around the peak + // to save computation, we'll use early-late balancing + float earlyIndex = maxIndex-1; + float lateIndex = maxIndex+1; + + float incr = 0.5; + while (incr > 1.0/1024.0) { + complex earlyP = interpolatePoint(rxBurst,earlyIndex); + complex lateP = interpolatePoint(rxBurst,lateIndex); + if (earlyP < lateP) + earlyIndex += incr; + else if (earlyP > lateP) + earlyIndex -= incr; + else break; + incr /= 2.0; + lateIndex = earlyIndex + 2.0; + } + + maxIndex = earlyIndex + 1.0; + maxVal = interpolatePoint(rxBurst,maxIndex); + + if (peakIndex!=NULL) + *peakIndex = maxIndex; + + if (avgPwr!=NULL) + *avgPwr = (sumPower-maxVal.norm2()) / (rxBurst.size()-1); + + return maxVal; + +} + +void scaleVector(signalVector &x, + complex scale) +{ + signalVector::iterator xP = x.begin(); + signalVector::iterator xPEnd = x.end(); + if (!x.isRealOnly()) { + while (xP < xPEnd) { + *xP = *xP * scale; + xP++; + } + } + else { + while (xP < xPEnd) { + *xP = xP->real() * scale; + xP++; + } + } +} + +/** in-place conjugation */ +void conjugateVector(signalVector &x) +{ + if (x.isRealOnly()) return; + signalVector::iterator xP = x.begin(); + signalVector::iterator xPEnd = x.end(); + while (xP < xPEnd) { + *xP = xP->conj(); + xP++; + } +} + + +// in-place addition!! +bool addVector(signalVector &x, + signalVector &y) +{ + signalVector::iterator xP = x.begin(); + signalVector::iterator yP = y.begin(); + signalVector::iterator xPEnd = x.end(); + signalVector::iterator yPEnd = y.end(); + while ((xP < xPEnd) && (yP < yPEnd)) { + *xP = *xP + *yP; + xP++; yP++; + } + return true; +} + +// in-place multiplication!! +bool multVector(signalVector &x, + signalVector &y) +{ + signalVector::iterator xP = x.begin(); + signalVector::iterator yP = y.begin(); + signalVector::iterator xPEnd = x.end(); + signalVector::iterator yPEnd = y.end(); + while ((xP < xPEnd) && (yP < yPEnd)) { + *xP = (*xP) * (*yP); + xP++; yP++; + } + return true; +} + + +void offsetVector(signalVector &x, + complex offset) +{ + signalVector::iterator xP = x.begin(); + signalVector::iterator xPEnd = x.end(); + if (!x.isRealOnly()) { + while (xP < xPEnd) { + *xP += offset; + xP++; + } + } + else { + while (xP < xPEnd) { + *xP = xP->real() + offset; + xP++; + } + } +} + +bool generateMidamble(signalVector &gsmPulse, + int samplesPerSymbol, + int TSC) +{ + + if ((TSC < 0) || (TSC > 7)) + return false; + + if (gMidambles[TSC]) { + if (gMidambles[TSC]->sequence!=NULL) delete gMidambles[TSC]->sequence; + if (gMidambles[TSC]->sequenceReversedConjugated!=NULL) delete gMidambles[TSC]->sequenceReversedConjugated; + } + + signalVector emptyPulse(1); + *(emptyPulse.begin()) = 1.0; + + // only use middle 16 bits of each TSC + signalVector *middleMidamble = modulateBurst(gTrainingSequence[TSC].segment(5,16), + emptyPulse, + 0, + samplesPerSymbol); + signalVector *midamble = modulateBurst(gTrainingSequence[TSC], + gsmPulse, + 0, + samplesPerSymbol); + + if (midamble == NULL) return false; + if (middleMidamble == NULL) return false; + + // NOTE: Because ideal TSC 16-bit midamble is 66 symbols into burst, + // the ideal TSC has an + 180 degree phase shift, + // due to the pi/2 frequency shift, that + // needs to be accounted for. + // 26-midamble is 61 symbols into burst, has +90 degree phase shift. + scaleVector(*middleMidamble,complex(-1.0,0.0)); + scaleVector(*midamble,complex(0.0,1.0)); + + signalVector *autocorr = correlate(midamble,middleMidamble,NULL,NO_DELAY); + + if (autocorr == NULL) return false; + + gMidambles[TSC] = new CorrelationSequence; + gMidambles[TSC]->sequence = middleMidamble; + gMidambles[TSC]->sequenceReversedConjugated = reverseConjugate(middleMidamble); + gMidambles[TSC]->gain = peakDetect(*autocorr,&gMidambles[TSC]->TOA,NULL); + + LOG(DEBUG) << "midamble autocorr: " << *autocorr; + + LOG(DEBUG) << "TOA: " << gMidambles[TSC]->TOA; + + //gMidambles[TSC]->TOA -= 5*samplesPerSymbol; + + delete autocorr; + delete midamble; + + return true; +} + +bool generateRACHSequence(signalVector &gsmPulse, + int samplesPerSymbol) +{ + + if (gRACHSequence) { + if (gRACHSequence->sequence!=NULL) delete gRACHSequence->sequence; + if (gRACHSequence->sequenceReversedConjugated!=NULL) delete gRACHSequence->sequenceReversedConjugated; + } + + signalVector *RACHSeq = modulateBurst(gRACHSynchSequence, + gsmPulse, + 0, + samplesPerSymbol); + + assert(RACHSeq); + + signalVector *autocorr = correlate(RACHSeq,RACHSeq,NULL,NO_DELAY); + + assert(autocorr); + + gRACHSequence = new CorrelationSequence; + gRACHSequence->sequence = RACHSeq; + gRACHSequence->sequenceReversedConjugated = reverseConjugate(RACHSeq); + gRACHSequence->gain = peakDetect(*autocorr,&gRACHSequence->TOA,NULL); + + delete autocorr; + + return true; + +} + + +bool detectRACHBurst(signalVector &rxBurst, + float detectThreshold, + int samplesPerSymbol, + complex *amplitude, + float* TOA) +{ + + //static complex staticData[500]; + + //signalVector correlatedRACH(staticData,0,rxBurst.size()); + signalVector correlatedRACH(rxBurst.size()); + correlate(&rxBurst,gRACHSequence->sequenceReversedConjugated,&correlatedRACH,NO_DELAY,true); + + float meanPower; + complex peakAmpl = peakDetect(correlatedRACH,TOA,&meanPower); + + float valleyPower = 0.0; + + // check for bogus results + if ((*TOA < 0.0) || (*TOA > correlatedRACH.size())) { + *amplitude = 0.0; + return false; + } + complex *peakPtr = correlatedRACH.begin() + (int) rint(*TOA); + + LOG(DEBUG) << "RACH corr: " << correlatedRACH; + + float numSamples = 0.0; + for (int i = 57*samplesPerSymbol; i <= 107*samplesPerSymbol;i++) { + if (peakPtr+i >= correlatedRACH.end()) + break; + valleyPower += (peakPtr+i)->norm2(); + numSamples++; + } + + if (numSamples < 2) { + *amplitude = 0.0; + return false; + } + + float RMS = sqrtf(valleyPower/(float) numSamples)+0.00001; + float peakToMean = peakAmpl.abs()/RMS; + + LOG(DEBUG) << "RACH peakAmpl=" << peakAmpl << " RMS=" << RMS << " peakToMean=" << peakToMean; + *amplitude = peakAmpl/(gRACHSequence->gain); + + *TOA = (*TOA) - gRACHSequence->TOA - 8*samplesPerSymbol; + + LOG(DEBUG) << "RACH thresh: " << peakToMean; + + return (peakToMean > detectThreshold); +} + +bool energyDetect(signalVector &rxBurst, + unsigned windowLength, + float detectThreshold, + float *avgPwr) +{ + + signalVector::const_iterator windowItr = rxBurst.begin(); //+rxBurst.size()/2 - 5*windowLength/2; + float energy = 0.0; + if (windowLength < 0) windowLength = 20; + if (windowLength > rxBurst.size()) windowLength = rxBurst.size(); + for (unsigned i = 0; i < windowLength; i++) { + energy += windowItr->norm2(); + windowItr+=4; + } + if (avgPwr) *avgPwr = energy/windowLength; + LOG(DEBUG) << "detected energy: " << energy/windowLength; + return (energy/windowLength > detectThreshold*detectThreshold); +} + + +bool analyzeTrafficBurst(signalVector &rxBurst, + unsigned TSC, + float detectThreshold, + int samplesPerSymbol, + complex *amplitude, + float *TOA, + unsigned maxTOA, + bool requestChannel, + signalVector **channelResponse, + float *channelResponseOffset) +{ + + assert(TSC<8); + assert(amplitude); + assert(TOA); + assert(gMidambles[TSC]); + + if (maxTOA < 3*samplesPerSymbol) maxTOA = 3*samplesPerSymbol; + unsigned spanTOA = maxTOA; + if (spanTOA < 5*samplesPerSymbol) spanTOA = 5*samplesPerSymbol; + + unsigned startIx = (66-spanTOA)*samplesPerSymbol; + unsigned endIx = (66+16+spanTOA)*samplesPerSymbol; + unsigned windowLen = endIx - startIx; + unsigned corrLen = 2*maxTOA+1; + + unsigned expectedTOAPeak = (unsigned) round(gMidambles[TSC]->TOA + (gMidambles[TSC]->sequenceReversedConjugated->size()-1)/2); + + signalVector burstSegment(rxBurst.begin(),startIx,windowLen); + + //static complex staticData[200]; + //signalVector correlatedBurst(staticData,0,corrLen); + signalVector correlatedBurst(corrLen); + correlate(&burstSegment, gMidambles[TSC]->sequenceReversedConjugated, + &correlatedBurst, CUSTOM,true, + expectedTOAPeak-maxTOA,corrLen); + + float meanPower; + *amplitude = peakDetect(correlatedBurst,TOA,&meanPower); + float valleyPower = 0.0; //amplitude->norm2(); + complex *peakPtr = correlatedBurst.begin() + (int) rint(*TOA); + + // check for bogus results + if ((*TOA < 0.0) || (*TOA > correlatedBurst.size())) { + *amplitude = 0.0; + return false; + } + + int numRms = 0; + for (int i = 2*samplesPerSymbol; i <= 5*samplesPerSymbol;i++) { + if (peakPtr - i >= correlatedBurst.begin()) { + valleyPower += (peakPtr-i)->norm2(); + numRms++; + } + if (peakPtr + i < correlatedBurst.end()) { + valleyPower += (peakPtr+i)->norm2(); + numRms++; + } + } + + if (numRms < 2) { + // check for bogus results + *amplitude = 0.0; + return false; + } + + float RMS = sqrtf(valleyPower/(float)numRms)+0.00001; + float peakToMean = (amplitude->abs())/RMS; + + // NOTE: Because ideal TSC is 66 symbols into burst, + // the ideal TSC has an +/- 180 degree phase shift, + // due to the pi/4 frequency shift, that + // needs to be accounted for. + + *amplitude = (*amplitude)/gMidambles[TSC]->gain; + *TOA = (*TOA) - (maxTOA); + + LOG(DEBUG) << "TCH peakAmpl=" << amplitude->abs() << " RMS=" << RMS << " peakToMean=" << peakToMean << " TOA=" << *TOA; + + LOG(DEBUG) << "autocorr: " << correlatedBurst; + + if (requestChannel && (peakToMean > detectThreshold)) { + float TOAoffset = maxTOA; //gMidambles[TSC]->TOA+(66*samplesPerSymbol-startIx); + delayVector(correlatedBurst,-(*TOA)); + // midamble only allows estimation of a 6-tap channel + signalVector channelVector(6*samplesPerSymbol); + float maxEnergy = -1.0; + int maxI = -1; + for (int i = 0; i < 7; i++) { + if (TOAoffset+(i-5)*samplesPerSymbol + channelVector.size() > correlatedBurst.size()) continue; + if (TOAoffset+(i-5)*samplesPerSymbol < 0) continue; + correlatedBurst.segmentCopyTo(channelVector,(int) floor(TOAoffset+(i-5)*samplesPerSymbol),channelVector.size()); + float energy = vectorNorm2(channelVector); + if (energy > 0.95*maxEnergy) { + maxI = i; + maxEnergy = energy; + } + } + + *channelResponse = new signalVector(channelVector.size()); + correlatedBurst.segmentCopyTo(**channelResponse,(int) floor(TOAoffset+(maxI-5)*samplesPerSymbol),(*channelResponse)->size()); + scaleVector(**channelResponse,complex(1.0,0.0)/gMidambles[TSC]->gain); + LOG(DEBUG) << "channelResponse: " << **channelResponse; + + if (channelResponseOffset) + *channelResponseOffset = 5*samplesPerSymbol-maxI; + + } + + return (peakToMean > detectThreshold); + +} + +signalVector *decimateVector(signalVector &wVector, + int decimationFactor) +{ + + if (decimationFactor <= 1) return NULL; + + signalVector *decVector = new signalVector(wVector.size()/decimationFactor); + decVector->isRealOnly(wVector.isRealOnly()); + + signalVector::iterator vecItr = decVector->begin(); + for (unsigned int i = 0; i < wVector.size();i+=decimationFactor) + *vecItr++ = wVector[i]; + + return decVector; +} + + +SoftVector *demodulateBurst(signalVector &rxBurst, + const signalVector &gsmPulse, + int samplesPerSymbol, + complex channel, + float TOA) + +{ + scaleVector(rxBurst,((complex) 1.0)/channel); + delayVector(rxBurst,-TOA); + + signalVector *shapedBurst = &rxBurst; + + // shift up by a quarter of a frequency + // ignore starting phase, since spec allows for discontinuous phase + GMSKReverseRotate(*shapedBurst); + + // run through slicer + if (samplesPerSymbol > 1) { + signalVector *decShapedBurst = decimateVector(*shapedBurst,samplesPerSymbol); + shapedBurst = decShapedBurst; + } + + LOG(DEBUG) << "shapedBurst: " << *shapedBurst; + + vectorSlicer(shapedBurst); + + SoftVector *burstBits = new SoftVector(shapedBurst->size()); + + SoftVector::iterator burstItr = burstBits->begin(); + signalVector::iterator shapedItr = shapedBurst->begin(); + for (; shapedItr < shapedBurst->end(); shapedItr++) + *burstItr++ = shapedItr->real(); + + if (samplesPerSymbol > 1) delete shapedBurst; + + return burstBits; + +} + + +// 1.0 is sampling frequency +// must satisfy cutoffFreq > 1/filterLen +signalVector *createLPF(float cutoffFreq, + int filterLen, + float gainDC) +{ + + signalVector *LPF = new signalVector(filterLen-1); + LPF->isRealOnly(true); + LPF->setSymmetry(ABSSYM); + signalVector::iterator itr = LPF->begin(); + double sum = 0.0; + for (int i = 1; i < filterLen; i++) { + float ys = sinc(M_2PI_F*cutoffFreq*((float)i-(float)(filterLen)/2.0F)); + float yg = 4.0F * cutoffFreq; + // Blackman -- less brickwall (sloping transition) but larger stopband attenuation + float yw = 0.42 - 0.5*cos(((float)i)*M_2PI_F/(float)(filterLen)) + 0.08*cos(((float)i)*2*M_2PI_F/(float)(filterLen)); + // Hamming -- more brickwall with smaller stopband attenuation + //float yw = 0.53836F - 0.46164F * cos(((float)i)*M_2PI_F/(float)(filterLen+1)); + *itr++ = (complex) ys*yg*yw; + sum += ys*yg*yw; + } + + float normFactor = gainDC/sum; //sqrtf(gainDC/vectorNorm2(*LPF)); + // normalize power + itr = LPF->begin(); + for (int i = 1; i < filterLen; i++) { + *itr = *itr*normFactor; + itr++; + } + return LPF; + +} + + + +#define POLYPHASESPAN 10 + +// assumes filter group delay is 0.5*(length of filter) +signalVector *polyphaseResampleVector(signalVector &wVector, + int P, int Q, + signalVector *LPF) + +{ + + bool deleteLPF = false; + + if (LPF==NULL) { + float cutoffFreq = (P < Q) ? (1.0/(float) Q) : (1.0/(float) P); + LPF = createLPF(cutoffFreq/3.0,100*POLYPHASESPAN+1,Q); + deleteLPF = true; + } + + signalVector *resampledVector = new signalVector((int) ceil(wVector.size()*(float) P / (float) Q)); + resampledVector->fill(0); + resampledVector->isRealOnly(wVector.isRealOnly()); + signalVector::iterator newItr = resampledVector->begin(); + + //FIXME: need to update for real-only vectors + int outputIx = (LPF->size()+1)/2/Q; //((P > Q) ? P : Q); + while (newItr < resampledVector->end()) { + int outputBranch = (outputIx*Q) % P; + int inputOffset = (outputIx*Q - outputBranch)/P; + signalVector::const_iterator inputItr = wVector.begin() + inputOffset; + signalVector::const_iterator filtItr = LPF->begin() + outputBranch; + while (inputItr >= wVector.end()) { + inputItr--; + filtItr+=P; + } + complex sum = 0.0; + if ((LPF->getSymmetry()!=ABSSYM) || (P>1)) { + if (!LPF->isRealOnly()) { + while ( (inputItr >= wVector.begin()) && (filtItr < LPF->end()) ) { + sum += (*inputItr)*(*filtItr); + inputItr--; + filtItr += P; + } + } + else { + while ( (inputItr >= wVector.begin()) && (filtItr < LPF->end()) ) { + sum += (*inputItr)*(filtItr->real()); + inputItr--; + filtItr += P; + } + } + } + else { + signalVector::const_iterator revInputItr = inputItr- LPF->size() + 1; + signalVector::const_iterator filtMidpoint = LPF->begin()+(LPF->size()-1)/2; + if (!LPF->isRealOnly()) { + while (filtItr <= filtMidpoint) { + if (inputItr < revInputItr) break; + if (inputItr == revInputItr) + sum += (*inputItr)*(*filtItr); + else if ( (inputItr < wVector.end()) && (revInputItr >= wVector.begin()) ) + sum += (*inputItr + *revInputItr)*(*filtItr); + else if ( inputItr < wVector.end() ) + sum += (*inputItr)*(*filtItr); + else if ( revInputItr >= wVector.begin() ) + sum += (*revInputItr)*(*filtItr); + inputItr--; + revInputItr++; + filtItr++; + } + } + else { + while (filtItr <= filtMidpoint) { + if (inputItr < revInputItr) break; + if (inputItr == revInputItr) + sum += (*inputItr)*(filtItr->real()); + else if ( (inputItr < wVector.end()) && (revInputItr >= wVector.begin()) ) + sum += (*inputItr + *revInputItr)*(filtItr->real()); + else if ( inputItr < wVector.end() ) + sum += (*inputItr)*(filtItr->real()); + else if ( revInputItr >= wVector.begin() ) + sum += (*revInputItr)*(filtItr->real()); + inputItr--; + revInputItr++; + filtItr++; + } + } + } + *newItr = sum; + newItr++; + outputIx++; + } + + if (deleteLPF) delete LPF; + + return resampledVector; +} + + +signalVector *resampleVector(signalVector &wVector, + float expFactor, + complex endPoint) + +{ + + if (expFactor < 1.0) return NULL; + + signalVector *retVec = new signalVector((int) ceil(wVector.size()*expFactor)); + + float t = 0.0; + + signalVector::iterator retItr = retVec->begin(); + while (retItr < retVec->end()) { + unsigned tLow = (unsigned int) floor(t); + unsigned tHigh = tLow + 1; + if (tLow > wVector.size()-1) break; + if (tHigh > wVector.size()) break; + complex lowPoint = wVector[tLow]; + complex highPoint = (tHigh == wVector.size()) ? endPoint : wVector[tHigh]; + complex a = (tHigh-t); + complex b = (t-tLow); + *retItr = (a*lowPoint + b*highPoint); + t += 1.0/expFactor; + } + + return retVec; + +} + + +// Assumes symbol-spaced sampling!!! +// Based upon paper by Al-Dhahir and Cioffi +bool designDFE(signalVector &channelResponse, + float SNRestimate, + int Nf, + signalVector **feedForwardFilter, + signalVector **feedbackFilter) +{ + + signalVector G0(Nf); + signalVector G1(Nf); + signalVector::iterator G0ptr = G0.begin(); + signalVector::iterator G1ptr = G1.begin(); + signalVector::iterator chanPtr = channelResponse.begin(); + + int nu = channelResponse.size()-1; + + *G0ptr = 1.0/sqrtf(SNRestimate); + for(int j = 0; j <= nu; j++) { + *G1ptr = chanPtr->conj(); + G1ptr++; chanPtr++; + } + + signalVector *L[Nf]; + signalVector::iterator Lptr; + float d; + for(int i = 0; i < Nf; i++) { + d = G0.begin()->norm2() + G1.begin()->norm2(); + L[i] = new signalVector(Nf+nu); + Lptr = L[i]->begin()+i; + G0ptr = G0.begin(); G1ptr = G1.begin(); + while ((G0ptr < G0.end()) && (Lptr < L[i]->end())) { + *Lptr = (*G0ptr*(G0.begin()->conj()) + *G1ptr*(G1.begin()->conj()) )/d; + Lptr++; + G0ptr++; + G1ptr++; + } + complex k = (*G1.begin())/(*G0.begin()); + + if (i != Nf-1) { + signalVector G0new = G1; + scaleVector(G0new,k.conj()); + addVector(G0new,G0); + + signalVector G1new = G0; + scaleVector(G1new,k*(-1.0)); + addVector(G1new,G1); + delayVector(G1new,-1.0); + + scaleVector(G0new,1.0/sqrtf(1.0+k.norm2())); + scaleVector(G1new,1.0/sqrtf(1.0+k.norm2())); + G0 = G0new; + G1 = G1new; + } + } + + *feedbackFilter = new signalVector(nu); + L[Nf-1]->segmentCopyTo(**feedbackFilter,Nf,nu); + scaleVector(**feedbackFilter,(complex) -1.0); + conjugateVector(**feedbackFilter); + + signalVector v(Nf); + signalVector::iterator vStart = v.begin(); + signalVector::iterator vPtr; + *(vStart+Nf-1) = (complex) 1.0; + for(int k = Nf-2; k >= 0; k--) { + Lptr = L[k]->begin()+k+1; + vPtr = vStart + k+1; + complex v_k = 0.0; + for (int j = k+1; j < Nf; j++) { + v_k -= (*vPtr)*(*Lptr); + vPtr++; Lptr++; + } + *(vStart + k) = v_k; + } + + *feedForwardFilter = new signalVector(Nf); + signalVector::iterator w = (*feedForwardFilter)->begin(); + for (int i = 0; i < Nf; i++) { + delete L[i]; + complex w_i = 0.0; + int endPt = ( nu < (Nf-1-i) ) ? nu : (Nf-1-i); + vPtr = vStart+i; + chanPtr = channelResponse.begin(); + for (int k = 0; k < endPt+1; k++) { + w_i += (*vPtr)*(chanPtr->conj()); + vPtr++; chanPtr++; + } + *w = w_i/d; + w++; + } + + + return true; + +} + +// Assumes symbol-rate sampling!!!! +SoftVector *equalizeBurst(signalVector &rxBurst, + float TOA, + int samplesPerSymbol, + signalVector &w, // feedforward filter + signalVector &b) // feedback filter +{ + + delayVector(rxBurst,-TOA); + + signalVector* postForwardFull = convolve(&rxBurst,&w,NULL,FULL_SPAN); + + signalVector* postForward = new signalVector(rxBurst.size()); + postForwardFull->segmentCopyTo(*postForward,w.size()-1,rxBurst.size()); + delete postForwardFull; + + signalVector::iterator dPtr = postForward->begin(); + signalVector::iterator dBackPtr; + signalVector::iterator rotPtr = GMSKRotation->begin(); + signalVector::iterator revRotPtr = GMSKReverseRotation->begin(); + + signalVector *DFEoutput = new signalVector(postForward->size()); + signalVector::iterator DFEItr = DFEoutput->begin(); + + // NOTE: can insert the midamble and/or use midamble to estimate BER + for (; dPtr < postForward->end(); dPtr++) { + dBackPtr = dPtr-1; + signalVector::iterator bPtr = b.begin(); + while ( (bPtr < b.end()) && (dBackPtr >= postForward->begin()) ) { + *dPtr = *dPtr + (*bPtr)*(*dBackPtr); + bPtr++; + dBackPtr--; + } + *dPtr = *dPtr * (*revRotPtr); + *DFEItr = *dPtr; + // make decision on symbol + *dPtr = (dPtr->real() > 0.0) ? 1.0 : -1.0; + //*DFEItr = *dPtr; + *dPtr = *dPtr * (*rotPtr); + DFEItr++; + rotPtr++; + revRotPtr++; + } + + vectorSlicer(DFEoutput); + + SoftVector *burstBits = new SoftVector(postForward->size()); + SoftVector::iterator burstItr = burstBits->begin(); + DFEItr = DFEoutput->begin(); + for (; DFEItr < DFEoutput->end(); DFEItr++) + *burstItr++ = DFEItr->real(); + + delete postForward; + + delete DFEoutput; + + return burstBits; +} diff --git a/TransceiverRAD1/sigProcLib.h b/TransceiverRAD1/sigProcLib.h new file mode 100644 index 0000000..cbf6963 --- /dev/null +++ b/TransceiverRAD1/sigProcLib.h @@ -0,0 +1,386 @@ +/* +* Copyright 2008 Free Software Foundation, Inc. +* +* This software is distributed under multiple licenses; see the COPYING file in the main directory for licensing information for this specific distribuion. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + 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. + +*/ + + + +#include "Vector.h" +#include "Complex.h" +#include "GSMTransfer.h" + + +using namespace GSM; + +/** Indicated signalVector symmetry */ +typedef enum Symmetry { + NONE = 0, + ABSSYM = 1 +}; + +/** Convolution type indicator */ +typedef enum ConvType { + FULL_SPAN = 0, + OVERLAP_ONLY = 1, + START_ONLY = 2, + WITH_TAIL = 3, + NO_DELAY = 4, + CUSTOM = 5, + UNDEFINED = 255 +}; + +/** the core data structure of the Transceiver */ +class signalVector: public Vector +{ + + private: + + Symmetry symmetry; ///< the symmetry of the vector + bool realOnly; ///< true if vector is real-valued, not complex-valued + + public: + + /** Constructors */ + signalVector(int dSize=0, Symmetry wSymmetry = NONE): + Vector(dSize), + realOnly(false) + { + symmetry = wSymmetry; + }; + + signalVector(complex* wData, size_t start, + size_t span, Symmetry wSymmetry = NONE): + Vector(NULL,wData+start,wData+start+span), + realOnly(false) + { + symmetry = wSymmetry; + }; + + signalVector(const signalVector &vec1, const signalVector &vec2): + Vector(vec1,vec2), + realOnly(false) + { + symmetry = vec1.symmetry; + }; + + signalVector(const signalVector &wVector): + Vector(wVector.size()), + realOnly(false) + { + wVector.copyTo(*this); + symmetry = wVector.getSymmetry(); + }; + + /** symmetry operators */ + Symmetry getSymmetry() const { return symmetry;}; + void setSymmetry(Symmetry wSymmetry) { symmetry = wSymmetry;}; + + /** real-valued operators */ + bool isRealOnly() const { return realOnly;}; + void isRealOnly(bool wOnly) { realOnly = wOnly;}; +}; + +/** Convert a linear number to a dB value */ +float dB(float x); + +/** Convert a dB value into a linear value */ +float dBinv(float x); + +/** Compute the energy of a vector */ +float vectorNorm2(const signalVector &x); + +/** Compute the average power of a vector */ +float vectorPower(const signalVector &x); + +/** Setup the signal processing library */ +void sigProcLibSetup(int samplesPerSymbol); + +/** Destroy the signal processing library */ +void sigProcLibDestroy(void); + +/** + Convolve two vectors. + @param a,b The vectors to be convolved. + @param c, A preallocated vector to hold the convolution result. + @param spanType The type/span of the convolution. + @return The convolution result. +*/ +signalVector* convolve(const signalVector *a, + const signalVector *b, + signalVector *c, + ConvType spanType, + unsigned startIx = 0, + unsigned len = 0); + +/** + Generate the GSM pulse. + @param samplesPerSymbol The number of samples per GSM symbol. + @param symbolLength The size of the pulse. + @return The GSM pulse. +*/ +signalVector* generateGSMPulse(int samplesPerSymbol, + int symbolLength); + +/** + Frequency shift a vector. + @param y The frequency shifted vector. + @param x The vector to-be-shifted. + @param freq The digital frequency shift + @param startPhase The starting phase of the oscillator + @param finalPhase The final phase of the oscillator + @return The frequency shifted vector. +*/ +signalVector* frequencyShift(signalVector *y, + signalVector *x, + double freq = 0.0, + float startPhase = 0.0, + float *finalPhase=NULL); + +/** + Correlate two vectors. + @param a,b The vectors to be correlated. + @param c, A preallocated vector to hold the correlation result. + @param spanType The type/span of the correlation. + @return The correlation result. +*/ +signalVector* correlate(signalVector *a, + signalVector *b, + signalVector *c, + ConvType spanType, + bool bReversedConjugated = false, + unsigned startIx = 0, + unsigned len = 0); + +/** Operate soft slicer on real-valued portion of vector */ +bool vectorSlicer(signalVector *x); + +/** GMSK modulate a GSM burst of bits */ +signalVector *modulateBurst(const BitVector &wBurst, + const signalVector &gsmPulse, + int guardPeriodLength, + int samplesPerSymbol); + +/** Sinc function */ +float sinc(float x); + +/** Delay a vector */ +void delayVector(signalVector &wBurst, + float delay); + +/** Add two vectors in-place */ +bool addVector(signalVector &x, + signalVector &y); + +/** Multiply two vectors in-place*/ +bool multVector(signalVector &x, + signalVector &y); + +/** Generate a vector of gaussian noise */ +signalVector *gaussianNoise(int length, + float variance = 1.0, + complex mean = complex(0.0)); + +/** + Given a non-integer index, interpolate a sample. + @param inSig The signal from which to interpolate. + @param ix The index. + @return The interpolated signal value. +*/ +complex interpolatePoint(const signalVector &inSig, + float ix); + +/** + Given a correlator output, locate the correlation peak. + @param rxBurst The correlator result. + @param peakIndex Pointer to value to receive interpolated peak index. + @param avgPower Power to value to receive mean power. + @return Peak value. +*/ +complex peakDetect(const signalVector &rxBurst, + float *peakIndex, + float *avgPwr); + +/** + Apply a scalar to a vector. + @param x The vector of interest. + @param scale The scalar. +*/ +void scaleVector(signalVector &x, + complex scale); + +/** + Add a constant offset to a vecotr. + @param x The vector of interest. + @param offset The offset. +*/ +void offsetVector(signalVector &x, + complex offset); + +/** + Generate a modulated GSM midamble, stored within the library. + @param gsmPulse The GSM pulse used for modulation. + @param samplesPerSymbol The number of samples per GSM symbol. + @param TSC The training sequence [0..7] + @return Success. +*/ +bool generateMidamble(signalVector &gsmPulse, + int samplesPerSymbol, + int TSC); +/** + Generate a modulated RACH sequence, stored within the library. + @param gsmPulse The GSM pulse used for modulation. + @param samplesPerSymbol The number of samples per GSM symbol. + @return Success. +*/ +bool generateRACHSequence(signalVector &gsmPulse, + int samplesPerSymbol); + +/** + Energy detector, checks to see if received burst energy is above a threshold. + @param rxBurst The received GSM burst of interest. + @param windowLength The number of burst samples used to compute burst energy + @param detectThreshold The detection threshold, a linear value. + @param avgPwr The average power of the received burst. + @return True if burst energy is above threshold. +*/ +bool energyDetect(signalVector &rxBurst, + unsigned windowLength, + float detectThreshold, + float *avgPwr = NULL); + +/** + RACH correlator/detector. + @param rxBurst The received GSM burst of interest. + @param detectThreshold The threshold that the received burst's post-correlator SNR is compared against to determine validity. + @param samplesPerSymbol The number of samples per GSM symbol. + @param amplitude The estimated amplitude of received RACH burst. + @param TOA The estimate time-of-arrival of received RACH burst. + @return True if burst SNR is larger that the detectThreshold value. +*/ +bool detectRACHBurst(signalVector &rxBurst, + float detectThreshold, + int samplesPerSymbol, + complex *amplitude, + float* TOA); + +/** + Normal burst correlator, detector, channel estimator. + @param rxBurst The received GSM burst of interest. + + @param detectThreshold The threshold that the received burst's post-correlator SNR is compared against to determine validity. + @param samplesPerSymbol The number of samples per GSM symbol. + @param amplitude The estimated amplitude of received TSC burst. + @param TOA The estimate time-of-arrival of received TSC burst. + @param maxTOA The maximum expected time-of-arrival + @param requestChannel Set to true if channel estimation is desired. + @param channelResponse The estimated channel. + @param channelResponseOffset The time offset b/w the first sample of the channel response and the reported TOA. + @return True if burst SNR is larger that the detectThreshold value. +*/ +bool analyzeTrafficBurst(signalVector &rxBurst, + unsigned TSC, + float detectThreshold, + int samplesPerSymbol, + complex *amplitude, + float *TOA, + unsigned maxTOA, + bool requestChannel = false, + signalVector** channelResponse = NULL, + float *channelResponseOffset = NULL); + +/** + Decimate a vector. + @param wVector The vector of interest. + @param decimationFactor The amount of decimation, i.e. the decimation factor. + @return The decimated signal vector. +*/ +signalVector *decimateVector(signalVector &wVector, + int decimationFactor); + +/** + Demodulates a received burst using a soft-slicer. + @param rxBurst The burst to be demodulated. + @param gsmPulse The GSM pulse. + @param samplesPerSymbol The number of samples per GSM symbol. + @param channel The amplitude estimate of the received burst. + @param TOA The time-of-arrival of the received burst. + @return The demodulated bit sequence. +*/ +SoftVector *demodulateBurst(signalVector &rxBurst, + const signalVector &gsmPulse, + int samplesPerSymbol, + complex channel, + float TOA); + +/** + Creates a simple Kaiser-windowed low-pass FIR filter. + @param cutoffFreq The digital 3dB bandwidth of the filter. + @param filterLen The number of taps in the filter. + @param gainDC The DC gain of the filter. + @return The desired LPF +*/ +signalVector *createLPF(float cutoffFreq, + int filterLen, + float gainDC = 1.0); + +/** + Change sampling rate of a vector via polyphase resampling. + @param wVector The vector to be resampled. + @param P The numerator, i.e. the amount of upsampling. + @param Q The denominator, i.e. the amount of downsampling. + @param LPF An optional low-pass filter used in the resampling process. + @return A vector resampled at P/Q of the original sampling rate. +*/ +signalVector *polyphaseResampleVector(signalVector &wVector, + int P, int Q, + signalVector *LPF); + +/** + Change the sampling rate of a vector via linear interpolation. + @param wVector The vector to be resampled. + @param expFactor Ratio of new sampling rate/original sampling rate. + @param endPoint ??? + @return A vector resampled a expFactor*original sampling rate. +*/ +signalVector *resampleVector(signalVector &wVector, + float expFactor, + complex endPoint); + +/** + Design the necessary filters for a decision-feedback equalizer. + @param channelResponse The multipath channel that we're mitigating. + @param SNRestimate The signal-to-noise estimate of the channel, a linear value + @param Nf The number of taps in the feedforward filter. + @param feedForwardFilter The designed feed forward filter. + @param feedbackFilter The designed feedback filter. + @return True if DFE can be designed. +*/ +bool designDFE(signalVector &channelResponse, + float SNRestimate, + int Nf, + signalVector **feedForwardFilter, + signalVector **feedbackFilter); + +/** + Equalize/demodulate a received burst via a decision-feedback equalizer. + @param rxBurst The received burst to be demodulated. + @param TOA The time-of-arrival of the received burst. + @param samplesPerSymbol The number of samples per GSM symbol. + @param w The feed forward filter of the DFE. + @param b The feedback filter of the DFE. + @return The demodulated bit sequence. +*/ +SoftVector *equalizeBurst(signalVector &rxBurst, + float TOA, + int samplesPerSymbol, + signalVector &w, + signalVector &b); diff --git a/TransceiverRAD1/sigProcLibTest.cpp b/TransceiverRAD1/sigProcLibTest.cpp new file mode 100644 index 0000000..475e194 --- /dev/null +++ b/TransceiverRAD1/sigProcLibTest.cpp @@ -0,0 +1,176 @@ +/* +* Copyright 2010 Free Software Foundation, Inc. +* Copyright (c) 2008, 2010 Kestrel Signal Processing, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +/* +Contributors: +Harvind S. Samra, hssamra@kestrelsp.com +*/ + + +#include "sigProcLib.h" +//#include "radioInterface.h" +#include +#include + +using namespace std; + +ConfigurationTable gConfig; + +int main(int argc, char **argv) { + + gLogInit("sigProcLibTest","DEBUG"); + + int samplesPerSymbol = 1; + + int TSC = 2; + + sigProcLibSetup(samplesPerSymbol); + + signalVector *gsmPulse = generateGSMPulse(2,samplesPerSymbol); + cout << *gsmPulse << endl; + + signalVector duh(600); + duh.fill(1.0); + frequencyShift(&duh,&duh,-2.0*M_PI*(400.0/1083.0)); + + cout << duh; + + exit(1); + + BitVector RACHBurstStart = "01010101"; + BitVector RACHBurstRest = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + BitVector RACHBurst(BitVector(RACHBurstStart,gRACHSynchSequence),RACHBurstRest); + + + signalVector *RACHSeq = modulateBurst(RACHBurst, + *gsmPulse, + 9, + samplesPerSymbol); + + generateRACHSequence(*gsmPulse,samplesPerSymbol); + + complex a; float t; + detectRACHBurst(*RACHSeq, 5, samplesPerSymbol,&a,&t); + + //cout << *RACHSeq << endl; + //signalVector *autocorr = correlate(RACHSeq,RACHSeq,NULL,NO_DELAY); + + //cout << *autocorr; + + //exit(1); + + + /*signalVector x(6500); + x.fill(1.0); + + frequencyShift(&x,&x,0.48*M_PI); + + signalVector *y = polyphaseResampleVector(x,96,65,NULL); + + cout << *y << endl; + + exit(1);*/ + + //CommSig normalBurstSeg = "0000000000000000000000000000000000000000000000000000000000000"; + + BitVector normalBurstSeg = "0000101010100111110010101010010110101110011000111001101010000"; + + BitVector normalBurst(BitVector(normalBurstSeg,gTrainingSequence[TSC]),normalBurstSeg); + + + generateMidamble(*gsmPulse,samplesPerSymbol,TSC); + + + signalVector *modBurst = modulateBurst(normalBurst,*gsmPulse, + 0,samplesPerSymbol); + + + //delayVector(*rsVector2,6.932); + + complex ampl = 1; + float TOA = 0; + + //modBurst = rsVector2; + //delayVector(*modBurst,0.8); + + /* + signalVector channelResponse(4); + signalVector::iterator c=channelResponse.begin(); + *c = (complex) 9000.0; c++; + *c = (complex) 0.4*9000.0; c++; c++; + *c = (complex) -1.2*0; + + signalVector *guhBurst = convolve(modBurst,&channelResponse,NULL,NO_DELAY); + delete modBurst; modBurst = guhBurst; + */ + + signalVector *chanResp; + /* + double noisePwr = 0.001/sqrtf(2); + signalVector *noise = gaussianNoise(modBurst->size(),noisePwr); + */ + float chanRespOffset; + analyzeTrafficBurst(*modBurst,TSC,8.0,samplesPerSymbol,&l,&TOA,1,true,&chanResp,&chanRespOffset); + //addVector(*modBurst,*noise); + + cout << "ampl:" << ampl << endl; + cout << "TOA: " << TOA << endl; + //cout << "chanResp: " << *chanResp << endl; + SoftVector *demodBurst = demodulateBurst(*modBurst,*gsmPulse,samplesPerSymbol,(complex) ampl, TOA); + + cout << *demodBurst << endl; + + /* + COUT("chanResp: " << *chanResp); + + signalVector *w,*b; + designDFE(*chanResp,1.0/noisePwr,7,&w,&b); + COUT("w: " << *w); + COUT("b: " << *b); + + + SoftSig *DFEBurst = equalizeBurst(*modBurst,TOA-chanRespOffset,samplesPerSymbol,*w,*b); + COUT("DFEBurst: " << *DFEBurst); + + delete gsmPulse; + delete RACHSeq; + delete modBurst; + delete sendLPF; + delete rcvLPF; + delete rsVector; + //delete rsVector2; + delete autocorr; + delete chanResp; + delete noise; + delete demodBurst; + delete w; + delete b; + delete DFEBurst; + */ + + sigProcLibDestroy(); + +} diff --git a/TransceiverRAD1/spi.h b/TransceiverRAD1/spi.h new file mode 100644 index 0000000..38ee890 --- /dev/null +++ b/TransceiverRAD1/spi.h @@ -0,0 +1,60 @@ +/* + * defines for the VRQ_SPI_READ and VRQ_SPI_WRITE commands + * + * SPI == "Serial Port Interface". SPI is a 3 wire bus plus a + * separate enable for each peripheral. The common lines are SCLK, + * SDI and SDO. The FX2 always drives SCLK and SDI, the clock and + * data lines from the FX2 to the peripheral. When enabled, a + * peripheral may drive SDO, the data line from the peripheral to the + * FX2. + * + * The SPI_READ and SPI_WRITE commands are formatted identically. + * Each specifies which peripherals to enable, whether the bits should + * be transmistted Most Significant Bit first or Least Significant Bit + * first, the number of bytes in the optional header, and the number + * of bytes to read or write in the body. + * + * The body is limited to 64 bytes. The optional header may contain + * 0, 1 or 2 bytes. For an SPI_WRITE, the header bytes are + * transmitted to the peripheral followed by the the body bytes. For + * an SPI_READ, the header bytes are transmitted to the peripheral, + * then len bytes are read back from the peripheral. + */ + +/* + * SPI_FMT_* goes in wIndexL + */ +#define SPI_FMT_xSB_MASK (1 << 7) +# define SPI_FMT_LSB (1 << 7) // least signficant bit first +# define SPI_FMT_MSB (0 << 7) // most significant bit first +#define SPI_FMT_HDR_MASK (3 << 5) +# define SPI_FMT_HDR_0 (0 << 5) // 0 header bytes +# define SPI_FMT_HDR_1 (1 << 5) // 1 header byte +# define SPI_FMT_HDR_2 (2 << 5) // 2 header bytes + +/* + * SPI_ENABLE_* goes in wIndexH + * + * For the software interface, the enables are active high. + * For reads, it's an error to have more than one enable set. + * + * [FWIW, the hardware implements them as active low. Don't change the + * definitions of these. They are related to usrp_rev1_regs.h] + */ +#define SPI_ENABLE_FPGA 0x01 // select FPGA +#define SPI_ENABLE_CODEC_A 0x02 // select AD9862 A +#define SPI_ENABLE_CODEC_B 0x04 // select AD9862 B +#define SPI_ENABLE_reserved 0x08 +#define SPI_ENABLE_TX_A 0x10 // select d'board TX A +#define SPI_ENABLE_RX_A 0x20 // select d'board RX A +#define SPI_ENABLE_TX_B 0x40 // select d'board TX B +#define SPI_ENABLE_RX_B 0x80 // select d'board RX B + +/* + * If there's one header byte, it goes in wValueL. + * + * If there are two header bytes, they go in wValueH | wValueL. + * The transmit order of the bytes (and bits within them) is + * determined by SPI_FMT_*SB + */ + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..6d85e35 --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,7199 @@ +# generated automatically by aclocal 1.9.4 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# 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. + +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- + +# serial 47 AC_PROG_LIBTOOL + + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If this macro is not defined by Autoconf, define it here. +m4_ifdef([AC_PROVIDE_IFELSE], + [], + [m4_define([AC_PROVIDE_IFELSE], + [m4_ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AC_PROG_LIBTOOL +# --------------- +AC_DEFUN([AC_PROG_LIBTOOL], +[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl +dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX +dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [AC_LIBTOOL_CXX], + [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX + ])]) +dnl And a similar setup for Fortran 77 support + AC_PROVIDE_IFELSE([AC_PROG_F77], + [AC_LIBTOOL_F77], + [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77 +])]) + +dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly. +dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run +dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both. + AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ], + [AC_LIBTOOL_GCJ], + [ifdef([AC_PROG_GCJ], + [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([A][M_PROG_GCJ], + [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])]) + ifdef([LT_AC_PROG_GCJ], + [define([LT_AC_PROG_GCJ], + defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])]) +])])# AC_PROG_LIBTOOL + + +# _AC_PROG_LIBTOOL +# ---------------- +AC_DEFUN([_AC_PROG_LIBTOOL], +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl +AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl +AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl +AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Prevent multiple expansion +define([AC_PROG_LIBTOOL], []) +])# _AC_PROG_LIBTOOL + + +# AC_LIBTOOL_SETUP +# ---------------- +AC_DEFUN([AC_LIBTOOL_SETUP], +[AC_PREREQ(2.50)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl +AC_REQUIRE([AC_PROG_NM])dnl + +AC_REQUIRE([AC_PROG_LN_S])dnl +AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! +AC_REQUIRE([AC_OBJEXT])dnl +AC_REQUIRE([AC_EXEEXT])dnl +dnl + +AC_LIBTOOL_SYS_MAX_CMD_LEN +AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +AC_LIBTOOL_OBJDIR + +AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +_LT_AC_PROG_ECHO_BACKSLASH + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'] + +# Same as above, but do not quote variable references. +[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'] + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +AC_CHECK_TOOL(AR, ar, false) +AC_CHECK_TOOL(RANLIB, ranlib, :) +AC_CHECK_TOOL(STRIP, strip, :) + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + AC_PATH_MAGIC + fi + ;; +esac + +AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +enable_win32_dll=yes, enable_win32_dll=no) + +AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +AC_ARG_WITH([pic], + [AC_HELP_STRING([--with-pic], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [pic_mode="$withval"], + [pic_mode=default]) +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +AC_LIBTOOL_LANG_C_CONFIG +_LT_AC_TAGCONFIG +])# AC_LIBTOOL_SETUP + + +# _LT_AC_SYS_COMPILER +# ------------------- +AC_DEFUN([_LT_AC_SYS_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_AC_SYS_COMPILER + + +# _LT_AC_SYS_LIBPATH_AIX +# ---------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX], +[AC_LINK_IFELSE(AC_LANG_PROGRAM,[ +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi],[]) +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi +])# _LT_AC_SYS_LIBPATH_AIX + + +# _LT_AC_SHELL_INIT(ARG) +# ---------------------- +AC_DEFUN([_LT_AC_SHELL_INIT], +[ifdef([AC_DIVERSION_NOTICE], + [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], + [AC_DIVERT_PUSH(NOTICE)]) +$1 +AC_DIVERT_POP +])# _LT_AC_SHELL_INIT + + +# _LT_AC_PROG_ECHO_BACKSLASH +# -------------------------- +# Add some code to the start of the generated configure script which +# will find an echo command which doesn't interpret backslashes. +AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], +[_LT_AC_SHELL_INIT([ +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` + ;; +esac + +echo=${ECHO-echo} +if test "X[$]1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X[$]1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} +fi + +if test "X[$]1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL [$]0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL [$]0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "[$]0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" +fi + +AC_SUBST(ECHO) +])])# _LT_AC_PROG_ECHO_BACKSLASH + + +# _LT_AC_LOCK +# ----------- +AC_DEFUN([_LT_AC_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AC_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw* | *-*-pw32*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; + ]) +esac + +need_locks="$enable_libtool_lock" + +])# _LT_AC_LOCK + + +# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], +[AC_REQUIRE([LT_AC_PROG_SED]) +AC_CACHE_CHECK([$1], [$2], + [$2=no + ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + $2=yes + fi + fi + $rm conftest* +]) + +if test x"[$]$2" = xyes; then + ifelse([$5], , :, [$5]) +else + ifelse([$6], , :, [$6]) +fi +])# AC_LIBTOOL_COMPILER_OPTION + + +# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ------------------------------------------------------------ +# Check whether the given compiler option works +AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], +[AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $3" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + else + $2=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" +]) + +if test x"[$]$2" = xyes; then + ifelse([$4], , :, [$4]) +else + ifelse([$5], , :, [$5]) +fi +])# AC_LIBTOOL_LINKER_OPTION + + +# AC_LIBTOOL_SYS_MAX_CMD_LEN +# -------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], +[# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* ) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for *BSD + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + ;; + + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac +]) +if test -n $lt_cv_sys_max_cmd_len ; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +])# AC_LIBTOOL_SYS_MAX_CMD_LEN + + +# _LT_AC_CHECK_DLFCN +# -------------------- +AC_DEFUN([_LT_AC_CHECK_DLFCN], +[AC_CHECK_HEADERS(dlfcn.h)dnl +])# _LT_AC_CHECK_DLFCN + + +# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ------------------------------------------------------------------ +AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "$cross_compiling" = yes; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +}] +EOF + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_unknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_AC_TRY_DLOPEN_SELF + + +# AC_LIBTOOL_DLOPEN_SELF +# ------------------- +AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], +[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen="shl_load"], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen="dlopen"], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_AC_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +])# AC_LIBTOOL_DLOPEN_SELF + + +# AC_LIBTOOL_PROG_CC_C_O([TAGNAME]) +# --------------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler +AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* +]) +])# AC_LIBTOOL_PROG_CC_C_O + + +# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME]) +# ----------------------------------------- +# Check to see if we can do hard links to lock some files if needed +AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], +[AC_REQUIRE([_LT_AC_LOCK])dnl + +hard_links="nottested" +if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test "$hard_links" = no; then + AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS + + +# AC_LIBTOOL_OBJDIR +# ----------------- +AC_DEFUN([AC_LIBTOOL_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +])# AC_LIBTOOL_OBJDIR + + +# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME]) +# ---------------------------------------------- +# Check hardcoding attributes. +AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_AC_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \ + test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \ + test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no && + test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then + # Linking always hardcodes the temporary library directory. + _LT_AC_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_AC_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_AC_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)]) + +if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi +])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH + + +# AC_LIBTOOL_SYS_LIB_STRIP +# ------------------------ +AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP], +[striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) +fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +])# AC_LIBTOOL_SYS_LIB_STRIP + + +# AC_LIBTOOL_SYS_DYNAMIC_LINKER +# ----------------------------- +# PORTME Fill in your ld.so characteristics +AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER], +[AC_MSG_CHECKING([dynamic linker characteristics]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/[:,\t]/ /g;s/=[^=]*$//;s/=[^= ]* / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[[89]] | openbsd2.[[89]].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test "$dynamic_linker" = no && can_build_shared=no +])# AC_LIBTOOL_SYS_DYNAMIC_LINKER + + +# _LT_AC_TAGCONFIG +# ---------------- +AC_DEFUN([_LT_AC_TAGCONFIG], +[AC_ARG_WITH([tags], + [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@], + [include additional configurations @<:@automatic@:>@])], + [tagnames="$withval"]) + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + AC_MSG_WARN([output file `$ofile' does not exist]) + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + AC_MSG_WARN([output file `$ofile' does not look like a libtool script]) + else + AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile']) + fi + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in + "") ;; + *) AC_MSG_ERROR([invalid tag name: $tagname]) + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + AC_MSG_ERROR([tag name \"$tagname\" already exists]) + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_LIBTOOL_LANG_CXX_CONFIG + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + AC_LIBTOOL_LANG_F77_CONFIG + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + AC_LIBTOOL_LANG_GCJ_CONFIG + else + tagname="" + fi + ;; + + RC) + AC_LIBTOOL_LANG_RC_CONFIG + ;; + + *) + AC_MSG_ERROR([Unsupported tag name: $tagname]) + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + AC_MSG_ERROR([unable to update list of available tagged configurations.]) + fi +fi +])# _LT_AC_TAGCONFIG + + +# AC_LIBTOOL_DLOPEN +# ----------------- +# enable checks for dlopen support +AC_DEFUN([AC_LIBTOOL_DLOPEN], + [AC_BEFORE([$0],[AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_DLOPEN + + +# AC_LIBTOOL_WIN32_DLL +# -------------------- +# declare package support for building win32 dll's +AC_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_BEFORE([$0], [AC_LIBTOOL_SETUP]) +])# AC_LIBTOOL_WIN32_DLL + + +# AC_ENABLE_SHARED([DEFAULT]) +# --------------------------- +# implement the --enable-shared flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_SHARED], +[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([shared], + [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_shared=]AC_ENABLE_SHARED_DEFAULT) +])# AC_ENABLE_SHARED + + +# AC_DISABLE_SHARED +# ----------------- +#- set the default shared flag to --disable-shared +AC_DEFUN([AC_DISABLE_SHARED], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no) +])# AC_DISABLE_SHARED + + +# AC_ENABLE_STATIC([DEFAULT]) +# --------------------------- +# implement the --enable-static flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_STATIC], +[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([static], + [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_static=]AC_ENABLE_STATIC_DEFAULT) +])# AC_ENABLE_STATIC + + +# AC_DISABLE_STATIC +# ----------------- +# set the default static flag to --disable-static +AC_DEFUN([AC_DISABLE_STATIC], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no) +])# AC_DISABLE_STATIC + + +# AC_ENABLE_FAST_INSTALL([DEFAULT]) +# --------------------------------- +# implement the --enable-fast-install flag +# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. +AC_DEFUN([AC_ENABLE_FAST_INSTALL], +[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE([fast-install], + [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac], + [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT) +])# AC_ENABLE_FAST_INSTALL + + +# AC_DISABLE_FAST_INSTALL +# ----------------------- +# set the default to --disable-fast-install +AC_DEFUN([AC_DISABLE_FAST_INSTALL], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no) +])# AC_DISABLE_FAST_INSTALL + + +# AC_LIBTOOL_PICMODE([MODE]) +# -------------------------- +# implement the --with-pic flag +# MODE is either `yes' or `no'. If omitted, it defaults to `both'. +AC_DEFUN([AC_LIBTOOL_PICMODE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +pic_mode=ifelse($#,1,$1,default) +])# AC_LIBTOOL_PICMODE + + +# AC_PROG_EGREP +# ------------- +# This is predefined starting with Autoconf 2.54, so this conditional +# definition can be removed once we require Autoconf 2.54 or later. +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP], +[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep], + [if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi]) + EGREP=$ac_cv_prog_egrep + AC_SUBST([EGREP]) +])]) + + +# AC_PATH_TOOL_PREFIX +# ------------------- +# find a file program which can recognise shared library +AC_DEFUN([AC_PATH_TOOL_PREFIX], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="ifelse([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$1; then + lt_cv_path_MAGIC_CMD="$ac_dir/$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac]) +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +])# AC_PATH_TOOL_PREFIX + + +# AC_PATH_MAGIC +# ------------- +# find a file program which can recognise a shared library +AC_DEFUN([AC_PATH_MAGIC], +[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# AC_PATH_MAGIC + + +# AC_PROG_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([AC_PROG_LD], +[AC_ARG_WITH([gnu-ld], + [AC_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test "$withval" = no || with_gnu_ld=yes], + [with_gnu_ld=no]) +AC_REQUIRE([LT_AC_PROG_SED])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case "$host_cpu" in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown +])# AC_DEPLIBS_CHECK_METHOD + + +# AC_PROG_NM +# ---------- +# find the pathname to a BSD-compatible name lister +AC_DEFUN([AC_PROG_NM], +[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/${ac_tool_prefix}nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + esac + fi + done + IFS="$lt_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi]) +NM="$lt_cv_path_NM" +])# AC_PROG_NM + + +# AC_CHECK_LIBM +# ------------- +# check for math library +AC_DEFUN([AC_CHECK_LIBM], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM="-lm") + ;; +esac +])# AC_CHECK_LIBM + + +# AC_LIBLTDL_CONVENIENCE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl convenience library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-convenience to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided, it is assumed to be `libltdl'. LIBLTDL will +# be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed with +# '${top_srcdir}/' (note the single quotes!). If your package is not +# flat and you're not using automake, define top_builddir and +# top_srcdir appropriately in the Makefiles. +AC_DEFUN([AC_LIBLTDL_CONVENIENCE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case $enable_ltdl_convenience in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_CONVENIENCE + + +# AC_LIBLTDL_INSTALLABLE([DIRECTORY]) +# ----------------------------------- +# sets LIBLTDL to the link flags for the libltdl installable library and +# LTDLINCL to the include flags for the libltdl header and adds +# --enable-ltdl-install to the configure arguments. Note that LIBLTDL +# and LTDLINCL are not AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If +# DIRECTORY is not provided and an installed libltdl is not found, it is +# assumed to be `libltdl'. LIBLTDL will be prefixed with '${top_builddir}/' +# and LTDLINCL will be prefixed with '${top_srcdir}/' (note the single +# quotes!). If your package is not flat and you're not using automake, +# define top_builddir and top_srcdir appropriately in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN([AC_LIBLTDL_INSTALLABLE], +[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, lt_dlinit, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la + LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + LTDLINCL= + fi + # For backwards non-gettext consistent compatibility... + INCLTDL="$LTDLINCL" +])# AC_LIBLTDL_INSTALLABLE + + +# AC_LIBTOOL_CXX +# -------------- +# enable support for C++ libraries +AC_DEFUN([AC_LIBTOOL_CXX], +[AC_REQUIRE([_LT_AC_LANG_CXX]) +])# AC_LIBTOOL_CXX + + +# _LT_AC_LANG_CXX +# --------------- +AC_DEFUN([_LT_AC_LANG_CXX], +[AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX]) +])# _LT_AC_LANG_CXX + +# _LT_AC_PROG_CXXCPP +# --------------- +AC_DEFUN([_LT_AC_PROG_CXXCPP], +[ +AC_REQUIRE([AC_PROG_CXX]) +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + AC_PROG_CXXCPP +fi +])# _LT_AC_PROG_CXXCPP + +# AC_LIBTOOL_F77 +# -------------- +# enable support for Fortran 77 libraries +AC_DEFUN([AC_LIBTOOL_F77], +[AC_REQUIRE([_LT_AC_LANG_F77]) +])# AC_LIBTOOL_F77 + + +# _LT_AC_LANG_F77 +# --------------- +AC_DEFUN([_LT_AC_LANG_F77], +[AC_REQUIRE([AC_PROG_F77]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77]) +])# _LT_AC_LANG_F77 + + +# AC_LIBTOOL_GCJ +# -------------- +# enable support for GCJ libraries +AC_DEFUN([AC_LIBTOOL_GCJ], +[AC_REQUIRE([_LT_AC_LANG_GCJ]) +])# AC_LIBTOOL_GCJ + + +# _LT_AC_LANG_GCJ +# --------------- +AC_DEFUN([_LT_AC_LANG_GCJ], +[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[], + [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[], + [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])], + [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])], + [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ]) +])# _LT_AC_LANG_GCJ + + +# AC_LIBTOOL_RC +# -------------- +# enable support for Windows resource files +AC_DEFUN([AC_LIBTOOL_RC], +[AC_REQUIRE([LT_AC_PROG_RC]) +_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC]) +])# AC_LIBTOOL_RC + + +# AC_LIBTOOL_LANG_C_CONFIG +# ------------------------ +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG]) +AC_DEFUN([_LT_AC_LANG_C_CONFIG], +[lt_save_CC="$CC" +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + +_LT_AC_SYS_COMPILER + +# +# Check for any special shared library compilation flags. +# +_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)= +if test "$GCC" = no; then + case $host_os in + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf' + ;; + esac +fi +if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then + AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries]) + if echo "$old_CC $old_CFLAGS " | grep "[[ ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[ ]]" >/dev/null; then : + else + AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure]) + _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no + fi +fi + + +# +# Check to make sure the static flag actually works. +# +AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1), + $_LT_AC_TAGVAR(lt_prog_compiler_static, $1), + [], + [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=]) + + +AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +# Report which librarie types wil actually be built +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) + +AC_MSG_CHECKING([whether to build shared libraries]) +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +AC_MSG_RESULT([$enable_shared]) + +AC_MSG_CHECKING([whether to build static libraries]) +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +AC_MSG_RESULT([$enable_static]) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC="$lt_save_CC" +])# AC_LIBTOOL_LANG_C_CONFIG + + +# AC_LIBTOOL_LANG_CXX_CONFIG +# -------------------------- +# Ensure that the configuration vars for the C compiler are +# suitably defined. Those variables are subsequently used by +# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'. +AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)]) +AC_DEFUN([_LT_AC_LANG_CXX_CONFIG], +[AC_LANG_PUSH(C++) +AC_REQUIRE([AC_PROG_CXX]) +AC_REQUIRE([_LT_AC_PROG_CXXCPP]) + +_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_AC_TAGVAR(allow_undefined_flag, $1)= +_LT_AC_TAGVAR(always_export_symbols, $1)=no +_LT_AC_TAGVAR(archive_expsym_cmds, $1)= +_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_direct, $1)=no +_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= +_LT_AC_TAGVAR(hardcode_libdir_separator, $1)= +_LT_AC_TAGVAR(hardcode_minus_L, $1)=no +_LT_AC_TAGVAR(hardcode_automatic, $1)=no +_LT_AC_TAGVAR(module_cmds, $1)= +_LT_AC_TAGVAR(module_expsym_cmds, $1)= +_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown +_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_AC_TAGVAR(no_undefined_flag, $1)= +_LT_AC_TAGVAR(whole_archive_flag_spec, $1)= +_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Dependencies to place before and after the object being linked: +_LT_AC_TAGVAR(predep_objects, $1)= +_LT_AC_TAGVAR(postdep_objects, $1)= +_LT_AC_TAGVAR(predeps, $1)= +_LT_AC_TAGVAR(postdeps, $1)= +_LT_AC_TAGVAR(compiler_lib_search_path, $1)= + +# Source file extension for C++ test sources. +ac_ext=cc + +# Object file extension for compiled C++ test sources. +objext=o +_LT_AC_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_AC_SYS_COMPILER + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +_LT_AC_TAGVAR(compiler, $1)=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' +else + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + AC_PROG_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +_LT_AC_TAGVAR(ld_shlibs, $1)=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GXX" = yes ; then + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + freebsd[12]*) + # C++ shared libraries reported to be fairly broken before switch to ELF + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + freebsd-elf*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + ;; + gnu*) + ;; + hpux9*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[-]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + esac + fi + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + *) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + aCC) + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case "$host_cpu" in + ia64*|hppa*64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + irix5* | irix6*) + case $cc_basename in + CC) + # SGI C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + linux*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + cxx) + # Compaq C++ + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + m88k*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + mvs*) + case $cc_basename in + cxx) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + ;; + osf3*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + cxx) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ + $rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + sco*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + lcc) + # Lucid + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[[LR]]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; +esac +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +_LT_AC_TAGVAR(GCC, $1)="$GXX" +_LT_AC_TAGVAR(LD, $1)="$LD" + +AC_LIBTOOL_POSTDEP_PREDEP($1) +AC_LIBTOOL_PROG_COMPILER_PIC($1) +AC_LIBTOOL_PROG_CC_C_O($1) +AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1) +AC_LIBTOOL_PROG_LD_SHLIBS($1) +AC_LIBTOOL_SYS_DYNAMIC_LINKER($1) +AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1) +AC_LIBTOOL_SYS_LIB_STRIP +AC_LIBTOOL_DLOPEN_SELF($1) + +AC_LIBTOOL_CONFIG($1) + +AC_LANG_POP +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +])# AC_LIBTOOL_LANG_CXX_CONFIG + +# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME]) +# ------------------------ +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[ +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +ifelse([$1],[],[cat > conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext < conftest.$ac_ext <> "$cfgfile" +ifelse([$1], [], +[#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG], +[# ### BEGIN LIBTOOL TAG CONFIG: $tagname]) + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1) + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_[]_LT_AC_TAGVAR(compiler, $1) + +# Is the compiler the GNU C compiler? +with_gcc=$_LT_AC_TAGVAR(GCC, $1) + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_[]_LT_AC_TAGVAR(LD, $1) + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1) + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1) + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1) + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1) + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1) +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1) + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) + +# Commands used to build and install a shared archive. +archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1) +archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1) +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1) +module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1) + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1) + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1) + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1) + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1) + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1) + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1) + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1) + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1) + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1) + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1) + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1) + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1) + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1) + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)" + +# Set to yes if exported symbols are required. +always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1) + +# The commands to list exported symbols. +export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1) + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1) + +# Symbols that must always be exported. +include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1) + +ifelse([$1],[], +[# ### END LIBTOOL CONFIG], +[# ### END LIBTOOL TAG CONFIG: $tagname]) + +__EOF__ + +ifelse([$1],[], [ + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +]) +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +fi +])# AC_LIBTOOL_CONFIG + + +# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], +[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl + +_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + + AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI + + +# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE +# --------------------------------- +AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_NM]) +AC_REQUIRE([AC_OBJEXT]) +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[[ABCDEGRST]]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux*) + if test "$host_cpu" = ia64; then + symcode='[[ABCDGIRSTW]]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris* | sysv5*) + symcode='[[BDRT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[[]] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi +]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE + + +# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME]) +# --------------------------------------- +AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC], +[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_AC_TAGVAR(lt_prog_compiler_static, $1)= + +AC_MSG_CHECKING([for $compiler option to produce PIC]) + ifelse([$1],[CXX],[ + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC) + # KAI C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + icpc) + # Intel C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + cxx) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC) + # Rational C++ 2.4.1 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx) + # Digital/Compaq C++ + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + sco*) + case $cc_basename in + CC) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + *) + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx) + # Green Hills C++ Compiler + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc) + # Lucid + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + unixware*) + ;; + vxworks*) + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test "$GCC" = yes; then + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon' + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + newsos6) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + ccc*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn' + ;; + + solaris*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sunos4*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + uts4*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)]) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then + AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works], + _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1), + [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])" + ;; +esac +]) + + +# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME]) +# ------------------------------------ +# See if the linker supports building shared libraries. +AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS], +[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +ifelse([$1],[CXX],[ + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" + ;; + cygwin* | mingw*) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +],[ + runpath_var= + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_AC_TAGVAR(archive_cmds, $1)= + _LT_AC_TAGVAR(archive_expsym_cmds, $1)= + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)= + _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + _LT_AC_TAGVAR(thread_safe_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown + _LT_AC_TAGVAR(hardcode_automatic, $1)=no + _LT_AC_TAGVAR(module_cmds, $1)= + _LT_AC_TAGVAR(module_expsym_cmds, $1)= + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_AC_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=no + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + _LT_AC_TAGVAR(ld_shlibs, $1)=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sunos4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_cmds, $1)="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ [01].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="$tmp_archive_cmds" + fi + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_AC_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = yes; then + runpath_var=LD_RUN_PATH + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + else + _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_AC_TAGVAR(archive_cmds, $1)='' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + + if test "$GCC" = yes; then + case $host_os in aix4.[012]|aix4.[012].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + else + # We have old collect2 + _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' + _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + _LT_AC_SYS_LIBPATH_AIX + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + _LT_AC_TAGVAR(always_export_symbols, $1)=yes + # Exported symbols can be pulled into shared objects from archives + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' ' + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + # This is similar to how AIX traditionally builds it's shared libraries. + _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + # see comment about different semantics on the GNU ld section + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + bsdi[[45]]*) + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[[012]]) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_automatic, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='' + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi + ;; + + dgux*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + freebsd1*) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + ia64*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + *) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + openbsd*) + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' + else + case $host_os in + openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + ;; + *) + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' + else + _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + sco3.2v5*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; + esac + _LT_AC_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_AC_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_AC_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4.2uw2*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_direct, $1)=yes + _LT_AC_TAGVAR(hardcode_minus_L, $1)=no + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*) + _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text' + if test "$GCC" = yes; then + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv5*) + _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_AC_TAGVAR(ld_shlibs, $1)=no + ;; + esac + fi +]) +AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)]) +test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $_LT_AC_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_MSG_CHECKING([whether -lc should be explicitly linked in]) + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1) + _LT_AC_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) + then + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no + else + _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)]) + ;; + esac + fi + ;; +esac +])# AC_LIBTOOL_PROG_LD_SHLIBS + + +# _LT_AC_FILE_LTDLL_C +# ------------------- +# Be careful that the start marker always follows a newline. +AC_DEFUN([_LT_AC_FILE_LTDLL_C], [ +# /* ltdll.c starts here */ +# #define WIN32_LEAN_AND_MEAN +# #include +# #undef WIN32_LEAN_AND_MEAN +# #include +# +# #ifndef __CYGWIN__ +# # ifdef __CYGWIN32__ +# # define __CYGWIN__ __CYGWIN32__ +# # endif +# #endif +# +# #ifdef __cplusplus +# extern "C" { +# #endif +# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); +# #ifdef __cplusplus +# } +# #endif +# +# #ifdef __CYGWIN__ +# #include +# DECLARE_CYGWIN_DLL( DllMain ); +# #endif +# HINSTANCE __hDllInstance_base; +# +# BOOL APIENTRY +# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) +# { +# __hDllInstance_base = hInst; +# return TRUE; +# } +# /* ltdll.c ends here */ +])# _LT_AC_FILE_LTDLL_C + + +# _LT_AC_TAGVAR(VARNAME, [TAGNAME]) +# --------------------------------- +AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])]) + + +# old names +AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) +AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) +AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) +AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) +AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) + +# This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL]) + +AC_DEFUN([LT_AC_PROG_GCJ], +[AC_CHECK_TOOL(GCJ, gcj, no) + test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS) +]) + +AC_DEFUN([LT_AC_PROG_RC], +[AC_CHECK_TOOL(RC, windres, no) +]) + +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +# LT_AC_PROG_SED +# -------------- +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +AC_DEFUN([LT_AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && break + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_MSG_RESULT([$SED]) +]) + +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES + +# -*- Autoconf -*- +# Copyright (C) 2002, 2003 Free Software Foundation, Inc. +# Generated from amversion.in; do not edit by hand. + +# 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, 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 + +# AM_AUTOMAKE_VERSION(VERSION) +# ---------------------------- +# Automake X.Y traces this macro to ensure aclocal.m4 has been +# generated from the m4 files accompanying Automake X.Y. +AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) + +# AM_SET_CURRENT_AUTOMAKE_VERSION +# ------------------------------- +# Call AM_AUTOMAKE_VERSION so it can be traced. +# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], + [AM_AUTOMAKE_VERSION([1.9.4])]) + +# Figure out how to run the assembler. -*- Autoconf -*- + +# serial 3 + +# Copyright (C) 2001, 2003, 2004 Free Software Foundation, Inc. + +# 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, 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. + +# AM_PROG_AS +# ---------- +AC_DEFUN([AM_PROG_AS], +[# By default we simply use the C compiler to build assembly code. +AC_REQUIRE([AC_PROG_CC]) +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS +AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)]) +AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)]) +]) + +# AM_AUX_DIR_EXPAND + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], +[dnl Rely on autoconf to set up CDPATH properly. +AC_PREREQ([2.50])dnl +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` +]) + +# AM_CONDITIONAL -*- Autoconf -*- + +# Copyright (C) 1997, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. + +# 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, 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. + +# serial 6 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], + [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi +AC_CONFIG_COMMANDS_PRE( +[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then + AC_MSG_ERROR([[conditional "$1" was never defined. +Usually this means the macro was only invoked conditionally.]]) +fi])]) + +# serial 7 -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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, 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. + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# ---------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX", "GCJ", or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) +AM_CONDITIONAL([am__fastdep$1], [ + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[AC_REQUIRE([AM_SET_LEADING_DOT])dnl +AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH]) +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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, 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. + +#serial 2 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`AS_DIRNAME("$mf")` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`AS_DIRNAME(["$file"])` + AS_MKDIR_P([$dirpart/$fdir]) + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +])# _AM_OUTPUT_DEPENDENCY_COMMANDS + + +# AM_OUTPUT_DEPENDENCY_COMMANDS +# ----------------------------- +# This macro should only be invoked once -- use via AC_REQUIRE. +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], +[AC_CONFIG_COMMANDS([depfiles], + [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], + [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) +]) + +# Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 7 + +# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. +AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) + +# Do all the work for Automake. -*- Autoconf -*- + +# This macro actually does too much some checks are only needed if +# your package does certain things. But this isn't really a big deal. + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +# Free Software Foundation, Inc. + +# 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, 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. + +# serial 11 + +# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) +# AM_INIT_AUTOMAKE([OPTIONS]) +# ----------------------------------------------- +# The call with PACKAGE and VERSION arguments is the old style +# call (pre autoconf-2.50), which is being phased out. PACKAGE +# and VERSION should now be passed to AC_INIT and removed from +# the call to AM_INIT_AUTOMAKE. +# We support both call styles for the transition. After +# the next Automake release, Autoconf can make the AC_INIT +# arguments mandatory, and then we can depend on a new Autoconf +# release and drop the old call support. +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_PREREQ([2.58])dnl +dnl Autoconf wants to disallow AM_ names. We explicitly allow +dnl the ones we care about. +m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl +AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl +AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi +AC_SUBST([CYGPATH_W]) + +# Define the identity of the package. +dnl Distinguish between old-style and new-style calls. +m4_ifval([$2], +[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl + AC_SUBST([PACKAGE], [$1])dnl + AC_SUBST([VERSION], [$2])], +[_AM_SET_OPTIONS([$1])dnl + AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl + AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl + +_AM_IF_OPTION([no-define],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) + AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_SET_LEADING_DOT])dnl +_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], + [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], + [_AM_PROG_TAR([v7])])]) +_AM_IF_OPTION([no-dependencies],, +[AC_PROVIDE_IFELSE([AC_PROG_CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) +]) + + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. The stamp files are numbered to have different names. + +# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the +# loop where config.status creates the headers, so we can generate +# our stamp files there. +AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], +[# Compute $1's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $1 | $1:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# -*- Autoconf -*- +# Copyright (C) 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 1 + +# Check whether the underlying file-system supports filenames +# with a leading dot. For instance MS-DOS doesn't. +AC_DEFUN([AM_SET_LEADING_DOT], +[rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null +AC_SUBST([am__leading_dot])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 2 + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi +AC_SUBST([am__include]) +AC_SUBST([am__quote]) +AC_MSG_RESULT([$_am_result]) +rm -f confinc confmf +]) + +# -*- Autoconf -*- + + +# Copyright (C) 1997, 1999, 2000, 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 3 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# AM_PROG_MKDIR_P +# --------------- +# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. + +# Copyright (C) 2003, 2004 Free Software Foundation, Inc. + +# 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, 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. + +# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories +# created by `make install' are always world readable, even if the +# installer happens to have an overly restrictive umask (e.g. 077). +# This was a mistake. There are at least two reasons why we must not +# use `-m 0755': +# - it causes special bits like SGID to be ignored, +# - it may be too restrictive (some setups expect 775 directories). +# +# Do not use -m 0755 and let people choose whatever they expect by +# setting umask. +# +# We cannot accept any implementation of `mkdir' that recognizes `-p'. +# Some implementations (such as Solaris 8's) are not thread-safe: if a +# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' +# concurrently, both version can detect that a/ is missing, but only +# one can create it and the other will error out. Consequently we +# restrict ourselves to GNU make (using the --version option ensures +# this.) +AC_DEFUN([AM_PROG_MKDIR_P], +[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi +AC_SUBST([mkdir_p])]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 2 + +# _AM_MANGLE_OPTION(NAME) +# ----------------------- +AC_DEFUN([_AM_MANGLE_OPTION], +[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) + +# _AM_SET_OPTION(NAME) +# ------------------------------ +# Set option NAME. Presently that only means defining a flag for this option. +AC_DEFUN([_AM_SET_OPTION], +[m4_define(_AM_MANGLE_OPTION([$1]), 1)]) + +# _AM_SET_OPTIONS(OPTIONS) +# ---------------------------------- +# OPTIONS is a space-separated list of Automake options. +AC_DEFUN([_AM_SET_OPTIONS], +[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) + +# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) +# ------------------------------------------- +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +AC_DEFUN([_AM_IF_OPTION], +[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) + +# +# Check to make sure that the build environment is sane. +# + +# Copyright (C) 1996, 1997, 2000, 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + +# AM_PROG_INSTALL_STRIP + +# Copyright (C) 2001, 2003 Free Software Foundation, Inc. + +# 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, 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. + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +dnl Don't test for $cross_compiling = yes, because it might be `maybe'. +if test "$cross_compiling" != no; then + AC_CHECK_TOOL([STRIP], [strip], :) +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004 Free Software Foundation, Inc. + +# 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, 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. + +# serial 1 + + +# _AM_PROG_TAR(FORMAT) +# -------------------- +# Check how to create a tarball in format FORMAT. +# FORMAT should be one of `v7', `ustar', or `pax'. +# +# Substitute a variable $(am__tar) that is a command +# writing to stdout a FORMAT-tarball containing the directory +# $tardir. +# tardir=directory && $(am__tar) > result.tar +# +# Substitute a variable $(am__untar) that extract such +# a tarball read from stdin. +# $(am__untar) < result.tar +AC_DEFUN([_AM_PROG_TAR], +[# Always define AMTAR for backward compatibility. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +for _am_tool in $_am_tools +do + case $_am_tool in + gnutar) + for _am_tar in tar gnutar gtar; + do + AM_RUN_LOG([$_am_tar --version]) && break + done + am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' + am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' + am__untar="$_am_tar -xf -" + ;; + plaintar) + # Must skip GNU tar: if it does not support --format= it doesn't create + # ustar tarball either. + (tar --version) >/dev/null 2>&1 && continue + am__tar='tar chf - "$$tardir"' + am__tar_='tar chf - "$tardir"' + am__untar='tar xf -' + ;; + pax) + am__tar='pax -L -x $1 -w "$$tardir"' + am__tar_='pax -L -x $1 -w "$tardir"' + am__untar='pax -r' + ;; + cpio) + am__tar='find "$$tardir" -print | cpio -o -H $1 -L' + am__tar_='find "$tardir" -print | cpio -o -H $1 -L' + am__untar='cpio -i -H $1 -d' + ;; + none) + am__tar=false + am__tar_=false + am__untar=false + ;; + esac + + # If the value was cached, stop now. We just wanted to have am__tar + # and am__untar set. + test -n "${am_cv_prog_tar_$1}" && break + + # tar/untar a dummy directory, and stop if the command works + rm -rf conftest.dir + mkdir conftest.dir + echo GrepMe > conftest.dir/file + AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) + rm -rf conftest.dir + if test -s conftest.tar; then + AM_RUN_LOG([$am__untar /dev/null 2>&1 && break + fi +done +rm -rf conftest.dir + +AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) +AC_MSG_RESULT([$am_cv_prog_tar_$1])]) +AC_SUBST([am__tar]) +AC_SUBST([am__untar]) +]) # _AM_PROG_TAR + diff --git a/apps/Makefile.am b/apps/Makefile.am new file mode 100644 index 0000000..ba10776 --- /dev/null +++ b/apps/Makefile.am @@ -0,0 +1,47 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2011 Range Networks, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -ldl -pthread + +noinst_PROGRAMS = \ + OpenBTS + +OpenBTS_SOURCES = OpenBTS.cpp +OpenBTS_LDADD = \ + $(CLI_LA) \ + $(SIP_LA) \ + $(GSM_LA) \ + $(TRX_LA) \ + $(GLOBALS_LA) \ + $(CONTROL_LA) \ + $(SR_LA) \ + $(COMMON_LA) \ + $(SQLITE_LA) \ + $(SMS_LA) \ + $(OSIP_LIBS) \ + $(ORTP_LIBS) + +EXTRA_DIST = \ + OpenBTS.example.sql + diff --git a/apps/Makefile.in b/apps/Makefile.in new file mode 100644 index 0000000..1cea6e9 --- /dev/null +++ b/apps/Makefile.in @@ -0,0 +1,554 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2011 Range Networks, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +SOURCES = $(OpenBTS_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.common +noinst_PROGRAMS = OpenBTS$(EXEEXT) +subdir = apps +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) +am_OpenBTS_OBJECTS = OpenBTS.$(OBJEXT) +OpenBTS_OBJECTS = $(am_OpenBTS_OBJECTS) +am__DEPENDENCIES_1 = $(top_builddir)/CLI/libcli.la +am__DEPENDENCIES_2 = $(top_builddir)/SIP/libSIP.la +am__DEPENDENCIES_3 = $(top_builddir)/GSM/libGSM.la +am__DEPENDENCIES_4 = $(top_builddir)/TRXManager/libtrxmanager.la +am__DEPENDENCIES_5 = $(top_builddir)/Globals/libglobals.la +am__DEPENDENCIES_6 = $(top_builddir)/Control/libcontrol.la +am__DEPENDENCIES_7 = $(top_builddir)/SR/libSR.la +am__DEPENDENCIES_8 = $(top_builddir)/CommonLibs/libcommon.la +am__DEPENDENCIES_9 = $(top_builddir)/sqlite3/libsqlite.la +am__DEPENDENCIES_10 = $(top_builddir)/SMS/libSMS.la +am__DEPENDENCIES_11 = +OpenBTS_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ + $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4) \ + $(am__DEPENDENCIES_5) $(am__DEPENDENCIES_6) \ + $(am__DEPENDENCIES_7) $(am__DEPENDENCIES_8) \ + $(am__DEPENDENCIES_9) $(am__DEPENDENCIES_10) \ + $(am__DEPENDENCIES_11) $(am__DEPENDENCIES_11) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(OpenBTS_SOURCES) +DIST_SOURCES = $(OpenBTS_SOURCES) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -ldl -pthread +OpenBTS_SOURCES = OpenBTS.cpp +OpenBTS_LDADD = \ + $(CLI_LA) \ + $(SIP_LA) \ + $(GSM_LA) \ + $(TRX_LA) \ + $(GLOBALS_LA) \ + $(CONTROL_LA) \ + $(SR_LA) \ + $(COMMON_LA) \ + $(SQLITE_LA) \ + $(SMS_LA) \ + $(OSIP_LIBS) \ + $(ORTP_LIBS) + +EXTRA_DIST = \ + OpenBTS.example.sql + +all: all-am + +.SUFFIXES: +.SUFFIXES: .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu apps/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu apps/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstPROGRAMS: + @list='$(noinst_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + echo " rm -f $$p $$f"; \ + rm -f $$p $$f ; \ + done +OpenBTS$(EXEEXT): $(OpenBTS_OBJECTS) $(OpenBTS_DEPENDENCIES) + @rm -f OpenBTS$(EXEEXT) + $(CXXLINK) $(OpenBTS_LDFLAGS) $(OpenBTS_OBJECTS) $(OpenBTS_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OpenBTS.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(PROGRAMS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/apps/OpenBTS.cpp b/apps/OpenBTS.cpp new file mode 100644 index 0000000..2756f3f --- /dev/null +++ b/apps/OpenBTS.cpp @@ -0,0 +1,379 @@ +/* +* Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +* Copyright 2010 Kestrel Signal Processing, Inc. +* Copyright 2011 Range Networks, Inc. +* +* This software is distributed under the terms of the GNU Affero Public License. +* See the COPYING file in the main directory for details. +* +* This use of this software may be subject to additional restrictions. +* See the LEGAL file in the main directory for details. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +*/ + +#include +#include + +#include +// Load configuration from a file. +ConfigurationTable gConfig("/etc/OpenBTS/OpenBTS.db"); + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#ifdef HAVE_LIBREADLINE // [ +//# include +# include +# include +#endif // HAVE_LIBREADLINE ] + +using namespace std; +using namespace GSM; + + +const char* gDateTime = __DATE__ " " __TIME__; + + +// All of the other globals that rely on the global configuration file need to +// be declared here. + +// The TMSI Table. +Control::TMSITable gTMSITable(gConfig.getStr("Control.Reporting.TMSITable").c_str()); + +// The transaction table. +Control::TransactionTable gTransactionTable; + +// Physical status reporting +GSM::PhysicalStatus gPhysStatus(gConfig.getStr("Control.Reporting.PhysStatusTable").c_str()); + +// The global SIPInterface object. +SIP::SIPInterface gSIPInterface; + +// Configure the BTS object based on the config file. +// So don't create this until AFTER loading the config file. +GSMConfig gBTS; + +// Our interface to the software-defined radio. +TransceiverManager gTRX(gConfig.getStr("TRX.IP").c_str(), gConfig.getNum("TRX.Port")); + +// Subscriber registry +SubscriberRegistry gSubscriberRegistry; + + +/** Define a function to call any time the configuration database changes. */ +void purgeConfig(void*,int,char const*, char const*, sqlite3_int64) +{ + LOG(INFO) << "purging configuration cache"; + gConfig.purge(); + gBTS.regenerateBeacon(); +} + + + +const char* transceiverPath = "./transceiver"; + +pid_t gTransceiverPid = 0; + +void startTransceiver() +{ + // Start the transceiver binary, if the path is defined. + // If the path is not defined, the transceiver must be started by some other process. + char TRXnumARFCN[4]; + sprintf(TRXnumARFCN,"%1d",1); + LOG(NOTICE) << "starting transceiver " << transceiverPath << " " << TRXnumARFCN; + gTransceiverPid = vfork(); + LOG_ASSERT(gTransceiverPid>=0); + if (gTransceiverPid==0) { + // Pid==0 means this is the process that starts the transceiver. + execlp(transceiverPath,transceiverPath,TRXnumARFCN,NULL); + LOG(EMERG) << "cannot find " << transceiverPath; + _exit(1); + } +} + + + + +int main(int argc, char *argv[]) +{ + + try { + + srandom(time(NULL)); + + gConfig.setUpdateHook(purgeConfig); + gLogInit("openbts",gConfig.getStr("Log.Level").c_str(),LOG_LOCAL7); + LOG(ALERT) << "OpenBTS starting, ver " << VERSION << " build date " << __DATE__; + + COUT("\n\n" << gOpenBTSWelcome << "\n"); + COUT("\nStarting the system..."); + + startTransceiver(); + + // Start the SIP interface. + gSIPInterface.start(); + + + // + // Configure the radio. + // + + // Start the transceiver interface. + // Sleep long enough for the USRP to bootload. + sleep(5); + gTRX.start(); + + // Set up the interface to the radio. + // Get a handle to the C0 transceiver interface. + ARFCNManager* C0radio = gTRX.ARFCN(); + + // Tuning. + // Make sure its off for tuning. + C0radio->powerOff(); + // Get the ARFCN list. + unsigned C0 = gConfig.getNum("GSM.Radio.C0"); + // Tune the radio. + LOG(INFO) << "tuning TRX to ARFCN " << C0; + ARFCNManager* radio = gTRX.ARFCN(); + radio->tune(C0); + + // Set TSC same as BCC everywhere. + C0radio->setTSC(gBTS.BCC()); + + // Set maximum expected delay spread. + C0radio->setMaxDelay(gConfig.getNum("GSM.Radio.MaxExpectedDelaySpread")); + + // Set Receiver Gain + C0radio->setRxGain(gConfig.getNum("GSM.Radio.RxGain")); + + // Turn on and power up. + C0radio->powerOn(); + C0radio->setPower(gConfig.getNum("GSM.Radio.PowerManager.MinAttenDB")); + + // + // Create a C-V channel set on C0T0. + // + + // C-V on C0T0 + C0radio->setSlot(0,5); + // SCH + SCHL1FEC SCH; + SCH.downstream(C0radio); + SCH.open(); + // FCCH + FCCHL1FEC FCCH; + FCCH.downstream(C0radio); + FCCH.open(); + // BCCH + BCCHL1FEC BCCH; + BCCH.downstream(C0radio); + BCCH.open(); + // RACH + RACHL1FEC RACH(gRACHC5Mapping); + RACH.downstream(C0radio); + RACH.open(); + // CCCHs + CCCHLogicalChannel CCCH0(gCCCH_0Mapping); + CCCH0.downstream(C0radio); + CCCH0.open(); + CCCHLogicalChannel CCCH1(gCCCH_1Mapping); + CCCH1.downstream(C0radio); + CCCH1.open(); + CCCHLogicalChannel CCCH2(gCCCH_2Mapping); + CCCH2.downstream(C0radio); + CCCH2.open(); + // use CCCHs as AGCHs + gBTS.addAGCH(&CCCH0); + gBTS.addAGCH(&CCCH1); + gBTS.addAGCH(&CCCH2); + + // C-V C0T0 SDCCHs + SDCCHLogicalChannel C0T0SDCCH[4] = { + SDCCHLogicalChannel(0,gSDCCH_4_0), + SDCCHLogicalChannel(0,gSDCCH_4_1), + SDCCHLogicalChannel(0,gSDCCH_4_2), + SDCCHLogicalChannel(0,gSDCCH_4_3), + }; + Thread C0T0SDCCHControlThread[4]; + for (int i=0; i<4; i++) { + C0T0SDCCH[i].downstream(C0radio); + C0T0SDCCHControlThread[i].start((void*(*)(void*))Control::DCCHDispatcher,&C0T0SDCCH[i]); + C0T0SDCCH[i].open(); + gBTS.addSDCCH(&C0T0SDCCH[i]); + } + + + // + // Configure the other slots. + // + + // Count configured slots. + unsigned sCount = 1; + + if (gConfig.defines("GSM.Channels.C1sFirst")) { + // Create C-I slots. + for (int i=0; i home_dir_len) { + if(!(history_name = (char *)malloc(history_len))) { + LOG(ERR) << "malloc failed: " << strerror(errno); + exit(2); + } + memcpy(history_name, home_dir, home_dir_len); + memcpy(history_name + home_dir_len, history_file_name, + history_file_len + 1); + read_history(history_name); + } + } +#endif // HAVE_LIBREADLINE ] + + + + LOG(INFO) << "system ready"; + COUT("\n\nWelcome to OpenBTS. Type \"help\" to see available commands."); + // FIXME: We want to catch control-d (emacs keybinding for exit()) + + + // The logging parts were removed from this loop. + // If we want them back, they will need to go into their own thread. + while (1) { +#ifdef HAVE_LIBREADLINE // [ + char *inbuf = readline(gConfig.getStr("CLI.Prompt").c_str()); + if (!inbuf) break; + if (*inbuf) { + add_history(inbuf); + // The parser returns -1 on exit. + if (gParser.process(inbuf, cout, cin)<0) { + free(inbuf); + break; + } + } + free(inbuf); +#else // HAVE_LIBREADLINE ][ + cout << endl << gConfig.getStr("CLI.Prompt"); + cout.flush(); + char inbuf[1024]; + cin.getline(inbuf,1024,'\n'); + // The parser returns -1 on exit. + if (gParser.process(inbuf,cout,cin)<0) break; +#endif // !HAVE_LIBREADLINE ] + } + +#ifdef HAVE_LIBREADLINE // [ + if(history_name) { + int e = write_history(history_name); + if(e) { + fprintf(stderr, "error: history: %s\n", strerror(e)); + } + free(history_name); + history_name = 0; + } +#endif // HAVE_LIBREADLINE ] + + if (gTransceiverPid) kill(gTransceiverPid, SIGKILL); + + + } + + catch (ConfigurationTableKeyNotFound e) { + + LOG(ALERT) << "configuration key " << e.key() << " not defined"; + exit(2); + } + +} + +// vim: ts=4 sw=4 diff --git a/apps/OpenBTS.example.sql b/apps/OpenBTS.example.sql new file mode 100644 index 0000000..84045a9 --- /dev/null +++ b/apps/OpenBTS.example.sql @@ -0,0 +1,120 @@ +PRAGMA foreign_keys=OFF; +BEGIN TRANSACTION; +CREATE TABLE CONFIG ( KEYSTRING TEXT UNIQUE NOT NULL, VALUESTRING TEXT, STATIC INTEGER DEFAULT 0, OPTIONAL INTEGER DEFAULT 0, COMMENTS TEXT DEFAULT ''); +INSERT INTO "CONFIG" VALUES('CLI.Prompt','OpenBTS> ',0,0,'Prompt for the OpenBTS command line interface.'); +INSERT INTO "CONFIG" VALUES('Control.Reporting.PhysStatusTable','/var/run/OpenBTS/ChannelTable.db',1,0,'File path for channel status reporting database. Static.'); +INSERT INTO "CONFIG" VALUES('Control.Reporting.TMSITable','/var/run/OpenBTS/TMSITable.db',1,0,'File path for TMSITable database. Static.'); +INSERT INTO "CONFIG" VALUES('Control.GSMTAP.TargetIP','127.0.0.1',0,1,'Target IP address for GSMTAP packets; the IP address of Wireshark, if you use it for GSM.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.AttachDetach',1,0,0,'Attach/detach flag. Set to 1 to use attach/detach procedure, 0 otherwise. This will make initial LUR more prompt. It will also cause an un-regstration if the handset powers off and really heavy LUR loads in areas with spotty coverage.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.FailedRegistration.Message','Your handset is not provisioned for this network. ',0,1,'If defined, send this text message, followed by the IMSI, to unprovisioned handsets that are denied registration.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.FailedRegistration.ShortCode','1000',0,1,'The return address for the failed registration message. If the message is defined, this must also be defined.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.NormalRegistration.Message',NULL,0,1,'If defined, send this text message, followed by the IMSI, to provisioned handsets when they attach on Um.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.NormalRegistration.ShortCode','0000',0,1,'The return address for the normal registration message. If the message is defined, this must also be defined.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.OpenRegistration',NULL,0,1,'If not NULL, allow unprovisioned handsets to attach in Um.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.OpenRegistration.Message','Welcome to the GSM test network. Your IMSI is ',0,1,'If defined, send this text message, followed by the IMSI, to unprovisioned handsets when they attach on Um due to open registration.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.OpenRegistration.ShortCode','101',0,1,'The return address for the open registration message. If the message is defined, this must also be defined.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.QueryClassmark',NULL,0,1,'If not NULL, query every MS for classmark during LUR.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.QueryIMEI',NULL,0,1,'If not NULL, query every MS for IMSI during LUR.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.QueryRRLP',NULL,0,1,'If not NULL, query every MS for its location via RRLP during LUR.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.SendTMSIs',NULL,0,1,'If not NULL, send new TMSI assignments to handsets that are allowed to attach.'); +INSERT INTO "CONFIG" VALUES('Control.LUR.UnprovisionedRejectCause','0x04',0,0,'Reject cause for location updating failures for unprovisioned phones. Reject causes come from GSM 04.08 10.5.3.6. Reject cause 0x04, IMSI not in VLR, is usually the right one.'); +INSERT INTO "CONFIG" VALUES('Control.NumSQLTries','3',0,0,'Number of times to retry SQL queries before declaring a database access failure.'); +INSERT INTO "CONFIG" VALUES('Control.TMSITable.MaxAge','72',0,0,'Maximum allowed age for a TMSI in hours.'); +INSERT INTO "CONFIG" VALUES('Control.TMSITable.MaxSize','100000',0,0,'Maximum size of TMSI table before oldest TMSIs are discarded.'); +INSERT INTO "CONFIG" VALUES('Control.VEA',1,0,1,'If not NULL, user very early assignment for speech call establishment. See GSM 04.08 Section 7.3.2 for a detailed explanation of assignment types. If VEA is selected, GSM.CellSelection.NECI should be set to 1. See GSM 04.08 Sections 9.1.8 and 10.5.2.4 for an explanation of the NECI bit.'); +INSERT INTO "CONFIG" VALUES('GSM.CCCH.AGCH.QMax','5',0,0,'Maximum number of access grants to be queued for transmission on AGCH before declaring congrestion.'); +INSERT INTO "CONFIG" VALUES('GSM.CCCH.CCCH-CONF','1',0,0,'CCCH configuration type. See GSM 10.5.2.11 for encoding. Value of 1 means we are using a C-V beacon. Any other value selects a C-IV beacon.'); +INSERT INTO "CONFIG" VALUES('GSM.CCCH.PCH.Reserve','0',0,0,'Number of CCCH subchannels to reserve for paging.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.CELL-RESELECT-HYSTERESIS','3',0,0,'Cell Reselection Hysteresis. See GSM 04.08 10.5.2.4, Table 10.5.23 for encoding. Encoding is $2N$ dB, values of $N$ are 0...7 for 0...14 dB.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.MS-TXPWR-MAX-CCH','0',0,0,'Cell selection parameters. See GSM 04.08 10.5.2.4.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.NCCsPermitted','1',0,0,'NCCs Permitted. An 8-bit mask of allowed NCCs. Unless you are coordinating with another carrier, this should probably just select your own NCC.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.NECI','1',0,0,'NECI, New Establishment Causes. This must be set to "1" if you want to support very early assignment (VEA). It can be set to "1" even if you do not use VEA, so you might as well leave it as "1". See GSM 04.08 10.5.2.4, Table 10.5.23 and 04.08 9.1.8, Table 9.9 and the Control.VEA parameter.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.Neighbors','39 41 43',0,0,'ARFCNs of neighboring cells.'); +INSERT INTO "CONFIG" VALUES('GSM.CellSelection.RXLEV-ACCESS-MIN','0',0,0,'Cell selection parameters. See GSM 04.08 10.5.2.4.'); +INSERT INTO "CONFIG" VALUES('GSM.Channels.C1sFirst',NULL,1,0,'If not NULL, allocate C-I slots first, starting at C0T1. Otherwise, allocate C-VII slots first. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Channels.NumC1s','7',1,0,'Number of Combination-I timeslots to configure. The C-I slot carries a single full-rate TCH, used for speech calling. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Channels.NumC7s','0',1,0,'Number of Combination-VII timeslots to configure. The C-VII slot carries 8 SDCCHs, useful to handle high registration loads or SMS. If C0T0 is C-IV, you must have at least one C-VII also. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.BSIC.BCC','2',0,0,'GSM basestation color code; lower 3 bits of the BSIC. BCC values in a multi-BTS network should be assigned so that BTS units with overlapping coverage do not share a BCC. This value will also select the training sequence used for all slots on this unit.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.BSIC.NCC','0',0,0,'GSM network color code; upper 3 bits of the BSIC. Assigned by your national regulator. Must be distinct from NCCs of other GSM operators in your area.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.CI','10',0,0,'Cell ID, 16 bits. Should be unique.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.LAC','1000',0,0,'Location area code, 16 bits, values 0xFFxx are reserved. For multi-BTS networks, assign a unique LAC to each BTS unit. (That is not the normal procedure in conventional GSM networks, but is the correct procedure in OpenBTS networks.)'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.MCC','001',0,0,'Mobile country code, 2 or 3 digits. Defined in ITU-T E.212.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.MNC','01',0,0,'Mobile network code; Must be 3 dgits. Assigned by your national regulator.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.ShortName','Range',0,1,'Network short name, displayed on some phones. Optional but must be defined if you also want the network to send time-of-day.'); +INSERT INTO "CONFIG" VALUES('GSM.Identity.ShowCountry',1,0,0,'If not NULL, tell the phone to show the country name based on the MCC.'); +INSERT INTO "CONFIG" VALUES('GSM.MS.Power.Damping','50',0,0,'Damping value for MS power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.MS.Power.Max','33',0,0,'Maximum commanded MS power level in dBm.'); +INSERT INTO "CONFIG" VALUES('GSM.MS.Power.Min','5',0,0,'Minimum commanded MS power level in dBm.'); +INSERT INTO "CONFIG" VALUES('GSM.MS.TA.Damping','50',0,0,'Damping value for timing advance control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.MS.TA.Max','5',0,0,'Maximum allowed timing advance in symbol periods. Ignore RACH bursts with delays greater than this. Can be used to limit service range.'); +INSERT INTO "CONFIG" VALUES('GSM.MaxSpeechLatency','2',0,0,'Maximum allowed speech buffering latency, in 20 ms frames. If the jitter is larger than this delay, frames will be lost.'); +INSERT INTO "CONFIG" VALUES('GSM.RACH.AC','0',0,0,'Access class flags. This is the raw parameter sent on the BCCH. See GSM 04.08 10.5.2.29 for encoding. Set to 0 to allow full access. If you do not have proper PSAP integration, set to 0x0400 to indicate no support for emergency calls.'); +INSERT INTO "CONFIG" VALUES('GSM.RACH.MaxRetrans','1',0,0,'Maximum RACH retransmission attempts. This is the raw parameter sent on the BCCH. See GSM 04.08 10.5.2.29 for encoding.'); +INSERT INTO "CONFIG" VALUES('GSM.RACH.TxInteger','14',0,0,'Parameter to spread RACH busts over time. This is the raw parameter sent on the BCCH. See GSM 04.08 10.5.2.29 for encoding.'); +INSERT INTO "CONFIG" VALUES('GSM.RADIO-LINK-TIMEOUT','15',0,0,' L1 radio link timeout. This is the raw parameter sent on the BCCH; see GSM 10.5.2.3 for encoding. Should be coordinated with T3109.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.ACCURACY','40',0,0,'Requested accuracy of location request. K in 10(1.1**K-1). See 3GPP 03.32, sect 6.2'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.ALMANAC.REFRESH.TIME','24.0',0,0,'How often the almanac is refreshed, in hours'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.ALMANAC.URL','http://www.navcen.uscg.gov/?pageName=currentAlmanac&format=yuma',0,0,'URL of almanac source.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.EPHEMERIS.REFRESH.TIME','1.0',0,0,'How often the ephemeris is refreshed, in hours.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.EPHEMERIS.URL','ftp://ftp.trimble.com/pub/eph/CurRnxN.nav',0,0,'URL of ephemeris source.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.RESPONSETIME','4',0,0,'Mobile timeout. (OpenBTS timeout is 130 sec = max response time + 2.) N in 2**N. See 3GPP 04.31 sect A.2.2.1'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.SEED.ALTITUDE','0',0,0,'Seed altitude in meters wrt geoidal surface.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.SEED.LATITUDE','37.357331',0,0,'Seed latitude in degrees. -90 (south pole) .. +90 (north pole)'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.SEED.LONGITUDE','-122.037807',0,0,'Seed longitude in degrees. -180 (west of greenwich) .. 180 (east)'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.SERVER.URL','http://localhost/cgi/rrlpserver.cgi',0,0,'URL of RRLP server.'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.ALMANAC.ASSIST.PRESENT','0',0,0,'1=send almanac info to mobile; 0=do not'); +INSERT INTO "CONFIG" VALUES('GSM.RRLP.EPHEMERIS.ASSIST.COUNT','9',0,0,'number of satellites to include in navigation model'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.Band','900',1,0,'The GSM operating band. Valid values are 850 (GSM850), 900 (PGSM900), 1800 (DCS1800) and 1900 (PCS1900). For most Range models, this value is dictated by the hardware and should not be changed. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.C0','51 ',1,0,'The C0 ARFCN. Also the base ARFCN for a multi-ARFCN configuration. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.MaxExpectedDelaySpread','1 ',0,0,'Expected worst-case delay spread in symbol periods, roughly 3.7 us or 1.1 km per unit.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.MaxAttenDB','10',0,0,'Maximum transmitter attenuation level, in dB wrt full scale on the D/A output. This sets the minimum power output level in the output power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.MinAttenDB','0',0,0,'Minimum transmitter attenuation level, in dB wrt full scale on the D/A output. This sets the maximum power output level in the output power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.NumSamples','10',0,0,'Number of samples averaged by the output power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.Period','6000',0,0,''); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.SamplePeriod','2000',0,0,'Sample period for the output power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.PowerManager.TargetT3122','5000',0,0,'Target value for T3122, the random access hold-off timer, for the power control loop.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.RxGain','47',1,0,'Receiver gain setting in dB. Ideal value is dictacted by the hardware. This database parameter is static but the receiver gain can be modified in real time with the CLI rxgain command. Static.'); +INSERT INTO "CONFIG" VALUES('GSM.Radio.RSSITarget','-50',0,0,'Target uplink RSSI for MS power control loop, in dB wrt to A/D full scale. Should be 6-10 dB above the noise floor.'); +INSERT INTO "CONFIG" VALUES('GSM.Timer.T3113','10000',0,0,'Paging timer T3113 in ms. This is the timeout for a handset to respond to a paging request. This should usually be the same as SIP.Timer.B in your VoIP network.'); +INSERT INTO "CONFIG" VALUES('GSM.Timer.T3122Max','255000',0,0,'Maximum allowed value for T3122, the RACH holdoff timer, in milliseconds.'); +INSERT INTO "CONFIG" VALUES('GSM.Timer.T3122Min','2000',0,0,'Minimum allowed value for T3122, the RACH holdoff timer, in milliseconds.'); +INSERT INTO "CONFIG" VALUES('GSM.Timer.T3212','30',0,0,'Registration timer T3212 period in minutes. Should be a factor of 6. Set to 0 to disable periodic registration. Should be smaller than SIP registration period.'); +INSERT INTO "CONFIG" VALUES('Log.Alarms.Max','20',0,0,'Maximum number of alarms to remember inside the application.'); +INSERT INTO "CONFIG" VALUES('Log.Level','WARNING',0,0,'Default logging level when no other level is defined for a file.'); +INSERT INTO "CONFIG" VALUES('Log.Level.CallControl.cpp','INFO',0,1,'Default configuration logs a trace at L3.'); +INSERT INTO "CONFIG" VALUES('Log.Level.MobilityManagement.cpp','INFO',0,1,'Default configuration logs a trace at L3.'); +INSERT INTO "CONFIG" VALUES('Log.Level.RadioResource.cpp','INFO',0,1,'Default configuration logs a trace at L3.'); +INSERT INTO "CONFIG" VALUES('Log.Level.SMSControl.cpp','INFO',0,1,'Default configuration logs a trace at L3.'); +INSERT INTO "CONFIG" VALUES('NTP.Server','pool.ntp.org',0,1,'NTP server(s) for time-of-day clock syncing. For multiple servers, use a space-delimited list. If left undefined, NTP will not be used, but it is strongly recommended.'); +INSERT INTO "CONFIG" VALUES('RTP.Range','98',1,0,'Range of RTP port pool. Pool is RTP.Start to RTP.Range-1. Static.'); +INSERT INTO "CONFIG" VALUES('RTP.Start','16484',1,0,'Base of RTP port pool. Pool is RTP.Start to RTP.Range-1. Static.'); +INSERT INTO "CONFIG" VALUES('SIP.DTMF.RFC2833','1',0,1,'If not NULL, use RFC-2833 (RTP event signalling) for in-call DTMF.'); +INSERT INTO "CONFIG" VALUES('SIP.DTMF.RFC2833.PayloadType','101',0,1,'Payload type to use for RFC-2833 telephone event packets. If SIP.DTMF.2833 is defined, this must also be defined.'); +INSERT INTO "CONFIG" VALUES('SIP.DTMF.RFC2967',NULL,0,1,'If not NULL, use RFC-2967 (SIP INFO method) for in-call DTMF.'); +INSERT INTO "CONFIG" VALUES('SIP.Local.IP','127.0.0.1',1,0,'IP address of the OpenBTS machine as seen by its proxies. If these are all local, this can be localhost. Static.'); +INSERT INTO "CONFIG" VALUES('SIP.Local.Port','5062',1,0,'IP port that OpenBTS uses for its SIP interface. Static.'); +INSERT INTO "CONFIG" VALUES('SIP.MaxForwards','5',0,0,'Maximum allowed number of referrals.'); +INSERT INTO "CONFIG" VALUES('SIP.Proxy.Registration','127.0.0.1:5064',0,0,'The IP host and port of the proxy to be used for registration and authentication. This should normally be the subscriber registry SIP interface, not Asterisk.'); +INSERT INTO "CONFIG" VALUES('SIP.Proxy.SMS','127.0.0.1:5063',0,0,'The IP host and port of the proxy to be used for text messaging. This is smqueue, for example.'); +INSERT INTO "CONFIG" VALUES('SIP.Proxy.Speech','127.0.0.1:5060',0,0,'The IP host and port of the proxy to be used for normal speech calls. This is Asterisk, for example.'); +INSERT INTO "CONFIG" VALUES('SIP.RegistrationPeriod','90',0,0,'Registration period in minutes for MS SIP users. Should be longer than GSM T3212.'); +INSERT INTO "CONFIG" VALUES('SIP.SMSC','smsc',0,1,'The SMSC handler in smqueue. This is the entity that handles full 3GPP MIME-encapsulted TPDUs. If not defined, use direct numeric addressing. Normally the value is NULL if SMS.MIMIEType is "text/plain" or "smsc" if SMS.MIMEType is "application/vnd.3gpp".'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.A','500',0,0,'INVITE retransmit period in ms.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.B','10000',0,0,'INVITE transaction timeout in ms. This value should usually match GSM.Timer.T3113.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.E','500',0,0,'Non-INVITE initial request retransmit period in ms.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.F','5000',0,0,'Non-INVITE initial request timeout in ms.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.J','500',0,0,'Non-INVITE non-initial request retransmit period in ms.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.H','5000',0,0,'ACK timeout period in ms.'); +INSERT INTO "CONFIG" VALUES('SIP.Timer.I','500',0,0,'ACK retransmit period in ms.'); +INSERT INTO "CONFIG" VALUES('SMS.DefaultDestSMSC','0000',0,0,'Use this to fill in L4 SMSC address in SMS submission.'); +INSERT INTO "CONFIG" VALUES('SMS.FakeSrcSMSC','0000',0,0,'Use this to fill in L4 SMSC address in SMS delivery.'); +INSERT INTO "CONFIG" VALUES('SMS.MIMEType','application/vnd.3gpp.sms',0,0,'This is the MIME Type that OpenBTS will use for RFC-3428 SIP MESSAGE payloads. Valid values are "application/vnd.3gpp.sms" and "text/plain".'); +INSERT INTO "CONFIG" VALUES('SubscriberRegistry.Manager.Title','Subscriber Registry',0,0,'Title of subscriber registry database manager web page.'); +INSERT INTO "CONFIG" VALUES('SubscriberRegistry.Manager.Url','http://127.0.0.1/cgi/srmanager.cgi',0,0,'URL of the subscriber registry database manager.'); +INSERT INTO "CONFIG" VALUES('SubscriberRegistry.Manager.VisibleColumns','name username type context host',0,0,'Field names in subscriber registry visible in the database manager.'); +INSERT INTO "CONFIG" VALUES('SubscriberRegistry.db','/var/lib/asterisk/sqlite3dir/sqlite3.db',0,0,'The location of the sqlite3 database holding the subscriber registry.'); +INSERT INTO "CONFIG" VALUES('TRX.IP','127.0.0.1',1,0,'IP address of the transceiver application. Static.'); +INSERT INTO "CONFIG" VALUES('TRX.Port','5700',1,0,'IP port of the transceiver application. Static.'); +INSERT INTO "CONFIG" VALUES('TRX.RadioFrequencyOffset','128',1,0,'Fine-tuning adjustment for the transceiver master clock. Roughly 170 Hz/step. Set at the factory. Do not adjust without proper calibration. Static.'); +INSERT INTO "CONFIG" VALUES('TRX.TxAttenOffset','2',1,0,'Hardware-specific gain adjustment for transmitter, matched to the power amplifier, expessed as an attenuationi in dB. Set at the factory. Do not adjust without proper calibration. Static.'); +COMMIT; diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..8229471 --- /dev/null +++ b/config.guess @@ -0,0 +1,1453 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + +timestamp='2004-11-12' + +# This file 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +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." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + amd64:OpenBSD:*:*) + echo x86_64-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + cats:OpenBSD:*:*) + echo arm-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + luna88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + macppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvmeppc:OpenBSD:*:*) + echo powerpc-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips64-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit 0 ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit 0 ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit 0 ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7 && exit 0 ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c \ + && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && exit 0 + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + # avoid double evaluation of $set_cc_for_build + test -n "$CC_FOR_BUILD" || eval $set_cc_for_build + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + x86:Interix*:[34]*) + echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' + exit 0 ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit 0 ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit 0 ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` + test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #ifdef __INTEL_COMPILER + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` + test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit 0 ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit 0 ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit 0 ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + *86) UNAME_PROCESSOR=i686 ;; + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit 0 ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms && exit 0 ;; + I*) echo ia64-dec-vms && exit 0 ;; + V*) echo vax-dec-vms && exit 0 ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +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` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..519d2a8 --- /dev/null +++ b/config.h.in @@ -0,0 +1,77 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_BYTESWAP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to `unsigned int' if does not define. */ +#undef size_t diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..0f84ac2 --- /dev/null +++ b/config.sub @@ -0,0 +1,1566 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. + +timestamp='2004-11-30' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 +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." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ + kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32r | m32rle | m68000 | m68k | m88k | mcore \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | msp430 \ + | ns16k | ns32k \ + | openrisc | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | msp430-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + or32 | or32-*) + basic_machine=or32-unknown + os=-coff + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config/Makefile.am b/config/Makefile.am new file mode 100644 index 0000000..69263e3 --- /dev/null +++ b/config/Makefile.am @@ -0,0 +1,30 @@ +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +# Install m4 macros in this directory +m4datadir = $(datadir)/aclocal + +# List your m4 macros here +m4macros = \ + pkg.m4 + +EXTRA_DIST = $(m4macros) diff --git a/config/Makefile.in b/config/Makefile.in new file mode 100644 index 0000000..ab5cf0b --- /dev/null +++ b/config/Makefile.in @@ -0,0 +1,416 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.common +subdir = config +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ + +# Install m4 macros in this directory +m4datadir = $(datadir)/aclocal + +# List your m4 macros here +m4macros = \ + pkg.m4 + +EXTRA_DIST = $(m4macros) +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu config/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu config/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/config/pkg.m4 b/config/pkg.m4 new file mode 100644 index 0000000..80bdfed --- /dev/null +++ b/config/pkg.m4 @@ -0,0 +1,188 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# +# Copyright © 2004 Scott James Remnant . +# Copyright © 2008 Free Software Foundation, Inc. +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_PATH)?$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.18]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi + +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# +# Similar to PKG_CHECK_MODULES, make sure that the first instance of +# this or PKG_CHECK_MODULES is called, or make sure to call +# PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_ifval([$2], [$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$PKG_CONFIG"; then + if test -n "$$1"; then + pkg_cv_[]$1="$$1" + else + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`], + [pkg_failed=yes]) + fi +else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# E.g., +# PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) +# defines: +# +# GSTUFF_LIBS +# GSTUFF_CFLAGS +# GSTUFF_INCLUDEDIR +# GSTUFF_CPPFLAGS # the -I, -D and -U's out of CFLAGS +# +# see pkg-config man page also defines GSTUFF_PKG_ERRORS on error +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_INCLUDEDIR], [includedir for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) + +if test x$cross_compiling = xyes +then + _PKG_CONFIG([$1][_LIBS], [libs-only-l --static], [$2]) +else + _PKG_CONFIG([$1][_LIBS], [libs --static], [$2]) +fi + +_PKG_CONFIG([$1][_INCLUDEDIR], [variable=includedir], [$2]) + + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$4], , [AC_MSG_ERROR(dnl +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT +])], + [AC_MSG_RESULT([no]) + $4]) +elif test $pkg_failed = untried; then + ifelse([$4], , [AC_MSG_FAILURE(dnl +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])], + [$4]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + $1[]_INCLUDEDIR=$pkg_cv_[]$1[]_INCLUDEDIR + + $1[]_CPPFLAGS="" + for flag in $$1[]_CFLAGS; do + case $flag in + -I* | -D* | -U*) $1[]_CPPFLAGS="$$1[]_CPPFLAGS $flag" ;; + esac + done + pkg_cv_[]$1[]_CPPFLAGS=$$1[]_CPPFLAGS + AC_SUBST($1[]_CPPFLAGS) + + AC_MSG_RESULT([yes]) + ifelse([$3], , :, [$3]) +fi[]dnl +])# PKG_CHECK_MODULES diff --git a/configure b/configure new file mode 100755 index 0000000..4e9b4e7 --- /dev/null +++ b/configure @@ -0,0 +1,23857 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.60 for openbts P2.8TRUNK. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 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 Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + + +# PATH needs CR +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /usr/bin/posix$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # 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 +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +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=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +# Find out whether ``test -x'' works. Don't use a zero-byte file, as +# systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + as_executable_p="test -x" +else + as_executable_p=: +fi +rm -f conf$$.file + +# 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'" + + + + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} + +case X$ECHO in +X*--fallback-echo) + # Remove one level of quotation (which was required for Make). + ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` + ;; +esac + +echo=${ECHO-echo} +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then + # Yippee, $echo works! + : +else + # Restart under the correct shell. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat </dev/null 2>&1 && unset CDPATH + +if test -z "$ECHO"; then +if test "X${echo_test_string+set}" != Xset; then +# find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/dev/null && + echo_test_string="`eval $cmd`" && + (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null + then + break + fi + done +fi + +if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + : +else + # The Solaris, AIX, and Digital Unix default echo programs unquote + # backslashes. This makes it impossible to quote backslashes using + # echo "$something" | sed 's/\\/\\\\/g' + # + # So, first we look for a working echo in the user's PATH. + + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for dir in $PATH /usr/ucb; do + IFS="$lt_save_ifs" + if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && + test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$dir/echo" + break + fi + done + IFS="$lt_save_ifs" + + if test "X$echo" = Xecho; then + # We didn't find a better echo, so look for alternatives. + if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # This shell has a builtin print -r that does the trick. + echo='print -r' + elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && + test "X$CONFIG_SHELL" != X/bin/ksh; then + # If we have ksh, try running configure again with it. + ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} + export ORIGINAL_CONFIG_SHELL + CONFIG_SHELL=/bin/ksh + export CONFIG_SHELL + exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} + else + # Try using printf. + echo='printf %s\n' + if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && + echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + # Cool, printf works + : + elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL + export CONFIG_SHELL + SHELL="$CONFIG_SHELL" + export SHELL + echo="$CONFIG_SHELL $0 --fallback-echo" + elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && + test "X$echo_testing_string" = 'X\t' && + echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && + test "X$echo_testing_string" = "X$echo_test_string"; then + echo="$CONFIG_SHELL $0 --fallback-echo" + else + # maybe with a smaller string... + prev=: + + for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do + if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null + then + break + fi + prev="$cmd" + done + + if test "$prev" != 'sed 50q "$0"'; then + echo_test_string=`eval $prev` + export echo_test_string + exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi +fi + +# Copy echo and quote the copy suitably for passing to libtool from +# the Makefile, instead of quoting the original, which is used later. +ECHO=$echo +if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" +fi + + + + +tagnames=${tagnames+${tagnames},}CXX + +tagnames=${tagnames+${tagnames},}F77 + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, 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= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='openbts' +PACKAGE_TARNAME='openbts' +PACKAGE_VERSION='P2.8TRUNK' +PACKAGE_STRING='openbts P2.8TRUNK' +PACKAGE_BUGREPORT='' + +ac_unique_file="config/Makefile.am" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#endif +#if HAVE_STDINT_H +# include +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +build +build_cpu +build_vendor +build_os +host +host_cpu +host_vendor +host_os +target +target_cpu +target_vendor +target_os +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +CYGPATH_W +PACKAGE +VERSION +ACLOCAL +AUTOCONF +AUTOMAKE +AUTOHEADER +MAKEINFO +install_sh +STRIP +INSTALL_STRIP_PROGRAM +mkdir_p +AWK +SET_MAKE +am__leading_dot +AMTAR +am__tar +am__untar +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +DEPDIR +am__include +am__quote +AMDEP_TRUE +AMDEP_FALSE +AMDEPBACKSLASH +CCDEPMODE +am__fastdepCC_TRUE +am__fastdepCC_FALSE +CCAS +CCASFLAGS +CXX +CXXFLAGS +ac_ct_CXX +CXXDEPMODE +am__fastdepCXX_TRUE +am__fastdepCXX_FALSE +LN_S +RM_PROG +GREP +EGREP +ECHO +AR +RANLIB +DLLTOOL +AS +OBJDUMP +CPP +CXXCPP +F77 +FFLAGS +ac_ct_F77 +LIBTOOL +PKG_CONFIG +OSIP_CFLAGS +OSIP_LIBS +ORTP_CFLAGS +ORTP_LIBS +LIBUSB_CFLAGS +LIBUSB_LIBS +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +CPPFLAGS +CCAS +CCASFLAGS +CXX +CXXFLAGS +CCC +CPP +CXXCPP +F77 +FFLAGS +PKG_CONFIG +OSIP_CFLAGS +OSIP_LIBS +ORTP_CFLAGS +ORTP_LIBS +LIBUSB_CFLAGS +LIBUSB_LIBS' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# 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_TARNAME}' +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=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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval enable_$ac_feature=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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval enable_$ac_feature=\$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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval with_$ac_package=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 ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + 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'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +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 + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +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 + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + 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 .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + 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 .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + 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 openbts P2.8TRUNK 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/openbts] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of openbts P2.8TRUNK:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --enable-shared[=PKGS] build shared libraries [default=yes] + --enable-static[=PKGS] build static libraries [default=no] + --enable-fast-install[=PKGS] + optimize for fast installation [default=yes] + --disable-libtool-lock avoid locking (might break parallel builds) + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld [default=no] + --with-pic try to use only PIC/non-PIC objects [default=use + both] + --with-tags[=TAGS] include additional configurations [automatic] + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CCAS assembler compiler command (defaults to CC) + CCASFLAGS assembler compiler flags (defaults to CFLAGS) + CXX C++ compiler command + CXXFLAGS C++ compiler flags + CPP C preprocessor + CXXCPP C++ preprocessor + F77 Fortran 77 compiler command + FFLAGS Fortran 77 compiler flags + PKG_CONFIG path to pkg-config utility + OSIP_CFLAGS C compiler flags for OSIP, overriding pkg-config + OSIP_LIBS linker flags for OSIP, overriding pkg-config + ORTP_CFLAGS C compiler flags for ORTP, overriding pkg-config + ORTP_LIBS linker flags for ORTP, overriding pkg-config + LIBUSB_CFLAGS + C compiler flags for LIBUSB, overriding pkg-config + LIBUSB_LIBS linker flags for LIBUSB, overriding pkg-config + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_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" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + 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 +openbts configure P2.8TRUNK +generated by GNU Autoconf 2.60 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 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 +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 openbts $as_me P2.8TRUNK, which was +generated by GNU Autoconf 2.60. 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=. + 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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$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 + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export 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 + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_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 + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + 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'; { (exit 1); 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 + +# 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 + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + 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. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +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 + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`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. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +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 + + + + +ac_aux_dir= +for ac_dir in . "$srcdir"/.; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in . \"$srcdir\"/." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in . \"$srcdir\"/." >&2;} + { (exit 1); exit 1; }; } +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +ac_config_headers="$ac_config_headers config.h" + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 +echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} + { (exit 1); exit 1; }; } + +{ echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6; } +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 +echo "$as_me: error: invalid value of canonical build" >&2;} + { (exit 1); exit 1; }; };; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6; } +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$host_alias" = x; then + ac_cv_host=$ac_cv_build +else + ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6; } +case $ac_cv_host in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 +echo "$as_me: error: invalid value of canonical host" >&2;} + { (exit 1); exit 1; }; };; +esac +host=$ac_cv_host +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_host +shift +host_cpu=$1 +host_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +host_os=$* +IFS=$ac_save_IFS +case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac + + +{ echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6; } +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "x$target_alias" = x; then + ac_cv_target=$ac_cv_host +else + ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || + { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 +echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} + { (exit 1); exit 1; }; } +fi + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6; } +case $ac_cv_target in +*-*-*) ;; +*) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 +echo "$as_me: error: invalid value of canonical target" >&2;} + { (exit 1); exit 1; }; };; +esac +target=$ac_cv_target +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_target +shift +target_cpu=$1 +target_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +target_os=$* +IFS=$ac_save_IFS +case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +am__api_version="1.9" +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then + # We used to keeping the `.' as first argument, in order to + # allow $(mkdir_p) to be used without argument. As in + # $(mkdir_p) $(somedir) + # where $(somedir) is conditionally defined. However this is wrong + # for two reasons: + # 1. if the package is installed by a user who cannot write `.' + # make install will fail, + # 2. the above comment should most certainly read + # $(mkdir_p) $(DESTDIR)$(somedir) + # so it does not work when $(somedir) is undefined and + # $(DESTDIR) is not. + # To support the latter case, we have to write + # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), + # so the `.' trick is pointless. + mkdir_p='mkdir -p --' +else + # On NextStep and OpenStep, the `mkdir' command does not + # recognize any option. It will interpret all options as + # directories to create, and then abort because `.' already + # exists. + for d in ./-p ./--version; + do + test -d $d && rmdir $d + done + # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. + if test -f "$ac_aux_dir/mkinstalldirs"; then + mkdir_p='$(mkinstalldirs)' + else + mkdir_p='$(install_sh) -d' + fi +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +rm -rf .tst 2>/dev/null +mkdir .tst 2>/dev/null +if test -d .tst; then + am__leading_dot=. +else + am__leading_dot=_ +fi +rmdir .tst 2>/dev/null + +# test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# test whether we have cygpath +if test -z "$CYGPATH_W"; then + if (cygpath --version) >/dev/null 2>/dev/null; then + CYGPATH_W='cygpath -w' + else + CYGPATH_W=echo + fi +fi + + +# Define the identity of the package. + PACKAGE='openbts' + VERSION='P2.8TRUNK' + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +# Installed binaries are usually stripped using `strip' when the user +# run `make install-strip'. However `strip' might not be the right +# tool to use in cross-compilation environments, therefore Automake +# will honor the `STRIP' environment variable to overrule this program. +if test "$cross_compiling" != no; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + +fi +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +DEPDIR="${am__leading_dot}deps" + +ac_config_commands="$ac_config_commands depfiles" + + +am_make=${MAKE-make} +cat > confinc << 'END' +am__doit: + @echo done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6; } +rm -f confinc confmf + +# Check whether --enable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval=$enable_dependency_tracking; +fi + +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +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}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_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" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out 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. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.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 + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$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 +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* 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" + 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +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 + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } +CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then + am__fastdepCC_TRUE= + am__fastdepCC_FALSE='#' +else + am__fastdepCC_TRUE='#' + am__fastdepCC_FALSE= +fi + + +# By default we simply use the C compiler to build assembly code. + +test "${CCAS+set}" = set || CCAS=$CC +test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS + + + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +if test -z "$CXX"; then + if test -n "$CCC"; then + CXX=$CCC + else + if test -n "$ac_tool_prefix"; then + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC + 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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CXX"; then + ac_cv_prog_CXX="$CXX" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CXX=$ac_cv_prog_CXX +if test -n "$CXX"; then + { echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CXX" && break + done +fi +if test -z "$CXX"; then + ac_ct_CXX=$CXX + for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CXX"; then + ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CXX=$ac_cv_prog_ac_ct_CXX +if test -n "$ac_ct_CXX"; then + { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CXX" && break +done + + if test "x$ac_ct_CXX" = x; then + CXX="g++" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_cxx_werror_flag=$ac_cxx_werror_flag + ac_cxx_werror_flag=yes + ac_cv_prog_cxx_g=no + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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_cxx_werror_flag=$ac_save_cxx_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } +if test "$ac_test_CXXFLAGS" = set; then + CXXFLAGS=$ac_save_CXXFLAGS +elif test $ac_cv_prog_cxx_g = yes; then + if test "$GXX" = yes; then + CXXFLAGS="-g -O2" + else + CXXFLAGS="-g" + fi +else + if test "$GXX" = yes; then + CXXFLAGS="-O2" + else + CXXFLAGS= + fi +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 + +depcc="$CXX" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + # We will build objects and dependencies in a subdirectory because + # it helps to detect inapplicable dependency modes. For instance + # both Tru64's cc and ICC support -MD to output dependencies as a + # side effect of compilation, but ICC will put the dependencies in + # the current directory while Tru64 will put them in the object + # directory. + mkdir sub + + am_cv_CXX_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # Setup a source with many dependencies, because some compilers + # like to wrap large dependency lists on column 80 (with \), and + # we should not choose a depcomp mode which is confused by this. + # + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + : > sub/conftest.c + for i in 1 2 3 4 5 6; do + echo '#include "conftst'$i'.h"' >> sub/conftest.c + # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with + # Solaris 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ + >/dev/null 2>conftest.err && + grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && + grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + # icc doesn't choke on unknown options, it will just issue warnings + # or remarks (even with -Werror). So we grep stderr for any message + # that says an option was ignored or not supported. + # When given -MP, icc 7.0 and 7.1 complain thusly: + # icc: Command line warning: ignoring option '-M'; no argument required + # The diagnosis changed in icc 8.0: + # icc: Command line remark: option '-MP' not supported + if (grep 'ignoring option' conftest.err || + grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else + am_cv_CXX_dependencies_compiler_type=$depmode + break + fi + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CXX_dependencies_compiler_type=none +fi + +fi +{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } +CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type + + + +if + test "x$enable_dependency_tracking" != xno \ + && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' +else + am__fastdepCXX_TRUE='#' + am__fastdepCXX_FALSE= +fi + + +{ echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; } +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else + { echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6; } +fi + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +SHELL = /bin/sh +all: + @echo '@@@%%%=$(MAKE)=@@@%%%' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +case `${MAKE-make} -f conftest.make 2>/dev/null` in + *@@@%%%=?*=@@@%%%*) + eval ac_cv_prog_make_${ac_make}_set=yes;; + *) + eval ac_cv_prog_make_${ac_make}_set=no;; +esac +rm -f conftest.make +fi +if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +# Extract the first word of "rm", so it can be a program name with args. +set dummy rm; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_RM_PROG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $RM_PROG in + [\\/]* | ?:[\\/]*) + ac_cv_path_RM_PROG="$RM_PROG" # Let the user override the test with a path. + ;; + *) + 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_RM_PROG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +RM_PROG=$ac_cv_path_RM_PROG +if test -n "$RM_PROG"; then + { echo "$as_me:$LINENO: result: $RM_PROG" >&5 +echo "${ECHO_T}$RM_PROG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + + + +# Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then + enableval=$enable_shared; p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_shared=yes +fi + + # Check whether --enable-static was given. +if test "${enable_static+set}" = set; then + enableval=$enable_static; p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_static=no +fi + + + # Check whether --enable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval=$enable_fast_install; p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for pkg in $enableval; do + IFS="$lt_save_ifs" + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$lt_save_ifs" + ;; + esac +else + enable_fast_install=yes +fi + + +{ echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 +echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6; } +if test "${lt_cv_path_SED+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f $lt_ac_sed && break + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test $lt_ac_count -gt 10 && break + lt_ac_count=`expr $lt_ac_count + 1` + if test $lt_ac_count -gt $lt_ac_max; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done + +fi + +SED=$lt_cv_path_SED +{ echo "$as_me:$LINENO: result: $SED" >&5 +echo "${ECHO_T}$SED" >&6; } + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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" + { test -f "$ac_path_GREP" && $as_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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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" + { test -f "$ac_path_EGREP" && $as_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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; } +else + { echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + +{ echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 +echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6; } +if test "${lt_cv_ld_reload_flag+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_ld_reload_flag='-r' +fi +{ echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 +echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6; } +reload_flag=$lt_cv_ld_reload_flag +case $reload_flag in +"" | " "*) ;; +*) reload_flag=" $reload_flag" ;; +esac +reload_cmds='$LD$reload_flag -o $output$reload_objs' +case $host_os in + darwin*) + if test "$GCC" = yes; then + reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs' + else + reload_cmds='$LD$reload_flag -o $output$reload_objs' + fi + ;; +esac + +{ echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6; } +if test "${lt_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM="$NM" +else + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + tmp_nm="$ac_dir/${ac_tool_prefix}nm" + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in + */dev/null* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + esac + fi + done + IFS="$lt_save_ifs" + test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm +fi +fi +{ echo "$as_me:$LINENO: result: $lt_cv_path_NM" >&5 +echo "${ECHO_T}$lt_cv_path_NM" >&6; } +NM="$lt_cv_path_NM" + +{ echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 +echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6; } +if test "${lt_cv_deplibs_check_method+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# `unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# which responds to the $file_magic_cmd with a given extended regex. +# If you have `file' or equivalent on your system and you're not sure +# whether `pass_all' will *always* work, you probably want this one. + +case $host_os in +aix4* | aix5*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[45]*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump'. + lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | kfreebsd*-gnu) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case "$host_cpu" in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]' + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be Linux ELF. +linux*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +nto-qnx*) + lt_cv_deplibs_check_method=unknown + ;; + +openbsd*) + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +sco3.2v5*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 +echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6; } +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + + + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE="32" + ;; + *ELF-64*) + HPUX_IA64_MODE="64" + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 5117 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + if test "$lt_cv_prog_gnu_ld" = yes; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*) + # Find out which ABI we are using. + echo 'int i;' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_i386" + ;; + ppc64-*linux*|powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + ppc*-*linux*|powerpc*-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + { echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6; } +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + lt_cv_cc_needs_belf=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + 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 + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6; } + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; +*-*-cygwin* | *-*-mingw* | *-*-pw32*) + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_DLLTOOL+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +DLLTOOL=$ac_cv_prog_DLLTOOL +if test -n "$DLLTOOL"; then + { echo "$as_me:$LINENO: result: $DLLTOOL" >&5 +echo "${ECHO_T}$DLLTOOL" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_DLLTOOL"; then + ac_ct_DLLTOOL=$DLLTOOL + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_DLLTOOL+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_DLLTOOL"; then + ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_DLLTOOL="dlltool" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL +if test -n "$ac_ct_DLLTOOL"; then + { echo "$as_me:$LINENO: result: $ac_ct_DLLTOOL" >&5 +echo "${ECHO_T}$ac_ct_DLLTOOL" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_DLLTOOL" = x; then + DLLTOOL="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + DLLTOOL=$ac_ct_DLLTOOL + fi +else + DLLTOOL="$ac_cv_prog_DLLTOOL" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AS+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AS="${ac_tool_prefix}as" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AS=$ac_cv_prog_AS +if test -n "$AS"; then + { echo "$as_me:$LINENO: result: $AS" >&5 +echo "${ECHO_T}$AS" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AS"; then + ac_ct_AS=$AS + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_AS+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AS"; then + ac_cv_prog_ac_ct_AS="$ac_ct_AS" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AS="as" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_AS=$ac_cv_prog_ac_ct_AS +if test -n "$ac_ct_AS"; then + { echo "$as_me:$LINENO: result: $ac_ct_AS" >&5 +echo "${ECHO_T}$ac_ct_AS" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_AS" = x; then + AS="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + AS=$ac_ct_AS + fi +else + AS="$ac_cv_prog_AS" +fi + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. +set dummy ${ac_tool_prefix}objdump; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_OBJDUMP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$OBJDUMP"; then + ac_cv_prog_OBJDUMP="$OBJDUMP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +OBJDUMP=$ac_cv_prog_OBJDUMP +if test -n "$OBJDUMP"; then + { echo "$as_me:$LINENO: result: $OBJDUMP" >&5 +echo "${ECHO_T}$OBJDUMP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_OBJDUMP"; then + ac_ct_OBJDUMP=$OBJDUMP + # Extract the first word of "objdump", so it can be a program name with args. +set dummy objdump; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_OBJDUMP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_OBJDUMP"; then + ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_OBJDUMP="objdump" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP +if test -n "$ac_ct_OBJDUMP"; then + { echo "$as_me:$LINENO: result: $ac_ct_OBJDUMP" >&5 +echo "${ECHO_T}$ac_ct_OBJDUMP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_OBJDUMP" = x; then + OBJDUMP="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + OBJDUMP=$ac_ct_OBJDUMP + fi +else + OBJDUMP="$ac_cv_prog_OBJDUMP" +fi + + ;; + +esac + +need_locks="$enable_libtool_lock" + + +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 +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 to if __STDC__ is defined, since + # 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f 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 +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$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 to if __STDC__ is defined, since + # 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +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 + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#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 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +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=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in dlfcn.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C++ preprocessor" >&5 +echo $ECHO_N "checking how to run the C++ preprocessor... $ECHO_C" >&6; } +if test -z "$CXXCPP"; then + if test "${ac_cv_prog_CXXCPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CXXCPP needs to be expanded + for CXXCPP in "$CXX -E" "/lib/cpp" + do + ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CXXCPP=$CXXCPP + +fi + CXXCPP=$ac_cv_prog_CXXCPP +else + ac_cv_prog_CXXCPP=$CXXCPP +fi +{ echo "$as_me:$LINENO: result: $CXXCPP" >&5 +echo "${ECHO_T}$CXXCPP" >&6; } +ac_preproc_ok=false +for ac_cxx_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_cxx_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_cxx_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ preprocessor \"$CXXCPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + +fi + + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77 f90 xlf90 pgf90 pghpf epcf90 gfortran g95 f95 fort xlf95 ifort ifc efc pgf95 lf95 ftn + 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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$F77"; then + ac_cv_prog_F77="$F77" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_F77="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +F77=$ac_cv_prog_F77 +if test -n "$F77"; then + { echo "$as_me:$LINENO: result: $F77" >&5 +echo "${ECHO_T}$F77" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$F77" && break + done +fi +if test -z "$F77"; then + ac_ct_F77=$F77 + for ac_prog in g77 f77 xlf frt pgf77 cf77 fort77 fl32 af77 f90 xlf90 pgf90 pghpf epcf90 gfortran g95 f95 fort xlf95 ifort ifc efc pgf95 lf95 ftn +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_F77"; then + ac_cv_prog_ac_ct_F77="$ac_ct_F77" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_F77="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_F77=$ac_cv_prog_ac_ct_F77 +if test -n "$ac_ct_F77"; then + { echo "$as_me:$LINENO: result: $ac_ct_F77" >&5 +echo "${ECHO_T}$ac_ct_F77" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_F77" && break +done + + if test "x$ac_ct_F77" = x; then + F77="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + F77=$ac_ct_F77 + fi +fi + + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for Fortran 77 compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +rm -f a.out + +# If we don't use `.F' as extension, the preprocessor is not run on the +# input file. (Note that this only needs to work for GNU compilers.) +ac_save_ext=$ac_ext +ac_ext=F +{ echo "$as_me:$LINENO: checking whether we are using the GNU Fortran 77 compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU Fortran 77 compiler... $ECHO_C" >&6; } +if test "${ac_cv_f77_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF + program main +#ifndef __GNUC__ + choke me +#endif + + end +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_f77_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_f77_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_f77_compiler_gnu" >&6; } +ac_ext=$ac_save_ext +ac_test_FFLAGS=${FFLAGS+set} +ac_save_FFLAGS=$FFLAGS +FFLAGS= +{ echo "$as_me:$LINENO: checking whether $F77 accepts -g" >&5 +echo $ECHO_N "checking whether $F77 accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_f77_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + FFLAGS=-g +cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_f77_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_prog_f77_g=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_f77_g" >&5 +echo "${ECHO_T}$ac_cv_prog_f77_g" >&6; } +if test "$ac_test_FFLAGS" = set; then + FFLAGS=$ac_save_FFLAGS +elif test $ac_cv_prog_f77_g = yes; then + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-g -O2" + else + FFLAGS="-g" + fi +else + if test "x$ac_cv_f77_compiler_gnu" = xyes; then + FFLAGS="-O2" + else + FFLAGS= + fi +fi + +G77=`test $ac_compiler_gnu = yes && echo yes` +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 + + + +# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers! + +# find the maximum length of command line arguments +{ echo "$as_me:$LINENO: checking the maximum length of command line arguments" >&5 +echo $ECHO_N "checking the maximum length of command line arguments... $ECHO_C" >&6; } +if test "${lt_cv_sys_max_cmd_len+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + i=0 + teststring="ABCD" + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + netbsd* | freebsd* | openbsd* | darwin* ) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for *BSD + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + ;; + + *) + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \ + = "XX$teststring") >/dev/null 2>&1 && + new_result=`expr "X$teststring" : ".*" 2>&1` && + lt_cv_sys_max_cmd_len=$new_result && + test $i != 17 # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + teststring= + # Add a significant safety factor because C++ compilers can tack on massive + # amounts of additional arguments before passing them to the linker. + # It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + ;; + esac + +fi + +if test -n $lt_cv_sys_max_cmd_len ; then + { echo "$as_me:$LINENO: result: $lt_cv_sys_max_cmd_len" >&5 +echo "${ECHO_T}$lt_cv_sys_max_cmd_len" >&6; } +else + { echo "$as_me:$LINENO: result: none" >&5 +echo "${ECHO_T}none" >&6; } +fi + + + + +# Check for command to grab the raw symbol name followed by C symbol from nm. +{ echo "$as_me:$LINENO: checking command to parse $NM output from $compiler object" >&5 +echo $ECHO_N "checking command to parse $NM output from $compiler object... $ECHO_C" >&6; } +if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[BCDEGRST]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([_A-Za-z][_A-Za-z0-9]*\)' + +# Transform the above into a raw symbol and a C symbol. +symxfrm='\1 \2\3 \3' + +# Transform an extracted symbol line into a proper C declaration +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw* | pw32*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + if test "$host_cpu" = ia64; then + symcode='[ABCDEGRST]' + fi + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + ;; +linux*) + if test "$host_cpu" = ia64; then + symcode='[ABCDGIRSTW]' + lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" + lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" + fi + ;; +irix* | nonstopux*) + symcode='[BCDEGRST]' + ;; +osf*) + symcode='[BCDEGQRST]' + ;; +solaris* | sysv5*) + symcode='[BDRT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +esac + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[ABCDGIRSTW]' ;; +esac + +# Try without a prefix undercore, then with it. +for ac_symprfx in "" "_"; do + + # Write the raw and C identifiers. + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Now try to grab the symbols. + nlist=conftest.nm + if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 + (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if grep ' nm_test_var$' "$nlist" >/dev/null; then + if grep ' nm_test_func$' "$nlist" >/dev/null; then + cat < conftest.$ac_ext +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext' + + cat <> conftest.$ac_ext +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext + cat <<\EOF >> conftest.$ac_ext + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_save_LIBS="$LIBS" + lt_save_CFLAGS="$CFLAGS" + LIBS="conftstm.$ac_objext" + CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext}; then + pipe_works=yes + fi + LIBS="$lt_save_LIBS" + CFLAGS="$lt_save_CFLAGS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + fi + rm -f conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done + +fi + +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + { echo "$as_me:$LINENO: result: failed" >&5 +echo "${ECHO_T}failed" >&6; } +else + { echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6; } +fi + +{ echo "$as_me:$LINENO: checking for objdir" >&5 +echo $ECHO_N "checking for objdir... $ECHO_C" >&6; } +if test "${lt_cv_objdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null +fi +{ echo "$as_me:$LINENO: result: $lt_cv_objdir" >&5 +echo "${ECHO_T}$lt_cv_objdir" >&6; } +objdir=$lt_cv_objdir + + + + + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e s/^X//' +sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' + +# Constants: +rm="rm -f" + +# Global variables: +default_ofile=libtool +can_build_shared=yes + +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +libext=a +ltmain="$ac_aux_dir/ltmain.sh" +ofile="$default_ofile" +with_gnu_ld="$lt_cv_prog_gnu_ld" + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +AR=$ac_cv_prog_AR +if test -n "$AR"; then + { echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_AR"; then + ac_ct_AR=$AR + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_AR"; then + ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_AR="ar" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_AR=$ac_cv_prog_ac_ct_AR +if test -n "$ac_ct_AR"; then + { echo "$as_me:$LINENO: result: $ac_ct_AR" >&5 +echo "${ECHO_T}$ac_ct_AR" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_AR" = x; then + AR="false" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + AR=$ac_ct_AR + fi +else + AR="$ac_cv_prog_AR" +fi + +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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. +set dummy ${ac_tool_prefix}strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$STRIP"; then + ac_cv_prog_STRIP="$STRIP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +STRIP=$ac_cv_prog_STRIP +if test -n "$STRIP"; then + { echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_STRIP"; then + ac_ct_STRIP=$STRIP + # Extract the first word of "strip", so it can be a program name with args. +set dummy strip; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_STRIP"; then + ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP +if test -n "$ac_ct_STRIP"; then + { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + STRIP=$ac_ct_STRIP + fi +else + STRIP="$ac_cv_prog_STRIP" +fi + + +old_CC="$CC" +old_CFLAGS="$CFLAGS" + +# Set sane defaults for various variables +test -z "$AR" && AR=ar +test -z "$AR_FLAGS" && AR_FLAGS=cru +test -z "$AS" && AS=as +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$DLLTOOL" && DLLTOOL=dlltool +test -z "$LD" && LD=ld +test -z "$LN_S" && LN_S="ln -s" +test -z "$MAGIC_CMD" && MAGIC_CMD=file +test -z "$NM" && NM=nm +test -z "$SED" && SED=sed +test -z "$OBJDUMP" && OBJDUMP=objdump +test -z "$RANLIB" && RANLIB=: +test -z "$STRIP" && STRIP=: +test -z "$ac_objext" && ac_objext=o + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + openbsd*) + old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" + ;; + *) + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" +fi + +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# Only perform the check for file, if the check method requires it +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + { echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 +echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/${ac_tool_prefix}file; then + lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + { echo "$as_me:$LINENO: checking for file" >&5 +echo $ECHO_N "checking for file... $ECHO_C" >&6; } +if test "${lt_cv_path_MAGIC_CMD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $MAGIC_CMD in +[\\/*] | ?:[\\/]*) + lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD="$MAGIC_CMD" + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" + for ac_dir in $ac_dummy; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/file; then + lt_cv_path_MAGIC_CMD="$ac_dir/file" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + MAGIC_CMD="$lt_cv_path_MAGIC_CMD" + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +EOF + fi ;; + esac + fi + break + fi + done + IFS="$lt_save_ifs" + MAGIC_CMD="$lt_save_MAGIC_CMD" + ;; +esac +fi + +MAGIC_CMD="$lt_cv_path_MAGIC_CMD" +if test -n "$MAGIC_CMD"; then + { echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 +echo "${ECHO_T}$MAGIC_CMD" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + else + MAGIC_CMD=: + fi +fi + + fi + ;; +esac + +enable_dlopen=no +enable_win32_dll=yes + +# Check whether --enable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval=$enable_libtool_lock; +fi + +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes + + +# Check whether --with-pic was given. +if test "${with_pic+set}" = set; then + withval=$with_pic; pic_mode="$withval" +else + pic_mode=default +fi + +test -z "$pic_mode" && pic_mode=default + +# Use C for the default configuration in the libtool script +tagname= +lt_save_CC="$CC" +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 + + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +objext=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}\n' + + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# +# Check for any special shared library compilation flags. +# +lt_prog_cc_shlib= +if test "$GCC" = no; then + case $host_os in + sco3.2v5*) + lt_prog_cc_shlib='-belf' + ;; + esac +fi +if test -n "$lt_prog_cc_shlib"; then + { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5 +echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;} + if echo "$old_CC $old_CFLAGS " | grep "[ ]$lt_prog_cc_shlib[ ]" >/dev/null; then : + else + { echo "$as_me:$LINENO: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 +echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} + lt_cv_prog_cc_can_build_shared=no + fi +fi + + +# +# Check to make sure the static flag actually works. +# +{ echo "$as_me:$LINENO: checking if $compiler static flag $lt_prog_compiler_static works" >&5 +echo $ECHO_N "checking if $compiler static flag $lt_prog_compiler_static works... $ECHO_C" >&6; } +if test "${lt_prog_compiler_static_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_static_works=no + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $lt_prog_compiler_static" + printf "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&5 + else + lt_prog_compiler_static_works=yes + fi + fi + $rm conftest* + LDFLAGS="$save_LDFLAGS" + +fi +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_static_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_static_works" >&6; } + +if test x"$lt_prog_compiler_static_works" = xyes; then + : +else + lt_prog_compiler_static= +fi + + + + +lt_prog_compiler_no_builtin_flag= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag=' -fno-builtin' + + +{ echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:7799: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:7803: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl= +lt_prog_compiler_pic= +lt_prog_compiler_static= + +{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_static='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static='-Bstatic' + else + lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + lt_prog_compiler_pic='-qnocommon' + lt_prog_compiler_wl='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-static' + ;; + ccc*) + lt_prog_compiler_wl='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic='-Kpic' + lt_prog_compiler_static='-dn' + ;; + + solaris*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl='-Qoption ld ' + lt_prog_compiler_pic='-PIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl='-Wl,' + lt_prog_compiler_pic='-KPIC' + lt_prog_compiler_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic='-Kconform_pic' + lt_prog_compiler_static='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic='-pic' + lt_prog_compiler_static='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic"; then + +{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic works... $ECHO_C" >&6; } +if test "${lt_prog_compiler_pic_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8042: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:8046: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works" >&6; } + +if test x"$lt_prog_compiler_pic_works" = xyes; then + case $lt_prog_compiler_pic in + "" | " "*) ;; + *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; + esac +else + lt_prog_compiler_pic= + lt_prog_compiler_can_build_shared=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic= + ;; + *) + lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" + ;; +esac + +{ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_c_o+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:8102: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:8106: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6; } + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } + + runpath_var= + allow_undefined_flag= + enable_shared_with_static_runtimes=no + archive_cmds= + archive_expsym_cmds= + old_archive_From_new_cmds= + old_archive_from_expsyms_cmds= + export_dynamic_flag_spec= + whole_archive_flag_spec= + thread_safe_flag_spec= + hardcode_libdir_flag_spec= + hardcode_libdir_flag_spec_ld= + hardcode_libdir_separator= + hardcode_direct=no + hardcode_minus_L=no + hardcode_shlibpath_var=unsupported + link_all_deplibs=unknown + hardcode_automatic=no + module_cmds= + module_expsym_cmds= + always_export_symbols=no + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec='-L$libdir' + allow_undefined_flag=unsupported + always_export_symbols=no + enable_shared_with_static_runtimes=yes + export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds="$tmp_archive_cmds" + fi + else + ld_shlibs=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs=no + fi + ;; + esac + + if test "$ld_shlibs" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag=unsupported + always_export_symbols=yes + archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds='' + hardcode_direct=yes + hardcode_libdir_separator=':' + link_all_deplibs=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct=yes + else + # We have old collect2 + hardcode_direct=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L=yes + hardcode_libdir_flag_spec='-L$libdir' + hardcode_libdir_separator= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag="-z nodefs" + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag=' ${wl}-bernotok' + allow_undefined_flag=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec=' ' + archive_cmds_need_lc=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + # see comment about different semantics on the GNU ld section + ld_shlibs=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec=' ' + allow_undefined_flag=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes=yes + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc=no + hardcode_direct=no + hardcode_automatic=yes + hardcode_shlibpath_var=unsupported + whole_archive_flag_spec='' + link_all_deplibs=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + freebsd1*) + ld_shlibs=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + export_dynamic_flag_spec='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld='+b $libdir' + hardcode_libdir_separator=: + hardcode_direct=no + hardcode_shlibpath_var=no + ;; + ia64*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=no + hardcode_shlibpath_var=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + *) + hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_direct=yes + export_dynamic_flag_spec='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld='-rpath $libdir' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + link_all_deplibs=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + newsos6) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + hardcode_shlibpath_var=no + ;; + + openbsd*) + hardcode_direct=yes + hardcode_shlibpath_var=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + export_dynamic_flag_spec='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + ;; + *) + archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag=' -expect_unresolved \*' + archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec='-rpath $libdir' + fi + hardcode_libdir_separator=: + ;; + + sco3.2v5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag=' -z text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec='-R$libdir' + hardcode_shlibpath_var=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds='$CC -r -o $output$reload_objs' + hardcode_direct=no + ;; + motorola) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes + hardcode_minus_L=no + hardcode_shlibpath_var=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + sysv5*) + no_undefined_flag=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $ld_shlibs" >&5 +echo "${ECHO_T}$ld_shlibs" >&6; } +test "$ld_shlibs" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag + allow_undefined_flag= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc=no + else + archive_cmds_need_lc=yes + fi + allow_undefined_flag=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { echo "$as_me:$LINENO: result: $archive_cmds_need_lc" >&5 +echo "${ECHO_T}$archive_cmds_need_lc" >&6; } + ;; + esac + fi + ;; +esac + +{ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +{ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var" || \ + test "X$hardcode_automatic" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +{ echo "$as_me:$LINENO: result: $hardcode_action" >&5 +echo "${ECHO_T}$hardcode_action" >&6; } + +if test "$hardcode_action" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +{ echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + ;; + *) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + { echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; } +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* 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 shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_shl_load || defined __stub___shl_load +choke me +#endif + +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6; } +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; } +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + { echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; } +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* 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 dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_dlopen || defined __stub___dlopen +choke me +#endif + +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6; } +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_svld_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; } +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_dld_link=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; } +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# Report which librarie types wil actually be built +{ echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6; } + +{ echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6; } +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4* | aix5*) + if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then + test "$enable_shared" = yes && enable_static=no + fi + ;; +esac +{ echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6; } + +{ echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6; } +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +{ echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6; } + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler \ + CC \ + LD \ + lt_prog_compiler_wl \ + lt_prog_compiler_pic \ + lt_prog_compiler_static \ + lt_prog_compiler_no_builtin_flag \ + export_dynamic_flag_spec \ + thread_safe_flag_spec \ + whole_archive_flag_spec \ + enable_shared_with_static_runtimes \ + old_archive_cmds \ + old_archive_from_new_cmds \ + predep_objects \ + postdep_objects \ + predeps \ + postdeps \ + compiler_lib_search_path \ + archive_cmds \ + archive_expsym_cmds \ + postinstall_cmds \ + postuninstall_cmds \ + old_archive_from_expsyms_cmds \ + allow_undefined_flag \ + no_undefined_flag \ + export_symbols_cmds \ + hardcode_libdir_flag_spec \ + hardcode_libdir_flag_spec_ld \ + hardcode_libdir_separator \ + hardcode_automatic \ + module_cmds \ + module_expsym_cmds \ + lt_cv_prog_compiler_c_o \ + exclude_expsyms \ + include_expsyms; do + + case $var in + old_archive_cmds | \ + old_archive_from_new_cmds | \ + archive_cmds | \ + archive_expsym_cmds | \ + module_cmds | \ + module_expsym_cmds | \ + old_archive_from_expsyms_cmds | \ + export_symbols_cmds | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="${ofile}T" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + $rm -f "$cfgfile" + { echo "$as_me:$LINENO: creating $ofile" >&5 +echo "$as_me: creating $ofile" >&6;} + + cat <<__EOF__ >> "$cfgfile" +#! $SHELL + +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +# NOTE: Changes made to this file will be lost: look at ltmain.sh. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# +# This file is part of GNU Libtool: +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A sed program that does not truncate output. +SED=$lt_SED + +# Sed that helps us avoid accidentally triggering echo(1) options like -n. +Xsed="$SED -e s/^X//" + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# The names of the tagged configurations supported by this script. +available_tags= + +# ### BEGIN LIBTOOL CONFIG + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler + +# Is the compiler the GNU C compiler? +with_gcc=$GCC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds +archive_expsym_cmds=$lt_archive_expsym_cmds +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds +module_expsym_cmds=$lt_module_expsym_cmds + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms + +# ### END LIBTOOL CONFIG + +__EOF__ + + + case $host_os in + aix3*) + cat <<\EOF >> "$cfgfile" + +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test "X${COLLECT_NAMES+set}" != Xset; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +EOF + ;; + esac + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || \ + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +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 + +CC="$lt_save_CC" + + +# Check whether --with-tags was given. +if test "${with_tags+set}" = set; then + withval=$with_tags; tagnames="$withval" +fi + + +if test -f "$ltmain" && test -n "$tagnames"; then + if test ! -f "${ofile}"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not exist" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;} + fi + + if test -z "$LTCC"; then + eval "`$SHELL ${ofile} --config | grep '^LTCC='`" + if test -z "$LTCC"; then + { echo "$as_me:$LINENO: WARNING: output file \`$ofile' does not look like a libtool script" >&5 +echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;} + else + { echo "$as_me:$LINENO: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5 +echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;} + fi + fi + + # Extract list of available tagged configurations in $ofile. + # Note that this assumes the entire list is on one line. + available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'` + + lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," + for tagname in $tagnames; do + IFS="$lt_save_ifs" + # Check whether tagname contains only valid characters + case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in + "") ;; + *) { { echo "$as_me:$LINENO: error: invalid tag name: $tagname" >&5 +echo "$as_me: error: invalid tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null + then + { { echo "$as_me:$LINENO: error: tag name \"$tagname\" already exists" >&5 +echo "$as_me: error: tag name \"$tagname\" already exists" >&2;} + { (exit 1); exit 1; }; } + fi + + # Update the list of available tags. + if test -n "$tagname"; then + echo appending configuration tag \"$tagname\" to $ofile + + case $tagname in + CXX) + if test -n "$CXX" && ( test "X$CXX" != "Xno" && + ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || + (test "X$CXX" != "Xg++"))) ; then + ac_ext=cpp +ac_cpp='$CXXCPP $CPPFLAGS' +ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_cxx_compiler_gnu + + + + +archive_cmds_need_lc_CXX=no +allow_undefined_flag_CXX= +always_export_symbols_CXX=no +archive_expsym_cmds_CXX= +export_dynamic_flag_spec_CXX= +hardcode_direct_CXX=no +hardcode_libdir_flag_spec_CXX= +hardcode_libdir_flag_spec_ld_CXX= +hardcode_libdir_separator_CXX= +hardcode_minus_L_CXX=no +hardcode_automatic_CXX=no +module_cmds_CXX= +module_expsym_cmds_CXX= +link_all_deplibs_CXX=unknown +old_archive_cmds_CXX=$old_archive_cmds +no_undefined_flag_CXX= +whole_archive_flag_spec_CXX= +enable_shared_with_static_runtimes_CXX=no + +# Dependencies to place before and after the object being linked: +predep_objects_CXX= +postdep_objects_CXX= +predeps_CXX= +postdeps_CXX= +compiler_lib_search_path_CXX= + +# Source file extension for C++ test sources. +ac_ext=cc + +# Object file extension for compiled C++ test sources. +objext=o +objext_CXX=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(int, char *) { return(0); }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_LD=$LD +lt_save_GCC=$GCC +GCC=$GXX +lt_save_with_gnu_ld=$with_gnu_ld +lt_save_path_LD=$lt_cv_path_LD +if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx +else + unset lt_cv_prog_gnu_ld +fi +if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX +else + unset lt_cv_path_LD +fi +test -z "${LDCXX+set}" || LD=$LDCXX +CC=${CXX-"c++"} +compiler=$CC +compiler_CXX=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +# We don't want -fno-exception wen compiling C++ code, so set the +# no_builtin_flag separately +if test "$GXX" = yes; then + lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin' +else + lt_prog_compiler_no_builtin_flag_CXX= +fi + +if test "$GXX" = yes; then + # Set up default GNU C++ configuration + + +# Check whether --with-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$GCC" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + { echo "$as_me:$LINENO: checking for ld used by $CC" >&5 +echo $ECHO_N "checking for ld used by $CC... $ECHO_C" >&6; } + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [\\/]* | ?:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + { echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6; } +else + { echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6; } +fi +if test "${lt_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS="$lt_save_ifs" + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &5 +echo "${ECHO_T}$LD" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +{ echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6; } +if test "${lt_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +case `$LD -v 2>&1 &5 +echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6; } +with_gnu_ld=$lt_cv_prog_gnu_ld + + + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test "$with_gnu_ld" = yes; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='${wl}' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | \ + grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_CXX= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + +else + GXX=no + with_gnu_ld=no + wlarc= +fi + +# PORTME: fill in a description of your system's C++ link characteristics +{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } +ld_shlibs_CXX=yes +case $host_os in + aix3*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_CXX='' + hardcode_direct_CXX=yes + hardcode_libdir_separator_CXX=':' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_CXX=yes + else + # We have old collect2 + hardcode_direct_CXX=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_CXX=yes + hardcode_libdir_flag_spec_CXX='-L$libdir' + hardcode_libdir_separator_CXX= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_CXX=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_CXX='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + + archive_expsym_cmds_CXX="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_CXX="-z nodefs" + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_CXX=' ${wl}-bernotok' + allow_undefined_flag_CXX=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_CXX=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_CXX=' ' + archive_cmds_need_lc_CXX=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_CXX='-L$libdir' + allow_undefined_flag_CXX=unsupported + always_export_symbols_CXX=no + enable_shared_with_static_runtimes_CXX=yes + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs_CXX=no + fi + ;; + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_CXX='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_CXX='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_CXX='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_direct_CXX=no + hardcode_automatic_CXX=yes + hardcode_shlibpath_var_CXX=unsupported + whole_archive_flag_spec_CXX='' + link_all_deplibs_CXX=yes + + if test "$GXX" = yes ; then + lt_int_apple_cc_single_mod=no + output_verbose_link_cmd='echo' + if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then + lt_int_apple_cc_single_mod=yes + fi + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_cmds_CXX='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + else + archive_cmds_CXX='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + fi + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + if test "X$lt_int_apple_cc_single_mod" = Xyes ; then + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + fi + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_CXX='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_CXX='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_CXX='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_CXX=no + ;; + esac + fi + ;; + + dgux*) + case $cc_basename in + ec++) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + ghcx) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + freebsd12*) + # C++ shared libraries reported to be fairly broken before switch to ELF + ld_shlibs_CXX=no + ;; + freebsd-elf*) + archive_cmds_need_lc_CXX=no + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + ld_shlibs_CXX=yes + ;; + gnu*) + ;; + hpux9*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC) + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + archive_cmds_CXX='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + hpux10*|hpux11*) + if test $with_gnu_ld = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_CXX='+b $libdir' + hardcode_libdir_separator_CXX=: + ;; + ia64*) + hardcode_libdir_flag_spec_CXX='-L$libdir' + ;; + *) + hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_CXX=: + export_dynamic_flag_spec_CXX='${wl}-E' + ;; + esac + fi + case "$host_cpu" in + hppa*64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + ;; + ia64*) + hardcode_direct_CXX=no + hardcode_shlibpath_var_CXX=no + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + *) + hardcode_direct_CXX=yes + hardcode_minus_L_CXX=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + aCC) + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes; then + if test $with_gnu_ld = no; then + case "$host_cpu" in + ia64*|hppa*64*) + archive_cmds_CXX='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs' + ;; + *) + archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + irix5* | irix6*) + case $cc_basename in + CC) + # SGI C++ + archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test "$GXX" = yes; then + if test "$with_gnu_ld" = no; then + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + else + archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib' + fi + fi + link_all_deplibs_CXX=yes + ;; + esac + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + ;; + linux*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + hardcode_libdir_flag_spec_CXX='${wl}--rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + archive_cmds_need_lc_CXX=no + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + export_dynamic_flag_spec_CXX='${wl}--export-dynamic' + whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive' + ;; + cxx) + # Compaq C++ + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + esac + ;; + lynxos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + m88k*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + mvs*) + case $cc_basename in + cxx) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + openbsd2*) + # C++ shared libraries are fairly broken + ld_shlibs_CXX=no + ;; + openbsd*) + hardcode_direct_CXX=yes + hardcode_shlibpath_var_CXX=no + archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' + export_dynamic_flag_spec_CXX='${wl}-E' + whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + fi + output_verbose_link_cmd='echo' + ;; + osf3*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' + + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx) + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + osf4* | osf5*) + case $cc_basename in + KCC) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir' + hardcode_libdir_separator_CXX=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' + ;; + RCC) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + cxx) + allow_undefined_flag_CXX=' -expect_unresolved \*' + archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib' + archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp `test -n "$verstring" && echo -set_version $verstring` -update_registry $objdir/so_locations -o $lib~ + $rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-rpath $libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + ;; + *) + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib' + + hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_CXX=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"' + + else + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + fi + ;; + esac + ;; + psos*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + sco*) + archive_cmds_need_lc_CXX=no + case $cc_basename in + CC) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + lcc) + # Lucid + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + no_undefined_flag_CXX=' -zdefs' + archive_cmds_CXX='$CC -G${allow_undefined_flag} -nolib -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G${allow_undefined_flag} -nolib ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + hardcode_libdir_flag_spec_CXX='-R$libdir' + hardcode_shlibpath_var_CXX=no + case $host_os in + solaris2.0-5 | solaris2.0-5.*) ;; + *) + # The C++ compiler is used as linker so we must use $wl + # flag to pass the commands to the underlying system + # linker. + # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' + ;; + esac + link_all_deplibs_CXX=yes + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep "\-[LR]"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs' + ;; + gcx) + # Green Hills C++ Compiler + archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test "$GXX" = yes && test "$with_gnu_ld" = no; then + no_undefined_flag_CXX=' ${wl}-z ${wl}defs' + if $CC --version | grep -v '^2\.7' > /dev/null; then + archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + else + # g++ 2.7 appears to require `-G' NOT `-shared' on this + # platform. + archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' + archive_expsym_cmds_CXX='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\"" + fi + + hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir' + fi + ;; + esac + ;; + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + archive_cmds_need_lc_CXX=no + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + esac + ;; + vxworks*) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; + *) + # FIXME: insert proper C++ library support + ld_shlibs_CXX=no + ;; +esac +{ echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6; } +test "$ld_shlibs_CXX" = no && can_build_shared=no + +GCC_CXX="$GXX" +LD_CXX="$LD" + + +cat > conftest.$ac_ext <&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + # The `*' in the case matches for architectures that use `case' in + # $output_verbose_cmd can trigger glob expansion during the loop + # eval without this substitution. + output_verbose_link_cmd="`$echo \"X$output_verbose_link_cmd\" | $Xsed -e \"$no_glob_subst\"`" + + for p in `eval $output_verbose_link_cmd`; do + case $p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test $p = "-L" \ + || test $p = "-R"; then + prev=$p + continue + else + prev= + fi + + if test "$pre_test_object_deps_done" = no; then + case $p in + -L* | -R*) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$compiler_lib_search_path_CXX"; then + compiler_lib_search_path_CXX="${prev}${p}" + else + compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$postdeps_CXX"; then + postdeps_CXX="${prev}${p}" + else + postdeps_CXX="${postdeps_CXX} ${prev}${p}" + fi + fi + ;; + + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test "$pre_test_object_deps_done" = no; then + if test -z "$predep_objects_CXX"; then + predep_objects_CXX="$p" + else + predep_objects_CXX="$predep_objects_CXX $p" + fi + else + if test -z "$postdep_objects_CXX"; then + postdep_objects_CXX="$p" + else + postdep_objects_CXX="$postdep_objects_CXX $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling CXX test program" +fi + +$rm -f confest.$objext + +case " $postdeps_CXX " in +*" -lc "*) archive_cmds_need_lc_CXX=no ;; +esac + +lt_prog_compiler_wl_CXX= +lt_prog_compiler_pic_CXX= +lt_prog_compiler_static_CXX= + +{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } + + # C++ specific cases for pic, static, wl, etc. + if test "$GXX" = yes; then + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + fi + ;; + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4' + ;; + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | os2* | pw32*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_CXX='-DDLL_EXPORT' + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_CXX='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + lt_prog_compiler_pic_CXX= + ;; + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_CXX=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + ;; + *) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + esac + else + case $host_os in + aix4* | aix5*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_CXX='-Bstatic' + else + lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68) + # Green Hills C++ Compiler + # _LT_AC_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + lt_prog_compiler_pic_CXX='-qnocommon' + lt_prog_compiler_wl_CXX='-Wl,' + ;; + esac + ;; + dgux*) + case $cc_basename in + ec++) + lt_prog_compiler_pic_CXX='-KPIC' + ;; + ghcx) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | kfreebsd*-gnu) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + if test "$host_cpu" != ia64; then + lt_prog_compiler_pic_CXX='+Z' + fi + ;; + aCC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_CXX='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC) + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_static_CXX='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux*) + case $cc_basename in + KCC) + # KAI C++ Compiler + lt_prog_compiler_wl_CXX='--backend -Wl,' + lt_prog_compiler_pic_CXX='-fPIC' + ;; + icpc) + # Intel C++ + lt_prog_compiler_wl_CXX='-Wl,' + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-static' + ;; + cxx) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx) + lt_prog_compiler_pic_CXX='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd*) + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC) + lt_prog_compiler_wl_CXX='--backend -Wl,' + ;; + RCC) + # Rational C++ 2.4.1 + lt_prog_compiler_pic_CXX='-pic' + ;; + cxx) + # Digital/Compaq C++ + lt_prog_compiler_wl_CXX='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + lt_prog_compiler_pic_CXX= + lt_prog_compiler_static_CXX='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + sco*) + case $cc_basename in + CC) + lt_prog_compiler_pic_CXX='-fPIC' + ;; + *) + ;; + esac + ;; + solaris*) + case $cc_basename in + CC) + # Sun C++ 4.2, 5.x and Centerline C++ + lt_prog_compiler_pic_CXX='-KPIC' + lt_prog_compiler_static_CXX='-Bstatic' + lt_prog_compiler_wl_CXX='-Qoption ld ' + ;; + gcx) + # Green Hills C++ Compiler + lt_prog_compiler_pic_CXX='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC) + # Sun C++ 4.x + lt_prog_compiler_pic_CXX='-pic' + lt_prog_compiler_static_CXX='-Bstatic' + ;; + lcc) + # Lucid + lt_prog_compiler_pic_CXX='-pic' + ;; + *) + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC) + # NonStop-UX NCC 3.20 + lt_prog_compiler_pic_CXX='-KPIC' + ;; + *) + ;; + esac + ;; + unixware*) + ;; + vxworks*) + ;; + *) + lt_prog_compiler_can_build_shared_CXX=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_CXX" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_CXX"; then + +{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... $ECHO_C" >&6; } +if test "${lt_prog_compiler_pic_works_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_CXX=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12713: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:12717: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_CXX=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_CXX" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_CXX" >&6; } + +if test x"$lt_prog_compiler_pic_works_CXX" = xyes; then + case $lt_prog_compiler_pic_CXX in + "" | " "*) ;; + *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;; + esac +else + lt_prog_compiler_pic_CXX= + lt_prog_compiler_can_build_shared_CXX=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_CXX= + ;; + *) + lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC" + ;; +esac + +{ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_c_o_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_CXX=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:12773: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:12777: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_CXX=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_CXX" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_CXX" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6; } + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } + + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + case $host_os in + aix4* | aix5*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + export_symbols_cmds_CXX="$ltdll_cmds" + ;; + cygwin* | mingw*) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + ;; + *) + export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac + +{ echo "$as_me:$LINENO: result: $ld_shlibs_CXX" >&5 +echo "${ECHO_T}$ld_shlibs_CXX" >&6; } +test "$ld_shlibs_CXX" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_CXX" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_CXX=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_CXX in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_CXX + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_CXX + allow_undefined_flag_CXX= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_CXX 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_CXX=no + else + archive_cmds_need_lc_CXX=yes + fi + allow_undefined_flag_CXX=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_CXX" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_CXX" >&6; } + ;; + esac + fi + ;; +esac + +{ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +{ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } +hardcode_action_CXX= +if test -n "$hardcode_libdir_flag_spec_CXX" || \ + test -n "$runpath_var_CXX" || \ + test "X$hardcode_automatic_CXX" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_CXX" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, CXX)" != no && + test "$hardcode_minus_L_CXX" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_CXX=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_CXX=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_CXX=unsupported +fi +{ echo "$as_me:$LINENO: result: $hardcode_action_CXX" >&5 +echo "${ECHO_T}$hardcode_action_CXX" >&6; } + +if test "$hardcode_action_CXX" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +{ echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + ;; + *) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + { echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; } +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* 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 shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_shl_load || defined __stub___shl_load +choke me +#endif + +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6; } +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; } +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + { echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; } +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* 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 dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_dlopen || defined __stub___dlopen +choke me +#endif + +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6; } +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_svld_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; } +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_cxx_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_dld_link=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; } +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_CXX \ + CC_CXX \ + LD_CXX \ + lt_prog_compiler_wl_CXX \ + lt_prog_compiler_pic_CXX \ + lt_prog_compiler_static_CXX \ + lt_prog_compiler_no_builtin_flag_CXX \ + export_dynamic_flag_spec_CXX \ + thread_safe_flag_spec_CXX \ + whole_archive_flag_spec_CXX \ + enable_shared_with_static_runtimes_CXX \ + old_archive_cmds_CXX \ + old_archive_from_new_cmds_CXX \ + predep_objects_CXX \ + postdep_objects_CXX \ + predeps_CXX \ + postdeps_CXX \ + compiler_lib_search_path_CXX \ + archive_cmds_CXX \ + archive_expsym_cmds_CXX \ + postinstall_cmds_CXX \ + postuninstall_cmds_CXX \ + old_archive_from_expsyms_cmds_CXX \ + allow_undefined_flag_CXX \ + no_undefined_flag_CXX \ + export_symbols_cmds_CXX \ + hardcode_libdir_flag_spec_CXX \ + hardcode_libdir_flag_spec_ld_CXX \ + hardcode_libdir_separator_CXX \ + hardcode_automatic_CXX \ + module_cmds_CXX \ + module_expsym_cmds_CXX \ + lt_cv_prog_compiler_c_o_CXX \ + exclude_expsyms_CXX \ + include_expsyms_CXX; do + + case $var in + old_archive_cmds_CXX | \ + old_archive_from_new_cmds_CXX | \ + archive_cmds_CXX | \ + archive_expsym_cmds_CXX | \ + module_cmds_CXX | \ + module_expsym_cmds_CXX | \ + old_archive_from_expsyms_cmds_CXX | \ + export_symbols_cmds_CXX | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_CXX + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_CXX + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_CXX + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_CXX + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_CXX + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_CXX +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_CXX + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_CXX + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_CXX +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_CXX +archive_expsym_cmds=$lt_archive_expsym_cmds_CXX +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_CXX +module_expsym_cmds=$lt_module_expsym_cmds_CXX + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_CXX + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_CXX + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_CXX + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_CXX + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_CXX + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_CXX + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_CXX + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_CXX + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_CXX + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_CXX + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_CXX + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_CXX" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_CXX + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_CXX + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_CXX + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_CXX + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +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 + +CC=$lt_save_CC +LDCXX=$LD +LD=$lt_save_LD +GCC=$lt_save_GCC +with_gnu_ldcxx=$with_gnu_ld +with_gnu_ld=$lt_save_with_gnu_ld +lt_cv_path_LDCXX=$lt_cv_path_LD +lt_cv_path_LD=$lt_save_path_LD +lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld +lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld + + else + tagname="" + fi + ;; + + F77) + if test -n "$F77" && test "X$F77" != "Xno"; then + +ac_ext=f +ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5' +ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_f77_compiler_gnu + + +archive_cmds_need_lc_F77=no +allow_undefined_flag_F77= +always_export_symbols_F77=no +archive_expsym_cmds_F77= +export_dynamic_flag_spec_F77= +hardcode_direct_F77=no +hardcode_libdir_flag_spec_F77= +hardcode_libdir_flag_spec_ld_F77= +hardcode_libdir_separator_F77= +hardcode_minus_L_F77=no +hardcode_automatic_F77=no +module_cmds_F77= +module_expsym_cmds_F77= +link_all_deplibs_F77=unknown +old_archive_cmds_F77=$old_archive_cmds +no_undefined_flag_F77= +whole_archive_flag_spec_F77= +enable_shared_with_static_runtimes_F77=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +objext_F77=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code=" subroutine t\n return\n end\n" + +# Code to be used in simple link tests +lt_simple_link_test_code=" program t\n end\n" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${F77-"f77"} +compiler=$CC +compiler_F77=$CC +cc_basename=`$echo X"$compiler" | $Xsed -e 's%^.*/%%'` + +{ echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 +echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $can_build_shared" >&5 +echo "${ECHO_T}$can_build_shared" >&6; } + +{ echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 +echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6; } +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; +aix4* | aix5*) + test "$enable_shared" = yes && enable_static=no + ;; +esac +{ echo "$as_me:$LINENO: result: $enable_shared" >&5 +echo "${ECHO_T}$enable_shared" >&6; } + +{ echo "$as_me:$LINENO: checking whether to build static libraries" >&5 +echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6; } +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes +{ echo "$as_me:$LINENO: result: $enable_static" >&5 +echo "${ECHO_T}$enable_static" >&6; } + +test "$ld_shlibs_F77" = no && can_build_shared=no + +GCC_F77="$G77" +LD_F77="$LD" + +lt_prog_compiler_wl_F77= +lt_prog_compiler_pic_F77= +lt_prog_compiler_static_F77= + +{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_static_F77='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_F77='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_F77='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_F77=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_F77=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_F77='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_F77='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_F77='-Bstatic' + else + lt_prog_compiler_static_F77='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + lt_prog_compiler_pic_F77='-qnocommon' + lt_prog_compiler_wl_F77='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_F77='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_F77='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_F77='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_F77='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_F77='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-static' + ;; + ccc*) + lt_prog_compiler_wl_F77='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_F77='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_F77='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic_F77='-Kpic' + lt_prog_compiler_static_F77='-dn' + ;; + + solaris*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl_F77='-Qoption ld ' + lt_prog_compiler_pic_F77='-PIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl_F77='-Wl,' + lt_prog_compiler_pic_F77='-KPIC' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_F77='-Kconform_pic' + lt_prog_compiler_static_F77='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic_F77='-pic' + lt_prog_compiler_static_F77='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_F77=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_F77" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_F77"; then + +{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_F77 works... $ECHO_C" >&6; } +if test "${lt_prog_compiler_pic_works_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_F77=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_F77" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15148: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:15152: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_F77=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_F77" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_F77" >&6; } + +if test x"$lt_prog_compiler_pic_works_F77" = xyes; then + case $lt_prog_compiler_pic_F77 in + "" | " "*) ;; + *) lt_prog_compiler_pic_F77=" $lt_prog_compiler_pic_F77" ;; + esac +else + lt_prog_compiler_pic_F77= + lt_prog_compiler_can_build_shared_F77=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_F77= + ;; + *) + lt_prog_compiler_pic_F77="$lt_prog_compiler_pic_F77" + ;; +esac + +{ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_c_o_F77+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_F77=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:15208: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:15212: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_F77=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_F77" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_F77" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_F77" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6; } + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } + + runpath_var= + allow_undefined_flag_F77= + enable_shared_with_static_runtimes_F77=no + archive_cmds_F77= + archive_expsym_cmds_F77= + old_archive_From_new_cmds_F77= + old_archive_from_expsyms_cmds_F77= + export_dynamic_flag_spec_F77= + whole_archive_flag_spec_F77= + thread_safe_flag_spec_F77= + hardcode_libdir_flag_spec_F77= + hardcode_libdir_flag_spec_ld_F77= + hardcode_libdir_separator_F77= + hardcode_direct_F77=no + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=unsupported + link_all_deplibs_F77=unknown + hardcode_automatic_F77=no + module_cmds_F77= + module_expsym_cmds_F77= + always_export_symbols_F77=no + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_F77= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_F77="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_F77=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_F77=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_F77=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_F77='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, F77) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_F77='-L$libdir' + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=no + enable_shared_with_static_runtimes_F77=yes + export_symbols_cmds_F77='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_F77='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_F77=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + + sunos4*) + archive_cmds_F77='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_F77="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_F77='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds_F77="$tmp_archive_cmds" + fi + else + ld_shlibs_F77=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_F77=no + fi + ;; + esac + + if test "$ld_shlibs_F77" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_F77='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_F77='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_F77="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_F77= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_F77=unsupported + always_export_symbols_F77=yes + archive_expsym_cmds_F77='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_F77=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_F77=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_F77='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_F77='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_F77='' + hardcode_direct_F77=yes + hardcode_libdir_separator_F77=':' + link_all_deplibs_F77=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_F77=yes + else + # We have old collect2 + hardcode_direct_F77=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_F77=yes + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_libdir_separator_F77= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_F77=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_F77='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_F77="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_F77='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_F77="-z nodefs" + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF + program main + + end +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_f77_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_F77='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_F77=' ${wl}-bernotok' + allow_undefined_flag_F77=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_F77=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_F77=' ' + archive_cmds_need_lc_F77=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_F77="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_F77='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_F77=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_F77=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_F77=' ' + allow_undefined_flag_F77=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_F77='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_F77='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_F77='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_F77=yes + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_F77='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_F77='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_F77='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_F77=no + hardcode_direct_F77=no + hardcode_automatic_F77=yes + hardcode_shlibpath_var_F77=unsupported + whole_archive_flag_spec_F77='' + link_all_deplibs_F77=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_F77='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_F77='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_F77='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_F77=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + freebsd1*) + ld_shlibs_F77=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds_F77='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_F77='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_F77='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_F77='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_F77='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_F77='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds_F77='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_F77='+b $libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + ;; + ia64*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=no + hardcode_shlibpath_var_F77=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + *) + hardcode_libdir_flag_spec_F77='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_direct_F77=yes + export_dynamic_flag_spec_F77='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_F77=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_F77='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_F77='-rpath $libdir' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + link_all_deplibs_F77=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_F77='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + newsos6) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + hardcode_shlibpath_var_F77=no + ;; + + openbsd*) + hardcode_direct_F77=yes + hardcode_shlibpath_var_F77=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + export_dynamic_flag_spec_F77='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_F77='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-R$libdir' + ;; + *) + archive_cmds_F77='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_F77='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_minus_L_F77=yes + allow_undefined_flag_F77=unsupported + archive_cmds_F77='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_F77='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_F77=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_F77=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_F77='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_F77='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_F77=' -expect_unresolved \*' + archive_cmds_F77='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_F77='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_F77='-rpath $libdir' + fi + hardcode_libdir_separator_F77=: + ;; + + sco3.2v5*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag_F77=' -z text' + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_F77='-R$libdir' + hardcode_shlibpath_var_F77=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_F77='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs_F77=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_F77='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_direct_F77=yes + hardcode_minus_L_F77=yes + hardcode_shlibpath_var_F77=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_F77='$CC -r -o $output$reload_objs' + hardcode_direct_F77=no + ;; + motorola) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv4.3*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + export_dynamic_flag_spec_F77='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_F77=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_F77=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds_F77='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_F77=yes + hardcode_minus_L_F77=no + hardcode_shlibpath_var_F77=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag_F77='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds_F77='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_F77='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_F77=no + ;; + + sysv5*) + no_undefined_flag_F77=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds_F77='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_F77='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec_F77= + hardcode_shlibpath_var_F77=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds_F77='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_F77='-L$libdir' + hardcode_shlibpath_var_F77=no + ;; + + *) + ld_shlibs_F77=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $ld_shlibs_F77" >&5 +echo "${ECHO_T}$ld_shlibs_F77" >&6; } +test "$ld_shlibs_F77" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_F77" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_F77=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_F77 in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_F77 + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_F77 + allow_undefined_flag_F77= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_F77 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_F77=no + else + archive_cmds_need_lc_F77=yes + fi + allow_undefined_flag_F77=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_F77" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_F77" >&6; } + ;; + esac + fi + ;; +esac + +{ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +{ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } +hardcode_action_F77= +if test -n "$hardcode_libdir_flag_spec_F77" || \ + test -n "$runpath_var_F77" || \ + test "X$hardcode_automatic_F77" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_F77" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, F77)" != no && + test "$hardcode_minus_L_F77" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_F77=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_F77=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_F77=unsupported +fi +{ echo "$as_me:$LINENO: result: $hardcode_action_F77" >&5 +echo "${ECHO_T}$hardcode_action_F77" >&6; } + +if test "$hardcode_action_F77" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +{ echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + ;; + *) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ;; + esac +fi + + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_F77 \ + CC_F77 \ + LD_F77 \ + lt_prog_compiler_wl_F77 \ + lt_prog_compiler_pic_F77 \ + lt_prog_compiler_static_F77 \ + lt_prog_compiler_no_builtin_flag_F77 \ + export_dynamic_flag_spec_F77 \ + thread_safe_flag_spec_F77 \ + whole_archive_flag_spec_F77 \ + enable_shared_with_static_runtimes_F77 \ + old_archive_cmds_F77 \ + old_archive_from_new_cmds_F77 \ + predep_objects_F77 \ + postdep_objects_F77 \ + predeps_F77 \ + postdeps_F77 \ + compiler_lib_search_path_F77 \ + archive_cmds_F77 \ + archive_expsym_cmds_F77 \ + postinstall_cmds_F77 \ + postuninstall_cmds_F77 \ + old_archive_from_expsyms_cmds_F77 \ + allow_undefined_flag_F77 \ + no_undefined_flag_F77 \ + export_symbols_cmds_F77 \ + hardcode_libdir_flag_spec_F77 \ + hardcode_libdir_flag_spec_ld_F77 \ + hardcode_libdir_separator_F77 \ + hardcode_automatic_F77 \ + module_cmds_F77 \ + module_expsym_cmds_F77 \ + lt_cv_prog_compiler_c_o_F77 \ + exclude_expsyms_F77 \ + include_expsyms_F77; do + + case $var in + old_archive_cmds_F77 | \ + old_archive_from_new_cmds_F77 | \ + archive_cmds_F77 | \ + archive_expsym_cmds_F77 | \ + module_cmds_F77 | \ + module_expsym_cmds_F77 | \ + old_archive_from_expsyms_cmds_F77 | \ + export_symbols_cmds_F77 | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_F77 + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77 + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_F77 + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_F77 + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_F77 + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_F77 + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_F77 +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77 + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_F77 + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77 + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77 + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77 + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_F77 + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_F77 +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77 + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77 + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_F77 +archive_expsym_cmds=$lt_archive_expsym_cmds_F77 +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_F77 +module_expsym_cmds=$lt_module_expsym_cmds_F77 + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_F77 + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_F77 + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_F77 + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_F77 + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_F77 + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_F77 + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_F77 + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77 + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_F77 + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77 + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_F77 + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_F77 + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_F77 + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_F77 + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_F77 + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_F77" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_F77 + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_F77 + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_F77 + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_F77 + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +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 + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + GCJ) + if test -n "$GCJ" && test "X$GCJ" != "Xno"; then + + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +objext_GCJ=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}\n" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String argv) {}; }\n' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${GCJ-"gcj"} +compiler=$CC +compiler_GCJ=$CC + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +archive_cmds_need_lc_GCJ=no + + +lt_prog_compiler_no_builtin_flag_GCJ= + +if test "$GCC" = yes; then + lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin' + + +{ echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 +echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_rtti_exceptions=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="-fno-rtti -fno-exceptions" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:17270: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:17274: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_cv_prog_compiler_rtti_exceptions=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_rtti_exceptions" >&6; } + +if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then + lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions" +else + : +fi + +fi + +lt_prog_compiler_wl_GCJ= +lt_prog_compiler_pic_GCJ= +lt_prog_compiler_static_GCJ= + +{ echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 +echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6; } + + if test "$GCC" = yes; then + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_static_GCJ='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + amigaos*) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the `-m68020' flag to GCC prevents building anything better, + # like `-m68040'. + lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4' + ;; + + beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + lt_prog_compiler_pic_GCJ='-fno-common' + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + lt_prog_compiler_can_build_shared_GCJ=no + enable_shared=no + ;; + + sysv4*MP*) + if test -d /usr/nec; then + lt_prog_compiler_pic_GCJ=-Kconform_pic + fi + ;; + + hpux*) + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + ;; + + *) + lt_prog_compiler_pic_GCJ='-fPIC' + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + lt_prog_compiler_wl_GCJ='-Wl,' + if test "$host_cpu" = ia64; then + # AIX 5 now supports IA64 processor + lt_prog_compiler_static_GCJ='-Bstatic' + else + lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp' + fi + ;; + darwin*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + case "$cc_basename" in + xlc*) + lt_prog_compiler_pic_GCJ='-qnocommon' + lt_prog_compiler_wl_GCJ='-Wl,' + ;; + esac + ;; + + mingw* | pw32* | os2*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + lt_prog_compiler_pic_GCJ='-DDLL_EXPORT' + ;; + + hpux9* | hpux10* | hpux11*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case "$host_cpu" in + hppa*64*|ia64*) + # +Z the default + ;; + *) + lt_prog_compiler_pic_GCJ='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + lt_prog_compiler_wl_GCJ='-Wl,' + # PIC (with -KPIC) is the default. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + newsos6) + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + linux*) + case $CC in + icc* | ecc*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-static' + ;; + ccc*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All Alpha code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + esac + ;; + + osf3* | osf4* | osf5*) + lt_prog_compiler_wl_GCJ='-Wl,' + # All OSF/1 code is PIC. + lt_prog_compiler_static_GCJ='-non_shared' + ;; + + sco3.2v5*) + lt_prog_compiler_pic_GCJ='-Kpic' + lt_prog_compiler_static_GCJ='-dn' + ;; + + solaris*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sunos4*) + lt_prog_compiler_wl_GCJ='-Qoption ld ' + lt_prog_compiler_pic_GCJ='-PIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + lt_prog_compiler_wl_GCJ='-Wl,' + lt_prog_compiler_pic_GCJ='-KPIC' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + lt_prog_compiler_pic_GCJ='-Kconform_pic' + lt_prog_compiler_static_GCJ='-Bstatic' + fi + ;; + + uts4*) + lt_prog_compiler_pic_GCJ='-pic' + lt_prog_compiler_static_GCJ='-Bstatic' + ;; + + *) + lt_prog_compiler_can_build_shared_GCJ=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_GCJ" >&6; } + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$lt_prog_compiler_pic_GCJ"; then + +{ echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5 +echo $ECHO_N "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... $ECHO_C" >&6; } +if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_prog_compiler_pic_works_GCJ=no + ac_outfile=conftest.$ac_objext + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$lt_prog_compiler_pic_GCJ" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:17513: $lt_compile\"" >&5) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&5 + echo "$as_me:17517: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s conftest.err; then + lt_prog_compiler_pic_works_GCJ=yes + fi + fi + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_prog_compiler_pic_works_GCJ" >&5 +echo "${ECHO_T}$lt_prog_compiler_pic_works_GCJ" >&6; } + +if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then + case $lt_prog_compiler_pic_GCJ in + "" | " "*) ;; + *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;; + esac +else + lt_prog_compiler_pic_GCJ= + lt_prog_compiler_can_build_shared_GCJ=no +fi + +fi +case "$host_os" in + # For platforms which do not support PIC, -DPIC is meaningless: + *djgpp*) + lt_prog_compiler_pic_GCJ= + ;; + *) + lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ" + ;; +esac + +{ echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 +echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6; } +if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + lt_cv_prog_compiler_c_o_GCJ=no + $rm -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ + -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:17573: $lt_compile\"" >&5) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&5 + echo "$as_me:17577: \$? = $ac_status" >&5 + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test ! -s out/conftest.err; then + lt_cv_prog_compiler_c_o_GCJ=yes + fi + fi + chmod u+w . + $rm conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files + $rm out/* && rmdir out + cd .. + rmdir conftest + $rm conftest* + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_prog_compiler_c_o_GCJ" >&5 +echo "${ECHO_T}$lt_cv_prog_compiler_c_o_GCJ" >&6; } + + +hard_links="nottested" +if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + { echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 +echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6; } + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + { echo "$as_me:$LINENO: result: $hard_links" >&5 +echo "${ECHO_T}$hard_links" >&6; } + if test "$hard_links" = no; then + { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 +echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} + need_locks=warn + fi +else + need_locks=no +fi + +{ echo "$as_me:$LINENO: checking whether the $compiler linker ($LD) supports shared libraries" >&5 +echo $ECHO_N "checking whether the $compiler linker ($LD) supports shared libraries... $ECHO_C" >&6; } + + runpath_var= + allow_undefined_flag_GCJ= + enable_shared_with_static_runtimes_GCJ=no + archive_cmds_GCJ= + archive_expsym_cmds_GCJ= + old_archive_From_new_cmds_GCJ= + old_archive_from_expsyms_cmds_GCJ= + export_dynamic_flag_spec_GCJ= + whole_archive_flag_spec_GCJ= + thread_safe_flag_spec_GCJ= + hardcode_libdir_flag_spec_GCJ= + hardcode_libdir_flag_spec_ld_GCJ= + hardcode_libdir_separator_GCJ= + hardcode_direct_GCJ=no + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=unsupported + link_all_deplibs_GCJ=unknown + hardcode_automatic_GCJ=no + module_cmds_GCJ= + module_expsym_cmds_GCJ= + always_export_symbols_GCJ=no + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + include_expsyms_GCJ= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ` (' and `)$', so one must not match beginning or + # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', + # as well as any symbol that contains `d'. + exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_" + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test "$GCC" != yes; then + with_gnu_ld=no + fi + ;; + openbsd*) + with_gnu_ld=no + ;; + esac + + ld_shlibs_GCJ=yes + if test "$with_gnu_ld" = yes; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='${wl}' + + # See if GNU ld supports shared libraries. + case $host_os in + aix3* | aix4* | aix5*) + # On AIX/PPC, the GNU linker is very broken + if test "$host_cpu" != ia64; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: the GNU linker, at least up to release 2.9.1, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to modify your PATH +*** so that a non-GNU linker is found, and then restart. + +EOF + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + + # Samuel A. Falvo II reports + # that the semantics of dynamic libraries on AmigaOS, at least up + # to version 4, is to share data among multiple programs linked + # with the same dynamic library. Since this doesn't match the + # behavior of shared libraries on other platforms, we can't use + # them. + ld_shlibs_GCJ=no + ;; + + beos*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + allow_undefined_flag_GCJ=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + cygwin* | mingw* | pw32*) + # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless, + # as there is no search path for DLLs. + hardcode_libdir_flag_spec_GCJ='-L$libdir' + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=no + enable_shared_with_static_runtimes_GCJ=yes + export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols' + + if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + # If the export-symbols file already is a .def file (1st line + # is EXPORTS), use it as is; otherwise, prepend... + archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib' + else + ld_shlibs=no + fi + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris* | sysv5*) + if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then + ld_shlibs_GCJ=no + cat <&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +EOF + elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + + sunos4*) + archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + linux*) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + tmp_archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_cmds_GCJ="$tmp_archive_cmds" + supports_anon_versioning=no + case `$LD -v 2>/dev/null` in + *\ 01.* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + if test $supports_anon_versioning = yes; then + archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~ +cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ +$echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' + else + archive_expsym_cmds_GCJ="$tmp_archive_cmds" + fi + else + ld_shlibs_GCJ=no + fi + ;; + + *) + if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' + else + ld_shlibs_GCJ=no + fi + ;; + esac + + if test "$ld_shlibs_GCJ" = yes; then + runpath_var=LD_RUN_PATH + hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir' + export_dynamic_flag_spec_GCJ='${wl}--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then + whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' + else + whole_archive_flag_spec_GCJ= + fi + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + allow_undefined_flag_GCJ=unsupported + always_export_symbols_GCJ=yes + archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L_GCJ=yes + if test "$GCC" = yes && test -z "$link_static_flag"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + hardcode_direct_GCJ=unsupported + fi + ;; + + aix4* | aix5*) + if test "$host_cpu" = ia64; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag="" + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to AIX nm, but means don't demangle with GNU nm + if $NM -V 2>&1 | grep 'GNU' > /dev/null; then + export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + else + export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # need to do runtime linking. + case $host_os in aix4.[23]|aix4.[23].*|aix5*) + for ld_flag in $LDFLAGS; do + if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then + aix_use_runtimelinking=yes + break + fi + done + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + archive_cmds_GCJ='' + hardcode_direct_GCJ=yes + hardcode_libdir_separator_GCJ=':' + link_all_deplibs_GCJ=yes + + if test "$GCC" = yes; then + case $host_os in aix4.012|aix4.012.*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`${CC} -print-prog-name=collect2` + if test -f "$collect2name" && \ + strings "$collect2name" | grep resolve_lib_name >/dev/null + then + # We have reworked collect2 + hardcode_direct_GCJ=yes + else + # We have old collect2 + hardcode_direct_GCJ=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + hardcode_minus_L_GCJ=yes + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_libdir_separator_GCJ= + fi + esac + shared_flag='-shared' + else + # not using gcc + if test "$host_cpu" = ia64; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test "$aix_use_runtimelinking" = yes; then + shared_flag='${wl}-G' + else + shared_flag='${wl}-bM:SRE' + fi + fi + fi + + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + always_export_symbols_GCJ=yes + if test "$aix_use_runtimelinking" = yes; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + allow_undefined_flag_GCJ='-berok' + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" + else + if test "$host_cpu" = ia64; then + hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib' + allow_undefined_flag_GCJ="-z nodefs" + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an empty executable. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + +aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'` +# Check for a 64-bit object if we didn't find anything. +if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; } +}'`; fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi + + hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + no_undefined_flag_GCJ=' ${wl}-bernotok' + allow_undefined_flag_GCJ=' ${wl}-berok' + # -bexpall does not export symbols beginning with underscore (_) + always_export_symbols_GCJ=yes + # Exported symbols can be pulled into shared objects from archives + whole_archive_flag_spec_GCJ=' ' + archive_cmds_need_lc_GCJ=yes + # This is similar to how AIX traditionally builds it's shared libraries. + archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' + fi + fi + ;; + + amigaos*) + archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + # see comment about different semantics on the GNU ld section + ld_shlibs_GCJ=no + ;; + + bsdi[45]*) + export_dynamic_flag_spec_GCJ=-rdynamic + ;; + + cygwin* | mingw* | pw32*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + hardcode_libdir_flag_spec_GCJ=' ' + allow_undefined_flag_GCJ=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=".dll" + # FIXME: Setting linknames here is a bad hack. + archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + old_archive_From_new_cmds_GCJ='true' + # FIXME: Should let the user specify the lib program. + old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs' + fix_srcfile_path='`cygpath -w "$srcfile"`' + enable_shared_with_static_runtimes_GCJ=yes + ;; + + darwin* | rhapsody*) + case "$host_os" in + rhapsody* | darwin1.[012]) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress' + ;; + *) # Darwin 1.3 on + if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + else + case ${MACOSX_DEPLOYMENT_TARGET} in + 10.[012]) + allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' + ;; + 10.*) + allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup' + ;; + esac + fi + ;; + esac + archive_cmds_need_lc_GCJ=no + hardcode_direct_GCJ=no + hardcode_automatic_GCJ=yes + hardcode_shlibpath_var_GCJ=unsupported + whole_archive_flag_spec_GCJ='' + link_all_deplibs_GCJ=yes + if test "$GCC" = yes ; then + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + else + case "$cc_basename" in + xlc*) + output_verbose_link_cmd='echo' + archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring' + module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags' + # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin ld's + archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[ ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}' + ;; + *) + ld_shlibs_GCJ=no + ;; + esac + fi + ;; + + dgux*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + freebsd1*) + ld_shlibs_GCJ=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | kfreebsd*-gnu) + archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + hpux9*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + else + archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + ;; + + hpux10* | hpux11*) + if test "$GCC" = yes -a "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case "$host_cpu" in + hppa*64*|ia64*) + archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + ;; + *) + archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + ;; + esac + fi + if test "$with_gnu_ld" = no; then + case "$host_cpu" in + hppa*64*) + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_flag_spec_ld_GCJ='+b $libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + ;; + ia64*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=no + hardcode_shlibpath_var_GCJ=no + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + *) + hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_direct_GCJ=yes + export_dynamic_flag_spec_GCJ='${wl}-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + hardcode_minus_L_GCJ=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + link_all_deplibs_GCJ=yes + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + newsos6) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + hardcode_shlibpath_var_GCJ=no + ;; + + openbsd*) + hardcode_direct_GCJ=yes + hardcode_shlibpath_var_GCJ=no + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + export_dynamic_flag_spec_GCJ='${wl}-E' + else + case $host_os in + openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) + archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-R$libdir' + ;; + *) + archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir' + ;; + esac + fi + ;; + + os2*) + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_minus_L_GCJ=yes + allow_undefined_flag_GCJ=unsupported + archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' + old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' + ;; + + osf3*) + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + hardcode_libdir_separator_GCJ=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test "$GCC" = yes; then + allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*' + archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' + hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir' + else + allow_undefined_flag_GCJ=' -expect_unresolved \*' + archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' + archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ + $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' + + # Both c and cxx compiler support -rpath directly + hardcode_libdir_flag_spec_GCJ='-rpath $libdir' + fi + hardcode_libdir_separator_GCJ=: + ;; + + sco3.2v5*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='${wl}-Bexport' + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ;; + + solaris*) + no_undefined_flag_GCJ=' -z text' + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp' + else + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + fi + hardcode_libdir_flag_spec_GCJ='-R$libdir' + hardcode_shlibpath_var_GCJ=no + case $host_os in + solaris2.[0-5] | solaris2.[0-5].*) ;; + *) # Supported since Solaris 2.6 (maybe 2.5.1?) + whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;; + esac + link_all_deplibs_GCJ=yes + ;; + + sunos4*) + if test "x$host_vendor" = xsequent; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=yes + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4) + case $host_vendor in + sni) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + reload_cmds_GCJ='$CC -r -o $output$reload_objs' + hardcode_direct_GCJ=no + ;; + motorola) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv4.3*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + export_dynamic_flag_spec_GCJ='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var_GCJ=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs_GCJ=yes + fi + ;; + + sysv4.2uw2*) + archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct_GCJ=yes + hardcode_minus_L_GCJ=no + hardcode_shlibpath_var_GCJ=no + hardcode_runpath_var=yes + runpath_var=LD_RUN_PATH + ;; + + sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) + no_undefined_flag_GCJ='${wl}-z ${wl}text' + if test "$GCC" = yes; then + archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + else + archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var_GCJ=no + ;; + + sysv5*) + no_undefined_flag_GCJ=' -z text' + # $CC -shared without GNU ld will not create a library from C++ + # object files and a static libstdc++, better avoid it by now + archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' + archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ + $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' + hardcode_libdir_flag_spec_GCJ= + hardcode_shlibpath_var_GCJ=no + runpath_var='LD_RUN_PATH' + ;; + + uts4*) + archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec_GCJ='-L$libdir' + hardcode_shlibpath_var_GCJ=no + ;; + + *) + ld_shlibs_GCJ=no + ;; + esac + fi + +{ echo "$as_me:$LINENO: result: $ld_shlibs_GCJ" >&5 +echo "${ECHO_T}$ld_shlibs_GCJ" >&6; } +test "$ld_shlibs_GCJ" = no && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test "$GCC" = yes; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +# +# Do we need to explicitly link libc? +# +case "x$archive_cmds_need_lc_GCJ" in +x|xyes) + # Assume -lc should be added + archive_cmds_need_lc_GCJ=yes + + if test "$enable_shared" = yes && test "$GCC" = yes; then + case $archive_cmds_GCJ in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + { echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 +echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6; } + $rm conftest* + printf "$lt_simple_compile_test_code" > conftest.$ac_ext + + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$lt_prog_compiler_wl_GCJ + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ + allow_undefined_flag_GCJ= + if { (eval echo "$as_me:$LINENO: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 + (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + then + archive_cmds_need_lc_GCJ=no + else + archive_cmds_need_lc_GCJ=yes + fi + allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $rm conftest* + { echo "$as_me:$LINENO: result: $archive_cmds_need_lc_GCJ" >&5 +echo "${ECHO_T}$archive_cmds_need_lc_GCJ" >&6; } + ;; + esac + fi + ;; +esac + +{ echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 +echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6; } +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=".so" +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +case $host_os in +aix3*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='${libname}${release}${shared_ext}$major' + ;; + +aix4* | aix5*) + version_type=linux + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test "$host_cpu" = ia64; then + # AIX 5 supports IA64 + library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line `#! .'. This would cause the generated library to + # depend on `.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[01] | aix4.[01].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # AIX (on Power*) has no versioning support, so currently we can not hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + if test "$aix_use_runtimelinking" = yes; then + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + else + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='${libname}${release}.a $libname.a' + soname_spec='${libname}${release}${shared_ext}$major' + fi + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + +beos*) + library_names_spec='${libname}${shared_ext}' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[45]*) + version_type=linux + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32*) + version_type=windows + shrext_cmds=".dll" + need_version=no + need_lib_prefix=no + + case $GCC,$host_os in + yes,cygwin* | yes,mingw* | yes,pw32*) + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \${file}`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $rm \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib" + ;; + mingw*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' + sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"` + if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then + # It is most probably a Windows format PATH printed by + # mingw gcc, but we are running on Cygwin. Gcc prints its search + # path with ; separators, and with drive letters. We can handle the + # drive letters (cygwin fileutils understands them), so leave them, + # especially as we might pass files found there to a mingw objdump, + # which wouldn't understand a cygwinified path. Ahh. + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/./-/g'`${versuffix}${shared_ext}' + ;; + esac + ;; + + *) + library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' + ;; + esac + dynamic_linker='Win32 ld.exe' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext' + soname_spec='${libname}${release}${major}$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='$(test .$module = .yes && echo .so || echo .dylib)' + # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same. + if test "$GCC" = yes; then + sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"` + else + sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib' + fi + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd1*) + dynamic_linker=no + ;; + +kfreebsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +freebsd*) + objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.01* | freebsdelf3.01*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + esac + ;; + +gnu*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case "$host_cpu" in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + if test "X$HPUX_IA64_MODE" = X32; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + fi + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555. + postinstall_cmds='chmod 555 $lib' + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test "$lt_cv_prog_gnu_ld" = yes; then + version_type=linux + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" + sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +# This must be Linux ELF. +linux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Append ld.so.conf contents to the search path + if test -f /etc/ld.so.conf; then + lt_ld_extra=`$SED -e 's/:,\t/ /g;s/=^=*$//;s/=^= * / /g' /etc/ld.so.conf | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +knetbsd*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='GNU ld.so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +nto-qnx*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +openbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then + case $host_os in + openbsd2.[89] | openbsd2.[89].*) + shlibpath_overrides_runpath=no + ;; + *) + shlibpath_overrides_runpath=yes + ;; + esac + else + shlibpath_overrides_runpath=yes + fi + ;; + +os2*) + libname_spec='$name' + shrext_cmds=".dll" + need_lib_prefix=no + library_names_spec='$libname${shared_ext} $libname.a' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=LIBPATH + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" + ;; + +sco3.2v5*) + version_type=osf + soname_spec='${libname}${release}${shared_ext}$major' + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + shlibpath_var=LD_LIBRARY_PATH + ;; + +solaris*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + export_dynamic_flag_spec='${wl}-Blargedynsym' + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' + soname_spec='$libname${shared_ext}.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +{ echo "$as_me:$LINENO: result: $dynamic_linker" >&5 +echo "${ECHO_T}$dynamic_linker" >&6; } +test "$dynamic_linker" = no && can_build_shared=no + +{ echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 +echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6; } +hardcode_action_GCJ= +if test -n "$hardcode_libdir_flag_spec_GCJ" || \ + test -n "$runpath_var_GCJ" || \ + test "X$hardcode_automatic_GCJ" = "Xyes" ; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct_GCJ" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no && + test "$hardcode_minus_L_GCJ" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action_GCJ=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action_GCJ=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action_GCJ=unsupported +fi +{ echo "$as_me:$LINENO: result: $hardcode_action_GCJ" >&5 +echo "${ECHO_T}$hardcode_action_GCJ" >&6; } + +if test "$hardcode_action_GCJ" = relink; then + # Fast installation is not supported + enable_fast_install=no +elif test "$shlibpath_overrides_runpath" = yes || + test "$enable_shared" = no; then + # Fast installation is not necessary + enable_fast_install=needless +fi + +striplib= +old_striplib= +{ echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 +echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6; } +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP" ; then + striplib="$STRIP -x" + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + ;; + *) + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + ;; + esac +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32*) + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen="dlopen" + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + + lt_cv_dlopen="dyld" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + +fi + + ;; + + *) + { echo "$as_me:$LINENO: checking for shl_load" >&5 +echo $ECHO_N "checking for shl_load... $ECHO_C" >&6; } +if test "${ac_cv_func_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define shl_load to an innocuous variant, in case declares shl_load. + For example, HP-UX 11i declares gettimeofday. */ +#define shl_load innocuous_shl_load + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char shl_load (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef shl_load + +/* 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 shl_load (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_shl_load || defined __stub___shl_load +choke me +#endif + +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 +echo "${ECHO_T}$ac_cv_func_shl_load" >&6; } +if test $ac_cv_func_shl_load = yes; then + lt_cv_dlopen="shl_load" +else + { echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 +echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_shl_load+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 shl_load (); +int +main () +{ +return shl_load (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_shl_load=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_shl_load=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6; } +if test $ac_cv_lib_dld_shl_load = yes; then + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" +else + { echo "$as_me:$LINENO: checking for dlopen" >&5 +echo $ECHO_N "checking for dlopen... $ECHO_C" >&6; } +if test "${ac_cv_func_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define dlopen to an innocuous variant, in case declares dlopen. + For example, HP-UX 11i declares gettimeofday. */ +#define dlopen innocuous_dlopen + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char dlopen (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef dlopen + +/* 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 dlopen (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_dlopen || defined __stub___dlopen +choke me +#endif + +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 +echo "${ECHO_T}$ac_cv_func_dlopen" >&6; } +if test $ac_cv_func_dlopen = yes; then + lt_cv_dlopen="dlopen" +else + { echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 +echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6; } +if test "${ac_cv_lib_dl_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dl_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dl_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6; } +if test $ac_cv_lib_dl_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + { echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 +echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6; } +if test "${ac_cv_lib_svld_dlopen+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lsvld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dlopen (); +int +main () +{ +return dlopen (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_svld_dlopen=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_svld_dlopen=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 +echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6; } +if test $ac_cv_lib_svld_dlopen = yes; then + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" +else + { echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 +echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6; } +if test "${ac_cv_lib_dld_dld_link+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ldld $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* 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 dld_link (); +int +main () +{ +return dld_link (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_dld_dld_link=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_dld_dld_link=no +fi + +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 +echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6; } +if test $ac_cv_lib_dld_dld_link = yes; then + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" +fi + + +fi + + +fi + + +fi + + +fi + + +fi + + ;; + esac + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + else + enable_dlopen=no + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS="$CPPFLAGS" + test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS="$LDFLAGS" + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS="$LIBS" + LIBS="$lt_cv_dlopen_libs $LIBS" + + { echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 +echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self" >&6; } + + if test "x$lt_cv_dlopen_self" = xyes; then + LDFLAGS="$LDFLAGS $link_static_flag" + { echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 +echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6; } +if test "${lt_cv_dlopen_self_static+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then : + lt_cv_dlopen_self_static=cross +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +#ifdef __cplusplus +extern "C" void exit (int); +#endif + +void fnord() { int i=42;} +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + /* dlclose (self); */ + } + + exit (status); +} +EOF + if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then + (./conftest; exit; ) 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; + x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; + esac + else : + # compilation failed + lt_cv_dlopen_self_static=no + fi +fi +rm -fr conftest* + + +fi +{ echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 +echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6; } + fi + + CPPFLAGS="$save_CPPFLAGS" + LDFLAGS="$save_LDFLAGS" + LIBS="$save_LIBS" + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi + + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_GCJ \ + CC_GCJ \ + LD_GCJ \ + lt_prog_compiler_wl_GCJ \ + lt_prog_compiler_pic_GCJ \ + lt_prog_compiler_static_GCJ \ + lt_prog_compiler_no_builtin_flag_GCJ \ + export_dynamic_flag_spec_GCJ \ + thread_safe_flag_spec_GCJ \ + whole_archive_flag_spec_GCJ \ + enable_shared_with_static_runtimes_GCJ \ + old_archive_cmds_GCJ \ + old_archive_from_new_cmds_GCJ \ + predep_objects_GCJ \ + postdep_objects_GCJ \ + predeps_GCJ \ + postdeps_GCJ \ + compiler_lib_search_path_GCJ \ + archive_cmds_GCJ \ + archive_expsym_cmds_GCJ \ + postinstall_cmds_GCJ \ + postuninstall_cmds_GCJ \ + old_archive_from_expsyms_cmds_GCJ \ + allow_undefined_flag_GCJ \ + no_undefined_flag_GCJ \ + export_symbols_cmds_GCJ \ + hardcode_libdir_flag_spec_GCJ \ + hardcode_libdir_flag_spec_ld_GCJ \ + hardcode_libdir_separator_GCJ \ + hardcode_automatic_GCJ \ + module_cmds_GCJ \ + module_expsym_cmds_GCJ \ + lt_cv_prog_compiler_c_o_GCJ \ + exclude_expsyms_GCJ \ + include_expsyms_GCJ; do + + case $var in + old_archive_cmds_GCJ | \ + old_archive_from_new_cmds_GCJ | \ + archive_cmds_GCJ | \ + archive_expsym_cmds_GCJ | \ + module_cmds_GCJ | \ + module_expsym_cmds_GCJ | \ + old_archive_from_expsyms_cmds_GCJ | \ + export_symbols_cmds_GCJ | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_GCJ + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_GCJ + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_GCJ + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_GCJ + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_GCJ + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_GCJ +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_GCJ + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_GCJ +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_GCJ +archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_GCJ +module_expsym_cmds=$lt_module_expsym_cmds_GCJ + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_GCJ + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_GCJ + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_GCJ + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_GCJ + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_GCJ + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_GCJ + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_GCJ + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_GCJ + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_GCJ + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_GCJ + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_GCJ" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_GCJ + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_GCJ + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_GCJ + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_GCJ + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +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 + +CC="$lt_save_CC" + + else + tagname="" + fi + ;; + + RC) + + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +objext_RC=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n' + +# Code to be used in simple link tests +lt_simple_link_test_code="$lt_simple_compile_test_code" + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# Allow CC to be a program name with arguments. +compiler=$CC + + +# Allow CC to be a program name with arguments. +lt_save_CC="$CC" +CC=${RC-"windres"} +compiler=$CC +compiler_RC=$CC +lt_cv_prog_compiler_c_o_RC=yes + +# The else clause should only fire when bootstrapping the +# libtool distribution, otherwise you forgot to ship ltmain.sh +# with your package, and you will get complaints that there are +# no rules to generate ltmain.sh. +if test -f "$ltmain"; then + # See if we are running on zsh, and set the options which allow our commands through + # without removal of \ escapes. + if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST + fi + # Now quote all the things that may contain metacharacters while being + # careful not to overquote the AC_SUBSTed values. We take copies of the + # variables and quote the copies for generation of the libtool script. + for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \ + SED SHELL STRIP \ + libname_spec library_names_spec soname_spec extract_expsyms_cmds \ + old_striplib striplib file_magic_cmd finish_cmds finish_eval \ + deplibs_check_method reload_flag reload_cmds need_locks \ + lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \ + lt_cv_sys_global_symbol_to_c_name_address \ + sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ + old_postinstall_cmds old_postuninstall_cmds \ + compiler_RC \ + CC_RC \ + LD_RC \ + lt_prog_compiler_wl_RC \ + lt_prog_compiler_pic_RC \ + lt_prog_compiler_static_RC \ + lt_prog_compiler_no_builtin_flag_RC \ + export_dynamic_flag_spec_RC \ + thread_safe_flag_spec_RC \ + whole_archive_flag_spec_RC \ + enable_shared_with_static_runtimes_RC \ + old_archive_cmds_RC \ + old_archive_from_new_cmds_RC \ + predep_objects_RC \ + postdep_objects_RC \ + predeps_RC \ + postdeps_RC \ + compiler_lib_search_path_RC \ + archive_cmds_RC \ + archive_expsym_cmds_RC \ + postinstall_cmds_RC \ + postuninstall_cmds_RC \ + old_archive_from_expsyms_cmds_RC \ + allow_undefined_flag_RC \ + no_undefined_flag_RC \ + export_symbols_cmds_RC \ + hardcode_libdir_flag_spec_RC \ + hardcode_libdir_flag_spec_ld_RC \ + hardcode_libdir_separator_RC \ + hardcode_automatic_RC \ + module_cmds_RC \ + module_expsym_cmds_RC \ + lt_cv_prog_compiler_c_o_RC \ + exclude_expsyms_RC \ + include_expsyms_RC; do + + case $var in + old_archive_cmds_RC | \ + old_archive_from_new_cmds_RC | \ + archive_cmds_RC | \ + archive_expsym_cmds_RC | \ + module_cmds_RC | \ + module_expsym_cmds_RC | \ + old_archive_from_expsyms_cmds_RC | \ + export_symbols_cmds_RC | \ + extract_expsyms_cmds | reload_cmds | finish_cmds | \ + postinstall_cmds | postuninstall_cmds | \ + old_postinstall_cmds | old_postuninstall_cmds | \ + sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) + # Double-quote double-evaled strings. + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case $lt_echo in + *'\$0 --fallback-echo"') + lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + +cfgfile="$ofile" + + cat <<__EOF__ >> "$cfgfile" +# ### BEGIN LIBTOOL TAG CONFIG: $tagname + +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: + +# Shell to use when invoking shell scripts. +SHELL=$lt_SHELL + +# Whether or not to build shared libraries. +build_libtool_libs=$enable_shared + +# Whether or not to build static libraries. +build_old_libs=$enable_static + +# Whether or not to add -lc for building shared libraries. +build_libtool_need_lc=$archive_cmds_need_lc_RC + +# Whether or not to disallow shared libs when runtime libs are static +allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC + +# Whether or not to optimize for fast installation. +fast_install=$enable_fast_install + +# The host system. +host_alias=$host_alias +host=$host + +# An echo program that does not interpret backslashes. +echo=$lt_echo + +# The archiver. +AR=$lt_AR +AR_FLAGS=$lt_AR_FLAGS + +# A C compiler. +LTCC=$lt_LTCC + +# A language-specific compiler. +CC=$lt_compiler_RC + +# Is the compiler the GNU C compiler? +with_gcc=$GCC_RC + +# An ERE matcher. +EGREP=$lt_EGREP + +# The linker used to build libraries. +LD=$lt_LD_RC + +# Whether we need hard or soft links. +LN_S=$lt_LN_S + +# A BSD-compatible nm program. +NM=$lt_NM + +# A symbol stripping program +STRIP=$lt_STRIP + +# Used to examine libraries when file_magic_cmd begins "file" +MAGIC_CMD=$MAGIC_CMD + +# Used on cygwin: DLL creation program. +DLLTOOL="$DLLTOOL" + +# Used on cygwin: object dumper. +OBJDUMP="$OBJDUMP" + +# Used on cygwin: assembler. +AS="$AS" + +# The name of the directory that contains temporary libtool files. +objdir=$objdir + +# How to create reloadable object files. +reload_flag=$lt_reload_flag +reload_cmds=$lt_reload_cmds + +# How to pass a linker flag through the compiler. +wl=$lt_lt_prog_compiler_wl_RC + +# Object file suffix (normally "o"). +objext="$ac_objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Shared library suffix (normally ".so"). +shrext_cmds='$shrext_cmds' + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$lt_lt_prog_compiler_pic_RC +pic_mode=$pic_mode + +# What is the maximum length of a command? +max_cmd_len=$lt_cv_sys_max_cmd_len + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC + +# Must we lock files when doing compilation ? +need_locks=$lt_need_locks + +# Do we need the lib prefix for modules? +need_lib_prefix=$need_lib_prefix + +# Do we need a version for libraries? +need_version=$need_version + +# Whether dlopen is supported. +dlopen_support=$enable_dlopen + +# Whether dlopen of programs is supported. +dlopen_self=$enable_dlopen_self + +# Whether dlopen of statically linked programs is supported. +dlopen_self_static=$enable_dlopen_self_static + +# Compiler flag to prevent dynamic linking. +link_static_flag=$lt_lt_prog_compiler_static_RC + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$lt_libname_spec + +# List of archive names. First name is the real one, the rest are links. +# The last name is the one that the linker finds with -lNAME. +library_names_spec=$lt_library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$lt_soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$lt_RANLIB +old_archive_cmds=$lt_old_archive_cmds_RC +old_postinstall_cmds=$lt_old_postinstall_cmds +old_postuninstall_cmds=$lt_old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC + +# Commands used to build and install a shared archive. +archive_cmds=$lt_archive_cmds_RC +archive_expsym_cmds=$lt_archive_expsym_cmds_RC +postinstall_cmds=$lt_postinstall_cmds +postuninstall_cmds=$lt_postuninstall_cmds + +# Commands used to build a loadable module (assumed same as above if empty) +module_cmds=$lt_module_cmds_RC +module_expsym_cmds=$lt_module_expsym_cmds_RC + +# Commands to strip libraries. +old_striplib=$lt_old_striplib +striplib=$lt_striplib + +# Dependencies to place before the objects being linked to create a +# shared library. +predep_objects=$lt_predep_objects_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdep_objects=$lt_postdep_objects_RC + +# Dependencies to place before the objects being linked to create a +# shared library. +predeps=$lt_predeps_RC + +# Dependencies to place after the objects being linked to create a +# shared library. +postdeps=$lt_postdeps_RC + +# The library search path used internally by the compiler when linking +# a shared library. +compiler_lib_search_path=$lt_compiler_lib_search_path_RC + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$lt_deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$lt_file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$lt_allow_undefined_flag_RC + +# Flag that forces no undefined symbols. +no_undefined_flag=$lt_no_undefined_flag_RC + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$lt_finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$lt_finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl + +# Transform the output of nm in a C name address pair +global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address + +# This is the shared library runtime path variable. +runpath_var=$runpath_var + +# This is the shared library path variable. +shlibpath_var=$shlibpath_var + +# Is shlibpath searched before the hard-coded library search path? +shlibpath_overrides_runpath=$shlibpath_overrides_runpath + +# How to hardcode a shared library path into an executable. +hardcode_action=$hardcode_action_RC + +# Whether we should hardcode library paths into libraries. +hardcode_into_libs=$hardcode_into_libs + +# Flag to hardcode \$libdir into a binary during linking. +# This must work even if \$libdir does not exist. +hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC + +# If ld is used when linking, flag to hardcode \$libdir into +# a binary during linking. This must work even if \$libdir does +# not exist. +hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC + +# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the +# resulting binary. +hardcode_direct=$hardcode_direct_RC + +# Set to yes if using the -LDIR flag during linking hardcodes DIR into the +# resulting binary. +hardcode_minus_L=$hardcode_minus_L_RC + +# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into +# the resulting binary. +hardcode_shlibpath_var=$hardcode_shlibpath_var_RC + +# Set to yes if building a shared library automatically hardcodes DIR into the library +# and all subsequent libraries and executables linked against it. +hardcode_automatic=$hardcode_automatic_RC + +# Variables whose values should be saved in libtool wrapper scripts and +# restored at relink time. +variables_saved_for_relink="$variables_saved_for_relink" + +# Whether libtool must link a program against all its dependency libraries. +link_all_deplibs=$link_all_deplibs_RC + +# Compile-time system search path for libraries +sys_lib_search_path_spec=$lt_sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec + +# Fix the shell variable \$srcfile for the compiler. +fix_srcfile_path="$fix_srcfile_path_RC" + +# Set to yes if exported symbols are required. +always_export_symbols=$always_export_symbols_RC + +# The commands to list exported symbols. +export_symbols_cmds=$lt_export_symbols_cmds_RC + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$lt_extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$lt_exclude_expsyms_RC + +# Symbols that must always be exported. +include_expsyms=$lt_include_expsyms_RC + +# ### END LIBTOOL TAG CONFIG: $tagname + +__EOF__ + + +else + # If there is no Makefile yet, we rely on a make rule to execute + # `config.status --recheck' to rerun these tests and create the + # libtool script then. + ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'` + if test -f "$ltmain_in"; then + test -f Makefile && make "$ltmain" + fi +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 + +CC="$lt_save_CC" + + ;; + + *) + { { echo "$as_me:$LINENO: error: Unsupported tag name: $tagname" >&5 +echo "$as_me: error: Unsupported tag name: $tagname" >&2;} + { (exit 1); exit 1; }; } + ;; + esac + + # Append the new tag name to the list of available tags. + if test -n "$tagname" ; then + available_tags="$available_tags $tagname" + fi + fi + done + IFS="$lt_save_ifs" + + # Now substitute the updated list of available tags. + if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then + mv "${ofile}T" "$ofile" + chmod +x "$ofile" + else + rm -f "${ofile}T" + { { echo "$as_me:$LINENO: error: unable to update list of available tagged configurations." >&5 +echo "$as_me: error: unable to update list of available tagged configurations." >&2;} + { (exit 1); exit 1; }; } + fi +fi + + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Prevent multiple expansion + + + + + + + + + + + + + + + + + + + + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#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 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + + +for ac_header in byteswap.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + ac_cpp_err=$ac_cpp_err$ac_c_werror_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset x; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *ccp; + char **p; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + ccp = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++ccp; + p = (char**) ccp; + ccp = (char const *const *) p; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !x[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6; } +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_inline=$ac_kw +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6; } + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +{ echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef size_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_size_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6; } +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_time=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_bigendian=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + + +# Defines OSIP_CFLAGS, OSIP_INCLUDEDIR, and OSIP_LIBS + + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +PKG_CONFIG=$ac_cv_path_PKG_CONFIG +if test -n "$PKG_CONFIG"; then + { echo "$as_me:$LINENO: result: $PKG_CONFIG" >&5 +echo "${ECHO_T}$PKG_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_path_PKG_CONFIG"; then + ac_pt_PKG_CONFIG=$PKG_CONFIG + # Extract the first word of "pkg-config", so it can be a program name with args. +set dummy pkg-config; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $ac_pt_PKG_CONFIG in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. + ;; + *) + 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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + + ;; +esac +fi +ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG +if test -n "$ac_pt_PKG_CONFIG"; then + { echo "$as_me:$LINENO: result: $ac_pt_PKG_CONFIG" >&5 +echo "${ECHO_T}$ac_pt_PKG_CONFIG" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_pt_PKG_CONFIG" = x; then + PKG_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + PKG_CONFIG=$ac_pt_PKG_CONFIG + fi +else + PKG_CONFIG="$ac_cv_path_PKG_CONFIG" +fi + +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=0.9.0 + { echo "$as_me:$LINENO: checking pkg-config is at least version $_pkg_min_version" >&5 +echo $ECHO_N "checking pkg-config is at least version $_pkg_min_version... $ECHO_C" >&6; } + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + PKG_CONFIG="" + fi + +fi + +pkg_failed=no +{ echo "$as_me:$LINENO: checking for OSIP" >&5 +echo $ECHO_N "checking for OSIP... $ECHO_C" >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$OSIP_CFLAGS"; then + pkg_cv_OSIP_CFLAGS="$OSIP_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libosip2\"") >&5 + ($PKG_CONFIG --exists --print-errors "libosip2") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_OSIP_CFLAGS=`$PKG_CONFIG --cflags "libosip2" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$OSIP_LIBS"; then + pkg_cv_OSIP_LIBS="$OSIP_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libosip2\"") >&5 + ($PKG_CONFIG --exists --print-errors "libosip2") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_OSIP_LIBS=`$PKG_CONFIG --libs "libosip2" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + OSIP_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libosip2"` + else + OSIP_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libosip2"` + fi + # Put the nasty error message in config.log where it belongs + echo "$OSIP_PKG_ERRORS" >&5 + + { { echo "$as_me:$LINENO: error: Package requirements (libosip2) were not met: + +$OSIP_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables OSIP_CFLAGS +and OSIP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&5 +echo "$as_me: error: Package requirements (libosip2) were not met: + +$OSIP_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables OSIP_CFLAGS +and OSIP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&2;} + { (exit 1); exit 1; }; } +elif test $pkg_failed = untried; then + { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables OSIP_CFLAGS +and OSIP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&5 +echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables OSIP_CFLAGS +and OSIP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + OSIP_CFLAGS=$pkg_cv_OSIP_CFLAGS + OSIP_LIBS=$pkg_cv_OSIP_LIBS + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + : +fi + +# Defines ORTP_CFLAGS, ORTP_INCLUDEDIR, and ORTP_LIBS + +pkg_failed=no +{ echo "$as_me:$LINENO: checking for ORTP" >&5 +echo $ECHO_N "checking for ORTP... $ECHO_C" >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$ORTP_CFLAGS"; then + pkg_cv_ORTP_CFLAGS="$ORTP_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"ortp\"") >&5 + ($PKG_CONFIG --exists --print-errors "ortp") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_ORTP_CFLAGS=`$PKG_CONFIG --cflags "ortp" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$ORTP_LIBS"; then + pkg_cv_ORTP_LIBS="$ORTP_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"ortp\"") >&5 + ($PKG_CONFIG --exists --print-errors "ortp") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_ORTP_LIBS=`$PKG_CONFIG --libs "ortp" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + ORTP_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "ortp"` + else + ORTP_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "ortp"` + fi + # Put the nasty error message in config.log where it belongs + echo "$ORTP_PKG_ERRORS" >&5 + + { { echo "$as_me:$LINENO: error: Package requirements (ortp) were not met: + +$ORTP_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables ORTP_CFLAGS +and ORTP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&5 +echo "$as_me: error: Package requirements (ortp) were not met: + +$ORTP_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables ORTP_CFLAGS +and ORTP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&2;} + { (exit 1); exit 1; }; } +elif test $pkg_failed = untried; then + { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables ORTP_CFLAGS +and ORTP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&5 +echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables ORTP_CFLAGS +and ORTP_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + ORTP_CFLAGS=$pkg_cv_ORTP_CFLAGS + ORTP_LIBS=$pkg_cv_ORTP_LIBS + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + : +fi + +# Defines LIBUSB_TRANSFER_CANCELLED, LIBUSB_TRANSFER_COMPLETED, LIBUSB_SUCCESS, LIBUSB_ERROR_* + +pkg_failed=no +{ echo "$as_me:$LINENO: checking for LIBUSB" >&5 +echo $ECHO_N "checking for LIBUSB... $ECHO_C" >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$LIBUSB_CFLAGS"; then + pkg_cv_LIBUSB_CFLAGS="$LIBUSB_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\"") >&5 + ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_LIBUSB_CFLAGS=`$PKG_CONFIG --cflags "libusb-1.0" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$LIBUSB_LIBS"; then + pkg_cv_LIBUSB_LIBS="$LIBUSB_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { (echo "$as_me:$LINENO: \$PKG_CONFIG --exists --print-errors \"libusb-1.0\"") >&5 + ($PKG_CONFIG --exists --print-errors "libusb-1.0") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + pkg_cv_LIBUSB_LIBS=`$PKG_CONFIG --libs "libusb-1.0" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + LIBUSB_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "libusb-1.0"` + else + LIBUSB_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "libusb-1.0"` + fi + # Put the nasty error message in config.log where it belongs + echo "$LIBUSB_PKG_ERRORS" >&5 + + { { echo "$as_me:$LINENO: error: Package requirements (libusb-1.0) were not met: + +$LIBUSB_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables LIBUSB_CFLAGS +and LIBUSB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&5 +echo "$as_me: error: Package requirements (libusb-1.0) were not met: + +$LIBUSB_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables LIBUSB_CFLAGS +and LIBUSB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" >&2;} + { (exit 1); exit 1; }; } +elif test $pkg_failed = untried; then + { { echo "$as_me:$LINENO: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables LIBUSB_CFLAGS +and LIBUSB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&5 +echo "$as_me: error: The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables LIBUSB_CFLAGS +and LIBUSB_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +else + LIBUSB_CFLAGS=$pkg_cv_LIBUSB_CFLAGS + LIBUSB_LIBS=$pkg_cv_LIBUSB_LIBS + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + : +fi + +# Prepends -lreadline to LIBS and defines HAVE_LIBREADLINE in config.h +#AC_CHECK_LIB(readline, readline) + + +ac_config_files="$ac_config_files Makefile apps/Makefile config/Makefile doc/Makefile tools/Makefile AsteriskConfig/Makefile CommonLibs/Makefile Globals/Makefile Control/Makefile GSM/Makefile SIP/Makefile SMS/Makefile TransceiverRAD1/Makefile Transceiver52M/Makefile TRXManager/Makefile CLI/Makefile SR/Makefile sqlite3/Makefile" + + +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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_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 + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +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= +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=`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. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $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} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs 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 +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + + +# PATH needs CR +# 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 + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # 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 +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +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=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +# Find out whether ``test -x'' works. Don't use a zero-byte file, as +# systems may use methods other than mode bits to determine executability. +cat >conf$$.file <<_ASEOF +#! /bin/sh +exit 0 +_ASEOF +chmod +x conf$$.file +if test -x conf$$.file >/dev/null 2>&1; then + as_executable_p="test -x" +else + as_executable_p=: +fi +rm -f conf$$.file + +# 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 + +# 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 openbts $as_me P2.8TRUNK, which was +generated by GNU Autoconf 2.60. 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 + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet 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 + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +openbts config.status P2.8TRUNK +configured by $0, generated by GNU Autoconf 2.60, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 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' +INSTALL='$INSTALL' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +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=$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 ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + 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. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$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 +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# 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" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "apps/Makefile") CONFIG_FILES="$CONFIG_FILES apps/Makefile" ;; + "config/Makefile") CONFIG_FILES="$CONFIG_FILES config/Makefile" ;; + "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; + "AsteriskConfig/Makefile") CONFIG_FILES="$CONFIG_FILES AsteriskConfig/Makefile" ;; + "CommonLibs/Makefile") CONFIG_FILES="$CONFIG_FILES CommonLibs/Makefile" ;; + "Globals/Makefile") CONFIG_FILES="$CONFIG_FILES Globals/Makefile" ;; + "Control/Makefile") CONFIG_FILES="$CONFIG_FILES Control/Makefile" ;; + "GSM/Makefile") CONFIG_FILES="$CONFIG_FILES GSM/Makefile" ;; + "SIP/Makefile") CONFIG_FILES="$CONFIG_FILES SIP/Makefile" ;; + "SMS/Makefile") CONFIG_FILES="$CONFIG_FILES SMS/Makefile" ;; + "TransceiverRAD1/Makefile") CONFIG_FILES="$CONFIG_FILES TransceiverRAD1/Makefile" ;; + "Transceiver52M/Makefile") CONFIG_FILES="$CONFIG_FILES Transceiver52M/Makefile" ;; + "TRXManager/Makefile") CONFIG_FILES="$CONFIG_FILES TRXManager/Makefile" ;; + "CLI/Makefile") CONFIG_FILES="$CONFIG_FILES CLI/Makefile" ;; + "SR/Makefile") CONFIG_FILES="$CONFIG_FILES SR/Makefile" ;; + "sqlite3/Makefile") CONFIG_FILES="$CONFIG_FILES sqlite3/Makefile" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + 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 + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +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= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +build!$build$ac_delim +build_cpu!$build_cpu$ac_delim +build_vendor!$build_vendor$ac_delim +build_os!$build_os$ac_delim +host!$host$ac_delim +host_cpu!$host_cpu$ac_delim +host_vendor!$host_vendor$ac_delim +host_os!$host_os$ac_delim +target!$target$ac_delim +target_cpu!$target_cpu$ac_delim +target_vendor!$target_vendor$ac_delim +target_os!$target_os$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +CYGPATH_W!$CYGPATH_W$ac_delim +PACKAGE!$PACKAGE$ac_delim +VERSION!$VERSION$ac_delim +ACLOCAL!$ACLOCAL$ac_delim +AUTOCONF!$AUTOCONF$ac_delim +AUTOMAKE!$AUTOMAKE$ac_delim +AUTOHEADER!$AUTOHEADER$ac_delim +MAKEINFO!$MAKEINFO$ac_delim +install_sh!$install_sh$ac_delim +STRIP!$STRIP$ac_delim +INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim +mkdir_p!$mkdir_p$ac_delim +AWK!$AWK$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +am__leading_dot!$am__leading_dot$ac_delim +AMTAR!$AMTAR$ac_delim +am__tar!$am__tar$ac_delim +am__untar!$am__untar$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +DEPDIR!$DEPDIR$ac_delim +am__include!$am__include$ac_delim +am__quote!$am__quote$ac_delim +AMDEP_TRUE!$AMDEP_TRUE$ac_delim +AMDEP_FALSE!$AMDEP_FALSE$ac_delim +AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CCDEPMODE!$CCDEPMODE$ac_delim +am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim +am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CCAS!$CCAS$ac_delim +CCASFLAGS!$CCASFLAGS$ac_delim +CXX!$CXX$ac_delim +CXXFLAGS!$CXXFLAGS$ac_delim +ac_ct_CXX!$ac_ct_CXX$ac_delim +CXXDEPMODE!$CXXDEPMODE$ac_delim +am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim +am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim +LN_S!$LN_S$ac_delim +RM_PROG!$RM_PROG$ac_delim +GREP!$GREP$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +CEOF$ac_eof +_ACEOF + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +EGREP!$EGREP$ac_delim +ECHO!$ECHO$ac_delim +AR!$AR$ac_delim +RANLIB!$RANLIB$ac_delim +DLLTOOL!$DLLTOOL$ac_delim +AS!$AS$ac_delim +OBJDUMP!$OBJDUMP$ac_delim +CPP!$CPP$ac_delim +CXXCPP!$CXXCPP$ac_delim +F77!$F77$ac_delim +FFLAGS!$FFLAGS$ac_delim +ac_ct_F77!$ac_ct_F77$ac_delim +LIBTOOL!$LIBTOOL$ac_delim +PKG_CONFIG!$PKG_CONFIG$ac_delim +OSIP_CFLAGS!$OSIP_CFLAGS$ac_delim +OSIP_LIBS!$OSIP_LIBS$ac_delim +ORTP_CFLAGS!$ORTP_CFLAGS$ac_delim +ORTP_LIBS!$ORTP_LIBS$ac_delim +LIBUSB_CFLAGS!$LIBUSB_CFLAGS$ac_delim +LIBUSB_LIBS!$LIBUSB_LIBS$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 22; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ 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[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[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="$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 || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$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 "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + 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 || +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" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`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 || +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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# 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= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + 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 + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;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 +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +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 "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then 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. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" +# Compute $ac_file's index in $config_headers. +_am_stamp_count=1 +for _am_header in $config_headers :; do + case $_am_header in + $ac_file | $ac_file:* ) + break ;; + * ) + _am_stamp_count=`expr $_am_stamp_count + 1` ;; + esac +done +echo "timestamp for $ac_file" >`$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 || +echo X$ac_file | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do + # Strip MF so we end up with the name of the file. + mf=`echo "$mf" | sed -e 's/:.*$//'` + # Check whether this is an Automake generated Makefile or not. + # We used to match only the files named `Makefile.in', but + # some people rename them; so instead we look at the file content. + # Grep'ing the first line is not enough: some people post-process + # each Makefile.in and add a new line on top of each file to say so. + # So let's grep whole file. + if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then + dirpart=`$as_dirname -- "$mf" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + else + continue + fi + # Extract the definition of DEPDIR, am__include, and am__quote + # from the Makefile without running `make'. + DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` + test -z "$DEPDIR" && continue + am__include=`sed -n 's/^am__include = //p' < "$mf"` + test -z "am__include" && continue + am__quote=`sed -n 's/^am__quote = //p' < "$mf"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //p' < "$mf"` + # Find all dependency output files, they are included files with + # $(DEPDIR) in their names. We invoke sed twice because it is the + # simplest approach to changing $(DEPDIR) to its actual value in the + # expansion. + for file in `sed -n " + s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`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 || +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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# 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 || { (exit 1); exit 1; } +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..26874dd --- /dev/null +++ b/configure.ac @@ -0,0 +1,92 @@ +dnl +dnl Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +dnl +dnl This software is distributed under the terms of the GNU Public License. +dnl See the COPYING file in the main directory for details. +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program. If not, see . +dnl + +AC_INIT(openbts,P2.8TRUNK) +AC_PREREQ(2.57) +AC_CONFIG_SRCDIR([config/Makefile.am]) +AC_CONFIG_AUX_DIR([.]) +AM_CONFIG_HEADER(config.h) + +AC_CANONICAL_BUILD +AC_CANONICAL_HOST +AC_CANONICAL_TARGET + +AM_INIT_AUTOMAKE + +AM_PROG_AS +AC_PROG_CXX +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_INSTALL +AC_PATH_PROG([RM_PROG], [rm]) + +AC_LIBTOOL_WIN32_DLL +AC_ENABLE_SHARED dnl do build shared libraries +AC_DISABLE_STATIC dnl don't build static libraries +AC_PROG_LIBTOOL + +dnl Checks for header files. +AC_HEADER_STDC +dnl This is required for GnuRadio includes to understand endianess correctly: +AC_CHECK_HEADERS([byteswap.h]) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T +AC_HEADER_TIME +AC_C_BIGENDIAN + +# Defines OSIP_CFLAGS, OSIP_INCLUDEDIR, and OSIP_LIBS +PKG_CHECK_MODULES(OSIP, libosip2) + +# Defines ORTP_CFLAGS, ORTP_INCLUDEDIR, and ORTP_LIBS +PKG_CHECK_MODULES(ORTP, ortp) + +# Defines LIBUSB_TRANSFER_CANCELLED, LIBUSB_TRANSFER_COMPLETED, LIBUSB_SUCCESS, LIBUSB_ERROR_* +PKG_CHECK_MODULES(LIBUSB, libusb-1.0) + +# Prepends -lreadline to LIBS and defines HAVE_LIBREADLINE in config.h +#AC_CHECK_LIB(readline, readline) + + +dnl Output files +AC_CONFIG_FILES([\ + Makefile \ + apps/Makefile \ + config/Makefile \ + doc/Makefile \ + tools/Makefile \ + AsteriskConfig/Makefile \ + CommonLibs/Makefile \ + Globals/Makefile \ + Control/Makefile \ + GSM/Makefile \ + SIP/Makefile \ + SMS/Makefile \ + TransceiverRAD1/Makefile \ + Transceiver52M/Makefile \ + TRXManager/Makefile \ + CLI/Makefile \ + SR/Makefile \ + sqlite3/Makefile \ +]) + +AC_OUTPUT diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..11e2d3b --- /dev/null +++ b/depcomp @@ -0,0 +1,522 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2004-05-31.23 + +# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc. + +# 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, 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit 0 + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit 0 + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # Dependencies are output in .lo.d with libtool 1.4. + # With libtool 1.5 they are output both in $dir.libs/$base.o.d + # and in $dir.libs/$base.o.d and $dir$base.o.d. We process the + # latter, because the former will be cleaned when $dir.libs is + # erased. + tmpdepfile1="$dir.libs/$base.lo.d" + tmpdepfile2="$dir$base.o.d" + tmpdepfile3="$dir.libs/$base.d" + "$@" -Wc,-MD + else + tmpdepfile1="$dir$base.o.d" + tmpdepfile2="$dir$base.d" + tmpdepfile3="$dir$base.d" + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + elif test -f "$tmpdepfile2"; then + tmpdepfile="$tmpdepfile2" + else + tmpdepfile="$tmpdepfile3" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/doc/CodingStandard b/doc/CodingStandard new file mode 100644 index 0000000..dc8d3b7 --- /dev/null +++ b/doc/CodingStandard @@ -0,0 +1,281 @@ += Coding Standard for C++ in OpenBTS = +Do not violate one of these rules unless you are sure that you understand the rationale behind the rule and are sure that you have a legitimate exception to that rationale. + +The "owner" of OpenBTS and its related applcations is the CTO of Range Networks, Inc. All public and private releases must ultimately be approved by this CTO. + +''This document uses trac-style wiki formatting.'' + + +== Libraries, Licenses and Portability == +'''All new library dependencies must be approvaed by the Range Networks CTO before being added to the system.''' + +=== POSIX === +Ideally, OpenBTS and its related applications should compile and run on any POSIX system. At a minimum, we expect these applications to be portable to any current-release Linux or BSD system. Any portability failure for current-release Linux or BSD distribution is considered to be a bug. + +=== Licenses === +OpenBTS and its related applications are distributed publicly under AGPLv3 and privately under other licenses. Do not use any GPL library for which a non-GPL license cannot be acquired. Any LGPL libraries must be linked dynamically or licensed under other terms. If you add a new library to the system, please update the LEGAL file with with appropriate licensing information. + +=== Libraries and Portbility === +Just because you ''can'' use a library for a task does not mean you ''should''. The difficulty of porting an application to a new platform is a direct function of the number of library dependencies it has, so if you can write handful of simple functions to take the place of a new external library, please do so. OpenBTS, in the long run, is intended to be a highly portable embedded application. We cannot tollerate a "kitchen sink" dependency list, requiring developers to download the entire internet before starting a build. + + + + +== Symbol Names == + +=== Name Formats === +Symbol names should be formatted so that a reader can determine the scope of a symbol from the format of the name. C++ symbol names are to use camel case (camelCase). Do not use underscores except in #define marcos. + +Capitalization rules: + * Local scope variables and member methods start with a lower case letter. + * Class names and type names start with an upper case letter. + * #define marcos are all-caps and underscores are allowed. + +Prefixes: + * Class instance variables are prefixed with "m". + * Static valiables are prefixed with "s". + * Global variables are prefixed with "g". + * Arguments to constructors and assignment accessors, when given the same name as the assigned instance variable, are prefixed with "w". + + +Example: +{{{ +bool gSomeGlobalFlag; + +#define DEFAULT_TAG 5 + +class ThisClass { + + private: + + int mValue; + int mTag; + static const int msDefaultTag = DEFAULT_TAG; + static int msClassCounter = 0; + + public: + + ThisClass(int wTag = gsDefaultTag) + :mTag(wTag) + { } + + int value() const { return mValue; } + void value(wValue) { mValue = wValue; } + + int tag() const { return mTag; } +}; +}}} + +=== Names from the Specificaitons === +When a variable name is taken from the GSM or ITU specicaitons, it sould follow the form in the specifications as closely as possible (substituting "_" for "-", for example). This rule overrides the formating guidelines given above. + +== Text Formatting == + +=== Tabs and Spaces === +Use tabs for indentation and for comment alignment. Set your editor to display the tab width you like. + +=== Curly Braces === +Place curly braces according to the following examples: +{{{ + +if (test) { + action(); +} + +if (test) { + action(); +} else { + otherAction(); +} + +while (condition) { + action(); +} + +void function(void) +{ + doStuff(); + do moreStuff(); +} + +/** An example class to show some formatting. */ +class ThisClass : public ThatClass { + + protected: + + int mValue; ///< an example instance variable + + + /** An initialization function called by the constructor. */ + void initStuff(); + + + public: + + /** + Construct a ThisClass object. + @param wValue The initial value for mValue + */ + ThisClass(wValue) + :ThatClass() + { + initStuff(); + } + + void bigFunction(void); ///< bigFunction defined in .cpp file + + /** Short one-liner can be defined right here. */ + void shortFunction(void) { doItHere(); } + +}; + +}}} + + +== Scoping == +Generally speaking, anything you declare should be declared in the smallest possible scope. + +=== Local Variables === +Like anything else, local variables should be defined in the smallest possible scope. For example, this: +{{{ +int sum = 0; +for (int i=0; i. +# + +include $(top_srcdir)/Makefile.common + +EXTRA_DIST = \ + CodingStandard \ + SoftwareP2.8Manual.pdf + diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 0000000..b2a91db --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,411 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(top_srcdir)/Makefile.common +subdir = doc +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SOURCES = +DIST_SOURCES = +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +EXTRA_DIST = \ + CodingStandard \ + SoftwareP2.8Manual.pdf + +all: all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu doc/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: +tags: TAGS +TAGS: + +ctags: CTAGS +CTAGS: + + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/SoftwareP2.8Manual.pdf b/doc/SoftwareP2.8Manual.pdf new file mode 100644 index 0000000..2ec3f8d Binary files /dev/null and b/doc/SoftwareP2.8Manual.pdf differ diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..6ebe46d --- /dev/null +++ b/install-sh @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2004-12-17.09 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit 0;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit 0;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 0000000..761e1fd --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,6402 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun configure. +# +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004 +# Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# 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. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +basename="s,^.*/,,g" + +# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh +# is ksh but when the shell is invoked as "sh" and the current value of +# the _XPG environment variable is not equal to 1 (one), the special +# positional parameter $0, within a function call, is the name of the +# function. +progpath="$0" + +# The name of this program: +progname=`echo "$progpath" | $SED $basename` +modename="$progname" + +# Global variables: +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +PROGRAM=ltmain.sh +PACKAGE=libtool +VERSION=1.5.10 +TIMESTAMP=" (1.1220.2.130 2004/09/19 12:13:49)" + +# See if we are running on zsh, and set the options which allow our +# commands through without removal of \ escapes. +if test -n "${ZSH_VERSION+set}" ; then + setopt NO_GLOB_SUBST +fi + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$progpath" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +##################################### +# Shell function definitions: +# This seems to be the best place for them + +# func_win32_libid arg +# return the library type of file 'arg' +# +# Need a lot of goo to handle *both* DLLs and import libs +# Has to be a shell function in order to 'eat' the argument +# that is supplied when $file_magic_command is called. +func_win32_libid () { + win32_libid_type="unknown" + win32_fileres=`file -L $1 2>/dev/null` + case $win32_fileres in + *ar\ archive\ import\ library*) # definitely import + win32_libid_type="x86 archive import" + ;; + *ar\ archive*) # could be an import, or static + if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \ + $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then + win32_nmres=`eval $NM -f posix -A $1 | \ + sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'` + if test "X$win32_nmres" = "Ximport" ; then + win32_libid_type="x86 archive import" + else + win32_libid_type="x86 archive static" + fi + fi + ;; + *DLL*) + win32_libid_type="x86 DLL" + ;; + *executable*) # but shell scripts are "executable" too... + case $win32_fileres in + *MS\ Windows\ PE\ Intel*) + win32_libid_type="x86 DLL" + ;; + esac + ;; + esac + $echo $win32_libid_type +} + + +# func_infer_tag arg +# Infer tagged configuration to use if any are available and +# if one wasn't chosen via the "--tag" command line option. +# Only attempt this if the compiler in the base compile +# command doesn't match the default compiler. +# arg is usually of the form 'gcc ...' +func_infer_tag () { + if test -n "$available_tags" && test -z "$tagname"; then + CC_quoted= + for arg in $CC; do + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case $@ in + # Blanks in the command may have been stripped by the calling shell, + # but not from the CC environment variable when configure was run. + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;; + # Blanks at the start of $base_compile will cause this to fail + # if we don't check for them as well. + *) + for z in $available_tags; do + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" + CC_quoted= + for arg in $CC; do + # Double-quote args containing other shell metacharacters. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + CC_quoted="$CC_quoted $arg" + done + case "$@ " in + " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) + # The compiler in the base compile command matches + # the one in the tagged configuration. + # Assume this is the tagged configuration we want. + tagname=$z + break + ;; + esac + fi + done + # If $tagname still isn't set, then no tagged configuration + # was found and let the user know that the "--tag" command + # line option must be used. + if test -z "$tagname"; then + $echo "$modename: unable to infer tagged configuration" + $echo "$modename: specify a tag with \`--tag'" 1>&2 + exit $EXIT_FAILURE +# else +# $echo "$modename: using $tagname tagged configuration" + fi + ;; + esac + fi +} + + +# func_extract_archives gentop oldlib ... +func_extract_archives () { + my_gentop="$1"; shift + my_oldlibs=${1+"$@"} + my_oldobjs="" + my_xlib="" + my_xabs="" + my_xdir="" + my_status="" + + $show "${rm}r $my_gentop" + $run ${rm}r "$my_gentop" + $show "$mkdir $my_gentop" + $run $mkdir "$my_gentop" + my_status=$? + if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then + exit $my_status + fi + + for my_xlib in $my_oldlibs; do + # Extract the objects. + case $my_xlib in + [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; + *) my_xabs=`pwd`"/$my_xlib" ;; + esac + my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'` + my_xdir="$my_gentop/$my_xlib" + + $show "${rm}r $my_xdir" + $run ${rm}r "$my_xdir" + $show "$mkdir $my_xdir" + $run $mkdir "$my_xdir" + status=$? + if test "$status" -ne 0 && test ! -d "$my_xdir"; then + exit $status + fi + case $host in + *-darwin*) + $show "Extracting $my_xabs" + # Do not bother doing anything if just a dry run + if test -z "$run"; then + darwin_orig_dir=`pwd` + cd $my_xdir || exit $? + darwin_archive=$my_xabs + darwin_curdir=`pwd` + darwin_base_archive=`basename $darwin_archive` + darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` + if test -n "$darwin_arches"; then + darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` + darwin_arch= + $show "$darwin_base_archive has multiple architectures $darwin_arches" + for darwin_arch in $darwin_arches ; do + mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}" + lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" + # Remove the table of contents from the thin files. + $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true + $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true + cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" + $AR -xo "${darwin_base_archive}" + rm "${darwin_base_archive}" + cd "$darwin_curdir" + done # $darwin_arches + ## Okay now we have a bunch of thin objects, gotta fatten them up :) + darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP` + darwin_file= + darwin_files= + for darwin_file in $darwin_filelist; do + darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` + lipo -create -output "$darwin_file" $darwin_files + done # $darwin_filelist + rm -rf unfat-$$ + cd "$darwin_orig_dir" + else + cd $darwin_orig_dir + (cd $my_xdir && $AR x $my_xabs) || exit $? + fi # $darwin_arches + fi # $run + ;; + *) + # We will extract separately just the conflicting names and we will + # no longer touch any unique names. It is faster to leave these + # extract automatically by $AR in one run. + $show "(cd $my_xdir && $AR x $my_xabs)" + $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $? + if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; renaming object files" 1>&2 + $echo "$modename: warning: to ensure that they will not overwrite" 1>&2 + $AR t "$my_xabs" | sort | uniq -cd | while read -r count name + do + i=1 + while test "$i" -le "$count" + do + # Put our $i before any first dot (extension) + # Never overwrite any file + name_to="$name" + while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to" + do + name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` + done + $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')" + $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $? + i=`expr $i + 1` + done + done + fi + ;; + esac + my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` + done + + func_extract_archives_result="$my_oldobjs" +} +# End of Shell function definitions +##################################### + +# Darwin sucks +eval std_shrext=\"$shrext_cmds\" + +# Parse our command line options once, thoroughly. +while test "$#" -gt 0 +do + arg="$1" + shift + + case $arg in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + execute_dlfiles) + execute_dlfiles="$execute_dlfiles $arg" + ;; + tag) + tagname="$arg" + preserve_args="${preserve_args}=$arg" + + # Check whether tagname contains only valid characters + case $tagname in + *[!-_A-Za-z0-9,/]*) + $echo "$progname: invalid tag name: $tagname" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $tagname in + CC) + # Don't test for the "default" C tag, as we know, it's there, but + # not specially marked. + ;; + *) + if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then + taglist="$taglist $tagname" + # Evaluate the configuration. + eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`" + else + $echo "$progname: ignoring unknown tag $tagname" 1>&2 + fi + ;; + esac + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case $arg in + --help) + show_help=yes + ;; + + --version) + $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + $echo + $echo "Copyright (C) 2003 Free Software Foundation, Inc." + $echo "This is free software; see the source for copying conditions. There is NO" + $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + exit $EXIT_SUCCESS + ;; + + --config) + ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath + # Now print the configurations for the tags. + for tagname in $taglist; do + ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath" + done + exit $EXIT_SUCCESS + ;; + + --debug) + $echo "$progname: enabling shell trace mode" + set -x + preserve_args="$preserve_args $arg" + ;; + + --dry-run | -n) + run=: + ;; + + --features) + $echo "host: $host" + if test "$build_libtool_libs" = yes; then + $echo "enable shared libraries" + else + $echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + $echo "enable static libraries" + else + $echo "disable static libraries" + fi + exit $EXIT_SUCCESS + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --preserve-dup-deps) duplicate_deps="yes" ;; + + --quiet | --silent) + show=: + preserve_args="$preserve_args $arg" + ;; + + --tag) prevopt="--tag" prev=tag ;; + --tag=*) + set tag "$optarg" ${1+"$@"} + shift + prev=tag + preserve_args="$preserve_args --tag" + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE +fi + +# If this variable is set in any of the actions, the command in it +# will be execed at the end. This prevents here-documents from being +# left over by shells. +exec_cmd= + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2 + $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2 + case $nonopt in + *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*) + mode=link + for arg + do + case $arg in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case $mode in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + srcfile="$nonopt" # always keep a non-empty value in "srcfile" + suppress_opt=yes + suppress_output= + arg_mode=normal + libobj= + later= + + for arg + do + case "$arg_mode" in + arg ) + # do not "continue". Instead, add this to base_compile + lastarg="$arg" + arg_mode=normal + ;; + + target ) + libobj="$arg" + arg_mode=normal + continue + ;; + + normal ) + # Accept any command-line options. + case $arg in + -o) + if test -n "$libobj" ; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit $EXIT_FAILURE + fi + arg_mode=target + continue + ;; + + -static | -prefer-pic | -prefer-non-pic) + later="$later $arg" + continue + ;; + + -no-suppress) + suppress_opt=no + continue + ;; + + -Xcompiler) + arg_mode=arg # the next one goes into the "base_compile" arg list + continue # The current "srcfile" will either be retained or + ;; # replaced later. I would guess that would be a bug. + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` + lastarg= + save_ifs="$IFS"; IFS=',' + for arg in $args; do + IFS="$save_ifs" + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + lastarg="$lastarg $arg" + done + IFS="$save_ifs" + lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` + + # Add the arguments to base_compile. + base_compile="$base_compile $lastarg" + continue + ;; + + * ) + # Accept the current argument as the source file. + # The previous "srcfile" becomes the current argument. + # + lastarg="$srcfile" + srcfile="$arg" + ;; + esac # case $arg + ;; + esac # case $arg_mode + + # Aesthetically quote the previous argument. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + case $lastarg in + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly + # in scan sets, so we specify it separately. + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + lastarg="\"$lastarg\"" + ;; + esac + + base_compile="$base_compile $lastarg" + done # for arg + + case $arg_mode in + arg) + $echo "$modename: you must specify an argument for -Xcompile" + exit $EXIT_FAILURE + ;; + target) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit $EXIT_FAILURE + ;; + *) + # Get the name of the library object. + [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSifmso]' + case $libobj in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.ii) xform=ii ;; + *.class) xform=class ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + *.java) xform=java ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case $libobj in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + func_infer_tag $base_compile + + for arg in $later; do + case $arg in + -static) + build_old_libs=yes + continue + ;; + + -prefer-pic) + pic_mode=yes + continue + ;; + + -prefer-non-pic) + pic_mode=no + continue + ;; + esac + done + + objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir= + else + xdir=$xdir/ + fi + lobj=${xdir}$objdir/$objname + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $lobj $libobj ${libobj}T" + else + removelist="$lobj $libobj ${libobj}T" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + + # On Cygwin there's no "real" PIC flag so we must build both object types + case $host_os in + cygwin* | mingw* | pw32* | os2*) + pic_mode=default + ;; + esac + if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default + fi + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15 + else + output_obj= + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until $run ln "$progpath" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + $echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + $echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + $run $rm "$libobj" "${libobj}T" + + # Create a libtool object file (analogous to a ".la" file), + # but don't create it if we're doing a dry run. + test -z "$run" && cat > ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed, then go on to compile the next one + if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then + $show "$mv $output_obj $lobj" + if $run $mv $output_obj $lobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the PIC object to the libtool object file. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T </dev/null`" != "X$srcfile"; then + $echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit $EXIT_FAILURE + fi + + # Just move the object if needed + if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Append the name of the non-PIC object the libtool object file. + # Only append if the libtool object file exists. + test -z "$run" && cat >> ${libobj}T <> ${libobj}T <&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test "$#" -gt 0; do + arg="$1" + shift + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test + ;; + *) qarg=$arg ;; + esac + libtool_args="$libtool_args $qarg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case $prev in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case $prev in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case $arg in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + continue + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit $EXIT_FAILURE + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + inst_prefix) + inst_prefix_dir="$arg" + prev= + continue + ;; + precious_regex) + precious_files_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + objectlist) + if test -f "$arg"; then + save_arg=$arg + moreargs= + for fil in `cat $save_arg` + do +# moreargs="$moreargs $fil" + arg=$fil + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + done + else + $echo "$modename: link input file \`$save_arg' does not exist" + exit $EXIT_FAILURE + fi + arg=$save_arg + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case $arg in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + xlinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $wl$qarg" + prev= + compile_command="$compile_command $wl$qarg" + finalize_command="$finalize_command $wl$qarg" + continue + ;; + xcclinker) + linker_flags="$linker_flags $qarg" + compiler_flags="$compiler_flags $qarg" + prev= + compile_command="$compile_command $qarg" + finalize_command="$finalize_command $qarg" + continue + ;; + shrext) + shrext_cmds="$arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi # test -n "$prev" + + prevarg="$arg" + + case $arg in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: more than one -exported-symbols argument is not allowed" + exit $EXIT_FAILURE + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -inst-prefix-dir) + prev=inst_prefix + continue + ;; + + # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* + # so, if we see these flags be careful not to treat them like -L + -L[A-Z][A-Z]*:*) + case $with_gcc/$host in + no/*-*-irix* | /*-*-irix*) + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + ;; + esac + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit $EXIT_FAILURE + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then + case $host in + *-*-cygwin* | *-*-pw32* | *-*-beos*) + # These systems don't actually have a C or math library (as such) + continue + ;; + *-*-mingw* | *-*-os2*) + # These systems don't actually have a C library (as such) + test "X$arg" = "X-lc" && continue + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C and math libraries are in the System framework + deplibs="$deplibs -framework System" + continue + esac + elif test "X$arg" = "X-lc_r"; then + case $host in + *-*-openbsd* | *-*-freebsd*) + # Do not include libc_r directly, use -pthread flag. + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + # gcc -m* arguments should be passed to the linker via $compiler_flags + # in order to pass architecture information to the linker + # (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo + # but this is not reliable with gcc because gcc may use -mfoo to + # select a different linker, different libraries, etc, while + # -Wl,-mfoo simply passes -mfoo to the linker. + -m*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + if test "$with_gcc" = "yes" ; then + compiler_flags="$compiler_flags $arg" + fi + continue + ;; + + -shrext) + prev=shrext + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-install) + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + # The PATH hackery in wrapper scripts is required on Windows + # in order for the loader to find any dlls it needs. + $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 + $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 + fast_install=no + ;; + *) no_install=yes ;; + esac + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -objectlist) + prev=objectlist + continue + ;; + + -o) prev=output ;; + + -precious-files-regex) + prev=precious_regex + continue + ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit $EXIT_FAILURE + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # The effects of -static are defined in a previous loop. + # We used to do the same as -all-static on platforms that + # didn't have a PIC flag, but the assumption that the effects + # would be equivalent was wrong. It would break on at least + # Digital Unix and AIX. + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + -version-number) + prev=vinfo + vinfo_number=yes + continue + ;; + + -Wc,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Wl,*) + args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` + arg= + save_ifs="$IFS"; IFS=',' + for flag in $args; do + IFS="$save_ifs" + case $flag in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + flag="\"$flag\"" + ;; + esac + arg="$arg $wl$flag" + compiler_flags="$compiler_flags $wl$flag" + linker_flags="$linker_flags $flag" + done + IFS="$save_ifs" + arg=`$echo "X$arg" | $Xsed -e "s/^ //"` + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + -XCClinker) + prev=xcclinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + + *.$objext) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A libtool-controlled object. + + # Check to see that this really is a libtool object. + if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + pic_object= + non_pic_object= + + # Read the .lo file + # If there is no directory component, then add one. + case $arg in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + if test -z "$pic_object" || \ + test -z "$non_pic_object" || + test "$pic_object" = none && \ + test "$non_pic_object" = none; then + $echo "$modename: cannot find name of object for \`$arg'" 1>&2 + exit $EXIT_FAILURE + fi + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + if test "$pic_object" != none; then + # Prepend the subdirectory the object is found in. + pic_object="$xdir$pic_object" + + if test "$prev" = dlfiles; then + if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then + dlfiles="$dlfiles $pic_object" + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + # CHECK ME: I think I busted this. -Ossama + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles $pic_object" + prev= + fi + + # A PIC object. + libobjs="$libobjs $pic_object" + arg="$pic_object" + fi + + # Non-PIC object. + if test "$non_pic_object" != none; then + # Prepend the subdirectory the object is found in. + non_pic_object="$xdir$non_pic_object" + + # A standard non-PIC object + non_pic_objects="$non_pic_objects $non_pic_object" + if test -z "$pic_object" || test "$pic_object" = none ; then + arg="$non_pic_object" + fi + fi + else + # Only an error if not doing a dry-run. + if test -z "$run"; then + $echo "$modename: \`$arg' is not a valid libtool object" 1>&2 + exit $EXIT_FAILURE + else + # Dry-run case. + + # Extract subdirectory from the argument. + xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$arg"; then + xdir= + else + xdir="$xdir/" + fi + + pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"` + non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"` + libobjs="$libobjs $pic_object" + non_pic_objects="$non_pic_objects $non_pic_object" + fi + fi + ;; + + *.$libext) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + if test "$prev" = dlfiles; then + # This library was specified with -dlopen. + dlfiles="$dlfiles $arg" + prev= + elif test "$prev" = dlprefiles; then + # The library was specified with -dlpreopen. + dlprefiles="$dlprefiles $arg" + prev= + else + deplibs="$deplibs $arg" + fi + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") + arg="\"$arg\"" + ;; + esac + ;; + esac # arg + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done # argument parsing loop + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + # Create the object directory. + if test ! -d "$output_objdir"; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test "$status" -ne 0 && test ! -d "$output_objdir"; then + exit $status + fi + fi + + # Determine the type of output + case $output in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + *.$libext) linkmode=oldlib ;; + *.lo | *.$objext) linkmode=obj ;; + *.la) linkmode=lib ;; + *) linkmode=prog ;; # Anything else should be a program. + esac + + case $host in + *cygwin* | *mingw* | *pw32*) + # don't eliminate duplications in $postdeps and $predeps + duplicate_compiler_generated_deps=yes + ;; + *) + duplicate_compiler_generated_deps=$duplicate_deps + ;; + esac + specialdeplibs= + + libs= + # Find all interdependent deplibs by searching for libraries + # that are linked more than once (e.g. -la -lb -la) + for deplib in $deplibs; do + if test "X$duplicate_deps" = "Xyes" ; then + case "$libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + libs="$libs $deplib" + done + + if test "$linkmode" = lib; then + libs="$predeps $libs $compiler_lib_search_path $postdeps" + + # Compute libraries that are listed more than once in $predeps + # $postdeps and mark them as special (i.e., whose duplicates are + # not to be eliminated). + pre_post_deps= + if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then + for pre_post_dep in $predeps $postdeps; do + case "$pre_post_deps " in + *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; + esac + pre_post_deps="$pre_post_deps $pre_post_dep" + done + fi + pre_post_deps= + fi + + deplibs= + newdependency_libs= + newlib_search_path= + need_relink=no # whether we're linking any uninstalled libtool libraries + notinst_deplibs= # not-installed libtool libraries + notinst_path= # paths that contain not-installed libtool libraries + case $linkmode in + lib) + passes="conv link" + for file in $dlfiles $dlprefiles; do + case $file in + *.la) ;; + *) + $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + prog) + compile_deplibs= + finalize_deplibs= + alldeplibs=no + newdlfiles= + newdlprefiles= + passes="conv scan dlopen dlpreopen link" + ;; + *) passes="conv" + ;; + esac + for pass in $passes; do + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan"; then + libs="$deplibs" + deplibs= + fi + if test "$linkmode" = prog; then + case $pass in + dlopen) libs="$dlfiles" ;; + dlpreopen) libs="$dlprefiles" ;; + link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; + esac + fi + if test "$pass" = dlopen; then + # Collect dlpreopened libraries + save_deplibs="$deplibs" + deplibs= + fi + for deplib in $libs; do + lib= + found=no + case $deplib in + -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe) + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + fi + continue + ;; + -l*) + if test "$linkmode" != lib && test "$linkmode" != prog; then + $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2 + continue + fi + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do + for search_ext in .la $std_shrext .so .a; do + # Search the libtool library + lib="$searchdir/lib${name}${search_ext}" + if test -f "$lib"; then + if test "$search_ext" = ".la"; then + found=yes + else + found=no + fi + break 2 + fi + done + done + if test "$found" != yes; then + # deplib doesn't seem to be a libtool library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + else # deplib is a libtool library + # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, + # We need to do some special things here, and not later. + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $deplib "*) + if (${SED} -e '2q' $lib | + grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + library_names= + old_library= + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + for l in $old_library $library_names; do + ll="$l" + done + if test "X$ll" = "X$old_library" ; then # only static version available + found=no + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + lib=$ladir/$old_library + if test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + deplibs="$deplib $deplibs" + test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" + fi + continue + fi + fi + ;; + *) ;; + esac + fi + fi + ;; # -l + -L*) + case $linkmode in + lib) + deplibs="$deplib $deplibs" + test "$pass" = conv && continue + newdependency_libs="$deplib $newdependency_libs" + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + prog) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + if test "$pass" = scan; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + *) + $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2 + ;; + esac # linkmode + continue + ;; # -L + -R*) + if test "$pass" = link; then + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + fi + deplibs="$deplib $deplibs" + continue + ;; + *.la) lib="$deplib" ;; + *.$libext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + continue + fi + case $linkmode in + lib) + valid_a_lib=no + case $deplibs_check_method in + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + if eval $echo \"$deplib\" 2>/dev/null \ + | $SED 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + valid_a_lib=yes + fi + ;; + pass_all) + valid_a_lib=yes + ;; + esac + if test "$valid_a_lib" != yes; then + $echo + $echo "*** Warning: Trying to link with static lib archive $deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because the file extensions .$libext of this argument makes me believe" + $echo "*** that it is just a static archive that I should not used here." + else + $echo + $echo "*** Warning: Linking the shared library $output against the" + $echo "*** static library $deplib is not portable!" + deplibs="$deplib $deplibs" + fi + continue + ;; + prog) + if test "$pass" != link; then + deplibs="$deplib $deplibs" + else + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + fi + continue + ;; + esac # linkmode + ;; # *.$libext + *.lo | *.$objext) + if test "$pass" = conv; then + deplibs="$deplib $deplibs" + elif test "$linkmode" = prog; then + if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then + # If there is no dlopen support or we're linking statically, + # we need to preload. + newdlprefiles="$newdlprefiles $deplib" + compile_deplibs="$deplib $compile_deplibs" + finalize_deplibs="$deplib $finalize_deplibs" + else + newdlfiles="$newdlfiles $deplib" + fi + fi + continue + ;; + %DEPLIBS%) + alldeplibs=yes + continue + ;; + esac # case $deplib + if test "$found" = yes || test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + + dlname= + dlopen= + dlpreopen= + libdir= + library_names= + old_library= + # If the library was installed with an old release of libtool, + # it will not redefine variables installed, or shouldnotlink + installed=yes + shouldnotlink=no + + # Read the .la file + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + if test "$linkmode,$pass" = "lib,link" || + test "$linkmode,$pass" = "prog,scan" || + { test "$linkmode" != prog && test "$linkmode" != lib; }; then + test -n "$dlopen" && dlfiles="$dlfiles $dlopen" + test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" + fi + + if test "$pass" = conv; then + # Only check for convenience libraries + deplibs="$lib $deplibs" + if test -z "$libdir"; then + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + tmp_libs= + for deplib in $dependency_libs; do + deplibs="$deplib $deplibs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + elif test "$linkmode" != prog && test "$linkmode" != lib; then + $echo "$modename: \`$lib' is not a convenience library" 1>&2 + exit $EXIT_FAILURE + fi + continue + fi # $pass = conv + + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + + # This library was specified with -dlopen. + if test "$pass" = dlopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + if test -z "$dlname" || + test "$dlopen_support" != yes || + test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking + # statically, we need to preload. We also need to preload any + # dependent libraries so libltdl's deplib preloader doesn't + # bomb out in the load deplibs phase. + dlprefiles="$dlprefiles $lib $dependency_libs" + else + newdlfiles="$newdlfiles $lib" + fi + continue + fi # $pass = dlopen + + # We need an absolute path. + case $ladir in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then + dir="$ladir" + absdir="$abs_ladir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + notinst_path="$notinst_path $abs_ladir" + fi + fi # $installed = yes + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + # This library was specified with -dlpreopen. + if test "$pass" = dlpreopen; then + if test -z "$libdir"; then + $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 + exit $EXIT_FAILURE + fi + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + newdlprefiles="$newdlprefiles $dir/$old_library" + # Otherwise, use the dlname, so that lt_dlopen finds it. + elif test -n "$dlname"; then + newdlprefiles="$newdlprefiles $dir/$dlname" + else + newdlprefiles="$newdlprefiles $dir/$linklib" + fi + fi # $pass = dlpreopen + + if test -z "$libdir"; then + # Link the convenience library + if test "$linkmode" = lib; then + deplibs="$dir/$old_library $deplibs" + elif test "$linkmode,$pass" = "prog,link"; then + compile_deplibs="$dir/$old_library $compile_deplibs" + finalize_deplibs="$dir/$old_library $finalize_deplibs" + else + deplibs="$lib $deplibs" # used for prog,scan pass + fi + continue + fi + + + if test "$linkmode" = prog && test "$pass" != link; then + newlib_search_path="$newlib_search_path $ladir" + deplibs="$lib $deplibs" + + linkalldeplibs=no + if test "$link_all_deplibs" != no || test -z "$library_names" || + test "$build_libtool_libs" = no; then + linkalldeplibs=yes + fi + + tmp_libs= + for deplib in $dependency_libs; do + case $deplib in + -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test + esac + # Need to link against all dependency_libs? + if test "$linkalldeplibs" = yes; then + deplibs="$deplib $deplibs" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$deplib $newdependency_libs" + fi + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done # for deplib + continue + fi # $linkmode = prog... + + if test "$linkmode,$pass" = "prog,link"; then + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi # $linkmode,$pass = prog,link... + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # We only need to search for static libraries + continue + fi + fi + + link_static=no # Whether the deplib will be linked statically + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + if test "$installed" = no; then + notinst_deplibs="$notinst_deplibs $lib" + need_relink=yes + fi + # This is a shared library + + # Warn about portability, can't link against -module's on + # some systems (darwin) + if test "$shouldnotlink" = yes && test "$pass" = link ; then + $echo + if test "$linkmode" = prog; then + $echo "*** Warning: Linking the executable $output against the loadable module" + else + $echo "*** Warning: Linking the shared library $output against the loadable module" + fi + $echo "*** $linklib is not portable!" + fi + if test "$linkmode" = lib && + test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + # use dlname if we got it. it's perfectly good, no? + if test -n "$dlname"; then + soname="$dlname" + elif test -n "$soname_spec"; then + # bleh windows + case $host in + *cygwin* | mingw*) + major=`expr $current - $age` + versuffix="-$major" + ;; + esac + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + soroot="$soname" + soname=`$echo $soroot | ${SED} -e 's/^.*\///'` + newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$extract_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + save_ifs="$IFS"; IFS='~' + cmds=$old_archive_from_expsyms_cmds + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi # test -n "$old_archive_from_expsyms_cmds" + + if test "$linkmode" = prog || test "$mode" != relink; then + add_shlibpath= + add_dir= + add= + lib_linked=yes + case $hardcode_action in + immediate | unsupported) + if test "$hardcode_direct" = no; then + add="$dir/$linklib" + case $host in + *-*-sco3.2v5* ) add_dir="-L$dir" ;; + *-*-darwin* ) + # if the lib is a module then we can not link against + # it, someone is ignoring the new warnings I added + if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then + $echo "** Warning, lib $linklib is a module, not a shared library" + if test -z "$old_library" ; then + $echo + $echo "** And there doesn't seem to be a static archive available" + $echo "** The link will probably fail, sorry" + else + add="$dir/$old_library" + fi + fi + esac + elif test "$hardcode_minus_L" = no; then + case $host in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + add="$dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add="-l$name" + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit $EXIT_FAILURE + fi + + if test -n "$add_shlibpath"; then + case :$compile_shlibpath: in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + if test "$linkmode" = prog; then + test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" + test -n "$add" && compile_deplibs="$add $compile_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + fi + fi + + if test "$linkmode" = prog || test "$mode" = relink; then + add_shlibpath= + add_dir= + add= + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + add="$libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add="-l$name" + elif test "$hardcode_shlibpath_var" = yes; then + case :$finalize_shlibpath: in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add="-l$name" + elif test "$hardcode_automatic" = yes; then + if test -n "$inst_prefix_dir" && + test -f "$inst_prefix_dir$libdir/$linklib" ; then + add="$inst_prefix_dir$libdir/$linklib" + else + add="$libdir/$linklib" + fi + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + # Try looking first in the location we're being installed to. + if test -n "$inst_prefix_dir"; then + case "$libdir" in + [\\/]*) + add_dir="$add_dir -L$inst_prefix_dir$libdir" + ;; + esac + fi + add="-l$name" + fi + + if test "$linkmode" = prog; then + test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" + test -n "$add" && finalize_deplibs="$add $finalize_deplibs" + else + test -n "$add_dir" && deplibs="$add_dir $deplibs" + test -n "$add" && deplibs="$add $deplibs" + fi + fi + elif test "$linkmode" = prog; then + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_deplibs="$dir/$linklib $compile_deplibs" + finalize_deplibs="$dir/$linklib $finalize_deplibs" + else + compile_deplibs="-l$name -L$dir $compile_deplibs" + finalize_deplibs="-l$name -L$dir $finalize_deplibs" + fi + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + $echo + $echo "*** Warning: This system can not link to static lib archive $lib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have." + if test "$module" = yes; then + $echo "*** But as you try to build a module library, libtool will still create " + $echo "*** a static module, that should work as long as the dlopening application" + $echo "*** is linked with the -dlopen flag to resolve symbols at runtime." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + else + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$dir/$old_library $deplibs" + link_static=yes + fi + fi # link shared/static library? + + if test "$linkmode" = lib; then + if test -n "$dependency_libs" && + { test "$hardcode_into_libs" != yes || + test "$build_old_libs" = yes || + test "$link_static" = yes; }; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case $libdir in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + newlib_search_path="$newlib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" + # ... and its dependency_libs + tmp_libs= + for deplib in $dependency_libs; do + newdependency_libs="$deplib $newdependency_libs" + if test "X$duplicate_deps" = "Xyes" ; then + case "$tmp_libs " in + *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; + esac + fi + tmp_libs="$tmp_libs $deplib" + done + + if test "$link_all_deplibs" != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case $deplib in + -L*) path="$deplib" ;; + *.la) + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + if grep "^installed=no" $deplib > /dev/null; then + path="$absdir/$objdir" + else + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + if test "$absdir" != "$libdir"; then + $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 + fi + path="$absdir" + fi + depdepl= + case $host in + *-*-darwin*) + # we do not want to link against static libs, + # but need to link against shared + eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` + if test -n "$deplibrary_names" ; then + for tmp in $deplibrary_names ; do + depdepl=$tmp + done + if test -f "$path/$depdepl" ; then + depdepl="$path/$depdepl" + fi + # do not add paths which are already there + case " $newlib_search_path " in + *" $path "*) ;; + *) newlib_search_path="$newlib_search_path $path";; + esac + fi + path="" + ;; + *) + path="-L$path" + ;; + esac + ;; + -l*) + case $host in + *-*-darwin*) + # Again, we only want to link against shared libraries + eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"` + for tmp in $newlib_search_path ; do + if test -f "$tmp/lib$tmp_libs.dylib" ; then + eval depdepl="$tmp/lib$tmp_libs.dylib" + break + fi + done + path="" + ;; + *) continue ;; + esac + ;; + *) continue ;; + esac + case " $deplibs " in + *" $depdepl "*) ;; + *) deplibs="$depdepl $deplibs" ;; + esac + case " $deplibs " in + *" $path "*) ;; + *) deplibs="$deplibs $path" ;; + esac + done + fi # link_all_deplibs != no + fi # linkmode = lib + done # for deplib in $libs + dependency_libs="$newdependency_libs" + if test "$pass" = dlpreopen; then + # Link the dlpreopened libraries before other libraries + for deplib in $save_deplibs; do + deplibs="$deplib $deplibs" + done + fi + if test "$pass" != dlopen; then + if test "$pass" != conv; then + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $newlib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + newlib_search_path= + fi + + if test "$linkmode,$pass" != "prog,link"; then + vars="deplibs" + else + vars="compile_deplibs finalize_deplibs" + fi + for var in $vars dependency_libs; do + # Add libraries to $var in reverse order + eval tmp_libs=\"\$$var\" + new_libs= + for deplib in $tmp_libs; do + # FIXME: Pedantically, this is the right thing to do, so + # that some nasty dependency loop isn't accidentally + # broken: + #new_libs="$deplib $new_libs" + # Pragmatically, this seems to cause very few problems in + # practice: + case $deplib in + -L*) new_libs="$deplib $new_libs" ;; + -R*) ;; + *) + # And here is the reason: when a library appears more + # than once as an explicit dependence of a library, or + # is implicitly linked in more than once by the + # compiler, it is considered special, and multiple + # occurrences thereof are not removed. Compare this + # with having the same library being listed as a + # dependency of multiple other libraries: in this case, + # we know (pedantically, we assume) the library does not + # need to be listed more than once, so we keep only the + # last copy. This is not always right, but it is rare + # enough that we require users that really mean to play + # such unportable linking tricks to link the library + # using -Wl,-lname, so that libtool does not consider it + # for duplicate removal. + case " $specialdeplibs " in + *" $deplib "*) new_libs="$deplib $new_libs" ;; + *) + case " $new_libs " in + *" $deplib "*) ;; + *) new_libs="$deplib $new_libs" ;; + esac + ;; + esac + ;; + esac + done + tmp_libs= + for deplib in $new_libs; do + case $deplib in + -L*) + case " $tmp_libs " in + *" $deplib "*) ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + ;; + *) tmp_libs="$tmp_libs $deplib" ;; + esac + done + eval $var=\"$tmp_libs\" + done # for var + fi + # Last step: remove runtime libs from dependency_libs + # (they stay in deplibs) + tmp_libs= + for i in $dependency_libs ; do + case " $predeps $postdeps $compiler_lib_search_path " in + *" $i "*) + i="" + ;; + esac + if test -n "$i" ; then + tmp_libs="$tmp_libs $i" + fi + done + dependency_libs=$tmp_libs + done # for pass + if test "$linkmode" = prog; then + dlfiles="$newdlfiles" + dlprefiles="$newdlprefiles" + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case $outputname in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval shared_ext=\"$shrext_cmds\" + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs"; then + if test "$deplibs_check_method" != pass_all; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 + exit $EXIT_FAILURE + else + $echo + $echo "*** Warning: Linking the shared library $output against the non-libtool" + $echo "*** objects $objs is not portable!" + libobjs="$libobjs $objs" + fi + fi + + if test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test "$#" -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + # Some compilers have problems with a `.al' extension so + # convenience libraries should have the same extension an + # archive normally would. + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # convert absolute version numbers to libtool ages + # this retains compatibility with .la files and attempts + # to make the code below a bit more comprehensible + + case $vinfo_number in + yes) + number_major="$2" + number_minor="$3" + number_revision="$4" + # + # There are really only two kinds -- those that + # use the current revision as the major version + # and those that subtract age and use age as + # a minor version. But, then there is irix + # which has an extra 1 added just for fun + # + case $version_type in + darwin|linux|osf|windows) + current=`expr $number_major + $number_minor` + age="$number_minor" + revision="$number_revision" + ;; + freebsd-aout|freebsd-elf|sunos) + current="$number_major" + revision="$number_minor" + age="0" + ;; + irix|nonstopux) + current=`expr $number_major + $number_minor - 1` + age="$number_minor" + revision="$number_minor" + ;; + esac + ;; + no) + current="$2" + revision="$3" + age="$4" + ;; + esac + + # Check that each of the things are valid numbers. + case $current in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $revision in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + case $age in + 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test "$age" -gt "$current"; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit $EXIT_FAILURE + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case $version_type in + none) ;; + + darwin) + # Like Linux, but with the current version available in + # verstring for coding it into the library header + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + # Darwin ld doesn't like 0 for these options... + minor_current=`expr $current + 1` + verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + irix | nonstopux) + major=`expr $current - $age + 1` + + case $version_type in + nonstopux) verstring_prefix=nonstopux ;; + *) verstring_prefix=sgi ;; + esac + verstring="$verstring_prefix$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test "$loop" -ne 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="$verstring_prefix$major.$iface:$verstring" + done + + # Before this point, $major must not contain `.'. + major=.$major + versuffix="$major.$revision" + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=.`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test "$loop" -ne 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + windows) + # Use '-' rather than '.', since we only want one + # extension on DOS 8.3 filesystems. + major=`expr $current - $age` + versuffix="-$major" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + $echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + case $version_type in + darwin) + # we can't check for "0.0" in archive_cmds due to quoting + # problems, so we reset it completely + verstring= + ;; + *) + verstring="0.0" + ;; + esac + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$mode" != relink; then + # Remove our outputs, but don't remove object files since they + # may have been created when compiling PIC objects. + removelist= + tempremovelist=`$echo "$output_objdir/*"` + for p in $tempremovelist; do + case $p in + *.$objext) + ;; + $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) + if test "X$precious_files_regex" != "X"; then + if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 + then + continue + fi + fi + removelist="$removelist $p" + ;; + *) ;; + esac + done + if test -n "$removelist"; then + $show "${rm}r $removelist" + $run ${rm}r $removelist + fi + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Eliminate all temporary directories. + for path in $notinst_path; do + lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'` + deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'` + dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` + done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then + dependency_libs="$temp_xrpath $dependency_libs" + fi + fi + + # Make sure dlfiles contains only unique files that won't be dlpreopened + old_dlfiles="$dlfiles" + dlfiles= + for lib in $old_dlfiles; do + case " $dlprefiles $dlfiles " in + *" $lib "*) ;; + *) dlfiles="$dlfiles $lib" ;; + esac + done + + # Make sure dlprefiles contains only unique files + old_dlprefiles="$dlprefiles" + dlprefiles= + for lib in $old_dlprefiles; do + case "$dlprefiles " in + *" $lib "*) ;; + *) dlprefiles="$dlprefiles $lib" ;; + esac + done + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *-*-rhapsody* | *-*-darwin1.[012]) + # Rhapsody C library is in the System framework + deplibs="$deplibs -framework System" + ;; + *-*-netbsd*) + # Don't link with libc until the a.out ld.so is fixed. + ;; + *-*-openbsd* | *-*-freebsd*) + # Do not include libc due to us having libc/libc_r. + test "X$arg" = "X-lc" && continue + ;; + *) + # Add libc to deplibs on all other systems if necessary. + if test "$build_libtool_need_lc" = "yes"; then + deplibs="$deplibs -lc" + fi + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case $deplibs_check_method in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behavior. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` + case $potliblink in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for file magic test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a file magic. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + match_pattern*) + set dummy $deplibs_check_method + match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` + for a_deplib in $deplibs; do + name="`expr $a_deplib : '-l\(.*\)'`" + # If $name is empty we are operating on a -L argument. + if test -n "$name" && test "$name" != "0"; then + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + case " $predeps $postdeps " in + *" $a_deplib "*) + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + ;; + esac + fi + if test -n "$a_deplib" ; then + libname=`eval \\$echo \"$libname_spec\"` + for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do + potential_libs=`ls $i/$libname[.-]* 2>/dev/null` + for potent_lib in $potential_libs; do + potlib="$potent_lib" # see symlink-check above in file_magic test + if eval $echo \"$potent_lib\" 2>/dev/null \ + | ${SED} 10q \ + | $EGREP "$match_pattern_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + fi + if test -n "$a_deplib" ; then + droppeddeps=yes + $echo + $echo "*** Warning: linker path does not have real file for library $a_deplib." + $echo "*** I have the capability to make that library automatically link in when" + $echo "*** you link to this library. But I can only do this if you have a" + $echo "*** shared version of the library, which you do not appear to have" + $echo "*** because I did check the linker path looking for a file starting" + if test -z "$potlib" ; then + $echo "*** with $libname but no candidates were found. (...for regex pattern test)" + else + $echo "*** with $libname and none of the candidates passed a file format test" + $echo "*** using a regex pattern. Last file checked: $potlib" + fi + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g'` + if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then + for i in $predeps $postdeps ; do + # can't use Xsed below, because $i might contain '/' + tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"` + done + fi + if $echo "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' \ + | grep . >/dev/null; then + $echo + if test "X$deplibs_check_method" = "Xnone"; then + $echo "*** Warning: inter-library dependencies are not supported in this platform." + else + $echo "*** Warning: inter-library dependencies are not known to be supported." + fi + $echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + $echo + $echo "*** Warning: libtool could not satisfy all declared inter-library" + $echo "*** dependencies of module $libname. Therefore, libtool will create" + $echo "*** a static module, that should work as long as the dlopening" + $echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + $echo + $echo "*** However, this would only work if libtool was able to extract symbol" + $echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + $echo "*** not find such a program. So, this module is probably useless." + $echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + $echo "*** The inter-library dependencies that have been dropped here will be" + $echo "*** automatically added whenever a program is linked with this library" + $echo "*** or is declared to -dlopen it." + + if test "$allow_undefined" = no; then + $echo + $echo "*** Since this library must not contain undefined symbols," + $echo "*** because either the platform does not support them or" + $echo "*** it was explicitly requested with -no-undefined," + $echo "*** libtool will only create a static version of it." + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + fi + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$mode" != relink && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + if test -n "$hardcode_libdir_flag_spec_ld"; then + eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" + else + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval shared_ext=\"$shrext_cmds\" + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + if test -z "$dlname"; then + dlname=$soname + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + cmds=$export_symbols_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + if len=`expr "X$cmd" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + $show "$cmd" + $run eval "$cmd" || exit $? + skipped_export=false + else + # The command line is too long to execute in one step. + $show "using reloadable object file for export list..." + skipped_export=: + fi + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + tmp_deplibs= + for test_deplib in $deplibs; do + case " $convenience " in + *" $test_deplib "*) ;; + *) + tmp_deplibs="$tmp_deplibs $test_deplib" + ;; + esac + done + deplibs="$tmp_deplibs" + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + libobjs="$libobjs $func_extract_archives_result" + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + eval test_cmds=\"$module_expsym_cmds\" + cmds=$module_expsym_cmds + else + eval test_cmds=\"$module_cmds\" + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval test_cmds=\"$archive_expsym_cmds\" + cmds=$archive_expsym_cmds + else + eval test_cmds=\"$archive_cmds\" + cmds=$archive_cmds + fi + fi + + if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + : + else + # The command line is too long to link in one step, link piecewise. + $echo "creating reloadable object files..." + + # Save the value of $output and $libobjs because we want to + # use them later. If we have whole_archive_flag_spec, we + # want to use save_libobjs as it was before + # whole_archive_flag_spec was expanded, because we can't + # assume the linker understands whole_archive_flag_spec. + # This may have to be revisited, in case too many + # convenience libraries get linked in and end up exceeding + # the spec. + if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then + save_libobjs=$libobjs + fi + save_output=$output + + # Clear the reloadable object creation command queue and + # initialize k to one. + test_cmds= + concat_cmds= + objlist= + delfiles= + last_robj= + k=1 + output=$output_objdir/$save_output-${k}.$objext + # Loop over the list of objects to be linked. + for obj in $save_libobjs + do + eval test_cmds=\"$reload_cmds $objlist $last_robj\" + if test "X$objlist" = X || + { len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; }; then + objlist="$objlist $obj" + else + # The command $test_cmds is almost too long, add a + # command to the queue. + if test "$k" -eq 1 ; then + # The first file doesn't have a previous command to add. + eval concat_cmds=\"$reload_cmds $objlist $last_robj\" + else + # All subsequent reloadable object files will link in + # the last one created. + eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\" + fi + last_robj=$output_objdir/$save_output-${k}.$objext + k=`expr $k + 1` + output=$output_objdir/$save_output-${k}.$objext + objlist=$obj + len=1 + fi + done + # Handle the remaining objects by creating one last + # reloadable object file. All subsequent reloadable object + # files will link in the last one created. + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" + + if ${skipped_export-false}; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + libobjs=$output + # Append the command to create the export file. + eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\" + fi + + # Set up a command to remove the reloadale object files + # after they are used. + i=0 + while test "$i" -lt "$k" + do + i=`expr $i + 1` + delfiles="$delfiles $output_objdir/$save_output-${i}.$objext" + done + + $echo "creating a temporary reloadable object file: $output" + + # Loop through the commands generated above and execute them. + save_ifs="$IFS"; IFS='~' + for cmd in $concat_cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + libobjs=$output + # Restore the value of output. + output=$save_output + + if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + fi + # Expand the library linking commands again to reset the + # value of $libobjs for piecewise linking. + + # Do each of the archive commands. + if test "$module" = yes && test -n "$module_cmds" ; then + if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then + cmds=$module_expsym_cmds + else + cmds=$module_cmds + fi + else + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + cmds=$archive_expsym_cmds + else + cmds=$archive_cmds + fi + fi + + # Append the command to remove the reloadable object files + # to the just-reset $cmds. + eval cmds=\"\$cmds~\$rm $delfiles\" + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$mode" = relink; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + exit $EXIT_SUCCESS + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case $output in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit $EXIT_FAILURE + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + generated="$generated $gentop" + + func_extract_archives $gentop $convenience + reload_conv_objs="$reload_objs $func_extract_archives_result" + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test + + output="$obj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + # $show "echo timestamp > $libobj" + # $run eval "echo timestamp > $libobj" || exit $? + exit $EXIT_SUCCESS + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + cmds=$reload_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit $EXIT_SUCCESS + ;; + + prog) + case $host in + *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; + esac + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + case $host in + *-*-rhapsody* | *-*-darwin1.[012]) + # On Rhapsody replace the C library is the System framework + compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` + ;; + esac + + case $host in + *darwin*) + # Don't allow lazy linking, it breaks C++ global constructors + if test "$tagname" = CXX ; then + compile_command="$compile_command ${wl}-bind_at_load" + finalize_command="$finalize_command ${wl}-bind_at_load" + fi + ;; + esac + + compile_command="$compile_command $compile_deplibs" + finalize_command="$finalize_command $finalize_deplibs" + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case $host in + *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) + case :$dllsearchpath: in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case $dlsyms in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`$echo "$arg" | ${SED} -e 's%^.*/%%'` + $run eval '$echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | + if sort -k 3 /dev/null 2>&1; then + sort -k 3 + else + sort +2 + fi | + uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + $echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr void * +#else +# define lt_ptr char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr address; +} +lt_preloaded_symbols[] = +{\ +" + + eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case $host in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit $EXIT_FAILURE + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test "$need_relink" = no || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case $dir in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$no_install" = yes; then + # We don't need to create a wrapper script. + link_command="$compile_var$compile_command$compile_rpath" + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + # Delete the old output file. + $run $rm $output + # Link the executable and exit + $show "$link_command" + $run eval "$link_command" || exit $? + exit $EXIT_SUCCESS + fi + + if test "$hardcode_action" = relink; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + relink_command="(cd `pwd`; $relink_command)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then + case $progpath in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; + *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;; + esac + # test for cygwin because mv fails w/o .exe extensions + case $host in + *cygwin*) + exeext=.exe + outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;; + *) exeext= ;; + esac + case $host in + *cygwin* | *mingw* ) + cwrappersource=`$echo ${objdir}/lt-${output}.c` + cwrapper=`$echo ${output}.exe` + $rm $cwrappersource $cwrapper + trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 + + cat > $cwrappersource <> $cwrappersource<<"EOF" +#include +#include +#include +#include +#include +#include + +#if defined(PATH_MAX) +# define LT_PATHMAX PATH_MAX +#elif defined(MAXPATHLEN) +# define LT_PATHMAX MAXPATHLEN +#else +# define LT_PATHMAX 1024 +#endif + +#ifndef DIR_SEPARATOR +#define DIR_SEPARATOR '/' +#endif + +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ + defined (__OS2__) +#define HAVE_DOS_BASED_FILE_SYSTEM +#ifndef DIR_SEPARATOR_2 +#define DIR_SEPARATOR_2 '\\' +#endif +#endif + +#ifndef DIR_SEPARATOR_2 +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) +#else /* DIR_SEPARATOR_2 */ +# define IS_DIR_SEPARATOR(ch) \ + (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) +#endif /* DIR_SEPARATOR_2 */ + +#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) +#define XFREE(stale) do { \ + if (stale) { free ((void *) stale); stale = 0; } \ +} while (0) + +const char *program_name = NULL; + +void * xmalloc (size_t num); +char * xstrdup (const char *string); +char * basename (const char *name); +char * fnqualify(const char *path); +char * strendzap(char *str, const char *pat); +void lt_fatal (const char *message, ...); + +int +main (int argc, char *argv[]) +{ + char **newargz; + int i; + + program_name = (char *) xstrdup ((char *) basename (argv[0])); + newargz = XMALLOC(char *, argc+2); +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" + newargz[1] = fnqualify(argv[0]); + /* we know the script has the same name, without the .exe */ + /* so make sure newargz[1] doesn't end in .exe */ + strendzap(newargz[1],".exe"); + for (i = 1; i < argc; i++) + newargz[i+1] = xstrdup(argv[i]); + newargz[argc+1] = NULL; +EOF + + cat >> $cwrappersource <> $cwrappersource <<"EOF" +} + +void * +xmalloc (size_t num) +{ + void * p = (void *) malloc (num); + if (!p) + lt_fatal ("Memory exhausted"); + + return p; +} + +char * +xstrdup (const char *string) +{ + return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL +; +} + +char * +basename (const char *name) +{ + const char *base; + +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + /* Skip over the disk name in MSDOS pathnames. */ + if (isalpha (name[0]) && name[1] == ':') + name += 2; +#endif + + for (base = name; *name; name++) + if (IS_DIR_SEPARATOR (*name)) + base = name + 1; + return (char *) base; +} + +char * +fnqualify(const char *path) +{ + size_t size; + char *p; + char tmp[LT_PATHMAX + 1]; + + assert(path != NULL); + + /* Is it qualified already? */ +#if defined (HAVE_DOS_BASED_FILE_SYSTEM) + if (isalpha (path[0]) && path[1] == ':') + return xstrdup (path); +#endif + if (IS_DIR_SEPARATOR (path[0])) + return xstrdup (path); + + /* prepend the current directory */ + /* doesn't handle '~' */ + if (getcwd (tmp, LT_PATHMAX) == NULL) + lt_fatal ("getcwd failed"); + size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */ + p = XMALLOC(char, size); + sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path); + return p; +} + +char * +strendzap(char *str, const char *pat) +{ + size_t len, patlen; + + assert(str != NULL); + assert(pat != NULL); + + len = strlen(str); + patlen = strlen(pat); + + if (patlen <= len) + { + str += len - patlen; + if (strcmp(str, pat) == 0) + *str = '\0'; + } + return str; +} + +static void +lt_error_core (int exit_status, const char * mode, + const char * message, va_list ap) +{ + fprintf (stderr, "%s: %s: ", program_name, mode); + vfprintf (stderr, message, ap); + fprintf (stderr, ".\n"); + + if (exit_status >= 0) + exit (exit_status); +} + +void +lt_fatal (const char *message, ...) +{ + va_list ap; + va_start (ap, message); + lt_error_core (EXIT_FAILURE, "FATAL", message, ap); + va_end (ap); +} +EOF + # we should really use a build-platform specific compiler + # here, but OTOH, the wrappers (shell script and this C one) + # are only useful if you want to execute the "real" binary. + # Since the "real" binary is built for $host, then this + # wrapper might as well be built for $host, too. + $run $LTCC -s -o $cwrapper $cwrappersource + ;; + esac + $rm $output + trap "$rm $output; exit $EXIT_FAILURE" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='${SED} -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + notinst_deplibs='$notinst_deplibs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + $echo >> $output "\ + program=lt-'$outputname'$exeext + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + $echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if relink_command_output=\`eval \$relink_command 2>&1\`; then : + else + $echo \"\$relink_command_output\" >&2 + $rm \"\$progdir/\$file\" + exit $EXIT_FAILURE + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + $echo >> $output "\ + program='$outputname' + progdir=\"\$thisdir/$objdir\" +" + fi + + $echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + # Backslashes separate directories on plain windows + *-*-mingw | *-*-os2*) + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + + *) + $echo >> $output "\ + exec \$progdir/\$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit $EXIT_FAILURE + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + $echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit $EXIT_FAILURE + fi +fi\ +" + chmod +x $output + fi + exit $EXIT_SUCCESS + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$old_deplibs $non_pic_objects" + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + + func_extract_archives $gentop $addlibs + oldobjs="$oldobjs $func_extract_archives_result" + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + cmds=$old_archive_from_new_cmds + else + eval cmds=\"$old_archive_cmds\" + + if len=`expr "X$cmds" : ".*"` && + test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then + cmds=$old_archive_cmds + else + # the command line is too long to link in one step, link in parts + $echo "using piecewise archive linking..." + save_RANLIB=$RANLIB + RANLIB=: + objlist= + concat_cmds= + save_oldobjs=$oldobjs + # GNU ar 2.10+ was changed to match POSIX; thus no paths are + # encoded into archives. This makes 'ar r' malfunction in + # this piecewise linking case whenever conflicting object + # names appear in distinct ar calls; check, warn and compensate. + if (for obj in $save_oldobjs + do + $echo "X$obj" | $Xsed -e 's%^.*/%%' + done | sort | sort -uc >/dev/null 2>&1); then + : + else + $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2 + $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2 + AR_FLAGS=cq + fi + # Is there a better way of finding the last object in the list? + for obj in $save_oldobjs + do + last_oldobj=$obj + done + for obj in $save_oldobjs + do + oldobjs="$objlist $obj" + objlist="$objlist $obj" + eval test_cmds=\"$old_archive_cmds\" + if len=`expr "X$test_cmds" : ".*"` && + test "$len" -le "$max_cmd_len"; then + : + else + # the above command should be used before it gets too long + oldobjs=$objlist + if test "$obj" = "$last_oldobj" ; then + RANLIB=$save_RANLIB + fi + test -z "$concat_cmds" || concat_cmds=$concat_cmds~ + eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" + objlist= + fi + done + RANLIB=$save_RANLIB + oldobjs=$objlist + if test "X$oldobjs" = "X" ; then + eval cmds=\"\$concat_cmds\" + else + eval cmds=\"\$concat_cmds~\$old_archive_cmds\" + fi + fi + fi + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + eval cmd=\"$cmd\" + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case $output in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Preserve any variables that may affect compiler behavior + for var in $variables_saved_for_relink; do + if eval test -z \"\${$var+set}\"; then + relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" + elif eval var_value=\$$var; test -z "$var_value"; then + relink_command="$var=; export $var; $relink_command" + else + var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` + relink_command="$var=\"$var_value\"; export $var; $relink_command" + fi + done + # Quote the link command for shipping. + relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + if test "$hardcode_automatic" = yes ; then + relink_command= + fi + + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case $deplib in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + newdlfiles= + for lib in $dlfiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlfiles="$newdlfiles $libdir/$name" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` + if test -z "$libdir"; then + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit $EXIT_FAILURE + fi + newdlprefiles="$newdlprefiles $libdir/$name" + done + dlprefiles="$newdlprefiles" + else + newdlfiles= + for lib in $dlfiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlfiles="$newdlfiles $abs" + done + dlfiles="$newdlfiles" + newdlprefiles= + for lib in $dlprefiles; do + case $lib in + [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; + *) abs=`pwd`"/$lib" ;; + esac + newdlprefiles="$newdlprefiles $abs" + done + dlprefiles="$newdlprefiles" + fi + $rm $output + # place dlname in correct position for cygwin + tdlname=$dlname + case $host,$output,$installed,$module,$dlname in + *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; + esac + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$tdlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Should we warn about portability when linking against -modules? +shouldnotlink=$module + +# Files to dlopen/dlpreopen +dlopen='$dlfiles' +dlpreopen='$dlprefiles' + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no && test "$need_relink" = yes; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit $EXIT_SUCCESS + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || + # Allow the use of GNU shtool's install command. + $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case $arg in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case $arg in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test "$#" -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + fi + case $destdir in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case $file in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case $file in + *.$libext) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test -n "$relink_command"; then + # Determine the prefix the user has applied to our future dir. + inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"` + + # Don't allow the user to place us outside of our expected + # location b/c this prevents finding dependent libraries that + # are installed to the same prefix. + # At present, this check doesn't affect windows .dll's that + # are installed into $libdir/../bin (currently, that works fine) + # but it's something to keep an eye on. + if test "$inst_prefix_dir" = "$destdir"; then + $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2 + exit $EXIT_FAILURE + fi + + if test -n "$inst_prefix_dir"; then + # Stick the inst_prefix_dir data into the link command. + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` + else + relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"` + fi + + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + exit $EXIT_FAILURE + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test -n "$relink_command" && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test "$#" -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + cmds=$postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case $destfile in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.$objext) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit $EXIT_SUCCESS + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # If the file is missing, and there is a .exe on the end, strip it + # because it is most likely a libtool script we actually want to + # install + stripped_ext="" + case $file in + *.exe) + if test ! -f "$file"; then + file=`$echo $file|${SED} 's,.exe$,,'` + stripped_ext=".exe" + fi + ;; + esac + + # Do a test to see if this is really a libtool program. + case $host in + *cygwin*|*mingw*) + wrapper=`$echo $file | ${SED} -e 's,.exe$,,'` + ;; + *) + wrapper=$file + ;; + esac + if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then + notinst_deplibs= + relink_command= + + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + # Check the variables that should have been set. + if test -z "$notinst_deplibs"; then + $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 + exit $EXIT_FAILURE + fi + + finalize=yes + for lib in $notinst_deplibs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case $lib in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # To insure that "foo" is sourced, and not "foo.exe", + # finese the cygwin/MSYS system by explicitly sourcing "foo." + # which disallows the automatic-append-.exe behavior. + case $build in + *cygwin* | *mingw*) wrapperdot=${wrapper}. ;; + *) wrapperdot=${wrapper} ;; + esac + # If there is no directory component, then add one. + case $file in + */* | *\\*) . ${wrapperdot} ;; + *) . ./${wrapperdot} ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + save_umask=`umask` + umask 0077 + if $mkdir "$tmpdir"; then + umask $save_umask + else + umask $save_umask + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'` + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + # remove .exe since cygwin /usr/bin/install will append another + # one anyways + case $install_prog,$host in + */usr/bin/install*,*cygwin*) + case $file:$destfile in + *.exe:*.exe) + # this is ok + ;; + *.exe:*) + destfile=$destfile.exe + ;; + *:*.exe) + destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'` + ;; + esac + ;; + esac + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$old_striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + cmds=$old_postinstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' + else + exit $EXIT_SUCCESS + fi + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + cmds=$finish_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit $EXIT_SUCCESS + + $echo "----------------------------------------------------------------------" + $echo "Libraries have been installed in:" + for libdir in $libdirs; do + $echo " $libdir" + done + $echo + $echo "If you ever happen to want to link against installed libraries" + $echo "in a given directory, LIBDIR, you must either use libtool, and" + $echo "specify the full pathname of the library, or use the \`-LLIBDIR'" + $echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + $echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + $echo " during execution" + fi + if test -n "$runpath_var"; then + $echo " - add LIBDIR to the \`$runpath_var' environment variable" + $echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + $echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + $echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + $echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + $echo + $echo "See any operating system documentation about shared libraries for" + $echo "more information, such as the ld(1) and ld.so(8) manual pages." + $echo "----------------------------------------------------------------------" + exit $EXIT_SUCCESS + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit $EXIT_FAILURE + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + dir= + case $file in + *.la) + # Check to see that this really is a libtool archive. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit $EXIT_FAILURE + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case $file in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case $file in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved environment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now prepare to actually exec the command. + exec_cmd="\$cmd$args" + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit $EXIT_SUCCESS + fi + ;; + + # libtool clean and uninstall mode + clean | uninstall) + modename="$modename: $mode" + rm="$nonopt" + files= + rmforce= + exit_status=0 + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case $arg in + -f) rm="$rm $arg"; rmforce=yes ;; + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + fi + + rmdirs= + + origobjdir="$objdir" + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$origobjdir" + else + objdir="$dir/$origobjdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + test "$mode" = uninstall && objdir="$dir" + + # Remember objdir for removal later, being careful to avoid duplicates + if test "$mode" = clean; then + case " $rmdirs " in + *" $objdir "*) ;; + *) rmdirs="$rmdirs $objdir" ;; + esac + fi + + # Don't error if the file doesn't exist and rm -f was used. + if (test -L "$file") >/dev/null 2>&1 \ + || (test -h "$file") >/dev/null 2>&1 \ + || test -f "$file"; then + : + elif test -d "$file"; then + exit_status=1 + continue + elif test "$rmforce" = yes; then + continue + fi + + rmfiles="$file" + + case $name in + *.la) + # Possibly a libtool archive, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + + if test "$mode" = uninstall; then + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + cmds=$postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + cmds=$old_postuninstall_cmds + save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + eval cmd=\"$cmd\" + $show "$cmd" + $run eval "$cmd" + if test "$?" -ne 0 && test "$rmforce" != yes; then + exit_status=1 + fi + done + IFS="$save_ifs" + fi + # FIXME: should reinstall the best remaining shared library. + fi + fi + ;; + + *.lo) + # Possibly a libtool object, so verify it. + if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + + # Read the .lo file + . $dir/$name + + # Add PIC object to the list of files to remove. + if test -n "$pic_object" \ + && test "$pic_object" != none; then + rmfiles="$rmfiles $dir/$pic_object" + fi + + # Add non-PIC object to the list of files to remove. + if test -n "$non_pic_object" \ + && test "$non_pic_object" != none; then + rmfiles="$rmfiles $dir/$non_pic_object" + fi + fi + ;; + + *) + if test "$mode" = clean ; then + noexename=$name + case $file in + *.exe) + file=`$echo $file|${SED} 's,.exe$,,'` + noexename=`$echo $name|${SED} 's,.exe$,,'` + # $file with .exe has already been added to rmfiles, + # add $file without .exe + rmfiles="$rmfiles $file" + ;; + esac + # Do a test to see if this is a libtool program. + if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$noexename + + # note $name still contains .exe if it was in $file originally + # as does the version of $file that was added into $rmfiles + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + if test "X$noexename" != "X$name" ; then + rmfiles="$rmfiles $objdir/lt-${noexename}.c" + fi + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles || exit_status=1 + done + objdir="$origobjdir" + + # Try to remove the ${objdir}s in the directories where we deleted files + for dir in $rmdirs; do + if test -d "$dir"; then + $show "rmdir $dir" + $run rmdir $dir >/dev/null 2>&1 + fi + done + + exit $exit_status + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + ;; + esac + + if test -z "$exec_cmd"; then + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit $EXIT_FAILURE + fi +fi # test -z "$show_help" + +if test -n "$exec_cmd"; then + eval exec $exec_cmd + exit $EXIT_FAILURE +fi + +# We need to display help for each of the modes. +case $mode in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --tag=TAG use configuration variables from tag TAG + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE. + +Report bugs to ." + exit $EXIT_SUCCESS + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -prefer-pic try to building PIC objects only + -prefer-non-pic try to building non-PIC objects only + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-fast-install disable the fast-install mode + -no-install link a not-installable executable + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -objectlist FILE Use a list of object files found in FILE to specify objects + -precious-files-regex REGEX + don't remove output files matching REGEX + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit $EXIT_FAILURE + ;; +esac + +$echo +$echo "Try \`$modename --help' for more information about other modes." + +exit $EXIT_SUCCESS + +# The TAGs below are defined such that we never get into a situation +# in which we disable both kinds of libraries. Given conflicting +# choices, we go for a static library, that is the most portable, +# since we can't tell whether shared libraries were disabled because +# the user asked for that or because the platform doesn't support +# them. This is particularly important on AIX, because we don't +# support having both static and shared libraries enabled at the same +# time on that platform, so we default to a shared-only configuration. +# If a disable-shared tag is given, we'll fallback to a static-only +# configuration. But we'll never go from static-only to shared-only. + +# ### BEGIN LIBTOOL TAG CONFIG: disable-shared +build_libtool_libs=no +build_old_libs=yes +# ### END LIBTOOL TAG CONFIG: disable-shared + +# ### BEGIN LIBTOOL TAG CONFIG: disable-static +build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` +# ### END LIBTOOL TAG CONFIG: disable-static + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/missing b/missing new file mode 100755 index 0000000..64b5f90 --- /dev/null +++ b/missing @@ -0,0 +1,353 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2004-09-07.08 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, 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. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit 0 + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit 0 + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case "$1" in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/sqlite3/Makefile.am b/sqlite3/Makefile.am new file mode 100644 index 0000000..5c4f5ed --- /dev/null +++ b/sqlite3/Makefile.am @@ -0,0 +1,36 @@ +# +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +include $(top_srcdir)/Makefile.common + +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -lpthread + +noinst_LTLIBRARIES = libsqlite.la + +libsqlite_la_SOURCES = \ + sqlite3.c \ + sqlite3util.cpp + +noinst_HEADERS = \ + sqlite3.h \ + sqlite3ext.h \ + sqlite3util.h + diff --git a/sqlite3/Makefile.in b/sqlite3/Makefile.in new file mode 100644 index 0000000..cd80819 --- /dev/null +++ b/sqlite3/Makefile.in @@ -0,0 +1,561 @@ +# Makefile.in generated by automake 1.9.4 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004 Free Software Foundation, Inc. +# This Makefile.in 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. + +@SET_MAKE@ + +# +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + +# +# Copyright 2008 Free Software Foundation, Inc. +# +# This software is distributed under the terms of the GNU Public License. +# See the COPYING file in the main directory for details. +# +# 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 3 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, see . +# + + +SOURCES = $(libsqlite_la_SOURCES) + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +INSTALL = @INSTALL@ +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ + $(srcdir)/Makefile.in $(top_srcdir)/Makefile.common +subdir = sqlite3 +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +libsqlite_la_LIBADD = +am_libsqlite_la_OBJECTS = sqlite3.lo sqlite3util.lo +libsqlite_la_OBJECTS = $(am_libsqlite_la_OBJECTS) +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(libsqlite_la_SOURCES) +DIST_SOURCES = $(libsqlite_la_SOURCES) +HEADERS = $(noinst_HEADERS) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +AMDEP_FALSE = @AMDEP_FALSE@ +AMDEP_TRUE = @AMDEP_TRUE@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +ECHO = @ECHO@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +F77 = @F77@ +FFLAGS = @FFLAGS@ +GREP = @GREP@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBUSB_CFLAGS = @LIBUSB_CFLAGS@ +LIBUSB_LIBS = @LIBUSB_LIBS@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +ORTP_CFLAGS = @ORTP_CFLAGS@ +ORTP_LIBS = @ORTP_LIBS@ +OSIP_CFLAGS = @OSIP_CFLAGS@ +OSIP_LIBS = @OSIP_LIBS@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +RANLIB = @RANLIB@ +RM_PROG = @RM_PROG@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_F77 = @ac_ct_F77@ +am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ +am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ +am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ +am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +COMMON_INCLUDEDIR = $(top_srcdir)/CommonLibs +CONTROL_INCLUDEDIR = $(top_srcdir)/Control +GSM_INCLUDEDIR = $(top_srcdir)/GSM +SIP_INCLUDEDIR = $(top_srcdir)/SIP +SMS_INCLUDEDIR = $(top_srcdir)/SMS +TRX_INCLUDEDIR = $(top_srcdir)/TRXManager +GLOBALS_INCLUDEDIR = $(top_srcdir)/Globals +CLI_INCLUDEDIR = $(top_srcdir)/CLI +SQLITE_INCLUDEDIR = $(top_srcdir)/sqlite3 +SR_INCLUDEDIR = $(top_srcdir)/SR +STD_DEFINES_AND_INCLUDES = \ + -I$(COMMON_INCLUDEDIR) \ + -I$(CONTROL_INCLUDEDIR) \ + -I$(GSM_INCLUDEDIR) \ + -I$(SIP_INCLUDEDIR) \ + -I$(SMS_INCLUDEDIR) \ + -I$(TRX_INCLUDEDIR) \ + -I$(GLOBALS_INCLUDEDIR) \ + -I$(CLI_INCLUDEDIR) \ + -I$(SR_INCLUDEDIR) \ + -I$(SQLITE_INCLUDEDIR) + +COMMON_LA = $(top_builddir)/CommonLibs/libcommon.la +GSM_LA = $(top_builddir)/GSM/libGSM.la +SIP_LA = $(top_builddir)/SIP/libSIP.la +SMS_LA = $(top_builddir)/SMS/libSMS.la +TRX_LA = $(top_builddir)/TRXManager/libtrxmanager.la +CONTROL_LA = $(top_builddir)/Control/libcontrol.la +GLOBALS_LA = $(top_builddir)/Globals/libglobals.la +CLI_LA = $(top_builddir)/CLI/libcli.la +SR_LA = $(top_builddir)/SR/libSR.la +SQLITE_LA = $(top_builddir)/sqlite3/libsqlite.la +MOSTLYCLEANFILES = *~ +AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) +AM_CXXFLAGS = -Wall -lpthread +noinst_LTLIBRARIES = libsqlite.la +libsqlite_la_SOURCES = \ + sqlite3.c \ + sqlite3util.cpp + +noinst_HEADERS = \ + sqlite3.h \ + sqlite3ext.h \ + sqlite3util.h + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .cpp .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu sqlite3/Makefile'; \ + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu sqlite3/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libsqlite.la: $(libsqlite_la_OBJECTS) $(libsqlite_la_DEPENDENCIES) + $(CXXLINK) $(libsqlite_la_LDFLAGS) $(libsqlite_la_OBJECTS) $(libsqlite_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlite3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlite3util.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +.cpp.o: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ if $(LTCXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +uninstall-info-am: + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + $(mkdir_p) $(distdir)/.. + @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ + list='$(DISTFILES)'; for file in $$list; do \ + case $$file in \ + $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ + $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ + esac; \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + dir="/$$dir"; \ + $(mkdir_p) "$(distdir)$$dir"; \ + else \ + dir=''; \ + fi; \ + if test -d $$d/$$file; then \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES) + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-info-am + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/sqlite3/sqlite3.c b/sqlite3/sqlite3.c new file mode 100644 index 0000000..91422d3 --- /dev/null +++ b/sqlite3/sqlite3.c @@ -0,0 +1,110860 @@ +/****************************************************************************** +** This file is an amalgamation of many separate C source files from SQLite +** version 3.6.22. By combining all the individual C code files into this +** single large file, the entire code can be compiled as a one translation +** unit. This allows many compilers to do optimizations that would not be +** possible if the files were compiled separately. Performance improvements +** of 5% are more are commonly seen when SQLite is compiled as a single +** translation unit. +** +** This file is all you need to compile SQLite. To use SQLite in other +** programs, you need this file and the "sqlite3.h" header file that defines +** the programming interface to the SQLite library. (If you do not have +** the "sqlite3.h" header file at hand, you will find a copy embedded within +** the text of this file. Search for "Begin file sqlite3.h" to find the start +** of the embedded sqlite3.h header file.) Additional code files may be needed +** if you want a wrapper to interface SQLite with your choice of programming +** language. The code for the "sqlite3" command-line shell is also in a +** separate file. This file contains only code for the core SQLite library. +*/ +#define SQLITE_CORE 1 +#define SQLITE_AMALGAMATION 1 +#ifndef SQLITE_PRIVATE +# define SQLITE_PRIVATE static +#endif +#ifndef SQLITE_API +# define SQLITE_API +#endif +/************** Begin file sqliteInt.h ***************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Internal interface definitions for SQLite. +** +*/ +#ifndef _SQLITEINT_H_ +#define _SQLITEINT_H_ + +/* +** These #defines should enable >2GB file support on POSIX if the +** underlying operating system supports it. If the OS lacks +** large file support, or if the OS is windows, these should be no-ops. +** +** Ticket #2739: The _LARGEFILE_SOURCE macro must appear before any +** system #includes. Hence, this block of code must be the very first +** code in all source files. +** +** Large file support can be disabled using the -DSQLITE_DISABLE_LFS switch +** on the compiler command line. This is necessary if you are compiling +** on a recent machine (ex: Red Hat 7.2) but you want your code to work +** on an older machine (ex: Red Hat 6.0). If you compile on Red Hat 7.2 +** without this option, LFS is enable. But LFS does not exist in the kernel +** in Red Hat 6.0, so the code won't work. Hence, for maximum binary +** portability you should omit LFS. +** +** Similar is true for Mac OS X. LFS is only supported on Mac OS X 9 and later. +*/ +#ifndef SQLITE_DISABLE_LFS +# define _LARGE_FILE 1 +# ifndef _FILE_OFFSET_BITS +# define _FILE_OFFSET_BITS 64 +# endif +# define _LARGEFILE_SOURCE 1 +#endif + +/* +** Include the configuration header output by 'configure' if we're using the +** autoconf-based build +*/ +#ifdef _HAVE_SQLITE_CONFIG_H +#include "config.h" +#endif + +/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/ +/************** Begin file sqliteLimit.h *************************************/ +/* +** 2007 May 7 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file defines various limits of what SQLite can process. +*/ + +/* +** The maximum length of a TEXT or BLOB in bytes. This also +** limits the size of a row in a table or index. +** +** The hard limit is the ability of a 32-bit signed integer +** to count the size: 2^31-1 or 2147483647. +*/ +#ifndef SQLITE_MAX_LENGTH +# define SQLITE_MAX_LENGTH 1000000000 +#endif + +/* +** This is the maximum number of +** +** * Columns in a table +** * Columns in an index +** * Columns in a view +** * Terms in the SET clause of an UPDATE statement +** * Terms in the result set of a SELECT statement +** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement. +** * Terms in the VALUES clause of an INSERT statement +** +** The hard upper limit here is 32676. Most database people will +** tell you that in a well-normalized database, you usually should +** not have more than a dozen or so columns in any table. And if +** that is the case, there is no point in having more than a few +** dozen values in any of the other situations described above. +*/ +#ifndef SQLITE_MAX_COLUMN +# define SQLITE_MAX_COLUMN 2000 +#endif + +/* +** The maximum length of a single SQL statement in bytes. +** +** It used to be the case that setting this value to zero would +** turn the limit off. That is no longer true. It is not possible +** to turn this limit off. +*/ +#ifndef SQLITE_MAX_SQL_LENGTH +# define SQLITE_MAX_SQL_LENGTH 1000000000 +#endif + +/* +** The maximum depth of an expression tree. This is limited to +** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might +** want to place more severe limits on the complexity of an +** expression. +** +** A value of 0 used to mean that the limit was not enforced. +** But that is no longer true. The limit is now strictly enforced +** at all times. +*/ +#ifndef SQLITE_MAX_EXPR_DEPTH +# define SQLITE_MAX_EXPR_DEPTH 1000 +#endif + +/* +** The maximum number of terms in a compound SELECT statement. +** The code generator for compound SELECT statements does one +** level of recursion for each term. A stack overflow can result +** if the number of terms is too large. In practice, most SQL +** never has more than 3 or 4 terms. Use a value of 0 to disable +** any limit on the number of terms in a compount SELECT. +*/ +#ifndef SQLITE_MAX_COMPOUND_SELECT +# define SQLITE_MAX_COMPOUND_SELECT 500 +#endif + +/* +** The maximum number of opcodes in a VDBE program. +** Not currently enforced. +*/ +#ifndef SQLITE_MAX_VDBE_OP +# define SQLITE_MAX_VDBE_OP 25000 +#endif + +/* +** The maximum number of arguments to an SQL function. +*/ +#ifndef SQLITE_MAX_FUNCTION_ARG +# define SQLITE_MAX_FUNCTION_ARG 127 +#endif + +/* +** The maximum number of in-memory pages to use for the main database +** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE +*/ +#ifndef SQLITE_DEFAULT_CACHE_SIZE +# define SQLITE_DEFAULT_CACHE_SIZE 2000 +#endif +#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE +# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500 +#endif + +/* +** The maximum number of attached databases. This must be between 0 +** and 30. The upper bound on 30 is because a 32-bit integer bitmap +** is used internally to track attached databases. +*/ +#ifndef SQLITE_MAX_ATTACHED +# define SQLITE_MAX_ATTACHED 10 +#endif + + +/* +** The maximum value of a ?nnn wildcard that the parser will accept. +*/ +#ifndef SQLITE_MAX_VARIABLE_NUMBER +# define SQLITE_MAX_VARIABLE_NUMBER 999 +#endif + +/* Maximum page size. The upper bound on this value is 32768. This a limit +** imposed by the necessity of storing the value in a 2-byte unsigned integer +** and the fact that the page size must be a power of 2. +** +** If this limit is changed, then the compiled library is technically +** incompatible with an SQLite library compiled with a different limit. If +** a process operating on a database with a page-size of 65536 bytes +** crashes, then an instance of SQLite compiled with the default page-size +** limit will not be able to rollback the aborted transaction. This could +** lead to database corruption. +*/ +#ifndef SQLITE_MAX_PAGE_SIZE +# define SQLITE_MAX_PAGE_SIZE 32768 +#endif + + +/* +** The default size of a database page. +*/ +#ifndef SQLITE_DEFAULT_PAGE_SIZE +# define SQLITE_DEFAULT_PAGE_SIZE 1024 +#endif +#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE +# undef SQLITE_DEFAULT_PAGE_SIZE +# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE +#endif + +/* +** Ordinarily, if no value is explicitly provided, SQLite creates databases +** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain +** device characteristics (sector-size and atomic write() support), +** SQLite may choose a larger value. This constant is the maximum value +** SQLite will choose on its own. +*/ +#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE +# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 +#endif +#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE +# undef SQLITE_MAX_DEFAULT_PAGE_SIZE +# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE +#endif + + +/* +** Maximum number of pages in one database file. +** +** This is really just the default value for the max_page_count pragma. +** This value can be lowered (or raised) at run-time using that the +** max_page_count macro. +*/ +#ifndef SQLITE_MAX_PAGE_COUNT +# define SQLITE_MAX_PAGE_COUNT 1073741823 +#endif + +/* +** Maximum length (in bytes) of the pattern in a LIKE or GLOB +** operator. +*/ +#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH +# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 +#endif + +/* +** Maximum depth of recursion for triggers. +** +** A value of 1 means that a trigger program will not be able to itself +** fire any triggers. A value of 0 means that no trigger programs at all +** may be executed. +*/ +#ifndef SQLITE_MAX_TRIGGER_DEPTH +# define SQLITE_MAX_TRIGGER_DEPTH 1000 +#endif + +/************** End of sqliteLimit.h *****************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ + +/* Disable nuisance warnings on Borland compilers */ +#if defined(__BORLANDC__) +#pragma warn -rch /* unreachable code */ +#pragma warn -ccc /* Condition is always true or false */ +#pragma warn -aus /* Assigned value is never used */ +#pragma warn -csu /* Comparing signed and unsigned */ +#pragma warn -spa /* Suspicious pointer arithmetic */ +#endif + +/* Needed for various definitions... */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE +#endif + +/* +** Include standard header files as necessary +*/ +#ifdef HAVE_STDINT_H +#include +#endif +#ifdef HAVE_INTTYPES_H +#include +#endif + +#define SQLITE_INDEX_SAMPLES 10 + +/* +** This macro is used to "hide" some ugliness in casting an int +** value to a ptr value under the MSVC 64-bit compiler. Casting +** non 64-bit values to ptr types results in a "hard" error with +** the MSVC 64-bit compiler which this attempts to avoid. +** +** A simple compiler pragma or casting sequence could not be found +** to correct this in all situations, so this macro was introduced. +** +** It could be argued that the intptr_t type could be used in this +** case, but that type is not available on all compilers, or +** requires the #include of specific headers which differs between +** platforms. +** +** Ticket #3860: The llvm-gcc-4.2 compiler from Apple chokes on +** the ((void*)&((char*)0)[X]) construct. But MSVC chokes on ((void*)(X)). +** So we have to define the macros in different ways depending on the +** compiler. +*/ +#if defined(__GNUC__) +# if defined(HAVE_STDINT_H) +# define SQLITE_INT_TO_PTR(X) ((void*)(intptr_t)(X)) +# define SQLITE_PTR_TO_INT(X) ((int)(intptr_t)(X)) +# else +# define SQLITE_INT_TO_PTR(X) ((void*)(X)) +# define SQLITE_PTR_TO_INT(X) ((int)(X)) +# endif +#else +# define SQLITE_INT_TO_PTR(X) ((void*)&((char*)0)[X]) +# define SQLITE_PTR_TO_INT(X) ((int)(((char*)X)-(char*)0)) +#endif + + +/* +** The SQLITE_THREADSAFE macro must be defined as either 0 or 1. +** Older versions of SQLite used an optional THREADSAFE macro. +** We support that for legacy +*/ +#if !defined(SQLITE_THREADSAFE) +#if defined(THREADSAFE) +# define SQLITE_THREADSAFE THREADSAFE +#else +# define SQLITE_THREADSAFE 1 +#endif +#endif + +/* +** The SQLITE_DEFAULT_MEMSTATUS macro must be defined as either 0 or 1. +** It determines whether or not the features related to +** SQLITE_CONFIG_MEMSTATUS are available by default or not. This value can +** be overridden at runtime using the sqlite3_config() API. +*/ +#if !defined(SQLITE_DEFAULT_MEMSTATUS) +# define SQLITE_DEFAULT_MEMSTATUS 1 +#endif + +/* +** Exactly one of the following macros must be defined in order to +** specify which memory allocation subsystem to use. +** +** SQLITE_SYSTEM_MALLOC // Use normal system malloc() +** SQLITE_MEMDEBUG // Debugging version of system malloc() +** SQLITE_MEMORY_SIZE // internal allocator #1 +** SQLITE_MMAP_HEAP_SIZE // internal mmap() allocator +** SQLITE_POW2_MEMORY_SIZE // internal power-of-two allocator +** +** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as +** the default. +*/ +#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + defined(SQLITE_MEMORY_SIZE)+defined(SQLITE_MMAP_HEAP_SIZE)+\ + defined(SQLITE_POW2_MEMORY_SIZE)>1 +# error "At most one of the following compile-time configuration options\ + is allows: SQLITE_SYSTEM_MALLOC, SQLITE_MEMDEBUG, SQLITE_MEMORY_SIZE,\ + SQLITE_MMAP_HEAP_SIZE, SQLITE_POW2_MEMORY_SIZE" +#endif +#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_MEMDEBUG)+\ + defined(SQLITE_MEMORY_SIZE)+defined(SQLITE_MMAP_HEAP_SIZE)+\ + defined(SQLITE_POW2_MEMORY_SIZE)==0 +# define SQLITE_SYSTEM_MALLOC 1 +#endif + +/* +** If SQLITE_MALLOC_SOFT_LIMIT is not zero, then try to keep the +** sizes of memory allocations below this value where possible. +*/ +#if !defined(SQLITE_MALLOC_SOFT_LIMIT) +# define SQLITE_MALLOC_SOFT_LIMIT 1024 +#endif + +/* +** We need to define _XOPEN_SOURCE as follows in order to enable +** recursive mutexes on most Unix systems. But Mac OS X is different. +** The _XOPEN_SOURCE define causes problems for Mac OS X we are told, +** so it is omitted there. See ticket #2673. +** +** Later we learn that _XOPEN_SOURCE is poorly or incorrectly +** implemented on some systems. So we avoid defining it at all +** if it is already defined or if it is unneeded because we are +** not doing a threadsafe build. Ticket #2681. +** +** See also ticket #2741. +*/ +#if !defined(_XOPEN_SOURCE) && !defined(__DARWIN__) && !defined(__APPLE__) && SQLITE_THREADSAFE +# define _XOPEN_SOURCE 500 /* Needed to enable pthread recursive mutexes */ +#endif + +/* +** The TCL headers are only needed when compiling the TCL bindings. +*/ +#if defined(SQLITE_TCL) || defined(TCLSH) +# include +#endif + +/* +** Many people are failing to set -DNDEBUG=1 when compiling SQLite. +** Setting NDEBUG makes the code smaller and run faster. So the following +** lines are added to automatically set NDEBUG unless the -DSQLITE_DEBUG=1 +** option is set. Thus NDEBUG becomes an opt-in rather than an opt-out +** feature. +*/ +#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) +# define NDEBUG 1 +#endif + +/* +** The testcase() macro is used to aid in coverage testing. When +** doing coverage testing, the condition inside the argument to +** testcase() must be evaluated both true and false in order to +** get full branch coverage. The testcase() macro is inserted +** to help ensure adequate test coverage in places where simple +** condition/decision coverage is inadequate. For example, testcase() +** can be used to make sure boundary values are tested. For +** bitmask tests, testcase() can be used to make sure each bit +** is significant and used at least once. On switch statements +** where multiple cases go to the same block of code, testcase() +** can insure that all cases are evaluated. +** +*/ +#ifdef SQLITE_COVERAGE_TEST +SQLITE_PRIVATE void sqlite3Coverage(int); +# define testcase(X) if( X ){ sqlite3Coverage(__LINE__); } +#else +# define testcase(X) +#endif + +/* +** The TESTONLY macro is used to enclose variable declarations or +** other bits of code that are needed to support the arguments +** within testcase() and assert() macros. +*/ +#if !defined(NDEBUG) || defined(SQLITE_COVERAGE_TEST) +# define TESTONLY(X) X +#else +# define TESTONLY(X) +#endif + +/* +** Sometimes we need a small amount of code such as a variable initialization +** to setup for a later assert() statement. We do not want this code to +** appear when assert() is disabled. The following macro is therefore +** used to contain that setup code. The "VVA" acronym stands for +** "Verification, Validation, and Accreditation". In other words, the +** code within VVA_ONLY() will only run during verification processes. +*/ +#ifndef NDEBUG +# define VVA_ONLY(X) X +#else +# define VVA_ONLY(X) +#endif + +/* +** The ALWAYS and NEVER macros surround boolean expressions which +** are intended to always be true or false, respectively. Such +** expressions could be omitted from the code completely. But they +** are included in a few cases in order to enhance the resilience +** of SQLite to unexpected behavior - to make the code "self-healing" +** or "ductile" rather than being "brittle" and crashing at the first +** hint of unplanned behavior. +** +** In other words, ALWAYS and NEVER are added for defensive code. +** +** When doing coverage testing ALWAYS and NEVER are hard-coded to +** be true and false so that the unreachable code then specify will +** not be counted as untested code. +*/ +#if defined(SQLITE_COVERAGE_TEST) +# define ALWAYS(X) (1) +# define NEVER(X) (0) +#elif !defined(NDEBUG) +# define ALWAYS(X) ((X)?1:(assert(0),0)) +# define NEVER(X) ((X)?(assert(0),1):0) +#else +# define ALWAYS(X) (X) +# define NEVER(X) (X) +#endif + +/* +** The macro unlikely() is a hint that surrounds a boolean +** expression that is usually false. Macro likely() surrounds +** a boolean expression that is usually true. GCC is able to +** use these hints to generate better code, sometimes. +*/ +#if defined(__GNUC__) && 0 +# define likely(X) __builtin_expect((X),1) +# define unlikely(X) __builtin_expect((X),0) +#else +# define likely(X) !!(X) +# define unlikely(X) !!(X) +#endif + +/************** Include sqlite3.h in the middle of sqliteInt.h ***************/ +/************** Begin file sqlite3.h *****************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the SQLite library +** presents to client programs. If a C-function, structure, datatype, +** or constant definition does not appear in this file, then it is +** not a published API of SQLite, is subject to change without +** notice, and should not be referenced by programs that use SQLite. +** +** Some of the definitions that are in this file are marked as +** "experimental". Experimental interfaces are normally new +** features recently added to SQLite. We do not anticipate changes +** to experimental interfaces but reserve the right to make minor changes +** if experience from use "in the wild" suggest such changes are prudent. +** +** The official C-language API documentation for SQLite is derived +** from comments in this file. This file is the authoritative source +** on how SQLite interfaces are suppose to operate. +** +** The name of this file under configuration management is "sqlite.h.in". +** The makefile makes some minor changes to this file (such as inserting +** the version number) and changes its name to "sqlite3.h" as +** part of the build process. +*/ +#ifndef _SQLITE3_H_ +#define _SQLITE3_H_ +#include /* Needed for the definition of va_list */ + +/* +** Make sure we can call this stuff from C++. +*/ +#if 0 +extern "C" { +#endif + + +/* +** Add the ability to override 'extern' +*/ +#ifndef SQLITE_EXTERN +# define SQLITE_EXTERN extern +#endif + +#ifndef SQLITE_API +# define SQLITE_API +#endif + + +/* +** These no-op macros are used in front of interfaces to mark those +** interfaces as either deprecated or experimental. New applications +** should not use deprecated interfaces - they are support for backwards +** compatibility only. Application writers should be aware that +** experimental interfaces are subject to change in point releases. +** +** These macros used to resolve to various kinds of compiler magic that +** would generate warning messages when they were used. But that +** compiler magic ended up generating such a flurry of bug reports +** that we have taken it all out and gone back to using simple +** noop macros. +*/ +#define SQLITE_DEPRECATED +#define SQLITE_EXPERIMENTAL + +/* +** Ensure these symbols were not defined by some previous header file. +*/ +#ifdef SQLITE_VERSION +# undef SQLITE_VERSION +#endif +#ifdef SQLITE_VERSION_NUMBER +# undef SQLITE_VERSION_NUMBER +#endif + +/* +** CAPI3REF: Compile-Time Library Version Numbers +** +** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header +** evaluates to a string literal that is the SQLite version in the +** format "X.Y.Z" where X is the major version number (always 3 for +** SQLite3) and Y is the minor version number and Z is the release number.)^ +** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer +** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same +** numbers used in [SQLITE_VERSION].)^ +** The SQLITE_VERSION_NUMBER for any given release of SQLite will also +** be larger than the release from which it is derived. Either Y will +** be held constant and Z will be incremented or else Y will be incremented +** and Z will be reset to zero. +** +** Since version 3.6.18, SQLite source code has been stored in the +** Fossil configuration management +** system. ^The SQLITE_SOURCE_ID macro evalutes to +** a string which identifies a particular check-in of SQLite +** within its configuration management system. ^The SQLITE_SOURCE_ID +** string contains the date and time of the check-in (UTC) and an SHA1 +** hash of the entire source tree. +** +** See also: [sqlite3_libversion()], +** [sqlite3_libversion_number()], [sqlite3_sourceid()], +** [sqlite_version()] and [sqlite_source_id()]. +*/ +#define SQLITE_VERSION "3.6.22" +#define SQLITE_VERSION_NUMBER 3006022 +#define SQLITE_SOURCE_ID "2010-01-05 15:30:36 28d0d7710761114a44a1a3a425a6883c661f06e7" + +/* +** CAPI3REF: Run-Time Library Version Numbers +** KEYWORDS: sqlite3_version +** +** These interfaces provide the same information as the [SQLITE_VERSION], +** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros +** but are associated with the library instead of the header file. ^(Cautious +** programmers might include assert() statements in their application to +** verify that values returned by these interfaces match the macros in +** the header, and thus insure that the application is +** compiled with matching library and header files. +** +**
+** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
+** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
+** 
)^ +** +** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] +** macro. ^The sqlite3_libversion() function returns a pointer to the +** to the sqlite3_version[] string constant. The sqlite3_libversion() +** function is provided for use in DLLs since DLL users usually do not have +** direct access to string constants within the DLL. ^The +** sqlite3_libversion_number() function returns an integer equal to +** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer +** to a string constant whose value is the same as the [SQLITE_SOURCE_ID] +** C preprocessor macro. +** +** See also: [sqlite_version()] and [sqlite_source_id()]. +*/ +SQLITE_API const char sqlite3_version[] = SQLITE_VERSION; +SQLITE_API const char *sqlite3_libversion(void); +SQLITE_API const char *sqlite3_sourceid(void); +SQLITE_API int sqlite3_libversion_number(void); + +/* +** CAPI3REF: Test To See If The Library Is Threadsafe +** +** ^The sqlite3_threadsafe() function returns zero if and only if +** SQLite was compiled mutexing code omitted due to the +** [SQLITE_THREADSAFE] compile-time option being set to 0. +** +** SQLite can be compiled with or without mutexes. When +** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes +** are enabled and SQLite is threadsafe. When the +** [SQLITE_THREADSAFE] macro is 0, +** the mutexes are omitted. Without the mutexes, it is not safe +** to use SQLite concurrently from more than one thread. +** +** Enabling mutexes incurs a measurable performance penalty. +** So if speed is of utmost importance, it makes sense to disable +** the mutexes. But for maximum safety, mutexes should be enabled. +** ^The default behavior is for mutexes to be enabled. +** +** This interface can be used by an application to make sure that the +** version of SQLite that it is linking against was compiled with +** the desired setting of the [SQLITE_THREADSAFE] macro. +** +** This interface only reports on the compile-time mutex setting +** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with +** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but +** can be fully or partially disabled using a call to [sqlite3_config()] +** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD], +** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the +** sqlite3_threadsafe() function shows only the compile-time setting of +** thread safety, not any run-time changes to that setting made by +** sqlite3_config(). In other words, the return value from sqlite3_threadsafe() +** is unchanged by calls to sqlite3_config().)^ +** +** See the [threading mode] documentation for additional information. +*/ +SQLITE_API int sqlite3_threadsafe(void); + +/* +** CAPI3REF: Database Connection Handle +** KEYWORDS: {database connection} {database connections} +** +** Each open SQLite database is represented by a pointer to an instance of +** the opaque structure named "sqlite3". It is useful to think of an sqlite3 +** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and +** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] +** is its destructor. There are many other interfaces (such as +** [sqlite3_prepare_v2()], [sqlite3_create_function()], and +** [sqlite3_busy_timeout()] to name but three) that are methods on an +** sqlite3 object. +*/ +typedef struct sqlite3 sqlite3; + +/* +** CAPI3REF: 64-Bit Integer Types +** KEYWORDS: sqlite_int64 sqlite_uint64 +** +** Because there is no cross-platform way to specify 64-bit integer types +** SQLite includes typedefs for 64-bit signed and unsigned integers. +** +** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. +** The sqlite_int64 and sqlite_uint64 types are supported for backwards +** compatibility only. +** +** ^The sqlite3_int64 and sqlite_int64 types can store integer values +** between -9223372036854775808 and +9223372036854775807 inclusive. ^The +** sqlite3_uint64 and sqlite_uint64 types can store integer values +** between 0 and +18446744073709551615 inclusive. +*/ +#ifdef SQLITE_INT64_TYPE + typedef SQLITE_INT64_TYPE sqlite_int64; + typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; +#elif defined(_MSC_VER) || defined(__BORLANDC__) + typedef __int64 sqlite_int64; + typedef unsigned __int64 sqlite_uint64; +#else + typedef long long int sqlite_int64; + typedef unsigned long long int sqlite_uint64; +#endif +typedef sqlite_int64 sqlite3_int64; +typedef sqlite_uint64 sqlite3_uint64; + +/* +** If compiling for a processor that lacks floating point support, +** substitute integer for floating-point. +*/ +#ifdef SQLITE_OMIT_FLOATING_POINT +# define double sqlite3_int64 +#endif + +/* +** CAPI3REF: Closing A Database Connection +** +** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. +** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is +** successfullly destroyed and all associated resources are deallocated. +** +** Applications must [sqlite3_finalize | finalize] all [prepared statements] +** and [sqlite3_blob_close | close] all [BLOB handles] associated with +** the [sqlite3] object prior to attempting to close the object. ^If +** sqlite3_close() is called on a [database connection] that still has +** outstanding [prepared statements] or [BLOB handles], then it returns +** SQLITE_BUSY. +** +** ^If [sqlite3_close()] is invoked while a transaction is open, +** the transaction is automatically rolled back. +** +** The C parameter to [sqlite3_close(C)] must be either a NULL +** pointer or an [sqlite3] object pointer obtained +** from [sqlite3_open()], [sqlite3_open16()], or +** [sqlite3_open_v2()], and not previously closed. +** ^Calling sqlite3_close() with a NULL pointer argument is a +** harmless no-op. +*/ +SQLITE_API int sqlite3_close(sqlite3 *); + +/* +** The type for a callback function. +** This is legacy and deprecated. It is included for historical +** compatibility and is not documented. +*/ +typedef int (*sqlite3_callback)(void*,int,char**, char**); + +/* +** CAPI3REF: One-Step Query Execution Interface +** +** The sqlite3_exec() interface is a convenience wrapper around +** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], +** that allows an application to run multiple statements of SQL +** without having to use a lot of C code. +** +** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, +** semicolon-separate SQL statements passed into its 2nd argument, +** in the context of the [database connection] passed in as its 1st +** argument. ^If the callback function of the 3rd argument to +** sqlite3_exec() is not NULL, then it is invoked for each result row +** coming out of the evaluated SQL statements. ^The 4th argument to +** to sqlite3_exec() is relayed through to the 1st argument of each +** callback invocation. ^If the callback pointer to sqlite3_exec() +** is NULL, then no callback is ever invoked and result rows are +** ignored. +** +** ^If an error occurs while evaluating the SQL statements passed into +** sqlite3_exec(), then execution of the current statement stops and +** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec() +** is not NULL then any error message is written into memory obtained +** from [sqlite3_malloc()] and passed back through the 5th parameter. +** To avoid memory leaks, the application should invoke [sqlite3_free()] +** on error message strings returned through the 5th parameter of +** of sqlite3_exec() after the error message string is no longer needed. +** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors +** occur, then sqlite3_exec() sets the pointer in its 5th parameter to +** NULL before returning. +** +** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec() +** routine returns SQLITE_ABORT without invoking the callback again and +** without running any subsequent SQL statements. +** +** ^The 2nd argument to the sqlite3_exec() callback function is the +** number of columns in the result. ^The 3rd argument to the sqlite3_exec() +** callback is an array of pointers to strings obtained as if from +** [sqlite3_column_text()], one for each column. ^If an element of a +** result row is NULL then the corresponding string pointer for the +** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the +** sqlite3_exec() callback is an array of pointers to strings where each +** entry represents the name of corresponding result column as obtained +** from [sqlite3_column_name()]. +** +** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer +** to an empty string, or a pointer that contains only whitespace and/or +** SQL comments, then no SQL statements are evaluated and the database +** is not changed. +** +** Restrictions: +** +**
    +**
  • The application must insure that the 1st parameter to sqlite3_exec() +** is a valid and open [database connection]. +**
  • The application must not close [database connection] specified by +** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. +**
  • The application must not modify the SQL statement text passed into +** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. +**
+*/ +SQLITE_API int sqlite3_exec( + sqlite3*, /* An open database */ + const char *sql, /* SQL to be evaluated */ + int (*callback)(void*,int,char**,char**), /* Callback function */ + void *, /* 1st argument to callback */ + char **errmsg /* Error msg written here */ +); + +/* +** CAPI3REF: Result Codes +** KEYWORDS: SQLITE_OK {error code} {error codes} +** KEYWORDS: {result code} {result codes} +** +** Many SQLite functions return an integer result code from the set shown +** here in order to indicates success or failure. +** +** New error codes may be added in future versions of SQLite. +** +** See also: [SQLITE_IOERR_READ | extended result codes] +*/ +#define SQLITE_OK 0 /* Successful result */ +/* beginning-of-error-codes */ +#define SQLITE_ERROR 1 /* SQL error or missing database */ +#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */ +#define SQLITE_PERM 3 /* Access permission denied */ +#define SQLITE_ABORT 4 /* Callback routine requested an abort */ +#define SQLITE_BUSY 5 /* The database file is locked */ +#define SQLITE_LOCKED 6 /* A table in the database is locked */ +#define SQLITE_NOMEM 7 /* A malloc() failed */ +#define SQLITE_READONLY 8 /* Attempt to write a readonly database */ +#define SQLITE_INTERRUPT 9 /* Operation terminated by sqlite3_interrupt()*/ +#define SQLITE_IOERR 10 /* Some kind of disk I/O error occurred */ +#define SQLITE_CORRUPT 11 /* The database disk image is malformed */ +#define SQLITE_NOTFOUND 12 /* NOT USED. Table or record not found */ +#define SQLITE_FULL 13 /* Insertion failed because database is full */ +#define SQLITE_CANTOPEN 14 /* Unable to open the database file */ +#define SQLITE_PROTOCOL 15 /* NOT USED. Database lock protocol error */ +#define SQLITE_EMPTY 16 /* Database is empty */ +#define SQLITE_SCHEMA 17 /* The database schema changed */ +#define SQLITE_TOOBIG 18 /* String or BLOB exceeds size limit */ +#define SQLITE_CONSTRAINT 19 /* Abort due to constraint violation */ +#define SQLITE_MISMATCH 20 /* Data type mismatch */ +#define SQLITE_MISUSE 21 /* Library used incorrectly */ +#define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ +#define SQLITE_AUTH 23 /* Authorization denied */ +#define SQLITE_FORMAT 24 /* Auxiliary database format error */ +#define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ +#define SQLITE_NOTADB 26 /* File opened that is not a database file */ +#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ +#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ +/* end-of-error-codes */ + +/* +** CAPI3REF: Extended Result Codes +** KEYWORDS: {extended error code} {extended error codes} +** KEYWORDS: {extended result code} {extended result codes} +** +** In its default configuration, SQLite API routines return one of 26 integer +** [SQLITE_OK | result codes]. However, experience has shown that many of +** these result codes are too coarse-grained. They do not provide as +** much information about problems as programmers might like. In an effort to +** address this, newer versions of SQLite (version 3.3.8 and later) include +** support for additional result codes that provide more detailed information +** about errors. The extended result codes are enabled or disabled +** on a per database connection basis using the +** [sqlite3_extended_result_codes()] API. +** +** Some of the available extended result codes are listed here. +** One may expect the number of extended result codes will be expand +** over time. Software that uses extended result codes should expect +** to see new result codes in future releases of SQLite. +** +** The SQLITE_OK result code will never be extended. It will always +** be exactly zero. +*/ +#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8)) +#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8)) +#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8)) +#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8)) +#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8)) +#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8)) +#define SQLITE_IOERR_FSTAT (SQLITE_IOERR | (7<<8)) +#define SQLITE_IOERR_UNLOCK (SQLITE_IOERR | (8<<8)) +#define SQLITE_IOERR_RDLOCK (SQLITE_IOERR | (9<<8)) +#define SQLITE_IOERR_DELETE (SQLITE_IOERR | (10<<8)) +#define SQLITE_IOERR_BLOCKED (SQLITE_IOERR | (11<<8)) +#define SQLITE_IOERR_NOMEM (SQLITE_IOERR | (12<<8)) +#define SQLITE_IOERR_ACCESS (SQLITE_IOERR | (13<<8)) +#define SQLITE_IOERR_CHECKRESERVEDLOCK (SQLITE_IOERR | (14<<8)) +#define SQLITE_IOERR_LOCK (SQLITE_IOERR | (15<<8)) +#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) +#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) +#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) + +/* +** CAPI3REF: Flags For File Open Operations +** +** These bit values are intended for use in the +** 3rd parameter to the [sqlite3_open_v2()] interface and +** in the 4th parameter to the xOpen method of the +** [sqlite3_vfs] object. +*/ +#define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */ +#define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */ +#define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */ +#define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */ +#define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */ +#define SQLITE_OPEN_MAIN_JOURNAL 0x00000800 /* VFS only */ +#define SQLITE_OPEN_TEMP_JOURNAL 0x00001000 /* VFS only */ +#define SQLITE_OPEN_SUBJOURNAL 0x00002000 /* VFS only */ +#define SQLITE_OPEN_MASTER_JOURNAL 0x00004000 /* VFS only */ +#define SQLITE_OPEN_NOMUTEX 0x00008000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ +#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ + +/* +** CAPI3REF: Device Characteristics +** +** The xDeviceCapabilities method of the [sqlite3_io_methods] +** object returns an integer which is a vector of the these +** bit values expressing I/O characteristics of the mass storage +** device that holds the file that the [sqlite3_io_methods] +** refers to. +** +** The SQLITE_IOCAP_ATOMIC property means that all writes of +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +** mean that writes of blocks that are nnn bytes in size and +** are aligned to an address which is an integer multiple of +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +** that when data is appended to a file, the data is appended +** first then the size of the file is extended, never the other +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +** information is written to disk in the same order as calls +** to xWrite(). +*/ +#define SQLITE_IOCAP_ATOMIC 0x00000001 +#define SQLITE_IOCAP_ATOMIC512 0x00000002 +#define SQLITE_IOCAP_ATOMIC1K 0x00000004 +#define SQLITE_IOCAP_ATOMIC2K 0x00000008 +#define SQLITE_IOCAP_ATOMIC4K 0x00000010 +#define SQLITE_IOCAP_ATOMIC8K 0x00000020 +#define SQLITE_IOCAP_ATOMIC16K 0x00000040 +#define SQLITE_IOCAP_ATOMIC32K 0x00000080 +#define SQLITE_IOCAP_ATOMIC64K 0x00000100 +#define SQLITE_IOCAP_SAFE_APPEND 0x00000200 +#define SQLITE_IOCAP_SEQUENTIAL 0x00000400 + +/* +** CAPI3REF: File Locking Levels +** +** SQLite uses one of these integer values as the second +** argument to calls it makes to the xLock() and xUnlock() methods +** of an [sqlite3_io_methods] object. +*/ +#define SQLITE_LOCK_NONE 0 +#define SQLITE_LOCK_SHARED 1 +#define SQLITE_LOCK_RESERVED 2 +#define SQLITE_LOCK_PENDING 3 +#define SQLITE_LOCK_EXCLUSIVE 4 + +/* +** CAPI3REF: Synchronization Type Flags +** +** When SQLite invokes the xSync() method of an +** [sqlite3_io_methods] object it uses a combination of +** these integer values as the second argument. +** +** When the SQLITE_SYNC_DATAONLY flag is used, it means that the +** sync operation only needs to flush data to mass storage. Inode +** information need not be flushed. If the lower four bits of the flag +** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics. +** If the lower four bits equal SQLITE_SYNC_FULL, that means +** to use Mac OS X style fullsync instead of fsync(). +*/ +#define SQLITE_SYNC_NORMAL 0x00002 +#define SQLITE_SYNC_FULL 0x00003 +#define SQLITE_SYNC_DATAONLY 0x00010 + +/* +** CAPI3REF: OS Interface Open File Handle +** +** An [sqlite3_file] object represents an open file in the +** [sqlite3_vfs | OS interface layer]. Individual OS interface +** implementations will +** want to subclass this object by appending additional fields +** for their own use. The pMethods entry is a pointer to an +** [sqlite3_io_methods] object that defines methods for performing +** I/O operations on the open file. +*/ +typedef struct sqlite3_file sqlite3_file; +struct sqlite3_file { + const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ +}; + +/* +** CAPI3REF: OS Interface File Virtual Methods Object +** +** Every file opened by the [sqlite3_vfs] xOpen method populates an +** [sqlite3_file] object (or, more commonly, a subclass of the +** [sqlite3_file] object) with a pointer to an instance of this object. +** This object defines the methods used to perform various operations +** against the open file represented by the [sqlite3_file] object. +** +** If the xOpen method sets the sqlite3_file.pMethods element +** to a non-NULL pointer, then the sqlite3_io_methods.xClose method +** may be invoked even if the xOpen reported that it failed. The +** only way to prevent a call to xClose following a failed xOpen +** is for the xOpen to set the sqlite3_file.pMethods element to NULL. +** +** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or +** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). +** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] +** flag may be ORed in to indicate that only the data of the file +** and not its inode needs to be synced. +** +** The integer values to xLock() and xUnlock() are one of +**
    +**
  • [SQLITE_LOCK_NONE], +**
  • [SQLITE_LOCK_SHARED], +**
  • [SQLITE_LOCK_RESERVED], +**
  • [SQLITE_LOCK_PENDING], or +**
  • [SQLITE_LOCK_EXCLUSIVE]. +**
+** xLock() increases the lock. xUnlock() decreases the lock. +** The xCheckReservedLock() method checks whether any database connection, +** either in this process or in some other process, is holding a RESERVED, +** PENDING, or EXCLUSIVE lock on the file. It returns true +** if such a lock exists and false otherwise. +** +** The xFileControl() method is a generic interface that allows custom +** VFS implementations to directly control an open file using the +** [sqlite3_file_control()] interface. The second "op" argument is an +** integer opcode. The third argument is a generic pointer intended to +** point to a structure that may contain arguments or space in which to +** write return values. Potential uses for xFileControl() might be +** functions to enable blocking locks with timeouts, to change the +** locking strategy (for example to use dot-file locks), to inquire +** about the status of a lock, or to break stale locks. The SQLite +** core reserves all opcodes less than 100 for its own use. +** A [SQLITE_FCNTL_LOCKSTATE | list of opcodes] less than 100 is available. +** Applications that define a custom xFileControl method should use opcodes +** greater than 100 to avoid conflicts. +** +** The xSectorSize() method returns the sector size of the +** device that underlies the file. The sector size is the +** minimum write that can be performed without disturbing +** other bytes in the file. The xDeviceCharacteristics() +** method returns a bit vector describing behaviors of the +** underlying device: +** +**
    +**
  • [SQLITE_IOCAP_ATOMIC] +**
  • [SQLITE_IOCAP_ATOMIC512] +**
  • [SQLITE_IOCAP_ATOMIC1K] +**
  • [SQLITE_IOCAP_ATOMIC2K] +**
  • [SQLITE_IOCAP_ATOMIC4K] +**
  • [SQLITE_IOCAP_ATOMIC8K] +**
  • [SQLITE_IOCAP_ATOMIC16K] +**
  • [SQLITE_IOCAP_ATOMIC32K] +**
  • [SQLITE_IOCAP_ATOMIC64K] +**
  • [SQLITE_IOCAP_SAFE_APPEND] +**
  • [SQLITE_IOCAP_SEQUENTIAL] +**
+** +** The SQLITE_IOCAP_ATOMIC property means that all writes of +** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values +** mean that writes of blocks that are nnn bytes in size and +** are aligned to an address which is an integer multiple of +** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means +** that when data is appended to a file, the data is appended +** first then the size of the file is extended, never the other +** way around. The SQLITE_IOCAP_SEQUENTIAL property means that +** information is written to disk in the same order as calls +** to xWrite(). +** +** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill +** in the unread portions of the buffer with zeros. A VFS that +** fails to zero-fill short reads might seem to work. However, +** failure to zero-fill short reads will eventually lead to +** database corruption. +*/ +typedef struct sqlite3_io_methods sqlite3_io_methods; +struct sqlite3_io_methods { + int iVersion; + int (*xClose)(sqlite3_file*); + int (*xRead)(sqlite3_file*, void*, int iAmt, sqlite3_int64 iOfst); + int (*xWrite)(sqlite3_file*, const void*, int iAmt, sqlite3_int64 iOfst); + int (*xTruncate)(sqlite3_file*, sqlite3_int64 size); + int (*xSync)(sqlite3_file*, int flags); + int (*xFileSize)(sqlite3_file*, sqlite3_int64 *pSize); + int (*xLock)(sqlite3_file*, int); + int (*xUnlock)(sqlite3_file*, int); + int (*xCheckReservedLock)(sqlite3_file*, int *pResOut); + int (*xFileControl)(sqlite3_file*, int op, void *pArg); + int (*xSectorSize)(sqlite3_file*); + int (*xDeviceCharacteristics)(sqlite3_file*); + /* Additional methods may be added in future releases */ +}; + +/* +** CAPI3REF: Standard File Control Opcodes +** +** These integer constants are opcodes for the xFileControl method +** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] +** interface. +** +** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This +** opcode causes the xFileControl method to write the current state of +** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED], +** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE]) +** into an integer that the pArg argument points to. This capability +** is used during testing and only needs to be supported when SQLITE_TEST +** is defined. +*/ +#define SQLITE_FCNTL_LOCKSTATE 1 +#define SQLITE_GET_LOCKPROXYFILE 2 +#define SQLITE_SET_LOCKPROXYFILE 3 +#define SQLITE_LAST_ERRNO 4 + +/* +** CAPI3REF: Mutex Handle +** +** The mutex module within SQLite defines [sqlite3_mutex] to be an +** abstract type for a mutex object. The SQLite core never looks +** at the internal representation of an [sqlite3_mutex]. It only +** deals with pointers to the [sqlite3_mutex] object. +** +** Mutexes are created using [sqlite3_mutex_alloc()]. +*/ +typedef struct sqlite3_mutex sqlite3_mutex; + +/* +** CAPI3REF: OS Interface Object +** +** An instance of the sqlite3_vfs object defines the interface between +** the SQLite core and the underlying operating system. The "vfs" +** in the name of the object stands for "virtual file system". +** +** The value of the iVersion field is initially 1 but may be larger in +** future versions of SQLite. Additional fields may be appended to this +** object when the iVersion value is increased. Note that the structure +** of the sqlite3_vfs object changes in the transaction between +** SQLite version 3.5.9 and 3.6.0 and yet the iVersion field was not +** modified. +** +** The szOsFile field is the size of the subclassed [sqlite3_file] +** structure used by this VFS. mxPathname is the maximum length of +** a pathname in this VFS. +** +** Registered sqlite3_vfs objects are kept on a linked list formed by +** the pNext pointer. The [sqlite3_vfs_register()] +** and [sqlite3_vfs_unregister()] interfaces manage this list +** in a thread-safe way. The [sqlite3_vfs_find()] interface +** searches the list. Neither the application code nor the VFS +** implementation should use the pNext pointer. +** +** The pNext field is the only field in the sqlite3_vfs +** structure that SQLite will ever modify. SQLite will only access +** or modify this field while holding a particular static mutex. +** The application should never modify anything within the sqlite3_vfs +** object once the object has been registered. +** +** The zName field holds the name of the VFS module. The name must +** be unique across all VFS modules. +** +** SQLite will guarantee that the zFilename parameter to xOpen +** is either a NULL pointer or string obtained +** from xFullPathname(). SQLite further guarantees that +** the string will be valid and unchanged until xClose() is +** called. Because of the previous sentence, +** the [sqlite3_file] can safely store a pointer to the +** filename if it needs to remember the filename for some reason. +** If the zFilename parameter is xOpen is a NULL pointer then xOpen +** must invent its own temporary name for the file. Whenever the +** xFilename parameter is NULL it will also be the case that the +** flags parameter will include [SQLITE_OPEN_DELETEONCLOSE]. +** +** The flags argument to xOpen() includes all bits set in +** the flags argument to [sqlite3_open_v2()]. Or if [sqlite3_open()] +** or [sqlite3_open16()] is used, then flags includes at least +** [SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]. +** If xOpen() opens a file read-only then it sets *pOutFlags to +** include [SQLITE_OPEN_READONLY]. Other bits in *pOutFlags may be set. +** +** SQLite will also add one of the following flags to the xOpen() +** call, depending on the object being opened: +** +**
    +**
  • [SQLITE_OPEN_MAIN_DB] +**
  • [SQLITE_OPEN_MAIN_JOURNAL] +**
  • [SQLITE_OPEN_TEMP_DB] +**
  • [SQLITE_OPEN_TEMP_JOURNAL] +**
  • [SQLITE_OPEN_TRANSIENT_DB] +**
  • [SQLITE_OPEN_SUBJOURNAL] +**
  • [SQLITE_OPEN_MASTER_JOURNAL] +**
+** +** The file I/O implementation can use the object type flags to +** change the way it deals with files. For example, an application +** that does not care about crash recovery or rollback might make +** the open of a journal file a no-op. Writes to this journal would +** also be no-ops, and any attempt to read the journal would return +** SQLITE_IOERR. Or the implementation might recognize that a database +** file will be doing page-aligned sector reads and writes in a random +** order and set up its I/O subsystem accordingly. +** +** SQLite might also add one of the following flags to the xOpen method: +** +**
    +**
  • [SQLITE_OPEN_DELETEONCLOSE] +**
  • [SQLITE_OPEN_EXCLUSIVE] +**
+** +** The [SQLITE_OPEN_DELETEONCLOSE] flag means the file should be +** deleted when it is closed. The [SQLITE_OPEN_DELETEONCLOSE] +** will be set for TEMP databases, journals and for subjournals. +** +** The [SQLITE_OPEN_EXCLUSIVE] flag is always used in conjunction +** with the [SQLITE_OPEN_CREATE] flag, which are both directly +** analogous to the O_EXCL and O_CREAT flags of the POSIX open() +** API. The SQLITE_OPEN_EXCLUSIVE flag, when paired with the +** SQLITE_OPEN_CREATE, is used to indicate that file should always +** be created, and that it is an error if it already exists. +** It is not used to indicate the file should be opened +** for exclusive access. +** +** At least szOsFile bytes of memory are allocated by SQLite +** to hold the [sqlite3_file] structure passed as the third +** argument to xOpen. The xOpen method does not have to +** allocate the structure; it should just fill it in. Note that +** the xOpen method must set the sqlite3_file.pMethods to either +** a valid [sqlite3_io_methods] object or to NULL. xOpen must do +** this even if the open fails. SQLite expects that the sqlite3_file.pMethods +** element will be valid after xOpen returns regardless of the success +** or failure of the xOpen call. +** +** The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS] +** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to +** test whether a file is readable and writable, or [SQLITE_ACCESS_READ] +** to test whether a file is at least readable. The file can be a +** directory. +** +** SQLite will always allocate at least mxPathname+1 bytes for the +** output buffer xFullPathname. The exact size of the output buffer +** is also passed as a parameter to both methods. If the output buffer +** is not large enough, [SQLITE_CANTOPEN] should be returned. Since this is +** handled as a fatal error by SQLite, vfs implementations should endeavor +** to prevent this by setting mxPathname to a sufficiently large value. +** +** The xRandomness(), xSleep(), and xCurrentTime() interfaces +** are not strictly a part of the filesystem, but they are +** included in the VFS structure for completeness. +** The xRandomness() function attempts to return nBytes bytes +** of good-quality randomness into zOut. The return value is +** the actual number of bytes of randomness obtained. +** The xSleep() method causes the calling thread to sleep for at +** least the number of microseconds given. The xCurrentTime() +** method returns a Julian Day Number for the current date and time. +** +*/ +typedef struct sqlite3_vfs sqlite3_vfs; +struct sqlite3_vfs { + int iVersion; /* Structure version number */ + int szOsFile; /* Size of subclassed sqlite3_file */ + int mxPathname; /* Maximum file pathname length */ + sqlite3_vfs *pNext; /* Next registered VFS */ + const char *zName; /* Name of this virtual file system */ + void *pAppData; /* Pointer to application-specific data */ + int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*, + int flags, int *pOutFlags); + int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir); + int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut); + int (*xFullPathname)(sqlite3_vfs*, const char *zName, int nOut, char *zOut); + void *(*xDlOpen)(sqlite3_vfs*, const char *zFilename); + void (*xDlError)(sqlite3_vfs*, int nByte, char *zErrMsg); + void (*(*xDlSym)(sqlite3_vfs*,void*, const char *zSymbol))(void); + void (*xDlClose)(sqlite3_vfs*, void*); + int (*xRandomness)(sqlite3_vfs*, int nByte, char *zOut); + int (*xSleep)(sqlite3_vfs*, int microseconds); + int (*xCurrentTime)(sqlite3_vfs*, double*); + int (*xGetLastError)(sqlite3_vfs*, int, char *); + /* New fields may be appended in figure versions. The iVersion + ** value will increment whenever this happens. */ +}; + +/* +** CAPI3REF: Flags for the xAccess VFS method +** +** These integer constants can be used as the third parameter to +** the xAccess method of an [sqlite3_vfs] object. They determine +** what kind of permissions the xAccess method is looking for. +** With SQLITE_ACCESS_EXISTS, the xAccess method +** simply checks whether the file exists. +** With SQLITE_ACCESS_READWRITE, the xAccess method +** checks whether the file is both readable and writable. +** With SQLITE_ACCESS_READ, the xAccess method +** checks whether the file is readable. +*/ +#define SQLITE_ACCESS_EXISTS 0 +#define SQLITE_ACCESS_READWRITE 1 +#define SQLITE_ACCESS_READ 2 + +/* +** CAPI3REF: Initialize The SQLite Library +** +** ^The sqlite3_initialize() routine initializes the +** SQLite library. ^The sqlite3_shutdown() routine +** deallocates any resources that were allocated by sqlite3_initialize(). +** These routines are designed to aid in process initialization and +** shutdown on embedded systems. Workstation applications using +** SQLite normally do not need to invoke either of these routines. +** +** A call to sqlite3_initialize() is an "effective" call if it is +** the first time sqlite3_initialize() is invoked during the lifetime of +** the process, or if it is the first time sqlite3_initialize() is invoked +** following a call to sqlite3_shutdown(). ^(Only an effective call +** of sqlite3_initialize() does any initialization. All other calls +** are harmless no-ops.)^ +** +** A call to sqlite3_shutdown() is an "effective" call if it is the first +** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only +** an effective call to sqlite3_shutdown() does any deinitialization. +** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^ +** +** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() +** is not. The sqlite3_shutdown() interface must only be called from a +** single thread. All open [database connections] must be closed and all +** other SQLite resources must be deallocated prior to invoking +** sqlite3_shutdown(). +** +** Among other things, ^sqlite3_initialize() will invoke +** sqlite3_os_init(). Similarly, ^sqlite3_shutdown() +** will invoke sqlite3_os_end(). +** +** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success. +** ^If for some reason, sqlite3_initialize() is unable to initialize +** the library (perhaps it is unable to allocate a needed resource such +** as a mutex) it returns an [error code] other than [SQLITE_OK]. +** +** ^The sqlite3_initialize() routine is called internally by many other +** SQLite interfaces so that an application usually does not need to +** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] +** calls sqlite3_initialize() so the SQLite library will be automatically +** initialized when [sqlite3_open()] is called if it has not be initialized +** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] +** compile-time option, then the automatic calls to sqlite3_initialize() +** are omitted and the application must call sqlite3_initialize() directly +** prior to using any other SQLite interface. For maximum portability, +** it is recommended that applications always invoke sqlite3_initialize() +** directly prior to using any other SQLite interface. Future releases +** of SQLite may require this. In other words, the behavior exhibited +** when SQLite is compiled with [SQLITE_OMIT_AUTOINIT] might become the +** default behavior in some future release of SQLite. +** +** The sqlite3_os_init() routine does operating-system specific +** initialization of the SQLite library. The sqlite3_os_end() +** routine undoes the effect of sqlite3_os_init(). Typical tasks +** performed by these routines include allocation or deallocation +** of static resources, initialization of global variables, +** setting up a default [sqlite3_vfs] module, or setting up +** a default configuration using [sqlite3_config()]. +** +** The application should never invoke either sqlite3_os_init() +** or sqlite3_os_end() directly. The application should only invoke +** sqlite3_initialize() and sqlite3_shutdown(). The sqlite3_os_init() +** interface is called automatically by sqlite3_initialize() and +** sqlite3_os_end() is called by sqlite3_shutdown(). Appropriate +** implementations for sqlite3_os_init() and sqlite3_os_end() +** are built into SQLite when it is compiled for Unix, Windows, or OS/2. +** When [custom builds | built for other platforms] +** (using the [SQLITE_OS_OTHER=1] compile-time +** option) the application must supply a suitable implementation for +** sqlite3_os_init() and sqlite3_os_end(). An application-supplied +** implementation of sqlite3_os_init() or sqlite3_os_end() +** must return [SQLITE_OK] on success and some other [error code] upon +** failure. +*/ +SQLITE_API int sqlite3_initialize(void); +SQLITE_API int sqlite3_shutdown(void); +SQLITE_API int sqlite3_os_init(void); +SQLITE_API int sqlite3_os_end(void); + +/* +** CAPI3REF: Configuring The SQLite Library +** EXPERIMENTAL +** +** The sqlite3_config() interface is used to make global configuration +** changes to SQLite in order to tune SQLite to the specific needs of +** the application. The default configuration is recommended for most +** applications and so this routine is usually not necessary. It is +** provided to support rare applications with unusual needs. +** +** The sqlite3_config() interface is not threadsafe. The application +** must insure that no other SQLite interfaces are invoked by other +** threads while sqlite3_config() is running. Furthermore, sqlite3_config() +** may only be invoked prior to library initialization using +** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()]. +** ^If sqlite3_config() is called after [sqlite3_initialize()] and before +** [sqlite3_shutdown()] then it will return SQLITE_MISUSE. +** Note, however, that ^sqlite3_config() can be called as part of the +** implementation of an application-defined [sqlite3_os_init()]. +** +** The first argument to sqlite3_config() is an integer +** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines +** what property of SQLite is to be configured. Subsequent arguments +** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] +** in the first argument. +** +** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK]. +** ^If the option is unknown or SQLite is unable to set the option +** then this routine returns a non-zero [error code]. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...); + +/* +** CAPI3REF: Configure database connections +** EXPERIMENTAL +** +** The sqlite3_db_config() interface is used to make configuration +** changes to a [database connection]. The interface is similar to +** [sqlite3_config()] except that the changes apply to a single +** [database connection] (specified in the first argument). The +** sqlite3_db_config() interface should only be used immediately after +** the database connection is created using [sqlite3_open()], +** [sqlite3_open16()], or [sqlite3_open_v2()]. +** +** The second argument to sqlite3_db_config(D,V,...) is the +** configuration verb - an integer code that indicates what +** aspect of the [database connection] is being configured. +** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. +** New verbs are likely to be added in future releases of SQLite. +** Additional arguments depend on the verb. +** +** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if +** the call is considered successful. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...); + +/* +** CAPI3REF: Memory Allocation Routines +** EXPERIMENTAL +** +** An instance of this object defines the interface between SQLite +** and low-level memory allocation routines. +** +** This object is used in only one place in the SQLite interface. +** A pointer to an instance of this object is the argument to +** [sqlite3_config()] when the configuration option is +** [SQLITE_CONFIG_MALLOC] or [SQLITE_CONFIG_GETMALLOC]. +** By creating an instance of this object +** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC]) +** during configuration, an application can specify an alternative +** memory allocation subsystem for SQLite to use for all of its +** dynamic memory needs. +** +** Note that SQLite comes with several [built-in memory allocators] +** that are perfectly adequate for the overwhelming majority of applications +** and that this object is only useful to a tiny minority of applications +** with specialized memory allocation requirements. This object is +** also used during testing of SQLite in order to specify an alternative +** memory allocator that simulates memory out-of-memory conditions in +** order to verify that SQLite recovers gracefully from such +** conditions. +** +** The xMalloc and xFree methods must work like the +** malloc() and free() functions from the standard C library. +** The xRealloc method must work like realloc() from the standard C library +** with the exception that if the second argument to xRealloc is zero, +** xRealloc must be a no-op - it must not perform any allocation or +** deallocation. ^SQLite guarantees that the second argument to +** xRealloc is always a value returned by a prior call to xRoundup. +** And so in cases where xRoundup always returns a positive number, +** xRealloc can perform exactly as the standard library realloc() and +** still be in compliance with this specification. +** +** xSize should return the allocated size of a memory allocation +** previously obtained from xMalloc or xRealloc. The allocated size +** is always at least as big as the requested size but may be larger. +** +** The xRoundup method returns what would be the allocated size of +** a memory allocation given a particular requested size. Most memory +** allocators round up memory allocations at least to the next multiple +** of 8. Some allocators round up to a larger multiple or to a power of 2. +** Every memory allocation request coming in through [sqlite3_malloc()] +** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, +** that causes the corresponding memory allocation to fail. +** +** The xInit method initializes the memory allocator. (For example, +** it might allocate any require mutexes or initialize internal data +** structures. The xShutdown method is invoked (indirectly) by +** [sqlite3_shutdown()] and should deallocate any resources acquired +** by xInit. The pAppData pointer is used as the only parameter to +** xInit and xShutdown. +** +** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes +** the xInit method, so the xInit method need not be threadsafe. The +** xShutdown method is only called from [sqlite3_shutdown()] so it does +** not need to be threadsafe either. For all other methods, SQLite +** holds the [SQLITE_MUTEX_STATIC_MEM] mutex as long as the +** [SQLITE_CONFIG_MEMSTATUS] configuration option is turned on (which +** it is by default) and so the methods are automatically serialized. +** However, if [SQLITE_CONFIG_MEMSTATUS] is disabled, then the other +** methods must be threadsafe or else make their own arrangements for +** serialization. +** +** SQLite will never invoke xInit() more than once without an intervening +** call to xShutdown(). +*/ +typedef struct sqlite3_mem_methods sqlite3_mem_methods; +struct sqlite3_mem_methods { + void *(*xMalloc)(int); /* Memory allocation function */ + void (*xFree)(void*); /* Free a prior allocation */ + void *(*xRealloc)(void*,int); /* Resize an allocation */ + int (*xSize)(void*); /* Return the size of an allocation */ + int (*xRoundup)(int); /* Round up request size to allocation size */ + int (*xInit)(void*); /* Initialize the memory allocator */ + void (*xShutdown)(void*); /* Deinitialize the memory allocator */ + void *pAppData; /* Argument to xInit() and xShutdown() */ +}; + +/* +** CAPI3REF: Configuration Options +** EXPERIMENTAL +** +** These constants are the available integer configuration options that +** can be passed as the first argument to the [sqlite3_config()] interface. +** +** New configuration options may be added in future releases of SQLite. +** Existing configuration options might be discontinued. Applications +** should check the return code from [sqlite3_config()] to make sure that +** the call worked. The [sqlite3_config()] interface will return a +** non-zero [error code] if a discontinued or unsupported configuration option +** is invoked. +** +**
+**
SQLITE_CONFIG_SINGLETHREAD
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Single-thread. In other words, it disables +** all mutexing and puts SQLite into a mode where it can only be used +** by a single thread. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to change the [threading mode] from its default +** value of Single-thread and so [sqlite3_config()] will return +** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD +** configuration option.
+** +**
SQLITE_CONFIG_MULTITHREAD
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Multi-thread. In other words, it disables +** mutexing on [database connection] and [prepared statement] objects. +** The application is responsible for serializing access to +** [database connections] and [prepared statements]. But other mutexes +** are enabled so that SQLite will be safe to use in a multi-threaded +** environment as long as no two threads attempt to use the same +** [database connection] at the same time. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to set the Multi-thread [threading mode] and +** [sqlite3_config()] will return [SQLITE_ERROR] if called with the +** SQLITE_CONFIG_MULTITHREAD configuration option.
+** +**
SQLITE_CONFIG_SERIALIZED
+**
There are no arguments to this option. ^This option sets the +** [threading mode] to Serialized. In other words, this option enables +** all mutexes including the recursive +** mutexes on [database connection] and [prepared statement] objects. +** In this mode (which is the default when SQLite is compiled with +** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access +** to [database connections] and [prepared statements] so that the +** application is free to use the same [database connection] or the +** same [prepared statement] in different threads at the same time. +** ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** it is not possible to set the Serialized [threading mode] and +** [sqlite3_config()] will return [SQLITE_ERROR] if called with the +** SQLITE_CONFIG_SERIALIZED configuration option.
+** +**
SQLITE_CONFIG_MALLOC
+**
^(This option takes a single argument which is a pointer to an +** instance of the [sqlite3_mem_methods] structure. The argument specifies +** alternative low-level memory allocation routines to be used in place of +** the memory allocation routines built into SQLite.)^ ^SQLite makes +** its own private copy of the content of the [sqlite3_mem_methods] structure +** before the [sqlite3_config()] call returns.
+** +**
SQLITE_CONFIG_GETMALLOC
+**
^(This option takes a single argument which is a pointer to an +** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods] +** structure is filled with the currently defined memory allocation routines.)^ +** This option can be used to overload the default memory allocation +** routines with a wrapper that simulations memory allocation failure or +** tracks memory usage, for example.
+** +**
SQLITE_CONFIG_MEMSTATUS
+**
^This option takes single argument of type int, interpreted as a +** boolean, which enables or disables the collection of memory allocation +** statistics. ^(When memory allocation statistics are disabled, the +** following SQLite interfaces become non-operational: +**
    +**
  • [sqlite3_memory_used()] +**
  • [sqlite3_memory_highwater()] +**
  • [sqlite3_soft_heap_limit()] +**
  • [sqlite3_status()] +**
)^ +** ^Memory allocation statistics are enabled by default unless SQLite is +** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory +** allocation statistics are disabled by default. +**
+** +**
SQLITE_CONFIG_SCRATCH
+**
^This option specifies a static memory buffer that SQLite can use for +** scratch memory. There are three arguments: A pointer an 8-byte +** aligned memory buffer from which the scrach allocations will be +** drawn, the size of each scratch allocation (sz), +** and the maximum number of scratch allocations (N). The sz +** argument must be a multiple of 16. The sz parameter should be a few bytes +** larger than the actual scratch space required due to internal overhead. +** The first argument must be a pointer to an 8-byte aligned buffer +** of at least sz*N bytes of memory. +** ^SQLite will use no more than one scratch buffer per thread. So +** N should be set to the expected maximum number of threads. ^SQLite will +** never require a scratch buffer that is more than 6 times the database +** page size. ^If SQLite needs needs additional scratch memory beyond +** what is provided by this configuration option, then +** [sqlite3_malloc()] will be used to obtain the memory needed.
+** +**
SQLITE_CONFIG_PAGECACHE
+**
^This option specifies a static memory buffer that SQLite can use for +** the database page cache with the default page cache implemenation. +** This configuration should not be used if an application-define page +** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. +** There are three arguments to this option: A pointer to 8-byte aligned +** memory, the size of each page buffer (sz), and the number of pages (N). +** The sz argument should be the size of the largest database page +** (a power of two between 512 and 32768) plus a little extra for each +** page header. ^The page header size is 20 to 40 bytes depending on +** the host architecture. ^It is harmless, apart from the wasted memory, +** to make sz a little too large. The first +** argument should point to an allocation of at least sz*N bytes of memory. +** ^SQLite will use the memory provided by the first argument to satisfy its +** memory needs for the first N pages that it adds to cache. ^If additional +** page cache memory is needed beyond what is provided by this option, then +** SQLite goes to [sqlite3_malloc()] for the additional storage space. +** ^The implementation might use one or more of the N buffers to hold +** memory accounting information. The pointer in the first argument must +** be aligned to an 8-byte boundary or subsequent behavior of SQLite +** will be undefined.
+** +**
SQLITE_CONFIG_HEAP
+**
^This option specifies a static memory buffer that SQLite will use +** for all of its dynamic memory allocation needs beyond those provided +** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. +** There are three arguments: An 8-byte aligned pointer to the memory, +** the number of bytes in the memory buffer, and the minimum allocation size. +** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts +** to using its default memory allocator (the system malloc() implementation), +** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the +** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or +** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory +** allocator is engaged to handle all of SQLites memory allocation needs. +** The first pointer (the memory pointer) must be aligned to an 8-byte +** boundary or subsequent behavior of SQLite will be undefined.
+** +**
SQLITE_CONFIG_MUTEX
+**
^(This option takes a single argument which is a pointer to an +** instance of the [sqlite3_mutex_methods] structure. The argument specifies +** alternative low-level mutex routines to be used in place +** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the +** content of the [sqlite3_mutex_methods] structure before the call to +** [sqlite3_config()] returns. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** the entire mutexing subsystem is omitted from the build and hence calls to +** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will +** return [SQLITE_ERROR].
+** +**
SQLITE_CONFIG_GETMUTEX
+**
^(This option takes a single argument which is a pointer to an +** instance of the [sqlite3_mutex_methods] structure. The +** [sqlite3_mutex_methods] +** structure is filled with the currently defined mutex routines.)^ +** This option can be used to overload the default mutex allocation +** routines with a wrapper used to track mutex usage for performance +** profiling or testing, for example. ^If SQLite is compiled with +** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then +** the entire mutexing subsystem is omitted from the build and hence calls to +** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will +** return [SQLITE_ERROR].
+** +**
SQLITE_CONFIG_LOOKASIDE
+**
^(This option takes two arguments that determine the default +** memory allocation for the lookaside memory allocator on each +** [database connection]. The first argument is the +** size of each lookaside buffer slot and the second is the number of +** slots allocated to each database connection.)^ ^(This option sets the +** default lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE] +** verb to [sqlite3_db_config()] can be used to change the lookaside +** configuration on individual connections.)^
+** +**
SQLITE_CONFIG_PCACHE
+**
^(This option takes a single argument which is a pointer to +** an [sqlite3_pcache_methods] object. This object specifies the interface +** to a custom page cache implementation.)^ ^SQLite makes a copy of the +** object and uses it for page cache memory allocations.
+** +**
SQLITE_CONFIG_GETPCACHE
+**
^(This option takes a single argument which is a pointer to an +** [sqlite3_pcache_methods] object. SQLite copies of the current +** page cache implementation into that object.)^
+** +**
+*/ +#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ +#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ +#define SQLITE_CONFIG_SERIALIZED 3 /* nil */ +#define SQLITE_CONFIG_MALLOC 4 /* sqlite3_mem_methods* */ +#define SQLITE_CONFIG_GETMALLOC 5 /* sqlite3_mem_methods* */ +#define SQLITE_CONFIG_SCRATCH 6 /* void*, int sz, int N */ +#define SQLITE_CONFIG_PAGECACHE 7 /* void*, int sz, int N */ +#define SQLITE_CONFIG_HEAP 8 /* void*, int nByte, int min */ +#define SQLITE_CONFIG_MEMSTATUS 9 /* boolean */ +#define SQLITE_CONFIG_MUTEX 10 /* sqlite3_mutex_methods* */ +#define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */ +/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */ +#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ +#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ +#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ + +/* +** CAPI3REF: Configuration Options +** EXPERIMENTAL +** +** These constants are the available integer configuration options that +** can be passed as the second argument to the [sqlite3_db_config()] interface. +** +** New configuration options may be added in future releases of SQLite. +** Existing configuration options might be discontinued. Applications +** should check the return code from [sqlite3_db_config()] to make sure that +** the call worked. ^The [sqlite3_db_config()] interface will return a +** non-zero [error code] if a discontinued or unsupported configuration option +** is invoked. +** +**
+**
SQLITE_DBCONFIG_LOOKASIDE
+**
^This option takes three additional arguments that determine the +** [lookaside memory allocator] configuration for the [database connection]. +** ^The first argument (the third parameter to [sqlite3_db_config()] is a +** pointer to an memory buffer to use for lookaside memory. +** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb +** may be NULL in which case SQLite will allocate the +** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the +** size of each lookaside buffer slot. ^The third argument is the number of +** slots. The size of the buffer in the first argument must be greater than +** or equal to the product of the second and third arguments. The buffer +** must be aligned to an 8-byte boundary. ^If the second argument to +** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally +** rounded down to the next smaller +** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]
+** +**
+*/ +#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ + + +/* +** CAPI3REF: Enable Or Disable Extended Result Codes +** +** ^The sqlite3_extended_result_codes() routine enables or disables the +** [extended result codes] feature of SQLite. ^The extended result +** codes are disabled by default for historical compatibility. +*/ +SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); + +/* +** CAPI3REF: Last Insert Rowid +** +** ^Each entry in an SQLite table has a unique 64-bit signed +** integer key called the [ROWID | "rowid"]. ^The rowid is always available +** as an undeclared column named ROWID, OID, or _ROWID_ as long as those +** names are not also used by explicitly declared columns. ^If +** the table has a column of type [INTEGER PRIMARY KEY] then that column +** is another alias for the rowid. +** +** ^This routine returns the [rowid] of the most recent +** successful [INSERT] into the database from the [database connection] +** in the first argument. ^If no successful [INSERT]s +** have ever occurred on that database connection, zero is returned. +** +** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted +** row is returned by this routine as long as the trigger is running. +** But once the trigger terminates, the value returned by this routine +** reverts to the last value inserted before the trigger fired.)^ +** +** ^An [INSERT] that fails due to a constraint violation is not a +** successful [INSERT] and does not change the value returned by this +** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK, +** and INSERT OR ABORT make no changes to the return value of this +** routine when their insertion fails. ^(When INSERT OR REPLACE +** encounters a constraint violation, it does not fail. The +** INSERT continues to completion after deleting rows that caused +** the constraint problem so INSERT OR REPLACE will always change +** the return value of this interface.)^ +** +** ^For the purposes of this routine, an [INSERT] is considered to +** be successful even if it is subsequently rolled back. +** +** This function is accessible to SQL statements via the +** [last_insert_rowid() SQL function]. +** +** If a separate thread performs a new [INSERT] on the same +** database connection while the [sqlite3_last_insert_rowid()] +** function is running and thus changes the last insert [rowid], +** then the value returned by [sqlite3_last_insert_rowid()] is +** unpredictable and might not equal either the old or the new +** last insert [rowid]. +*/ +SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); + +/* +** CAPI3REF: Count The Number Of Rows Modified +** +** ^This function returns the number of database rows that were changed +** or inserted or deleted by the most recently completed SQL statement +** on the [database connection] specified by the first parameter. +** ^(Only changes that are directly specified by the [INSERT], [UPDATE], +** or [DELETE] statement are counted. Auxiliary changes caused by +** triggers or [foreign key actions] are not counted.)^ Use the +** [sqlite3_total_changes()] function to find the total number of changes +** including changes caused by triggers and foreign key actions. +** +** ^Changes to a view that are simulated by an [INSTEAD OF trigger] +** are not counted. Only real table changes are counted. +** +** ^(A "row change" is a change to a single row of a single table +** caused by an INSERT, DELETE, or UPDATE statement. Rows that +** are changed as side effects of [REPLACE] constraint resolution, +** rollback, ABORT processing, [DROP TABLE], or by any other +** mechanisms do not count as direct row changes.)^ +** +** A "trigger context" is a scope of execution that begins and +** ends with the script of a [CREATE TRIGGER | trigger]. +** Most SQL statements are +** evaluated outside of any trigger. This is the "top level" +** trigger context. If a trigger fires from the top level, a +** new trigger context is entered for the duration of that one +** trigger. Subtriggers create subcontexts for their duration. +** +** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does +** not create a new trigger context. +** +** ^This function returns the number of direct row changes in the +** most recent INSERT, UPDATE, or DELETE statement within the same +** trigger context. +** +** ^Thus, when called from the top level, this function returns the +** number of changes in the most recent INSERT, UPDATE, or DELETE +** that also occurred at the top level. ^(Within the body of a trigger, +** the sqlite3_changes() interface can be called to find the number of +** changes in the most recently completed INSERT, UPDATE, or DELETE +** statement within the body of the same trigger. +** However, the number returned does not include changes +** caused by subtriggers since those have their own context.)^ +** +** See also the [sqlite3_total_changes()] interface, the +** [count_changes pragma], and the [changes() SQL function]. +** +** If a separate thread makes changes on the same database connection +** while [sqlite3_changes()] is running then the value returned +** is unpredictable and not meaningful. +*/ +SQLITE_API int sqlite3_changes(sqlite3*); + +/* +** CAPI3REF: Total Number Of Rows Modified +** +** ^This function returns the number of row changes caused by [INSERT], +** [UPDATE] or [DELETE] statements since the [database connection] was opened. +** ^(The count returned by sqlite3_total_changes() includes all changes +** from all [CREATE TRIGGER | trigger] contexts and changes made by +** [foreign key actions]. However, +** the count does not include changes used to implement [REPLACE] constraints, +** do rollbacks or ABORT processing, or [DROP TABLE] processing. The +** count does not include rows of views that fire an [INSTEAD OF trigger], +** though if the INSTEAD OF trigger makes changes of its own, those changes +** are counted.)^ +** ^The sqlite3_total_changes() function counts the changes as soon as +** the statement that makes them is completed (when the statement handle +** is passed to [sqlite3_reset()] or [sqlite3_finalize()]). +** +** See also the [sqlite3_changes()] interface, the +** [count_changes pragma], and the [total_changes() SQL function]. +** +** If a separate thread makes changes on the same database connection +** while [sqlite3_total_changes()] is running then the value +** returned is unpredictable and not meaningful. +*/ +SQLITE_API int sqlite3_total_changes(sqlite3*); + +/* +** CAPI3REF: Interrupt A Long-Running Query +** +** ^This function causes any pending database operation to abort and +** return at its earliest opportunity. This routine is typically +** called in response to a user action such as pressing "Cancel" +** or Ctrl-C where the user wants a long query operation to halt +** immediately. +** +** ^It is safe to call this routine from a thread different from the +** thread that is currently running the database operation. But it +** is not safe to call this routine with a [database connection] that +** is closed or might close before sqlite3_interrupt() returns. +** +** ^If an SQL operation is very nearly finished at the time when +** sqlite3_interrupt() is called, then it might not have an opportunity +** to be interrupted and might continue to completion. +** +** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT]. +** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE +** that is inside an explicit transaction, then the entire transaction +** will be rolled back automatically. +** +** ^The sqlite3_interrupt(D) call is in effect until all currently running +** SQL statements on [database connection] D complete. ^Any new SQL statements +** that are started after the sqlite3_interrupt() call and before the +** running statements reaches zero are interrupted as if they had been +** running prior to the sqlite3_interrupt() call. ^New SQL statements +** that are started after the running statement count reaches zero are +** not effected by the sqlite3_interrupt(). +** ^A call to sqlite3_interrupt(D) that occurs when there are no running +** SQL statements is a no-op and has no effect on SQL statements +** that are started after the sqlite3_interrupt() call returns. +** +** If the database connection closes while [sqlite3_interrupt()] +** is running then bad things will likely happen. +*/ +SQLITE_API void sqlite3_interrupt(sqlite3*); + +/* +** CAPI3REF: Determine If An SQL Statement Is Complete +** +** These routines are useful during command-line input to determine if the +** currently entered text seems to form a complete SQL statement or +** if additional input is needed before sending the text into +** SQLite for parsing. ^These routines return 1 if the input string +** appears to be a complete SQL statement. ^A statement is judged to be +** complete if it ends with a semicolon token and is not a prefix of a +** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within +** string literals or quoted identifier names or comments are not +** independent tokens (they are part of the token in which they are +** embedded) and thus do not count as a statement terminator. ^Whitespace +** and comments that follow the final semicolon are ignored. +** +** ^These routines return 0 if the statement is incomplete. ^If a +** memory allocation fails, then SQLITE_NOMEM is returned. +** +** ^These routines do not parse the SQL statements thus +** will not detect syntactically incorrect SQL. +** +** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior +** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked +** automatically by sqlite3_complete16(). If that initialization fails, +** then the return value from sqlite3_complete16() will be non-zero +** regardless of whether or not the input SQL is complete.)^ +** +** The input to [sqlite3_complete()] must be a zero-terminated +** UTF-8 string. +** +** The input to [sqlite3_complete16()] must be a zero-terminated +** UTF-16 string in native byte order. +*/ +SQLITE_API int sqlite3_complete(const char *sql); +SQLITE_API int sqlite3_complete16(const void *sql); + +/* +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors +** +** ^This routine sets a callback function that might be invoked whenever +** an attempt is made to open a database table that another thread +** or process has locked. +** +** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] +** is returned immediately upon encountering the lock. ^If the busy callback +** is not NULL, then the callback might be invoked with two arguments. +** +** ^The first argument to the busy handler is a copy of the void* pointer which +** is the third argument to sqlite3_busy_handler(). ^The second argument to +** the busy handler callback is the number of times that the busy handler has +** been invoked for this locking event. ^If the +** busy callback returns 0, then no additional attempts are made to +** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned. +** ^If the callback returns non-zero, then another attempt +** is made to open the database for reading and the cycle repeats. +** +** The presence of a busy handler does not guarantee that it will be invoked +** when there is lock contention. ^If SQLite determines that invoking the busy +** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] +** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. +** Consider a scenario where one process is holding a read lock that +** it is trying to promote to a reserved lock and +** a second process is holding a reserved lock that it is trying +** to promote to an exclusive lock. The first process cannot proceed +** because it is blocked by the second and the second process cannot +** proceed because it is blocked by the first. If both processes +** invoke the busy handlers, neither will make any progress. Therefore, +** SQLite returns [SQLITE_BUSY] for the first process, hoping that this +** will induce the first process to release its read lock and allow +** the second process to proceed. +** +** ^The default busy callback is NULL. +** +** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] +** when SQLite is in the middle of a large transaction where all the +** changes will not fit into the in-memory cache. SQLite will +** already hold a RESERVED lock on the database file, but it needs +** to promote this lock to EXCLUSIVE so that it can spill cache +** pages into the database file without harm to concurrent +** readers. ^If it is unable to promote the lock, then the in-memory +** cache will be left in an inconsistent state and so the error +** code is promoted from the relatively benign [SQLITE_BUSY] to +** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion +** forces an automatic rollback of the changes. See the +** +** CorruptionFollowingBusyError wiki page for a discussion of why +** this is important. +** +** ^(There can only be a single busy handler defined for each +** [database connection]. Setting a new busy handler clears any +** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] +** will also set or clear the busy handler. +** +** The busy callback should not take any actions which modify the +** database connection that invoked the busy handler. Any such actions +** result in undefined behavior. +** +** A busy handler must not close the database connection +** or [prepared statement] that invoked the busy handler. +*/ +SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); + +/* +** CAPI3REF: Set A Busy Timeout +** +** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps +** for a specified amount of time when a table is locked. ^The handler +** will sleep multiple times until at least "ms" milliseconds of sleeping +** have accumulated. ^After at least "ms" milliseconds of sleeping, +** the handler returns 0 which causes [sqlite3_step()] to return +** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. +** +** ^Calling this routine with an argument less than or equal to zero +** turns off all busy handlers. +** +** ^(There can only be a single busy handler for a particular +** [database connection] any any given moment. If another busy handler +** was defined (using [sqlite3_busy_handler()]) prior to calling +** this routine, that other busy handler is cleared.)^ +*/ +SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); + +/* +** CAPI3REF: Convenience Routines For Running Queries +** +** Definition: A result table is memory data structure created by the +** [sqlite3_get_table()] interface. A result table records the +** complete query results from one or more queries. +** +** The table conceptually has a number of rows and columns. But +** these numbers are not part of the result table itself. These +** numbers are obtained separately. Let N be the number of rows +** and M be the number of columns. +** +** A result table is an array of pointers to zero-terminated UTF-8 strings. +** There are (N+1)*M elements in the array. The first M pointers point +** to zero-terminated strings that contain the names of the columns. +** The remaining entries all point to query results. NULL values result +** in NULL pointers. All other values are in their UTF-8 zero-terminated +** string representation as returned by [sqlite3_column_text()]. +** +** A result table might consist of one or more memory allocations. +** It is not safe to pass a result table directly to [sqlite3_free()]. +** A result table should be deallocated using [sqlite3_free_table()]. +** +** As an example of the result table format, suppose a query result +** is as follows: +** +**
+**        Name        | Age
+**        -----------------------
+**        Alice       | 43
+**        Bob         | 28
+**        Cindy       | 21
+** 
+** +** There are two column (M==2) and three rows (N==3). Thus the +** result table has 8 entries. Suppose the result table is stored +** in an array names azResult. Then azResult holds this content: +** +**
+**        azResult[0] = "Name";
+**        azResult[1] = "Age";
+**        azResult[2] = "Alice";
+**        azResult[3] = "43";
+**        azResult[4] = "Bob";
+**        azResult[5] = "28";
+**        azResult[6] = "Cindy";
+**        azResult[7] = "21";
+** 
+** +** ^The sqlite3_get_table() function evaluates one or more +** semicolon-separated SQL statements in the zero-terminated UTF-8 +** string of its 2nd parameter and returns a result table to the +** pointer given in its 3rd parameter. +** +** After the application has finished with the result from sqlite3_get_table(), +** it should pass the result table pointer to sqlite3_free_table() in order to +** release the memory that was malloced. Because of the way the +** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling +** function must not try to call [sqlite3_free()] directly. Only +** [sqlite3_free_table()] is able to release the memory properly and safely. +** +** ^(The sqlite3_get_table() interface is implemented as a wrapper around +** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access +** to any internal data structures of SQLite. It uses only the public +** interface defined here. As a consequence, errors that occur in the +** wrapper layer outside of the internal [sqlite3_exec()] call are not +** reflected in subsequent calls to [sqlite3_errcode()] or +** [sqlite3_errmsg()].)^ +*/ +SQLITE_API int sqlite3_get_table( + sqlite3 *db, /* An open database */ + const char *zSql, /* SQL to be evaluated */ + char ***pazResult, /* Results of the query */ + int *pnRow, /* Number of result rows written here */ + int *pnColumn, /* Number of result columns written here */ + char **pzErrmsg /* Error msg written here */ +); +SQLITE_API void sqlite3_free_table(char **result); + +/* +** CAPI3REF: Formatted String Printing Functions +** +** These routines are work-alikes of the "printf()" family of functions +** from the standard C library. +** +** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their +** results into memory obtained from [sqlite3_malloc()]. +** The strings returned by these two routines should be +** released by [sqlite3_free()]. ^Both routines return a +** NULL pointer if [sqlite3_malloc()] is unable to allocate enough +** memory to hold the resulting string. +** +** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from +** the standard C library. The result is written into the +** buffer supplied as the second parameter whose size is given by +** the first parameter. Note that the order of the +** first two parameters is reversed from snprintf().)^ This is an +** historical accident that cannot be fixed without breaking +** backwards compatibility. ^(Note also that sqlite3_snprintf() +** returns a pointer to its buffer instead of the number of +** characters actually written into the buffer.)^ We admit that +** the number of characters written would be a more useful return +** value but we cannot change the implementation of sqlite3_snprintf() +** now without breaking compatibility. +** +** ^As long as the buffer size is greater than zero, sqlite3_snprintf() +** guarantees that the buffer is always zero-terminated. ^The first +** parameter "n" is the total size of the buffer, including space for +** the zero terminator. So the longest string that can be completely +** written will be n-1 characters. +** +** These routines all implement some additional formatting +** options that are useful for constructing SQL statements. +** All of the usual printf() formatting options apply. In addition, there +** is are "%q", "%Q", and "%z" options. +** +** ^(The %q option works like %s in that it substitutes a null-terminated +** string from the argument list. But %q also doubles every '\'' character. +** %q is designed for use inside a string literal.)^ By doubling each '\'' +** character it escapes that character and allows it to be inserted into +** the string. +** +** For example, assume the string variable zText contains text as follows: +** +**
+**  char *zText = "It's a happy day!";
+** 
+** +** One can use this text in an SQL statement as follows: +** +**
+**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES('%q')", zText);
+**  sqlite3_exec(db, zSQL, 0, 0, 0);
+**  sqlite3_free(zSQL);
+** 
+** +** Because the %q format string is used, the '\'' character in zText +** is escaped and the SQL generated is as follows: +** +**
+**  INSERT INTO table1 VALUES('It''s a happy day!')
+** 
+** +** This is correct. Had we used %s instead of %q, the generated SQL +** would have looked like this: +** +**
+**  INSERT INTO table1 VALUES('It's a happy day!');
+** 
+** +** This second example is an SQL syntax error. As a general rule you should +** always use %q instead of %s when inserting text into a string literal. +** +** ^(The %Q option works like %q except it also adds single quotes around +** the outside of the total string. Additionally, if the parameter in the +** argument list is a NULL pointer, %Q substitutes the text "NULL" (without +** single quotes).)^ So, for example, one could say: +** +**
+**  char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
+**  sqlite3_exec(db, zSQL, 0, 0, 0);
+**  sqlite3_free(zSQL);
+** 
+** +** The code above will render a correct SQL statement in the zSQL +** variable even if the zText variable is a NULL pointer. +** +** ^(The "%z" formatting option works like "%s" but with the +** addition that after the string has been read and copied into +** the result, [sqlite3_free()] is called on the input string.)^ +*/ +SQLITE_API char *sqlite3_mprintf(const char*,...); +SQLITE_API char *sqlite3_vmprintf(const char*, va_list); +SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); + +/* +** CAPI3REF: Memory Allocation Subsystem +** +** The SQLite core uses these three routines for all of its own +** internal memory allocation needs. "Core" in the previous sentence +** does not include operating-system specific VFS implementation. The +** Windows VFS uses native malloc() and free() for some operations. +** +** ^The sqlite3_malloc() routine returns a pointer to a block +** of memory at least N bytes in length, where N is the parameter. +** ^If sqlite3_malloc() is unable to obtain sufficient free +** memory, it returns a NULL pointer. ^If the parameter N to +** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns +** a NULL pointer. +** +** ^Calling sqlite3_free() with a pointer previously returned +** by sqlite3_malloc() or sqlite3_realloc() releases that memory so +** that it might be reused. ^The sqlite3_free() routine is +** a no-op if is called with a NULL pointer. Passing a NULL pointer +** to sqlite3_free() is harmless. After being freed, memory +** should neither be read nor written. Even reading previously freed +** memory might result in a segmentation fault or other severe error. +** Memory corruption, a segmentation fault, or other severe error +** might result if sqlite3_free() is called with a non-NULL pointer that +** was not obtained from sqlite3_malloc() or sqlite3_realloc(). +** +** ^(The sqlite3_realloc() interface attempts to resize a +** prior memory allocation to be at least N bytes, where N is the +** second parameter. The memory allocation to be resized is the first +** parameter.)^ ^ If the first parameter to sqlite3_realloc() +** is a NULL pointer then its behavior is identical to calling +** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc(). +** ^If the second parameter to sqlite3_realloc() is zero or +** negative then the behavior is exactly the same as calling +** sqlite3_free(P) where P is the first parameter to sqlite3_realloc(). +** ^sqlite3_realloc() returns a pointer to a memory allocation +** of at least N bytes in size or NULL if sufficient memory is unavailable. +** ^If M is the size of the prior allocation, then min(N,M) bytes +** of the prior allocation are copied into the beginning of buffer returned +** by sqlite3_realloc() and the prior allocation is freed. +** ^If sqlite3_realloc() returns NULL, then the prior allocation +** is not freed. +** +** ^The memory returned by sqlite3_malloc() and sqlite3_realloc() +** is always aligned to at least an 8 byte boundary. +** +** In SQLite version 3.5.0 and 3.5.1, it was possible to define +** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in +** implementation of these routines to be omitted. That capability +** is no longer provided. Only built-in memory allocators can be used. +** +** The Windows OS interface layer calls +** the system malloc() and free() directly when converting +** filenames between the UTF-8 encoding used by SQLite +** and whatever filename encoding is used by the particular Windows +** installation. Memory allocation errors are detected, but +** they are reported back as [SQLITE_CANTOPEN] or +** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. +** +** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] +** must be either NULL or else pointers obtained from a prior +** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have +** not yet been released. +** +** The application must not read or write any part of +** a block of memory after it has been released using +** [sqlite3_free()] or [sqlite3_realloc()]. +*/ +SQLITE_API void *sqlite3_malloc(int); +SQLITE_API void *sqlite3_realloc(void*, int); +SQLITE_API void sqlite3_free(void*); + +/* +** CAPI3REF: Memory Allocator Statistics +** +** SQLite provides these two interfaces for reporting on the status +** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] +** routines, which form the built-in memory allocation subsystem. +** +** ^The [sqlite3_memory_used()] routine returns the number of bytes +** of memory currently outstanding (malloced but not freed). +** ^The [sqlite3_memory_highwater()] routine returns the maximum +** value of [sqlite3_memory_used()] since the high-water mark +** was last reset. ^The values returned by [sqlite3_memory_used()] and +** [sqlite3_memory_highwater()] include any overhead +** added by SQLite in its implementation of [sqlite3_malloc()], +** but not overhead added by the any underlying system library +** routines that [sqlite3_malloc()] may call. +** +** ^The memory high-water mark is reset to the current value of +** [sqlite3_memory_used()] if and only if the parameter to +** [sqlite3_memory_highwater()] is true. ^The value returned +** by [sqlite3_memory_highwater(1)] is the high-water mark +** prior to the reset. +*/ +SQLITE_API sqlite3_int64 sqlite3_memory_used(void); +SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); + +/* +** CAPI3REF: Pseudo-Random Number Generator +** +** SQLite contains a high-quality pseudo-random number generator (PRNG) used to +** select random [ROWID | ROWIDs] when inserting new records into a table that +** already uses the largest possible [ROWID]. The PRNG is also used for +** the build-in random() and randomblob() SQL functions. This interface allows +** applications to access the same PRNG for other purposes. +** +** ^A call to this routine stores N bytes of randomness into buffer P. +** +** ^The first time this routine is invoked (either internally or by +** the application) the PRNG is seeded using randomness obtained +** from the xRandomness method of the default [sqlite3_vfs] object. +** ^On all subsequent invocations, the pseudo-randomness is generated +** internally and without recourse to the [sqlite3_vfs] xRandomness +** method. +*/ +SQLITE_API void sqlite3_randomness(int N, void *P); + +/* +** CAPI3REF: Compile-Time Authorization Callbacks +** +** ^This routine registers a authorizer callback with a particular +** [database connection], supplied in the first argument. +** ^The authorizer callback is invoked as SQL statements are being compiled +** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()], +** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various +** points during the compilation process, as logic is being created +** to perform various actions, the authorizer callback is invoked to +** see if those actions are allowed. ^The authorizer callback should +** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the +** specific action but allow the SQL statement to continue to be +** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be +** rejected with an error. ^If the authorizer callback returns +** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] +** then the [sqlite3_prepare_v2()] or equivalent call that triggered +** the authorizer will fail with an error message. +** +** When the callback returns [SQLITE_OK], that means the operation +** requested is ok. ^When the callback returns [SQLITE_DENY], the +** [sqlite3_prepare_v2()] or equivalent call that triggered the +** authorizer will fail with an error message explaining that +** access is denied. +** +** ^The first parameter to the authorizer callback is a copy of the third +** parameter to the sqlite3_set_authorizer() interface. ^The second parameter +** to the callback is an integer [SQLITE_COPY | action code] that specifies +** the particular action to be authorized. ^The third through sixth parameters +** to the callback are zero-terminated strings that contain additional +** details about the action to be authorized. +** +** ^If the action code is [SQLITE_READ] +** and the callback returns [SQLITE_IGNORE] then the +** [prepared statement] statement is constructed to substitute +** a NULL value in place of the table column that would have +** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] +** return can be used to deny an untrusted user access to individual +** columns of a table. +** ^If the action code is [SQLITE_DELETE] and the callback returns +** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the +** [truncate optimization] is disabled and all rows are deleted individually. +** +** An authorizer is used when [sqlite3_prepare | preparing] +** SQL statements from an untrusted source, to ensure that the SQL statements +** do not try to access data they are not allowed to see, or that they do not +** try to execute malicious statements that damage the database. For +** example, an application may allow a user to enter arbitrary +** SQL queries for evaluation by a database. But the application does +** not want the user to be able to make arbitrary changes to the +** database. An authorizer could then be put in place while the +** user-entered SQL is being [sqlite3_prepare | prepared] that +** disallows everything except [SELECT] statements. +** +** Applications that need to process SQL from untrusted sources +** might also consider lowering resource limits using [sqlite3_limit()] +** and limiting database size using the [max_page_count] [PRAGMA] +** in addition to using an authorizer. +** +** ^(Only a single authorizer can be in place on a database connection +** at a time. Each call to sqlite3_set_authorizer overrides the +** previous call.)^ ^Disable the authorizer by installing a NULL callback. +** The authorizer is disabled by default. +** +** The authorizer callback must not do anything that will modify +** the database connection that invoked the authorizer callback. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the +** statement might be re-prepared during [sqlite3_step()] due to a +** schema change. Hence, the application should ensure that the +** correct authorizer callback remains in place during the [sqlite3_step()]. +** +** ^Note that the authorizer callback is invoked only during +** [sqlite3_prepare()] or its variants. Authorization is not +** performed during statement evaluation in [sqlite3_step()], unless +** as stated in the previous paragraph, sqlite3_step() invokes +** sqlite3_prepare_v2() to reprepare a statement after a schema change. +*/ +SQLITE_API int sqlite3_set_authorizer( + sqlite3*, + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), + void *pUserData +); + +/* +** CAPI3REF: Authorizer Return Codes +** +** The [sqlite3_set_authorizer | authorizer callback function] must +** return either [SQLITE_OK] or one of these two constants in order +** to signal SQLite whether or not the action is permitted. See the +** [sqlite3_set_authorizer | authorizer documentation] for additional +** information. +*/ +#define SQLITE_DENY 1 /* Abort the SQL statement with an error */ +#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ + +/* +** CAPI3REF: Authorizer Action Codes +** +** The [sqlite3_set_authorizer()] interface registers a callback function +** that is invoked to authorize certain SQL statement actions. The +** second parameter to the callback is an integer code that specifies +** what action is being authorized. These are the integer action codes that +** the authorizer callback may be passed. +** +** These action code values signify what kind of operation is to be +** authorized. The 3rd and 4th parameters to the authorization +** callback function will be parameters or NULL depending on which of these +** codes is used as the second parameter. ^(The 5th parameter to the +** authorizer callback is the name of the database ("main", "temp", +** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback +** is the name of the inner-most trigger or view that is responsible for +** the access attempt or NULL if this access attempt is directly from +** top-level SQL code. +*/ +/******************************************* 3rd ************ 4th ***********/ +#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ +#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ +#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ +#define SQLITE_CREATE_TEMP_TABLE 4 /* Table Name NULL */ +#define SQLITE_CREATE_TEMP_TRIGGER 5 /* Trigger Name Table Name */ +#define SQLITE_CREATE_TEMP_VIEW 6 /* View Name NULL */ +#define SQLITE_CREATE_TRIGGER 7 /* Trigger Name Table Name */ +#define SQLITE_CREATE_VIEW 8 /* View Name NULL */ +#define SQLITE_DELETE 9 /* Table Name NULL */ +#define SQLITE_DROP_INDEX 10 /* Index Name Table Name */ +#define SQLITE_DROP_TABLE 11 /* Table Name NULL */ +#define SQLITE_DROP_TEMP_INDEX 12 /* Index Name Table Name */ +#define SQLITE_DROP_TEMP_TABLE 13 /* Table Name NULL */ +#define SQLITE_DROP_TEMP_TRIGGER 14 /* Trigger Name Table Name */ +#define SQLITE_DROP_TEMP_VIEW 15 /* View Name NULL */ +#define SQLITE_DROP_TRIGGER 16 /* Trigger Name Table Name */ +#define SQLITE_DROP_VIEW 17 /* View Name NULL */ +#define SQLITE_INSERT 18 /* Table Name NULL */ +#define SQLITE_PRAGMA 19 /* Pragma Name 1st arg or NULL */ +#define SQLITE_READ 20 /* Table Name Column Name */ +#define SQLITE_SELECT 21 /* NULL NULL */ +#define SQLITE_TRANSACTION 22 /* Operation NULL */ +#define SQLITE_UPDATE 23 /* Table Name Column Name */ +#define SQLITE_ATTACH 24 /* Filename NULL */ +#define SQLITE_DETACH 25 /* Database Name NULL */ +#define SQLITE_ALTER_TABLE 26 /* Database Name Table Name */ +#define SQLITE_REINDEX 27 /* Index Name NULL */ +#define SQLITE_ANALYZE 28 /* Table Name NULL */ +#define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ +#define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ +#define SQLITE_FUNCTION 31 /* NULL Function Name */ +#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ +#define SQLITE_COPY 0 /* No longer used */ + +/* +** CAPI3REF: Tracing And Profiling Functions +** EXPERIMENTAL +** +** These routines register callback functions that can be used for +** tracing and profiling the execution of SQL statements. +** +** ^The callback function registered by sqlite3_trace() is invoked at +** various times when an SQL statement is being run by [sqlite3_step()]. +** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the +** SQL statement text as the statement first begins executing. +** ^(Additional sqlite3_trace() callbacks might occur +** as each triggered subprogram is entered. The callbacks for triggers +** contain a UTF-8 SQL comment that identifies the trigger.)^ +** +** ^The callback function registered by sqlite3_profile() is invoked +** as each SQL statement finishes. ^The profile callback contains +** the original statement text and an estimate of wall-clock time +** of how long that statement took to run. +*/ +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); +SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, + void(*xProfile)(void*,const char*,sqlite3_uint64), void*); + +/* +** CAPI3REF: Query Progress Callbacks +** +** ^This routine configures a callback function - the +** progress callback - that is invoked periodically during long +** running calls to [sqlite3_exec()], [sqlite3_step()] and +** [sqlite3_get_table()]. An example use for this +** interface is to keep a GUI updated during a large query. +** +** ^If the progress callback returns non-zero, the operation is +** interrupted. This feature can be used to implement a +** "Cancel" button on a GUI progress dialog box. +** +** The progress handler must not do anything that will modify +** the database connection that invoked the progress handler. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +*/ +SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); + +/* +** CAPI3REF: Opening A New Database Connection +** +** ^These routines open an SQLite database file whose name is given by the +** filename argument. ^The filename argument is interpreted as UTF-8 for +** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte +** order for sqlite3_open16(). ^(A [database connection] handle is usually +** returned in *ppDb, even if an error occurs. The only exception is that +** if SQLite is unable to allocate memory to hold the [sqlite3] object, +** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] +** object.)^ ^(If the database is opened (and/or created) successfully, then +** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The +** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain +** an English language description of the error following a failure of any +** of the sqlite3_open() routines. +** +** ^The default encoding for the database will be UTF-8 if +** sqlite3_open() or sqlite3_open_v2() is called and +** UTF-16 in the native byte order if sqlite3_open16() is used. +** +** Whether or not an error occurs when it is opened, resources +** associated with the [database connection] handle should be released by +** passing it to [sqlite3_close()] when it is no longer required. +** +** The sqlite3_open_v2() interface works like sqlite3_open() +** except that it accepts two additional parameters for additional control +** over the new database connection. ^(The flags parameter to +** sqlite3_open_v2() can take one of +** the following three values, optionally combined with the +** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], +** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ +** +**
+** ^(
[SQLITE_OPEN_READONLY]
+**
The database is opened in read-only mode. If the database does not +** already exist, an error is returned.
)^ +** +** ^(
[SQLITE_OPEN_READWRITE]
+**
The database is opened for reading and writing if possible, or reading +** only if the file is write protected by the operating system. In either +** case the database must already exist, otherwise an error is returned.
)^ +** +** ^(
[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]
+**
The database is opened for reading and writing, and is creates it if +** it does not already exist. This is the behavior that is always used for +** sqlite3_open() and sqlite3_open16().
)^ +**
+** +** If the 3rd parameter to sqlite3_open_v2() is not one of the +** combinations shown above or one of the combinations shown above combined +** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], +** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, +** then the behavior is undefined. +** +** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection +** opens in the multi-thread [threading mode] as long as the single-thread +** mode has not been set at compile-time or start-time. ^If the +** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens +** in the serialized [threading mode] unless single-thread was +** previously selected at compile-time or start-time. +** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be +** eligible to use [shared cache mode], regardless of whether or not shared +** cache is enabled using [sqlite3_enable_shared_cache()]. ^The +** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not +** participate in [shared cache mode] even if it is enabled. +** +** ^If the filename is ":memory:", then a private, temporary in-memory database +** is created for the connection. ^This in-memory database will vanish when +** the database connection is closed. Future versions of SQLite might +** make use of additional special filenames that begin with the ":" character. +** It is recommended that when a database filename actually does begin with +** a ":" character you should prefix the filename with a pathname such as +** "./" to avoid ambiguity. +** +** ^If the filename is an empty string, then a private, temporary +** on-disk database will be created. ^This private database will be +** automatically deleted as soon as the database connection is closed. +** +** ^The fourth parameter to sqlite3_open_v2() is the name of the +** [sqlite3_vfs] object that defines the operating system interface that +** the new database connection should use. ^If the fourth parameter is +** a NULL pointer then the default [sqlite3_vfs] object is used. +** +** Note to Windows users: The encoding used for the filename argument +** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever +** codepage is currently defined. Filenames containing international +** characters must be converted to UTF-8 prior to passing them into +** sqlite3_open() or sqlite3_open_v2(). +*/ +SQLITE_API int sqlite3_open( + const char *filename, /* Database filename (UTF-8) */ + sqlite3 **ppDb /* OUT: SQLite db handle */ +); +SQLITE_API int sqlite3_open16( + const void *filename, /* Database filename (UTF-16) */ + sqlite3 **ppDb /* OUT: SQLite db handle */ +); +SQLITE_API int sqlite3_open_v2( + const char *filename, /* Database filename (UTF-8) */ + sqlite3 **ppDb, /* OUT: SQLite db handle */ + int flags, /* Flags */ + const char *zVfs /* Name of VFS module to use */ +); + +/* +** CAPI3REF: Error Codes And Messages +** +** ^The sqlite3_errcode() interface returns the numeric [result code] or +** [extended result code] for the most recent failed sqlite3_* API call +** associated with a [database connection]. If a prior API call failed +** but the most recent API call succeeded, the return value from +** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode() +** interface is the same except that it always returns the +** [extended result code] even when extended result codes are +** disabled. +** +** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language +** text that describes the error, as either UTF-8 or UTF-16 respectively. +** ^(Memory to hold the error message string is managed internally. +** The application does not need to worry about freeing the result. +** However, the error string might be overwritten or deallocated by +** subsequent calls to other SQLite interface functions.)^ +** +** When the serialized [threading mode] is in use, it might be the +** case that a second error occurs on a separate thread in between +** the time of the first error and the call to these interfaces. +** When that happens, the second error will be reported since these +** interfaces always report the most recent result. To avoid +** this, each thread can obtain exclusive use of the [database connection] D +** by invoking [sqlite3_mutex_enter]([sqlite3_db_mutex](D)) before beginning +** to use D and invoking [sqlite3_mutex_leave]([sqlite3_db_mutex](D)) after +** all calls to the interfaces listed here are completed. +** +** If an interface fails with SQLITE_MISUSE, that means the interface +** was invoked incorrectly by the application. In that case, the +** error code and message may or may not be set. +*/ +SQLITE_API int sqlite3_errcode(sqlite3 *db); +SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); +SQLITE_API const char *sqlite3_errmsg(sqlite3*); +SQLITE_API const void *sqlite3_errmsg16(sqlite3*); + +/* +** CAPI3REF: SQL Statement Object +** KEYWORDS: {prepared statement} {prepared statements} +** +** An instance of this object represents a single SQL statement. +** This object is variously known as a "prepared statement" or a +** "compiled SQL statement" or simply as a "statement". +** +** The life of a statement object goes something like this: +** +**
    +**
  1. Create the object using [sqlite3_prepare_v2()] or a related +** function. +**
  2. Bind values to [host parameters] using the sqlite3_bind_*() +** interfaces. +**
  3. Run the SQL by calling [sqlite3_step()] one or more times. +**
  4. Reset the statement using [sqlite3_reset()] then go back +** to step 2. Do this zero or more times. +**
  5. Destroy the object using [sqlite3_finalize()]. +**
+** +** Refer to documentation on individual methods above for additional +** information. +*/ +typedef struct sqlite3_stmt sqlite3_stmt; + +/* +** CAPI3REF: Run-time Limits +** +** ^(This interface allows the size of various constructs to be limited +** on a connection by connection basis. The first parameter is the +** [database connection] whose limit is to be set or queried. The +** second parameter is one of the [limit categories] that define a +** class of constructs to be size limited. The third parameter is the +** new limit for that construct. The function returns the old limit.)^ +** +** ^If the new limit is a negative number, the limit is unchanged. +** ^(For the limit category of SQLITE_LIMIT_XYZ there is a +** [limits | hard upper bound] +** set by a compile-time C preprocessor macro named +** [limits | SQLITE_MAX_XYZ]. +** (The "_LIMIT_" in the name is changed to "_MAX_".))^ +** ^Attempts to increase a limit above its hard upper bound are +** silently truncated to the hard upper bound. +** +** Run-time limits are intended for use in applications that manage +** both their own internal database and also databases that are controlled +** by untrusted external sources. An example application might be a +** web browser that has its own databases for storing history and +** separate databases controlled by JavaScript applications downloaded +** off the Internet. The internal databases can be given the +** large, default limits. Databases managed by external sources can +** be given much smaller limits designed to prevent a denial of service +** attack. Developers might also want to use the [sqlite3_set_authorizer()] +** interface to further control untrusted SQL. The size of the database +** created by an untrusted script can be contained using the +** [max_page_count] [PRAGMA]. +** +** New run-time limit categories may be added in future releases. +*/ +SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); + +/* +** CAPI3REF: Run-Time Limit Categories +** KEYWORDS: {limit category} {*limit categories} +** +** These constants define various performance limits +** that can be lowered at run-time using [sqlite3_limit()]. +** The synopsis of the meanings of the various limits is shown below. +** Additional information is available at [limits | Limits in SQLite]. +** +**
+** ^(
SQLITE_LIMIT_LENGTH
+**
The maximum size of any string or BLOB or table row.
)^ +** +** ^(
SQLITE_LIMIT_SQL_LENGTH
+**
The maximum length of an SQL statement, in bytes.
)^ +** +** ^(
SQLITE_LIMIT_COLUMN
+**
The maximum number of columns in a table definition or in the +** result set of a [SELECT] or the maximum number of columns in an index +** or in an ORDER BY or GROUP BY clause.
)^ +** +** ^(
SQLITE_LIMIT_EXPR_DEPTH
+**
The maximum depth of the parse tree on any expression.
)^ +** +** ^(
SQLITE_LIMIT_COMPOUND_SELECT
+**
The maximum number of terms in a compound SELECT statement.
)^ +** +** ^(
SQLITE_LIMIT_VDBE_OP
+**
The maximum number of instructions in a virtual machine program +** used to implement an SQL statement.
)^ +** +** ^(
SQLITE_LIMIT_FUNCTION_ARG
+**
The maximum number of arguments on a function.
)^ +** +** ^(
SQLITE_LIMIT_ATTACHED
+**
The maximum number of [ATTACH | attached databases].)^
+** +** ^(
SQLITE_LIMIT_LIKE_PATTERN_LENGTH
+**
The maximum length of the pattern argument to the [LIKE] or +** [GLOB] operators.
)^ +** +** ^(
SQLITE_LIMIT_VARIABLE_NUMBER
+**
The maximum number of variables in an SQL statement that can +** be bound.
)^ +** +** ^(
SQLITE_LIMIT_TRIGGER_DEPTH
+**
The maximum depth of recursion for triggers.
)^ +**
+*/ +#define SQLITE_LIMIT_LENGTH 0 +#define SQLITE_LIMIT_SQL_LENGTH 1 +#define SQLITE_LIMIT_COLUMN 2 +#define SQLITE_LIMIT_EXPR_DEPTH 3 +#define SQLITE_LIMIT_COMPOUND_SELECT 4 +#define SQLITE_LIMIT_VDBE_OP 5 +#define SQLITE_LIMIT_FUNCTION_ARG 6 +#define SQLITE_LIMIT_ATTACHED 7 +#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 +#define SQLITE_LIMIT_VARIABLE_NUMBER 9 +#define SQLITE_LIMIT_TRIGGER_DEPTH 10 + +/* +** CAPI3REF: Compiling An SQL Statement +** KEYWORDS: {SQL statement compiler} +** +** To execute an SQL query, it must first be compiled into a byte-code +** program using one of these routines. +** +** The first argument, "db", is a [database connection] obtained from a +** prior successful call to [sqlite3_open()], [sqlite3_open_v2()] or +** [sqlite3_open16()]. The database connection must not have been closed. +** +** The second argument, "zSql", is the statement to be compiled, encoded +** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() +** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() +** use UTF-16. +** +** ^If the nByte argument is less than zero, then zSql is read up to the +** first zero terminator. ^If nByte is non-negative, then it is the maximum +** number of bytes read from zSql. ^When nByte is non-negative, the +** zSql string ends at either the first '\000' or '\u0000' character or +** the nByte-th byte, whichever comes first. If the caller knows +** that the supplied string is nul-terminated, then there is a small +** performance advantage to be gained by passing an nByte parameter that +** is equal to the number of bytes in the input string including +** the nul-terminator bytes. +** +** ^If pzTail is not NULL then *pzTail is made to point to the first byte +** past the end of the first SQL statement in zSql. These routines only +** compile the first statement in zSql, so *pzTail is left pointing to +** what remains uncompiled. +** +** ^*ppStmt is left pointing to a compiled [prepared statement] that can be +** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set +** to NULL. ^If the input text contains no SQL (if the input is an empty +** string or a comment) then *ppStmt is set to NULL. +** The calling procedure is responsible for deleting the compiled +** SQL statement using [sqlite3_finalize()] after it has finished with it. +** ppStmt may not be NULL. +** +** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK]; +** otherwise an [error code] is returned. +** +** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are +** recommended for all new programs. The two older interfaces are retained +** for backwards compatibility, but their use is discouraged. +** ^In the "v2" interfaces, the prepared statement +** that is returned (the [sqlite3_stmt] object) contains a copy of the +** original SQL text. This causes the [sqlite3_step()] interface to +** behave differently in three ways: +** +**
    +**
  1. +** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it +** always used to do, [sqlite3_step()] will automatically recompile the SQL +** statement and try to run it again. ^If the schema has changed in +** a way that makes the statement no longer valid, [sqlite3_step()] will still +** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is +** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the +** error go away. Note: use [sqlite3_errmsg()] to find the text +** of the parsing error that results in an [SQLITE_SCHEMA] return. +**
  2. +** +**
  3. +** ^When an error occurs, [sqlite3_step()] will return one of the detailed +** [error codes] or [extended error codes]. ^The legacy behavior was that +** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code +** and the application would have to make a second call to [sqlite3_reset()] +** in order to find the underlying cause of the problem. With the "v2" prepare +** interfaces, the underlying reason for the error is returned immediately. +**
  4. +** +**
  5. +** ^If the value of a [parameter | host parameter] in the WHERE clause might +** change the query plan for a statement, then the statement may be +** automatically recompiled (as if there had been a schema change) on the first +** [sqlite3_step()] call following any change to the +** [sqlite3_bind_text | bindings] of the [parameter]. +**
  6. +**
+*/ +SQLITE_API int sqlite3_prepare( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare_v2( + sqlite3 *db, /* Database handle */ + const char *zSql, /* SQL statement, UTF-8 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const char **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare16( + sqlite3 *db, /* Database handle */ + const void *zSql, /* SQL statement, UTF-16 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const void **pzTail /* OUT: Pointer to unused portion of zSql */ +); +SQLITE_API int sqlite3_prepare16_v2( + sqlite3 *db, /* Database handle */ + const void *zSql, /* SQL statement, UTF-16 encoded */ + int nByte, /* Maximum length of zSql in bytes. */ + sqlite3_stmt **ppStmt, /* OUT: Statement handle */ + const void **pzTail /* OUT: Pointer to unused portion of zSql */ +); + +/* +** CAPI3REF: Retrieving Statement SQL +** +** ^This interface can be used to retrieve a saved copy of the original +** SQL text used to create a [prepared statement] if that statement was +** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. +*/ +SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Dynamically Typed Value Object +** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} +** +** SQLite uses the sqlite3_value object to represent all values +** that can be stored in a database table. SQLite uses dynamic typing +** for the values it stores. ^Values stored in sqlite3_value objects +** can be integers, floating point values, strings, BLOBs, or NULL. +** +** An sqlite3_value object may be either "protected" or "unprotected". +** Some interfaces require a protected sqlite3_value. Other interfaces +** will accept either a protected or an unprotected sqlite3_value. +** Every interface that accepts sqlite3_value arguments specifies +** whether or not it requires a protected sqlite3_value. +** +** The terms "protected" and "unprotected" refer to whether or not +** a mutex is held. A internal mutex is held for a protected +** sqlite3_value object but no mutex is held for an unprotected +** sqlite3_value object. If SQLite is compiled to be single-threaded +** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0) +** or if SQLite is run in one of reduced mutex modes +** [SQLITE_CONFIG_SINGLETHREAD] or [SQLITE_CONFIG_MULTITHREAD] +** then there is no distinction between protected and unprotected +** sqlite3_value objects and they can be used interchangeably. However, +** for maximum code portability it is recommended that applications +** still make the distinction between between protected and unprotected +** sqlite3_value objects even when not strictly required. +** +** ^The sqlite3_value objects that are passed as parameters into the +** implementation of [application-defined SQL functions] are protected. +** ^The sqlite3_value object returned by +** [sqlite3_column_value()] is unprotected. +** Unprotected sqlite3_value objects may only be used with +** [sqlite3_result_value()] and [sqlite3_bind_value()]. +** The [sqlite3_value_blob | sqlite3_value_type()] family of +** interfaces require protected sqlite3_value objects. +*/ +typedef struct Mem sqlite3_value; + +/* +** CAPI3REF: SQL Function Context Object +** +** The context in which an SQL function executes is stored in an +** sqlite3_context object. ^A pointer to an sqlite3_context object +** is always first parameter to [application-defined SQL functions]. +** The application-defined SQL function implementation will pass this +** pointer through into calls to [sqlite3_result_int | sqlite3_result()], +** [sqlite3_aggregate_context()], [sqlite3_user_data()], +** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], +** and/or [sqlite3_set_auxdata()]. +*/ +typedef struct sqlite3_context sqlite3_context; + +/* +** CAPI3REF: Binding Values To Prepared Statements +** KEYWORDS: {host parameter} {host parameters} {host parameter name} +** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} +** +** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, +** literals may be replaced by a [parameter] that matches one of following +** templates: +** +**
    +**
  • ? +**
  • ?NNN +**
  • :VVV +**
  • @VVV +**
  • $VVV +**
+** +** In the templates above, NNN represents an integer literal, +** and VVV represents an alphanumeric identifer.)^ ^The values of these +** parameters (also called "host parameter names" or "SQL parameters") +** can be set using the sqlite3_bind_*() routines defined here. +** +** ^The first argument to the sqlite3_bind_*() routines is always +** a pointer to the [sqlite3_stmt] object returned from +** [sqlite3_prepare_v2()] or its variants. +** +** ^The second argument is the index of the SQL parameter to be set. +** ^The leftmost SQL parameter has an index of 1. ^When the same named +** SQL parameter is used more than once, second and subsequent +** occurrences have the same index as the first occurrence. +** ^The index for named parameters can be looked up using the +** [sqlite3_bind_parameter_index()] API if desired. ^The index +** for "?NNN" parameters is the value of NNN. +** ^The NNN value must be between 1 and the [sqlite3_limit()] +** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). +** +** ^The third argument is the value to bind to the parameter. +** +** ^(In those routines that have a fourth argument, its value is the +** number of bytes in the parameter. To be clear: the value is the +** number of bytes in the value, not the number of characters.)^ +** ^If the fourth parameter is negative, the length of the string is +** the number of bytes up to the first zero terminator. +** +** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and +** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or +** string after SQLite has finished with it. ^If the fifth argument is +** the special value [SQLITE_STATIC], then SQLite assumes that the +** information is in static, unmanaged space and does not need to be freed. +** ^If the fifth argument has the value [SQLITE_TRANSIENT], then +** SQLite makes its own private copy of the data immediately, before +** the sqlite3_bind_*() routine returns. +** +** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that +** is filled with zeroes. ^A zeroblob uses a fixed amount of memory +** (just an integer to hold its size) while it is being processed. +** Zeroblobs are intended to serve as placeholders for BLOBs whose +** content is later written using +** [sqlite3_blob_open | incremental BLOB I/O] routines. +** ^A negative value for the zeroblob results in a zero-length BLOB. +** +** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer +** for the [prepared statement] or with a prepared statement for which +** [sqlite3_step()] has been called more recently than [sqlite3_reset()], +** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_() +** routine is passed a [prepared statement] that has been finalized, the +** result is undefined and probably harmful. +** +** ^Bindings are not cleared by the [sqlite3_reset()] routine. +** ^Unbound parameters are interpreted as NULL. +** +** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an +** [error code] if anything goes wrong. +** ^[SQLITE_RANGE] is returned if the parameter +** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. +** +** See also: [sqlite3_bind_parameter_count()], +** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); +SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); +SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); +SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); +SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); +SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*)); +SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); +SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); +SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); + +/* +** CAPI3REF: Number Of SQL Parameters +** +** ^This routine can be used to find the number of [SQL parameters] +** in a [prepared statement]. SQL parameters are tokens of the +** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as +** placeholders for values that are [sqlite3_bind_blob | bound] +** to the parameters at a later time. +** +** ^(This routine actually returns the index of the largest (rightmost) +** parameter. For all forms except ?NNN, this will correspond to the +** number of unique parameters. If parameters of the ?NNN form are used, +** there may be gaps in the list.)^ +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_name()], and +** [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); + +/* +** CAPI3REF: Name Of A Host Parameter +** +** ^The sqlite3_bind_parameter_name(P,N) interface returns +** the name of the N-th [SQL parameter] in the [prepared statement] P. +** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA" +** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" +** respectively. +** In other words, the initial ":" or "$" or "@" or "?" +** is included as part of the name.)^ +** ^Parameters of the form "?" without a following integer have no name +** and are referred to as "nameless" or "anonymous parameters". +** +** ^The first host parameter has an index of 1, not 0. +** +** ^If the value N is out of range or if the N-th parameter is +** nameless, then NULL is returned. ^The returned string is +** always in UTF-8 encoding even if the named parameter was +** originally specified as UTF-16 in [sqlite3_prepare16()] or +** [sqlite3_prepare16_v2()]. +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_count()], and +** [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); + +/* +** CAPI3REF: Index Of A Parameter With A Given Name +** +** ^Return the index of an SQL parameter given its name. ^The +** index value returned is suitable for use as the second +** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero +** is returned if no matching parameter is found. ^The parameter +** name must be given in UTF-8 even if the original statement +** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. +** +** See also: [sqlite3_bind_blob|sqlite3_bind()], +** [sqlite3_bind_parameter_count()], and +** [sqlite3_bind_parameter_index()]. +*/ +SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); + +/* +** CAPI3REF: Reset All Bindings On A Prepared Statement +** +** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset +** the [sqlite3_bind_blob | bindings] on a [prepared statement]. +** ^Use this routine to reset all host parameters to NULL. +*/ +SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); + +/* +** CAPI3REF: Number Of Columns In A Result Set +** +** ^Return the number of columns in the result set returned by the +** [prepared statement]. ^This routine returns 0 if pStmt is an SQL +** statement that does not return data (for example an [UPDATE]). +*/ +SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Column Names In A Result Set +** +** ^These routines return the name assigned to a particular column +** in the result set of a [SELECT] statement. ^The sqlite3_column_name() +** interface returns a pointer to a zero-terminated UTF-8 string +** and sqlite3_column_name16() returns a pointer to a zero-terminated +** UTF-16 string. ^The first parameter is the [prepared statement] +** that implements the [SELECT] statement. ^The second parameter is the +** column number. ^The leftmost column is number 0. +** +** ^The returned string pointer is valid until either the [prepared statement] +** is destroyed by [sqlite3_finalize()] or until the next call to +** sqlite3_column_name() or sqlite3_column_name16() on the same column. +** +** ^If sqlite3_malloc() fails during the processing of either routine +** (for example during a conversion from UTF-8 to UTF-16) then a +** NULL pointer is returned. +** +** ^The name of a result column is the value of the "AS" clause for +** that column, if there is an AS clause. If there is no AS clause +** then the name of the column is unspecified and may change from +** one release of SQLite to the next. +*/ +SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); +SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); + +/* +** CAPI3REF: Source Of Data In A Query Result +** +** ^These routines provide a means to determine the database, table, and +** table column that is the origin of a particular result column in +** [SELECT] statement. +** ^The name of the database or table or column can be returned as +** either a UTF-8 or UTF-16 string. ^The _database_ routines return +** the database name, the _table_ routines return the table name, and +** the origin_ routines return the column name. +** ^The returned string is valid until the [prepared statement] is destroyed +** using [sqlite3_finalize()] or until the same information is requested +** again in a different encoding. +** +** ^The names returned are the original un-aliased names of the +** database, table, and column. +** +** ^The first argument to these interfaces is a [prepared statement]. +** ^These functions return information about the Nth result column returned by +** the statement, where N is the second function argument. +** ^The left-most column is column 0 for these routines. +** +** ^If the Nth column returned by the statement is an expression or +** subquery and is not a column value, then all of these functions return +** NULL. ^These routine might also return NULL if a memory allocation error +** occurs. ^Otherwise, they return the name of the attached database, table, +** or column that query result column was extracted from. +** +** ^As with all other SQLite APIs, those whose names end with "16" return +** UTF-16 encoded strings and the other functions return UTF-8. +** +** ^These APIs are only available if the library was compiled with the +** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol. +** +** If two or more threads call one or more of these routines against the same +** prepared statement and column at the same time then the results are +** undefined. +** +** If two or more threads call one or more +** [sqlite3_column_database_name | column metadata interfaces] +** for the same [prepared statement] and result column +** at the same time then the results are undefined. +*/ +SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int); +SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); +SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); + +/* +** CAPI3REF: Declared Datatype Of A Query Result +** +** ^(The first parameter is a [prepared statement]. +** If this statement is a [SELECT] statement and the Nth column of the +** returned result set of that [SELECT] is a table column (not an +** expression or subquery) then the declared type of the table +** column is returned.)^ ^If the Nth column of the result set is an +** expression or subquery, then a NULL pointer is returned. +** ^The returned string is always UTF-8 encoded. +** +** ^(For example, given the database schema: +** +** CREATE TABLE t1(c1 VARIANT); +** +** and the following statement to be compiled: +** +** SELECT c1 + 1, c1 FROM t1; +** +** this routine would return the string "VARIANT" for the second result +** column (i==1), and a NULL pointer for the first result column (i==0).)^ +** +** ^SQLite uses dynamic run-time typing. ^So just because a column +** is declared to contain a particular type does not mean that the +** data stored in that column is of the declared type. SQLite is +** strongly typed, but the typing is dynamic not static. ^Type +** is associated with individual values, not with the containers +** used to hold those values. +*/ +SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); +SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); + +/* +** CAPI3REF: Evaluate An SQL Statement +** +** After a [prepared statement] has been prepared using either +** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy +** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function +** must be called one or more times to evaluate the statement. +** +** The details of the behavior of the sqlite3_step() interface depend +** on whether the statement was prepared using the newer "v2" interface +** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy +** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the +** new "v2" interface is recommended for new applications but the legacy +** interface will continue to be supported. +** +** ^In the legacy interface, the return value will be either [SQLITE_BUSY], +** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE]. +** ^With the "v2" interface, any of the other [result codes] or +** [extended result codes] might be returned as well. +** +** ^[SQLITE_BUSY] means that the database engine was unable to acquire the +** database locks it needs to do its job. ^If the statement is a [COMMIT] +** or occurs outside of an explicit transaction, then you can retry the +** statement. If the statement is not a [COMMIT] and occurs within a +** explicit transaction then you should rollback the transaction before +** continuing. +** +** ^[SQLITE_DONE] means that the statement has finished executing +** successfully. sqlite3_step() should not be called again on this virtual +** machine without first calling [sqlite3_reset()] to reset the virtual +** machine back to its initial state. +** +** ^If the SQL statement being executed returns any data, then [SQLITE_ROW] +** is returned each time a new row of data is ready for processing by the +** caller. The values may be accessed using the [column access functions]. +** sqlite3_step() is called again to retrieve the next row of data. +** +** ^[SQLITE_ERROR] means that a run-time error (such as a constraint +** violation) has occurred. sqlite3_step() should not be called again on +** the VM. More information may be found by calling [sqlite3_errmsg()]. +** ^With the legacy interface, a more specific error code (for example, +** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) +** can be obtained by calling [sqlite3_reset()] on the +** [prepared statement]. ^In the "v2" interface, +** the more specific error code is returned directly by sqlite3_step(). +** +** [SQLITE_MISUSE] means that the this routine was called inappropriately. +** Perhaps it was called on a [prepared statement] that has +** already been [sqlite3_finalize | finalized] or on one that had +** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could +** be the case that the same database connection is being used by two or +** more threads at the same moment in time. +** +** Goofy Interface Alert: In the legacy interface, the sqlite3_step() +** API always returns a generic error code, [SQLITE_ERROR], following any +** error other than [SQLITE_BUSY] and [SQLITE_MISUSE]. You must call +** [sqlite3_reset()] or [sqlite3_finalize()] in order to find one of the +** specific [error codes] that better describes the error. +** We admit that this is a goofy design. The problem has been fixed +** with the "v2" interface. If you prepare all of your SQL statements +** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead +** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, +** then the more specific [error codes] are returned directly +** by sqlite3_step(). The use of the "v2" interface is recommended. +*/ +SQLITE_API int sqlite3_step(sqlite3_stmt*); + +/* +** CAPI3REF: Number of columns in a result set +** +** ^The sqlite3_data_count(P) the number of columns in the +** of the result set of [prepared statement] P. +*/ +SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Fundamental Datatypes +** KEYWORDS: SQLITE_TEXT +** +** ^(Every value in SQLite has one of five fundamental datatypes: +** +**
    +**
  • 64-bit signed integer +**
  • 64-bit IEEE floating point number +**
  • string +**
  • BLOB +**
  • NULL +**
)^ +** +** These constants are codes for each of those types. +** +** Note that the SQLITE_TEXT constant was also used in SQLite version 2 +** for a completely different meaning. Software that links against both +** SQLite version 2 and SQLite version 3 should use SQLITE3_TEXT, not +** SQLITE_TEXT. +*/ +#define SQLITE_INTEGER 1 +#define SQLITE_FLOAT 2 +#define SQLITE_BLOB 4 +#define SQLITE_NULL 5 +#ifdef SQLITE_TEXT +# undef SQLITE_TEXT +#else +# define SQLITE_TEXT 3 +#endif +#define SQLITE3_TEXT 3 + +/* +** CAPI3REF: Result Values From A Query +** KEYWORDS: {column access functions} +** +** These routines form the "result set" interface. +** +** ^These routines return information about a single column of the current +** result row of a query. ^In every case the first argument is a pointer +** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] +** that was returned from [sqlite3_prepare_v2()] or one of its variants) +** and the second argument is the index of the column for which information +** should be returned. ^The leftmost column of the result set has the index 0. +** ^The number of columns in the result can be determined using +** [sqlite3_column_count()]. +** +** If the SQL statement does not currently point to a valid row, or if the +** column index is out of range, the result is undefined. +** These routines may only be called when the most recent call to +** [sqlite3_step()] has returned [SQLITE_ROW] and neither +** [sqlite3_reset()] nor [sqlite3_finalize()] have been called subsequently. +** If any of these routines are called after [sqlite3_reset()] or +** [sqlite3_finalize()] or after [sqlite3_step()] has returned +** something other than [SQLITE_ROW], the results are undefined. +** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] +** are called from a different thread while any of these routines +** are pending, then the results are undefined. +** +** ^The sqlite3_column_type() routine returns the +** [SQLITE_INTEGER | datatype code] for the initial data type +** of the result column. ^The returned value is one of [SQLITE_INTEGER], +** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value +** returned by sqlite3_column_type() is only meaningful if no type +** conversions have occurred as described below. After a type conversion, +** the value returned by sqlite3_column_type() is undefined. Future +** versions of SQLite may change the behavior of sqlite3_column_type() +** following a type conversion. +** +** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes() +** routine returns the number of bytes in that BLOB or string. +** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts +** the string to UTF-8 and then returns the number of bytes. +** ^If the result is a numeric value then sqlite3_column_bytes() uses +** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns +** the number of bytes in that string. +** ^The value returned does not include the zero terminator at the end +** of the string. ^For clarity: the value returned is the number of +** bytes in the string, not the number of characters. +** +** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(), +** even empty strings, are always zero terminated. ^The return +** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary +** pointer, possibly even a NULL pointer. +** +** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() +** but leaves the result in UTF-16 in native byte order instead of UTF-8. +** ^The zero terminator is not included in this count. +** +** ^The object returned by [sqlite3_column_value()] is an +** [unprotected sqlite3_value] object. An unprotected sqlite3_value object +** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. +** If the [unprotected sqlite3_value] object returned by +** [sqlite3_column_value()] is used in any other way, including calls +** to routines like [sqlite3_value_int()], [sqlite3_value_text()], +** or [sqlite3_value_bytes()], then the behavior is undefined. +** +** These routines attempt to convert the value where appropriate. ^For +** example, if the internal representation is FLOAT and a text result +** is requested, [sqlite3_snprintf()] is used internally to perform the +** conversion automatically. ^(The following table details the conversions +** that are applied: +** +**
+** +**
Internal
Type
Requested
Type
Conversion +** +**
NULL INTEGER Result is 0 +**
NULL FLOAT Result is 0.0 +**
NULL TEXT Result is NULL pointer +**
NULL BLOB Result is NULL pointer +**
INTEGER FLOAT Convert from integer to float +**
INTEGER TEXT ASCII rendering of the integer +**
INTEGER BLOB Same as INTEGER->TEXT +**
FLOAT INTEGER Convert from float to integer +**
FLOAT TEXT ASCII rendering of the float +**
FLOAT BLOB Same as FLOAT->TEXT +**
TEXT INTEGER Use atoi() +**
TEXT FLOAT Use atof() +**
TEXT BLOB No change +**
BLOB INTEGER Convert to TEXT then use atoi() +**
BLOB FLOAT Convert to TEXT then use atof() +**
BLOB TEXT Add a zero terminator if needed +**
+**
)^ +** +** The table above makes reference to standard C library functions atoi() +** and atof(). SQLite does not really use these functions. It has its +** own equivalent internal routines. The atoi() and atof() names are +** used in the table for brevity and because they are familiar to most +** C programmers. +** +** ^Note that when type conversions occur, pointers returned by prior +** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or +** sqlite3_column_text16() may be invalidated. +** ^(Type conversions and pointer invalidations might occur +** in the following cases: +** +**
    +**
  • The initial content is a BLOB and sqlite3_column_text() or +** sqlite3_column_text16() is called. A zero-terminator might +** need to be added to the string.
  • +**
  • The initial content is UTF-8 text and sqlite3_column_bytes16() or +** sqlite3_column_text16() is called. The content must be converted +** to UTF-16.
  • +**
  • The initial content is UTF-16 text and sqlite3_column_bytes() or +** sqlite3_column_text() is called. The content must be converted +** to UTF-8.
  • +**
)^ +** +** ^Conversions between UTF-16be and UTF-16le are always done in place and do +** not invalidate a prior pointer, though of course the content of the buffer +** that the prior pointer points to will have been modified. Other kinds +** of conversion are done in place when it is possible, but sometimes they +** are not possible and in those cases prior pointers are invalidated. +** +** ^(The safest and easiest to remember policy is to invoke these routines +** in one of the following ways: +** +**
    +**
  • sqlite3_column_text() followed by sqlite3_column_bytes()
  • +**
  • sqlite3_column_blob() followed by sqlite3_column_bytes()
  • +**
  • sqlite3_column_text16() followed by sqlite3_column_bytes16()
  • +**
)^ +** +** In other words, you should call sqlite3_column_text(), +** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result +** into the desired format, then invoke sqlite3_column_bytes() or +** sqlite3_column_bytes16() to find the size of the result. Do not mix calls +** to sqlite3_column_text() or sqlite3_column_blob() with calls to +** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() +** with calls to sqlite3_column_bytes(). +** +** ^The pointers returned are valid until a type conversion occurs as +** described above, or until [sqlite3_step()] or [sqlite3_reset()] or +** [sqlite3_finalize()] is called. ^The memory space used to hold strings +** and BLOBs is freed automatically. Do not pass the pointers returned +** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into +** [sqlite3_free()]. +** +** ^(If a memory allocation error occurs during the evaluation of any +** of these routines, a default value is returned. The default value +** is either the integer 0, the floating point number 0.0, or a NULL +** pointer. Subsequent calls to [sqlite3_errcode()] will return +** [SQLITE_NOMEM].)^ +*/ +SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); +SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol); +SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol); +SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol); +SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); +SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); +SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); + +/* +** CAPI3REF: Destroy A Prepared Statement Object +** +** ^The sqlite3_finalize() function is called to delete a [prepared statement]. +** ^If the statement was executed successfully or not executed at all, then +** SQLITE_OK is returned. ^If execution of the statement failed then an +** [error code] or [extended error code] is returned. +** +** ^This routine can be called at any point during the execution of the +** [prepared statement]. ^If the virtual machine has not +** completed execution when this routine is called, that is like +** encountering an error or an [sqlite3_interrupt | interrupt]. +** ^Incomplete updates may be rolled back and transactions canceled, +** depending on the circumstances, and the +** [error code] returned will be [SQLITE_ABORT]. +*/ +SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Reset A Prepared Statement Object +** +** The sqlite3_reset() function is called to reset a [prepared statement] +** object back to its initial state, ready to be re-executed. +** ^Any SQL statement variables that had values bound to them using +** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. +** Use [sqlite3_clear_bindings()] to reset the bindings. +** +** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S +** back to the beginning of its program. +** +** ^If the most recent call to [sqlite3_step(S)] for the +** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE], +** or if [sqlite3_step(S)] has never before been called on S, +** then [sqlite3_reset(S)] returns [SQLITE_OK]. +** +** ^If the most recent call to [sqlite3_step(S)] for the +** [prepared statement] S indicated an error, then +** [sqlite3_reset(S)] returns an appropriate [error code]. +** +** ^The [sqlite3_reset(S)] interface does not change the values +** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S. +*/ +SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Create Or Redefine SQL Functions +** KEYWORDS: {function creation routines} +** KEYWORDS: {application-defined SQL function} +** KEYWORDS: {application-defined SQL functions} +** +** ^These two functions (collectively known as "function creation routines") +** are used to add SQL functions or aggregates or to redefine the behavior +** of existing SQL functions or aggregates. The only difference between the +** two is that the second parameter, the name of the (scalar) function or +** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16 +** for sqlite3_create_function16(). +** +** ^The first parameter is the [database connection] to which the SQL +** function is to be added. ^If an application uses more than one database +** connection then application-defined SQL functions must be added +** to each database connection separately. +** +** The second parameter is the name of the SQL function to be created or +** redefined. ^The length of the name is limited to 255 bytes, exclusive of +** the zero-terminator. Note that the name length limit is in bytes, not +** characters. ^Any attempt to create a function with a longer name +** will result in [SQLITE_ERROR] being returned. +** +** ^The third parameter (nArg) +** is the number of arguments that the SQL function or +** aggregate takes. ^If this parameter is -1, then the SQL function or +** aggregate may take any number of arguments between 0 and the limit +** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third +** parameter is less than -1 or greater than 127 then the behavior is +** undefined. +** +** The fourth parameter, eTextRep, specifies what +** [SQLITE_UTF8 | text encoding] this SQL function prefers for +** its parameters. Any SQL function implementation should be able to work +** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be +** more efficient with one encoding than another. ^An application may +** invoke sqlite3_create_function() or sqlite3_create_function16() multiple +** times with the same function but with different values of eTextRep. +** ^When multiple implementations of the same function are available, SQLite +** will pick the one that involves the least amount of data conversion. +** If there is only a single implementation which does not care what text +** encoding is used, then the fourth argument should be [SQLITE_ANY]. +** +** ^(The fifth parameter is an arbitrary pointer. The implementation of the +** function can gain access to this pointer using [sqlite3_user_data()].)^ +** +** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are +** pointers to C-language functions that implement the SQL function or +** aggregate. ^A scalar SQL function requires an implementation of the xFunc +** callback only; NULL pointers should be passed as the xStep and xFinal +** parameters. ^An aggregate SQL function requires an implementation of xStep +** and xFinal and NULL should be passed for xFunc. ^To delete an existing +** SQL function or aggregate, pass NULL for all three function callbacks. +** +** ^It is permitted to register multiple implementations of the same +** functions with the same name but with either differing numbers of +** arguments or differing preferred text encodings. ^SQLite will use +** the implementation that most closely matches the way in which the +** SQL function is used. ^A function implementation with a non-negative +** nArg parameter is a better match than a function implementation with +** a negative nArg. ^A function where the preferred text encoding +** matches the database encoding is a better +** match than a function where the encoding is different. +** ^A function where the encoding difference is between UTF16le and UTF16be +** is a closer match than a function where the encoding difference is +** between UTF8 and UTF16. +** +** ^Built-in functions may be overloaded by new application-defined functions. +** ^The first application-defined function with a given name overrides all +** built-in functions in the same [database connection] with the same name. +** ^Subsequent application-defined functions of the same name only override +** prior application-defined functions that are an exact match for the +** number of parameters and preferred encoding. +** +** ^An application-defined function is permitted to call other +** SQLite interfaces. However, such calls must not +** close the database connection nor finalize or reset the prepared +** statement in which the function is running. +*/ +SQLITE_API int sqlite3_create_function( + sqlite3 *db, + const char *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) +); +SQLITE_API int sqlite3_create_function16( + sqlite3 *db, + const void *zFunctionName, + int nArg, + int eTextRep, + void *pApp, + void (*xFunc)(sqlite3_context*,int,sqlite3_value**), + void (*xStep)(sqlite3_context*,int,sqlite3_value**), + void (*xFinal)(sqlite3_context*) +); + +/* +** CAPI3REF: Text Encodings +** +** These constant define integer codes that represent the various +** text encodings supported by SQLite. +*/ +#define SQLITE_UTF8 1 +#define SQLITE_UTF16LE 2 +#define SQLITE_UTF16BE 3 +#define SQLITE_UTF16 4 /* Use native byte order */ +#define SQLITE_ANY 5 /* sqlite3_create_function only */ +#define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ + +/* +** CAPI3REF: Deprecated Functions +** DEPRECATED +** +** These functions are [deprecated]. In order to maintain +** backwards compatibility with older code, these functions continue +** to be supported. However, new applications should avoid +** the use of these functions. To help encourage people to avoid +** using these functions, we are not going to tell you what they do. +*/ +#ifndef SQLITE_OMIT_DEPRECATED +SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); +SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); +SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); +SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); +#endif + +/* +** CAPI3REF: Obtaining SQL Function Parameter Values +** +** The C-language implementation of SQL functions and aggregates uses +** this set of interface routines to access the parameter values on +** the function or aggregate. +** +** The xFunc (for scalar functions) or xStep (for aggregates) parameters +** to [sqlite3_create_function()] and [sqlite3_create_function16()] +** define callbacks that implement the SQL functions and aggregates. +** The 4th parameter to these callbacks is an array of pointers to +** [protected sqlite3_value] objects. There is one [sqlite3_value] object for +** each parameter to the SQL function. These routines are used to +** extract values from the [sqlite3_value] objects. +** +** These routines work only with [protected sqlite3_value] objects. +** Any attempt to use these routines on an [unprotected sqlite3_value] +** object results in undefined behavior. +** +** ^These routines work just like the corresponding [column access functions] +** except that these routines take a single [protected sqlite3_value] object +** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. +** +** ^The sqlite3_value_text16() interface extracts a UTF-16 string +** in the native byte-order of the host machine. ^The +** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces +** extract UTF-16 strings as big-endian and little-endian respectively. +** +** ^(The sqlite3_value_numeric_type() interface attempts to apply +** numeric affinity to the value. This means that an attempt is +** made to convert the value to an integer or floating point. If +** such a conversion is possible without loss of information (in other +** words, if the value is a string that looks like a number) +** then the conversion is performed. Otherwise no conversion occurs. +** The [SQLITE_INTEGER | datatype] after conversion is returned.)^ +** +** Please pay particular attention to the fact that the pointer returned +** from [sqlite3_value_blob()], [sqlite3_value_text()], or +** [sqlite3_value_text16()] can be invalidated by a subsequent call to +** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], +** or [sqlite3_value_text16()]. +** +** These routines must be called from the same thread as +** the SQL function that supplied the [sqlite3_value*] parameters. +*/ +SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); +SQLITE_API int sqlite3_value_bytes(sqlite3_value*); +SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); +SQLITE_API double sqlite3_value_double(sqlite3_value*); +SQLITE_API int sqlite3_value_int(sqlite3_value*); +SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*); +SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*); +SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); +SQLITE_API int sqlite3_value_type(sqlite3_value*); +SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); + +/* +** CAPI3REF: Obtain Aggregate Function Context +** +** Implementions of aggregate SQL functions use this +** routine to allocate memory for storing their state. +** +** ^The first time the sqlite3_aggregate_context(C,N) routine is called +** for a particular aggregate function, SQLite +** allocates N of memory, zeroes out that memory, and returns a pointer +** to the new memory. ^On second and subsequent calls to +** sqlite3_aggregate_context() for the same aggregate function instance, +** the same buffer is returned. Sqlite3_aggregate_context() is normally +** called once for each invocation of the xStep callback and then one +** last time when the xFinal callback is invoked. ^(When no rows match +** an aggregate query, the xStep() callback of the aggregate function +** implementation is never called and xFinal() is called exactly once. +** In those cases, sqlite3_aggregate_context() might be called for the +** first time from within xFinal().)^ +** +** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is +** less than or equal to zero or if a memory allocate error occurs. +** +** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is +** determined by the N parameter on first successful call. Changing the +** value of N in subsequent call to sqlite3_aggregate_context() within +** the same aggregate function instance will not resize the memory +** allocation.)^ +** +** ^SQLite automatically frees the memory allocated by +** sqlite3_aggregate_context() when the aggregate query concludes. +** +** The first parameter must be a copy of the +** [sqlite3_context | SQL function context] that is the first parameter +** to the xStep or xFinal callback routine that implements the aggregate +** function. +** +** This routine must be called from the same thread in which +** the aggregate SQL function is running. +*/ +SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); + +/* +** CAPI3REF: User Data For Functions +** +** ^The sqlite3_user_data() interface returns a copy of +** the pointer that was the pUserData parameter (the 5th parameter) +** of the [sqlite3_create_function()] +** and [sqlite3_create_function16()] routines that originally +** registered the application defined function. +** +** This routine must be called from the same thread in which +** the application-defined function is running. +*/ +SQLITE_API void *sqlite3_user_data(sqlite3_context*); + +/* +** CAPI3REF: Database Connection For Functions +** +** ^The sqlite3_context_db_handle() interface returns a copy of +** the pointer to the [database connection] (the 1st parameter) +** of the [sqlite3_create_function()] +** and [sqlite3_create_function16()] routines that originally +** registered the application defined function. +*/ +SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); + +/* +** CAPI3REF: Function Auxiliary Data +** +** The following two functions may be used by scalar SQL functions to +** associate metadata with argument values. If the same value is passed to +** multiple invocations of the same SQL function during query execution, under +** some circumstances the associated metadata may be preserved. This may +** be used, for example, to add a regular-expression matching scalar +** function. The compiled version of the regular expression is stored as +** metadata associated with the SQL value passed as the regular expression +** pattern. The compiled regular expression can be reused on multiple +** invocations of the same function so that the original pattern string +** does not need to be recompiled on each invocation. +** +** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata +** associated by the sqlite3_set_auxdata() function with the Nth argument +** value to the application-defined function. ^If no metadata has been ever +** been set for the Nth argument of the function, or if the corresponding +** function parameter has changed since the meta-data was set, +** then sqlite3_get_auxdata() returns a NULL pointer. +** +** ^The sqlite3_set_auxdata() interface saves the metadata +** pointed to by its 3rd parameter as the metadata for the N-th +** argument of the application-defined function. Subsequent +** calls to sqlite3_get_auxdata() might return this data, if it has +** not been destroyed. +** ^If it is not NULL, SQLite will invoke the destructor +** function given by the 4th parameter to sqlite3_set_auxdata() on +** the metadata when the corresponding function parameter changes +** or when the SQL statement completes, whichever comes first. +** +** SQLite is free to call the destructor and drop metadata on any +** parameter of any function at any time. ^The only guarantee is that +** the destructor will be called before the metadata is dropped. +** +** ^(In practice, metadata is preserved between function calls for +** expressions that are constant at compile time. This includes literal +** values and [parameters].)^ +** +** These routines must be called from the same thread in which +** the SQL function is running. +*/ +SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); +SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); + + +/* +** CAPI3REF: Constants Defining Special Destructor Behavior +** +** These are special values for the destructor that is passed in as the +** final argument to routines like [sqlite3_result_blob()]. ^If the destructor +** argument is SQLITE_STATIC, it means that the content pointer is constant +** and will never change. It does not need to be destroyed. ^The +** SQLITE_TRANSIENT value means that the content will likely change in +** the near future and that SQLite should make its own private copy of +** the content before returning. +** +** The typedef is necessary to work around problems in certain +** C++ compilers. See ticket #2191. +*/ +typedef void (*sqlite3_destructor_type)(void*); +#define SQLITE_STATIC ((sqlite3_destructor_type)0) +#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) + +/* +** CAPI3REF: Setting The Result Of An SQL Function +** +** These routines are used by the xFunc or xFinal callbacks that +** implement SQL functions and aggregates. See +** [sqlite3_create_function()] and [sqlite3_create_function16()] +** for additional information. +** +** These functions work very much like the [parameter binding] family of +** functions used to bind values to host parameters in prepared statements. +** Refer to the [SQL parameter] documentation for additional information. +** +** ^The sqlite3_result_blob() interface sets the result from +** an application-defined function to be the BLOB whose content is pointed +** to by the second parameter and which is N bytes long where N is the +** third parameter. +** +** ^The sqlite3_result_zeroblob() interfaces set the result of +** the application-defined function to be a BLOB containing all zero +** bytes and N bytes in size, where N is the value of the 2nd parameter. +** +** ^The sqlite3_result_double() interface sets the result from +** an application-defined function to be a floating point value specified +** by its 2nd argument. +** +** ^The sqlite3_result_error() and sqlite3_result_error16() functions +** cause the implemented SQL function to throw an exception. +** ^SQLite uses the string pointed to by the +** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16() +** as the text of an error message. ^SQLite interprets the error +** message string from sqlite3_result_error() as UTF-8. ^SQLite +** interprets the string from sqlite3_result_error16() as UTF-16 in native +** byte order. ^If the third parameter to sqlite3_result_error() +** or sqlite3_result_error16() is negative then SQLite takes as the error +** message all text up through the first zero character. +** ^If the third parameter to sqlite3_result_error() or +** sqlite3_result_error16() is non-negative then SQLite takes that many +** bytes (not characters) from the 2nd parameter as the error message. +** ^The sqlite3_result_error() and sqlite3_result_error16() +** routines make a private copy of the error message text before +** they return. Hence, the calling function can deallocate or +** modify the text after they return without harm. +** ^The sqlite3_result_error_code() function changes the error code +** returned by SQLite as a result of an error in a function. ^By default, +** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() +** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. +** +** ^The sqlite3_result_toobig() interface causes SQLite to throw an error +** indicating that a string or BLOB is too long to represent. +** +** ^The sqlite3_result_nomem() interface causes SQLite to throw an error +** indicating that a memory allocation failed. +** +** ^The sqlite3_result_int() interface sets the return value +** of the application-defined function to be the 32-bit signed integer +** value given in the 2nd argument. +** ^The sqlite3_result_int64() interface sets the return value +** of the application-defined function to be the 64-bit signed integer +** value given in the 2nd argument. +** +** ^The sqlite3_result_null() interface sets the return value +** of the application-defined function to be NULL. +** +** ^The sqlite3_result_text(), sqlite3_result_text16(), +** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces +** set the return value of the application-defined function to be +** a text string which is represented as UTF-8, UTF-16 native byte order, +** UTF-16 little endian, or UTF-16 big endian, respectively. +** ^SQLite takes the text result from the application from +** the 2nd parameter of the sqlite3_result_text* interfaces. +** ^If the 3rd parameter to the sqlite3_result_text* interfaces +** is negative, then SQLite takes result text from the 2nd parameter +** through the first zero character. +** ^If the 3rd parameter to the sqlite3_result_text* interfaces +** is non-negative, then as many bytes (not characters) of the text +** pointed to by the 2nd parameter are taken as the application-defined +** function result. +** ^If the 4th parameter to the sqlite3_result_text* interfaces +** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that +** function as the destructor on the text or BLOB result when it has +** finished using that result. +** ^If the 4th parameter to the sqlite3_result_text* interfaces or to +** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite +** assumes that the text or BLOB result is in constant space and does not +** copy the content of the parameter nor call a destructor on the content +** when it has finished using that result. +** ^If the 4th parameter to the sqlite3_result_text* interfaces +** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT +** then SQLite makes a copy of the result into space obtained from +** from [sqlite3_malloc()] before it returns. +** +** ^The sqlite3_result_value() interface sets the result of +** the application-defined function to be a copy the +** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The +** sqlite3_result_value() interface makes a copy of the [sqlite3_value] +** so that the [sqlite3_value] specified in the parameter may change or +** be deallocated after sqlite3_result_value() returns without harm. +** ^A [protected sqlite3_value] object may always be used where an +** [unprotected sqlite3_value] object is required, so either +** kind of [sqlite3_value] object can be used with this interface. +** +** If these routines are called from within the different thread +** than the one containing the application-defined function that received +** the [sqlite3_context] pointer, the results are undefined. +*/ +SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_double(sqlite3_context*, double); +SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); +SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); +SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); +SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); +SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); +SQLITE_API void sqlite3_result_int(sqlite3_context*, int); +SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); +SQLITE_API void sqlite3_result_null(sqlite3_context*); +SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); +SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); +SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); +SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); +SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); + +/* +** CAPI3REF: Define New Collating Sequences +** +** These functions are used to add new collation sequences to the +** [database connection] specified as the first argument. +** +** ^The name of the new collation sequence is specified as a UTF-8 string +** for sqlite3_create_collation() and sqlite3_create_collation_v2() +** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases +** the name is passed as the second function argument. +** +** ^The third argument may be one of the constants [SQLITE_UTF8], +** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied +** routine expects to be passed pointers to strings encoded using UTF-8, +** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The +** third argument might also be [SQLITE_UTF16] to indicate that the routine +** expects pointers to be UTF-16 strings in the native byte order, or the +** argument can be [SQLITE_UTF16_ALIGNED] if the +** the routine expects pointers to 16-bit word aligned strings +** of UTF-16 in the native byte order. +** +** A pointer to the user supplied routine must be passed as the fifth +** argument. ^If it is NULL, this is the same as deleting the collation +** sequence (so that SQLite cannot call it anymore). +** ^Each time the application supplied function is invoked, it is passed +** as its first parameter a copy of the void* passed as the fourth argument +** to sqlite3_create_collation() or sqlite3_create_collation16(). +** +** ^The remaining arguments to the application-supplied routine are two strings, +** each represented by a (length, data) pair and encoded in the encoding +** that was passed as the third argument when the collation sequence was +** registered. The application defined collation routine should +** return negative, zero or positive if the first string is less than, +** equal to, or greater than the second string. i.e. (STRING1 - STRING2). +** +** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() +** except that it takes an extra argument which is a destructor for +** the collation. ^The destructor is called when the collation is +** destroyed and is passed a copy of the fourth parameter void* pointer +** of the sqlite3_create_collation_v2(). +** ^Collations are destroyed when they are overridden by later calls to the +** collation creation functions or when the [database connection] is closed +** using [sqlite3_close()]. +** +** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()]. +*/ +SQLITE_API int sqlite3_create_collation( + sqlite3*, + const char *zName, + int eTextRep, + void*, + int(*xCompare)(void*,int,const void*,int,const void*) +); +SQLITE_API int sqlite3_create_collation_v2( + sqlite3*, + const char *zName, + int eTextRep, + void*, + int(*xCompare)(void*,int,const void*,int,const void*), + void(*xDestroy)(void*) +); +SQLITE_API int sqlite3_create_collation16( + sqlite3*, + const void *zName, + int eTextRep, + void*, + int(*xCompare)(void*,int,const void*,int,const void*) +); + +/* +** CAPI3REF: Collation Needed Callbacks +** +** ^To avoid having to register all collation sequences before a database +** can be used, a single callback function may be registered with the +** [database connection] to be invoked whenever an undefined collation +** sequence is required. +** +** ^If the function is registered using the sqlite3_collation_needed() API, +** then it is passed the names of undefined collation sequences as strings +** encoded in UTF-8. ^If sqlite3_collation_needed16() is used, +** the names are passed as UTF-16 in machine native byte order. +** ^A call to either function replaces the existing collation-needed callback. +** +** ^(When the callback is invoked, the first argument passed is a copy +** of the second argument to sqlite3_collation_needed() or +** sqlite3_collation_needed16(). The second argument is the database +** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], +** or [SQLITE_UTF16LE], indicating the most desirable form of the collation +** sequence function required. The fourth parameter is the name of the +** required collation sequence.)^ +** +** The callback function should register the desired collation using +** [sqlite3_create_collation()], [sqlite3_create_collation16()], or +** [sqlite3_create_collation_v2()]. +*/ +SQLITE_API int sqlite3_collation_needed( + sqlite3*, + void*, + void(*)(void*,sqlite3*,int eTextRep,const char*) +); +SQLITE_API int sqlite3_collation_needed16( + sqlite3*, + void*, + void(*)(void*,sqlite3*,int eTextRep,const void*) +); + +/* +** Specify the key for an encrypted database. This routine should be +** called right after sqlite3_open(). +** +** The code to implement this API is not available in the public release +** of SQLite. +*/ +SQLITE_API int sqlite3_key( + sqlite3 *db, /* Database to be rekeyed */ + const void *pKey, int nKey /* The key */ +); + +/* +** Change the key on an open database. If the current database is not +** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the +** database is decrypted. +** +** The code to implement this API is not available in the public release +** of SQLite. +*/ +SQLITE_API int sqlite3_rekey( + sqlite3 *db, /* Database to be rekeyed */ + const void *pKey, int nKey /* The new key */ +); + +/* +** CAPI3REF: Suspend Execution For A Short Time +** +** ^The sqlite3_sleep() function causes the current thread to suspend execution +** for at least a number of milliseconds specified in its parameter. +** +** ^If the operating system does not support sleep requests with +** millisecond time resolution, then the time will be rounded up to +** the nearest second. ^The number of milliseconds of sleep actually +** requested from the operating system is returned. +** +** ^SQLite implements this interface by calling the xSleep() +** method of the default [sqlite3_vfs] object. +*/ +SQLITE_API int sqlite3_sleep(int); + +/* +** CAPI3REF: Name Of The Folder Holding Temporary Files +** +** ^(If this global variable is made to point to a string which is +** the name of a folder (a.k.a. directory), then all temporary files +** created by SQLite when using a built-in [sqlite3_vfs | VFS] +** will be placed in that directory.)^ ^If this variable +** is a NULL pointer, then SQLite performs a search for an appropriate +** temporary file directory. +** +** It is not safe to read or modify this variable in more than one +** thread at a time. It is not safe to read or modify this variable +** if a [database connection] is being used at the same time in a separate +** thread. +** It is intended that this variable be set once +** as part of process initialization and before any SQLite interface +** routines have been called and that this variable remain unchanged +** thereafter. +** +** ^The [temp_store_directory pragma] may modify this variable and cause +** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, +** the [temp_store_directory pragma] always assumes that any string +** that this variable points to is held in memory obtained from +** [sqlite3_malloc] and the pragma may attempt to free that memory +** using [sqlite3_free]. +** Hence, if this variable is modified directly, either it should be +** made NULL or made to point to memory obtained from [sqlite3_malloc] +** or else the use of the [temp_store_directory pragma] should be avoided. +*/ +SQLITE_API char *sqlite3_temp_directory; + +/* +** CAPI3REF: Test For Auto-Commit Mode +** KEYWORDS: {autocommit mode} +** +** ^The sqlite3_get_autocommit() interface returns non-zero or +** zero if the given database connection is or is not in autocommit mode, +** respectively. ^Autocommit mode is on by default. +** ^Autocommit mode is disabled by a [BEGIN] statement. +** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK]. +** +** If certain kinds of errors occur on a statement within a multi-statement +** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], +** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the +** transaction might be rolled back automatically. The only way to +** find out whether SQLite automatically rolled back the transaction after +** an error is to use this function. +** +** If another thread changes the autocommit status of the database +** connection while this routine is running, then the return value +** is undefined. +*/ +SQLITE_API int sqlite3_get_autocommit(sqlite3*); + +/* +** CAPI3REF: Find The Database Handle Of A Prepared Statement +** +** ^The sqlite3_db_handle interface returns the [database connection] handle +** to which a [prepared statement] belongs. ^The [database connection] +** returned by sqlite3_db_handle is the same [database connection] +** that was the first argument +** to the [sqlite3_prepare_v2()] call (or its variants) that was used to +** create the statement in the first place. +*/ +SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); + +/* +** CAPI3REF: Find the next prepared statement +** +** ^This interface returns a pointer to the next [prepared statement] after +** pStmt associated with the [database connection] pDb. ^If pStmt is NULL +** then this interface returns a pointer to the first prepared statement +** associated with the database connection pDb. ^If no prepared statement +** satisfies the conditions of this routine, it returns NULL. +** +** The [database connection] pointer D in a call to +** [sqlite3_next_stmt(D,S)] must refer to an open database +** connection and in particular must not be a NULL pointer. +*/ +SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); + +/* +** CAPI3REF: Commit And Rollback Notification Callbacks +** +** ^The sqlite3_commit_hook() interface registers a callback +** function to be invoked whenever a transaction is [COMMIT | committed]. +** ^Any callback set by a previous call to sqlite3_commit_hook() +** for the same database connection is overridden. +** ^The sqlite3_rollback_hook() interface registers a callback +** function to be invoked whenever a transaction is [ROLLBACK | rolled back]. +** ^Any callback set by a previous call to sqlite3_rollback_hook() +** for the same database connection is overridden. +** ^The pArg argument is passed through to the callback. +** ^If the callback on a commit hook function returns non-zero, +** then the commit is converted into a rollback. +** +** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions +** return the P argument from the previous call of the same function +** on the same [database connection] D, or NULL for +** the first call for each function on D. +** +** The callback implementation must not do anything that will modify +** the database connection that invoked the callback. Any actions +** to modify the database connection must be deferred until after the +** completion of the [sqlite3_step()] call that triggered the commit +** or rollback hook in the first place. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** ^Registering a NULL function disables the callback. +** +** ^When the commit hook callback routine returns zero, the [COMMIT] +** operation is allowed to continue normally. ^If the commit hook +** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK]. +** ^The rollback hook is invoked on a rollback that results from a commit +** hook returning non-zero, just as it would be with any other rollback. +** +** ^For the purposes of this API, a transaction is said to have been +** rolled back if an explicit "ROLLBACK" statement is executed, or +** an error or constraint causes an implicit rollback to occur. +** ^The rollback callback is not invoked if a transaction is +** automatically rolled back because the database connection is closed. +** ^The rollback callback is not invoked if a transaction is +** rolled back because a commit callback returned non-zero. +** +** See also the [sqlite3_update_hook()] interface. +*/ +SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); +SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); + +/* +** CAPI3REF: Data Change Notification Callbacks +** +** ^The sqlite3_update_hook() interface registers a callback function +** with the [database connection] identified by the first argument +** to be invoked whenever a row is updated, inserted or deleted. +** ^Any callback set by a previous call to this function +** for the same database connection is overridden. +** +** ^The second argument is a pointer to the function to invoke when a +** row is updated, inserted or deleted. +** ^The first argument to the callback is a copy of the third argument +** to sqlite3_update_hook(). +** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], +** or [SQLITE_UPDATE], depending on the operation that caused the callback +** to be invoked. +** ^The third and fourth arguments to the callback contain pointers to the +** database and table name containing the affected row. +** ^The final callback parameter is the [rowid] of the row. +** ^In the case of an update, this is the [rowid] after the update takes place. +** +** ^(The update hook is not invoked when internal system tables are +** modified (i.e. sqlite_master and sqlite_sequence).)^ +** +** ^In the current implementation, the update hook +** is not invoked when duplication rows are deleted because of an +** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook +** invoked when rows are deleted using the [truncate optimization]. +** The exceptions defined in this paragraph might change in a future +** release of SQLite. +** +** The update hook implementation must not do anything that will modify +** the database connection that invoked the update hook. Any actions +** to modify the database connection must be deferred until after the +** completion of the [sqlite3_step()] call that triggered the update hook. +** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their +** database connections for the meaning of "modify" in this paragraph. +** +** ^The sqlite3_update_hook(D,C,P) function +** returns the P argument from the previous call +** on the same [database connection] D, or NULL for +** the first call on D. +** +** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] +** interfaces. +*/ +SQLITE_API void *sqlite3_update_hook( + sqlite3*, + void(*)(void *,int ,char const *,char const *,sqlite3_int64), + void* +); + +/* +** CAPI3REF: Enable Or Disable Shared Pager Cache +** KEYWORDS: {shared cache} +** +** ^(This routine enables or disables the sharing of the database cache +** and schema data structures between [database connection | connections] +** to the same database. Sharing is enabled if the argument is true +** and disabled if the argument is false.)^ +** +** ^Cache sharing is enabled and disabled for an entire process. +** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, +** sharing was enabled or disabled for each thread separately. +** +** ^(The cache sharing mode set by this interface effects all subsequent +** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. +** Existing database connections continue use the sharing mode +** that was in effect at the time they were opened.)^ +** +** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled +** successfully. An [error code] is returned otherwise.)^ +** +** ^Shared cache is disabled by default. But this might change in +** future releases of SQLite. Applications that care about shared +** cache setting should set it explicitly. +** +** See Also: [SQLite Shared-Cache Mode] +*/ +SQLITE_API int sqlite3_enable_shared_cache(int); + +/* +** CAPI3REF: Attempt To Free Heap Memory +** +** ^The sqlite3_release_memory() interface attempts to free N bytes +** of heap memory by deallocating non-essential memory allocations +** held by the database library. Memory used to cache database +** pages to improve performance is an example of non-essential memory. +** ^sqlite3_release_memory() returns the number of bytes actually freed, +** which might be more or less than the amount requested. +*/ +SQLITE_API int sqlite3_release_memory(int); + +/* +** CAPI3REF: Impose A Limit On Heap Size +** +** ^The sqlite3_soft_heap_limit() interface places a "soft" limit +** on the amount of heap memory that may be allocated by SQLite. +** ^If an internal allocation is requested that would exceed the +** soft heap limit, [sqlite3_release_memory()] is invoked one or +** more times to free up some space before the allocation is performed. +** +** ^The limit is called "soft" because if [sqlite3_release_memory()] +** cannot free sufficient memory to prevent the limit from being exceeded, +** the memory is allocated anyway and the current operation proceeds. +** +** ^A negative or zero value for N means that there is no soft heap limit and +** [sqlite3_release_memory()] will only be called when memory is exhausted. +** ^The default value for the soft heap limit is zero. +** +** ^(SQLite makes a best effort to honor the soft heap limit. +** But if the soft heap limit cannot be honored, execution will +** continue without error or notification.)^ This is why the limit is +** called a "soft" limit. It is advisory only. +** +** Prior to SQLite version 3.5.0, this routine only constrained the memory +** allocated by a single thread - the same thread in which this routine +** runs. Beginning with SQLite version 3.5.0, the soft heap limit is +** applied to all threads. The value specified for the soft heap limit +** is an upper bound on the total memory allocation for all threads. In +** version 3.5.0 there is no mechanism for limiting the heap usage for +** individual threads. +*/ +SQLITE_API void sqlite3_soft_heap_limit(int); + +/* +** CAPI3REF: Extract Metadata About A Column Of A Table +** +** ^This routine returns metadata about a specific column of a specific +** database table accessible using the [database connection] handle +** passed as the first function argument. +** +** ^The column is identified by the second, third and fourth parameters to +** this function. ^The second parameter is either the name of the database +** (i.e. "main", "temp", or an attached database) containing the specified +** table or NULL. ^If it is NULL, then all attached databases are searched +** for the table using the same algorithm used by the database engine to +** resolve unqualified table references. +** +** ^The third and fourth parameters to this function are the table and column +** name of the desired column, respectively. Neither of these parameters +** may be NULL. +** +** ^Metadata is returned by writing to the memory locations passed as the 5th +** and subsequent parameters to this function. ^Any of these arguments may be +** NULL, in which case the corresponding element of metadata is omitted. +** +** ^(
+** +**
Parameter Output
Type
Description +** +**
5th const char* Data type +**
6th const char* Name of default collation sequence +**
7th int True if column has a NOT NULL constraint +**
8th int True if column is part of the PRIMARY KEY +**
9th int True if column is [AUTOINCREMENT] +**
+**
)^ +** +** ^The memory pointed to by the character pointers returned for the +** declaration type and collation sequence is valid only until the next +** call to any SQLite API function. +** +** ^If the specified table is actually a view, an [error code] is returned. +** +** ^If the specified column is "rowid", "oid" or "_rowid_" and an +** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output +** parameters are set for the explicitly declared column. ^(If there is no +** explicitly declared [INTEGER PRIMARY KEY] column, then the output +** parameters are set as follows: +** +**
+**     data type: "INTEGER"
+**     collation sequence: "BINARY"
+**     not null: 0
+**     primary key: 1
+**     auto increment: 0
+** 
)^ +** +** ^(This function may load one or more schemas from database files. If an +** error occurs during this process, or if the requested table or column +** cannot be found, an [error code] is returned and an error message left +** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^ +** +** ^This API is only available if the library was compiled with the +** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. +*/ +SQLITE_API int sqlite3_table_column_metadata( + sqlite3 *db, /* Connection handle */ + const char *zDbName, /* Database name or NULL */ + const char *zTableName, /* Table name */ + const char *zColumnName, /* Column name */ + char const **pzDataType, /* OUTPUT: Declared data type */ + char const **pzCollSeq, /* OUTPUT: Collation sequence name */ + int *pNotNull, /* OUTPUT: True if NOT NULL constraint exists */ + int *pPrimaryKey, /* OUTPUT: True if column part of PK */ + int *pAutoinc /* OUTPUT: True if column is auto-increment */ +); + +/* +** CAPI3REF: Load An Extension +** +** ^This interface loads an SQLite extension library from the named file. +** +** ^The sqlite3_load_extension() interface attempts to load an +** SQLite extension library contained in the file zFile. +** +** ^The entry point is zProc. +** ^zProc may be 0, in which case the name of the entry point +** defaults to "sqlite3_extension_init". +** ^The sqlite3_load_extension() interface returns +** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. +** ^If an error occurs and pzErrMsg is not 0, then the +** [sqlite3_load_extension()] interface shall attempt to +** fill *pzErrMsg with error message text stored in memory +** obtained from [sqlite3_malloc()]. The calling function +** should free this memory by calling [sqlite3_free()]. +** +** ^Extension loading must be enabled using +** [sqlite3_enable_load_extension()] prior to calling this API, +** otherwise an error will be returned. +** +** See also the [load_extension() SQL function]. +*/ +SQLITE_API int sqlite3_load_extension( + sqlite3 *db, /* Load the extension into this database connection */ + const char *zFile, /* Name of the shared library containing extension */ + const char *zProc, /* Entry point. Derived from zFile if 0 */ + char **pzErrMsg /* Put error message here if not 0 */ +); + +/* +** CAPI3REF: Enable Or Disable Extension Loading +** +** ^So as not to open security holes in older applications that are +** unprepared to deal with extension loading, and as a means of disabling +** extension loading while evaluating user-entered SQL, the following API +** is provided to turn the [sqlite3_load_extension()] mechanism on and off. +** +** ^Extension loading is off by default. See ticket #1863. +** ^Call the sqlite3_enable_load_extension() routine with onoff==1 +** to turn extension loading on and call it with onoff==0 to turn +** it back off again. +*/ +SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); + +/* +** CAPI3REF: Automatically Load An Extensions +** +** ^This API can be invoked at program startup in order to register +** one or more statically linked extensions that will be available +** to all new [database connections]. +** +** ^(This routine stores a pointer to the extension entry point +** in an array that is obtained from [sqlite3_malloc()]. That memory +** is deallocated by [sqlite3_reset_auto_extension()].)^ +** +** ^This function registers an extension entry point that is +** automatically invoked whenever a new [database connection] +** is opened using [sqlite3_open()], [sqlite3_open16()], +** or [sqlite3_open_v2()]. +** ^Duplicate extensions are detected so calling this routine +** multiple times with the same extension is harmless. +** ^Automatic extensions apply across all threads. +*/ +SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); + +/* +** CAPI3REF: Reset Automatic Extension Loading +** +** ^(This function disables all previously registered automatic +** extensions. It undoes the effect of all prior +** [sqlite3_auto_extension()] calls.)^ +** +** ^This function disables automatic extensions in all threads. +*/ +SQLITE_API void sqlite3_reset_auto_extension(void); + +/* +****** EXPERIMENTAL - subject to change without notice ************** +** +** The interface to the virtual-table mechanism is currently considered +** to be experimental. The interface might change in incompatible ways. +** If this is a problem for you, do not use the interface at this time. +** +** When the virtual-table mechanism stabilizes, we will declare the +** interface fixed, support it indefinitely, and remove this comment. +*/ + +/* +** Structures used by the virtual table interface +*/ +typedef struct sqlite3_vtab sqlite3_vtab; +typedef struct sqlite3_index_info sqlite3_index_info; +typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; +typedef struct sqlite3_module sqlite3_module; + +/* +** CAPI3REF: Virtual Table Object +** KEYWORDS: sqlite3_module {virtual table module} +** EXPERIMENTAL +** +** This structure, sometimes called a a "virtual table module", +** defines the implementation of a [virtual tables]. +** This structure consists mostly of methods for the module. +** +** ^A virtual table module is created by filling in a persistent +** instance of this structure and passing a pointer to that instance +** to [sqlite3_create_module()] or [sqlite3_create_module_v2()]. +** ^The registration remains valid until it is replaced by a different +** module or until the [database connection] closes. The content +** of this structure must not change while it is registered with +** any database connection. +*/ +struct sqlite3_module { + int iVersion; + int (*xCreate)(sqlite3*, void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVTab, char**); + int (*xConnect)(sqlite3*, void *pAux, + int argc, const char *const*argv, + sqlite3_vtab **ppVTab, char**); + int (*xBestIndex)(sqlite3_vtab *pVTab, sqlite3_index_info*); + int (*xDisconnect)(sqlite3_vtab *pVTab); + int (*xDestroy)(sqlite3_vtab *pVTab); + int (*xOpen)(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor); + int (*xClose)(sqlite3_vtab_cursor*); + int (*xFilter)(sqlite3_vtab_cursor*, int idxNum, const char *idxStr, + int argc, sqlite3_value **argv); + int (*xNext)(sqlite3_vtab_cursor*); + int (*xEof)(sqlite3_vtab_cursor*); + int (*xColumn)(sqlite3_vtab_cursor*, sqlite3_context*, int); + int (*xRowid)(sqlite3_vtab_cursor*, sqlite3_int64 *pRowid); + int (*xUpdate)(sqlite3_vtab *, int, sqlite3_value **, sqlite3_int64 *); + int (*xBegin)(sqlite3_vtab *pVTab); + int (*xSync)(sqlite3_vtab *pVTab); + int (*xCommit)(sqlite3_vtab *pVTab); + int (*xRollback)(sqlite3_vtab *pVTab); + int (*xFindFunction)(sqlite3_vtab *pVtab, int nArg, const char *zName, + void (**pxFunc)(sqlite3_context*,int,sqlite3_value**), + void **ppArg); + int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); +}; + +/* +** CAPI3REF: Virtual Table Indexing Information +** KEYWORDS: sqlite3_index_info +** EXPERIMENTAL +** +** The sqlite3_index_info structure and its substructures is used to +** pass information into and receive the reply from the [xBestIndex] +** method of a [virtual table module]. The fields under **Inputs** are the +** inputs to xBestIndex and are read-only. xBestIndex inserts its +** results into the **Outputs** fields. +** +** ^(The aConstraint[] array records WHERE clause constraints of the form: +** +**
column OP expr
+** +** where OP is =, <, <=, >, or >=.)^ ^(The particular operator is +** stored in aConstraint[].op.)^ ^(The index of the column is stored in +** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the +** expr on the right-hand side can be evaluated (and thus the constraint +** is usable) and false if it cannot.)^ +** +** ^The optimizer automatically inverts terms of the form "expr OP column" +** and makes other simplifications to the WHERE clause in an attempt to +** get as many WHERE clause terms into the form shown above as possible. +** ^The aConstraint[] array only reports WHERE clause terms that are +** relevant to the particular virtual table being queried. +** +** ^Information about the ORDER BY clause is stored in aOrderBy[]. +** ^Each term of aOrderBy records a column of the ORDER BY clause. +** +** The [xBestIndex] method must fill aConstraintUsage[] with information +** about what parameters to pass to xFilter. ^If argvIndex>0 then +** the right-hand side of the corresponding aConstraint[] is evaluated +** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit +** is true, then the constraint is assumed to be fully handled by the +** virtual table and is not checked again by SQLite.)^ +** +** ^The idxNum and idxPtr values are recorded and passed into the +** [xFilter] method. +** ^[sqlite3_free()] is used to free idxPtr if and only if +** needToFreeIdxPtr is true. +** +** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in +** the correct order to satisfy the ORDER BY clause so that no separate +** sorting step is required. +** +** ^The estimatedCost value is an estimate of the cost of doing the +** particular lookup. A full scan of a table with N entries should have +** a cost of N. A binary search of a table of N entries should have a +** cost of approximately log(N). +*/ +struct sqlite3_index_info { + /* Inputs */ + int nConstraint; /* Number of entries in aConstraint */ + struct sqlite3_index_constraint { + int iColumn; /* Column on left-hand side of constraint */ + unsigned char op; /* Constraint operator */ + unsigned char usable; /* True if this constraint is usable */ + int iTermOffset; /* Used internally - xBestIndex should ignore */ + } *aConstraint; /* Table of WHERE clause constraints */ + int nOrderBy; /* Number of terms in the ORDER BY clause */ + struct sqlite3_index_orderby { + int iColumn; /* Column number */ + unsigned char desc; /* True for DESC. False for ASC. */ + } *aOrderBy; /* The ORDER BY clause */ + /* Outputs */ + struct sqlite3_index_constraint_usage { + int argvIndex; /* if >0, constraint is part of argv to xFilter */ + unsigned char omit; /* Do not code a test for this constraint */ + } *aConstraintUsage; + int idxNum; /* Number used to identify the index */ + char *idxStr; /* String, possibly obtained from sqlite3_malloc */ + int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ + int orderByConsumed; /* True if output is already ordered */ + double estimatedCost; /* Estimated cost of using this index */ +}; +#define SQLITE_INDEX_CONSTRAINT_EQ 2 +#define SQLITE_INDEX_CONSTRAINT_GT 4 +#define SQLITE_INDEX_CONSTRAINT_LE 8 +#define SQLITE_INDEX_CONSTRAINT_LT 16 +#define SQLITE_INDEX_CONSTRAINT_GE 32 +#define SQLITE_INDEX_CONSTRAINT_MATCH 64 + +/* +** CAPI3REF: Register A Virtual Table Implementation +** EXPERIMENTAL +** +** ^These routines are used to register a new [virtual table module] name. +** ^Module names must be registered before +** creating a new [virtual table] using the module and before using a +** preexisting [virtual table] for the module. +** +** ^The module name is registered on the [database connection] specified +** by the first parameter. ^The name of the module is given by the +** second parameter. ^The third parameter is a pointer to +** the implementation of the [virtual table module]. ^The fourth +** parameter is an arbitrary client data pointer that is passed through +** into the [xCreate] and [xConnect] methods of the virtual table module +** when a new virtual table is be being created or reinitialized. +** +** ^The sqlite3_create_module_v2() interface has a fifth parameter which +** is a pointer to a destructor for the pClientData. ^SQLite will +** invoke the destructor function (if it is not NULL) when SQLite +** no longer needs the pClientData pointer. ^The sqlite3_create_module() +** interface is equivalent to sqlite3_create_module_v2() with a NULL +** destructor. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module( + sqlite3 *db, /* SQLite connection to register module with */ + const char *zName, /* Name of the module */ + const sqlite3_module *p, /* Methods for the module */ + void *pClientData /* Client data for xCreate/xConnect */ +); +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2( + sqlite3 *db, /* SQLite connection to register module with */ + const char *zName, /* Name of the module */ + const sqlite3_module *p, /* Methods for the module */ + void *pClientData, /* Client data for xCreate/xConnect */ + void(*xDestroy)(void*) /* Module destructor function */ +); + +/* +** CAPI3REF: Virtual Table Instance Object +** KEYWORDS: sqlite3_vtab +** EXPERIMENTAL +** +** Every [virtual table module] implementation uses a subclass +** of this object to describe a particular instance +** of the [virtual table]. Each subclass will +** be tailored to the specific needs of the module implementation. +** The purpose of this superclass is to define certain fields that are +** common to all module implementations. +** +** ^Virtual tables methods can set an error message by assigning a +** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should +** take care that any prior string is freed by a call to [sqlite3_free()] +** prior to assigning a new string to zErrMsg. ^After the error message +** is delivered up to the client application, the string will be automatically +** freed by sqlite3_free() and the zErrMsg field will be zeroed. +*/ +struct sqlite3_vtab { + const sqlite3_module *pModule; /* The module for this virtual table */ + int nRef; /* NO LONGER USED */ + char *zErrMsg; /* Error message from sqlite3_mprintf() */ + /* Virtual table implementations will typically add additional fields */ +}; + +/* +** CAPI3REF: Virtual Table Cursor Object +** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} +** EXPERIMENTAL +** +** Every [virtual table module] implementation uses a subclass of the +** following structure to describe cursors that point into the +** [virtual table] and are used +** to loop through the virtual table. Cursors are created using the +** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed +** by the [sqlite3_module.xClose | xClose] method. Cursors are used +** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods +** of the module. Each module implementation will define +** the content of a cursor structure to suit its own needs. +** +** This superclass exists in order to define fields of the cursor that +** are common to all implementations. +*/ +struct sqlite3_vtab_cursor { + sqlite3_vtab *pVtab; /* Virtual table of this cursor */ + /* Virtual table implementations will typically add additional fields */ +}; + +/* +** CAPI3REF: Declare The Schema Of A Virtual Table +** EXPERIMENTAL +** +** ^The [xCreate] and [xConnect] methods of a +** [virtual table module] call this interface +** to declare the format (the names and datatypes of the columns) of +** the virtual tables they implement. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL); + +/* +** CAPI3REF: Overload A Function For A Virtual Table +** EXPERIMENTAL +** +** ^(Virtual tables can provide alternative implementations of functions +** using the [xFindFunction] method of the [virtual table module]. +** But global versions of those functions +** must exist in order to be overloaded.)^ +** +** ^(This API makes sure a global version of a function with a particular +** name and number of parameters exists. If no such function exists +** before this API is called, a new function is created.)^ ^The implementation +** of the new function always causes an exception to be thrown. So +** the new function is not good for anything by itself. Its only +** purpose is to be a placeholder function that can be overloaded +** by a [virtual table]. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg); + +/* +** The interface to the virtual-table mechanism defined above (back up +** to a comment remarkably similar to this one) is currently considered +** to be experimental. The interface might change in incompatible ways. +** If this is a problem for you, do not use the interface at this time. +** +** When the virtual-table mechanism stabilizes, we will declare the +** interface fixed, support it indefinitely, and remove this comment. +** +****** EXPERIMENTAL - subject to change without notice ************** +*/ + +/* +** CAPI3REF: A Handle To An Open BLOB +** KEYWORDS: {BLOB handle} {BLOB handles} +** +** An instance of this object represents an open BLOB on which +** [sqlite3_blob_open | incremental BLOB I/O] can be performed. +** ^Objects of this type are created by [sqlite3_blob_open()] +** and destroyed by [sqlite3_blob_close()]. +** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces +** can be used to read or write small subsections of the BLOB. +** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes. +*/ +typedef struct sqlite3_blob sqlite3_blob; + +/* +** CAPI3REF: Open A BLOB For Incremental I/O +** +** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located +** in row iRow, column zColumn, table zTable in database zDb; +** in other words, the same BLOB that would be selected by: +** +**
+**     SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
+** 
)^ +** +** ^If the flags parameter is non-zero, then the BLOB is opened for read +** and write access. ^If it is zero, the BLOB is opened for read access. +** ^It is not possible to open a column that is part of an index or primary +** key for writing. ^If [foreign key constraints] are enabled, it is +** not possible to open a column that is part of a [child key] for writing. +** +** ^Note that the database name is not the filename that contains +** the database but rather the symbolic name of the database that +** appears after the AS keyword when the database is connected using [ATTACH]. +** ^For the main database file, the database name is "main". +** ^For TEMP tables, the database name is "temp". +** +** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written +** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set +** to be a null pointer.)^ +** ^This function sets the [database connection] error code and message +** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related +** functions. ^Note that the *ppBlob variable is always initialized in a +** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob +** regardless of the success or failure of this routine. +** +** ^(If the row that a BLOB handle points to is modified by an +** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects +** then the BLOB handle is marked as "expired". +** This is true if any column of the row is changed, even a column +** other than the one the BLOB handle is open on.)^ +** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for +** a expired BLOB handle fail with an return code of [SQLITE_ABORT]. +** ^(Changes written into a BLOB prior to the BLOB expiring are not +** rolled back by the expiration of the BLOB. Such changes will eventually +** commit if the transaction continues to completion.)^ +** +** ^Use the [sqlite3_blob_bytes()] interface to determine the size of +** the opened blob. ^The size of a blob may not be changed by this +** interface. Use the [UPDATE] SQL command to change the size of a +** blob. +** +** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces +** and the built-in [zeroblob] SQL function can be used, if desired, +** to create an empty, zero-filled blob in which to read or write using +** this interface. +** +** To avoid a resource leak, every open [BLOB handle] should eventually +** be released by a call to [sqlite3_blob_close()]. +*/ +SQLITE_API int sqlite3_blob_open( + sqlite3*, + const char *zDb, + const char *zTable, + const char *zColumn, + sqlite3_int64 iRow, + int flags, + sqlite3_blob **ppBlob +); + +/* +** CAPI3REF: Close A BLOB Handle +** +** ^Closes an open [BLOB handle]. +** +** ^Closing a BLOB shall cause the current transaction to commit +** if there are no other BLOBs, no pending prepared statements, and the +** database connection is in [autocommit mode]. +** ^If any writes were made to the BLOB, they might be held in cache +** until the close operation if they will fit. +** +** ^(Closing the BLOB often forces the changes +** out to disk and so if any I/O errors occur, they will likely occur +** at the time when the BLOB is closed. Any errors that occur during +** closing are reported as a non-zero return value.)^ +** +** ^(The BLOB is closed unconditionally. Even if this routine returns +** an error code, the BLOB is still closed.)^ +** +** ^Calling this routine with a null pointer (such as would be returned +** by a failed call to [sqlite3_blob_open()]) is a harmless no-op. +*/ +SQLITE_API int sqlite3_blob_close(sqlite3_blob *); + +/* +** CAPI3REF: Return The Size Of An Open BLOB +** +** ^Returns the size in bytes of the BLOB accessible via the +** successfully opened [BLOB handle] in its only argument. ^The +** incremental blob I/O routines can only read or overwriting existing +** blob content; they cannot change the size of a blob. +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +*/ +SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); + +/* +** CAPI3REF: Read Data From A BLOB Incrementally +** +** ^(This function is used to read data from an open [BLOB handle] into a +** caller-supplied buffer. N bytes of data are copied into buffer Z +** from the open BLOB, starting at offset iOffset.)^ +** +** ^If offset iOffset is less than N bytes from the end of the BLOB, +** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is +** less than zero, [SQLITE_ERROR] is returned and no data is read. +** ^The size of the blob (and hence the maximum value of N+iOffset) +** can be determined using the [sqlite3_blob_bytes()] interface. +** +** ^An attempt to read from an expired [BLOB handle] fails with an +** error code of [SQLITE_ABORT]. +** +** ^(On success, sqlite3_blob_read() returns SQLITE_OK. +** Otherwise, an [error code] or an [extended error code] is returned.)^ +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +** +** See also: [sqlite3_blob_write()]. +*/ +SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); + +/* +** CAPI3REF: Write Data Into A BLOB Incrementally +** +** ^This function is used to write data into an open [BLOB handle] from a +** caller-supplied buffer. ^N bytes of data are copied from the buffer Z +** into the open BLOB, starting at offset iOffset. +** +** ^If the [BLOB handle] passed as the first argument was not opened for +** writing (the flags parameter to [sqlite3_blob_open()] was zero), +** this function returns [SQLITE_READONLY]. +** +** ^This function may only modify the contents of the BLOB; it is +** not possible to increase the size of a BLOB using this API. +** ^If offset iOffset is less than N bytes from the end of the BLOB, +** [SQLITE_ERROR] is returned and no data is written. ^If N is +** less than zero [SQLITE_ERROR] is returned and no data is written. +** The size of the BLOB (and hence the maximum value of N+iOffset) +** can be determined using the [sqlite3_blob_bytes()] interface. +** +** ^An attempt to write to an expired [BLOB handle] fails with an +** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred +** before the [BLOB handle] expired are not rolled back by the +** expiration of the handle, though of course those changes might +** have been overwritten by the statement that expired the BLOB handle +** or by other independent statements. +** +** ^(On success, sqlite3_blob_write() returns SQLITE_OK. +** Otherwise, an [error code] or an [extended error code] is returned.)^ +** +** This routine only works on a [BLOB handle] which has been created +** by a prior successful call to [sqlite3_blob_open()] and which has not +** been closed by [sqlite3_blob_close()]. Passing any other pointer in +** to this routine results in undefined and probably undesirable behavior. +** +** See also: [sqlite3_blob_read()]. +*/ +SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); + +/* +** CAPI3REF: Virtual File System Objects +** +** A virtual filesystem (VFS) is an [sqlite3_vfs] object +** that SQLite uses to interact +** with the underlying operating system. Most SQLite builds come with a +** single default VFS that is appropriate for the host computer. +** New VFSes can be registered and existing VFSes can be unregistered. +** The following interfaces are provided. +** +** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name. +** ^Names are case sensitive. +** ^Names are zero-terminated UTF-8 strings. +** ^If there is no match, a NULL pointer is returned. +** ^If zVfsName is NULL then the default VFS is returned. +** +** ^New VFSes are registered with sqlite3_vfs_register(). +** ^Each new VFS becomes the default VFS if the makeDflt flag is set. +** ^The same VFS can be registered multiple times without injury. +** ^To make an existing VFS into the default VFS, register it again +** with the makeDflt flag set. If two different VFSes with the +** same name are registered, the behavior is undefined. If a +** VFS is registered with a name that is NULL or an empty string, +** then the behavior is undefined. +** +** ^Unregister a VFS with the sqlite3_vfs_unregister() interface. +** ^(If the default VFS is unregistered, another VFS is chosen as +** the default. The choice for the new VFS is arbitrary.)^ +*/ +SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); +SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); +SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); + +/* +** CAPI3REF: Mutexes +** +** The SQLite core uses these routines for thread +** synchronization. Though they are intended for internal +** use by SQLite, code that links against SQLite is +** permitted to use any of these routines. +** +** The SQLite source code contains multiple implementations +** of these mutex routines. An appropriate implementation +** is selected automatically at compile-time. ^(The following +** implementations are available in the SQLite core: +** +**
    +**
  • SQLITE_MUTEX_OS2 +**
  • SQLITE_MUTEX_PTHREAD +**
  • SQLITE_MUTEX_W32 +**
  • SQLITE_MUTEX_NOOP +**
)^ +** +** ^The SQLITE_MUTEX_NOOP implementation is a set of routines +** that does no real locking and is appropriate for use in +** a single-threaded application. ^The SQLITE_MUTEX_OS2, +** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations +** are appropriate for use on OS/2, Unix, and Windows. +** +** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor +** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex +** implementation is included with the library. In this case the +** application must supply a custom mutex implementation using the +** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function +** before calling sqlite3_initialize() or any other public sqlite3_ +** function that calls sqlite3_initialize().)^ +** +** ^The sqlite3_mutex_alloc() routine allocates a new +** mutex and returns a pointer to it. ^If it returns NULL +** that means that a mutex could not be allocated. ^SQLite +** will unwind its stack and return an error. ^(The argument +** to sqlite3_mutex_alloc() is one of these integer constants: +** +**
    +**
  • SQLITE_MUTEX_FAST +**
  • SQLITE_MUTEX_RECURSIVE +**
  • SQLITE_MUTEX_STATIC_MASTER +**
  • SQLITE_MUTEX_STATIC_MEM +**
  • SQLITE_MUTEX_STATIC_MEM2 +**
  • SQLITE_MUTEX_STATIC_PRNG +**
  • SQLITE_MUTEX_STATIC_LRU +**
  • SQLITE_MUTEX_STATIC_LRU2 +**
)^ +** +** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) +** cause sqlite3_mutex_alloc() to create +** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE +** is used but not necessarily so when SQLITE_MUTEX_FAST is used. +** The mutex implementation does not need to make a distinction +** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does +** not want to. ^SQLite will only request a recursive mutex in +** cases where it really needs one. ^If a faster non-recursive mutex +** implementation is available on the host platform, the mutex subsystem +** might return such a mutex in response to SQLITE_MUTEX_FAST. +** +** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other +** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return +** a pointer to a static preexisting mutex. ^Six static mutexes are +** used by the current version of SQLite. Future versions of SQLite +** may add additional static mutexes. Static mutexes are for internal +** use by SQLite only. Applications that use SQLite mutexes should +** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or +** SQLITE_MUTEX_RECURSIVE. +** +** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST +** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() +** returns a different mutex on every call. ^But for the static +** mutex types, the same mutex is returned on every call that has +** the same type number. +** +** ^The sqlite3_mutex_free() routine deallocates a previously +** allocated dynamic mutex. ^SQLite is careful to deallocate every +** dynamic mutex that it allocates. The dynamic mutexes must not be in +** use when they are deallocated. Attempting to deallocate a static +** mutex results in undefined behavior. ^SQLite never deallocates +** a static mutex. +** +** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt +** to enter a mutex. ^If another thread is already within the mutex, +** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return +** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK] +** upon successful entry. ^(Mutexes created using +** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. +** In such cases the, +** mutex must be exited an equal number of times before another thread +** can enter.)^ ^(If the same thread tries to enter any other +** kind of mutex more than once, the behavior is undefined. +** SQLite will never exhibit +** such behavior in its own use of mutexes.)^ +** +** ^(Some systems (for example, Windows 95) do not support the operation +** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try() +** will always return SQLITE_BUSY. The SQLite core only ever uses +** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^ +** +** ^The sqlite3_mutex_leave() routine exits a mutex that was +** previously entered by the same thread. ^(The behavior +** is undefined if the mutex is not currently entered by the +** calling thread or is not currently allocated. SQLite will +** never do either.)^ +** +** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or +** sqlite3_mutex_leave() is a NULL pointer, then all three routines +** behave as no-ops. +** +** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. +*/ +SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int); +SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*); +SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); +SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); +SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); + +/* +** CAPI3REF: Mutex Methods Object +** EXPERIMENTAL +** +** An instance of this structure defines the low-level routines +** used to allocate and use mutexes. +** +** Usually, the default mutex implementations provided by SQLite are +** sufficient, however the user has the option of substituting a custom +** implementation for specialized deployments or systems for which SQLite +** does not provide a suitable implementation. In this case, the user +** creates and populates an instance of this structure to pass +** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. +** Additionally, an instance of this structure can be used as an +** output variable when querying the system for the current mutex +** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. +** +** ^The xMutexInit method defined by this structure is invoked as +** part of system initialization by the sqlite3_initialize() function. +** ^The xMutexInit routine is calle by SQLite exactly once for each +** effective call to [sqlite3_initialize()]. +** +** ^The xMutexEnd method defined by this structure is invoked as +** part of system shutdown by the sqlite3_shutdown() function. The +** implementation of this method is expected to release all outstanding +** resources obtained by the mutex methods implementation, especially +** those obtained by the xMutexInit method. ^The xMutexEnd() +** interface is invoked exactly once for each call to [sqlite3_shutdown()]. +** +** ^(The remaining seven methods defined by this structure (xMutexAlloc, +** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and +** xMutexNotheld) implement the following interfaces (respectively): +** +**
    +**
  • [sqlite3_mutex_alloc()]
  • +**
  • [sqlite3_mutex_free()]
  • +**
  • [sqlite3_mutex_enter()]
  • +**
  • [sqlite3_mutex_try()]
  • +**
  • [sqlite3_mutex_leave()]
  • +**
  • [sqlite3_mutex_held()]
  • +**
  • [sqlite3_mutex_notheld()]
  • +**
)^ +** +** The only difference is that the public sqlite3_XXX functions enumerated +** above silently ignore any invocations that pass a NULL pointer instead +** of a valid mutex handle. The implementations of the methods defined +** by this structure are not required to handle this case, the results +** of passing a NULL pointer instead of a valid mutex handle are undefined +** (i.e. it is acceptable to provide an implementation that segfaults if +** it is passed a NULL pointer). +** +** The xMutexInit() method must be threadsafe. ^It must be harmless to +** invoke xMutexInit() mutiple times within the same process and without +** intervening calls to xMutexEnd(). Second and subsequent calls to +** xMutexInit() must be no-ops. +** +** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()] +** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory +** allocation for a static mutex. ^However xMutexAlloc() may use SQLite +** memory allocation for a fast or recursive mutex. +** +** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is +** called, but only if the prior call to xMutexInit returned SQLITE_OK. +** If xMutexInit fails in any way, it is expected to clean up after itself +** prior to returning. +*/ +typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; +struct sqlite3_mutex_methods { + int (*xMutexInit)(void); + int (*xMutexEnd)(void); + sqlite3_mutex *(*xMutexAlloc)(int); + void (*xMutexFree)(sqlite3_mutex *); + void (*xMutexEnter)(sqlite3_mutex *); + int (*xMutexTry)(sqlite3_mutex *); + void (*xMutexLeave)(sqlite3_mutex *); + int (*xMutexHeld)(sqlite3_mutex *); + int (*xMutexNotheld)(sqlite3_mutex *); +}; + +/* +** CAPI3REF: Mutex Verification Routines +** +** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines +** are intended for use inside assert() statements. ^The SQLite core +** never uses these routines except inside an assert() and applications +** are advised to follow the lead of the core. ^The SQLite core only +** provides implementations for these routines when it is compiled +** with the SQLITE_DEBUG flag. ^External mutex implementations +** are only required to provide these routines if SQLITE_DEBUG is +** defined and if NDEBUG is not defined. +** +** ^These routines should return true if the mutex in their argument +** is held or not held, respectively, by the calling thread. +** +** ^The implementation is not required to provided versions of these +** routines that actually work. If the implementation does not provide working +** versions of these routines, it should at least provide stubs that always +** return true so that one does not get spurious assertion failures. +** +** ^If the argument to sqlite3_mutex_held() is a NULL pointer then +** the routine should return 1. This seems counter-intuitive since +** clearly the mutex cannot be held if it does not exist. But the +** the reason the mutex does not exist is because the build is not +** using mutexes. And we do not want the assert() containing the +** call to sqlite3_mutex_held() to fail, so a non-zero return is +** the appropriate thing to do. ^The sqlite3_mutex_notheld() +** interface should also return 1 when given a NULL pointer. +*/ +#ifndef NDEBUG +SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); +SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); +#endif + +/* +** CAPI3REF: Mutex Types +** +** The [sqlite3_mutex_alloc()] interface takes a single argument +** which is one of these integer constants. +** +** The set of static mutexes may change from one SQLite release to the +** next. Applications that override the built-in mutex logic must be +** prepared to accommodate additional static mutexes. +*/ +#define SQLITE_MUTEX_FAST 0 +#define SQLITE_MUTEX_RECURSIVE 1 +#define SQLITE_MUTEX_STATIC_MASTER 2 +#define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ +#define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ +#define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ +#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ +#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ +#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ + +/* +** CAPI3REF: Retrieve the mutex for a database connection +** +** ^This interface returns a pointer the [sqlite3_mutex] object that +** serializes access to the [database connection] given in the argument +** when the [threading mode] is Serialized. +** ^If the [threading mode] is Single-thread or Multi-thread then this +** routine returns a NULL pointer. +*/ +SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); + +/* +** CAPI3REF: Low-Level Control Of Database Files +** +** ^The [sqlite3_file_control()] interface makes a direct call to the +** xFileControl method for the [sqlite3_io_methods] object associated +** with a particular database identified by the second argument. ^The +** name of the database "main" for the main database or "temp" for the +** TEMP database, or the name that appears after the AS keyword for +** databases that are added using the [ATTACH] SQL command. +** ^A NULL pointer can be used in place of "main" to refer to the +** main database file. +** ^The third and fourth parameters to this routine +** are passed directly through to the second and third parameters of +** the xFileControl method. ^The return value of the xFileControl +** method becomes the return value of this routine. +** +** ^If the second parameter (zDbName) does not match the name of any +** open database file, then SQLITE_ERROR is returned. ^This error +** code is not remembered and will not be recalled by [sqlite3_errcode()] +** or [sqlite3_errmsg()]. The underlying xFileControl method might +** also return SQLITE_ERROR. There is no way to distinguish between +** an incorrect zDbName and an SQLITE_ERROR return from the underlying +** xFileControl method. +** +** See also: [SQLITE_FCNTL_LOCKSTATE] +*/ +SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); + +/* +** CAPI3REF: Testing Interface +** +** ^The sqlite3_test_control() interface is used to read out internal +** state of SQLite and to inject faults into SQLite for testing +** purposes. ^The first parameter is an operation code that determines +** the number, meaning, and operation of all subsequent parameters. +** +** This interface is not for use by applications. It exists solely +** for verifying the correct operation of the SQLite library. Depending +** on how the SQLite library is compiled, this interface might not exist. +** +** The details of the operation codes, their meanings, the parameters +** they take, and what they do are all subject to change without notice. +** Unlike most of the SQLite API, this function is not guaranteed to +** operate consistently from one release to the next. +*/ +SQLITE_API int sqlite3_test_control(int op, ...); + +/* +** CAPI3REF: Testing Interface Operation Codes +** +** These constants are the valid operation code parameters used +** as the first argument to [sqlite3_test_control()]. +** +** These parameters and their meanings are subject to change +** without notice. These values are for testing purposes only. +** Applications should not use any of these parameters or the +** [sqlite3_test_control()] interface. +*/ +#define SQLITE_TESTCTRL_FIRST 5 +#define SQLITE_TESTCTRL_PRNG_SAVE 5 +#define SQLITE_TESTCTRL_PRNG_RESTORE 6 +#define SQLITE_TESTCTRL_PRNG_RESET 7 +#define SQLITE_TESTCTRL_BITVEC_TEST 8 +#define SQLITE_TESTCTRL_FAULT_INSTALL 9 +#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 +#define SQLITE_TESTCTRL_PENDING_BYTE 11 +#define SQLITE_TESTCTRL_ASSERT 12 +#define SQLITE_TESTCTRL_ALWAYS 13 +#define SQLITE_TESTCTRL_RESERVE 14 +#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 +#define SQLITE_TESTCTRL_ISKEYWORD 16 +#define SQLITE_TESTCTRL_LAST 16 + +/* +** CAPI3REF: SQLite Runtime Status +** EXPERIMENTAL +** +** ^This interface is used to retrieve runtime status information +** about the preformance of SQLite, and optionally to reset various +** highwater marks. ^The first argument is an integer code for +** the specific parameter to measure. ^(Recognized integer codes +** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^ +** ^The current value of the parameter is returned into *pCurrent. +** ^The highest recorded value is returned in *pHighwater. ^If the +** resetFlag is true, then the highest record value is reset after +** *pHighwater is written. ^(Some parameters do not record the highest +** value. For those parameters +** nothing is written into *pHighwater and the resetFlag is ignored.)^ +** ^(Other parameters record only the highwater mark and not the current +** value. For these latter parameters nothing is written into *pCurrent.)^ +** +** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a +** non-zero [error code] on failure. +** +** This routine is threadsafe but is not atomic. This routine can be +** called while other threads are running the same or different SQLite +** interfaces. However the values returned in *pCurrent and +** *pHighwater reflect the status of SQLite at different points in time +** and it is possible that another thread might change the parameter +** in between the times when *pCurrent and *pHighwater are written. +** +** See also: [sqlite3_db_status()] +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); + + +/* +** CAPI3REF: Status Parameters +** EXPERIMENTAL +** +** These integer constants designate various run-time status parameters +** that can be returned by [sqlite3_status()]. +** +**
+** ^(
SQLITE_STATUS_MEMORY_USED
+**
This parameter is the current amount of memory checked out +** using [sqlite3_malloc()], either directly or indirectly. The +** figure includes calls made to [sqlite3_malloc()] by the application +** and internal memory usage by the SQLite library. Scratch memory +** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache +** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in +** this parameter. The amount returned is the sum of the allocation +** sizes as reported by the xSize method in [sqlite3_mem_methods].
)^ +** +** ^(
SQLITE_STATUS_MALLOC_SIZE
+**
This parameter records the largest memory allocation request +** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their +** internal equivalents). Only the value returned in the +** *pHighwater parameter to [sqlite3_status()] is of interest. +** The value written into the *pCurrent parameter is undefined.
)^ +** +** ^(
SQLITE_STATUS_PAGECACHE_USED
+**
This parameter returns the number of pages used out of the +** [pagecache memory allocator] that was configured using +** [SQLITE_CONFIG_PAGECACHE]. The +** value returned is in pages, not in bytes.
)^ +** +** ^(
SQLITE_STATUS_PAGECACHE_OVERFLOW
+**
This parameter returns the number of bytes of page cache +** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] +** buffer and where forced to overflow to [sqlite3_malloc()]. The +** returned value includes allocations that overflowed because they +** where too large (they were larger than the "sz" parameter to +** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because +** no space was left in the page cache.
)^ +** +** ^(
SQLITE_STATUS_PAGECACHE_SIZE
+**
This parameter records the largest memory allocation request +** handed to [pagecache memory allocator]. Only the value returned in the +** *pHighwater parameter to [sqlite3_status()] is of interest. +** The value written into the *pCurrent parameter is undefined.
)^ +** +** ^(
SQLITE_STATUS_SCRATCH_USED
+**
This parameter returns the number of allocations used out of the +** [scratch memory allocator] configured using +** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not +** in bytes. Since a single thread may only have one scratch allocation +** outstanding at time, this parameter also reports the number of threads +** using scratch memory at the same time.
)^ +** +** ^(
SQLITE_STATUS_SCRATCH_OVERFLOW
+**
This parameter returns the number of bytes of scratch memory +** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] +** buffer and where forced to overflow to [sqlite3_malloc()]. The values +** returned include overflows because the requested allocation was too +** larger (that is, because the requested allocation was larger than the +** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer +** slots were available. +**
)^ +** +** ^(
SQLITE_STATUS_SCRATCH_SIZE
+**
This parameter records the largest memory allocation request +** handed to [scratch memory allocator]. Only the value returned in the +** *pHighwater parameter to [sqlite3_status()] is of interest. +** The value written into the *pCurrent parameter is undefined.
)^ +** +** ^(
SQLITE_STATUS_PARSER_STACK
+**
This parameter records the deepest parser stack. It is only +** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].
)^ +**
+** +** New status parameters may be added from time to time. +*/ +#define SQLITE_STATUS_MEMORY_USED 0 +#define SQLITE_STATUS_PAGECACHE_USED 1 +#define SQLITE_STATUS_PAGECACHE_OVERFLOW 2 +#define SQLITE_STATUS_SCRATCH_USED 3 +#define SQLITE_STATUS_SCRATCH_OVERFLOW 4 +#define SQLITE_STATUS_MALLOC_SIZE 5 +#define SQLITE_STATUS_PARSER_STACK 6 +#define SQLITE_STATUS_PAGECACHE_SIZE 7 +#define SQLITE_STATUS_SCRATCH_SIZE 8 + +/* +** CAPI3REF: Database Connection Status +** EXPERIMENTAL +** +** ^This interface is used to retrieve runtime status information +** about a single [database connection]. ^The first argument is the +** database connection object to be interrogated. ^The second argument +** is the parameter to interrogate. ^Currently, the only allowed value +** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. +** Additional options will likely appear in future releases of SQLite. +** +** ^The current value of the requested parameter is written into *pCur +** and the highest instantaneous value is written into *pHiwtr. ^If +** the resetFlg is true, then the highest instantaneous value is +** reset back down to the current value. +** +** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); + +/* +** CAPI3REF: Status Parameters for database connections +** EXPERIMENTAL +** +** These constants are the available integer "verbs" that can be passed as +** the second argument to the [sqlite3_db_status()] interface. +** +** New verbs may be added in future releases of SQLite. Existing verbs +** might be discontinued. Applications should check the return code from +** [sqlite3_db_status()] to make sure that the call worked. +** The [sqlite3_db_status()] interface will return a non-zero error code +** if a discontinued or unsupported verb is invoked. +** +**
+** ^(
SQLITE_DBSTATUS_LOOKASIDE_USED
+**
This parameter returns the number of lookaside memory slots currently +** checked out.
)^ +**
+*/ +#define SQLITE_DBSTATUS_LOOKASIDE_USED 0 + + +/* +** CAPI3REF: Prepared Statement Status +** EXPERIMENTAL +** +** ^(Each prepared statement maintains various +** [SQLITE_STMTSTATUS_SORT | counters] that measure the number +** of times it has performed specific operations.)^ These counters can +** be used to monitor the performance characteristics of the prepared +** statements. For example, if the number of table steps greatly exceeds +** the number of table searches or result rows, that would tend to indicate +** that the prepared statement is using a full table scan rather than +** an index. +** +** ^(This interface is used to retrieve and reset counter values from +** a [prepared statement]. The first argument is the prepared statement +** object to be interrogated. The second argument +** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter] +** to be interrogated.)^ +** ^The current value of the requested counter is returned. +** ^If the resetFlg is true, then the counter is reset to zero after this +** interface call returns. +** +** See also: [sqlite3_status()] and [sqlite3_db_status()]. +*/ +SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); + +/* +** CAPI3REF: Status Parameters for prepared statements +** EXPERIMENTAL +** +** These preprocessor macros define integer codes that name counter +** values associated with the [sqlite3_stmt_status()] interface. +** The meanings of the various counters are as follows: +** +**
+**
SQLITE_STMTSTATUS_FULLSCAN_STEP
+**
^This is the number of times that SQLite has stepped forward in +** a table as part of a full table scan. Large numbers for this counter +** may indicate opportunities for performance improvement through +** careful use of indices.
+** +**
SQLITE_STMTSTATUS_SORT
+**
^This is the number of sort operations that have occurred. +** A non-zero value in this counter may indicate an opportunity to +** improvement performance through careful use of indices.
+** +**
+*/ +#define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 +#define SQLITE_STMTSTATUS_SORT 2 + +/* +** CAPI3REF: Custom Page Cache Object +** EXPERIMENTAL +** +** The sqlite3_pcache type is opaque. It is implemented by +** the pluggable module. The SQLite core has no knowledge of +** its size or internal structure and never deals with the +** sqlite3_pcache object except by holding and passing pointers +** to the object. +** +** See [sqlite3_pcache_methods] for additional information. +*/ +typedef struct sqlite3_pcache sqlite3_pcache; + +/* +** CAPI3REF: Application Defined Page Cache. +** KEYWORDS: {page cache} +** EXPERIMENTAL +** +** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can +** register an alternative page cache implementation by passing in an +** instance of the sqlite3_pcache_methods structure.)^ The majority of the +** heap memory used by SQLite is used by the page cache to cache data read +** from, or ready to be written to, the database file. By implementing a +** custom page cache using this API, an application can control more +** precisely the amount of memory consumed by SQLite, the way in which +** that memory is allocated and released, and the policies used to +** determine exactly which parts of a database file are cached and for +** how long. +** +** ^(The contents of the sqlite3_pcache_methods structure are copied to an +** internal buffer by SQLite within the call to [sqlite3_config]. Hence +** the application may discard the parameter after the call to +** [sqlite3_config()] returns.)^ +** +** ^The xInit() method is called once for each call to [sqlite3_initialize()] +** (usually only once during the lifetime of the process). ^(The xInit() +** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^ +** ^The xInit() method can set up up global structures and/or any mutexes +** required by the custom page cache implementation. +** +** ^The xShutdown() method is called from within [sqlite3_shutdown()], +** if the application invokes this API. It can be used to clean up +** any outstanding resources before process shutdown, if required. +** +** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes +** the xInit method, so the xInit method need not be threadsafe. ^The +** xShutdown method is only called from [sqlite3_shutdown()] so it does +** not need to be threadsafe either. All other methods must be threadsafe +** in multithreaded applications. +** +** ^SQLite will never invoke xInit() more than once without an intervening +** call to xShutdown(). +** +** ^The xCreate() method is used to construct a new cache instance. SQLite +** will typically create one cache instance for each open database file, +** though this is not guaranteed. ^The +** first parameter, szPage, is the size in bytes of the pages that must +** be allocated by the cache. ^szPage will not be a power of two. ^szPage +** will the page size of the database file that is to be cached plus an +** increment (here called "R") of about 100 or 200. ^SQLite will use the +** extra R bytes on each page to store metadata about the underlying +** database page on disk. The value of R depends +** on the SQLite version, the target platform, and how SQLite was compiled. +** ^R is constant for a particular build of SQLite. ^The second argument to +** xCreate(), bPurgeable, is true if the cache being created will +** be used to cache database pages of a file stored on disk, or +** false if it is used for an in-memory database. ^The cache implementation +** does not have to do anything special based with the value of bPurgeable; +** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will +** never invoke xUnpin() except to deliberately delete a page. +** ^In other words, a cache created with bPurgeable set to false will +** never contain any unpinned pages. +** +** ^(The xCachesize() method may be called at any time by SQLite to set the +** suggested maximum cache-size (number of pages stored by) the cache +** instance passed as the first argument. This is the value configured using +** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable +** parameter, the implementation is not required to do anything with this +** value; it is advisory only. +** +** ^The xPagecount() method should return the number of pages currently +** stored in the cache. +** +** ^The xFetch() method is used to fetch a page and return a pointer to it. +** ^A 'page', in this context, is a buffer of szPage bytes aligned at an +** 8-byte boundary. ^The page to be fetched is determined by the key. ^The +** mimimum key value is 1. After it has been retrieved using xFetch, the page +** is considered to be "pinned". +** +** ^If the requested page is already in the page cache, then the page cache +** implementation must return a pointer to the page buffer with its content +** intact. ^(If the requested page is not already in the cache, then the +** behavior of the cache implementation is determined by the value of the +** createFlag parameter passed to xFetch, according to the following table: +** +** +**
createFlag Behaviour when page is not already in cache +**
0 Do not allocate a new page. Return NULL. +**
1 Allocate a new page if it easy and convenient to do so. +** Otherwise return NULL. +**
2 Make every effort to allocate a new page. Only return +** NULL if allocating a new page is effectively impossible. +**
)^ +** +** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If +** a call to xFetch() with createFlag==1 returns NULL, then SQLite will +** attempt to unpin one or more cache pages by spilling the content of +** pinned pages to disk and synching the operating system disk cache. After +** attempting to unpin pages, the xFetch() method will be invoked again with +** a createFlag of 2. +** +** ^xUnpin() is called by SQLite with a pointer to a currently pinned page +** as its second argument. ^(If the third parameter, discard, is non-zero, +** then the page should be evicted from the cache. In this case SQLite +** assumes that the next time the page is retrieved from the cache using +** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is +** zero, then the page is considered to be unpinned. ^The cache implementation +** may choose to evict unpinned pages at any time. +** +** ^(The cache is not required to perform any reference counting. A single +** call to xUnpin() unpins the page regardless of the number of prior calls +** to xFetch().)^ +** +** ^The xRekey() method is used to change the key value associated with the +** page passed as the second argument from oldKey to newKey. ^If the cache +** previously contains an entry associated with newKey, it should be +** discarded. ^Any prior cache entry associated with newKey is guaranteed not +** to be pinned. +** +** ^When SQLite calls the xTruncate() method, the cache must discard all +** existing cache entries with page numbers (keys) greater than or equal +** to the value of the iLimit parameter passed to xTruncate(). ^If any +** of these pages are pinned, they are implicitly unpinned, meaning that +** they can be safely discarded. +** +** ^The xDestroy() method is used to delete a cache allocated by xCreate(). +** All resources associated with the specified cache should be freed. ^After +** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] +** handle invalid, and will not use it with any other sqlite3_pcache_methods +** functions. +*/ +typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; +struct sqlite3_pcache_methods { + void *pArg; + int (*xInit)(void*); + void (*xShutdown)(void*); + sqlite3_pcache *(*xCreate)(int szPage, int bPurgeable); + void (*xCachesize)(sqlite3_pcache*, int nCachesize); + int (*xPagecount)(sqlite3_pcache*); + void *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag); + void (*xUnpin)(sqlite3_pcache*, void*, int discard); + void (*xRekey)(sqlite3_pcache*, void*, unsigned oldKey, unsigned newKey); + void (*xTruncate)(sqlite3_pcache*, unsigned iLimit); + void (*xDestroy)(sqlite3_pcache*); +}; + +/* +** CAPI3REF: Online Backup Object +** EXPERIMENTAL +** +** The sqlite3_backup object records state information about an ongoing +** online backup operation. ^The sqlite3_backup object is created by +** a call to [sqlite3_backup_init()] and is destroyed by a call to +** [sqlite3_backup_finish()]. +** +** See Also: [Using the SQLite Online Backup API] +*/ +typedef struct sqlite3_backup sqlite3_backup; + +/* +** CAPI3REF: Online Backup API. +** EXPERIMENTAL +** +** The backup API copies the content of one database into another. +** It is useful either for creating backups of databases or +** for copying in-memory databases to or from persistent files. +** +** See Also: [Using the SQLite Online Backup API] +** +** ^Exclusive access is required to the destination database for the +** duration of the operation. ^However the source database is only +** read-locked while it is actually being read; it is not locked +** continuously for the entire backup operation. ^Thus, the backup may be +** performed on a live source database without preventing other users from +** reading or writing to the source database while the backup is underway. +** +** ^(To perform a backup operation: +**
    +**
  1. sqlite3_backup_init() is called once to initialize the +** backup, +**
  2. sqlite3_backup_step() is called one or more times to transfer +** the data between the two databases, and finally +**
  3. sqlite3_backup_finish() is called to release all resources +** associated with the backup operation. +**
)^ +** There should be exactly one call to sqlite3_backup_finish() for each +** successful call to sqlite3_backup_init(). +** +** sqlite3_backup_init() +** +** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the +** [database connection] associated with the destination database +** and the database name, respectively. +** ^The database name is "main" for the main database, "temp" for the +** temporary database, or the name specified after the AS keyword in +** an [ATTACH] statement for an attached database. +** ^The S and M arguments passed to +** sqlite3_backup_init(D,N,S,M) identify the [database connection] +** and database name of the source database, respectively. +** ^The source and destination [database connections] (parameters S and D) +** must be different or else sqlite3_backup_init(D,N,S,M) will file with +** an error. +** +** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is +** returned and an error code and error message are store3d in the +** destination [database connection] D. +** ^The error code and message for the failed call to sqlite3_backup_init() +** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or +** [sqlite3_errmsg16()] functions. +** ^A successful call to sqlite3_backup_init() returns a pointer to an +** [sqlite3_backup] object. +** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and +** sqlite3_backup_finish() functions to perform the specified backup +** operation. +** +** sqlite3_backup_step() +** +** ^Function sqlite3_backup_step(B,N) will copy up to N pages between +** the source and destination databases specified by [sqlite3_backup] object B. +** ^If N is negative, all remaining source pages are copied. +** ^If sqlite3_backup_step(B,N) successfully copies N pages and there +** are still more pages to be copied, then the function resturns [SQLITE_OK]. +** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages +** from source to destination, then it returns [SQLITE_DONE]. +** ^If an error occurs while running sqlite3_backup_step(B,N), +** then an [error code] is returned. ^As well as [SQLITE_OK] and +** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], +** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. +** +** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination +** database was opened read-only or if +** the destination is an in-memory database with a different page size +** from the source database. +** +** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then +** the [sqlite3_busy_handler | busy-handler function] +** is invoked (if one is specified). ^If the +** busy-handler returns non-zero before the lock is available, then +** [SQLITE_BUSY] is returned to the caller. ^In this case the call to +** sqlite3_backup_step() can be retried later. ^If the source +** [database connection] +** is being used to write to the source database when sqlite3_backup_step() +** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this +** case the call to sqlite3_backup_step() can be retried later on. ^(If +** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or +** [SQLITE_READONLY] is returned, then +** there is no point in retrying the call to sqlite3_backup_step(). These +** errors are considered fatal.)^ The application must accept +** that the backup operation has failed and pass the backup operation handle +** to the sqlite3_backup_finish() to release associated resources. +** +** ^The first call to sqlite3_backup_step() obtains an exclusive lock +** on the destination file. ^The exclusive lock is not released until either +** sqlite3_backup_finish() is called or the backup operation is complete +** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to +** sqlite3_backup_step() obtains a [shared lock] on the source database that +** lasts for the duration of the sqlite3_backup_step() call. +** ^Because the source database is not locked between calls to +** sqlite3_backup_step(), the source database may be modified mid-way +** through the backup process. ^If the source database is modified by an +** external process or via a database connection other than the one being +** used by the backup operation, then the backup will be automatically +** restarted by the next call to sqlite3_backup_step(). ^If the source +** database is modified by the using the same database connection as is used +** by the backup operation, then the backup database is automatically +** updated at the same time. +** +** sqlite3_backup_finish() +** +** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the +** application wishes to abandon the backup operation, the application +** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish(). +** ^The sqlite3_backup_finish() interfaces releases all +** resources associated with the [sqlite3_backup] object. +** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any +** active write-transaction on the destination database is rolled back. +** The [sqlite3_backup] object is invalid +** and may not be used following a call to sqlite3_backup_finish(). +** +** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no +** sqlite3_backup_step() errors occurred, regardless or whether or not +** sqlite3_backup_step() completed. +** ^If an out-of-memory condition or IO error occurred during any prior +** sqlite3_backup_step() call on the same [sqlite3_backup] object, then +** sqlite3_backup_finish() returns the corresponding [error code]. +** +** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() +** is not a permanent error and does not affect the return value of +** sqlite3_backup_finish(). +** +** sqlite3_backup_remaining(), sqlite3_backup_pagecount() +** +** ^Each call to sqlite3_backup_step() sets two values inside +** the [sqlite3_backup] object: the number of pages still to be backed +** up and the total number of pages in the source databae file. +** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces +** retrieve these two values, respectively. +** +** ^The values returned by these functions are only updated by +** sqlite3_backup_step(). ^If the source database is modified during a backup +** operation, then the values are not updated to account for any extra +** pages that need to be updated or the size of the source database file +** changing. +** +** Concurrent Usage of Database Handles +** +** ^The source [database connection] may be used by the application for other +** purposes while a backup operation is underway or being initialized. +** ^If SQLite is compiled and configured to support threadsafe database +** connections, then the source database connection may be used concurrently +** from within other threads. +** +** However, the application must guarantee that the destination +** [database connection] is not passed to any other API (by any thread) after +** sqlite3_backup_init() is called and before the corresponding call to +** sqlite3_backup_finish(). SQLite does not currently check to see +** if the application incorrectly accesses the destination [database connection] +** and so no error code is reported, but the operations may malfunction +** nevertheless. Use of the destination database connection while a +** backup is in progress might also also cause a mutex deadlock. +** +** If running in [shared cache mode], the application must +** guarantee that the shared cache used by the destination database +** is not accessed while the backup is running. In practice this means +** that the application must guarantee that the disk file being +** backed up to is not accessed by any connection within the process, +** not just the specific connection that was passed to sqlite3_backup_init(). +** +** The [sqlite3_backup] object itself is partially threadsafe. Multiple +** threads may safely make multiple concurrent calls to sqlite3_backup_step(). +** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount() +** APIs are not strictly speaking threadsafe. If they are invoked at the +** same time as another thread is invoking sqlite3_backup_step() it is +** possible that they return invalid values. +*/ +SQLITE_API sqlite3_backup *sqlite3_backup_init( + sqlite3 *pDest, /* Destination database handle */ + const char *zDestName, /* Destination database name */ + sqlite3 *pSource, /* Source database handle */ + const char *zSourceName /* Source database name */ +); +SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage); +SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p); +SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p); +SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p); + +/* +** CAPI3REF: Unlock Notification +** EXPERIMENTAL +** +** ^When running in shared-cache mode, a database operation may fail with +** an [SQLITE_LOCKED] error if the required locks on the shared-cache or +** individual tables within the shared-cache cannot be obtained. See +** [SQLite Shared-Cache Mode] for a description of shared-cache locking. +** ^This API may be used to register a callback that SQLite will invoke +** when the connection currently holding the required lock relinquishes it. +** ^This API is only available if the library was compiled with the +** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. +** +** See Also: [Using the SQLite Unlock Notification Feature]. +** +** ^Shared-cache locks are released when a database connection concludes +** its current transaction, either by committing it or rolling it back. +** +** ^When a connection (known as the blocked connection) fails to obtain a +** shared-cache lock and SQLITE_LOCKED is returned to the caller, the +** identity of the database connection (the blocking connection) that +** has locked the required resource is stored internally. ^After an +** application receives an SQLITE_LOCKED error, it may call the +** sqlite3_unlock_notify() method with the blocked connection handle as +** the first argument to register for a callback that will be invoked +** when the blocking connections current transaction is concluded. ^The +** callback is invoked from within the [sqlite3_step] or [sqlite3_close] +** call that concludes the blocking connections transaction. +** +** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, +** there is a chance that the blocking connection will have already +** concluded its transaction by the time sqlite3_unlock_notify() is invoked. +** If this happens, then the specified callback is invoked immediately, +** from within the call to sqlite3_unlock_notify().)^ +** +** ^If the blocked connection is attempting to obtain a write-lock on a +** shared-cache table, and more than one other connection currently holds +** a read-lock on the same table, then SQLite arbitrarily selects one of +** the other connections to use as the blocking connection. +** +** ^(There may be at most one unlock-notify callback registered by a +** blocked connection. If sqlite3_unlock_notify() is called when the +** blocked connection already has a registered unlock-notify callback, +** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is +** called with a NULL pointer as its second argument, then any existing +** unlock-notify callback is cancelled. ^The blocked connections +** unlock-notify callback may also be canceled by closing the blocked +** connection using [sqlite3_close()]. +** +** The unlock-notify callback is not reentrant. If an application invokes +** any sqlite3_xxx API functions from within an unlock-notify callback, a +** crash or deadlock may be the result. +** +** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always +** returns SQLITE_OK. +** +** Callback Invocation Details +** +** When an unlock-notify callback is registered, the application provides a +** single void* pointer that is passed to the callback when it is invoked. +** However, the signature of the callback function allows SQLite to pass +** it an array of void* context pointers. The first argument passed to +** an unlock-notify callback is a pointer to an array of void* pointers, +** and the second is the number of entries in the array. +** +** When a blocking connections transaction is concluded, there may be +** more than one blocked connection that has registered for an unlock-notify +** callback. ^If two or more such blocked connections have specified the +** same callback function, then instead of invoking the callback function +** multiple times, it is invoked once with the set of void* context pointers +** specified by the blocked connections bundled together into an array. +** This gives the application an opportunity to prioritize any actions +** related to the set of unblocked database connections. +** +** Deadlock Detection +** +** Assuming that after registering for an unlock-notify callback a +** database waits for the callback to be issued before taking any further +** action (a reasonable assumption), then using this API may cause the +** application to deadlock. For example, if connection X is waiting for +** connection Y's transaction to be concluded, and similarly connection +** Y is waiting on connection X's transaction, then neither connection +** will proceed and the system may remain deadlocked indefinitely. +** +** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock +** detection. ^If a given call to sqlite3_unlock_notify() would put the +** system in a deadlocked state, then SQLITE_LOCKED is returned and no +** unlock-notify callback is registered. The system is said to be in +** a deadlocked state if connection A has registered for an unlock-notify +** callback on the conclusion of connection B's transaction, and connection +** B has itself registered for an unlock-notify callback when connection +** A's transaction is concluded. ^Indirect deadlock is also detected, so +** the system is also considered to be deadlocked if connection B has +** registered for an unlock-notify callback on the conclusion of connection +** C's transaction, where connection C is waiting on connection A. ^Any +** number of levels of indirection are allowed. +** +** The "DROP TABLE" Exception +** +** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost +** always appropriate to call sqlite3_unlock_notify(). There is however, +** one exception. When executing a "DROP TABLE" or "DROP INDEX" statement, +** SQLite checks if there are any currently executing SELECT statements +** that belong to the same connection. If there are, SQLITE_LOCKED is +** returned. In this case there is no "blocking connection", so invoking +** sqlite3_unlock_notify() results in the unlock-notify callback being +** invoked immediately. If the application then re-attempts the "DROP TABLE" +** or "DROP INDEX" query, an infinite loop might be the result. +** +** One way around this problem is to check the extended error code returned +** by an sqlite3_step() call. ^(If there is a blocking connection, then the +** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in +** the special "DROP TABLE/INDEX" case, the extended error code is just +** SQLITE_LOCKED.)^ +*/ +SQLITE_API int sqlite3_unlock_notify( + sqlite3 *pBlocked, /* Waiting connection */ + void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ + void *pNotifyArg /* Argument to pass to xNotify */ +); + + +/* +** CAPI3REF: String Comparison +** EXPERIMENTAL +** +** ^The [sqlite3_strnicmp()] API allows applications and extensions to +** compare the contents of two buffers containing UTF-8 strings in a +** case-indendent fashion, using the same definition of case independence +** that SQLite uses internally when comparing identifiers. +*/ +SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); + +/* +** Undo the hack that converts floating point types to integer for +** builds on processors without floating point support. +*/ +#ifdef SQLITE_OMIT_FLOATING_POINT +# undef double +#endif + +#if 0 +} /* End of the 'extern "C"' block */ +#endif +#endif + + +/************** End of sqlite3.h *********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include hash.h in the middle of sqliteInt.h ******************/ +/************** Begin file hash.h ********************************************/ +/* +** 2001 September 22 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This is the header file for the generic hash-table implemenation +** used in SQLite. +*/ +#ifndef _SQLITE_HASH_H_ +#define _SQLITE_HASH_H_ + +/* Forward declarations of structures. */ +typedef struct Hash Hash; +typedef struct HashElem HashElem; + +/* A complete hash table is an instance of the following structure. +** The internals of this structure are intended to be opaque -- client +** code should not attempt to access or modify the fields of this structure +** directly. Change this structure only by using the routines below. +** However, some of the "procedures" and "functions" for modifying and +** accessing this structure are really macros, so we can't really make +** this structure opaque. +** +** All elements of the hash table are on a single doubly-linked list. +** Hash.first points to the head of this list. +** +** There are Hash.htsize buckets. Each bucket points to a spot in +** the global doubly-linked list. The contents of the bucket are the +** element pointed to plus the next _ht.count-1 elements in the list. +** +** Hash.htsize and Hash.ht may be zero. In that case lookup is done +** by a linear search of the global list. For small tables, the +** Hash.ht table is never allocated because if there are few elements +** in the table, it is faster to do a linear search than to manage +** the hash table. +*/ +struct Hash { + unsigned int htsize; /* Number of buckets in the hash table */ + unsigned int count; /* Number of entries in this table */ + HashElem *first; /* The first element of the array */ + struct _ht { /* the hash table */ + int count; /* Number of entries with this hash */ + HashElem *chain; /* Pointer to first entry with this hash */ + } *ht; +}; + +/* Each element in the hash table is an instance of the following +** structure. All elements are stored on a single doubly-linked list. +** +** Again, this structure is intended to be opaque, but it can't really +** be opaque because it is used by macros. +*/ +struct HashElem { + HashElem *next, *prev; /* Next and previous elements in the table */ + void *data; /* Data associated with this element */ + const char *pKey; int nKey; /* Key associated with this element */ +}; + +/* +** Access routines. To delete, insert a NULL pointer. +*/ +SQLITE_PRIVATE void sqlite3HashInit(Hash*); +SQLITE_PRIVATE void *sqlite3HashInsert(Hash*, const char *pKey, int nKey, void *pData); +SQLITE_PRIVATE void *sqlite3HashFind(const Hash*, const char *pKey, int nKey); +SQLITE_PRIVATE void sqlite3HashClear(Hash*); + +/* +** Macros for looping over all elements of a hash table. The idiom is +** like this: +** +** Hash h; +** HashElem *p; +** ... +** for(p=sqliteHashFirst(&h); p; p=sqliteHashNext(p)){ +** SomeStructure *pData = sqliteHashData(p); +** // do something with pData +** } +*/ +#define sqliteHashFirst(H) ((H)->first) +#define sqliteHashNext(E) ((E)->next) +#define sqliteHashData(E) ((E)->data) +/* #define sqliteHashKey(E) ((E)->pKey) // NOT USED */ +/* #define sqliteHashKeysize(E) ((E)->nKey) // NOT USED */ + +/* +** Number of entries in a hash table +*/ +/* #define sqliteHashCount(H) ((H)->count) // NOT USED */ + +#endif /* _SQLITE_HASH_H_ */ + +/************** End of hash.h ************************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include parse.h in the middle of sqliteInt.h *****************/ +/************** Begin file parse.h *******************************************/ +#define TK_SEMI 1 +#define TK_EXPLAIN 2 +#define TK_QUERY 3 +#define TK_PLAN 4 +#define TK_BEGIN 5 +#define TK_TRANSACTION 6 +#define TK_DEFERRED 7 +#define TK_IMMEDIATE 8 +#define TK_EXCLUSIVE 9 +#define TK_COMMIT 10 +#define TK_END 11 +#define TK_ROLLBACK 12 +#define TK_SAVEPOINT 13 +#define TK_RELEASE 14 +#define TK_TO 15 +#define TK_TABLE 16 +#define TK_CREATE 17 +#define TK_IF 18 +#define TK_NOT 19 +#define TK_EXISTS 20 +#define TK_TEMP 21 +#define TK_LP 22 +#define TK_RP 23 +#define TK_AS 24 +#define TK_COMMA 25 +#define TK_ID 26 +#define TK_INDEXED 27 +#define TK_ABORT 28 +#define TK_ACTION 29 +#define TK_AFTER 30 +#define TK_ANALYZE 31 +#define TK_ASC 32 +#define TK_ATTACH 33 +#define TK_BEFORE 34 +#define TK_BY 35 +#define TK_CASCADE 36 +#define TK_CAST 37 +#define TK_COLUMNKW 38 +#define TK_CONFLICT 39 +#define TK_DATABASE 40 +#define TK_DESC 41 +#define TK_DETACH 42 +#define TK_EACH 43 +#define TK_FAIL 44 +#define TK_FOR 45 +#define TK_IGNORE 46 +#define TK_INITIALLY 47 +#define TK_INSTEAD 48 +#define TK_LIKE_KW 49 +#define TK_MATCH 50 +#define TK_NO 51 +#define TK_KEY 52 +#define TK_OF 53 +#define TK_OFFSET 54 +#define TK_PRAGMA 55 +#define TK_RAISE 56 +#define TK_REPLACE 57 +#define TK_RESTRICT 58 +#define TK_ROW 59 +#define TK_TRIGGER 60 +#define TK_VACUUM 61 +#define TK_VIEW 62 +#define TK_VIRTUAL 63 +#define TK_REINDEX 64 +#define TK_RENAME 65 +#define TK_CTIME_KW 66 +#define TK_ANY 67 +#define TK_OR 68 +#define TK_AND 69 +#define TK_IS 70 +#define TK_BETWEEN 71 +#define TK_IN 72 +#define TK_ISNULL 73 +#define TK_NOTNULL 74 +#define TK_NE 75 +#define TK_EQ 76 +#define TK_GT 77 +#define TK_LE 78 +#define TK_LT 79 +#define TK_GE 80 +#define TK_ESCAPE 81 +#define TK_BITAND 82 +#define TK_BITOR 83 +#define TK_LSHIFT 84 +#define TK_RSHIFT 85 +#define TK_PLUS 86 +#define TK_MINUS 87 +#define TK_STAR 88 +#define TK_SLASH 89 +#define TK_REM 90 +#define TK_CONCAT 91 +#define TK_COLLATE 92 +#define TK_BITNOT 93 +#define TK_STRING 94 +#define TK_JOIN_KW 95 +#define TK_CONSTRAINT 96 +#define TK_DEFAULT 97 +#define TK_NULL 98 +#define TK_PRIMARY 99 +#define TK_UNIQUE 100 +#define TK_CHECK 101 +#define TK_REFERENCES 102 +#define TK_AUTOINCR 103 +#define TK_ON 104 +#define TK_INSERT 105 +#define TK_DELETE 106 +#define TK_UPDATE 107 +#define TK_SET 108 +#define TK_DEFERRABLE 109 +#define TK_FOREIGN 110 +#define TK_DROP 111 +#define TK_UNION 112 +#define TK_ALL 113 +#define TK_EXCEPT 114 +#define TK_INTERSECT 115 +#define TK_SELECT 116 +#define TK_DISTINCT 117 +#define TK_DOT 118 +#define TK_FROM 119 +#define TK_JOIN 120 +#define TK_USING 121 +#define TK_ORDER 122 +#define TK_GROUP 123 +#define TK_HAVING 124 +#define TK_LIMIT 125 +#define TK_WHERE 126 +#define TK_INTO 127 +#define TK_VALUES 128 +#define TK_INTEGER 129 +#define TK_FLOAT 130 +#define TK_BLOB 131 +#define TK_REGISTER 132 +#define TK_VARIABLE 133 +#define TK_CASE 134 +#define TK_WHEN 135 +#define TK_THEN 136 +#define TK_ELSE 137 +#define TK_INDEX 138 +#define TK_ALTER 139 +#define TK_ADD 140 +#define TK_TO_TEXT 141 +#define TK_TO_BLOB 142 +#define TK_TO_NUMERIC 143 +#define TK_TO_INT 144 +#define TK_TO_REAL 145 +#define TK_ISNOT 146 +#define TK_END_OF_FILE 147 +#define TK_ILLEGAL 148 +#define TK_SPACE 149 +#define TK_UNCLOSED_STRING 150 +#define TK_FUNCTION 151 +#define TK_COLUMN 152 +#define TK_AGG_FUNCTION 153 +#define TK_AGG_COLUMN 154 +#define TK_CONST_FUNC 155 +#define TK_UMINUS 156 +#define TK_UPLUS 157 + +/************** End of parse.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +#include +#include +#include +#include +#include + +/* +** If compiling for a processor that lacks floating point support, +** substitute integer for floating-point +*/ +#ifdef SQLITE_OMIT_FLOATING_POINT +# define double sqlite_int64 +# define LONGDOUBLE_TYPE sqlite_int64 +# ifndef SQLITE_BIG_DBL +# define SQLITE_BIG_DBL (((sqlite3_int64)1)<<50) +# endif +# define SQLITE_OMIT_DATETIME_FUNCS 1 +# define SQLITE_OMIT_TRACE 1 +# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT +# undef SQLITE_HAVE_ISNAN +#endif +#ifndef SQLITE_BIG_DBL +# define SQLITE_BIG_DBL (1e99) +#endif + +/* +** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0 +** afterward. Having this macro allows us to cause the C compiler +** to omit code used by TEMP tables without messy #ifndef statements. +*/ +#ifdef SQLITE_OMIT_TEMPDB +#define OMIT_TEMPDB 1 +#else +#define OMIT_TEMPDB 0 +#endif + +/* +** If the following macro is set to 1, then NULL values are considered +** distinct when determining whether or not two entries are the same +** in a UNIQUE index. This is the way PostgreSQL, Oracle, DB2, MySQL, +** OCELOT, and Firebird all work. The SQL92 spec explicitly says this +** is the way things are suppose to work. +** +** If the following macro is set to 0, the NULLs are indistinct for +** a UNIQUE index. In this mode, you can only have a single NULL entry +** for a column declared UNIQUE. This is the way Informix and SQL Server +** work. +*/ +#define NULL_DISTINCT_FOR_UNIQUE 1 + +/* +** The "file format" number is an integer that is incremented whenever +** the VDBE-level file format changes. The following macros define the +** the default file format for new databases and the maximum file format +** that the library can read. +*/ +#define SQLITE_MAX_FILE_FORMAT 4 +#ifndef SQLITE_DEFAULT_FILE_FORMAT +# define SQLITE_DEFAULT_FILE_FORMAT 1 +#endif + +#ifndef SQLITE_DEFAULT_RECURSIVE_TRIGGERS +# define SQLITE_DEFAULT_RECURSIVE_TRIGGERS 0 +#endif + +/* +** Provide a default value for SQLITE_TEMP_STORE in case it is not specified +** on the command-line +*/ +#ifndef SQLITE_TEMP_STORE +# define SQLITE_TEMP_STORE 1 +#endif + +/* +** GCC does not define the offsetof() macro so we'll have to do it +** ourselves. +*/ +#ifndef offsetof +#define offsetof(STRUCTURE,FIELD) ((int)((char*)&((STRUCTURE*)0)->FIELD)) +#endif + +/* +** Check to see if this machine uses EBCDIC. (Yes, believe it or +** not, there are still machines out there that use EBCDIC.) +*/ +#if 'A' == '\301' +# define SQLITE_EBCDIC 1 +#else +# define SQLITE_ASCII 1 +#endif + +/* +** Integers of known sizes. These typedefs might change for architectures +** where the sizes very. Preprocessor macros are available so that the +** types can be conveniently redefined at compile-type. Like this: +** +** cc '-DUINTPTR_TYPE=long long int' ... +*/ +#ifndef UINT32_TYPE +# ifdef HAVE_UINT32_T +# define UINT32_TYPE uint32_t +# else +# define UINT32_TYPE unsigned int +# endif +#endif +#ifndef UINT16_TYPE +# ifdef HAVE_UINT16_T +# define UINT16_TYPE uint16_t +# else +# define UINT16_TYPE unsigned short int +# endif +#endif +#ifndef INT16_TYPE +# ifdef HAVE_INT16_T +# define INT16_TYPE int16_t +# else +# define INT16_TYPE short int +# endif +#endif +#ifndef UINT8_TYPE +# ifdef HAVE_UINT8_T +# define UINT8_TYPE uint8_t +# else +# define UINT8_TYPE unsigned char +# endif +#endif +#ifndef INT8_TYPE +# ifdef HAVE_INT8_T +# define INT8_TYPE int8_t +# else +# define INT8_TYPE signed char +# endif +#endif +#ifndef LONGDOUBLE_TYPE +# define LONGDOUBLE_TYPE long double +#endif +typedef sqlite_int64 i64; /* 8-byte signed integer */ +typedef sqlite_uint64 u64; /* 8-byte unsigned integer */ +typedef UINT32_TYPE u32; /* 4-byte unsigned integer */ +typedef UINT16_TYPE u16; /* 2-byte unsigned integer */ +typedef INT16_TYPE i16; /* 2-byte signed integer */ +typedef UINT8_TYPE u8; /* 1-byte unsigned integer */ +typedef INT8_TYPE i8; /* 1-byte signed integer */ + +/* +** SQLITE_MAX_U32 is a u64 constant that is the maximum u64 value +** that can be stored in a u32 without loss of data. The value +** is 0x00000000ffffffff. But because of quirks of some compilers, we +** have to specify the value in the less intuitive manner shown: +*/ +#define SQLITE_MAX_U32 ((((u64)1)<<32)-1) + +/* +** Macros to determine whether the machine is big or little endian, +** evaluated at runtime. +*/ +#ifdef SQLITE_AMALGAMATION +SQLITE_PRIVATE const int sqlite3one = 1; +#else +SQLITE_PRIVATE const int sqlite3one; +#endif +#if defined(i386) || defined(__i386__) || defined(_M_IX86)\ + || defined(__x86_64) || defined(__x86_64__) +# define SQLITE_BIGENDIAN 0 +# define SQLITE_LITTLEENDIAN 1 +# define SQLITE_UTF16NATIVE SQLITE_UTF16LE +#else +# define SQLITE_BIGENDIAN (*(char *)(&sqlite3one)==0) +# define SQLITE_LITTLEENDIAN (*(char *)(&sqlite3one)==1) +# define SQLITE_UTF16NATIVE (SQLITE_BIGENDIAN?SQLITE_UTF16BE:SQLITE_UTF16LE) +#endif + +/* +** Constants for the largest and smallest possible 64-bit signed integers. +** These macros are designed to work correctly on both 32-bit and 64-bit +** compilers. +*/ +#define LARGEST_INT64 (0xffffffff|(((i64)0x7fffffff)<<32)) +#define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64) + +/* +** Round up a number to the next larger multiple of 8. This is used +** to force 8-byte alignment on 64-bit architectures. +*/ +#define ROUND8(x) (((x)+7)&~7) + +/* +** Round down to the nearest multiple of 8 +*/ +#define ROUNDDOWN8(x) ((x)&~7) + +/* +** Assert that the pointer X is aligned to an 8-byte boundary. This +** macro is used only within assert() to verify that the code gets +** all alignment restrictions correct. +** +** Except, if SQLITE_4_BYTE_ALIGNED_MALLOC is defined, then the +** underlying malloc() implemention might return us 4-byte aligned +** pointers. In that case, only verify 4-byte alignment. +*/ +#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC +# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&3)==0) +#else +# define EIGHT_BYTE_ALIGNMENT(X) ((((char*)(X) - (char*)0)&7)==0) +#endif + + +/* +** An instance of the following structure is used to store the busy-handler +** callback for a given sqlite handle. +** +** The sqlite.busyHandler member of the sqlite struct contains the busy +** callback for the database handle. Each pager opened via the sqlite +** handle is passed a pointer to sqlite.busyHandler. The busy-handler +** callback is currently invoked only from within pager.c. +*/ +typedef struct BusyHandler BusyHandler; +struct BusyHandler { + int (*xFunc)(void *,int); /* The busy callback */ + void *pArg; /* First arg to busy callback */ + int nBusy; /* Incremented with each busy call */ +}; + +/* +** Name of the master database table. The master database table +** is a special table that holds the names and attributes of all +** user tables and indices. +*/ +#define MASTER_NAME "sqlite_master" +#define TEMP_MASTER_NAME "sqlite_temp_master" + +/* +** The root-page of the master database table. +*/ +#define MASTER_ROOT 1 + +/* +** The name of the schema table. +*/ +#define SCHEMA_TABLE(x) ((!OMIT_TEMPDB)&&(x==1)?TEMP_MASTER_NAME:MASTER_NAME) + +/* +** A convenience macro that returns the number of elements in +** an array. +*/ +#define ArraySize(X) ((int)(sizeof(X)/sizeof(X[0]))) + +/* +** The following value as a destructor means to use sqlite3DbFree(). +** This is an internal extension to SQLITE_STATIC and SQLITE_TRANSIENT. +*/ +#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3DbFree) + +/* +** When SQLITE_OMIT_WSD is defined, it means that the target platform does +** not support Writable Static Data (WSD) such as global and static variables. +** All variables must either be on the stack or dynamically allocated from +** the heap. When WSD is unsupported, the variable declarations scattered +** throughout the SQLite code must become constants instead. The SQLITE_WSD +** macro is used for this purpose. And instead of referencing the variable +** directly, we use its constant as a key to lookup the run-time allocated +** buffer that holds real variable. The constant is also the initializer +** for the run-time allocated buffer. +** +** In the usual case where WSD is supported, the SQLITE_WSD and GLOBAL +** macros become no-ops and have zero performance impact. +*/ +#ifdef SQLITE_OMIT_WSD + #define SQLITE_WSD const + #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v))) + #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config) +SQLITE_API int sqlite3_wsd_init(int N, int J); +SQLITE_API void *sqlite3_wsd_find(void *K, int L); +#else + #define SQLITE_WSD + #define GLOBAL(t,v) v + #define sqlite3GlobalConfig sqlite3Config +#endif + +/* +** The following macros are used to suppress compiler warnings and to +** make it clear to human readers when a function parameter is deliberately +** left unused within the body of a function. This usually happens when +** a function is called via a function pointer. For example the +** implementation of an SQL aggregate step callback may not use the +** parameter indicating the number of arguments passed to the aggregate, +** if it knows that this is enforced elsewhere. +** +** When a function parameter is not used at all within the body of a function, +** it is generally named "NotUsed" or "NotUsed2" to make things even clearer. +** However, these macros may also be used to suppress warnings related to +** parameters that may or may not be used depending on compilation options. +** For example those parameters only used in assert() statements. In these +** cases the parameters are named as per the usual conventions. +*/ +#define UNUSED_PARAMETER(x) (void)(x) +#define UNUSED_PARAMETER2(x,y) UNUSED_PARAMETER(x),UNUSED_PARAMETER(y) + +/* +** Forward references to structures +*/ +typedef struct AggInfo AggInfo; +typedef struct AuthContext AuthContext; +typedef struct AutoincInfo AutoincInfo; +typedef struct Bitvec Bitvec; +typedef struct RowSet RowSet; +typedef struct CollSeq CollSeq; +typedef struct Column Column; +typedef struct Db Db; +typedef struct Schema Schema; +typedef struct Expr Expr; +typedef struct ExprList ExprList; +typedef struct ExprSpan ExprSpan; +typedef struct FKey FKey; +typedef struct FuncDef FuncDef; +typedef struct FuncDefHash FuncDefHash; +typedef struct IdList IdList; +typedef struct Index Index; +typedef struct IndexSample IndexSample; +typedef struct KeyClass KeyClass; +typedef struct KeyInfo KeyInfo; +typedef struct Lookaside Lookaside; +typedef struct LookasideSlot LookasideSlot; +typedef struct Module Module; +typedef struct NameContext NameContext; +typedef struct Parse Parse; +typedef struct Savepoint Savepoint; +typedef struct Select Select; +typedef struct SrcList SrcList; +typedef struct StrAccum StrAccum; +typedef struct Table Table; +typedef struct TableLock TableLock; +typedef struct Token Token; +typedef struct TriggerPrg TriggerPrg; +typedef struct TriggerStep TriggerStep; +typedef struct Trigger Trigger; +typedef struct UnpackedRecord UnpackedRecord; +typedef struct VTable VTable; +typedef struct Walker Walker; +typedef struct WherePlan WherePlan; +typedef struct WhereInfo WhereInfo; +typedef struct WhereLevel WhereLevel; + +/* +** Defer sourcing vdbe.h and btree.h until after the "u8" and +** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque +** pointer types (i.e. FuncDef) defined above. +*/ +/************** Include btree.h in the middle of sqliteInt.h *****************/ +/************** Begin file btree.h *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the sqlite B-Tree file +** subsystem. See comments in the source code for a detailed description +** of what each interface routine does. +*/ +#ifndef _BTREE_H_ +#define _BTREE_H_ + +/* TODO: This definition is just included so other modules compile. It +** needs to be revisited. +*/ +#define SQLITE_N_BTREE_META 10 + +/* +** If defined as non-zero, auto-vacuum is enabled by default. Otherwise +** it must be turned on for each database using "PRAGMA auto_vacuum = 1". +*/ +#ifndef SQLITE_DEFAULT_AUTOVACUUM + #define SQLITE_DEFAULT_AUTOVACUUM 0 +#endif + +#define BTREE_AUTOVACUUM_NONE 0 /* Do not do auto-vacuum */ +#define BTREE_AUTOVACUUM_FULL 1 /* Do full auto-vacuum */ +#define BTREE_AUTOVACUUM_INCR 2 /* Incremental vacuum */ + +/* +** Forward declarations of structure +*/ +typedef struct Btree Btree; +typedef struct BtCursor BtCursor; +typedef struct BtShared BtShared; +typedef struct BtreeMutexArray BtreeMutexArray; + +/* +** This structure records all of the Btrees that need to hold +** a mutex before we enter sqlite3VdbeExec(). The Btrees are +** are placed in aBtree[] in order of aBtree[]->pBt. That way, +** we can always lock and unlock them all quickly. +*/ +struct BtreeMutexArray { + int nMutex; + Btree *aBtree[SQLITE_MAX_ATTACHED+1]; +}; + + +SQLITE_PRIVATE int sqlite3BtreeOpen( + const char *zFilename, /* Name of database file to open */ + sqlite3 *db, /* Associated database connection */ + Btree **ppBtree, /* Return open Btree* here */ + int flags, /* Flags */ + int vfsFlags /* Flags passed through to VFS open */ +); + +/* The flags parameter to sqlite3BtreeOpen can be the bitwise or of the +** following values. +** +** NOTE: These values must match the corresponding PAGER_ values in +** pager.h. +*/ +#define BTREE_OMIT_JOURNAL 1 /* Do not use journal. No argument */ +#define BTREE_NO_READLOCK 2 /* Omit readlocks on readonly files */ +#define BTREE_MEMORY 4 /* In-memory DB. No argument */ +#define BTREE_READONLY 8 /* Open the database in read-only mode */ +#define BTREE_READWRITE 16 /* Open for both reading and writing */ +#define BTREE_CREATE 32 /* Create the database if it does not exist */ + +SQLITE_PRIVATE int sqlite3BtreeClose(Btree*); +SQLITE_PRIVATE int sqlite3BtreeSetCacheSize(Btree*,int); +SQLITE_PRIVATE int sqlite3BtreeSetSafetyLevel(Btree*,int,int); +SQLITE_PRIVATE int sqlite3BtreeSyncDisabled(Btree*); +SQLITE_PRIVATE int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix); +SQLITE_PRIVATE int sqlite3BtreeGetPageSize(Btree*); +SQLITE_PRIVATE int sqlite3BtreeMaxPageCount(Btree*,int); +SQLITE_PRIVATE int sqlite3BtreeGetReserve(Btree*); +SQLITE_PRIVATE int sqlite3BtreeSetAutoVacuum(Btree *, int); +SQLITE_PRIVATE int sqlite3BtreeGetAutoVacuum(Btree *); +SQLITE_PRIVATE int sqlite3BtreeBeginTrans(Btree*,int); +SQLITE_PRIVATE int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster); +SQLITE_PRIVATE int sqlite3BtreeCommitPhaseTwo(Btree*); +SQLITE_PRIVATE int sqlite3BtreeCommit(Btree*); +SQLITE_PRIVATE int sqlite3BtreeRollback(Btree*); +SQLITE_PRIVATE int sqlite3BtreeBeginStmt(Btree*,int); +SQLITE_PRIVATE int sqlite3BtreeCreateTable(Btree*, int*, int flags); +SQLITE_PRIVATE int sqlite3BtreeIsInTrans(Btree*); +SQLITE_PRIVATE int sqlite3BtreeIsInReadTrans(Btree*); +SQLITE_PRIVATE int sqlite3BtreeIsInBackup(Btree*); +SQLITE_PRIVATE void *sqlite3BtreeSchema(Btree *, int, void(*)(void *)); +SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *pBtree); +SQLITE_PRIVATE int sqlite3BtreeLockTable(Btree *pBtree, int iTab, u8 isWriteLock); +SQLITE_PRIVATE int sqlite3BtreeSavepoint(Btree *, int, int); + +SQLITE_PRIVATE const char *sqlite3BtreeGetFilename(Btree *); +SQLITE_PRIVATE const char *sqlite3BtreeGetJournalname(Btree *); +SQLITE_PRIVATE int sqlite3BtreeCopyFile(Btree *, Btree *); + +SQLITE_PRIVATE int sqlite3BtreeIncrVacuum(Btree *); + +/* The flags parameter to sqlite3BtreeCreateTable can be the bitwise OR +** of the following flags: +*/ +#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */ +#define BTREE_ZERODATA 2 /* Table has keys only - no data */ +#define BTREE_LEAFDATA 4 /* Data stored in leaves only. Implies INTKEY */ + +SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*); +SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*); +SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int); + +SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue); +SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); + +/* +** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta +** should be one of the following values. The integer values are assigned +** to constants so that the offset of the corresponding field in an +** SQLite database header may be found using the following formula: +** +** offset = 36 + (idx * 4) +** +** For example, the free-page-count field is located at byte offset 36 of +** the database file header. The incr-vacuum-flag field is located at +** byte offset 64 (== 36+4*7). +*/ +#define BTREE_FREE_PAGE_COUNT 0 +#define BTREE_SCHEMA_VERSION 1 +#define BTREE_FILE_FORMAT 2 +#define BTREE_DEFAULT_CACHE_SIZE 3 +#define BTREE_LARGEST_ROOT_PAGE 4 +#define BTREE_TEXT_ENCODING 5 +#define BTREE_USER_VERSION 6 +#define BTREE_INCR_VACUUM 7 + +SQLITE_PRIVATE int sqlite3BtreeCursor( + Btree*, /* BTree containing table to open */ + int iTable, /* Index of root page */ + int wrFlag, /* 1 for writing. 0 for read-only */ + struct KeyInfo*, /* First argument to compare function */ + BtCursor *pCursor /* Space to write cursor structure */ +); +SQLITE_PRIVATE int sqlite3BtreeCursorSize(void); +SQLITE_PRIVATE void sqlite3BtreeCursorZero(BtCursor*); + +SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*); +SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked( + BtCursor*, + UnpackedRecord *pUnKey, + i64 intKey, + int bias, + int *pRes +); +SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*, int*); +SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*); +SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey, + const void *pData, int nData, + int nZero, int bias, int seekResult); +SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); +SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); +SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int *pRes); +SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); +SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int *pRes); +SQLITE_PRIVATE int sqlite3BtreeKeySize(BtCursor*, i64 *pSize); +SQLITE_PRIVATE int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*); +SQLITE_PRIVATE const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt); +SQLITE_PRIVATE const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt); +SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor*, u32 *pSize); +SQLITE_PRIVATE int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*); +SQLITE_PRIVATE void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64); +SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor*); + +SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*); +SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*); + +SQLITE_PRIVATE int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); +SQLITE_PRIVATE void sqlite3BtreeCacheOverflow(BtCursor *); +SQLITE_PRIVATE void sqlite3BtreeClearCursor(BtCursor *); + +#ifndef NDEBUG +SQLITE_PRIVATE int sqlite3BtreeCursorIsValid(BtCursor*); +#endif + +#ifndef SQLITE_OMIT_BTREECOUNT +SQLITE_PRIVATE int sqlite3BtreeCount(BtCursor *, i64 *); +#endif + +#ifdef SQLITE_TEST +SQLITE_PRIVATE int sqlite3BtreeCursorInfo(BtCursor*, int*, int); +SQLITE_PRIVATE void sqlite3BtreeCursorList(Btree*); +#endif + +/* +** If we are not using shared cache, then there is no need to +** use mutexes to access the BtShared structures. So make the +** Enter and Leave procedures no-ops. +*/ +#ifndef SQLITE_OMIT_SHARED_CACHE +SQLITE_PRIVATE void sqlite3BtreeEnter(Btree*); +SQLITE_PRIVATE void sqlite3BtreeEnterAll(sqlite3*); +#else +# define sqlite3BtreeEnter(X) +# define sqlite3BtreeEnterAll(X) +#endif + +#if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE +SQLITE_PRIVATE void sqlite3BtreeLeave(Btree*); +SQLITE_PRIVATE void sqlite3BtreeEnterCursor(BtCursor*); +SQLITE_PRIVATE void sqlite3BtreeLeaveCursor(BtCursor*); +SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3*); +SQLITE_PRIVATE void sqlite3BtreeMutexArrayEnter(BtreeMutexArray*); +SQLITE_PRIVATE void sqlite3BtreeMutexArrayLeave(BtreeMutexArray*); +SQLITE_PRIVATE void sqlite3BtreeMutexArrayInsert(BtreeMutexArray*, Btree*); +#ifndef NDEBUG + /* These routines are used inside assert() statements only. */ +SQLITE_PRIVATE int sqlite3BtreeHoldsMutex(Btree*); +SQLITE_PRIVATE int sqlite3BtreeHoldsAllMutexes(sqlite3*); +#endif +#else + +# define sqlite3BtreeLeave(X) +# define sqlite3BtreeEnterCursor(X) +# define sqlite3BtreeLeaveCursor(X) +# define sqlite3BtreeLeaveAll(X) +# define sqlite3BtreeMutexArrayEnter(X) +# define sqlite3BtreeMutexArrayLeave(X) +# define sqlite3BtreeMutexArrayInsert(X,Y) + +# define sqlite3BtreeHoldsMutex(X) 1 +# define sqlite3BtreeHoldsAllMutexes(X) 1 +#endif + + +#endif /* _BTREE_H_ */ + +/************** End of btree.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include vdbe.h in the middle of sqliteInt.h ******************/ +/************** Begin file vdbe.h ********************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** Header file for the Virtual DataBase Engine (VDBE) +** +** This header defines the interface to the virtual database engine +** or VDBE. The VDBE implements an abstract machine that runs a +** simple program to access and modify the underlying database. +*/ +#ifndef _SQLITE_VDBE_H_ +#define _SQLITE_VDBE_H_ + +/* +** A single VDBE is an opaque structure named "Vdbe". Only routines +** in the source file sqliteVdbe.c are allowed to see the insides +** of this structure. +*/ +typedef struct Vdbe Vdbe; + +/* +** The names of the following types declared in vdbeInt.h are required +** for the VdbeOp definition. +*/ +typedef struct VdbeFunc VdbeFunc; +typedef struct Mem Mem; +typedef struct SubProgram SubProgram; + +/* +** A single instruction of the virtual machine has an opcode +** and as many as three operands. The instruction is recorded +** as an instance of the following structure: +*/ +struct VdbeOp { + u8 opcode; /* What operation to perform */ + signed char p4type; /* One of the P4_xxx constants for p4 */ + u8 opflags; /* Mask of the OPFLG_* flags in opcodes.h */ + u8 p5; /* Fifth parameter is an unsigned character */ + int p1; /* First operand */ + int p2; /* Second parameter (often the jump destination) */ + int p3; /* The third parameter */ + union { /* fourth parameter */ + int i; /* Integer value if p4type==P4_INT32 */ + void *p; /* Generic pointer */ + char *z; /* Pointer to data for string (char array) types */ + i64 *pI64; /* Used when p4type is P4_INT64 */ + double *pReal; /* Used when p4type is P4_REAL */ + FuncDef *pFunc; /* Used when p4type is P4_FUNCDEF */ + VdbeFunc *pVdbeFunc; /* Used when p4type is P4_VDBEFUNC */ + CollSeq *pColl; /* Used when p4type is P4_COLLSEQ */ + Mem *pMem; /* Used when p4type is P4_MEM */ + VTable *pVtab; /* Used when p4type is P4_VTAB */ + KeyInfo *pKeyInfo; /* Used when p4type is P4_KEYINFO */ + int *ai; /* Used when p4type is P4_INTARRAY */ + SubProgram *pProgram; /* Used when p4type is P4_SUBPROGRAM */ + } p4; +#ifdef SQLITE_DEBUG + char *zComment; /* Comment to improve readability */ +#endif +#ifdef VDBE_PROFILE + int cnt; /* Number of times this instruction was executed */ + u64 cycles; /* Total time spent executing this instruction */ +#endif +}; +typedef struct VdbeOp VdbeOp; + + +/* +** A sub-routine used to implement a trigger program. +*/ +struct SubProgram { + VdbeOp *aOp; /* Array of opcodes for sub-program */ + int nOp; /* Elements in aOp[] */ + int nMem; /* Number of memory cells required */ + int nCsr; /* Number of cursors required */ + int nRef; /* Number of pointers to this structure */ + void *token; /* id that may be used to recursive triggers */ +}; + +/* +** A smaller version of VdbeOp used for the VdbeAddOpList() function because +** it takes up less space. +*/ +struct VdbeOpList { + u8 opcode; /* What operation to perform */ + signed char p1; /* First operand */ + signed char p2; /* Second parameter (often the jump destination) */ + signed char p3; /* Third parameter */ +}; +typedef struct VdbeOpList VdbeOpList; + +/* +** Allowed values of VdbeOp.p4type +*/ +#define P4_NOTUSED 0 /* The P4 parameter is not used */ +#define P4_DYNAMIC (-1) /* Pointer to a string obtained from sqliteMalloc() */ +#define P4_STATIC (-2) /* Pointer to a static string */ +#define P4_COLLSEQ (-4) /* P4 is a pointer to a CollSeq structure */ +#define P4_FUNCDEF (-5) /* P4 is a pointer to a FuncDef structure */ +#define P4_KEYINFO (-6) /* P4 is a pointer to a KeyInfo structure */ +#define P4_VDBEFUNC (-7) /* P4 is a pointer to a VdbeFunc structure */ +#define P4_MEM (-8) /* P4 is a pointer to a Mem* structure */ +#define P4_TRANSIENT (-9) /* P4 is a pointer to a transient string */ +#define P4_VTAB (-10) /* P4 is a pointer to an sqlite3_vtab structure */ +#define P4_MPRINTF (-11) /* P4 is a string obtained from sqlite3_mprintf() */ +#define P4_REAL (-12) /* P4 is a 64-bit floating point value */ +#define P4_INT64 (-13) /* P4 is a 64-bit signed integer */ +#define P4_INT32 (-14) /* P4 is a 32-bit signed integer */ +#define P4_INTARRAY (-15) /* P4 is a vector of 32-bit integers */ +#define P4_SUBPROGRAM (-18) /* P4 is a pointer to a SubProgram structure */ + +/* When adding a P4 argument using P4_KEYINFO, a copy of the KeyInfo structure +** is made. That copy is freed when the Vdbe is finalized. But if the +** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still +** gets freed when the Vdbe is finalized so it still should be obtained +** from a single sqliteMalloc(). But no copy is made and the calling +** function should *not* try to free the KeyInfo. +*/ +#define P4_KEYINFO_HANDOFF (-16) +#define P4_KEYINFO_STATIC (-17) + +/* +** The Vdbe.aColName array contains 5n Mem structures, where n is the +** number of columns of data returned by the statement. +*/ +#define COLNAME_NAME 0 +#define COLNAME_DECLTYPE 1 +#define COLNAME_DATABASE 2 +#define COLNAME_TABLE 3 +#define COLNAME_COLUMN 4 +#ifdef SQLITE_ENABLE_COLUMN_METADATA +# define COLNAME_N 5 /* Number of COLNAME_xxx symbols */ +#else +# ifdef SQLITE_OMIT_DECLTYPE +# define COLNAME_N 1 /* Store only the name */ +# else +# define COLNAME_N 2 /* Store the name and decltype */ +# endif +#endif + +/* +** The following macro converts a relative address in the p2 field +** of a VdbeOp structure into a negative number so that +** sqlite3VdbeAddOpList() knows that the address is relative. Calling +** the macro again restores the address. +*/ +#define ADDR(X) (-1-(X)) + +/* +** The makefile scans the vdbe.c source file and creates the "opcodes.h" +** header file that defines a number for each opcode used by the VDBE. +*/ +/************** Include opcodes.h in the middle of vdbe.h ********************/ +/************** Begin file opcodes.h *****************************************/ +/* Automatically generated. Do not edit */ +/* See the mkopcodeh.awk script for details */ +#define OP_Goto 1 +#define OP_Gosub 2 +#define OP_Return 3 +#define OP_Yield 4 +#define OP_HaltIfNull 5 +#define OP_Halt 6 +#define OP_Integer 7 +#define OP_Int64 8 +#define OP_Real 130 /* same as TK_FLOAT */ +#define OP_String8 94 /* same as TK_STRING */ +#define OP_String 9 +#define OP_Null 10 +#define OP_Blob 11 +#define OP_Variable 12 +#define OP_Move 13 +#define OP_Copy 14 +#define OP_SCopy 15 +#define OP_ResultRow 16 +#define OP_Concat 91 /* same as TK_CONCAT */ +#define OP_Add 86 /* same as TK_PLUS */ +#define OP_Subtract 87 /* same as TK_MINUS */ +#define OP_Multiply 88 /* same as TK_STAR */ +#define OP_Divide 89 /* same as TK_SLASH */ +#define OP_Remainder 90 /* same as TK_REM */ +#define OP_CollSeq 17 +#define OP_Function 18 +#define OP_BitAnd 82 /* same as TK_BITAND */ +#define OP_BitOr 83 /* same as TK_BITOR */ +#define OP_ShiftLeft 84 /* same as TK_LSHIFT */ +#define OP_ShiftRight 85 /* same as TK_RSHIFT */ +#define OP_AddImm 20 +#define OP_MustBeInt 21 +#define OP_RealAffinity 22 +#define OP_ToText 141 /* same as TK_TO_TEXT */ +#define OP_ToBlob 142 /* same as TK_TO_BLOB */ +#define OP_ToNumeric 143 /* same as TK_TO_NUMERIC*/ +#define OP_ToInt 144 /* same as TK_TO_INT */ +#define OP_ToReal 145 /* same as TK_TO_REAL */ +#define OP_Eq 76 /* same as TK_EQ */ +#define OP_Ne 75 /* same as TK_NE */ +#define OP_Lt 79 /* same as TK_LT */ +#define OP_Le 78 /* same as TK_LE */ +#define OP_Gt 77 /* same as TK_GT */ +#define OP_Ge 80 /* same as TK_GE */ +#define OP_Permutation 23 +#define OP_Compare 24 +#define OP_Jump 25 +#define OP_And 69 /* same as TK_AND */ +#define OP_Or 68 /* same as TK_OR */ +#define OP_Not 19 /* same as TK_NOT */ +#define OP_BitNot 93 /* same as TK_BITNOT */ +#define OP_If 26 +#define OP_IfNot 27 +#define OP_IsNull 73 /* same as TK_ISNULL */ +#define OP_NotNull 74 /* same as TK_NOTNULL */ +#define OP_Column 28 +#define OP_Affinity 29 +#define OP_MakeRecord 30 +#define OP_Count 31 +#define OP_Savepoint 32 +#define OP_AutoCommit 33 +#define OP_Transaction 34 +#define OP_ReadCookie 35 +#define OP_SetCookie 36 +#define OP_VerifyCookie 37 +#define OP_OpenRead 38 +#define OP_OpenWrite 39 +#define OP_OpenEphemeral 40 +#define OP_OpenPseudo 41 +#define OP_Close 42 +#define OP_SeekLt 43 +#define OP_SeekLe 44 +#define OP_SeekGe 45 +#define OP_SeekGt 46 +#define OP_Seek 47 +#define OP_NotFound 48 +#define OP_Found 49 +#define OP_IsUnique 50 +#define OP_NotExists 51 +#define OP_Sequence 52 +#define OP_NewRowid 53 +#define OP_Insert 54 +#define OP_InsertInt 55 +#define OP_Delete 56 +#define OP_ResetCount 57 +#define OP_RowKey 58 +#define OP_RowData 59 +#define OP_Rowid 60 +#define OP_NullRow 61 +#define OP_Last 62 +#define OP_Sort 63 +#define OP_Rewind 64 +#define OP_Prev 65 +#define OP_Next 66 +#define OP_IdxInsert 67 +#define OP_IdxDelete 70 +#define OP_IdxRowid 71 +#define OP_IdxLT 72 +#define OP_IdxGE 81 +#define OP_Destroy 92 +#define OP_Clear 95 +#define OP_CreateIndex 96 +#define OP_CreateTable 97 +#define OP_ParseSchema 98 +#define OP_LoadAnalysis 99 +#define OP_DropTable 100 +#define OP_DropIndex 101 +#define OP_DropTrigger 102 +#define OP_IntegrityCk 103 +#define OP_RowSetAdd 104 +#define OP_RowSetRead 105 +#define OP_RowSetTest 106 +#define OP_Program 107 +#define OP_Param 108 +#define OP_FkCounter 109 +#define OP_FkIfZero 110 +#define OP_MemMax 111 +#define OP_IfPos 112 +#define OP_IfNeg 113 +#define OP_IfZero 114 +#define OP_AggStep 115 +#define OP_AggFinal 116 +#define OP_Vacuum 117 +#define OP_IncrVacuum 118 +#define OP_Expire 119 +#define OP_TableLock 120 +#define OP_VBegin 121 +#define OP_VCreate 122 +#define OP_VDestroy 123 +#define OP_VOpen 124 +#define OP_VFilter 125 +#define OP_VColumn 126 +#define OP_VNext 127 +#define OP_VRename 128 +#define OP_VUpdate 129 +#define OP_Pagecount 131 +#define OP_Trace 132 +#define OP_Noop 133 +#define OP_Explain 134 + +/* The following opcode values are never used */ +#define OP_NotUsed_135 135 +#define OP_NotUsed_136 136 +#define OP_NotUsed_137 137 +#define OP_NotUsed_138 138 +#define OP_NotUsed_139 139 +#define OP_NotUsed_140 140 + + +/* Properties such as "out2" or "jump" that are specified in +** comments following the "case" for each opcode in the vdbe.c +** are encoded into bitvectors as follows: +*/ +#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */ +#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */ +#define OPFLG_IN1 0x0004 /* in1: P1 is an input */ +#define OPFLG_IN2 0x0008 /* in2: P2 is an input */ +#define OPFLG_IN3 0x0010 /* in3: P3 is an input */ +#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */ +#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */ +#define OPFLG_INITIALIZER {\ +/* 0 */ 0x00, 0x01, 0x05, 0x04, 0x04, 0x10, 0x00, 0x02,\ +/* 8 */ 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x24, 0x24,\ +/* 16 */ 0x00, 0x00, 0x00, 0x24, 0x04, 0x05, 0x04, 0x00,\ +/* 24 */ 0x00, 0x01, 0x05, 0x05, 0x00, 0x00, 0x00, 0x02,\ +/* 32 */ 0x00, 0x00, 0x00, 0x02, 0x10, 0x00, 0x00, 0x00,\ +/* 40 */ 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x11, 0x08,\ +/* 48 */ 0x11, 0x11, 0x11, 0x11, 0x02, 0x02, 0x00, 0x00,\ +/* 56 */ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x01,\ +/* 64 */ 0x01, 0x01, 0x01, 0x08, 0x4c, 0x4c, 0x00, 0x02,\ +/* 72 */ 0x01, 0x05, 0x05, 0x15, 0x15, 0x15, 0x15, 0x15,\ +/* 80 */ 0x15, 0x01, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c,\ +/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x02, 0x24, 0x02, 0x00,\ +/* 96 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ +/* 104 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x00, 0x01, 0x08,\ +/* 112 */ 0x05, 0x05, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00,\ +/* 120 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01,\ +/* 128 */ 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00,\ +/* 136 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x04,\ +/* 144 */ 0x04, 0x04,} + +/************** End of opcodes.h *********************************************/ +/************** Continuing where we left off in vdbe.h ***********************/ + +/* +** Prototypes for the VDBE interface. See comments on the implementation +** for a description of what each of these routines does. +*/ +SQLITE_PRIVATE Vdbe *sqlite3VdbeCreate(sqlite3*); +SQLITE_PRIVATE int sqlite3VdbeAddOp0(Vdbe*,int); +SQLITE_PRIVATE int sqlite3VdbeAddOp1(Vdbe*,int,int); +SQLITE_PRIVATE int sqlite3VdbeAddOp2(Vdbe*,int,int,int); +SQLITE_PRIVATE int sqlite3VdbeAddOp3(Vdbe*,int,int,int,int); +SQLITE_PRIVATE int sqlite3VdbeAddOp4(Vdbe*,int,int,int,int,const char *zP4,int); +SQLITE_PRIVATE int sqlite3VdbeAddOp4Int(Vdbe*,int,int,int,int,int); +SQLITE_PRIVATE int sqlite3VdbeAddOpList(Vdbe*, int nOp, VdbeOpList const *aOp); +SQLITE_PRIVATE void sqlite3VdbeChangeP1(Vdbe*, int addr, int P1); +SQLITE_PRIVATE void sqlite3VdbeChangeP2(Vdbe*, int addr, int P2); +SQLITE_PRIVATE void sqlite3VdbeChangeP3(Vdbe*, int addr, int P3); +SQLITE_PRIVATE void sqlite3VdbeChangeP5(Vdbe*, u8 P5); +SQLITE_PRIVATE void sqlite3VdbeJumpHere(Vdbe*, int addr); +SQLITE_PRIVATE void sqlite3VdbeChangeToNoop(Vdbe*, int addr, int N); +SQLITE_PRIVATE void sqlite3VdbeChangeP4(Vdbe*, int addr, const char *zP4, int N); +SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int); +SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int); +SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*); +SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*); +SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,int,int,int,int,int,int); +SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*); +SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int); +SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*); +#ifdef SQLITE_DEBUG +SQLITE_PRIVATE int sqlite3VdbeAssertMayAbort(Vdbe *, int); +SQLITE_PRIVATE void sqlite3VdbeTrace(Vdbe*,FILE*); +#endif +SQLITE_PRIVATE void sqlite3VdbeResetStepResult(Vdbe*); +SQLITE_PRIVATE int sqlite3VdbeReset(Vdbe*); +SQLITE_PRIVATE void sqlite3VdbeSetNumCols(Vdbe*,int); +SQLITE_PRIVATE int sqlite3VdbeSetColName(Vdbe*, int, int, const char *, void(*)(void*)); +SQLITE_PRIVATE void sqlite3VdbeCountChanges(Vdbe*); +SQLITE_PRIVATE sqlite3 *sqlite3VdbeDb(Vdbe*); +SQLITE_PRIVATE void sqlite3VdbeSetSql(Vdbe*, const char *z, int n, int); +SQLITE_PRIVATE void sqlite3VdbeSwap(Vdbe*,Vdbe*); +SQLITE_PRIVATE VdbeOp *sqlite3VdbeTakeOpArray(Vdbe*, int*, int*); +SQLITE_PRIVATE void sqlite3VdbeProgramDelete(sqlite3 *, SubProgram *, int); +SQLITE_PRIVATE sqlite3_value *sqlite3VdbeGetValue(Vdbe*, int, u8); +SQLITE_PRIVATE void sqlite3VdbeSetVarmask(Vdbe*, int); +#ifndef SQLITE_OMIT_TRACE +SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*); +#endif + +SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,char*,int); +SQLITE_PRIVATE void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); +SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); + + +#ifndef NDEBUG +SQLITE_PRIVATE void sqlite3VdbeComment(Vdbe*, const char*, ...); +# define VdbeComment(X) sqlite3VdbeComment X +SQLITE_PRIVATE void sqlite3VdbeNoopComment(Vdbe*, const char*, ...); +# define VdbeNoopComment(X) sqlite3VdbeNoopComment X +#else +# define VdbeComment(X) +# define VdbeNoopComment(X) +#endif + +#endif + +/************** End of vdbe.h ************************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include pager.h in the middle of sqliteInt.h *****************/ +/************** Begin file pager.h *******************************************/ +/* +** 2001 September 15 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the sqlite page cache +** subsystem. The page cache subsystem reads and writes a file a page +** at a time and provides a journal for rollback. +*/ + +#ifndef _PAGER_H_ +#define _PAGER_H_ + +/* +** Default maximum size for persistent journal files. A negative +** value means no limit. This value may be overridden using the +** sqlite3PagerJournalSizeLimit() API. See also "PRAGMA journal_size_limit". +*/ +#ifndef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT + #define SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT -1 +#endif + +/* +** The type used to represent a page number. The first page in a file +** is called page 1. 0 is used to represent "not a page". +*/ +typedef u32 Pgno; + +/* +** Each open file is managed by a separate instance of the "Pager" structure. +*/ +typedef struct Pager Pager; + +/* +** Handle type for pages. +*/ +typedef struct PgHdr DbPage; + +/* +** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is +** reserved for working around a windows/posix incompatibility). It is +** used in the journal to signify that the remainder of the journal file +** is devoted to storing a master journal name - there are no more pages to +** roll back. See comments for function writeMasterJournal() in pager.c +** for details. +*/ +#define PAGER_MJ_PGNO(x) ((Pgno)((PENDING_BYTE/((x)->pageSize))+1)) + +/* +** Allowed values for the flags parameter to sqlite3PagerOpen(). +** +** NOTE: These values must match the corresponding BTREE_ values in btree.h. +*/ +#define PAGER_OMIT_JOURNAL 0x0001 /* Do not use a rollback journal */ +#define PAGER_NO_READLOCK 0x0002 /* Omit readlocks on readonly files */ + +/* +** Valid values for the second argument to sqlite3PagerLockingMode(). +*/ +#define PAGER_LOCKINGMODE_QUERY -1 +#define PAGER_LOCKINGMODE_NORMAL 0 +#define PAGER_LOCKINGMODE_EXCLUSIVE 1 + +/* +** Valid values for the second argument to sqlite3PagerJournalMode(). +*/ +#define PAGER_JOURNALMODE_QUERY -1 +#define PAGER_JOURNALMODE_DELETE 0 /* Commit by deleting journal file */ +#define PAGER_JOURNALMODE_PERSIST 1 /* Commit by zeroing journal header */ +#define PAGER_JOURNALMODE_OFF 2 /* Journal omitted. */ +#define PAGER_JOURNALMODE_TRUNCATE 3 /* Commit by truncating journal */ +#define PAGER_JOURNALMODE_MEMORY 4 /* In-memory journal file */ + +/* +** The remainder of this file contains the declarations of the functions +** that make up the Pager sub-system API. See source code comments for +** a detailed description of each routine. +*/ + +/* Open and close a Pager connection. */ +SQLITE_PRIVATE int sqlite3PagerOpen( + sqlite3_vfs*, + Pager **ppPager, + const char*, + int, + int, + int, + void(*)(DbPage*) +); +SQLITE_PRIVATE int sqlite3PagerClose(Pager *pPager); +SQLITE_PRIVATE int sqlite3PagerReadFileheader(Pager*, int, unsigned char*); + +/* Functions used to configure a Pager object. */ +SQLITE_PRIVATE void sqlite3PagerSetBusyhandler(Pager*, int(*)(void *), void *); +SQLITE_PRIVATE int sqlite3PagerSetPagesize(Pager*, u16*, int); +SQLITE_PRIVATE int sqlite3PagerMaxPageCount(Pager*, int); +SQLITE_PRIVATE void sqlite3PagerSetCachesize(Pager*, int); +SQLITE_PRIVATE void sqlite3PagerSetSafetyLevel(Pager*,int,int); +SQLITE_PRIVATE int sqlite3PagerLockingMode(Pager *, int); +SQLITE_PRIVATE int sqlite3PagerJournalMode(Pager *, int); +SQLITE_PRIVATE i64 sqlite3PagerJournalSizeLimit(Pager *, i64); +SQLITE_PRIVATE sqlite3_backup **sqlite3PagerBackupPtr(Pager*); + +/* Functions used to obtain and release page references. */ +SQLITE_PRIVATE int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag); +#define sqlite3PagerGet(A,B,C) sqlite3PagerAcquire(A,B,C,0) +SQLITE_PRIVATE DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno); +SQLITE_PRIVATE void sqlite3PagerRef(DbPage*); +SQLITE_PRIVATE void sqlite3PagerUnref(DbPage*); + +/* Operations on page references. */ +SQLITE_PRIVATE int sqlite3PagerWrite(DbPage*); +SQLITE_PRIVATE void sqlite3PagerDontWrite(DbPage*); +SQLITE_PRIVATE int sqlite3PagerMovepage(Pager*,DbPage*,Pgno,int); +SQLITE_PRIVATE int sqlite3PagerPageRefcount(DbPage*); +SQLITE_PRIVATE void *sqlite3PagerGetData(DbPage *); +SQLITE_PRIVATE void *sqlite3PagerGetExtra(DbPage *); + +/* Functions used to manage pager transactions and savepoints. */ +SQLITE_PRIVATE int sqlite3PagerPagecount(Pager*, int*); +SQLITE_PRIVATE int sqlite3PagerBegin(Pager*, int exFlag, int); +SQLITE_PRIVATE int sqlite3PagerCommitPhaseOne(Pager*,const char *zMaster, int); +SQLITE_PRIVATE int sqlite3PagerSync(Pager *pPager); +SQLITE_PRIVATE int sqlite3PagerCommitPhaseTwo(Pager*); +SQLITE_PRIVATE int sqlite3PagerRollback(Pager*); +SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n); +SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint); +SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager); + +/* Functions used to query pager state and configuration. */ +SQLITE_PRIVATE u8 sqlite3PagerIsreadonly(Pager*); +SQLITE_PRIVATE int sqlite3PagerRefcount(Pager*); +SQLITE_PRIVATE const char *sqlite3PagerFilename(Pager*); +SQLITE_PRIVATE const sqlite3_vfs *sqlite3PagerVfs(Pager*); +SQLITE_PRIVATE sqlite3_file *sqlite3PagerFile(Pager*); +SQLITE_PRIVATE const char *sqlite3PagerJournalname(Pager*); +SQLITE_PRIVATE int sqlite3PagerNosync(Pager*); +SQLITE_PRIVATE void *sqlite3PagerTempSpace(Pager*); +SQLITE_PRIVATE int sqlite3PagerIsMemdb(Pager*); + +/* Functions used to truncate the database file. */ +SQLITE_PRIVATE void sqlite3PagerTruncateImage(Pager*,Pgno); + +/* Functions to support testing and debugging. */ +#if !defined(NDEBUG) || defined(SQLITE_TEST) +SQLITE_PRIVATE Pgno sqlite3PagerPagenumber(DbPage*); +SQLITE_PRIVATE int sqlite3PagerIswriteable(DbPage*); +#endif +#ifdef SQLITE_TEST +SQLITE_PRIVATE int *sqlite3PagerStats(Pager*); +SQLITE_PRIVATE void sqlite3PagerRefdump(Pager*); + void disable_simulated_io_errors(void); + void enable_simulated_io_errors(void); +#else +# define disable_simulated_io_errors() +# define enable_simulated_io_errors() +#endif + +#endif /* _PAGER_H_ */ + +/************** End of pager.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include pcache.h in the middle of sqliteInt.h ****************/ +/************** Begin file pcache.h ******************************************/ +/* +** 2008 August 05 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** This header file defines the interface that the sqlite page cache +** subsystem. +*/ + +#ifndef _PCACHE_H_ + +typedef struct PgHdr PgHdr; +typedef struct PCache PCache; + +/* +** Every page in the cache is controlled by an instance of the following +** structure. +*/ +struct PgHdr { + void *pData; /* Content of this page */ + void *pExtra; /* Extra content */ + PgHdr *pDirty; /* Transient list of dirty pages */ + Pgno pgno; /* Page number for this page */ + Pager *pPager; /* The pager this page is part of */ +#ifdef SQLITE_CHECK_PAGES + u32 pageHash; /* Hash of page content */ +#endif + u16 flags; /* PGHDR flags defined below */ + + /********************************************************************** + ** Elements above are public. All that follows is private to pcache.c + ** and should not be accessed by other modules. + */ + i16 nRef; /* Number of users of this page */ + PCache *pCache; /* Cache that owns this page */ + + PgHdr *pDirtyNext; /* Next element in list of dirty pages */ + PgHdr *pDirtyPrev; /* Previous element in list of dirty pages */ +}; + +/* Bit values for PgHdr.flags */ +#define PGHDR_DIRTY 0x002 /* Page has changed */ +#define PGHDR_NEED_SYNC 0x004 /* Fsync the rollback journal before + ** writing this page to the database */ +#define PGHDR_NEED_READ 0x008 /* Content is unread */ +#define PGHDR_REUSE_UNLIKELY 0x010 /* A hint that reuse is unlikely */ +#define PGHDR_DONT_WRITE 0x020 /* Do not write content to disk */ + +/* Initialize and shutdown the page cache subsystem */ +SQLITE_PRIVATE int sqlite3PcacheInitialize(void); +SQLITE_PRIVATE void sqlite3PcacheShutdown(void); + +/* Page cache buffer management: +** These routines implement SQLITE_CONFIG_PAGECACHE. +*/ +SQLITE_PRIVATE void sqlite3PCacheBufferSetup(void *, int sz, int n); + +/* Create a new pager cache. +** Under memory stress, invoke xStress to try to make pages clean. +** Only clean and unpinned pages can be reclaimed. +*/ +SQLITE_PRIVATE void sqlite3PcacheOpen( + int szPage, /* Size of every page */ + int szExtra, /* Extra space associated with each page */ + int bPurgeable, /* True if pages are on backing store */ + int (*xStress)(void*, PgHdr*), /* Call to try to make pages clean */ + void *pStress, /* Argument to xStress */ + PCache *pToInit /* Preallocated space for the PCache */ +); + +/* Modify the page-size after the cache has been created. */ +SQLITE_PRIVATE void sqlite3PcacheSetPageSize(PCache *, int); + +/* Return the size in bytes of a PCache object. Used to preallocate +** storage space. +*/ +SQLITE_PRIVATE int sqlite3PcacheSize(void); + +/* One release per successful fetch. Page is pinned until released. +** Reference counted. +*/ +SQLITE_PRIVATE int sqlite3PcacheFetch(PCache*, Pgno, int createFlag, PgHdr**); +SQLITE_PRIVATE void sqlite3PcacheRelease(PgHdr*); + +SQLITE_PRIVATE void sqlite3PcacheDrop(PgHdr*); /* Remove page from cache */ +SQLITE_PRIVATE void sqlite3PcacheMakeDirty(PgHdr*); /* Make sure page is marked dirty */ +SQLITE_PRIVATE void sqlite3PcacheMakeClean(PgHdr*); /* Mark a single page as clean */ +SQLITE_PRIVATE void sqlite3PcacheCleanAll(PCache*); /* Mark all dirty list pages as clean */ + +/* Change a page number. Used by incr-vacuum. */ +SQLITE_PRIVATE void sqlite3PcacheMove(PgHdr*, Pgno); + +/* Remove all pages with pgno>x. Reset the cache if x==0 */ +SQLITE_PRIVATE void sqlite3PcacheTruncate(PCache*, Pgno x); + +/* Get a list of all dirty pages in the cache, sorted by page number */ +SQLITE_PRIVATE PgHdr *sqlite3PcacheDirtyList(PCache*); + +/* Reset and close the cache object */ +SQLITE_PRIVATE void sqlite3PcacheClose(PCache*); + +/* Clear flags from pages of the page cache */ +SQLITE_PRIVATE void sqlite3PcacheClearSyncFlags(PCache *); + +/* Discard the contents of the cache */ +SQLITE_PRIVATE void sqlite3PcacheClear(PCache*); + +/* Return the total number of outstanding page references */ +SQLITE_PRIVATE int sqlite3PcacheRefCount(PCache*); + +/* Increment the reference count of an existing page */ +SQLITE_PRIVATE void sqlite3PcacheRef(PgHdr*); + +SQLITE_PRIVATE int sqlite3PcachePageRefcount(PgHdr*); + +/* Return the total number of pages stored in the cache */ +SQLITE_PRIVATE int sqlite3PcachePagecount(PCache*); + +#if defined(SQLITE_CHECK_PAGES) || defined(SQLITE_DEBUG) +/* Iterate through all dirty pages currently stored in the cache. This +** interface is only available if SQLITE_CHECK_PAGES is defined when the +** library is built. +*/ +SQLITE_PRIVATE void sqlite3PcacheIterateDirty(PCache *pCache, void (*xIter)(PgHdr *)); +#endif + +/* Set and get the suggested cache-size for the specified pager-cache. +** +** If no global maximum is configured, then the system attempts to limit +** the total number of pages cached by purgeable pager-caches to the sum +** of the suggested cache-sizes. +*/ +SQLITE_PRIVATE void sqlite3PcacheSetCachesize(PCache *, int); +#ifdef SQLITE_TEST +SQLITE_PRIVATE int sqlite3PcacheGetCachesize(PCache *); +#endif + +#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT +/* Try to return memory used by the pcache module to the main memory heap */ +SQLITE_PRIVATE int sqlite3PcacheReleaseMemory(int); +#endif + +#ifdef SQLITE_TEST +SQLITE_PRIVATE void sqlite3PcacheStats(int*,int*,int*,int*); +#endif + +SQLITE_PRIVATE void sqlite3PCacheSetDefault(void); + +#endif /* _PCACHE_H_ */ + +/************** End of pcache.h **********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ + +/************** Include os.h in the middle of sqliteInt.h ********************/ +/************** Begin file os.h **********************************************/ +/* +** 2001 September 16 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This header file (together with is companion C source-code file +** "os.c") attempt to abstract the underlying operating system so that +** the SQLite library will work on both POSIX and windows systems. +** +** This header file is #include-ed by sqliteInt.h and thus ends up +** being included by every source file. +*/ +#ifndef _SQLITE_OS_H_ +#define _SQLITE_OS_H_ + +/* +** Figure out if we are dealing with Unix, Windows, or some other +** operating system. After the following block of preprocess macros, +** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER +** will defined to either 1 or 0. One of the four will be 1. The other +** three will be 0. +*/ +#if defined(SQLITE_OS_OTHER) +# if SQLITE_OS_OTHER==1 +# undef SQLITE_OS_UNIX +# define SQLITE_OS_UNIX 0 +# undef SQLITE_OS_WIN +# define SQLITE_OS_WIN 0 +# undef SQLITE_OS_OS2 +# define SQLITE_OS_OS2 0 +# else +# undef SQLITE_OS_OTHER +# endif +#endif +#if !defined(SQLITE_OS_UNIX) && !defined(SQLITE_OS_OTHER) +# define SQLITE_OS_OTHER 0 +# ifndef SQLITE_OS_WIN +# if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) +# define SQLITE_OS_WIN 1 +# define SQLITE_OS_UNIX 0 +# define SQLITE_OS_OS2 0 +# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) +# define SQLITE_OS_WIN 0 +# define SQLITE_OS_UNIX 0 +# define SQLITE_OS_OS2 1 +# else +# define SQLITE_OS_WIN 0 +# define SQLITE_OS_UNIX 1 +# define SQLITE_OS_OS2 0 +# endif +# else +# define SQLITE_OS_UNIX 0 +# define SQLITE_OS_OS2 0 +# endif +#else +# ifndef SQLITE_OS_WIN +# define SQLITE_OS_WIN 0 +# endif +#endif + +/* +** Determine if we are dealing with WindowsCE - which has a much +** reduced API. +*/ +#if defined(_WIN32_WCE) +# define SQLITE_OS_WINCE 1 +#else +# define SQLITE_OS_WINCE 0 +#endif + + +/* +** Define the maximum size of a temporary filename +*/ +#if SQLITE_OS_WIN +# include +# define SQLITE_TEMPNAME_SIZE (MAX_PATH+50) +#elif SQLITE_OS_OS2 +# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) +# include /* has to be included before os2.h for linking to work */ +# endif +# define INCL_DOSDATETIME +# define INCL_DOSFILEMGR +# define INCL_DOSERRORS +# define INCL_DOSMISC +# define INCL_DOSPROCESS +# define INCL_DOSMODULEMGR +# define INCL_DOSSEMAPHORES +# include +# include +# define SQLITE_TEMPNAME_SIZE (CCHMAXPATHCOMP) +#else +# define SQLITE_TEMPNAME_SIZE 200 +#endif + +/* If the SET_FULLSYNC macro is not defined above, then make it +** a no-op +*/ +#ifndef SET_FULLSYNC +# define SET_FULLSYNC(x,y) +#endif + +/* +** The default size of a disk sector +*/ +#ifndef SQLITE_DEFAULT_SECTOR_SIZE +# define SQLITE_DEFAULT_SECTOR_SIZE 512 +#endif + +/* +** Temporary files are named starting with this prefix followed by 16 random +** alphanumeric characters, and no file extension. They are stored in the +** OS's standard temporary file directory, and are deleted prior to exit. +** If sqlite is being embedded in another program, you may wish to change the +** prefix to reflect your program's name, so that if your program exits +** prematurely, old temporary files can be easily identified. This can be done +** using -DSQLITE_TEMP_FILE_PREFIX=myprefix_ on the compiler command line. +** +** 2006-10-31: The default prefix used to be "sqlite_". But then +** Mcafee started using SQLite in their anti-virus product and it +** started putting files with the "sqlite" name in the c:/temp folder. +** This annoyed many windows users. Those users would then do a +** Google search for "sqlite", find the telephone numbers of the +** developers and call to wake them up at night and complain. +** For this reason, the default name prefix is changed to be "sqlite" +** spelled backwards. So the temp files are still identified, but +** anybody smart enough to figure out the code is also likely smart +** enough to know that calling the developer will not help get rid +** of the file. +*/ +#ifndef SQLITE_TEMP_FILE_PREFIX +# define SQLITE_TEMP_FILE_PREFIX "etilqs_" +#endif + +/* +** The following values may be passed as the second argument to +** sqlite3OsLock(). The various locks exhibit the following semantics: +** +** SHARED: Any number of processes may hold a SHARED lock simultaneously. +** RESERVED: A single process may hold a RESERVED lock on a file at +** any time. Other processes may hold and obtain new SHARED locks. +** PENDING: A single process may hold a PENDING lock on a file at +** any one time. Existing SHARED locks may persist, but no new +** SHARED locks may be obtained by other processes. +** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks. +** +** PENDING_LOCK may not be passed directly to sqlite3OsLock(). Instead, a +** process that requests an EXCLUSIVE lock may actually obtain a PENDING +** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to +** sqlite3OsLock(). +*/ +#define NO_LOCK 0 +#define SHARED_LOCK 1 +#define RESERVED_LOCK 2 +#define PENDING_LOCK 3 +#define EXCLUSIVE_LOCK 4 + +/* +** File Locking Notes: (Mostly about windows but also some info for Unix) +** +** We cannot use LockFileEx() or UnlockFileEx() on Win95/98/ME because +** those functions are not available. So we use only LockFile() and +** UnlockFile(). +** +** LockFile() prevents not just writing but also reading by other processes. +** A SHARED_LOCK is obtained by locking a single randomly-chosen +** byte out of a specific range of bytes. The lock byte is obtained at +** random so two separate readers can probably access the file at the +** same time, unless they are unlucky and choose the same lock byte. +** An EXCLUSIVE_LOCK is obtained by locking all bytes in the range. +** There can only be one writer. A RESERVED_LOCK is obtained by locking +** a single byte of the file that is designated as the reserved lock byte. +** A PENDING_LOCK is obtained by locking a designated byte different from +** the RESERVED_LOCK byte. +** +** On WinNT/2K/XP systems, LockFileEx() and UnlockFileEx() are available, +** which means we can use reader/writer locks. When reader/writer locks +** are used, the lock is placed on the same range of bytes that is used +** for probabilistic locking in Win95/98/ME. Hence, the locking scheme +** will support two or more Win95 readers or two or more WinNT readers. +** But a single Win95 reader will lock out all WinNT readers and a single +** WinNT reader will lock out all other Win95 readers. +** +** The following #defines specify the range of bytes used for locking. +** SHARED_SIZE is the number of bytes available in the pool from which +** a random byte is selected for a shared lock. The pool of bytes for +** shared locks begins at SHARED_FIRST. +** +** The same locking strategy and +** byte ranges are used for Unix. This leaves open the possiblity of having +** clients on win95, winNT, and unix all talking to the same shared file +** and all locking correctly. To do so would require that samba (or whatever +** tool is being used for file sharing) implements locks correctly between +** windows and unix. I'm guessing that isn't likely to happen, but by +** using the same locking range we are at least open to the possibility. +** +** Locking in windows is manditory. For this reason, we cannot store +** actual data in the bytes used for locking. The pager never allocates +** the pages involved in locking therefore. SHARED_SIZE is selected so +** that all locks will fit on a single page even at the minimum page size. +** PENDING_BYTE defines the beginning of the locks. By default PENDING_BYTE +** is set high so that we don't have to allocate an unused page except +** for very large databases. But one should test the page skipping logic +** by setting PENDING_BYTE low and running the entire regression suite. +** +** Changing the value of PENDING_BYTE results in a subtly incompatible +** file format. Depending on how it is changed, you might not notice +** the incompatibility right away, even running a full regression test. +** The default location of PENDING_BYTE is the first byte past the +** 1GB boundary. +** +*/ +#define PENDING_BYTE sqlite3PendingByte +#define RESERVED_BYTE (PENDING_BYTE+1) +#define SHARED_FIRST (PENDING_BYTE+2) +#define SHARED_SIZE 510 + +/* +** Wrapper around OS specific sqlite3_os_init() function. +*/ +SQLITE_PRIVATE int sqlite3OsInit(void); + +/* +** Functions for accessing sqlite3_file methods +*/ +SQLITE_PRIVATE int sqlite3OsClose(sqlite3_file*); +SQLITE_PRIVATE int sqlite3OsRead(sqlite3_file*, void*, int amt, i64 offset); +SQLITE_PRIVATE int sqlite3OsWrite(sqlite3_file*, const void*, int amt, i64 offset); +SQLITE_PRIVATE int sqlite3OsTruncate(sqlite3_file*, i64 size); +SQLITE_PRIVATE int sqlite3OsSync(sqlite3_file*, int); +SQLITE_PRIVATE int sqlite3OsFileSize(sqlite3_file*, i64 *pSize); +SQLITE_PRIVATE int sqlite3OsLock(sqlite3_file*, int); +SQLITE_PRIVATE int sqlite3OsUnlock(sqlite3_file*, int); +SQLITE_PRIVATE int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut); +SQLITE_PRIVATE int sqlite3OsFileControl(sqlite3_file*,int,void*); +#define SQLITE_FCNTL_DB_UNCHANGED 0xca093fa0 +SQLITE_PRIVATE int sqlite3OsSectorSize(sqlite3_file *id); +SQLITE_PRIVATE int sqlite3OsDeviceCharacteristics(sqlite3_file *id); + +/* +** Functions for accessing sqlite3_vfs methods +*/ +SQLITE_PRIVATE int sqlite3OsOpen(sqlite3_vfs *, const char *, sqlite3_file*, int, int *); +SQLITE_PRIVATE int sqlite3OsDelete(sqlite3_vfs *, const char *, int); +SQLITE_PRIVATE int sqlite3OsAccess(sqlite3_vfs *, const char *, int, int *pResOut); +SQLITE_PRIVATE int sqlite3OsFullPathname(sqlite3_vfs *, const char *, int, char *); +#ifndef SQLITE_OMIT_LOAD_EXTENSION +SQLITE_PRIVATE void *sqlite3OsDlOpen(sqlite3_vfs *, const char *); +SQLITE_PRIVATE void sqlite3OsDlError(sqlite3_vfs *, int, char *); +SQLITE_PRIVATE void (*sqlite3OsDlSym(sqlite3_vfs *, void *, const char *))(void); +SQLITE_PRIVATE void sqlite3OsDlClose(sqlite3_vfs *, void *); +#endif /* SQLITE_OMIT_LOAD_EXTENSION */ +SQLITE_PRIVATE int sqlite3OsRandomness(sqlite3_vfs *, int, char *); +SQLITE_PRIVATE int sqlite3OsSleep(sqlite3_vfs *, int); +SQLITE_PRIVATE int sqlite3OsCurrentTime(sqlite3_vfs *, double*); + +/* +** Convenience functions for opening and closing files using +** sqlite3_malloc() to obtain space for the file-handle structure. +*/ +SQLITE_PRIVATE int sqlite3OsOpenMalloc(sqlite3_vfs *, const char *, sqlite3_file **, int,int*); +SQLITE_PRIVATE int sqlite3OsCloseFree(sqlite3_file *); + +#endif /* _SQLITE_OS_H_ */ + +/************** End of os.h **************************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ +/************** Include mutex.h in the middle of sqliteInt.h *****************/ +/************** Begin file mutex.h *******************************************/ +/* +** 2007 August 28 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +************************************************************************* +** +** This file contains the common header for all mutex implementations. +** The sqliteInt.h header #includes this file so that it is available +** to all source files. We break it out in an effort to keep the code +** better organized. +** +** NOTE: source files should *not* #include this header file directly. +** Source files should #include the sqliteInt.h file and let that file +** include this one indirectly. +*/ + + +/* +** Figure out what version of the code to use. The choices are +** +** SQLITE_MUTEX_OMIT No mutex logic. Not even stubs. The +** mutexes implemention cannot be overridden +** at start-time. +** +** SQLITE_MUTEX_NOOP For single-threaded applications. No +** mutual exclusion is provided. But this +** implementation can be overridden at +** start-time. +** +** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. +** +** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. +** +** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. +*/ +#if !SQLITE_THREADSAFE +# define SQLITE_MUTEX_OMIT +#endif +#if SQLITE_THREADSAFE && !defined(SQLITE_MUTEX_NOOP) +# if SQLITE_OS_UNIX +# define SQLITE_MUTEX_PTHREADS +# elif SQLITE_OS_WIN +# define SQLITE_MUTEX_W32 +# elif SQLITE_OS_OS2 +# define SQLITE_MUTEX_OS2 +# else +# define SQLITE_MUTEX_NOOP +# endif +#endif + +#ifdef SQLITE_MUTEX_OMIT +/* +** If this is a no-op implementation, implement everything as macros. +*/ +#define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) +#define sqlite3_mutex_free(X) +#define sqlite3_mutex_enter(X) +#define sqlite3_mutex_try(X) SQLITE_OK +#define sqlite3_mutex_leave(X) +#define sqlite3_mutex_held(X) 1 +#define sqlite3_mutex_notheld(X) 1 +#define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) +#define sqlite3MutexInit() SQLITE_OK +#define sqlite3MutexEnd() +#endif /* defined(SQLITE_MUTEX_OMIT) */ + +/************** End of mutex.h ***********************************************/ +/************** Continuing where we left off in sqliteInt.h ******************/ + + +/* +** Each database file to be accessed by the system is an instance +** of the following structure. There are normally two of these structures +** in the sqlite.aDb[] array. aDb[0] is the main database file and +** aDb[1] is the database file used to hold temporary tables. Additional +** databases may be attached. +*/ +struct Db { + char *zName; /* Name of this database */ + Btree *pBt; /* The B*Tree structure for this database file */ + u8 inTrans; /* 0: not writable. 1: Transaction. 2: Checkpoint */ + u8 safety_level; /* How aggressive at syncing data to disk */ + Schema *pSchema; /* Pointer to database schema (possibly shared) */ +}; + +/* +** An instance of the following structure stores a database schema. +** +** If there are no virtual tables configured in this schema, the +** Schema.db variable is set to NULL. After the first virtual table +** has been added, it is set to point to the database connection +** used to create the connection. Once a virtual table has been +** added to the Schema structure and the Schema.db variable populated, +** only that database connection may use the Schema to prepare +** statements. +*/ +struct Schema { + int schema_cookie; /* Database schema version number for this file */ + Hash tblHash; /* All tables indexed by name */ + Hash idxHash; /* All (named) indices indexed by name */ + Hash trigHash; /* All triggers indexed by name */ + Hash fkeyHash; /* All foreign keys by referenced table name */ + Table *pSeqTab; /* The sqlite_sequence table used by AUTOINCREMENT */ + u8 file_format; /* Schema format version for this file */ + u8 enc; /* Text encoding used by this database */ + u16 flags; /* Flags associated with this schema */ + int cache_size; /* Number of pages to use in the cache */ +#ifndef SQLITE_OMIT_VIRTUALTABLE + sqlite3 *db; /* "Owner" connection. See comment above */ +#endif +}; + +/* +** These macros can be used to test, set, or clear bits in the +** Db.flags field. +*/ +#define DbHasProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))==(P)) +#define DbHasAnyProperty(D,I,P) (((D)->aDb[I].pSchema->flags&(P))!=0) +#define DbSetProperty(D,I,P) (D)->aDb[I].pSchema->flags|=(P) +#define DbClearProperty(D,I,P) (D)->aDb[I].pSchema->flags&=~(P) + +/* +** Allowed values for the DB.flags field. +** +** The DB_SchemaLoaded flag is set after the database schema has been +** read into internal hash tables. +** +** DB_UnresetViews means that one or more views have column names that +** have been filled out. If the schema changes, these column names might +** changes and so the view will need to be reset. +*/ +#define DB_SchemaLoaded 0x0001 /* The schema has been loaded */ +#define DB_UnresetViews 0x0002 /* Some views have defined column names */ +#define DB_Empty 0x0004 /* The file is empty (length 0 bytes) */ + +/* +** The number of different kinds of things that can be limited +** using the sqlite3_limit() interface. +*/ +#define SQLITE_N_LIMIT (SQLITE_LIMIT_TRIGGER_DEPTH+1) + +/* +** Lookaside malloc is a set of fixed-size buffers that can be used +** to satisfy small transient memory allocation requests for objects +** associated with a particular database connection. The use of +** lookaside malloc provides a significant performance enhancement +** (approx 10%) by avoiding numerous malloc/free requests while parsing +** SQL statements. +** +** The Lookaside structure holds configuration information about the +** lookaside malloc subsystem. Each available memory allocation in +** the lookaside subsystem is stored on a linked list of LookasideSlot +** objects. +** +** Lookaside allocations are only allowed for objects that are associated +** with a particular database connection. Hence, schema information cannot +** be stored in lookaside because in shared cache mode the schema information +** is shared by multiple database connections. Therefore, while parsing +** schema information, the Lookaside.bEnabled flag is cleared so that +** lookaside allocations are not used to construct the schema objects. +*/ +struct Lookaside { + u16 sz; /* Size of each buffer in bytes */ + u8 bEnabled; /* False to disable new lookaside allocations */ + u8 bMalloced; /* True if pStart obtained from sqlite3_malloc() */ + int nOut; /* Number of buffers currently checked out */ + int mxOut; /* Highwater mark for nOut */ + LookasideSlot *pFree; /* List of available buffers */ + void *pStart; /* First byte of available memory space */ + void *pEnd; /* First byte past end of available space */ +}; +struct LookasideSlot { + LookasideSlot *pNext; /* Next buffer in the list of free buffers */ +}; + +/* +** A hash table for function definitions. +** +** Hash each FuncDef structure into one of the FuncDefHash.a[] slots. +** Collisions are on the FuncDef.pHash chain. +*/ +struct FuncDefHash { + FuncDef *a[23]; /* Hash table for functions */ +}; + +/* +** Each database is an instance of the following structure. +** +** The sqlite.lastRowid records the last insert rowid generated by an +** insert statement. Inserts on views do not affect its value. Each +** trigger has its own context, so that lastRowid can be updated inside +** triggers as usual. The previous value will be restored once the trigger +** exits. Upon entering a before or instead of trigger, lastRowid is no +** longer (since after version 2.8.12) reset to -1. +** +** The sqlite.nChange does not count changes within triggers and keeps no +** context. It is reset at start of sqlite3_exec. +** The sqlite.lsChange represents the number of changes made by the last +** insert, update, or delete statement. It remains constant throughout the +** length of a statement and is then updated by OP_SetCounts. It keeps a +** context stack just like lastRowid so that the count of changes +** within a trigger is not seen outside the trigger. Changes to views do not +** affect the value of lsChange. +** The sqlite.csChange keeps track of the number of current changes (since +** the last statement) and is used to update sqlite_lsChange. +** +** The member variables sqlite.errCode, sqlite.zErrMsg and sqlite.zErrMsg16 +** store the most recent error code and, if applicable, string. The +** internal function sqlite3Error() is used to set these variables +** consistently. +*/ +struct sqlite3 { + sqlite3_vfs *pVfs; /* OS Interface */ + int nDb; /* Number of backends currently in use */ + Db *aDb; /* All backends */ + int flags; /* Miscellaneous flags. See below */ + int openFlags; /* Flags passed to sqlite3_vfs.xOpen() */ + int errCode; /* Most recent error code (SQLITE_*) */ + int errMask; /* & result codes with this before returning */ + u8 autoCommit; /* The auto-commit flag. */ + u8 temp_store; /* 1: file 2: memory 0: default */ + u8 mallocFailed; /* True if we have seen a malloc failure */ + u8 dfltLockMode; /* Default locking-mode for attached dbs */ + u8 dfltJournalMode; /* Default journal mode for attached dbs */ + signed char nextAutovac; /* Autovac setting after VACUUM if >=0 */ + int nextPagesize; /* Pagesize after VACUUM if >0 */ + int nTable; /* Number of tables in the database */ + CollSeq *pDfltColl; /* The default collating sequence (BINARY) */ + i64 lastRowid; /* ROWID of most recent insert (see above) */ + u32 magic; /* Magic number for detect library misuse */ + int nChange; /* Value returned by sqlite3_changes() */ + int nTotalChange; /* Value returned by sqlite3_total_changes() */ + sqlite3_mutex *mutex; /* Connection mutex */ + int aLimit[SQLITE_N_LIMIT]; /* Limits */ + struct sqlite3InitInfo { /* Information used during initialization */ + int iDb; /* When back is being initialized */ + int newTnum; /* Rootpage of table being initialized */ + u8 busy; /* TRUE if currently initializing */ + u8 orphanTrigger; /* Last statement is orphaned TEMP trigger */ + } init; + int nExtension; /* Number of loaded extensions */ + void **aExtension; /* Array of shared library handles */ + struct Vdbe *pVdbe; /* List of active virtual machines */ + int activeVdbeCnt; /* Number of VDBEs currently executing */ + int writeVdbeCnt; /* Number of active VDBEs that are writing */ + void (*xTrace)(void*,const char*); /* Trace function */ + void *pTraceArg; /* Argument to the trace function */ + void (*xProfile)(void*,const char*,u64); /* Profiling function */ + void *pProfileArg; /* Argument to profile function */ + void *pCommitArg; /* Argument to xCommitCallback() */ + int (*xCommitCallback)(void*); /* Invoked at every commit. */ + void *pRollbackArg; /* Argument to xRollbackCallback() */ + void (*xRollbackCallback)(void*); /* Invoked at every commit. */ + void *pUpdateArg; + void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64); + void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*); + void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*); + void *pCollNeededArg; + sqlite3_value *pErr; /* Most recent error message */ + char *zErrMsg; /* Most recent error message (UTF-8 encoded) */ + char *zErrMsg16; /* Most recent error message (UTF-16 encoded) */ + union { + volatile int isInterrupted; /* True if sqlite3_interrupt has been called */ + double notUsed1; /* Spacer */ + } u1; + Lookaside lookaside; /* Lookaside malloc configuration */ +#ifndef SQLITE_OMIT_AUTHORIZATION + int (*xAuth)(void*,int,const char*,const char*,const char*,const char*); + /* Access authorization function */ + void *pAuthArg; /* 1st argument to the access auth function */ +#endif +#ifndef SQLITE_OMIT_PROGRESS_CALLBACK + int (*xProgress)(void *); /* The progress callback */ + void *pProgressArg; /* Argument to the progress callback */ + int nProgressOps; /* Number of opcodes for progress callback */ +#endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + Hash aModule; /* populated by sqlite3_create_module() */ + Table *pVTab; /* vtab with active Connect/Create method */ + VTable **aVTrans; /* Virtual tables with open transactions */ + int nVTrans; /* Allocated size of aVTrans */ + VTable *pDisconnect; /* Disconnect these in next sqlite3_prepare() */ +#endif + FuncDefHash aFunc; /* Hash table of connection functions */ + Hash aCollSeq; /* All collating sequences */ + BusyHandler busyHandler; /* Busy callback */ + int busyTimeout; /* Busy handler timeout, in msec */ + Db aDbStatic[2]; /* Static space for the 2 default backends */ + Savepoint *pSavepoint; /* List of active savepoints */ + int nSavepoint; /* Number of non-transaction savepoints */ + int nStatement; /* Number of nested statement-transactions */ + u8 isTransactionSavepoint; /* True if the outermost savepoint is a TS */ + i64 nDeferredCons; /* Net deferred constraints this transaction. */ + +#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY + /* The following variables are all protected by the STATIC_MASTER + ** mutex, not by sqlite3.mutex. They are used by code in notify.c. + ** + ** When X.pUnlockConnection==Y, that means that X is waiting for Y to + ** unlock so that it can proceed. + ** + ** When X.pBlockingConnection==Y, that means that something that X tried + ** tried to do recently failed with an SQLITE_LOCKED error due to locks + ** held by Y. + */ + sqlite3 *pBlockingConnection; /* Connection that caused SQLITE_LOCKED */ + sqlite3 *pUnlockConnection; /* Connection to watch for unlock */ + void *pUnlockArg; /* Argument to xUnlockNotify */ + void (*xUnlockNotify)(void **, int); /* Unlock notify callback */ + sqlite3 *pNextBlocked; /* Next in list of all blocked connections */ +#endif +}; + +/* +** A macro to discover the encoding of a database. +*/ +#define ENC(db) ((db)->aDb[0].pSchema->enc) + +/* +** Possible values for the sqlite3.flags. +*/ +#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */ +#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */ +#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */ +#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */ +#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */ + /* DELETE, or UPDATE and return */ + /* the count using a callback. */ +#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */ + /* result set is empty */ +#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */ +#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */ +#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */ +#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when + ** accessing read-only databases */ +#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */ +#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */ +#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */ +#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */ +#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */ +#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */ +#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */ +#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */ +#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */ + +/* +** Bits of the sqlite3.flags field that are used by the +** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface. +** These must be the low-order bits of the flags field. +*/ +#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */ +#define SQLITE_ColumnCache 0x02 /* Disable the column cache */ +#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */ +#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */ +#define SQLITE_IndexCover 0x10 /* Disable index covering table */ +#define SQLITE_OptMask 0x1f /* Mask of all disablable opts */ + +/* +** Possible values for the sqlite.magic field. +** The numbers are obtained at random and have no special meaning, other +** than being distinct from one another. +*/ +#define SQLITE_MAGIC_OPEN 0xa029a697 /* Database is open */ +#define SQLITE_MAGIC_CLOSED 0x9f3c2d33 /* Database is closed */ +#define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ +#define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ +#define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ + +/* +** Each SQL function is defined by an instance of the following +** structure. A pointer to this structure is stored in the sqlite.aFunc +** hash table. When multiple functions have the same name, the hash table +** points to a linked list of these structures. +*/ +struct FuncDef { + i16 nArg; /* Number of arguments. -1 means unlimited */ + u8 iPrefEnc; /* Preferred text encoding (SQLITE_UTF8, 16LE, 16BE) */ + u8 flags; /* Some combination of SQLITE_FUNC_* */ + void *pUserData; /* User data parameter */ + FuncDef *pNext; /* Next function with same name */ + void (*xFunc)(sqlite3_context*,int,sqlite3_value**); /* Regular function */ + void (*xStep)(sqlite3_context*,int,sqlite3_value**); /* Aggregate step */ + void (*xFinalize)(sqlite3_context*); /* Aggregate finalizer */ + char *zName; /* SQL name of the function. */ + FuncDef *pHash; /* Next with a different name but the same hash */ +}; + +/* +** Possible values for FuncDef.flags +*/ +#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */ +#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */ +#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */ +#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */ +#define SQLITE_FUNC_PRIVATE 0x10 /* Allowed for internal use only */ +#define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */ +#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */ + +/* +** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are +** used to create the initializers for the FuncDef structures. +** +** FUNCTION(zName, nArg, iArg, bNC, xFunc) +** Used to create a scalar function definition of a function zName +** implemented by C function xFunc that accepts nArg arguments. The +** value passed as iArg is cast to a (void*) and made available +** as the user-data (sqlite3_user_data()) for the function. If +** argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set. +** +** AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal) +** Used to create an aggregate function definition implemented by +** the C functions xStep and xFinal. The first four parameters +** are interpreted in the same way as the first 4 parameters to +** FUNCTION(). +** +** LIKEFUNC(zName, nArg, pArg, flags) +** Used to create a scalar function definition of a function zName +** that accepts nArg arguments and is implemented by a call to C +** function likeFunc. Argument pArg is cast to a (void *) and made +** available as the function user-data (sqlite3_user_data()). The +** FuncDef.flags variable is set to the value passed as the flags +** parameter. +*/ +#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \ + {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0} +#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ + {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \ + pArg, 0, xFunc, 0, 0, #zName, 0} +#define LIKEFUNC(zName, nArg, arg, flags) \ + {nArg, SQLITE_UTF8, flags, (void *)arg, 0, likeFunc, 0, 0, #zName, 0} +#define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal) \ + {nArg, SQLITE_UTF8, nc*SQLITE_FUNC_NEEDCOLL, \ + SQLITE_INT_TO_PTR(arg), 0, 0, xStep,xFinal,#zName,0} + +/* +** All current savepoints are stored in a linked list starting at +** sqlite3.pSavepoint. The first element in the list is the most recently +** opened savepoint. Savepoints are added to the list by the vdbe +** OP_Savepoint instruction. +*/ +struct Savepoint { + char *zName; /* Savepoint name (nul-terminated) */ + i64 nDeferredCons; /* Number of deferred fk violations */ + Savepoint *pNext; /* Parent savepoint (if any) */ +}; + +/* +** The following are used as the second parameter to sqlite3Savepoint(), +** and as the P1 argument to the OP_Savepoint instruction. +*/ +#define SAVEPOINT_BEGIN 0 +#define SAVEPOINT_RELEASE 1 +#define SAVEPOINT_ROLLBACK 2 + + +/* +** Each SQLite module (virtual table definition) is defined by an +** instance of the following structure, stored in the sqlite3.aModule +** hash table. +*/ +struct Module { + const sqlite3_module *pModule; /* Callback pointers */ + const char *zName; /* Name passed to create_module() */ + void *pAux; /* pAux passed to create_module() */ + void (*xDestroy)(void *); /* Module destructor function */ +}; + +/* +** information about each column of an SQL table is held in an instance +** of this structure. +*/ +struct Column { + char *zName; /* Name of this column */ + Expr *pDflt; /* Default value of this column */ + char *zDflt; /* Original text of the default value */ + char *zType; /* Data type for this column */ + char *zColl; /* Collating sequence. If NULL, use the default */ + u8 notNull; /* True if there is a NOT NULL constraint */ + u8 isPrimKey; /* True if this column is part of the PRIMARY KEY */ + char affinity; /* One of the SQLITE_AFF_... values */ +#ifndef SQLITE_OMIT_VIRTUALTABLE + u8 isHidden; /* True if this column is 'hidden' */ +#endif +}; + +/* +** A "Collating Sequence" is defined by an instance of the following +** structure. Conceptually, a collating sequence consists of a name and +** a comparison routine that defines the order of that sequence. +** +** There may two separate implementations of the collation function, one +** that processes text in UTF-8 encoding (CollSeq.xCmp) and another that +** processes text encoded in UTF-16 (CollSeq.xCmp16), using the machine +** native byte order. When a collation sequence is invoked, SQLite selects +** the version that will require the least expensive encoding +** translations, if any. +** +** The CollSeq.pUser member variable is an extra parameter that passed in +** as the first argument to the UTF-8 comparison function, xCmp. +** CollSeq.pUser16 is the equivalent for the UTF-16 comparison function, +** xCmp16. +** +** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the +** collating sequence is undefined. Indices built on an undefined +** collating sequence may not be read or written. +*/ +struct CollSeq { + char *zName; /* Name of the collating sequence, UTF-8 encoded */ + u8 enc; /* Text encoding handled by xCmp() */ + u8 type; /* One of the SQLITE_COLL_... values below */ + void *pUser; /* First argument to xCmp() */ + int (*xCmp)(void*,int, const void*, int, const void*); + void (*xDel)(void*); /* Destructor for pUser */ +}; + +/* +** Allowed values of CollSeq.type: +*/ +#define SQLITE_COLL_BINARY 1 /* The default memcmp() collating sequence */ +#define SQLITE_COLL_NOCASE 2 /* The built-in NOCASE collating sequence */ +#define SQLITE_COLL_REVERSE 3 /* The built-in REVERSE collating sequence */ +#define SQLITE_COLL_USER 0 /* Any other user-defined collating sequence */ + +/* +** A sort order can be either ASC or DESC. +*/ +#define SQLITE_SO_ASC 0 /* Sort in ascending order */ +#define SQLITE_SO_DESC 1 /* Sort in ascending order */ + +/* +** Column affinity types. +** +** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and +** 't' for SQLITE_AFF_TEXT. But we can save a little space and improve +** the speed a little by numbering the values consecutively. +** +** But rather than start with 0 or 1, we begin with 'a'. That way, +** when multiple affinity types are concatenated into a string and +** used as the P4 operand, they will be more readable. +** +** Note also that the numeric types are grouped together so that testing +** for a numeric type is a single comparison. +*/ +#define SQLITE_AFF_TEXT 'a' +#define SQLITE_AFF_NONE 'b' +#define SQLITE_AFF_NUMERIC 'c' +#define SQLITE_AFF_INTEGER 'd' +#define SQLITE_AFF_REAL 'e' + +#define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) + +/* +** The SQLITE_AFF_MASK values masks off the significant bits of an +** affinity value. +*/ +#define SQLITE_AFF_MASK 0x67 + +/* +** Additional bit values that can be ORed with an affinity without +** changing the affinity. +*/ +#define SQLITE_JUMPIFNULL 0x08 /* jumps if either operand is NULL */ +#define SQLITE_STOREP2 0x10 /* Store result in reg[P2] rather than jump */ +#define SQLITE_NULLEQ 0x80 /* NULL=NULL */ + +/* +** An object of this type is created for each virtual table present in +** the database schema. +** +** If the database schema is shared, then there is one instance of this +** structure for each database connection (sqlite3*) that uses the shared +** schema. This is because each database connection requires its own unique +** instance of the sqlite3_vtab* handle used to access the virtual table +** implementation. sqlite3_vtab* handles can not be shared between +** database connections, even when the rest of the in-memory database +** schema is shared, as the implementation often stores the database +** connection handle passed to it via the xConnect() or xCreate() method +** during initialization internally. This database connection handle may +** then used by the virtual table implementation to access real tables +** within the database. So that they appear as part of the callers +** transaction, these accesses need to be made via the same database +** connection as that used to execute SQL operations on the virtual table. +** +** All VTable objects that correspond to a single table in a shared +** database schema are initially stored in a linked-list pointed to by +** the Table.pVTable member variable of the corresponding Table object. +** When an sqlite3_prepare() operation is required to access the virtual +** table, it searches the list for the VTable that corresponds to the +** database connection doing the preparing so as to use the correct +** sqlite3_vtab* handle in the compiled query. +** +** When an in-memory Table object is deleted (for example when the +** schema is being reloaded for some reason), the VTable objects are not +** deleted and the sqlite3_vtab* handles are not xDisconnect()ed +** immediately. Instead, they are moved from the Table.pVTable list to +** another linked list headed by the sqlite3.pDisconnect member of the +** corresponding sqlite3 structure. They are then deleted/xDisconnected +** next time a statement is prepared using said sqlite3*. This is done +** to avoid deadlock issues involving multiple sqlite3.mutex mutexes. +** Refer to comments above function sqlite3VtabUnlockList() for an +** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect +** list without holding the corresponding sqlite3.mutex mutex. +** +** The memory for objects of this type is always allocated by +** sqlite3DbMalloc(), using the connection handle stored in VTable.db as +** the first argument. +*/ +struct VTable { + sqlite3 *db; /* Database connection associated with this table */ + Module *pMod; /* Pointer to module implementation */ + sqlite3_vtab *pVtab; /* Pointer to vtab instance */ + int nRef; /* Number of pointers to this structure */ + VTable *pNext; /* Next in linked list (see above) */ +}; + +/* +** Each SQL table is represented in memory by an instance of the +** following structure. +** +** Table.zName is the name of the table. The case of the original +** CREATE TABLE statement is stored, but case is not significant for +** comparisons. +** +** Table.nCol is the number of columns in this table. Table.aCol is a +** pointer to an array of Column structures, one for each column. +** +** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of +** the column that is that key. Otherwise Table.iPKey is negative. Note +** that the datatype of the PRIMARY KEY must be INTEGER for this field to +** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of +** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid +** is generated for each row of the table. TF_HasPrimaryKey is set if +** the table has any PRIMARY KEY, INTEGER or otherwise. +** +** Table.tnum is the page number for the root BTree page of the table in the +** database file. If Table.iDb is the index of the database table backend +** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that +** holds temporary tables and indices. If TF_Ephemeral is set +** then the table is stored in a file that is automatically deleted +** when the VDBE cursor to the table is closed. In this case Table.tnum +** refers VDBE cursor number that holds the table open, not to the root +** page number. Transient tables are used to hold the results of a +** sub-query that appears instead of a real table name in the FROM clause +** of a SELECT statement. +*/ +struct Table { + sqlite3 *dbMem; /* DB connection used for lookaside allocations. */ + char *zName; /* Name of the table or view */ + int iPKey; /* If not negative, use aCol[iPKey] as the primary key */ + int nCol; /* Number of columns in this table */ + Column *aCol; /* Information about each column */ + Index *pIndex; /* List of SQL indexes on this table. */ + int tnum; /* Root BTree node for this table (see note above) */ + Select *pSelect; /* NULL for tables. Points to definition if a view. */ + u16 nRef; /* Number of pointers to this Table */ + u8 tabFlags; /* Mask of TF_* values */ + u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */ + FKey *pFKey; /* Linked list of all foreign keys in this table */ + char *zColAff; /* String defining the affinity of each column */ +#ifndef SQLITE_OMIT_CHECK + Expr *pCheck; /* The AND of all CHECK constraints */ +#endif +#ifndef SQLITE_OMIT_ALTERTABLE + int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */ +#endif +#ifndef SQLITE_OMIT_VIRTUALTABLE + VTable *pVTable; /* List of VTable objects. */ + int nModuleArg; /* Number of arguments to the module */ + char **azModuleArg; /* Text of all module args. [0] is module name */ +#endif + Trigger *pTrigger; /* List of triggers stored in pSchema */ + Schema *pSchema; /* Schema that contains this table */ + Table *pNextZombie; /* Next on the Parse.pZombieTab list */ +}; + +/* +** Allowed values for Tabe.tabFlags. +*/ +#define TF_Readonly 0x01 /* Read-only system table */ +#define TF_Ephemeral 0x02 /* An ephemeral table */ +#define TF_HasPrimaryKey 0x04 /* Table has a primary key */ +#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */ +#define TF_Virtual 0x10 /* Is a virtual table */ +#define TF_NeedMetadata 0x20 /* aCol[].zType and aCol[].pColl missing */ + + + +/* +** Test to see whether or not a table is a virtual table. This is +** done as a macro so that it will be optimized out when virtual +** table support is omitted from the build. +*/ +#ifndef SQLITE_OMIT_VIRTUALTABLE +# define IsVirtual(X) (((X)->tabFlags & TF_Virtual)!=0) +# define IsHiddenColumn(X) ((X)->isHidden) +#else +# define IsVirtual(X) 0 +# define IsHiddenColumn(X) 0 +#endif + +/* +** Each foreign key constraint is an instance of the following structure. +** +** A foreign key is associated with two tables. The "from" table is +** the table that contains the REFERENCES clause that creates the foreign +** key. The "to" table is the table that is named in the REFERENCES clause. +** Consider this example: +** +** CREATE TABLE ex1( +** a INTEGER PRIMARY KEY, +** b INTEGER CONSTRAINT fk1 REFERENCES ex2(x) +** ); +** +** For foreign key "fk1", the from-table is "ex1" and the to-table is "ex2". +** +** Each REFERENCES clause generates an instance of the following structure +** which is attached to the from-table. The to-table need not exist when +** the from-table is created. The existence of the to-table is not checked. +*/ +struct FKey { + Table *pFrom; /* Table containing the REFERENCES clause (aka: Child) */ + FKey *pNextFrom; /* Next foreign key in pFrom */ + char *zTo; /* Name of table that the key points to (aka: Parent) */ + FKey *pNextTo; /* Next foreign key on table named zTo */ + FKey *pPrevTo; /* Previous foreign key on table named zTo */ + int nCol; /* Number of columns in this key */ + /* EV: R-30323-21917 */ + u8 isDeferred; /* True if constraint checking is deferred till COMMIT */ + u8 aAction[2]; /* ON DELETE and ON UPDATE actions, respectively */ + Trigger *apTrigger[2]; /* Triggers for aAction[] actions */ + struct sColMap { /* Mapping of columns in pFrom to columns in zTo */ + int iFrom; /* Index of column in pFrom */ + char *zCol; /* Name of column in zTo. If 0 use PRIMARY KEY */ + } aCol[1]; /* One entry for each of nCol column s */ +}; + +/* +** SQLite supports many different ways to resolve a constraint +** error. ROLLBACK processing means that a constraint violation +** causes the operation in process to fail and for the current transaction +** to be rolled back. ABORT processing means the operation in process +** fails and any prior changes from that one operation are backed out, +** but the transaction is not rolled back. FAIL processing means that +** the operation in progress stops and returns an error code. But prior +** changes due to the same operation are not backed out and no rollback +** occurs. IGNORE means that the particular row that caused the constraint +** error is not inserted or updated. Processing continues and no error +** is returned. REPLACE means that preexisting database rows that caused +** a UNIQUE constraint violation are removed so that the new insert or +** update can proceed. Processing continues and no error is reported. +** +** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys. +** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the +** same as ROLLBACK for DEFERRED keys. SETNULL means that the foreign +** key is set to NULL. CASCADE means that a DELETE or UPDATE of the +** referenced table row is propagated into the row that holds the +** foreign key. +** +** The following symbolic values are used to record which type +** of action to take. +*/ +#define OE_None 0 /* There is no constraint to check */ +#define OE_Rollback 1 /* Fail the operation and rollback the transaction */ +#define OE_Abort 2 /* Back out changes but do no rollback transaction */ +#define OE_Fail 3 /* Stop the operation but leave all prior changes */ +#define OE_Ignore 4 /* Ignore the error. Do not do the INSERT or UPDATE */ +#define OE_Replace 5 /* Delete existing record, then do INSERT or UPDATE */ + +#define OE_Restrict 6 /* OE_Abort for IMMEDIATE, OE_Rollback for DEFERRED */ +#define OE_SetNull 7 /* Set the foreign key value to NULL */ +#define OE_SetDflt 8 /* Set the foreign key value to its default */ +#define OE_Cascade 9 /* Cascade the changes */ + +#define OE_Default 99 /* Do whatever the default action is */ + + +/* +** An instance of the following structure is passed as the first +** argument to sqlite3VdbeKeyCompare and is used to control the +** comparison of the two index keys. +*/ +struct KeyInfo { + sqlite3 *db; /* The database connection */ + u8 enc; /* Text encoding - one of the TEXT_Utf* values */ + u16 nField; /* Number of entries in aColl[] */ + u8 *aSortOrder; /* If defined an aSortOrder[i] is true, sort DESC */ + CollSeq *aColl[1]; /* Collating sequence for each term of the key */ +}; + +/* +** An instance of the following structure holds information about a +** single index record that has already been parsed out into individual +** values. +** +** A record is an object that contains one or more fields of data. +** Records are used to store the content of a table row and to store +** the key of an index. A blob encoding of a record is created by +** the OP_MakeRecord opcode of the VDBE and is disassembled by the +** OP_Column opcode. +** +** This structure holds a record that has already been disassembled +** into its constituent fields. +*/ +struct UnpackedRecord { + KeyInfo *pKeyInfo; /* Collation and sort-order information */ + u16 nField; /* Number of entries in apMem[] */ + u16 flags; /* Boolean settings. UNPACKED_... below */ + i64 rowid; /* Used by UNPACKED_PREFIX_SEARCH */ + Mem *aMem; /* Values */ +}; + +/* +** Allowed values of UnpackedRecord.flags +*/ +#define UNPACKED_NEED_FREE 0x0001 /* Memory is from sqlite3Malloc() */ +#define UNPACKED_NEED_DESTROY 0x0002 /* apMem[]s should all be destroyed */ +#define UNPACKED_IGNORE_ROWID 0x0004 /* Ignore trailing rowid on key1 */ +#define UNPACKED_INCRKEY 0x0008 /* Make this key an epsilon larger */ +#define UNPACKED_PREFIX_MATCH 0x0010 /* A prefix match is considered OK */ +#define UNPACKED_PREFIX_SEARCH 0x0020 /* A prefix match is considered OK */ + +/* +** Each SQL index is represented in memory by an +** instance of the following structure. +** +** The columns of the table that are to be indexed are described +** by the aiColumn[] field of this structure. For example, suppose +** we have the following table and index: +** +** CREATE TABLE Ex1(c1 int, c2 int, c3 text); +** CREATE INDEX Ex2 ON Ex1(c3,c1); +** +** In the Table structure describing Ex1, nCol==3 because there are +** three columns in the table. In the Index structure describing +** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed. +** The value of aiColumn is {2, 0}. aiColumn[0]==2 because the +** first column to be indexed (c3) has an index of 2 in Ex1.aCol[]. +** The second column to be indexed (c1) has an index of 0 in +** Ex1.aCol[], hence Ex2.aiColumn[1]==0. +** +** The Index.onError field determines whether or not the indexed columns +** must be unique and what to do if they are not. When Index.onError=OE_None, +** it means this is not a unique index. Otherwise it is a unique index +** and the value of Index.onError indicate the which conflict resolution +** algorithm to employ whenever an attempt is made to insert a non-unique +** element. +*/ +struct Index { + char *zName; /* Name of this index */ + int nColumn; /* Number of columns in the table used by this index */ + int *aiColumn; /* Which columns are used by this index. 1st is 0 */ + unsigned *aiRowEst; /* Result of ANALYZE: Est. rows selected by each column */ + Table *pTable; /* The SQL table being indexed */ + int tnum; /* Page containing root of this index in database file */ + u8 onError; /* OE_Abort, OE_Ignore, OE_Replace, or OE_None */ + u8 autoIndex; /* True if is automatically created (ex: by UNIQUE) */ + char *zColAff; /* String defining the affinity of each column */ + Index *pNext; /* The next index associated with the same table */ + Schema *pSchema; /* Schema containing this index */ + u8 *aSortOrder; /* Array of size Index.nColumn. True==DESC, False==ASC */ + char **azColl; /* Array of collation sequence names for index */ + IndexSample *aSample; /* Array of SQLITE_INDEX_SAMPLES samples */ +}; + +/* +** Each sample stored in the sqlite_stat2 table is represented in memory +** using a structure of this type. +*/ +struct IndexSample { + union { + char *z; /* Value if eType is SQLITE_TEXT or SQLITE_BLOB */ + double r; /* Value if eType is SQLITE_FLOAT or SQLITE_INTEGER */ + } u; + u8 eType; /* SQLITE_NULL, SQLITE_INTEGER ... etc. */ + u8 nByte; /* Size in byte of text or blob. */ +}; + +/* +** Each token coming out of the lexer is an instance of +** this structure. Tokens are also used as part of an expression. +** +** Note if Token.z==0 then Token.dyn and Token.n are undefined and +** may contain random values. Do not make any assumptions about Token.dyn +** and Token.n when Token.z==0. +*/ +struct Token { + const char *z; /* Text of the token. Not NULL-terminated! */ + unsigned int n; /* Number of characters in this token */ +}; + +/* +** An instance of this structure contains information needed to generate +** code for a SELECT that contains aggregate functions. +** +** If Expr.op==TK_AGG_COLUMN or TK_AGG_FUNCTION then Expr.pAggInfo is a +** pointer to this structure. The Expr.iColumn field is the index in +** AggInfo.aCol[] or AggInfo.aFunc[] of information needed to generate +** code for that node. +** +** AggInfo.pGroupBy and AggInfo.aFunc.pExpr point to fields within the +** original Select structure that describes the SELECT statement. These +** fields do not need to be freed when deallocating the AggInfo structure. +*/ +struct AggInfo { + u8 directMode; /* Direct rendering mode means take data directly + ** from source tables rather than from accumulators */ + u8 useSortingIdx; /* In direct mode, reference the sorting index rather + ** than the source table */ + int sortingIdx; /* Cursor number of the sorting index */ + ExprList *pGroupBy; /* The group by clause */ + int nSortingColumn; /* Number of columns in the sorting index */ + struct AggInfo_col { /* For each column used in source tables */ + Table *pTab; /* Source table */ + int iTable; /* Cursor number of the source table */ + int iColumn; /* Column number within the source table */ + int iSorterColumn; /* Column number in the sorting index */ + int iMem; /* Memory location that acts as accumulator */ + Expr *pExpr; /* The original expression */ + } *aCol; + int nColumn; /* Number of used entries in aCol[] */ + int nColumnAlloc; /* Number of slots allocated for aCol[] */ + int nAccumulator; /* Number of columns that show through to the output. + ** Additional columns are used only as parameters to + ** aggregate functions */ + struct AggInfo_func { /* For each aggregate function */ + Expr *pExpr; /* Expression encoding the function */ + FuncDef *pFunc; /* The aggregate function implementation */ + int iMem; /* Memory location that acts as accumulator */ + int iDistinct; /* Ephemeral table used to enforce DISTINCT */ + } *aFunc; + int nFunc; /* Number of entries in aFunc[] */ + int nFuncAlloc; /* Number of slots allocated for aFunc[] */ +}; + +/* +** The datatype ynVar is a signed integer, either 16-bit or 32-bit. +** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater +** than 32767 we have to make it 32-bit. 16-bit is preferred because +** it uses less memory in the Expr object, which is a big memory user +** in systems with lots of prepared statements. And few applications +** need more than about 10 or 20 variables. But some extreme users want +** to have prepared statements with over 32767 variables, and for them +** the option is available (at compile-time). +*/ +#if SQLITE_MAX_VARIABLE_NUMBER<=32767 +typedef i16 ynVar; +#else +typedef int ynVar; +#endif + +/* +** Each node of an expression in the parse tree is an instance +** of this structure. +** +** Expr.op is the opcode. The integer parser token codes are reused +** as opcodes here. For example, the parser defines TK_GE to be an integer +** code representing the ">=" operator. This same integer code is reused +** to represent the greater-than-or-equal-to operator in the expression +** tree. +** +** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, +** or TK_STRING), then Expr.token contains the text of the SQL literal. If +** the expression is a variable (TK_VARIABLE), then Expr.token contains the +** variable name. Finally, if the expression is an SQL function (TK_FUNCTION), +** then Expr.token contains the name of the function. +** +** Expr.pRight and Expr.pLeft are the left and right subexpressions of a +** binary operator. Either or both may be NULL. +** +** Expr.x.pList is a list of arguments if the expression is an SQL function, +** a CASE expression or an IN expression of the form " IN (, ...)". +** Expr.x.pSelect is used if the expression is a sub-select or an expression of +** the form " IN (SELECT ...)". If the EP_xIsSelect bit is set in the +** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is +** valid. +** +** An expression of the form ID or ID.ID refers to a column in a table. +** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is +** the integer cursor number of a VDBE cursor pointing to that table and +** Expr.iColumn is the column number for the specific column. If the +** expression is used as a result in an aggregate SELECT, then the +** value is also stored in the Expr.iAgg column in the aggregate so that +** it can be accessed after all aggregates are computed. +** +** If the expression is an unbound variable marker (a question mark +** character '?' in the original SQL) then the Expr.iTable holds the index +** number for that variable. +** +** If the expression is a subquery then Expr.iColumn holds an integer +** register number containing the result of the subquery. If the +** subquery gives a constant result, then iTable is -1. If the subquery +** gives a different answer at different times during statement processing +** then iTable is the address of a subroutine that computes the subquery. +** +** If the Expr is of type OP_Column, and the table it is selecting from +** is a disk table or the "old.*" pseudo-table, then pTab points to the +** corresponding table definition. +** +** ALLOCATION NOTES: +** +** Expr objects can use a lot of memory space in database schema. To +** help reduce memory requirements, sometimes an Expr object will be +** truncated. And to reduce the number of memory allocations, sometimes +** two or more Expr objects will be stored in a single memory allocation, +** together with Expr.zToken strings. +** +** If the EP_Reduced and EP_TokenOnly flags are set when +** an Expr object is truncated. When EP_Reduced is set, then all +** the child Expr objects in the Expr.pLeft and Expr.pRight subtrees +** are contained within the same memory allocation. Note, however, that +** the subtrees in Expr.x.pList or Expr.x.pSelect are always separately +** allocated, regardless of whether or not EP_Reduced is set. +*/ +struct Expr { + u8 op; /* Operation performed by this node */ + char affinity; /* The affinity of the column or 0 if not a column */ + u16 flags; /* Various flags. EP_* See below */ + union { + char *zToken; /* Token value. Zero terminated and dequoted */ + int iValue; /* Integer value if EP_IntValue */ + } u; + + /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no + ** space is allocated for the fields below this point. An attempt to + ** access them will result in a segfault or malfunction. + *********************************************************************/ + + Expr *pLeft; /* Left subnode */ + Expr *pRight; /* Right subnode */ + union { + ExprList *pList; /* Function arguments or in " IN ( IN (