From 975604d3ee4c9d76d72220802b6b22dc4a958662 Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 28 Aug 2021 11:25:05 +0300 Subject: [PATCH] build: make meson the default build system We still support autotools for now, but it is no longer the default. --- Makefile.meson | 43 +++++++++++++++++++++++++++++++++ autogen.sh | 31 ++++++++++-------------- configure.ac | 4 +++ mu4e/meson.build | 14 ++++++++++- mu4e/mu4e.texi | 63 ++++++++++++++++-------------------------------- 5 files changed, 94 insertions(+), 61 deletions(-) create mode 100644 Makefile.meson diff --git a/Makefile.meson b/Makefile.meson new file mode 100644 index 00000000..381ae319 --- /dev/null +++ b/Makefile.meson @@ -0,0 +1,43 @@ +## Copyright (C) 2008-2021 Dirk-Jan C. Binnema +## +## 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 3 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + +# Makefile with some useful targets for meson/ninja + +NINJA ?= ninja +BUILDDIR ?= $(CURDIR)/build +MESON ?= meson + +all: $(BUILDDIR) + $(NINJA) -C $(BUILDDIR) + +$(BUILDDIR): + $(MESON) $(BUILDDIR) + +check: test + +test: $(BUILDDIR) + @cd $(BUILDDIR); $(MESON) test + +dist: $(BUILDDIR) + @cd $(BUILDDIR); $(MESON) dist + +install: $(BUILDDIR) + @cd $(BUILDDIR); $(MESON) install + +clean: + @test -d $(BUILDDIR) && $(NINJA) -C $(BUILDDIR) clean + diff --git a/autogen.sh b/autogen.sh index 1155320f..555cdb2d 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,34 +1,29 @@ #!/bin/sh # Run this to generate all the initial makefiles, etc. +echo "*** meson build setup" + test -f mu/mu.cc || { echo "*** Run this script from the top-level mu source directory" exit 1 } -# opportunistically; usually not needed, but occasionally it'll -# avoid build errors that would otherwise confuse users. -test -f Makefile && { - echo "*** clear out old things" - make distclean 2> /dev/null -} +BUILDDIR=build - -command -V autoreconf > /dev/null +command -v meson 2> /dev/null if [ $? != 0 ]; then - echo "*** No autoreconf found, please install it ***" + echo "*** No meson found, please install it ***" exit 1 fi -rm -f config.cache -rm -rf autom4te.cache - -autoreconf --force --install --verbose || exit $? - -if test -z "$*"; then - echo "# Configuring without parameters" +# we could remove build/ but let's avoid rm -rf risks... +if test -d ${BUILDDIR}; then + meson --reconfigure ${BUILDDIR} else - echo "# Configure with parameters $*" + meson ${BUILDDIR} $@ fi -./configure --config-cache $@ +# Add a Makefile with some useful target +cp Makefile.meson Makefile + +echo "*** Now run 'ninja -C ${BUILDDIR}' to build mu" diff --git a/configure.ac b/configure.ac index 0485978e..1c0e82e0 100644 --- a/configure.ac +++ b/configure.ac @@ -363,6 +363,10 @@ AS_IF([test "x$ac_cv_header_wordexp_h" != "xyes"],[ echo " --maildir=/home/user/Maildir" ]) + +echo "NOTE: autotools support has been deprecated and will be removed" +echo " after the next stable release. use the meson build instead" + echo echo "Now, type 'make' (or 'gmake') to build mu" echo diff --git a/mu4e/meson.build b/mu4e/meson.build index d8fb0db3..3e310f24 100644 --- a/mu4e/meson.build +++ b/mu4e/meson.build @@ -23,7 +23,7 @@ mu4e_meta = configure_file( 'VERSION' : meson.project_version(), # project_build_root() with meson >= 0.56 'abs_top_builddir': join_paths(meson.build_root()), - 'MU_DOC_DIR' : join_paths(datadir, 'doc', 'mu') + 'MU_DOC_DIR' : join_paths(datadir, 'doc', 'mu'), }) @@ -53,6 +53,13 @@ mu4e_srcs=[ 'obsolete/org-mu4e.el', ] + +# +# with (development) emacs 28.50 / native compilation this doesn't +# _quite_ work; see: https://debbugs.gnu.org/db/47/47987.html +# +lispdir = join_paths(datadir, 'emacs', 'site-lisp', 'mu4e') + foreach src : mu4e_srcs target_name= '@BASENAME@.elc' target_path = join_paths(meson.current_build_dir(), target_name) @@ -61,6 +68,8 @@ foreach src : mu4e_srcs build_by_default: true, input: src, output: target_name, + install_dir: lispdir, + install: true, command: [emacs, '--no-init-file', '--batch', @@ -70,6 +79,9 @@ foreach src : mu4e_srcs '--funcall', 'batch-byte-compile', '@INPUT@']) endforeach +# also install the sources. +install_data(mu4e_srcs, install_dir: lispdir) + if makeinfo.found() custom_target('mu4e_info', diff --git a/mu4e/mu4e.texi b/mu4e/mu4e.texi index 2806c5dd..ec2f8544 100644 --- a/mu4e/mu4e.texi +++ b/mu4e/mu4e.texi @@ -266,38 +266,20 @@ details depend on your distribution. If you're using another distribution (or another OS), the below can at least be helpful in identifying the packages to install. -We provide some instructions for Debian, Ubuntu and Fedora; if those do not -apply to you, you can follow either @ref{Building from a release tarball} or -@ref{Building from git}. +We provide some instructions for Debian, Ubuntu and Fedora; if those +do not apply to you, you can follow either @ref{Building from a +release tarball} or @ref{Building from git}. @subsection Dependencies for Debian/Ubuntu @example -$ sudo apt-get install libgmime-3.0-dev libxapian-dev - -# get emacs 25 or higher if you don't have it yet -$ sudo apt-get install emacs - -# optional -$ sudo apt-get install guile-2.2-dev html2text xdg-utils - -# optional: only needed for msg2pdf and mug (toy gtk+ frontend) -$ sudo apt-get install libwebkitgtk-3.0-dev +$ sudo apt-get install libgmime-3.0-dev libxapian-dev emacs @end example @subsection Dependencies for Fedora @example -$ sudo yum install gmime30-devel xapian-core-devel - -# get emacs 25 or higher if you don't have it yet -$ sudo yum install emacs - -# optional -$ sudo yum install html2text xdg-utils guile22-devel - -# optional: only needed for msg2pdf and mug (toy gtk+ frontend) -$ sudo yum install webkitgtk3-devel +$ sudo yum install gmime30-devel xapian-core-devel emacs @end example @subsection Building on Msys2 @@ -348,10 +330,18 @@ Xapian, GMime and their dependencies must be installed. @subsection Building from git @anchor{Building from git} -Alternatively, if you build from the git repository or use a tarball -like the ones that @t{github} produces, the instructions are slightly -different, and require you to have autotools (@t{autoconf}, -@t{automake}, @t{libtool}, @t{texinfo}) installed: +By default, @t{mu} use the Meson@footnote{@url{https://mesonbuild.com/}} build-system. + +@example +$ git clone git://github.com/djcb/mu.git +$ cd mu +$ meson build && ninja -C build +$ sudo ninja -C install +@end example + +For now, you can also use the (deprecated) @t{autotools} build setup, +assuming you have autotools (@t{autoconf}, @t{automake}, @t{libtool}, +@t{texinfo}) installed: @example # get from git (alternatively, use a github tarball) @@ -368,29 +358,18 @@ $ sudo make install After this, @t{mu} and @t{mu4e} should be installed @footnote{there's a hard dependency between versions of @t{mu4e} and @t{mu} --- you cannot combine different versions} on your system, and be available -from the command line and in Emacs. +from the command line and in Emacs. You may need to restart Emacs, so it can find @t{mu4e} in its @code{load-path}. If, even after restarting, Emacs cannot find -@t{mu4e}, you may need to add it to your @code{load-path} explicitly; check -where @t{mu4e} is installed, and add something like the following to your -configuration before trying again: +@t{mu4e}, you may need to add it to your @code{load-path} explicitly; +check where @t{mu4e} is installed, and add something like the +following to your configuration before trying again: @lisp ;; the exact path may differ --- check it (add-to-list 'load-path "/usr/local/share/emacs/site-lisp/mu4e") @end lisp -@subsection Building using the meson build system - -As an (experimental) alternative to the @t{autotools}-build, it is possible to use -the Meson@footnote{@url{https://mesonbuild.com/}} build-system instead. - -@example -$ git clone git://github.com/djcb/mu.git -$ cd mu -$ meson build && ninja -C build -$ sudo ninja -C install -@end example @subsection mu4e and emacs customization