From b87fe2967a0d7ee64189c18f012c430b978009e3 Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Fri, 27 Apr 2012 19:46:39 -0700 Subject: [PATCH] configure wrapper script and top-level Makefile: closes #5143 This introduces a configure script that automates the basic task of setting up a CMake build directory. It also uses a top-level Makefile (which the configure script generates, to prevent running it until configure has executed) which does the build and copies the final executables into the root of the source tree. --- .gitignore | 10 ++--- CMakeLists.txt | 2 +- Makefile.in | 29 ++++++++++++++ configure | 100 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 6 deletions(-) create mode 100644 Makefile.in create mode 100755 configure diff --git a/.gitignore b/.gitignore index 9ef0650b..2f2b0b16 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ *~ -.lock-wafbuild .valencia -.waf-* +/Makefile +/.stamp build/ -/console /geary -/norman -/theseus /gearyd +/geary-mailer +/geary-console + diff --git a/CMakeLists.txt b/CMakeLists.txt index f9e05997..eea23946 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ) # Base bits # set(GETTEXT_PACKAGE "geary") -set(RELEASE_NAME "Lightweight email client for Gnome.") +set(RELEASE_NAME "Lightweight email client for GNOME.") set(VERSION "0.0.0+trunk") set(VERSION_INFO "Release") diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..95c6da01 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,29 @@ +# Makefile.in +# +# Copyright 2012 Yorba Foundation + +BUILD_DIR := build +BINARIES := geary gearyd geary-console geary-mailer + +BUILD_BINARIES := $(addprefix $(BUILD_DIR)/,$(BINARIES)) + +.PHONY: all +all: + @$(MAKE) -C $(BUILD_DIR) + @cp $(BUILD_BINARIES) . + +.PHONY: install uninstall +install uninstall: + @$(MAKE) -C $(BUILD_DIR) $@ + +.PHONY: clean +clean: + @-$(MAKE) -C $(BUILD_DIR) clean + @-rm -f $(BINARIES) + @-rm -f .stamp + +.PHONY: distclean +distclean: clean + @-rm -rf $(BUILD_DIR) + @-rm -f Makefile + diff --git a/configure b/configure new file mode 100755 index 00000000..3dca2e47 --- /dev/null +++ b/configure @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# +# Copyright 2012 Yorba Foundation +# +# This software is licensed under the GNU LGPL (version 2.1 or later). +# See the COPYING file in this distribution. + +DEFAULT_PREFIX="/usr/local" + +PREFIX=$DEFAULT_PREFIX + +configure_help() { + printf "Usage:\n" + printf "\t./configure [OPTIONS]...\n" + printf "\n" + printf "Options:\n" + + printf "\t-h, --help\t\tPrint this help and exit.\n" + + printf "\t--prefix=PREFIX\t\tPrepend PREFIX to program installation paths.\n" + printf "\t\t\t\t[%s]\n" $DEFAULT_PREFIX + + printf "\n" +} + +abort() { + printf "%s: Invalid argument %s\n" $0 $1 + configure_help + exit 1 +} + +while [ $# != 0 ] +do + option=`echo $1 | sed 's/=.*//'` + if [ `echo $1 | grep '='` ] + then + value=`echo $1 | sed 's/.*=//'` + fi + + case $option in + -h | --help) configure_help + exit 0 + ;; + + --prefix) if [ ! $value ] + then + abort $1 + fi + + CMDLINE="${CMDLINE}-DCMAKE_INSTALL_PREFIX=${value} " + ;; + + *) abort $option + ;; + esac + + shift +done + +# Verify cmake is installed +# TODO: Check for minimum version number +if ! cmake --version +then + printf "cmake must be installed to configure and build.\n" + exit 1 +fi + +# Simple check to verify this script is running in the root of the source tree +if ! [ -e Makefile.in ] +then + printf "configure script must be executed in source directory (Makefile.in not found).\n" + exit 1 +fi + +# Remove existing Makefile so it's not left around if configure fails +rm -f Makefile + +if ! mkdir -p build +then + printf "Unable to create build directory.\n" + exit 1 +fi + +cd build + +if ! cmake $CMDLINE .. +then + printf "Unable to prepare build directory.\n" + exit 1 +fi + +cd .. + +if ! cp -f Makefile.in Makefile +then + printf "Unable to prepare Makefile.\n" + exit 1 +fi + +printf "Configured. Type 'make' to build, 'make install' to install.\n"