mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-12-22 01:14:53 +01:00
build: Add support for non-source-directory builds.
Such as: mkdir build cd build ../configure make This is implemented by having the configure script set a srcdir variable in Makefile.config, and then sprinkling $(srcdir) into various make rules. We also use vpath directives to convince GNU make to find the source files from the original source directory.
This commit is contained in:
parent
38f46b6869
commit
3e4a9d60a9
8 changed files with 52 additions and 23 deletions
2
Makefile
2
Makefile
|
@ -19,7 +19,7 @@ extra_cxxflags :=
|
|||
# Makefile.config if it doesn't exist yet. And add Makefile.config to
|
||||
# our global dependency list.
|
||||
include Makefile.config
|
||||
Makefile.config: configure
|
||||
Makefile.config: $(srcdir)/configure
|
||||
@echo ""
|
||||
@echo "Note: Calling ./configure with no command-line arguments. This is often fine,"
|
||||
@echo " but if you want to specify any arguments (such as an alternate prefix"
|
||||
|
|
|
@ -12,7 +12,7 @@ PACKAGE=notmuch
|
|||
|
||||
IS_GIT=$(shell if [ -d .git ] ; then echo yes ; else echo no; fi)
|
||||
|
||||
VERSION:=$(shell cat version)
|
||||
VERSION:=$(shell cat ${srcdir}/version)
|
||||
ifneq ($(MAKECMDGOALS),release)
|
||||
ifneq ($(MAKECMDGOALS),release-message)
|
||||
ifeq ($(IS_GIT),yes)
|
||||
|
@ -81,7 +81,7 @@ dist: $(TAR_FILE)
|
|||
# targets in the case of parallel invocation of make (-j).
|
||||
#
|
||||
# We carefully ensure that our VERSION variable is passed down to any
|
||||
# sub-ordinate make invocations (which won't otherwhise know that they
|
||||
# sub-ordinate make invocations (which won't otherwise know that they
|
||||
# are part of the release and need to take the version from the
|
||||
# version file).
|
||||
.PHONY: release
|
||||
|
|
10
TODO
10
TODO
|
@ -255,16 +255,6 @@ existing messages at the next database upgrade).
|
|||
Add support for the user to specify custom headers to be indexed (and
|
||||
re-index these for existing messages at the next database upgrade).
|
||||
|
||||
Build system
|
||||
------------
|
||||
Fix to allow a non-source-directory build. For example, the below
|
||||
should be made to work:
|
||||
|
||||
mkdir build_dir
|
||||
cd build_dir
|
||||
../configure
|
||||
make
|
||||
|
||||
Test suite
|
||||
----------
|
||||
Achieve 100% test coverage with the test suite.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
dir := compat
|
||||
extra_cflags += -I$(dir)
|
||||
extra_cflags += -I$(srcdir)/$(dir)
|
||||
|
||||
notmuch_compat_srcs :=
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@ dir := completion
|
|||
# The dir variable will be re-assigned to later, so we can't use it
|
||||
# directly in any shell commands. Instead we save its value in other,
|
||||
# private variables that we can use in the commands.
|
||||
bash_script := $(dir)/notmuch-completion.bash
|
||||
zsh_script := $(dir)/notmuch-completion.zsh
|
||||
bash_script := $(srcdir)/$(dir)/notmuch-completion.bash
|
||||
zsh_script := $(srcdir)/$(dir)/notmuch-completion.zsh
|
||||
|
||||
install: install-$(dir)
|
||||
|
||||
|
|
43
configure
vendored
43
configure
vendored
|
@ -1,5 +1,26 @@
|
|||
#! /bin/sh
|
||||
|
||||
srcdir=$(dirname "$0")
|
||||
|
||||
# For a non-srcdir configure invocation (such as ../configure), create
|
||||
# the directory structure and copy Makefiles.
|
||||
if [ "$srcdir" != "." ]; then
|
||||
|
||||
for dir in . $(grep "^subdirs *=" "$srcdir"/Makefile | sed -e "s/subdirs *= *//"); do
|
||||
mkdir -p "$dir"
|
||||
cp "$srcdir"/"$dir"/Makefile.local "$dir"
|
||||
cp "$srcdir"/"$dir"/Makefile "$dir"
|
||||
done
|
||||
|
||||
# Easiest way to get the test suite to work is to just copy the
|
||||
# whole thing into the build directory.
|
||||
cp -a "$srcdir"/test/* test
|
||||
|
||||
# Emacs only likes to generate compiled files next to the .el files
|
||||
# by default so copy these as well (which is not ideal0.
|
||||
cp -a "$srcdir"/emacs/*.el emacs
|
||||
fi
|
||||
|
||||
# Set several defaults (optionally specified by the user in
|
||||
# environemnt variables)
|
||||
CC=${CC:-gcc}
|
||||
|
@ -424,7 +445,7 @@ EOF
|
|||
fi
|
||||
|
||||
printf "Checking for getline... "
|
||||
if ${CC} -o compat/have_getline compat/have_getline.c > /dev/null 2>&1
|
||||
if ${CC} -o compat/have_getline "$srcdir"/compat/have_getline.c > /dev/null 2>&1
|
||||
then
|
||||
printf "Yes.\n"
|
||||
have_getline=1
|
||||
|
@ -435,7 +456,7 @@ fi
|
|||
rm -f compat/have_getline
|
||||
|
||||
printf "Checking for strcasestr... "
|
||||
if ${CC} -o compat/have_strcasestr compat/have_strcasestr.c > /dev/null 2>&1
|
||||
if ${CC} -o compat/have_strcasestr "$srcdir"/compat/have_strcasestr.c > /dev/null 2>&1
|
||||
then
|
||||
printf "Yes.\n"
|
||||
have_strcasestr=1
|
||||
|
@ -508,6 +529,24 @@ cat > Makefile.config <<EOF
|
|||
# changes, (and this could happen by simply calling "make" if the
|
||||
# configure script is updated).
|
||||
|
||||
srcdir = ${srcdir}
|
||||
|
||||
# We use vpath directives (rather than the VPATH variable) since the
|
||||
# VPATH variable matches targets as well as prerequisites, (which is
|
||||
# not useful since then a target left-over from a srcdir build would
|
||||
# cause a target to not be built in the non-srcdir build).
|
||||
#
|
||||
# Also, we don't use a single "vpath % \$(srcdir)" here because we
|
||||
# don't want the vpath to trigger for our emacs lisp compilation,
|
||||
# (unless we first find a way to convince emacs to build the .elc
|
||||
# target in a directory other than the directory of the .el
|
||||
# prerequisite). In the meantime, we're actually copying in the .el
|
||||
# files, (which is quite ugly).
|
||||
vpath %.c \$(srcdir)
|
||||
vpath %.cc \$(srcdir)
|
||||
vpath %.1 \$(srcdir)
|
||||
vpath Makefile.% \$(srcdir)
|
||||
|
||||
# The C compiler to use
|
||||
CC = ${CC}
|
||||
|
||||
|
|
|
@ -15,9 +15,9 @@ emacs_sources := \
|
|||
$(dir)/coolj.el
|
||||
|
||||
emacs_images := \
|
||||
$(dir)/notmuch-logo.png
|
||||
$(srcdir)/$(dir)/notmuch-logo.png
|
||||
|
||||
emacs_bytecode := $(subst .el,.elc,$(emacs_sources))
|
||||
emacs_bytecode = $(emacs_sources:.el=.elc)
|
||||
|
||||
%.elc: %.el
|
||||
$(call quiet,EMACS) --directory emacs -batch -f batch-byte-compile $<
|
||||
|
|
|
@ -45,7 +45,7 @@ endif
|
|||
endif
|
||||
|
||||
dir := lib
|
||||
extra_cflags += -I$(dir) -fPIC
|
||||
extra_cflags += -I$(srcdir)/$(dir) -fPIC
|
||||
|
||||
libnotmuch_c_srcs = \
|
||||
$(notmuch_compat_srcs) \
|
||||
|
@ -85,13 +85,13 @@ install: install-$(dir)
|
|||
# but cannot be used reliably within commands, so copy its value to a
|
||||
# variable that is not reused.
|
||||
lib := $(dir)
|
||||
install-$(dir):
|
||||
install-$(dir): $(dir)/$(LIBNAME)
|
||||
mkdir -p "$(DESTDIR)$(libdir)/"
|
||||
install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
|
||||
ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
|
||||
ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
|
||||
mkdir -p "$(DESTDIR)$(includedir)"
|
||||
install -m0644 "$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
|
||||
install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
|
||||
$(LIBRARY_INSTALL_POST_COMMAND)
|
||||
|
||||
SRCS := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
|
||||
|
|
Loading…
Reference in a new issue