/*
 * LALDetCharVCSInfo.c - LALDetChar VCS Information
 *
 * 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 with program; see the file COPYING. If not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 *
 * Copyright (C) 2009-2013 Adam Mercer
 * Copyright (C) 2014, 2016 Karl Wette
 */

#include <stdlib.h>
#include <config.h>

#include <lal/LALVCSInfoType.h>
#include <lal/XLALError.h>

#if defined(HAVE_LIBLAL)
#include <lal/LALVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALFRAME)
#include <lal/LALFrameVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALMETAIO)
#include <lal/LALMetaIOVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALXML)
#include <lal/LALXMLVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALSIMULATION)
#include <lal/LALSimulationVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALBURST)
#include <lal/LALBurstVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALDETCHAR)
#include <lal/LALDetCharVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALINSPIRAL)
#include <lal/LALInspiralVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALPULSAR)
#include <lal/LALPulsarVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALINFERENCE)
#include <lal/LALInferenceVCSInfoHeader.h>
#endif
#if defined(HAVE_LIBLALSTOCHASTIC)
#include <lal/LALStochasticVCSInfoHeader.h>
#endif

#include "LALDetCharVCSInfoHeader.h"

/* global variables for vcs information */
const char *const lalDetCharVCSVersion = LALDETCHAR_VERSION;
const char *const lalDetCharVCSId = LALDETCHAR_VCS_ID;
const char *const lalDetCharVCSDate = LALDETCHAR_VCS_DATE;
const char *const lalDetCharVCSBranch = LALDETCHAR_VCS_BRANCH;
const char *const lalDetCharVCSTag = LALDETCHAR_VCS_TAG;
const char *const lalDetCharVCSAuthor = LALDETCHAR_VCS_AUTHOR;
const char *const lalDetCharVCSCommitter = LALDETCHAR_VCS_COMMITTER;
const char *const lalDetCharVCSStatus = LALDETCHAR_VCS_STATUS;

/* global variables for vcs information - identable */
const char *const lalDetCharVCSIdentId = LALDETCHAR_VCS_IDENT_ID;
const char *const lalDetCharVCSIdentDate = LALDETCHAR_VCS_IDENT_DATE;
const char *const lalDetCharVCSIdentBranch = LALDETCHAR_VCS_IDENT_BRANCH;
const char *const lalDetCharVCSIdentTag = LALDETCHAR_VCS_IDENT_TAG;
const char *const lalDetCharVCSIdentAuthor = LALDETCHAR_VCS_IDENT_AUTHOR;
const char *const lalDetCharVCSIdentCommitter = LALDETCHAR_VCS_IDENT_COMMITTER;
const char *const lalDetCharVCSIdentStatus = LALDETCHAR_VCS_IDENT_STATUS;

/* library vcs information structure */
const struct tagLALVCSInfo lalDetCharVCSInfo = { \
  LALDETCHAR_NAME, \
  LALDETCHAR_VERSION, \
  LALDETCHAR_VCS_ID, \
  LALDETCHAR_VCS_DATE, \
  LALDETCHAR_VCS_BRANCH, \
  LALDETCHAR_VCS_TAG, \
  LALDETCHAR_VCS_AUTHOR, \
  LALDETCHAR_VCS_COMMITTER, \
  LALDETCHAR_VCS_STATUS \
};

const LALVCSInfo *const lalDetCharVCSInfoList[32] = {
#if defined(HAVE_LIBLAL)
  &lalVCSInfo,
#endif
#if defined(HAVE_LIBLALFRAME)
  &lalFrameVCSInfo,
#endif
#if defined(HAVE_LIBLALMETAIO)
  &lalMetaIOVCSInfo,
#endif
#if defined(HAVE_LIBLALXML)
  &lalXMLVCSInfo,
#endif
#if defined(HAVE_LIBLALSIMULATION)
  &lalSimulationVCSInfo,
#endif
#if defined(HAVE_LIBLALBURST)
  &lalBurstVCSInfo,
#endif
#if defined(HAVE_LIBLALDETCHAR)
  &lalDetCharVCSInfo,
#endif
#if defined(HAVE_LIBLALINSPIRAL)
  &lalInspiralVCSInfo,
#endif
#if defined(HAVE_LIBLALPULSAR)
  &lalPulsarVCSInfo,
#endif
#if defined(HAVE_LIBLALINFERENCE)
  &lalInferenceVCSInfo,
#endif
#if defined(HAVE_LIBLALSTOCHASTIC)
  &lalStochasticVCSInfo,
#endif
  &lalDetCharVCSInfo,
  NULL
};

int XLALDetCharVCSInfoCheck(void)
{
#define VCS_INFO_CHECK(vcsinfo) \
  do { \
    if (XLALVCSInfoCompare(&vcsinfo##Header, &vcsinfo) != 0) { \
      XLALPrintError("%s: FATAL: version mismatch between compile-time (%s) and run-time (%s) %s library\n", \
                     __func__, vcsinfo##Header.vcsId, vcsinfo.vcsId, vcsinfo.name); \
      XLALPrintError("This indicates a potential compilation problem: ensure your setup is consistent and recompile.\n"); \
      XLAL_ERROR(XLAL_EERR); \
    } \
  } while (0)

#if defined(HAVE_LIBLAL) && (LAL_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalVCSInfo);
#endif
#if defined(HAVE_LIBLALFRAME) && (LALFRAME_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalFrameVCSInfo);
#endif
#if defined(HAVE_LIBLALMETAIO) && (LALMETAIO_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalMetaIOVCSInfo);
#endif
#if defined(HAVE_LIBLALXML) && (LALXML_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalXMLVCSInfo);
#endif
#if defined(HAVE_LIBLALSIMULATION) && (LALSIMULATION_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalSimulationVCSInfo);
#endif
#if defined(HAVE_LIBLALBURST) && (LALBURST_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalBurstVCSInfo);
#endif
#if defined(HAVE_LIBLALDETCHAR) && (LALDETCHAR_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalDetCharVCSInfo);
#endif
#if defined(HAVE_LIBLALINSPIRAL) && (LALINSPIRAL_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalInspiralVCSInfo);
#endif
#if defined(HAVE_LIBLALPULSAR) && (LALPULSAR_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalPulsarVCSInfo);
#endif
#if defined(HAVE_LIBLALINFERENCE) && (LALINFERENCE_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalInferenceVCSInfo);
#endif
#if defined(HAVE_LIBLALSTOCHASTIC) && (LALSTOCHASTIC_VERSION_DEVEL != 0 || LALDetChar_VERSION_DEVEL != 0)
  VCS_INFO_CHECK(lalStochasticVCSInfo);
#endif
  VCS_INFO_CHECK(lalDetCharVCSInfo);

#undef VCS_INFO_CHECK

  return XLAL_SUCCESS;
}

/*
 * vim: tw=0 ts=2 et
 */
