source: trunk/test/yat_pc_test.sh

Last change on this file was 4019, checked in by Peter, 15 months ago

merge 0.18 into trunk

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1#! /bin/sh
2# $Id: yat_pc_test.sh 4019 2020-11-06 01:55:37Z peter $
3#
4# Copyright (C) 2013, 2014, 2015, 2017, 2020 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
59PATH="$abs_top_builddir/build_support:$PATH"
60export PATH
61
62# add PATH so pkg-config find yat.pc in build tree first
63PKG_CONFIG_PATH=$abs_top_builddir/build_support:$PKG_CONFIG_PATH
64
65echo "check if we need to update PKG_CONFIG_PATH"
66
67# test if pkg-config finds gsl.pc
68$PKG_CONFIG gsl --exists --print-errors || pc_find gsl
69# ensure path for zlib
70$PKG_CONFIG zlib --exists --print-errors || pc_find zlib
71
72if test $have_htslib = yes; then
73  $PKG_CONFIG htslib --exists --print-errors || pc_find htslib;
74fi
75
76export PKG_CONFIG_PATH
77
78$PKG_CONFIG yat --exists --print-errors || exit_fail
79
80cat > Makefile <<EOF
81CXX = `yat-config --cxx`
82# add -I flags to include local header files; 2nd term needed for VPATH build
83CPPFLAGS = -I$abs_top_srcdir -I$abs_top_builddir \
84-I$abs_top_builddir/yat/utility \
85`$PKG_CONFIG yat --cflags-only-I`
86CXXFLAGS = `$PKG_CONFIG yat --cflags-only-other`
87# add -L to link to local libyat
88LDFLAGS = -L$abs_top_builddir/yat/${lt_cv_objdir} `$PKG_CONFIG yat --libs-only-L --libs-only-other`
89LDLIBS = `$PKG_CONFIG yat --libs-only-l`
90
91all: prog
92
93# Make the rules explicit to allow also non-GNU make.
94prog.o: prog.cc
95  \$(CXX) -c -o \$@ \$< \$(CPPFLAGS) \$(CXXFLAGS)
96prog: prog.o
97  \$(CXX) -o \$@ \$< \$(CXXFLAGS) \$(LDFLAGS) \$(LDLIBS)
98EOF
99
100cat Makefile
101
102cat > prog.cc <<EOF
103#include <yat/utility/Vector.h>
104#include <yat/random/random.h>
105#include <yat/omic/BamFile.h>
106#include <yat/omic/VcfFile.h>
107int main()
108{
109theplu::yat::utility::Vector x(52);
110theplu::yat::random::Gaussian gauss;
111x(0) = gauss();
112theplu::yat::omic::OutBamFile out;
113theplu::yat::omic::VcfFile vcf;
114return 0;
115}
116EOF
117
118rm -f prog
119$MAKE || exit_fail
120test -s prog || exit_fail
121exit_success
Note: See TracBrowser for help on using the repository browser.