Skip to content

Commit 59de222

Browse files
Adding autotools functionality
1 parent 509a031 commit 59de222

File tree

7 files changed

+1382
-6
lines changed

7 files changed

+1382
-6
lines changed

Makefile.am

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file is part of smithlab_cpp
2+
#
3+
# Copyright (C) 2010-2019: Andrew D. Smith and Meng Zhou
4+
#
5+
# Author: Andrew D. Smith and Meng Zhou
6+
#
7+
# This is free software: you can redistribute it and/or modify it
8+
# under the terms of the GNU General Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This software is distributed in the hope that it will be useful, but
13+
# WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
# General Public License for more details.
16+
17+
ACLOCAL_AMFLAGS = -I m4
18+
19+
lib_LTLIBRARIES = libsmithlab_cpp.la
20+
21+
libsmithlab_cpp_la_SOURCES = GenomicRegion.cpp MappedRead.cpp \
22+
OptionParser.cpp QualityScore.cpp RNG.cpp bisulfite_utils.cpp \
23+
chromosome_utils.cpp sim_utils.cpp smithlab_os.cpp smithlab_utils.cpp \
24+
zlib_wrapper.cpp
25+
26+
if HAS_HTSLIB
27+
libsmithlab_cpp_la_SOURCES += htslib_wrapper.cpp
28+
endif
29+
30+
include_HEADERS = GenomicRegion.hpp MappedRead.hpp OptionParser.hpp \
31+
QualityScore.hpp RNG.hpp bisulfite_utils.hpp chromosome_utils.hpp \
32+
sim_utils.hpp smithlab_os.hpp smithlab_utils.hpp zlib_wrapper.hpp \
33+
htslib_wrapper.hpp

