Skip to content

Commit

Permalink
Test autotools pkg-config (*.pc files). (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
fghoussen authored Apr 23, 2022
1 parent 3ba4dbf commit 9331036
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 30 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,27 @@ jobs:
make all
make check
make distcheck
ubuntu_latest_autotools_install:
runs-on: ubuntu-latest
steps:
- name: Clone and check out repository code
uses: actions/checkout@v2
with:
fetch-depth: 0
ref: ${{github.event.pull_request.head.ref}} # Branch where changes are implemented.
repository: ${{github.event.pull_request.head.repo.full_name}} # Repo where changes are implemented.
- name: Check commit
run: |
git log -1
- name: Update OS
run: sudo apt-get update
- name: Install apt-get dependencies
run: sudo apt-get install -y gfortran gcc g++ openmpi-bin libopenmpi-dev libblas-dev liblapack-dev automake autoconf pkg-config libtool
- name: Run job
run: |
./bootstrap
./configure
bash ./tstAutotoolsInstall.sh
ubuntu_latest_cmake_python:
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ parpack.pc
arpackSolver.pc
arpackdef.h
arpackicb.h
arpack-ng-config.cmake
arpack-ng-config-version.cmake
tstAutotoolsInstall.sh

# Generated by `make`
.dirstamp
Expand Down
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ arpack-ng - 3.9.0
* Support for NAG's nagfor Fortran compiler

[ Franck Houssen ]
* Test autotools pkg-config (*.pc files).
* Test CMake find_package (*.cmake files).
* [BUG FIX] autotools: ICB must be checked first (MPI changes compilers).
* [BUG FIX] BLAS/LAPACK: allow suffixes in case BLAS/LAPACK can not provide ICB.
Expand Down
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ include(GNUInstallDirs)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix \${prefix})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng)
set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
set(PACKAGE_NAME ${PROJECT_NAME})
set(PACKAGE_VERSION ${arpack_ng_VERSION})
set(PACKAGE_URL "https://github.com/opencollab/arpack-ng/")
Expand All @@ -753,24 +753,24 @@ foreach(lib ${LAPACK_LIBRARIES} ${MPI_Fortran_LIBRARIES})
endforeach()
string(REPLACE ";" " " PARPACK_PC_LIBS_PRIVATE "${PARPACK_PC_LIBS_PRIVATE}")

configure_file(SRC/arpack.pc.in "${PROJECT_BINARY_DIR}/SRC/arpack${LIBSUFFIX}.pc" @ONLY)
configure_file(PARPACK/SRC/MPI/parpack.pc.in "${PROJECT_BINARY_DIR}/PARPACK/SRC/MPI/parpack${LIBSUFFIX}.pc" @ONLY)
configure_file(EXAMPLES/MATRIX_MARKET/arpackSolver.pc.in "${PROJECT_BINARY_DIR}/EXAMPLES/MATRIX_MARKET/arpackSolver.pc" @ONLY)
configure_file(pkg-config/arpack.pc.in "${PROJECT_BINARY_DIR}/arpack${LIBSUFFIX}.pc" @ONLY)
configure_file(pkg-config/parpack.pc.in "${PROJECT_BINARY_DIR}/parpack${LIBSUFFIX}.pc" @ONLY)
configure_file(pkg-config/arpackSolver.pc.in "${PROJECT_BINARY_DIR}/arpackSolver.pc" @ONLY)


