1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2024-12-23 04:43:57 +01:00

pkgconfig

This commit is contained in:
Anthony Scemama 2021-05-05 12:17:15 +02:00
parent f7dea1fd1c
commit f272d27863
3 changed files with 39 additions and 13 deletions

View File

@ -75,6 +75,7 @@ $(distdir): FORCE
cp $(srcdir)/tests/test.f90 $(distdir)/tests cp $(srcdir)/tests/test.f90 $(distdir)/tests
cp $(srcdir)/tests/Makefile.in $(distdir)/tests cp $(srcdir)/tests/Makefile.in $(distdir)/tests
cp $(srcdir)/Makefile.in $(distdir) cp $(srcdir)/Makefile.in $(distdir)
cp $(srcdir)/trexio.pc.in $(distdir)
cp $(srcdir)/LICENSE $(distdir) cp $(srcdir)/LICENSE $(distdir)

View File

@ -17,6 +17,7 @@ fi
AC_CONFIG_SRCDIR([src/Makefile.in]) AC_CONFIG_SRCDIR([src/Makefile.in])
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([trexio.pc])
PKG_PROG_PKG_CONFIG() PKG_PROG_PKG_CONFIG()
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
@ -59,17 +60,21 @@ AC_MSG_ERROR([
fi fi
AC_ARG_WITH([hdf5], AC_ARG_WITH([hdf5],
AS_HELP_STRING([--with-hdf5], AS_HELP_STRING([--with-hdf5],
[Include HDF5 functionality @<:@default: yes@:>@])], [Include HDF5 functionality @<:@default: yes@:>@])],
[hdf5=${withval}], [hdf5=${withval}],
[hdf5=yes]) [hdf5=yes])
if test "x${hdf5}" = xno; then if test "x${hdf5}" = xno; then
AC_MSG_WARN([ AC_MSG_WARN([
------------------------------------------ ------------------------------------------
Configuring with the HDF5 library is Configuring with the HDF5 library is
recommended to build efficient TREXIO. recommended to build efficient TREXIO.
------------------------------------------]) ------------------------------------------])
PKG_HDF5=""
PKG_HDF5_LIBS=""
PKG_HDF5_CFLAGS=""
elif test "x${hdf5}" = xyes; then elif test "x${hdf5}" = xyes; then
# Check if HDF5 is already configured (e.g. after calling `module load hdf5-<version>`) # Check if HDF5 is already configured (e.g. after calling `module load hdf5-<version>`)
@ -85,17 +90,24 @@ elif test "x${hdf5}" = xyes; then
CFLAGS="${HDF5_CFLAGS} ${CFLAGS}" CFLAGS="${HDF5_CFLAGS} ${CFLAGS}"
FCFLAGS="${HDF5_CFLAGS} ${FCFLAGS}" FCFLAGS="${HDF5_CFLAGS} ${FCFLAGS}"
LIBS="${HDF5_LIBS} -lhdf5_hl ${LIBS}" LIBS="${HDF5_LIBS} -lhdf5_hl ${LIBS}"
PKG_HDF5="hdf5"
PKG_HDF5_LIBS=""
PKG_HDF5_CFLAGS=""
else
PKG_HDF5=""
PKG_HDF5_LIBS="${HDF5_LIBS} -lhdf5_hl"
PKG_HDF5_CFLAGS="${HDF5_CFLAGS}"
fi fi
else else
if test "x${hdf5}" = x; then if test "x${hdf5}" = x; then
AC_MSG_ERROR([ AC_MSG_ERROR([
------------------------------------------ ------------------------------------------
The path to HDF5 library is required. The path to HDF5 library is required.
Maybe you forgot to pass --with-hdf5="/your/path/" to configure script. Maybe you forgot to pass --with-hdf5="/your/path/" to configure script.
Stopping... Stopping...
------------------------------------------]) ------------------------------------------])
fi fi
CPPFLAGS="-I${hdf5}/include ${CPPFLAGS}" CPPFLAGS="-I${hdf5}/include ${CPPFLAGS}"
@ -107,7 +119,14 @@ else
AC_CHECK_HEADERS([hdf5.h]) AC_CHECK_HEADERS([hdf5.h])
AC_CHECK_LIB([hdf5], [H5open], [], [have_hdf5=no]) AC_CHECK_LIB([hdf5], [H5open], [], [have_hdf5=no])
PKG_HDF5=""
PKG_HDF5_LIBS="-L${hdf5} -lhdf5_hl"
PKG_HDF5_CFLAGS="-I${hdf5}/include"
fi fi
AC_SUBST([PKG_HDF5])
AC_SUBST([PKG_HDF5_LIBS])
AC_SUBST([PKG_HDF5_CFLAGS])
# add -fPIC if not present in CFLAGS, necessary to compile TREXIO # add -fPIC if not present in CFLAGS, necessary to compile TREXIO
# TODO: replace with AM_CFLAGS for appropriate targer once Automake is introduced # TODO: replace with AM_CFLAGS for appropriate targer once Automake is introduced
@ -116,7 +135,7 @@ case "${CFLAGS}" in
;; ;;
*) *)
AC_MSG_WARN([ AC_MSG_WARN([
------------------------------------------ ------------------------------------------
Adding -fPIC option to CFLAGS. Adding -fPIC option to CFLAGS.
This is necessary to build TREXIO. This is necessary to build TREXIO.
------------------------------------------]) ------------------------------------------])

