From 8526b232e0c21e75e61bd57764fee1d4df6ba1ee Mon Sep 17 00:00:00 2001
From: Pierre Kestener <pierre.kestener@cea.fr>
Date: Wed, 16 Mar 2022 10:21:43 +0100
Subject: [PATCH] Update Makefile to install a package config file.
---
Makefile | 51 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 13 deletions(-)
Index: wannier90-3.1.0/Makefile
===================================================================
--- wannier90-3.1.0.orig/Makefile
+++ wannier90-3.1.0/Makefile
@@ -10,6 +10,13 @@ default: wannier post
PREFIX ?= /usr
+VERSION_MAJOR = 3
+VERSION_MINOR = 1
+VERSION_PATCH = 0
+
+VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)
+VERSION_SHORT = $(VERSION_MAJOR).$(VERSION_MINOR)
+
install: default
install -d $(DESTDIR)$(PREFIX)/bin/
for x in wannier90.x postw90.x w90chk2chk.x w90spn2spn.x ; do \
@@ -19,6 +26,7 @@ install: default
if [ -f "utility/w90vdw/w90vdw.x" ]; then install -m755 "utility/w90vdw/w90vdw.x" "$(DESTDIR)$(PREFIX)/bin/w90vdw.x"; fi;
install -d $(DESTDIR)$(PREFIX)/lib/
if [ -f "libwannier.a" ]; then install -m644 "libwannier.a" "$(DESTDIR)$(PREFIX)/lib/libwannier.a"; fi;
+ if [ -f "libwannier.a" ]; then $(MAKE) pkgconfig; fi;
all: wannier lib post w90chk2chk w90pov w90vdw w90spn2spn
@@ -50,12 +58,29 @@ w90vdw:
libs: lib
+PKGCONFIG_FILENAME = wannier.pc
+pkgconfig:
+ $(file > $(PKGCONFIG_FILENAME),prefix=$(DESTDIR)$(PREFIX))
+ $(file >> $(PKGCONFIG_FILENAME),exec_prefix=$(DESTDIR)$(PREFIX)/bin)
+ $(file >> $(PKGCONFIG_FILENAME),libdir=$(DESTDIR)$(PREFIX)/lib)
+ $(file >> $(PKGCONFIG_FILENAME),includedir=$(DESTDIR)$(PREFIX)/include)
+ $(file >> $(PKGCONFIG_FILENAME),)
+ $(file >> $(PKGCONFIG_FILENAME),Name: wannier)
+ $(file >> $(PKGCONFIG_FILENAME),Description: Compute maximally-localised Wannier functions.)
+ $(file >> $(PKGCONFIG_FILENAME),Requires: )
+ $(file >> $(PKGCONFIG_FILENAME),Version: $(VERSION))
+ $(file >> $(PKGCONFIG_FILENAME),Libs: -L$${libdir} -lwannier)
+ $(file >> $(PKGCONFIG_FILENAME),Cflags: -I$${includedir})
+ install -D -m644 "$(PKGCONFIG_FILENAME)" "$(DESTDIR)$(PREFIX)/lib/pkgconfig/$(PKGCONFIG_FILENAME)"
+ cd $(ROOTDIR) && rm -f $(PKGCONFIG_FILENAME)
+
post: objdirp
(cd $(ROOTDIR)/src/objp && $(MAKE) -f $(REALMAKEFILE) post)
clean:
cd $(ROOTDIR) && rm -f *~
cd $(ROOTDIR) && rm -f src/*~
+ cd $(ROOTDIR) && rm -f $(PKGCONFIG_FILENAME)
@( cd $(ROOTDIR) && if [ -d src/obj ] ; \
then cd src/obj && \
$(MAKE) -f $(REALMAKEFILE) clean && \
@@ -76,17 +101,17 @@ veryclean: clean
cd $(ROOTDIR) && rm -f wannier90.x postw90.x libwannier.a w90chk2chk.x w90spn2spn.x
cd $(ROOTDIR)/doc && rm -f user_guide.pdf tutorial.pdf
cd $(ROOTDIR)/doc/user_guide && rm -f user_guide.ps
- cd $(ROOTDIR)/doc/tutorial && rm -f tutorial.ps
+ cd $(ROOTDIR)/doc/tutorial && rm -f tutorial.ps
cd $(ROOTDIR)/test-suite && ./clean_tests -i
thedoc:
- $(MAKE) -C $(ROOTDIR)/doc/user_guide
- $(MAKE) -C $(ROOTDIR)/doc/tutorial
+ $(MAKE) -C $(ROOTDIR)/doc/user_guide
+ $(MAKE) -C $(ROOTDIR)/doc/tutorial
# For now hardcoded to 3.1.0, and using HEAD
# Better to get the version from the io.F90 file and use
# the tag (e.g. v3.1.0) instead of HEAD
-dist:
+dist:
cd $(ROOTDIR) && git archive HEAD --prefix=wannier90-3.1.0/ -o wannier90-3.1.0.tar.gz
dist-legacy:
@@ -182,10 +207,10 @@ dist-legacy:
./CHANGE.log \
)
-test-serial: w90chk2chk wannier post
+test-serial: w90chk2chk wannier post
(cd $(ROOTDIR)/test-suite && ./run_tests --category=default )
-test-parallel: w90chk2chk wannier post
+test-parallel: w90chk2chk wannier post
(cd $(ROOTDIR)/test-suite && ./run_tests --category=default --numprocs=4 )
# Alias
@@ -217,4 +242,4 @@ objdirp:
then mkdir src/objp ; \
fi ) ;
-.PHONY: wannier default all doc lib libs post clean veryclean thedoc dist test-serial test-parallel dist-lite objdir objdirp serialobjs tests w90spn2spn install
+.PHONY: wannier default all doc lib libs post clean veryclean thedoc dist test-serial test-parallel dist-lite objdir objdirp serialobjs tests w90spn2spn install pkgconfi