1## Generic Makefile to allow the octave-forge packages to be build and 2## installed using "configure; make all; make install". This Makefile 3## includes the capability to install to a temporary location, and install 4## an on_uninstall.m file that prevents the user removing this package 5## with Octave's package manager. This is useful for for the distribution's 6## various package managers and is forced by defining DESTDIR and DISTPKG. 7 8PKGDIR := $(shell pwd | sed -e 's|^.*/||') 9TMPDIR ?= /tmp 10PACKAGE ?= $(TMPDIR)/$(PKGDIR).tar.gz 11PKG := $(shell echo $(PKGDIR) | sed -e 's|^\(.*\)-.*|\1|') 12 13all: build package 14 15build: 16 @if [ -e src/Makefile ]; then \ 17 $(MAKE) -C src all; \ 18 fi 19 20package: build 21 @if [ -e src/Makefile ]; then \ 22 mv src/Makefile src/Makefile.disable; \ 23 fi; \ 24 if [ -e src/configure ]; then \ 25 mv src/configure src/configure.disable; \ 26 fi; \ 27 cd ..; tar -czf $(PACKAGE) $(PKGDIR); \ 28 29install: 30 @cd ../; \ 31 if [ "X${DISTPKG}X" != "XX" ]; then \ 32 stripcmd="unlink(pkg('local_list'));unlink(pkg('global_list'));"; \ 33 fi; \ 34 if [ "X$(DESTDIR)X" = "XX" ]; then \ 35 pkgdir=`octave -H -q --no-site-file --eval "warning('off','all');pkg('install','$(PACKAGE)');l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);$$stripcmd;"`; \ 36 else \ 37 shareprefix=$(DESTDIR)/`octave -H -q --no-site-file --eval "disp(fullfile(OCTAVE_HOME(),'share','octave'));"`; \ 38 libexecprefix=$(DESTDIR)/`octave -H -q --no-site-file --eval "disp(fullfile(octave_config_info('libexecdir'),'octave'));"`; \ 39 octprefix=$$shareprefix/packages; \ 40 archprefix=$$libexecprefix/packages; \ 41 if [ ! -e $$octprefix ]; then \ 42 mkdir -p $$octprefix; \ 43 fi; \ 44 if [ ! -e $$archprefix ]; then \ 45 mkdir -p $$archprefix; \ 46 fi; \ 47 octave -H -q --no-site-file --eval "warning('off','all');pkg('prefix','$$octprefix','$$archprefix');pkg('global_list',fullfile('$$shareprefix','octave_packages'));pkg('local_list',fullfile('$$shareprefix','octave_packages'));pkg('install','-nodeps','-verbose','$(PACKAGE)');"; \ 48 pkgdir=`octave -H -q --no-site-file --eval "warning('off','all');pkg('prefix','$$octprefix','$$archprefix');pkg('global_list',fullfile('$$shareprefix','octave_packages'));pkg('local_list',fullfile('$$shareprefix','octave_packages'));l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);$$stripcmd;"`; \ 49 fi; \ 50 if [ "X${DISTPKG}X" != "XX" ]; then \ 51 if [ -e $$pkgdir/packinfo/on_uninstall.m ]; then \ 52 mv $$pkgdir/packinfo/on_uninstall.m \ 53 $$pkgdir/packinfo/on_uninstall.m.orig; \ 54 fi; \ 55 echo "function on_uninstall (desc)" > $$pkgdir/packinfo/on_uninstall.m; \ 56 echo " error ('Can not uninstall %s installed by the $(DISTPKG) package manager', desc.name);" >> $$pkgdir/packinfo/on_uninstall.m; \ 57 echo "endfunction" >> $$pkgdir/packinfo/on_uninstall.m; \ 58 echo "#! /bin/sh -f" > $$pkgdir/packinfo/dist_admin; \ 59 echo "if [ \"\$$1\" == \"install\" ]; then" >> $$pkgdir/packinfo/dist_admin; \ 60 echo " octave -H -q --no-site-file --eval \"pkg('rebuild');\"" >> $$pkgdir/packinfo/dist_admin; \ 61 echo "else" >> $$pkgdir/packinfo/dist_admin; \ 62 echo " pkgdir=\`octave -H -q --no-site-file --eval \"pkg('rebuild');l=pkg('list');disp(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)}.dir);\"\`" >> $$pkgdir/packinfo/dist_admin; \ 63 echo " rm \$$pkgdir/packinfo/on_uninstall.m" >> $$pkgdir/packinfo/dist_admin; \ 64 echo " if [ -e \$$pkgdir/packinfo/on_uninstall.m.orig ]; then" >> $$pkgdir/packinfo/dist_admin; \ 65 echo " mv \$$pkgdir/packinfo/on_uninstall.m.orig \$$pkgdir/packinfo/on_uninstall.m" >> $$pkgdir/packinfo/dist_admin; \ 66 echo " cd \$$pkgdir/packinfo" >> $$pkgdir/packinfo/dist_admin; \ 67 echo " octave -q -H --no-site-file --eval \"l=pkg('list');on_uninstall(l{cellfun(@(x)strcmp(x.name,'$(PKG)'),l)});\"" >> $$pkgdir/packinfo/dist_admin; \ 68 echo " fi" >> $$pkgdir/packinfo/dist_admin; \ 69 echo "fi" >> $$pkgdir/packinfo/dist_admin; \ 70 chmod a+x $$pkgdir/packinfo/dist_admin; \ 71 fi; 72 73clean: 74 rm $(PACKAGE) 75 $(MAKE) -C src clean 76