Blame wannier90-install-pkgconfig.patch

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