View File

@ -12,6 +12,8 @@ includedir = @includedir@
docdir = @docdir@ docdir = @docdir@
htmldir = @htmldir@ htmldir = @htmldir@
libdir = @libdir@ libdir = @libdir@
pkgconfigdir= $(libdir)/pkgconfig
# Supplementary # Supplementary
exec_prefix = @exec_prefix@ exec_prefix = @exec_prefix@
libexecdir = @libexecdir@ libexecdir = @libexecdir@
@ -74,7 +76,7 @@ HEADER_FILES= $(trexio_h) trexio_text.h trexio_hdf5.h trexio_s.h
all: $(libtrexio) fortran all: $(libtrexio) fortran
$(libtrexio): $(OBJECT_FILES) $(HEADER_FILES) $(libtrexio): $(OBJECT_FILES) $(HEADER_FILES)
$(CC) -shared $(OBJECT_FILES) -o $(libtrexio) $(CC) -shared $(OBJECT_FILES) -o $(libtrexio)
@ -99,20 +101,24 @@ cppcheck.out: $(HEADER_FILES) $(SOURCE_FILES)
# $(DESTDIR) is needed for future support of package managers # $(DESTDIR) is needed for future support of package managers
# install should avoid build target due to possible conflict when prefix overriden # install should avoid build target due to possible conflict when prefix overriden
install: install:
$(INSTALL) -d $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) $(INSTALL) -d $(DESTDIR)$(libdir)
$(INSTALL) -d $(DESTDIR)$(includedir)
$(INSTALL) -d $(DESTDIR)$(pkgconfigdir)
cp $(libtrexio) $(DESTDIR)$(libdir) cp $(libtrexio) $(DESTDIR)$(libdir)
cp $(trexio_h) $(DESTDIR)$(includedir) cp $(trexio_h) $(DESTDIR)$(includedir)
cp $(trexio_f) $(DESTDIR)$(includedir) cp $(trexio_f) $(DESTDIR)$(includedir)
cp ../trexio.pc $(DESTDIR)$(pkgconfigdir)
uninstall: uninstall:
-$(RM) -- $(DESTDIR)$(libdir)/$(libtrexio_so) -$(RM) -- $(DESTDIR)$(libdir)/$(libtrexio_so)
-$(RM) -- $(DESTDIR)$(includedir)/$(trexio_h_file) -$(RM) -- $(DESTDIR)$(includedir)/$(trexio_h_file)
-$(RM) -- $(DESTDIR)$(includedir)/$(trexio_f_file) -$(RM) -- $(DESTDIR)$(includedir)/$(trexio_f_file)
-$(RM) -- $(DESTDIR)$(pkgconfigdir)/trexio.pc
clean: clean:
$(RM) -- *.o $(libtrexio) trexio.mod $(RM) -- *.o $(libtrexio) trexio.mod
maintainer-clean: maintainer-clean: