#! /usr/bin/make -f # ## Makefile for generating standard software packages (deb, rpm, etc) # ## This makefile offers generic support for building standard binary # software packages like Debian or Redhat currently using EPM to do the # packaging. EPM is Free Software covered by the GPL and can be obtained # from http://www.easysw.com/epm/ (on Debian it is actually included in the # distribution). # # a makefile including buildpkg.mk must define at least the following macros: # o MODULE: basename of the module to be build; this name is used to # initialize the macros PKGNAME and LIBNAME, if they are # undefined. # o INSTALL: path to the install program. This macro must also be used to # install any files and directories in the superior makefile! # o PKGBINS: List of binaries to install (may be empty for library pkgs) # o PKGSRCS: list of source files (needed to calculate dependencies) # o PKGHDRS: list of header files to be installed (may be empty) # o PKGVERSION: the version number the package should get # o PACKAGER: the name of whoever is building the package, e.g $(USER) # o VENDOR: who's distributing the package # o README: path to the README file to be included in the package # o COPYNOTE: the name of the file containing the copyright notice to be # included. # o LICENSE: the license style, e.g. GPL # # the superior makefile must also provide an "install" target which generates # and installs all files to be packaged. The "install" target is invoked from # within buildpkg.mk with the macro RELEASE defined. This can be used to make # sure all compilation flags are set to values suitable for releases. # # It may define the following optional macros: # o PKGFORM: the package form to be built, e.g. deb for Debian # please refer to `man epm' for details # o PKGNAME: Name for the package, if other than MODULE # o PKGRELEASE: a Release number, defaults to zero if undefined. # # Furthermore it should define: # o PKGMKFILES: to include its own name and the names of all makefiles # which influence the compilation of the software to be packaged. # # A superior makefile may request a specific version buildpkg.mk by defining # BUILDPKG_VERSION to contain an appropriate value e.g. BUILDPKG_VERSION = 2.1 # ## GPL 2004 Manfred Waßmann http://www.berlinos.de/ ## # # Copyright (C) 2004 Manfred Waßmann http://www.berlinos.de/ # # buildpkg.mk,v 2.10 2005-10-07 08:43:48 manolo Exp # override PKGMKFILES += buildpkg.mk PKGFORM ?= deb PKGNAME ?= $(MODULE) ifeq ($(shell id -u),0) PKGBUILDER := epm else PKGBUILDER := fakeroot epm endif PKGBUILDDIR := epmbuild PKGBUILDARGS = -v -n -f $(PKGFORM) -k $(PKGNAME) PKGLISTFILE = $(MODULE).epm PKGINSTALL = ./epmhelper LIBNAME ?= $(MODULE) DOWNLOADPROG:= wget DOWNLOADARGS:= -nd -N DOWNLOADCMD = $(DOWNLOADPROG) $(DOWNLOADARGS) # clean-pkg may be used as a dependency for distclean in the superior makefile clean-pkg := cleanpkg override R:= override __REV__ := $(strip 2.10R) checkversion = @test -z "$(strip $(1))" || ( echo Requested version: $(1) ; \ test "$(__REV__)" = "evision: $(1)" -o "$(__REV__)" = "$(1)R" ) checkmacro = @printf "%s %s: " $(0) $(1) ; \ if [ "$(strip $($(1)))" ];then \ echo "$($(1))" ;else echo " * NOT SET * ";false;fi condinstall = @test -z "$(strip $(2))" || \ { echo "Packaging $(3): $(2)"; $(INSTALL) $(2) $(1) ; } ###################### ### Target section ### ###################### #################### ### Main Targets ### #################### buildpkg: pkgcheck pkgprepare @+printf "[%s%s]\n" $@ " {$?}" cleanpkg: @+printf "[%s%s]\n" $@ $(RM) *.epm.O $(RM) -r *.epm $(PKGBUILDDIR) deb: buildpkg @+printf "[%s%s]\n" $@ " {$?}" rpm: @+printf "[%s%s]\n" $@ $(MAKE) buildpkg PKGFORM=rpm ######################## ### Internal Targets ### ######################## pkgcheck: $(PKGINSTALL) @+printf "[%s%s]\n" $@ $(call checkversion,$(strip $(BUILDPKG_VERSION))) $(call checkmacro,MODULE) $(call checkmacro,LIBNAME) $(call checkmacro,INSTALL) pkgprepare: $(PKGBUILDDIR) $(PKGLISTFILE) $(COPYNOTE) $(PKGHDRS) pkginstlibs @+printf "[%s%s]\n" $@ " {$?}" $(call condinstall,$<,$(COPYNOTE),"copyright notice") $(call condinstall,$<,$(PKGHDRS),"headers") $(call condinstall,$<,$(PKGBINS),"programs") $(call condinstall,$<, \ $(wildcard lib*$(LIBNAME).a lib*$(LIBNAME).so.*),"libraries") # $(INSTALL) $(PKGLISTFILE) $(PKGBUILDDIR) if [ "$(PKGCONFFILES)" ];then sed \ $(foreach FILE,$(PKGCONFFILES),-e '/$(FILE)/s/^f/c/') \ $(PKGLISTFILE) >$(PKGBUILDDIR)/$(PKGLISTFILE) ;\ else \ cp -f $(PKGLISTFILE) $(PKGBUILDDIR)/$(PKGLISTFILE); \ fi cd $< && $(PKGBUILDER) $(PKGBUILDARGS) $(PKGLISTFILE) $(PKGBUILDDIR): @+printf "[%s%s]\n" $@ $(INSTALL) -d $@ chmod 0775 $@ %.epm: $(PKGSRCS) $(PKGHDRS) $(PKGMKFILES) @+printf "[%s%s]\n" $@ " {$?}" printf "%s %s\n" \ "%product" "$(MODULE)" \ "%copyright" "$(LICENSE)" \ "%license" "$(COPYNOTE)" \ "%packager" "$(PACKAGER)" \ "%vendor" "$(VENDOR)" \ "%readme" "$(README)" \ "%version" "$(PKGVERSION)" \ >$@ -test $(PKGRELEASE) && printf "%s %s\n" "%release" "$(PKGRELEASE)" >>$@ $(MAKE) install RELEASE=1 \ INSTALL="$(PKGINSTALL) -d $(PKGBUILDDIR) -f $@ -i $(INSTALL)" $(RM) -v $@.O epmhelper: @+printf "[%s%s]\n" $@ $(DOWNLOADCMD) http://www.berlinos.de/Snippets/$@ chmod a+x $@ ############################## ### Administrative Targets ### ############################## .PHONY: buildpkg cleanpkg deb rpm pkgcheck pkgprepare pkginstlibs # buildpkg.mk,v # Revision 2.10 2005-10-07 08:43:48 manolo # Fix empty PKGCONFFILES macro. # # Revision 2.9 2005/06/29 06:37:08 manolo # Support config files via PKGCONFFILES macro. # # Revision 2.8 2005/02/11 16:30:44 manolo # Package name may be overriden by specifying new macro PKGNAME; # fakeroot is only used, if not invoked from root account. # # Revision 2.7 2005/02/08 00:36:59 manolo # epmhelper fixes. # # Revision 2.6 2005/02/07 23:40:15 manolo # New: epmhelper, integrates writing list file and copying files into builddir. # # Revision 2.5 2004/12/20 22:12:39 manolo # More robust empty tests. # # Revision 2.4 2004/12/11 12:00:33 manolo # Fixed checkversion for CVS exported script; # beautified output from checkmacro and condinstall. # # Revision 2.3 2004/12/08 16:31:09 manolo # Added macro PKGBINS. # # Revision 2.2 2004/12/08 16:17:18 manolo # Fixed pkgdir creation. # # Revision 2.1 2004/10/16 17:09:33 manolo # Added support for superior makefiles to require a specific version. # # Revision 2.0 2004/10/16 10:56:12 manolo # Major cleanup. Incompatible changes: # o sources -> PKGSRCS # o headers -> PKGHDRS # o makefiles -> PKGMKFILES # o pkgclean -> clean-pkg #