source: trunk/test/yat_pc_test.sh @ 3417

Last change on this file since 3417 was 3417, checked in by Peter, 4 years ago

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.0 KB
Line 
1#! /bin/sh
2# $Id: yat_pc_test.sh 3417 2015-05-25 01:35:59Z peter $
3#
4# Copyright (C) 2013, 2014, 2015 Peter Johansson
5#
6# This file is part of the yat library, http://dev.thep.lu.se/yat
7#
8# The yat library is free software; you can redistribute it
9# and/or modify it under the terms of the GNU General Public License as
10# published by the Free Software Foundation; either version 3 of the
11# License, or (at your option) any later version.
12#
13# The yat library is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with yat. If not, see <http://www.gnu.org/licenses/>.
20
21# testing that pkg-config works with yat.pc
22
23required="pkg-config htslib"
24
25set -e
26
27. test/init.sh || exit 99
28
29
30#
31populate_search_dirs ()
32{
33  search_dirs=`grep '^sys_lib_dlsearch_path_spec' \
34  $abs_top_builddir/libtool | cut -f 2 -d '='`
35  for d in : $YAT_LDFLAGS $LDFLAGS; do
36    echo $d | grep '^-L' -q \
37    && search_dirs="$search_dirs `echo $d | sed 's,-L,,'`"
38  done
39}
40
41
42# look for pc file $pkg and update PKG_CONFIG_PATH
43pc_find ()
44{
45  pkg=$1
46  test x"$search_dirs" = x"" && populate_search_dirs
47  pc_dir=
48  for d in $search_dirs; do
49    test x"$pc_dir" = x"" \
50    && test -e $d/pkgconfig/${pkg}.pc \
51    && pc_dir="$d/pkgconfig";
52  done
53  test x"$pc_dir" = x"" && exit_fail no $pkg pc file found
54  PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$pc_dir"
55  export PKG_CONFIG_PATH
56  pkg-config $pkg --exists --print-errors || exit_skip no $pkg pc file found
57}
58
59
60# add PATH so pkg-config find yat.pc in build tree first
61PKG_CONFIG_PATH=$abs_top_builddir/build_support:$PKG_CONFIG_PATH
62
63echo "check if we need to update PKG_CONFIG_PATH"
64
65# test if pkg-config finds gsl.pc
66pkg-config gsl --exists --print-errors || pc_find gsl
67# ensure path for libz
68pkg-config libz --exists --print-errors || pc_find zlib
69
70if test $HAVE_HTSLIB = yes; then
71  pkg-config htslib --exists --print-errors || pc_find htslib;
72fi
73
74export PKG_CONFIG_PATH
75
76pkg-config yat --exists --print-errors || exit_fail
77
78cat > Makefile <<EOF
79# add -I flags to include local header files; 2nd term needed for VPATH build
80CPPFLAGS = -I$abs_top_srcdir -I$abs_top_builddir/yat/utility \
81`pkg-config yat --cflags-only-I`
82CXXFLAGS = `pkg-config yat --cflags-only-other`
83# add -L to link to local libyat
84LDFLAGS = -L$abs_top_builddir/yat/${lt_cv_objdir} `pkg-config yat --libs --static`
85all: prog
86
87# Default make rule is problematic with static libs
88prog.o: prog.cc
89  \$(CXX) -c -o \$@ \$< \$(CPPFLAGS) \$(CXXFLAGS)
90prog: prog.o
91  \$(CXX) -o \$@ \$< \$(CXXFLAGS) \$(LDFLAGS)
92EOF
93
94cat Makefile
95
96cat > prog.cc <<EOF
97#include <yat/utility/Vector.h>
98#include <yat/random/random.h>
99#include <yat/omic/BamFile.h>
100int main()
101{
102theplu::yat::utility::Vector x(52);
103theplu::yat::random::Gaussian gauss;
104x(0) = gauss();
105theplu::yat::omic::OutBamFile out;
106return 0;
107}
108EOF
109
110rm -f prog
111make || exit_fail
112test -s prog || exit_fail
113exit_success
Note: See TracBrowser for help on using the repository browser.