1## Makefile to simplify Octave Forge package maintenance tasks 2 3PACKAGE = $(shell $(SED) -n -e 's/^Name: *\(\w\+\)/\1/p' DESCRIPTION | $(TOLOWER)) 4VERSION = $(shell $(SED) -n -e 's/^Version: *\(\w\+\)/\1/p' DESCRIPTION | $(TOLOWER)) 5DEPENDS = $(shell $(SED) -n -e 's/^Depends[^,]*, \(.*\)/\1/p' DESCRIPTION | $(SED) 's/ *([^()]*),*/ /g') 6 7RELEASE_DIR = $(PACKAGE)-$(VERSION) 8RELEASE_TARBALL = $(PACKAGE)-$(VERSION).tar.gz 9HTML_DIR = $(PACKAGE)-html 10HTML_TARBALL = $(PACKAGE)-html.tar.gz 11 12MD5SUM ?= md5sum 13SED ?= sed 14TAR ?= tar 15GREP ?= grep 16 17HG := hg 18HG_CMD = $(HG) --config alias.$(1)=$(1) --config defaults.$(1)= $(1) 19HG_ID := $(shell $(call HG_CMD,identify) --id | sed -e 's/+//' ) 20HG_TIMESTAMP := $(firstword $(shell $(call HG_CMD,log) --rev $(HG_ID) --template '{date|hgdate}')) 21 22TAR_REPRODUCIBLE_OPTIONS := --sort=name --mtime="@$(HG_TIMESTAMP)" --owner=0 --group=0 --numeric-owner 23TAR_OPTIONS := --format=ustar $(TAR_REPRODUCIBLE_OPTIONS) 24 25# Follow jwe suggestion on not hinreting these vars from 26# the enviroment, so they can be set as command line arguemnts 27MKOCTFILE := mkoctfile 28OCTAVE := octave --no-gui 29 30TOLOWER = $(SED) -e 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/' 31 32AUTOCONF_TARGETS := src/configure src/Makefile 33 34CC_SOURCES := $(wildcard src/*.cc) 35PKG_ADD := $(shell $(GREP) -sPho '(?<=(//|\#\#) PKG_ADD: ).*' \ 36 $(CC_SOURCES)) 37 38.PHONY: help dist html release install all check run doc clean maintainer-clean 39 40help: 41 @echo "Targets:" 42 @echo " dist - Create $(RELEASE_TARBALL) for release" 43 @echo " html - Create $(HTML_TARBALL) for release" 44 @echo " release - Create both of the above and show md5sums" 45 @echo 46 @echo " install - Install the package in GNU Octave" 47 @echo " all - Build all oct files" 48 @echo " check - Execute package tests (w/o install)" 49 @echo " run - Run Octave with development in PATH (no install)" 50 @echo " doc - Build Texinfo package manual" 51 @echo 52 @echo " clean - Remove releases, html documentation, and oct files" 53 @echo " maintainer-clean - Additionally remove all generated files" 54 55$(RELEASE_DIR): .hg/dirstate 56 @echo "Creating package version $(VERSION) release ..." 57 -rm -rf $@ 58 $(HG) archive --exclude ".hg*" --exclude Makefile --type files $@ 59 cd "$@/src" && $(SHELL) ./bootstrap && $(RM) -r "autom4te.cache" 60 chmod -R a+rX,u+w,go-w $@ 61 62$(RELEASE_TARBALL): $(RELEASE_DIR) 63 $(TAR) -cf - $(TAR_OPTIONS) "$(notdir $<)" | gzip -9n > "$@" 64 -rm -rf $< 65 66$(HTML_DIR): install 67 @echo "Generating HTML documentation. This may take a while ..." 68 -rm -rf $@ 69 $(OCTAVE) --silent \ 70 --eval 'graphics_toolkit ("gnuplot");' \ 71 --eval 'pkg load generate_html $(PACKAGE);' \ 72 --eval 'generate_package_html ("$(PACKAGE)", "$@", "octave-forge");' 73 chmod -R a+rX,u+w,go-w $@ 74 75$(HTML_TARBALL): $(HTML_DIR) 76 $(TAR) -cf - $(TAR_OPTIONS) "$(notdir $<)" | gzip -9n > "$@" 77 -rm -rf $< 78 79dist: $(RELEASE_TARBALL) 80 81html: $(HTML_TARBALL) 82 83release: dist html 84 @$(MD5SUM) $(RELEASE_TARBALL) $(HTML_TARBALL) 85 @echo "Upload @ https://sourceforge.net/p/octave/package-releases/new/" 86 @echo "Execute: hg tag \"$(VERSION)\"" 87 88install: $(RELEASE_TARBALL) 89 @echo "Installing package locally ..." 90 $(OCTAVE) --silent --eval 'pkg install $(RELEASE_TARBALL);' 91 92all: autoconf_target 93 cd src && $(MAKE) $@ 94 95check: all 96 $(OCTAVE) --silent \ 97 --eval 'if(!isempty("$(DEPENDS)")); pkg load $(DEPENDS); endif;' \ 98 --eval '$(PKG_ADD); ' \ 99 --eval 'addpath (fullfile ([pwd filesep "inst"]));' \ 100 --eval 'addpath (fullfile ([pwd filesep "src"]));' \ 101 --eval 'runtests ("inst"); runtests ("src");' 102 103run: all 104 $(OCTAVE) --silent --persist \ 105 --eval 'if(!isempty("$(DEPENDS)")); pkg load $(DEPENDS); endif;' \ 106 --eval 'addpath (fullfile ([pwd filesep "inst"]));' \ 107 --eval 'addpath (fullfile ([pwd filesep "src"]));' \ 108 --eval '$(PKG_ADD)' 109 110doc: 111 112clean: 113 -rm -rf $(RELEASE_DIR) $(RELEASE_TARBALL) $(HTML_TARBALL) $(HTML_DIR) 114 cd src && $(MAKE) $@ 115 116distclean: clean 117 -$(RM) -r inst/test 118 119maintainer-clean: clean 120 121# 122# Recipes for testing purposes 123# 124src/configure: src/configure.ac 125 cd src && $(SHELL) ./bootstrap 126 127src/Makefile: src/Makefile.in src/configure 128 cd src && ./configure 129 130autoconf_target: $(AUTOCONF_TARGETS) 131 132 133