install(TARGETS arpack
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${PROJECT_BINARY_DIR}/SRC/arpack${LIBSUFFIX}.pc"
install(FILES "${PROJECT_BINARY_DIR}/arpack${LIBSUFFIX}.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

if (MPI)
install(TARGETS parpack
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${PROJECT_BINARY_DIR}/PARPACK/SRC/MPI/parpack${LIBSUFFIX}.pc"
install(FILES "${PROJECT_BINARY_DIR}/parpack${LIBSUFFIX}.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif ()

Expand All @@ -783,7 +783,7 @@ if(ICB)
endif()
if (ICBEXMM)
install(FILES EXAMPLES/MATRIX_MARKET/arpackSolver.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/arpack-ng)
install(FILES "${PROJECT_BINARY_DIR}/EXAMPLES/MATRIX_MARKET/arpackSolver.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES "${PROJECT_BINARY_DIR}/arpackSolver.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
endif()

Expand Down
3 changes: 0 additions & 3 deletions EXAMPLES/MATRIX_MARKET/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
LDADD = $(top_builddir)/SRC/libarpack$(LIBSUFFIX).la
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)/ICB $(EIGEN3_CFLAGS)

pkgincludedir = $(includedir)/arpack

EXTRA_DIST = README

check_PROGRAMS = arpackmm
Expand All @@ -14,7 +12,6 @@ arpackmm_SOURCES = arpackmm.cpp

if ICBEXMM
pkginclude_HEADERS = arpackSolver.hpp
pkgconfig_DATA = arpackSolver.pc
endif

CLEANFILES = \
Expand Down
2 changes: 0 additions & 2 deletions ICB/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir)

pkgincludedir = $(includedir)/arpack

pkginclude_HEADERS = debug_c.h debug_c.hpp
pkginclude_HEADERS += stat_c.h stat_c.hpp
pkginclude_HEADERS += arpack.h arpack.hpp
Expand Down
8 changes: 7 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ACLOCAL_AMFLAGS = -I m4

pkgincludedir = $(includedir)/arpack
pkgincludedir = $(includedir)/arpack-ng
pkginclude_HEADERS = debug.h stat.h debugF90.h statF90.h arpackdef.h

AM_DISTCHECK_CONFIGURE_FLAGS =
Expand All @@ -9,6 +9,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS += --enable-mpi
endif
if ICB
AM_DISTCHECK_CONFIGURE_FLAGS += --enable-icb
pkginclude_HEADERS += arpackicb.h
endif
if ICBEXMM
AM_DISTCHECK_CONFIGURE_FLAGS += --enable-icb-exmm
Expand All @@ -25,3 +26,8 @@ endif

EXTRA_DIST = README.md PARPACK_CHANGES CHANGES DOCUMENTS VISUAL_STUDIO \
detect_arpack_bug.m4 CMakeLists.txt

pkgconfig_DATA = arpack@[email protected] parpack@[email protected] arpackSolver@[email protected]

# Due to the LIBSUFFIX, configure doesn't automatically clean this file:
DISTCLEANFILES = arpack@[email protected] parpack@[email protected] arpackSolver@[email protected]
5 changes: 0 additions & 5 deletions PARPACK/SRC/MPI/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@ if ICB
libparpack@LIBSUFFIX@_la_LIBADD += $(top_builddir)/ICB/libdbgicb.la $(top_builddir)/ICB/libstaicb.la
libparpack@LIBSUFFIX@_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)
endif

pkgconfig_DATA = parpack@[email protected]

# Due to the LIBSUFFIX, configure doesn't automatically clean this file:
DISTCLEANFILES = parpack@[email protected]
5 changes: 0 additions & 5 deletions SRC/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,3 @@ if ICB
libarpack@LIBSUFFIX@_la_LIBADD += $(top_builddir)/ICB/libdbgicb.la $(top_builddir)/ICB/libstaicb.la
libarpack@LIBSUFFIX@_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_builddir)
endif

pkgconfig_DATA = arpack@[email protected]

# Due to the LIBSUFFIX, configure doesn't automatically clean this file:
DISTCLEANFILES = arpack@[email protected]
11 changes: 8 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,19 @@ AM_CONDITIONAL([ICBEXMM], [test x"$enable_icb_exmm" != x"no"])
m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], [AC_SUBST([pkgconfigdir], [${libdir}/pkgconfig])])
AC_SUBST([ARPACK_PC_LIBS_PRIVATE], ["$LAPACK_LIBS $BLAS_LIBS"])
AC_SUBST([PARPACK_PC_LIBS_PRIVATE], ["$LAPACK_LIBS $BLAS_LIBS $MPI_Fortran_LIBS"])

AC_CONFIG_FILES([
SRC/arpack$LIBSUFFIX.pc:SRC/arpack.pc.in
PARPACK/SRC/MPI/parpack$LIBSUFFIX.pc:PARPACK/SRC/MPI/parpack.pc.in
arpack$LIBSUFFIX.pc:pkg-config/arpack.pc.in
parpack$LIBSUFFIX.pc:pkg-config/parpack.pc.in
arpackSolver$LIBSUFFIX.pc:pkg-config/arpackSolver.pc.in
], [], [LIBSUFFIX="$LIBSUFFIX"])

dnl We do NOT want arpackng*.cmake files to be created: @MPI@ can not be replaced.
AC_CONFIG_FILES([
EXAMPLES/MATRIX_MARKET/arpackSolver.pc
tstAutotoolsInstall.sh:pkg-config/tstAutotoolsInstall.sh.in
], [], [abs_top_builddir="$abs_top_builddir"])

