From 43da466b006ac680f0f86ce98eeac9baa11e3838 Mon Sep 17 00:00:00 2001 From: "G.raud" Date: Mon, 1 Jul 2013 15:40:37 +0200 Subject: [PATCH] Makefile: install, install-doc & general update version.sh: new helper script to get the version number install: use $(prefix) and $(DESTDIR) install-doc: new target installing $(MANDOC), $(HTMLDOC) --- Makefile | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- version.sh | 44 +++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 17 deletions(-) create mode 100755 version.sh diff --git a/Makefile b/Makefile index d1f8c12..1029566 100644 --- a/Makefile +++ b/Makefile @@ -1,40 +1,101 @@ +# GNU Makefile for ng-jackspa +# Copyright © 2012,2013 Géraud Meyer +# +# This file is part of ng-jackspa. +# +# ng-jackspa is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License version 2 as published by the +# Free Software Foundation. +# +# This package is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with ng-jackspa. If not, see . + +prefix ?= $(HOME)/.local +bindir ?= $(prefix)/bin +datarootdir ?= $(prefix)/share +sysconfdir ?= $(prefix)/etc +docdir ?= $(datarootdir)/doc/$(PACKAGE_TARNAME) +mandir ?= $(datarootdir)/man +# DESTDIR = # distributors set this on the command line + PACKAGE_NAME ?= ng-jackspa +PACKAGE_TARNAME ?= ngjackspa +# Get the version via git or from the VERSION file or from the project +# directory name. +VERSION = $(shell test -x version.sh && ./version.sh $(PACKAGE_TARNAME) \ + || echo "unknown_version") +# Allow either to be overwritten by setting DIST_VERSION on the command line. +ifdef DIST_VERSION +VERSION = $(DIST_VERSION) +endif +PACKAGE_VERSION = $(VERSION) + +RM ?= rm +MKDIR ?= mkdir +INSTALL ?= install MAKE ?= make QMAKE = qmake ASCIIDOC ?= asciidoc -ASCIIDOC_FLAGS = -apackagename="$(PACKAGE_NAME)" +ASCIIDOC_FLAGS = -apackagename="$(PACKAGE_NAME)" -aversion="$(VERSION)" XMLTO ?= xmlto -CFLAGS = -Wall -Werror -g -CFLAGS += -DG_DISABLE_DEPRECATED `pkg-config --cflags glib-2.0` -CXXFLAGS = $(CFLAGS) -LDFLAGS = -lm -ljack -ldl `pkg-config --libs glib-2.0` -g -EXECUTABLES = njackspa gjackspa qjackspa jackspa-cli -INSTALL_PATH = /usr/local/bin +CFLAGS ?= -Wall -Werror -g +CXXFLAGS ?= $(CFLAGS) +override CFLAGS += -DG_DISABLE_DEPRECATED `pkg-config --cflags glib-2.0` +override CXXFLAGS += -DG_DISABLE_DEPRECATED `pkg-config --cflags glib-2.0` +override LDFLAGS += -lm -ljack -ldl `pkg-config --libs glib-2.0` -g +PROGS = njackspa gjackspa qjackspa jackspa-cli +SCRIPTS = MODULES = jackspa.o control.o -OBJECTS = $(MODULES) $(EXECUTABLES:%=%.o) +OBJECTS = $(MODULES) $(PROGS:%=%.o) COMMONS = interface.c +TESTS = QMAKE_PRO = qjackspa.pro QMAKE_MAKEFILE = Makefile.qmake MANDOC = ng-jackspa.1 HTMLDOC = README.html ng-jackspa.1.html -.PHONY : all doc clean distclean install force +all : build +.PHONY : all .help help build doc clean distclean install install-doc force +.help : + @echo "Available targets for $(PACKAGE_NAME) Makefile:" + @echo " .help all build clean doc distclean install install-doc" + @echo "Useful variables for $(PACKAGE_NAME) Makefile:" + @echo " CFLAGS CXXFLAGS CPPFLAGS LDFLAGS prefix DESTDIR MAKE" +help : .help -all : $(EXECUTABLES) +build : $(PROGS) $(TESTS) doc : $(MANDOC) $(HTMLDOC) clean : -$(MAKE) -f $(QMAKE_MAKEFILE) clean mocclean - -rm -f $(EXECUTABLES) $(OBJECTS) $(QMAKE_MAKEFILE) + -$(RM) $(PROGS) $(OBJECTS) $(QMAKE_MAKEFILE) distclean : clean - -rm -f $(MANDOC) $(HTMLDOC) + -$(RM) $(MANDOC) $(HTMLDOC) -install : all - mkdir -p $(INSTALL_PATH) - install -c $(EXECUTABLES) $(INSTALL_PATH) +install : build + $(MKDIR) -p $(DESTDIR)$(bindir) + set -e; for prog in $(PROGS) $(SCRIPTS); do \ + $(INSTALL) -p -m 0755 "$$prog" "$(DESTDIR)$(bindir)/"; \ + done +install-doc : doc + $(MKDIR) -p $(DESTDIR)$(mandir)/man1 + set -e; for doc in $(MANDOC); do \ + gzip -9 <"$$doc" >"$$doc".gz; \ + $(INSTALL) -p -m 0644 "$$doc".gz "$(DESTDIR)$(mandir)/man1/"; \ + $(RM) "$$doc".gz; \ + done + $(MKDIR) -p $(DESTDIR)$(docdir) + set -e; for doc in $(HTMLDOC); do \ + $(INSTALL) -p -m 0644 "$$doc" "$(DESTDIR)$(docdir)/"; \ + done njackspa : njackspa.c curses.c $(COMMONS) $(MODULES) $(CC) $(CFLAGS) -o $@ $< $(MODULES) $(LDFLAGS) -lncurses @@ -51,8 +112,6 @@ jackspa.o : ladspa.c $(QMAKE_MAKEFILE) : $(QMAKE_PRO) $(QMAKE) -o $@ -force : - README.html : README asciidoc.conf $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b xhtml11 -d article -a readme $< @@ -62,3 +121,5 @@ README.html : README asciidoc.conf $(ASCIIDOC) $(ASCIIDOC_FLAGS) -b docbook -d manpage $< % : %.xml $(XMLTO) man $< + +force : diff --git a/version.sh b/version.sh new file mode 100755 index 0000000..7192d29 --- /dev/null +++ b/version.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# version.sh - execute in the root of the project to get the version number +# +# Unlimited permission to copy, distribute and modify this file is granted. +# This file is offered as-is, without any warranty. + +test $# -gt 0 && PACKAGE_NAME=$1 +PACKAGE_NAME=${PACKAGE_NAME=ngjackspa} +DEF_VER="unknown_version" + +NL=' +' + +# First try git-describe, then see if there is a VERSION file (included in +# release tarballs), then see if the project directory matches the project +# name, then use the default. +if + test -d .git || test -f .git && + VN=$(git describe --abbrev=7 --match "version/*" --tags HEAD --always 2>/dev/null) && + case $VN in + *$NL*) + false ;; + version/*) + git update-index -q --refresh + test -z "$(git diff-index --name-only HEAD --)" || + VN="$VN.dirty" ;; + esac +then + VN=$(echo "$VN" | sed -e 's#^[vV][eE][rR][a-zA-Z]\{0,\}/##' -e 's/-/+/' -e 's/-/_/') + # +_g.dirty +elif + test -f VERSION && test -s VERSION +then + VN=$(cat VERSION) || VN=$DEF_VER +elif + VN=$(pwd | sed -e 's#^.\{0,\}/##') && + test x"$VN" != x"${VN#"$PACKAGE_NAME-"}" +then + VN=${VN#"$PACKAGE_NAME-"} +else + VN=$DEF_VER +fi + +echo "$VN" -- 2.11.4.GIT