debian swirl logo

Back to the packages list backbone

#!/usr/bin/make -f
# -*- mode: makefile; coding: utf-8 -*-
# Copyright © 2010-2014 Jonas Smedegaard 
# Description: Main Debian packaging script for Backbone
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This program 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 this program.  If not, see .

include /usr/share/cdbs/1/rules/upstream-tarball.mk
include /usr/share/cdbs/1/rules/utils.mk
include /usr/share/cdbs/1/rules/debhelper.mk

pkg = $(DEB_SOURCE_PACKAGE)
jspkg = libjs-$(pkg)
js-stems = $(pkg)
nodepkg = node-$(pkg)

DEB_UPSTREAM_URL = https://github.com/documentcloud/$(pkg)/archive
DEB_UPSTREAM_TARBALL_BASENAME = $(DEB_UPSTREAM_TARBALL_VERSION)
DEB_UPSTREAM_TARBALL_MD5 = d24ee0a1d401705c8bb098b5ebf01725

# Ease backporting (node-uglify is tough to backport)
# TODO: drop fallback-dependency when uglifyjs is in Debian stable
CDBS_BUILD_DEPENDS += , node-uglify | yui-compressor
js-compressor := $(or $(notdir $(shell which uglifyjs)),yui-compressor)

CDBS_BUILD_DEPENDS += , coffeescript, phantomjs, libjs-json, libjs-jquery
CDBS_BUILD_DEPENDS += , libjs-underscore
CDBS_BUILD_DEPENDS += , node-underscore
CDBS_DEPENDS_$(jspkg) = libjs-underscore
CDBS_DEPENDS_$(nodepkg) = nodejs, libjs-backbone
CDBS_DEPENDS_$(nodepkg) += , node-underscore
CDBS_RECOMMENDS_ALL = libjs-json
CDBS_RECOMMENDS_ALL += , libjs-jquery | libjs-zepto | libjs-ender
CDBS_RECOMMENDS_$(jspkg) = javascript-common

# Handle package split
CDBS_BREAKS_$(nodepkg) = libjs-backbone (<< 0.5.3-3)
CDBS_REPLACES_$(nodepkg) = libjs-backbone (<< 0.5.3-3)

# Silence images in addition to the default debian files
DEB_COPYRIGHT_CHECK_IGNORE_REGEX = ^docs/images/.*\.(jpg|png)|debian/(changelog|copyright(|_hints|_newhints))$

DEB_INSTALL_DOCS_ALL += README.md

build/$(jspkg):: debian/stamp-build
debian/stamp-build:
		$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),,coffee test/*.coffee)
		$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),,phantomjs test/vendor/runner.js test/index.html?noglobals=true)
		touch $@
clean::
		rm -f debian/stamp-build

DEB_INSTALL_DOCS_ALL += index.html
DEB_INSTALL_EXAMPLES_$(jspkg) += examples/*

# TODO: generalize parts below as a CDBS javascript snippet

#js-basedir =
js-dirname ?= $(pkg)
js-stems ?= $(basename $(wildcard $(js-basedir)*.js))
js-min ?= $(js-stems:$(js-basedir)%=debian/%.min.js)
js-destdir ?= /usr/share/javascript/$(js-dirname)
js-compressor ?= uglifyjs
js-compressor-opts ?= -o $@ $<

DEB_DH_INSTALL_ARGS_$(jspkg) = $(addsuffix .js,$(js-stems)) debian/*.min.js $(js-destdir)

build/$(jspkg):: $(js-min)
$(js-min): debian/%.min.js: $(js-basedir)%.js
		$(js-compressor) $(js-compressor-opts)
clean::
		rm -f debian/*.js

# TODO: maybe generalize parts below as a CDBS node snippet

node-dirname ?= $(pkg)
js-nodestem ?= $(pkg)
node-destdir ?= /usr/lib/nodejs/

DEB_DH_LINK_$(nodepkg) = $(js-destdir)/$(js-nodestem).js $(node-destdir)$(node-dirname).js

Builds:

libjs-backbone
some backbone for javascript applications - browser library
node-backbone
some backbone for javascript applications - node module