Skip to content
Browse files

Replace prefix at install time for 'make install prefix=/new/path' (#27)

  • Loading branch information...
1 parent 43fc5f5 commit 80571907bbc0b34a90a47132511bbf22c598a6f8 @benkirk benkirk committed
Showing with 36 additions and 4 deletions.
  1. +18 −2 Makefile.am
  2. +18 −2 Makefile.in
View
20 Makefile.am
@@ -82,9 +82,25 @@ EXTRA_DIST += contrib/bin/make_dependencies.pl
libmesh_configdir = $(exec_prefix)/bin
libmesh_config_SCRIPTS = contrib/bin/libmesh-config
-# when doing 'make install', symlik etc/libmesh/Make.common
-# when doing 'make install', update libmesh_config
+# This rule extends the built-in make install rule, and can
+# be used to:
+# when doing 'make install prefix=/other/path', update generated files
+# when doing 'make install', symlik etc/libmesh/Make.common
+# when doing 'make install', update libmesh_config
install-data-hook:
+ @if (test "x$(prefix)" != "x@prefix@") ; then \
+ oldprefix="@prefix@" ; \
+ newprefix="$(prefix)" ; \
+ for genfile in `find $(DESTDIR)$(prefix) -name "*.pc" -o -name Make.common -o -name libmesh-config -type f` ; do \
+ echo " " ; \
+ echo " *** replacing $$oldprefix" ; \
+ echo " *** with $$newprefix" ; \
+ echo " *** in generated file $$genfile" ; \
+ echo " " ; \
+ cd $(DESTDIR)$(prefix) && cat $$genfile | $(SED) "s,$$oldprefix,$$newprefix,g" > $$genfile.replaced ; \
+ cd $(DESTDIR)$(prefix) && mv $$genfile.replaced $$genfile ; \
+ done ; \
+ fi
cd $(DESTDIR)$(prefix) && rm -f Make.common && $(LN_S) etc/libmesh/Make.common Make.common
cat $(DESTDIR)$(libmesh_configdir)/libmesh-config | $(SED) "s/has_been_installed=no/has_been_installed=yes/g" > $(DESTDIR)$(libmesh_configdir)/libmesh-config.installed
mv $(DESTDIR)$(libmesh_configdir)/libmesh-config.installed $(DESTDIR)$(libmesh_configdir)/libmesh-config && chmod +x $(DESTDIR)$(libmesh_configdir)/libmesh-config
View
20 Makefile.in
@@ -26420,9 +26420,25 @@ uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
uninstall-nobase_dataDATA uninstall-pkgconfigDATA
-# when doing 'make install', symlik etc/libmesh/Make.common
-# when doing 'make install', update libmesh_config
+# This rule extends the built-in make install rule, and can
+# be used to:
+# when doing 'make install prefix=/other/path', update generated files
+# when doing 'make install', symlik etc/libmesh/Make.common
+# when doing 'make install', update libmesh_config
install-data-hook:
+ @if (test "x$(prefix)" != "x@prefix@") ; then \
+ oldprefix="@prefix@" ; \
+ newprefix="$(prefix)" ; \
+ for genfile in `find $(DESTDIR)$(prefix) -name "*.pc" -o -name Make.common -o -name libmesh-config -type f` ; do \
+ echo " " ; \
+ echo " *** replacing $$oldprefix" ; \
+ echo " *** with $$newprefix" ; \
+ echo " *** in generated file $$genfile" ; \
+ echo " " ; \
+ cd $(DESTDIR)$(prefix) && cat $$genfile | $(SED) "s,$$oldprefix,$$newprefix,g" > $$genfile.replaced ; \
+ cd $(DESTDIR)$(prefix) && mv $$genfile.replaced $$genfile ; \
+ done ; \
+ fi
cd $(DESTDIR)$(prefix) && rm -f Make.common && $(LN_S) etc/libmesh/Make.common Make.common
cat $(DESTDIR)$(libmesh_configdir)/libmesh-config | $(SED) "s/has_been_installed=no/has_been_installed=yes/g" > $(DESTDIR)$(libmesh_configdir)/libmesh-config.installed
mv $(DESTDIR)$(libmesh_configdir)/libmesh-config.installed $(DESTDIR)$(libmesh_configdir)/libmesh-config && chmod +x $(DESTDIR)$(libmesh_configdir)/libmesh-config

0 comments on commit 8057190

Please sign in to comment.
Something went wrong with that request. Please try again.