configure.ac

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
dnl This file is part of smithlab_cpp
2+
dnl
3+
dnl Copyright (C) 2010-2019: Andrew D. Smith and Meng Zhou
4+
dnl
5+
dnl Author: Andrew D. Smith and Meng Zhou
6+
dnl
7+
dnl This is free software: you can redistribute it and/or modify it
8+
dnl under the terms of the GNU General Public License as published by
9+
dnl the Free Software Foundation, either version 3 of the License, or
10+
dnl (at your option) any later version.
11+
dnl
12+
dnl This software is distributed in the hope that it will be useful,
13+
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
dnl General Public License for more details.
16+
17+
AC_INIT([libsmithlab_cpp], [1.0], [[email protected]],
18+
[], [https://github.com/smithlabcode])
19+
AC_PREREQ([2.63]) dnl 4-argument AC_CHECK_HEADER
20+
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
21+
22+
AC_CONFIG_SRCDIR([smithlab_os.cpp])
23+
AC_CONFIG_MACRO_DIR([m4])
24+
25+
dnl check for c++11
26+
AC_LANG(C++)
27+
AC_PROG_CXX
28+
AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
29+
30+
AM_PROG_AR
31+
LT_INIT
32+
33+
dnl check for HTSLib
34+
AX_WITH_HTSLIB
35+
AS_IF([test "x$ax_cv_htslib" != "xyes"],
36+
[AC_MSG_WARN([HTSlib not found.
37+
38+
HTSLib is optional for using libsmithlab_cpp. Please use
39+
--with-htslib=DIR to specify htslib installation if you have it
40+
installed locally.
41+
])])
42+
AM_CONDITIONAL([HAS_HTSLIB], [test "x$ax_cv_htslib" = "xyes"])
43+
44+
dnl check for gsl
45+
AX_CHECK_ZLIB(, [AC_MSG_ERROR([zlib not found.
46+
47+
zlib is required for using libsmithlab_cpp. Please use --with-zlib=DIR
48+
to specify zlib installation if you have it installed locally.
49+
])])
50+
51+
dnl check for gsl
52+
AC_CHECK_HEADERS([gsl/gsl_blas.h], [],
53+
[AC_MSG_ERROR([failed to find gsl headers])])
54+
AC_CHECK_LIB([m],[main])
55+
AC_CHECK_LIB([gslcblas],[main])
56+
AC_CHECK_LIB([gsl],[main])
57+
58+
AC_CONFIG_FILES([Makefile])
59+
AC_OUTPUT

m4/ax_check_zlib.m4

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# ===========================================================================
2+
# https://www.gnu.org/software/autoconf-archive/ax_check_zlib.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_CHECK_ZLIB([action-if-found], [action-if-not-found])
8+
#
9+
# DESCRIPTION
10+
#
11+
# This macro searches for an installed zlib library. If nothing was
12+
# specified when calling configure, it searches first in /usr/local and
13+
# then in /usr, /opt/local and /sw. If the --with-zlib=DIR is specified,
14+
# it will try to find it in DIR/include/zlib.h and DIR/lib/libz.a. If
15+
# --without-zlib is specified, the library is not searched at all.
16+
#
17+
# If either the header file (zlib.h) or the library (libz) is not found,
18+
# shell commands 'action-if-not-found' is run. If 'action-if-not-found' is
19+
# not specified, the configuration exits on error, asking for a valid zlib
20+
# installation directory or --without-zlib.
21+
#
22+
# If both header file and library are found, shell commands
23+
# 'action-if-found' is run. If 'action-if-found' is not specified, the
24+
# default action appends '-I${ZLIB_HOME}/include' to CPFLAGS, appends
25+
# '-L$ZLIB_HOME}/lib' to LDFLAGS, prepends '-lz' to LIBS, and calls
26+
# AC_DEFINE(HAVE_LIBZ). You should use autoheader to include a definition
27+
# for this symbol in a config.h file. Sample usage in a C/C++ source is as
28+
# follows:
29+
#
30+
# #ifdef HAVE_LIBZ
31+
# #include <zlib.h>
32+
# #endif /* HAVE_LIBZ */
33+
#
34+
# LICENSE
35+
#
36+
# Copyright (c) 2008 Loic Dachary <[email protected]>
37+
# Copyright (c) 2010 Bastien Chevreux <[email protected]>
38+
#
39+
# This program is free software; you can redistribute it and/or modify it
40+
# under the terms of the GNU General Public License as published by the
41+
# Free Software Foundation; either version 2 of the License, or (at your
42+
# option) any later version.
43+
#
44+
# This program is distributed in the hope that it will be useful, but
45+
# WITHOUT ANY WARRANTY; without even the implied warranty of
46+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
47+
# Public License for more details.
48+
#
49+
# You should have received a copy of the GNU General Public License along
50+
# with this program. If not, see <https://www.gnu.org/licenses/>.
51+
#
52+
# As a special exception, the respective Autoconf Macro's copyright owner
53+
# gives unlimited permission to copy, distribute and modify the configure
54+
# scripts that are the output of Autoconf when processing the Macro. You
55+
# need not follow the terms of the GNU General Public License when using
56+
# or distributing such scripts, even though portions of the text of the
57+
# Macro appear in them. The GNU General Public License (GPL) does govern
58+
# all other use of the material that constitutes the Autoconf Macro.
59+
#
60+
# This special exception to the GPL applies to versions of the Autoconf
61+
# Macro released by the Autoconf Archive. When you make and distribute a
62+
# modified version of the Autoconf Macro, you may extend this special
63+
# exception to the GPL to apply to your modified version as well.
64+
65+
#serial 16
66+
67+
AU_ALIAS([CHECK_ZLIB], [AX_CHECK_ZLIB])
68+
AC_DEFUN([AX_CHECK_ZLIB],
69+
#
70+
# Handle user hints
71+
#
72+
[AC_MSG_CHECKING(if zlib is wanted)
73+
zlib_places="/usr/local /usr /opt/local /sw"
74+
AC_ARG_WITH([zlib],
75+
[ --with-zlib=DIR root directory path of zlib installation @<:@defaults to
76+
/usr/local or /usr if not found in /usr/local@:>@
77+
--without-zlib to disable zlib usage completely],
78+
[if test "$withval" != no ; then
79+
AC_MSG_RESULT(yes)
80+
if test -d "$withval"
81+
then
82+
zlib_places="$withval $zlib_places"
83+
else
84+
AC_MSG_WARN([Sorry, $withval does not exist, checking usual places])
85+
fi
86+
else
87+
zlib_places=
88+
AC_MSG_RESULT(no)
89+
fi],
90+
[AC_MSG_RESULT(yes)])
91+
92+
#
93+
# Locate zlib, if wanted
94+
#
95+
if test -n "${zlib_places}"
96+
then
97+
# check the user supplied or any other more or less 'standard' place:
98+
# Most UNIX systems : /usr/local and /usr
99+
# MacPorts / Fink on OSX : /opt/local respectively /sw
100+
for ZLIB_HOME in ${zlib_places} ; do
101+
if test -f "${ZLIB_HOME}/include/zlib.h"; then break; fi
102+
ZLIB_HOME=""
103+
done
104+
105+
ZLIB_OLD_LDFLAGS=$LDFLAGS
106+
ZLIB_OLD_CPPFLAGS=$CPPFLAGS
107+
if test -n "${ZLIB_HOME}"; then
108+
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
109+
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
110+
fi
111+
AC_LANG_PUSH([C])
112+
AC_CHECK_LIB([z], [inflateEnd], [zlib_cv_libz=yes], [zlib_cv_libz=no])
113+
AC_CHECK_HEADER([zlib.h], [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
114+
AC_LANG_POP([C])
115+
if test "$zlib_cv_libz" = "yes" && test "$zlib_cv_zlib_h" = "yes"
116+
then
117+
#
118+
# If both library and header were found, action-if-found
119+
#
120+
m4_ifblank([$1],[
121+
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
122+
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
123+
LIBS="-lz $LIBS"
124+
AC_DEFINE([HAVE_LIBZ], [1],
125+
[Define to 1 if you have `z' library (-lz)])
126+
],[
127+
# Restore variables
128+
LDFLAGS="$ZLIB_OLD_LDFLAGS"
129+
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
130+
$1
131+
])
132+
else
133+
#
134+
# If either header or library was not found, action-if-not-found
135+
#
136+
m4_default([$2],[
137+
AC_MSG_ERROR([either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib])
138+
])
139+
fi
140+
fi
141+
])

0 commit comments

Comments
 (0)