#!/usr/bin/make -f ############################################################################### ## ## 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 2 of the License, 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, write to the Free Software ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ## ############################################################################### ## Portions liberally borrowed from: ## http://women.alioth.debian.org/wiki/index.php/English/BuildingWithoutHelper ## Also borrowed heavily from the 'hello' package package = treecc docdir = debian/tmp/usr/share/doc/$(package) CC = gcc CFLAGS = -g -Wall INSTALL_PROGRAM = install ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif define checkdir @test -f debian/rules -a -f main.c || (echo Not in correct source directory; exit 1) endef define checkroot @test $$(id -u) = 0 || (echo need root priviledges; exit 1) endef # Top directory of the source code (thanks Manoj) SRCTOP := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi) # Destination directory where files will be installed DESTDIR = $(SRCTOP)/debian/$(package) # Definition of directories BIN_DIR = $(DESTDIR)/usr/bin SHARE_DIR = $(DESTDIR)/usr/share/treecc DOCS_DIR = $(DESTDIR)/usr/share/doc/treecc MAN_DIR = $(DESTDIR)/usr/share/man/man1 ## Stamp rules configure-stamp: $(checkdir) ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info touch configure-stamp build-stamp: configure-stamp $(checkdir) -rm -f build-stamp $(MAKE) touch build-stamp ## Debian rules build: build-stamp clean: $(checkroot) $(checkdir) -rm -f *-stamp -$(MAKE) -i distclean -rm -rf debian/$(package) -rm -f debian/files -rm -f debian/substvars binary-indep: build # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. # Definitions for install INST_OWN = -o root -g root MAKE_DIR = install -p -d $(INST_OWN) -m 755 INST_FILE = install -c $(INST_OWN) -m 644 INST_PROG = $(INSTALL_PROGRAM) -c $(INST_OWN) -m 755 INST_SCRIPT = install -c $(INST_OWN) -m 755 binary-arch: build $(checkdir) $(checkroot) # Install program $(MAKE) install DESTDIR=$(DESTDIR) # Run program test suite $(MAKE) check # Install program resources $(MAKE_DIR) $(SHARE_DIR) # Create directory for debian metadata # This doesn't show up in the final binary .deb as a directory # We will install various packaging data in here as it is built $(MAKE_DIR) $(DESTDIR)/DEBIAN # Install docs # The debianchangelog & copyright are always installed $(MAKE_DIR) $(DOCS_DIR) $(INST_FILE) debian/copyright $(DOCS_DIR)/copyright $(INST_FILE) debian/changelog $(DOCS_DIR)/changelog.Debian $(INST_FILE) ChangeLog $(DOCS_DIR)/changelog $(INST_FILE) README $(DOCS_DIR)/README $(INST_FILE) AUTHORS $(DOCS_DIR)/AUTHORS $(INST_FILE) NEWS $(DOCS_DIR)/NEWS # Install package scripts # The postinst runs after the package is installed, prerm before it is removed # Details of this are at http://women.alioth.debian.org/wiki/index.php/English/MaintainerScripts $(INST_SCRIPT) debian/postinst $(DESTDIR)/DEBIAN $(INST_SCRIPT) debian/prerm $(DESTDIR)/DEBIAN # Compress docs gzip -9 $(DOCS_DIR)/changelog.Debian $(DOCS_DIR)/changelog gzip -r9 $(DESTDIR)/usr/share/man gzip -r9 $(DESTDIR)/usr/share/info # Work out the shared library dependancies # This goes into debian/substvars # See man 1 dpkg-source for details dpkg-shlibdeps $(package) # Generate the control file # -isp : Includes Section & Priority for each binary package # -P : Use $(DESTDIR) instead of debian/tmp dpkg-gencontrol -isp -P$(DESTDIR) # Make DEBIAN/md5sums # The DEBIAN/md5sums file lists the md5sums of each file in the package, excluding files in DEBIAN/ # These files are used by the debsums package. cd $(DESTDIR) && find . -type f ! -regex '.*DEBIAN/.*' -printf '%P\0' | xargs -r0 md5sum > DEBIAN/md5sums # Create the .deb package # This is an ar archive, containing 2 tarballs & a file stating the debian packaging system version # ar t ~/debian/pbuilder/result/treecc_0.3.6-0ubuntu1_i386.deb # debian-binary # control.tar.gz # data.tar.gz dpkg-deb -b $(DESTDIR) ../ binary: binary-indep binary-arch .PHONY: binary binary-arch binary-indep clean build