AC_CONFIG_FILES([
arpackdef.h
arpackicb.h
Makefile
Expand Down
3 changes: 2 additions & 1 deletion SRC/arpack.pc.in → pkg-config/arpack.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
includedir=@includedir@/arpack-ng

Name: @PACKAGE_NAME@
Description: Collection of Fortran77 subroutines designed to solve large scale eigenvalue problems
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion PARPACK/SRC/MPI/parpack.pc.in → pkg-config/parpack.pc.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
includedir=@includedir@/arpack-ng

Name: @PACKAGE_NAME@
Description: Collection of Fortran77 subroutines designed to solve large scale eigenvalue problems
Expand Down
94 changes: 94 additions & 0 deletions pkg-config/tstAutotoolsInstall.sh.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash -eu
# Testing that PKG_CHECK_MODULES works.
# Note: this script must not be added to the test suite as it will change cmake options.

# 1. Define temporary directory.

export TMP_DIR="/tmp/tstAutotoolsInstall"
mkdir -p "${TMP_DIR}"

# 2. Rerun cmake with prefix, install arpack-ng.
# Note: this script must not be added to the test suite as it will change cmake options.

make clean
make distclean

export PROJECT_SOURCE_DIR="$(pwd)"
export TMP_PREFIX="${TMP_DIR}/local"
./configure --prefix="${TMP_PREFIX}" --enable-mpi
make all install

# 3. Setup environment for PKG_CHECK_MODULES to work (what you typically in module-environment files).

cd "${TMP_DIR}"
export PKG_CONFIG_PATH="${TMP_PREFIX}/lib/pkgconfig"

# 4. Create new cmake project, in temporary directory, with files from arpack-ng.

mkdir -p tstAutotoolsInstall
cd tstAutotoolsInstall

cp "${PROJECT_SOURCE_DIR}/EXAMPLES/BAND/dnband.f" .
cp "${PROJECT_SOURCE_DIR}/EXAMPLES/BAND/dnbdr1.f" .
cp "${PROJECT_SOURCE_DIR}/PARPACK/EXAMPLES/MPI/pdndrv1.f" .
cp -fr "${PROJECT_SOURCE_DIR}/m4" .

echo "AC_PREREQ([2.68]) " > configure.ac
echo "AC_INIT([tstAutotoolsInstall], 1.0) " >> configure.ac
echo "AM_INIT_AUTOMAKE([foreign]) " >> configure.ac
echo "AC_CONFIG_MACRO_DIR([m4]) " >> configure.ac
echo " " >> configure.ac
echo "AC_PROG_FC " >> configure.ac
echo "AC_PROG_MKDIR_P " >> configure.ac
echo "AC_PROG_MAKE_SET " >> configure.ac
echo "PKG_PROG_PKG_CONFIG " >> configure.ac
echo " " >> configure.ac
echo "AX_BLAS([], [AC_MSG_ERROR([cannot find BLAS libraries])]) " >> configure.ac
echo "AC_SUBST([BLAS_LIBS]) " >> configure.ac
echo " " >> configure.ac
echo "AX_LAPACK([], [AC_MSG_ERROR([cannot find LAPACK libraries])]) " >> configure.ac
echo "AC_SUBST([LAPACK_LIBS]) " >> configure.ac
echo " " >> configure.ac
echo "AC_LANG_PUSH([Fortran 77]) " >> configure.ac
echo "AX_MPI([], AC_MSG_ERROR([could not compile a Fortran MPI test program]))" >> configure.ac
echo "F77=\$MPIF77 " >> configure.ac
echo "AC_SUBST([MPI_Fortran_LIBS]) " >> configure.ac
echo " " >> configure.ac
echo "PKG_CHECK_MODULES([ARPACK], [arpack]) " >> configure.ac
echo "AC_SUBST([ARPACK_CFLAGS]) " >> configure.ac
echo "AC_SUBST([ARPACK_LIBS]) " >> configure.ac
echo " " >> configure.ac
echo "PKG_CHECK_MODULES([PARPACK], [parpack]) " >> configure.ac
echo "AC_SUBST([PARPACK_CFLAGS]) " >> configure.ac
echo "AC_SUBST([PARPACK_LIBS]) " >> configure.ac
echo " " >> configure.ac
echo "LT_INIT " >> configure.ac
echo " " >> configure.ac
echo "AC_CONFIG_FILES([Makefile]) " >> configure.ac
echo "AC_OUTPUT " >> configure.ac

echo "AUTOMAKE_OPTIONS = foreign " > Makefile.am
echo "ACLOCAL_AMFLAGS = -I m4 " >> Makefile.am
echo " " >> Makefile.am
echo "EXTRA_DIST = debug.h stat.h " >> Makefile.am
echo " " >> Makefile.am
echo "bin_PROGRAMS = dnbdr1 pdndrv1 " >> Makefile.am
echo " " >> Makefile.am
echo "dnbdr1_SOURCES = dnbdr1.f dnband.f " >> Makefile.am
echo "dnbdr1_FFLAGS = \$(ARPACK_CFLAGS) " >> Makefile.am
echo "dnbdr1_LDADD = \$(ARPACK_LIBS) \$(LAPACK_LIBS) \$(BLAS_LIBS) " >> Makefile.am
echo " " >> Makefile.am
echo "pdndrv1_SOURCES = pdndrv1.f dnband.f " >> Makefile.am
echo "pdndrv1_FFLAGS = \$(PARPACK_CFLAGS) \$(ARPACK_CFLAGS) " >> Makefile.am
echo "pdndrv1_LDADD = \$(PARPACK_LIBS) \$(ARPACK_LIBS) \$(LAPACK_LIBS) \$(BLAS_LIBS) \$(MPI_Fortran_LIBS)" >> Makefile.am

# 5. Build and test this new project with cmake: for this to be possible, PKG_CHECK_MODULES must work.

autoreconf --force --verbose --install

./configure
make all

./dnbdr1
mpirun -n 2 ./pdndrv1

0 comments on commit 9331036

Please sign in to comment.