#!/usr/bin/make -f # # Build (debuggable) Evo from SVN # Run "make help" for some help, or see the comments below. # # Requires GNU make 3.80 or better. # # Author: Paul Smith # Version: 2.12 # Date: 29 May 2008 # # -------------------------------------------------- # Copyright (C) 2007, 2008 Paul Smith # This Makefile 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 of the License, or (at your option) # any later version. # # You should have a copy of the GNU General Public License on your system. # If not, see . # -------------------------------------------------- # # You can look here for more/alternate information: # http://www.go-evolution.org/Compiling_Evolution_from_SVN # # Enhancements/suggestions provided by: # Patrick Ohly # ====================================================================== # By default we build for Ubuntu (I'm testing on Ubuntu 8.04). # # If you want to build for another distro, see if it's listed in the DISTROS # variable (currently only Debian & Ubuntu releases are listed) and, if so, # change "DISTRO" to your distro. You can do this in local.mk to avoid # changing this makefile. # # If your distro is not supported, you can set "distro" to empty and the check # for prerequisite packages will be skipped. Of course, if you don't have all # the proper development packages installed the build will fail. # ====================================================================== # vvvvvvvvvvvvvvvvvvvvvvvvv User Customization vvvvvvvvvvvvvvvvvvvvvvvvv # Feel free to change these if you like # What branch to work with. If not set, we use the trunk. Close to a # release, however, you might prefer to use the pending release. # E.g.: # BRANCH := 2.20 BRANCH := # Where to install Evo. DO NOT use /usr here for any system controlled by a # package manager (rpm, dpkg) PREFIX := /opt/evo # Where to build objects. Currently not all packages work properly outside of # their own directories, even though the GNU coding standards require it. OBJDIR := obj #OBJDIR := . # What distro you use, for checking that all prerequisite packages for a # successful build are installed. The currently supported distros are # listed in the DISTROS variable below. # If yours is not one of these, set this to empty and take your chances! distro := # Comment this out if you don't want to use ccache CCACHE := ccache # Set this to empty if you want to see the rules being run V := @ # Enable/disable optional packages ENABLE_gtkhtml := y ENABLE_exchange := y ENABLE_webcal := y # You can override the above by creating local.mk setting these vars # if you don't want to modify this makefile. -include local.mk # ^^^^^^^^^^^^^^^^^^^^^^^^^ User Customization ^^^^^^^^^^^^^^^^^^^^^^^^^ # ====================================================================== # ----- << You don't need to touch anything below here!! >> ----- # ----- << (unless you really know what you're doing...) >> ----- # These are the prerequisite packages needed on the system before we can build # Evo. There are different ways to check for them, based on distro. DISTROS := feisty gutsy hardy etch feisty-PREREQS := \ gtk-doc-tools subversion flex bison build-essential \ libldap2-dev libnss-dev libnspr-dev libgail-dev evolution-dev \ icon-naming-utils $(CCACHE) gutsy-PREREQS := \ gtk-doc-tools subversion flex bison build-essential \ libssl-dev libldap2-dev libnss3-dev libnspr4-dev libgail-dev \ evolution-dev icon-naming-utils libdbus-glib-1-dev \ $(CCACHE) hardy-PREREQS := \ gtk-doc-tools subversion flex bison build-essential \ libldap2-dev libnss3-dev libsoup2.4-dev libenchant-dev \ gnome-common evolution-dev \ $(CCACHE) etch-PREREQS := \ gtk-doc-tools subversion flex bison build-essential \ libssl-dev libldap2-dev libnss3-dev libnspr4-dev \ libgail-dev evolution-dev icon-naming-utils gnome-doc-utils \ $(CCACHE) # These are the packages we need to build from SVN, and any config/make/etc. # customized options we need to provide. PACKAGE_gtkhtml-y := gtkhtml PACKAGE_exchange-y := evolution-exchange PACKAGE_webcal-y := evolution-webcal # glib libsoup libbonobo PACKAGES := $(local_PACKAGES) \ $(PACKAGE_gtkhtml-$(ENABLE_gtkhtml)) \ evolution-data-server evolution \ $(PACKAGE_exchange-$(ENABLE_exchange)) \ $(PACKAGE_webcal-$(ENABLE_webcal)) CONFIG_VARS = CC='$(CC)' CFLAGS=-ggdb CONFIG_OPTS = --prefix='$(PREFIX)' BUILD_VARS = BUILD_OPTS = -j3 INSTALL_VARS = INSTALL_OPTS = CCACHE_DIR := $(CURDIR)/ccache export CCACHE_DIR PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig:$(PREFIX)/share/pkgconfig:$(PKG_CONFIG_PATH) export PKG_CONFIG_PATH ACLOCAL_FLAGS := -I $(PREFIX)/share/aclocal $(ACLOCAL_FLAGS) export ACLOCAL_FLAGS LD_LIBRARY_PATH := $(PREFIX)/lib:$(LD_LIBRARY_PATH) export LD_LIBRARY_PATH ifneq ($(LINGUAS),) export LINGUAS endif # ----- Per-package configuration and build options # # Each package can have any or all of these variables set: # # _PREREQS # _CONFIG_VARS # _CONFIG_OPTS # _BUILD_VARS # _BUILD_OPTS # _INSTALL_VARS # _INSTALL_OPTS # # The _PREREQS value lists packages that are (make) prerequisites. # The _*_VARS values are environment variable settings for that stage. # The _*_OPTS values are command line options for that stage. # # Only the variables with any values are listed here. libsoup_PREREQS := glib libbonobo_PREREQS := glib gtkhtml_PREREQS := glib libsoup libbonobo evolution-data-server_PREREQS := glib gvfs libsoup libbonobo gtkhtml evolution-data-server_CONFIG_OPTS = \ --with-openldap=yes --enable-gnome-keyring=yes --with-e2k-debug \ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults' # I decided to disable scrollkeeper since otherwise Evolution will try # to register it, and this requires root privileges. # --enable-nss=yes --enable-smime=yes --enable-plugins=all --enable-plugins=experimental \ CONFIG_exchange-y := --enable-exchange=yes evolution_PREREQS := glib libsoup libbonobo gtkhtml evolution-data-server evolution_CONFIG_OPTS = \ --with-openldap=yes --enable-nntp=yes --enable-ipv6=yes \ --enable-nss=yes --enable-smime=yes --enable-plugins=all \ --enable-cairo-calendar=yes --enable-imap4=yes --with-e2k-debug \ --disable-scrollkeeper $(CONFIG_exchange-$(ENABLE_exchange)) \ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults' evolution-exchange_PREREQS := glib libsoup libbonobo evolution-data-server evolution evolution-exchange_CONFIG_OPTS = \ --with-openldap=yes --with-e2k-debug \ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults' evolution-webcal_PREREQS := glib libsoup libbonobo evolution-data-server evolution evolution-webcal_CONFIG_OPTS = \ --with-gconf-source='xml:merged:$(PREFIX)/etc/gconf/gconf.xml.defaults' # ----- STAMPDIR := .stamp STAMPFILE = $(CURDIR)/$@ ifeq ($(OBJDIR),.) OBJPATH = $* SRCPATH = . else OBJPATH = $(OBJDIR)/$* SRCPATH = ../../$* endif # Commands CC := $(strip $(CCACHE) gcc) CP := cp -p CPDIR := cp -a DPKG := dpkg ECHO := echo LINK := ln -s MKDIR := mkdir -p RM := rm -f RMDIR := rm -rf SED := sed SUDO := sudo SVN := svn TOUCH := touch UNPACK := tar xjf WGET := wget MKSTAMP = $(TOUCH) '$(STAMPFILE)' # How to get things from SVN SVNROOTURL := http://svn.gnome.org/svn # Compute the SVN version path # If it's empty, assume the trunk # If it contains a "/", use it as-is # Otherwise, convert it into a branch name using the standard GNOME format. # Default branches for various distros; older distros can't always build # newer branches BRANCH_feisty := 2.20 ifeq ($(BRANCH),) BRANCH = $(BRANCH_$(DISTRO)) endif ifeq ($(BRANCH),) SVNPATH := trunk BRANCH := trunk else ifeq ($(notdir $(BRANCH)),$(BRANCH)) SVNPATH := branches/gnome-$(subst .,-,$(BRANCH)) else SVNPATH := $(BRANCH) endif branch := branch $(BRANCH) endif SVNPKGURL = "$(SVNROOTURL)/$$pkg/$(SVNPATH)" # Make sure we look in the new location for apps PATH := $(PREFIX)/bin:$(PATH) export PATH # Create the prefix directory if needed. # This could be done as an order-only prereq or something, but if we do it # here then the user is asked for a password up-front, rather than halfway # through the build when they've gone out for more tea. $(shell if [ -d '$(PREFIX)' ] || $(MKDIR) '$(PREFIX)' 2>/dev/null; then \ :; \ else \ $(ECHO) "Need root to create directory $(PREFIX)." 1>&2; \ $(ECHO) "Please enter YOUR password when asked (for sudo)." 1>&2; \ $(SUDO) $(MKDIR) '$(PREFIX)' && $(SUDO) chown '$(USER)' '$(PREFIX)';\ fi) # aclocal throws up if this doesn't exist... bogus! $(shell [ -d '$(PREFIX)/share/aclocal' ] || $(MKDIR) '$(PREFIX)/share/aclocal') # Make stamp and obj directories early, so make doesn't throw out patterns # for them. $(shell $(MKDIR) '$(CURDIR)/$(STAMPDIR)' '$(CURDIR)/obj') STAMPTYPES := update patch config build install # ----- all target # All means everything is installed .PHONY: all install update help all: install $(PREFIX)/bin/evolution-svn $(PREFIX)/bin/evolution-env install: $(patsubst %,$(STAMPDIR)/%.install,$(PACKAGES)) update: $(patsubst %,$(STAMPDIR)/%.update,$(PACKAGES)) help: $(SED) -n 's/^#h://p' < Makefile # Make sure none of the targets are considered intermediate .PRECIOUS: $(foreach X,$(STAMPTYPES),$(STAMPDIR)/%.$X) \ $(addsuffix /.svn,$(PACKAGES)) # ----- install script wrappers $(PREFIX)/bin/evolution-%: Makefile $V $(MKDIR) -p '$(@D)' \ && $(SED) -n -e 's|^#$*:||p' < '$<' \ | $(SED) -e 's|@PREFIX@|$(PREFIX)|' \ -e 's|@PKG_CONFIG_PATH@|$(PKG_CONFIG_PATH)|' \ -e 's|@LD_LIBRARY_PATH@|$(LD_LIBRARY_PATH)|' \ > '$@' \ && chmod 0755 '$@' \ && echo "Installed $@" # ----- final setup operations # Make sure camel-lock-helper has the right privs for handling email install: $V $(ECHO) "Setting mail helper privileges (may require $(SUDO)!)"; \ ls -1 $(PREFIX)/libexec/camel-lock-helper-* \ | while read helper; do \ [ -f "$$helper" ] || continue; \ case `stat --format="%G:%A" "$$helper"` in \ mail:??????s???) : all set ;; \ *) $(SUDO) chgrp mail "$$helper" \ && $(SUDO) chmod g+s "$$helper" ;; \ esac; \ done # ----- install SVN workspaces $(STAMPDIR)/%.install: $(STAMPDIR)/%.build | $(PREFIX) $V [ -d '$(PREFIX)/etc/gconf' ] || $(MKDIR) '$(PREFIX)/etc/gconf' $V cd '$(OBJPATH)' \ && $(INSTALL_VARS) $($*_INSTALL_VARS) \ $(MAKE) install $(INSTALL_OPTS) $($*_INSTALL_OPTS) @ $(MKSTAMP) # ----- build SVN workspaces $(STAMPDIR)/%.build: $(STAMPDIR)/%.config $V cd '$(OBJPATH)' \ && $(BUILD_VARS) $($*_BUILD_VARS) \ $(MAKE) $(BUILD_OPTS) $($*_BUILD_OPTS) @ $(MKSTAMP) # ----- configure SVN workspaces _CONFIG = $(MKDIR) '$(OBJPATH)/' && cd '$(OBJPATH)' \ && $(CONFIG_VARS) $($*_CONFIG_VARS) \ '$(SRCPATH)/autogen.sh' $(CONFIG_OPTS) $($*_CONFIG_OPTS) # We don't use the stamp files here because if we do, it will cause all the # prerequisite information at the end to come into play. config.%: $(_CONFIG) $(STAMPDIR)/%.config: $(STAMPDIR)/%.patch $V $(_CONFIG) @ $(MKSTAMP) # ----- patch SVN workspaces $(STAMPDIR)/%.patch: $(STAMPDIR)/%.update @ $(MKSTAMP) # ----- update SVN workspaces getsvnrev = `$(SVN) info $(1) | $(SED) -n 's/^Revision: \([0-9][0-9]*\).*/\1/p'` getsvninfo = eval `$(SVN) info $(2) | $(SED) -n -e 's/^Revision: \([0-9][0-9]*\).*/$(1)rev="\1"/p' -e 's/^URL: \(http:.*\)/$(1)url="\1"/p'` $(STAMPDIR)/%.update: %/.svn FORCE | check-prereqs-$(DISTRO) $V pkg='$*'; cd "$$pkg" \ && $(call getsvninfo,repo,$(SVNPKGURL)) \ && $(call getsvninfo,work,) \ && if [ "$$workrev:$$workurl" = "$$reporev:$$repourl" ]; then \ $(ECHO) "No SVN update needed for $$pkg."; \ [ -f '$(STAMPFILE)' ] || $(MKSTAMP); \ else \ $(ECHO) ">>>> Updating package $$pkg from SVN:"; \ $(SVN) switch $(SVNPKGURL) \ && $(SVN) update \ && $(MKSTAMP); \ fi FORCE: %/.svn: @ $(ECHO) ">>>> Checking out package $* from SVN:" $V pkg='$*'; $(SVN) checkout $(SVNPKGURL) "$$pkg" @ $(TOUCH) '$(CURDIR)/$(STAMPDIR)/$*.update' .PHONY: check-update check-update: @for pkg in $(PACKAGES); do \ ( \ cd "$$pkg"; \ $(call getsvninfo,repo,$(SVNPKGURL)); \ $(call getsvninfo,work,); \ if [ "$$workrev" = "$$reporev" ]; then \ $(ECHO) ">>>> No SVN update needed for $$pkg."; \ else \ $(ECHO) ">>>> $$pkg has SVN updates available:"; \ if [ "$$workurl" = "$$repourl" ]; then \ $(SVN) status -q -u; \ else \ $(ECHO) "-> On $(BRANCH). Use 'make update'."; \ fi; \ fi; \ ); \ done .PHONY: check-changelog check-changelog: @for pkg in $(PACKAGES); do \ ( \ cd "$$pkg"; \ $(call getsvninfo,repo,$(SVNPKGURL)); \ $(call getsvninfo,work,); \ if [ "$$workrev" = "$$reporev" ]; then \ $(ECHO) ">>>> No SVN update needed for $$pkg."; \ else \ $(ECHO) ">>>> $$pkg has SVN updates available:"; \ if [ "$$workurl" != "$$repourl" ]; then \ $(ECHO) "-> On $(BRANCH). Use 'make update'."; \ else \ log="/tmp/svnstatus.log.$$$$"; \ $(SVN) status -q -u 2>&1 | tee "$$log"; \ sort "$$log" \ | while read stat rev fn; do \ case $$fn in \ ChangeLog|*/ChangeLog) \ $(ECHO) ">>>> $$pkg: $(SVN) diff -r $$rev:HEAD $$fn"; \ $(SVN) diff -r "$$rev:HEAD" "$$fn" ;; \ esac; \ done; \ $(RM) "$$log"; \ fi; \ fi; \ ); \ done # ----- create SVN workspaces # ----- check packages # This is for DPKG systems. Someone else will have to write the # equivalent RPM code. .PHONY: check-prereqs check-prereqs- check-prereqs-ubuntu check-prereqs: check-prereqs-$(DISTRO) check-prereqs-: @$(ECHO) "Cannot verify system package prerequisites."; \ $(ECHO) "I'm trying to build anyway..."; \ $(ECHO) " Good luck!!" check-prereqs-%: @$(ECHO) "Unsupported distro: '$*'. Choose one of:"; \ for d in $(DISTROS); do $(ECHO) " $$d"; done; \ $(ECHO) "Or to force a build, set 'distro' empty in the makefile."; \ exit 1 $(addprefix check-prereqs-,$(DISTROS)): check-prereqs-%: @log="/tmp/evo-chk-prereqs.$$$$" \ && $(RM) "$$log" \ && $(TOUCH) "$$log" \ && $(DPKG) -l $(sort $($*-PREREQS)) \ | while read s n rest; do \ case $$s in \ ii) echo "$$n" >> "$$log" ;; \ [a-z][a-z]) \ echo "Package $$n not installed (state $$s)" ;; \ esac; \ done; \ num=`wc -l < "$$log"`; \ $(RM) "$$log"; \ if [ "$$num" != "$(words $(sort $($*-PREREQS)))" ]; then \ $(ECHO); \ $(ECHO) "Not all prerequisites are installed!"; \ $(ECHO) "Use 'aptitude install ...' on the above missing packages."; \ $(ECHO); \ exit 1; \ fi # ----- cleanup .PHONY: clean shinyclean superclean clean: $(RMDIR) $(STAMPDIR) ifeq ($(OBJDIR),.) for pkg in $(PACKAGES); do \ (cd $$pkg && $(MAKE) clean); \ done else $(RMDIR) $(OBJDIR) endif shinyclean: $(RMDIR) $(STAMPDIR) $(PACKAGES) ifneq ($(OBJDIR),.) $(RMDIR) $(OBJDIR) endif superclean: shinyclean $(RMDIR) $(PREFIX) # Clean out the builtin database .SUFFIXES: # ----- ordering # These ensure that packages are built in the correct order. In general, # we can't do the config until after we've installed the previous packages. # # Technically, we don't really need to reconfig after every install: most of # the time it would be enough to rebuild after the install; however, there's # no good way to make that work all the time, unless we had perfect # prerequisite declarations (knowing which installed files actually would # require a reconfig vs. a rebuild for example). # Generate prerequisites, but don't depend on packages we don't build prereqs = $(STAMPDIR)/$(1).config : $(patsubst %,$(STAMPDIR)/%.install,$(filter $($(1)_PREREQS),$(PACKAGES))) $(call prereqs,glib) $(call prereqs,libsoup) $(call prereqs,gtkhtml) $(call prereqs,evolution-data-server) $(call prereqs,evolution) $(call prereqs,evolution-exchange) $(call prereqs,evolution-webcal) # ---- END OF MAKEFILE ---- # ----------------------------------------------------------------------------- # This is the content of evolution-env. It's extracted by sed. #env:#!/bin/sh #env:# #env:# Put this file in your PATH and/or invoke it directly. #env:# #env:# - Sets up the environment for running the compiled version of #env:# Evolution and compiling programs against it. #env:# - Runs the program on the command line (if one given) or a bash #env:# shell. #env: #env:prefix='@PREFIX@' #env:pkgconfig='@PKG_CONFIG_PATH@' #env:ldlibrary='@LD_LIBRARY_PATH@' #env: #env:BONOBO_ACTIVATION_PATH=$prefix/lib/bonobo/servers #env:export BONOBO_ACTIVATION_PATH #env: #env:case ":$PKG_CONFIG_PATH:" in #env: *":$pkgconfig:"*) : ok ;; #env: *) PKG_CONFIG_PATH="$pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}" #env: export PKG_CONFIG_PATH ;; #env:esac #env: #env:case ":$LD_LIBRARY_PATH:" in #env: *":$ldlibrary:"*) : ok ;; #env: *) LD_LIBRARY_PATH="$ldlibrary${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" #env: export LD_LIBRARY_PATH ;; #env:esac #env: #env:case ":$PATH:" in #env: *":$prefix/bin:$prefix/libexec:"*) : ok ;; #env: *) PATH="$prefix/bin:$prefix/libexec:$PATH" #env: export PATH ;; #env:esac #env: #env:exec "${@:-${SHELL:-/bin/bash}}" # ----------------------------------------------------------------------------- # This is the content of evolution-svn. It's extracted by sed. #svn:#!/bin/sh #svn:# #svn:# Put this file in your PATH and/or invoke it directly. #svn:# #svn:# - Enables full debugging (note! Privacy concerns!) #svn:# - Enables core dumps (ulimit) #svn:# - Creates a new log directory for this instance of Evo #svn:# - Cd's there to keep everything related to this run together #svn:# #svn:# You should clean out those log directories occasionally. #svn: #svn:prefix='@PREFIX@' #svn: #svn:# Set up debugging. Remember EVERYTHING! #svn:E2K_DEBUG=5 #svn:CAMEL_DEBUG=all #svn:export E2K_DEBUG CAMEL_DEBUG #svn:export XDG_DATA_DIRS=/opt/evo/share:$XDG_DATA_DIRS #svn:export EDITOR=gvim #svn: #svn:# Allow for core dumps. #svn:ulimit -c unlimited #svn: #svn:# All our email is dumped with debugging, so set restrictive permissions #svn:umask 0077 #svn: #svn:# Create a directory just for this run #svn:logdir="$prefix/log/`date '+%Y%m%d.%H%M%S'`" #svn:mkdir -p "$logdir" #svn:cd "$logdir" || exit 1 #svn: #svn:# Run it #svn:i=0 #svn:while [ -e "$logdir/evo.log.$i" ]; do #svn: i=`expr $i + 1` #svn:done #svn: #svn:exec "$prefix/bin/evolution-env" "$prefix/bin/evolution" "$@" >"$logdir/evo.log.$i" 2>&1 # ----------------------------------------------------------------------------- # This is some help. Run "make help" to read it most easily. #h:Makefile for building Evolution from SVN #h:---------------------------------------- #h: #h:MAKE TARGETS: #h: #h:all [Default] Check out, configure, compile, install the various #h: components necessary to build Evolution from SVN. #h: #h:update Perform SVN updates of all the checked out components. #h: #h:check-update Check whether there are new updates in the SVN repository. #h: Doesn't check anything out. #h: #h:check-changelog Check whether there are new updates, AND show the ChangeLog #h: diffs. #h: #h:check-prereqs Verify that the packages needed for the build are installed. #h: #h:clean For each source package, "make clean" #h: #h:shinyclean Remove the source packages completely #h: #h:superclean Remove the source packages AND the installed Evolution #h: #h: #h:CUSTOMIZATION: #h: #h:You can create a makefile "local.mk" in the same directory that contains the #h:Makefile. This file, if it exists, can contain one or more of the following #h:variables: #h: #h:PREFIX The directory in which to install Evolution. #h: Must NOT be /usr! #h: #h:DISTRO The GNU/Linux distribution you're running. This helps the #h: Makefile check for the right packages before starting the #h: build. Currently supported are "feisty", "gutsy", "hardy", and #h: "etch" (Debian). You can also set it to empty and hope for the best. #h: #h:BRANCH The SVN label or branch to build. If you don't set this then #h: a distro-specific value is chosen: it uses the SVN trunk where #h: possible. #h: #h:CCACHE Enable ccache (on by default). If you don't want to use it, #h: set this to empty. #h: #h:ENABLE_exchange Turn on Evolution Exchange support (on by default). If you #h: don't want to build it, set this to "n" (or any non-"y" #h: value). #h: #h:ENABLE_webcal Turn on Evolution Webcall support (on by default). If you #h: don't want to build it, set this to "n" (or any non-"y" #h: value). #h: #h:LINGUAS Restrict the number of translations built and installed to #h: those listed in this variable. #h: #h:local_PACKAGES A list of extra packages you want to build. These must be #h: "standard" Gnome packages kept on the Gnome SVN server and #h: using the normal build operations. Common packages you might #h: want to list here are glib, libbonobo, and libsoup. #h: