summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorPatrick Griffis <tingping@tingping.se>2016-12-13 16:12:03 -0500
committerPatrick Griffis <tingping@tingping.se>2017-06-13 23:54:51 -0400
commit628100c19f5d82747170acdf2917cba8c119ccbf (patch)
tree351a7e9714a1a58390ba349808df5703cef25c3e
parent2edf50d4ddc61ce6f73bf02263c9bdd09632c66b (diff)
build: Replace Autotools with Meson
Quick rundown of benefits:

- Much faster:
  - Autotools (with autogen): 22 seconds
  - Meson: 7 seconds
  - Meson (with ccache): 2 seconds

- Simpler:
  - ~1000 lines smaller
  - Single simple language

- Potentially better Windows (Visual Studio) support

What is not done:

- Complete Windows support
- OSX support (easy)

Closes #2013
Closes #1937
Closes #1803
-rw-r--r--.editorconfig5
-rw-r--r--.gitignore65
-rw-r--r--.travis.yml38
-rw-r--r--Makefile.am7
-rwxr-xr-xautogen.sh32
-rw-r--r--configure.ac798
-rw-r--r--data/Makefile.am16
-rw-r--r--data/icons/Makefile.am15
-rw-r--r--data/icons/meson.build9
-rw-r--r--data/man/Makefile.am3
-rw-r--r--data/man/meson.build10
-rw-r--r--data/meson.build11
-rw-r--r--data/misc/Makefile.am50
-rw-r--r--data/misc/hexchat.appdata.xml.in6
-rw-r--r--data/misc/hexchat.desktop.in.in10
-rw-r--r--data/misc/htm.desktop.in2
-rw-r--r--data/misc/meson.build48
-rw-r--r--data/pkgconfig/Makefile.am4
-rw-r--r--data/pkgconfig/meson.build14
-rw-r--r--fedora-mingw64.ini17
-rw-r--r--m4/as-ac-expand.m440
-rw-r--r--m4/ax_check_enable_debug.m4124
-rw-r--r--m4/ax_is_release.m469
-rw-r--r--m4/ax_python_devel.m4327
-rw-r--r--m4/clang-analyze.am8
-rw-r--r--meson.build130
-rw-r--r--meson_options.txt56
-rw-r--r--meson_post_install.py24
-rw-r--r--plugins/Makefile.am25
-rw-r--r--plugins/checksum/Makefile.am8
-rw-r--r--plugins/checksum/meson.build6
-rw-r--r--plugins/exec/meson.build5
-rw-r--r--plugins/fishlim/Makefile.am10
-rw-r--r--plugins/fishlim/meson.build18
-rw-r--r--plugins/lua/Makefile.am9
-rw-r--r--plugins/lua/meson.build12
-rw-r--r--plugins/meson.build39
-rw-r--r--plugins/perl/Makefile.am20
-rwxr-xr-xplugins/perl/generate_header.py29
-rw-r--r--plugins/perl/meson.build73
-rw-r--r--plugins/python/Makefile.am9
-rw-r--r--plugins/python/meson.build13
-rw-r--r--plugins/python/python.c2
-rw-r--r--plugins/sysinfo/Makefile.am17
-rw-r--r--plugins/sysinfo/meson.build46
-rw-r--r--plugins/upd/meson.build8
-rw-r--r--plugins/winamp/meson.build6
-rw-r--r--po/Makevars7
-rw-r--r--po/POTFILES (renamed from po/POTFILES.in)0
-rw-r--r--po/meson.build1
-rw-r--r--src/Makefile.am17
-rw-r--r--src/common/Makefile.am89
-rw-r--r--src/common/cfgfiles.c20
-rw-r--r--src/common/dbus/Makefile.am35
-rw-r--r--src/common/dbus/meson.build44
-rwxr-xr-xsrc/common/make-te.py55
-rw-r--r--src/common/meson.build116
-rw-r--r--src/common/sysinfo/win32/backend.c19
-rw-r--r--src/common/util.c12
-rw-r--r--src/fe-gtk/Makefile.am64
-rw-r--r--src/fe-gtk/meson.build79
-rw-r--r--src/fe-text/Makefile.am9
-rw-r--r--src/fe-text/fe-text.c2
-rw-r--r--src/fe-text/meson.build7
-rw-r--r--src/htm/Makefile.am15
-rw-r--r--src/htm/htm-mono.csproj144
-rw-r--r--src/htm/meson.build33
-rw-r--r--src/htm/thememan.HTM.resourcesbin0 -> 10228 bytes
-rwxr-xr-x[-rw-r--r--]src/htm/thememan.in0
-rw-r--r--src/meson.build13
-rw-r--r--win32/version-template.ps12
71 files changed, 979 insertions, 2097 deletions
diff --git a/.editorconfig b/.editorconfig
index 973cb4fe..3fa759e9 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,3 +12,8 @@ end_of_line = lf
 indent_style = space
 indent_size = 4
 end_of_line = lf
+
+[{meson.build,meson_options.txt}]
+indent_size = 2
+indent_style = space
+insert_final_newline = true
diff --git a/.gitignore b/.gitignore
index f17e925c..ab853464 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,68 +1,8 @@
-# git ignore file
-# Unix generated files
-.deps/
-.libs/
-.dirstamp
-Makefile
-Makefile.in
-aclocal.m4
-autom4te.cache/
-/build-aux/
-confdefs.h
-conftest
-conftest.c
-conftest.err
-config.*
-config-win32.h
-configure
-configure.tmp
+/build
 doxygen*.tmp
 html/
-libtool
-m4/
-plugins/perl/irc.pm.h
-plugins/perl/xchat.pm.h
-plugins/perl/hexchat.pm.h
-po/Makefile.in.in
-po/POTFILES
-po/remove-potcdate.sed
-po/stamp-*
-osx/Info.plist
-data/man/hexchat.1
-data/pkgconfig/hexchat-plugin.pc
-data/misc/hexchat.appdata.xml
-data/misc/hexchat.desktop
-data/misc/hexchat.desktop.in
-data/misc/htm.desktop
-src/common/dbus/example
-src/common/dbus/org.hexchat.service.service
-src/common/dbus/remote-object-glue.h
-src/common/make-te
-src/common/marshal.*
-src/common/textenums.h
-src/common/textevents.h
-src/fe-gtk/hexchat
-src/fe-gtk/hexchat.rc
-src/fe-gtk/resources.c
-src/fe-gtk/resources.h
-src/fe-text/hexchat-text
-src/htm/Main.resources
-src/htm/thememan.exe
-src/htm/thememan.exe.config
-src/htm/thememan.exe.mdb
-src/htm/thememan
-stamp-h1
-*.a
-*.o
-*.la
-*.lo
-*.gmo
-*.mo
-*.po~
-*.pot
 *.patch
 tags
-src/**/*.plist
 # Win32 generated files
 plugins/wmpa/wmpa_h.h
 plugins/wmpa/wmpa_i.c
@@ -79,10 +19,9 @@ resource.h
 *.suo
 *.user
 *.exe
-#OSX
+# OSX
 osx/HexChat.app
 osx/.HexChat.app
-po/.intltool-merge-cache
 *.zip
 *.dmg
 *.VC.db
diff --git a/.travis.yml b/.travis.yml
index 667c14ec..7e7b4ab0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,16 @@
 sudo: required
-dist: trusty
-language: c
-cache: apt
-compiler: clang
+services: docker
+before_install:
+    - docker pull ubuntu:16.04
+    - docker run --privileged --cidfile=/tmp/cid ubuntu:16.04 /bin/sh -c 'apt-get update && apt-get install -y meson/xenial-backports libcanberra-dev libdbus-glib-1-dev libglib2.0-dev libgtk2.0-dev libluajit-5.1-dev libnotify-dev libpci-dev libperl-dev libproxy-dev libssl-dev python3-dev mono-devel desktop-file-utils'
+    - docker commit `cat /tmp/cid` hexchat/ubuntu-ci
+    - rm -f /tmp/cid
+install:
+    - docker run -d --privileged --cidfile=/tmp/cid --volume=${PWD}:/opt/hexchat hexchat/ubuntu-ci /bin/systemd --system
 script:
-    - ./autogen.sh --enable-textfe --with-theme-manager --enable-static-analysis
-    - make V=1 -j$(nproc)
+    - docker exec `cat /tmp/cid` /bin/sh -c 'meson /opt/hexchat /opt/hexchat-build -Dwith-text=true -Dwith-theme-manager=true && ninja -C /opt/hexchat-build install'
+after_script:
+    - docker kill `cat /tmp/cid`
 notifications:
     irc:
         channels: "chat.freenode.net#hexchat-devel"
@@ -13,24 +18,3 @@ notifications:
         on_success: change
 matrix:
      fast_finish: true
-addons:
-    apt:
-        packages:
-            - automake
-            - autoconf-archive
-            - imagemagick
-            - intltool
-            - libcanberra-dev
-            - libdbus-glib-1-dev
-            - libglib2.0-dev
-            - libgtk2.0-dev
-            - libluajit-5.1-dev
-            - libnotify-dev
-            - libpci-dev
-            - libperl-dev
-            - libproxy-dev
-            - libssl-dev
-            - libtool
-            - monodevelop
-            - mono-devel
-            - python-dev
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index a8899ff2..00000000
--- a/Makefile.am
+++ /dev/null
@@ -1,7 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-ACLOCAL_AMFLAGS = -I m4
-
-SUBDIRS = po src plugins data
-
-EXTRA_DIST = autogen.sh Doxyfile readme.md
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index df42d3bd..00000000
--- a/autogen.sh
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-# Run this to generate all the initial makefiles, etc.
-
-srcdir=`dirname $0`
-test -z "$srcdir" && srcdir=.
-
-(test -f $srcdir/src/common/hexchat.c) || {
-	echo -n "**Error**: Directory "\`$srcdir\'" does not look like the top-level directory"
-	exit 1
-}
-
-if [ "$1" = "--copy" ]; then
-	shift
-	aclocal --force --install || exit 1
-	intltoolize --force --copy --automake || exit 1
-	autoreconf --force --install --include=m4 -Wno-portability || exit 1
-else
-	intltoolize --automake || exit 1
-	autoreconf --install --symlink --include=m4 -Wno-portability || exit 1
-fi
-
-if [ "$NOCONFIGURE" = "" ]; then
-        $srcdir/configure "$@" || exit 1
-
-        if [ "$1" = "--help" ]; then exit 0 else
-                echo "Now type \`make\' to compile" || exit 1
-        fi
-else
-        echo "Skipping configure process."
-fi
-
-set +x
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index fc4f8e77..00000000
--- a/configure.ac
+++ /dev/null
@@ -1,798 +0,0 @@
-dnl Process this file with autoconf to produce a configure script.
-
-AC_INIT([HexChat],[2.12.4])
-
-AC_PREREQ([2.64])
-AC_COPYRIGHT([Copyright (C) 1998-2010 Peter Zelezny])
-
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_SRCDIR([configure.ac])
-
-AC_CONFIG_MACRO_DIR([m4])
-AC_CONFIG_AUX_DIR([build-aux])
-
-AM_INIT_AUTOMAKE([1.11.1 dist-xz no-dist-gzip subdir-objects no-define foreign])
-AM_SILENT_RULES([yes])
-
-AC_DEFUN([HEX_CHECK_MACRO], [m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined. Is ]$2[ installed?])])])
-
-HEX_CHECK_MACRO([AX_APPEND_COMPILE_FLAGS], [autoconf-archive])
-HEX_CHECK_MACRO([PKG_PROG_PKG_CONFIG], [pkg-config])
-
-AX_IS_RELEASE([minor-version])
-AX_CHECK_ENABLE_DEBUG([yes])
-
-AC_USE_SYSTEM_EXTENSIONS
-AM_MAINTAINER_MODE([enable])
-AC_PROG_CC
-AM_PROG_CC_C_O
-AC_PROG_CPP
-AC_PROG_OBJC
-AM_PROG_AS
-AM_PROG_AR
-LT_PREREQ([2.2.6])
-LT_INIT([disable-static])
-AC_PATH_PROG(MDTOOL, mdtool, no)
-PKG_PROG_PKG_CONFIG
-
-dnl -----------------------------------------------------------
-dnl Language Support
-dnl -----------------------------------------------------------
-GETTEXT_PACKAGE=hexchat
-AC_SUBST(GETTEXT_PACKAGE)
-AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[Gettext package name])
-IT_PROG_INTLTOOL([0.40.0])
-AM_GLIB_GNU_GETTEXT
-
-dnl displaced from acconfig.h
-AH_VERBATIM([OLD_PERL],[#undef OLD_PERL])
-AH_VERBATIM([PREFIX],[#undef PREFIX])
-AH_VERBATIM([HEXCHATLIBDIR],[#undef HEXCHATLIBDIR])
-AH_VERBATIM([HEXCHATSHAREDIR],[#undef HEXCHATSHAREDIR])
-AH_VERBATIM([USE_LIBPROXY],[#undef USE_LIBPROXY])
-AH_VERBATIM([HAVE_LIBPCI],[#undef HAVE_LIBPCI])
-AH_VERBATIM([HAVE_ISO_CODES],[#undef HAVE_ISO_CODES])
-AH_VERBATIM([HAVE_GTK_MAC],[#undef HAVE_GTK_MAC])
-AH_VERBATIM([USE_LIBNOTIFY],[#undef USE_LIBNOTIFY])
-AH_VERBATIM([USE_LIBCANBERRA],[#undef USE_LIBCANBERRA])
-AH_VERBATIM([USE_OPENSSL],[#undef USE_OPENSSL])
-AH_VERBATIM([USE_PLUGIN],[#undef USE_PLUGIN])
-AH_VERBATIM([USE_SIGACTION],[#undef USE_SIGACTION])
-AH_VERBATIM([USING_FREEBSD],[#undef USING_FREEBSD])
-AH_VERBATIM([USING_LINUX],[#undef USING_LINUX])
-AH_VERBATIM([socklen_t],[#undef socklen_t])
-AH_VERBATIM([USE_DBUS],[#undef USE_DBUS])
-
-AC_PATH_PROG(sedpath, sed)
-AS_IF([test "_$sedpath" = _], [
-	AC_MSG_ERROR(Cannot find sed: I need it!)
-])
-
-AC_PATH_PROG(unamepath, uname)
-AS_IF([test "_$unamepath" = _], [
-	system="unknown"
-], [
-	AC_MSG_CHECKING(system type)
-	system=`$unamepath -s`
-	AC_MSG_RESULT($system)
-	AS_IF([test "$system" = "Linux"], [
-		AC_DEFINE(USING_LINUX)
-	], [test "$system" = "FreeBSD"], [
-		AC_DEFINE(USING_FREEBSD)
-	])
-])
-
-platform_win32=no
-platform_osx=no
-AS_CASE([$host_os],
-	[*mingw*|*cygwin*|*msys*], [
-		platform_win32=yes
-	],
-	[darwin*], [
-		platform_osx=yes
-	]
-)
-
-dnl *********************************************************************
-dnl ** configure switches ***********************************************
-dnl *********************************************************************
-
-AC_ARG_ENABLE(openssl,
-	[AS_HELP_STRING([--enable-openssl[=PATH]],[enable use of openSSL])],
-        openssl=$enableval, openssl=yes)
-
-AC_ARG_ENABLE(gtkfe,
-	[AS_HELP_STRING([--disable-gtkfe],[disable building gtk frontend])],
-        gtkfe=$enableval, gtkfe=yes)
-
-AC_ARG_ENABLE(textfe,
-	[AS_HELP_STRING([--enable-textfe],[build the text frontend (default: no)])],
-        textfe=$enableval, textfe=no)
-
-AC_ARG_ENABLE(python,
-	[AS_HELP_STRING([--enable-python=pythonversion],[build the python plugin; possible values: "python2", "python3" or specific such as "python3.3" (default on, python2)])],
-        python=$enableval, python=python2)
-AS_IF([test "x$python" = "xyes"], [python=python2])
-
-AC_ARG_ENABLE(perl,
-	[AS_HELP_STRING([--disable-perl],[don\'t build the perl plugin])],
-        perl=$enableval, perl=yes)
-
-AC_ARG_ENABLE(lua,
-	[AS_HELP_STRING([--disable-lua],[don\'t build the lua plugin])],
-        lua=$enableval, lua=yes)
-
-AC_ARG_ENABLE(perl_old,
-	[AS_HELP_STRING([--disable-perl_old],[no backwards compatibility for perl plugin])],
-        perl_old=$enableval, perl_old=yes)
-
-AC_ARG_ENABLE(plugin,
-	[AS_HELP_STRING([--disable-plugin],[disable plugin support])],
-        plugin=$enableval, plugin=yes)
-
-AC_ARG_ENABLE(checksum,
-	[AS_HELP_STRING([--disable-checksum],[disable the Checksum plugin])],
-        checksum=$enableval, checksum=yes)
-
-AC_ARG_ENABLE(fishlim,
-	[AS_HELP_STRING([--disable-fishlim],[disable the FiSHLiM plugin])],
-        fishlim=$enableval, fishlim=yes)
-
-AC_ARG_ENABLE(sysinfo,
-	[AS_HELP_STRING([--disable-sysinfo],[disable the SysInfo plugin])],
-        sysinfo=$enableval, sysinfo=yes)
-
-AC_ARG_ENABLE(dbus,
-	[AS_HELP_STRING([--disable-dbus],[disable DBUS support])],
-        dbus=$enableval, dbus=yes)
-
-AC_ARG_ENABLE(libnotify,
-	[AS_HELP_STRING([--disable-libnotify],[disable libnotify support])],
-        libnotify=$enableval, libnotify=yes)
-
-AC_ARG_ENABLE(libcanberra,
-	[AS_HELP_STRING([--disable-libcanberra],[disable libcanberra support])],
-		libcanberra=$enableval, libcanberra=yes)
-
-AC_ARG_ENABLE(libproxy,
-	[AS_HELP_STRING([--disable-libproxy],[disable libproxy support (default: auto)])],
-        libproxy=$enableval, libproxy=auto)
-
-AC_ARG_ENABLE(isocodes,
-	[AS_HELP_STRING([--disable-isocodes],[disable iso-codes with spell-check])],
-        isocodes=$enableval, isocodes=yes)
-
-AC_ARG_ENABLE(static-analysis,
-	[AS_HELP_STRING([--enable-static-analysis],[if using clang run static analysis during build (default: no)])],
-        analyze=$enableval, analyze=no)
-
-AC_ARG_WITH(theme-manager,
-	[AS_HELP_STRING([--with-theme-manager],[compile theme manager (needs monodevelop, default: off)])],
-		theme_manager=$withval, theme_manager=no)
-
-AC_ARG_ENABLE(stack-protector,
-	[AS_HELP_STRING([--disable-stack-protector],[disable building with stack-protector])],
-        stack_protector=$enableval, stack_protector=yes)
-
-
-dnl *********************************************************************
-dnl ** THEME-MANAGER ****************************************************
-dnl *********************************************************************
-AS_IF([test "x$theme_manager" != "xno"], [
-	AS_IF([test "x$MDTOOL" = "xno"], [
-		AC_MSG_ERROR([No "mdtool" found, you need to install monodevelop!])
-	])
-])
-
-
-dnl *********************************************************************
-dnl ** GLIB *************************************************************
-dnl *********************************************************************
-
-AM_PATH_GLIB_2_0([2.34.0], [], [AC_MSG_ERROR([Glib not found!])], [gmodule gobject gio])
-COMMON_CFLAGS="$GLIB_CFLAGS -DG_DISABLE_SINGLE_INCLUDES"
-COMMON_LIBS="$GLIB_LIBS"
-AC_DEFINE([GLIB_VERSION_MIN_REQUIRED], [GLIB_VERSION_2_34], [Dont warn using older APIs])
-AC_DEFINE([GLIB_VERSION_MAX_ALLOWED], [GLIB_VERSION_2_34], [Prevents using newer APIs])
-
-dnl *********************************************************************
-dnl ** GTK **************************************************************
-dnl *********************************************************************
-
-AS_IF([test "$gtkfe" = yes], [
-	PKG_CHECK_MODULES(GTK, [gtk+-2.0 >= 2.24.0], [
-		GUI_LIBS="$GUI_LIBS $GTK_LIBS"
-		GUI_CFLAGS="$GUI_CFLAGS $GTK_CFLAGS -DGDK_PIXBUF_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_DEPRECATED"
-	], [
-		gtkfe=no
-	])
-])
-
-dnl *********************************************************************
-dnl ** MAC_INTEGRATION **************************************************
-dnl *********************************************************************
-
-_gdk_tgt=`$PKG_CONFIG --variable=target gdk-2.0`
-AS_IF([test "x$_gdk_tgt" = xquartz], [
-	PKG_CHECK_MODULES(GTK_MAC, gtk-mac-integration-gtk2, [
-		GUI_LIBS="$GUI_LIBS $GTK_MAC_LIBS"
-		GUI_CFLAGS="$GUI_CFLAGS $GTK_MAC_CFLAGS"
-		AC_DEFINE(HAVE_GTK_MAC)
-	])
-])
-
-
-dnl *********************************************************************
-dnl ** Lua **************************************************************
-dnl *********************************************************************
-
-AS_IF([test "$lua" = yes], [
-	AC_MSG_CHECKING(for plugin interface used by lua)
-	AS_IF([test "$plugin" = yes], [
-		AC_MSG_RESULT([yes])
-
-		m4_define_default([_LUA_LIST], [luajit lua lua5.3 lua53 lua5.2 lua52 lua5.1 lua51])
-
-		AC_ARG_VAR([LUA], [The Lua pkgconfig name, e.g. luajit or lua5.2])
-		AS_IF([test "x$LUA" = 'x'], [
-			for lua_var in _LUA_LIST; do
-				$PKG_CONFIG --exists $lua_var || continue
-				LUA=$lua_var
-				break
-			done
-			AS_IF([test "x$LUA" = 'x'], [
-				AC_MSG_ERROR([Failed to find lua])
-			])
-		])
-
-		PKG_CHECK_MODULES([LUA], $LUA, [
-			AC_SUBST([LUA_CFLAGS])
-			AC_SUBST([LUA_LIBS])
-		])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for lua])
-		lua=no
-	])
-])
-
-dnl *********************************************************************
-dnl ** PERL *************************************************************
-dnl *********************************************************************
-
-AS_IF([test "$perl" = yes], [
-	AC_MSG_CHECKING(for plugin interface used by Perl)
-	AS_IF([test "$plugin" = yes], [
-		AC_MSG_RESULT([yes])
-
-		AX_PERL_EXT_FLAGS([PERL_CFLAGS], [PERL_LDFLAGS])
-		original_cflags="$CFLAGS"
-		original_ldflags="$LDFLAGS"
-		CFLAGS="$PERL_CFLAGS"
-		LDFLAGS="$PERL_LDFLAGS"
-		AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-				#define PERL_NO_INLINE_FUNCTIONS
-				#include <EXTERN.h>
-				#include <perl.h>
-			]], [[]])],[perl_is_usable=yes],[perl_is_usable=no])
-		CFLAGS="$original_cflags"
-		LDFLAGS="$original_ldflags"
-		AS_IF([test "$perl_is_usable" = "no"], [
-			AC_MSG_WARN([perl test failed to compile, disabling])
-			perl=no
-		], [
-			AC_MSG_CHECKING([if perl plugin will be backward compatible])
-			AS_IF([test "$perl_old" = "yes"], [
-				  AC_MSG_RESULT([yes])
-				  AC_DEFINE(OLD_PERL)
-			], [
-				  AC_MSG_RESULT([no])
-			])
-		])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Perl])
-		perl=no
-	])
-])
-
-dnl *********************************************************************
-dnl ** PYTHON ***********************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$python" != xno], [
-	AC_MSG_CHECKING(for plugin interface used by Python)
-	AS_IF([test "$plugin" = yes], [
-		AC_MSG_RESULT([yes])
-		AS_CASE([$python],
-			dnl set python2 default here
-			[python2], [
-				PYTHON_VERSION=2
-				AX_PYTHON_DEVEL([>= '2.7'])
-			],
-			dnl set python3 default here
-			[python3], [
-				PYTHON_VERSION=3
-				AX_PYTHON_DEVEL([>= '3.3'])
-			],
-			dnl add broken versions here
-			[python2.5|python2.6|python3.1|python3.2], [
-				AC_MSG_WARN(Unsupported Python version ${python}!)
-			],
-			dnl user supplied version
-			[python*], [
-				PYTHON_VERSION="${python#python}"
-				AX_PYTHON_DEVEL()
-			],[
-				AC_MSG_WARN(Unsupported Python ${python}!)
-			]
-		)
-		AC_MSG_CHECKING(Python version)
-
-		AS_IF([test "$ac_python_version" != ""], [
-			AC_MSG_RESULT($ac_python_version)
-			python="python-${ac_python_version}"
-		], [
-			AC_MSG_RESULT(Not found)
-			python=no
-		])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for Python])
-		python=no
-	])
-])
-
-dnl *********************************************************************
-dnl ** IPv6 *************************************************************
-dnl *********************************************************************
-
-dnl purely for Solaris
-AC_CHECK_FUNC(select, ,
-	AC_CHECK_LIB(socket, select, ,
-		AC_CHECK_LIB(nsl, select, ,
-			AC_CHECK_LIB(inet, select, ,
-				AC_CHECK_LIB(cposix, select, ,
-					AC_CHECK_LIB(net, select, ,
-						AC_MSG_WARN(i can not find select.  you might need to help me)))))))
-AC_CHECK_LIB(socket, select)
-
-AC_CHECK_FUNCS(getaddrinfo, have_getaddrinfo=yes)
-AC_MSG_CHECKING(whether IPv6 is supported)
-AS_IF([test "$have_getaddrinfo" = yes], [
-	AC_MSG_RESULT(yes)
-], [
-	AC_MSG_RESULT(no)
-	AC_MSG_ERROR(ipv6 support not found!)
-])
-
-dnl *********************************************************************
-dnl ** OPENSSL **********************************************************
-dnl *********************************************************************
-
-
-AS_IF([test "$openssl" != no], [
-	PKG_CHECK_MODULES(OPENSSL, [openssl >= 0.9.8], [
-		AC_DEFINE(USE_OPENSSL)
-		openssl=yes
-		COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
-		COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
-	], [
-		unset openssl_path ac_cv_lib_ssl_SSL_new ac_cv_header_openssl_ssl_h
-		AS_IF([test "$openssl" != yes], [
-			openssl_path=$openssl
-		])
-		openssl=no
-		OPENSSL_LIBS="-lcrypto"
-		AS_IF([test -n "$openssl_path"], [
-			OPENSSL_LIBS="-L$openssl_path/lib $OPENSSL_LIBS"
-		])
-		SAVED_LIBS=$LIBS
-		LIBS="$LIBS $OPENSSL_LIBS"
-		AC_CHECK_LIB(ssl, SSL_new, [
-			AS_IF([test -n "$openssl_path"], [
-				OPENSSL_CFLAGS="-I$openssl_path/include"
-			])
-			SAVED_CFLAGS=$CFLAGS
-			CFLAGS="$CFLAGS $OPENSSL_CFLAGS"
-			AC_CHECK_HEADERS(openssl/ssl.h, [
-				openssl=yes
-				AC_DEFINE(USE_OPENSSL)
-				OPENSSL_LIBS="$OPENSSL_LIBS -lssl"
-
-				COMMON_LIBS="$COMMON_LIBS $OPENSSL_LIBS"
-				COMMON_CFLAGS="$COMMON_CFLAGS $OPENSSL_CFLAGS"
-			])
-			CFLAGS=$SAVED_CFLAGS
-		])
-		LIBS=$SAVED_LIBS
-	])
-
-	AS_IF([test "$openssl" = yes], [
-		dnl Test for various functions that are not available in LibreSSL
-		SAVED_LIBS="$LIBS"
-		LIBS="$OPENSSL_LIBS"
-		AC_CHECK_FUNCS([SSL_CTX_get_ssl_method X509_get_signature_nid DH_set0_pqg DH_get0_key DH_set0_key])
-		LIBS="$SAVED_LIBS"
-	])
-])
-
-dnl *********************************************************************
-dnl ** LIBPROXY *********************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$libproxy" = "xyes" -o "x$libproxy" = "xauto"], [
-	PKG_CHECK_MODULES([LIBPROXY], [libproxy-1.0], [
-		COMMON_LIBS="$COMMON_LIBS $LIBPROXY_LIBS"
-		COMMON_CFLAGS="$COMMON_CFLAGS $LIBPROXY_CFLAGS"
-		AC_DEFINE(USE_LIBPROXY)
-		libproxy=yes
-	], [
-		AS_IF([test "x$libproxy" = "xyes"], [
-			AC_MSG_ERROR(Cannot find libproxy!)
-		])
-		libproxy=no
-	])
-], [
-	libproxy=no
-])
-
-dnl *********************************************************************
-dnl ** PLUGIN ***********************************************************
-dnl *********************************************************************
-
-AS_IF([test "$plugin" = yes], [
-	AC_DEFINE(USE_PLUGIN)
-	PLUGIN_LDFLAGS="-avoid-version"
-	AS_IF([test "$platform_win32" = yes], [
-		PLUGIN_LDFLAGS="$PLUGIN_LDFLAGS -no-undefined"
-	])
-])
-
-dnl *********************************************************************
-dnl ** Checksum *********************************************************
-dnl *********************************************************************
-
-AS_IF([test "$checksum" != "no"], [
-	checksum=no
-	AC_MSG_CHECKING(for plugin interface used by Checksum)
-	AS_IF([test "$plugin" = yes], [
-		checksum=yes
-		AC_MSG_RESULT([yes])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
-	])
-])
-
-dnl *********************************************************************
-dnl ** FiSHLiM **********************************************************
-dnl *********************************************************************
-
-AS_IF([test "$fishlim" != "no"], [
-	fishlim=no
-	AC_MSG_CHECKING(for plugin interface used by FiSHLiM)
-	AS_IF([test "$plugin" = yes], [
-		AC_MSG_RESULT([yes])
-		AC_MSG_CHECKING(for OpenSSL used by FiSHLiM)
-		AS_IF([test "$openssl" = yes], [
-			fishlim=yes
-			AC_MSG_RESULT([yes])
-		], [
-			AC_MSG_RESULT([OpenSSL cannot be found, use the --enable-openssl option])
-		])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option])
-	])
-])
-
-dnl *********************************************************************
-dnl ** SYSINFO **********************************************************
-dnl *********************************************************************
-
-AS_IF([test "$sysinfo" != "no"], [
-	AC_MSG_CHECKING(for plugin interface used by SysInfo)
-	AS_IF([test "$plugin" = yes], [
-		AC_MSG_RESULT([yes])
-		AS_IF([test "$platform_osx" = yes], [
-			sysinfo=yes
-		], [
-			PKG_CHECK_MODULES(LIBPCI, libpci >= 3.0.0, [
-				sysinfo=yes
-				AC_DEFINE(HAVE_LIBPCI)
-			], [sysinfo=no])
-		])
-	], [
-		AC_MSG_RESULT([plugins are disabled, use the --enable-plugin option for SysInfo])
-		sysinfo=no
-	])
-])
-
-dnl #######################################################################
-dnl # Check for DBUS libraries
-dnl #######################################################################
-
-AS_IF([test "x$dbus" = "xyes"], [
-	PKG_CHECK_MODULES(DBUS, [dbus-1 >= 0.60 dbus-glib-1 >= 0.60 gthread-2.0], dbus=yes, [
-		dbus=no
-	])
-	AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)
-	AS_IF([test "x$DBUS_BINDING_TOOL" = "xno" || test "x$dbus" = "xno"], [
-		dbus="no"
-	], [
-		COMMON_LIBS="$COMMON_LIBS $DBUS_LIBS"
-		COMMON_CFLAGS="$COMMON_CFLAGS $DBUS_CFLAGS"
-		AC_DEFINE(USE_DBUS)
-
-		AS_AC_EXPAND(DBUS_SERVICES_DIR, "$datadir/dbus-1/services")
-		AC_SUBST(DBUS_SERVICES_DIR)
-		AC_DEFINE_UNQUOTED(DBUS_SERVICES_DIR, "$DBUS_SERVICES_DIR", [Where services dir for DBUS is])
-	])
-])
-
-dnl *********************************************************************
-dnl ** LIBNOTIFY ********************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$libnotify" = "xyes"], [
-	PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= 0.4, [], [
-		libnotify=no
-	])
-	AS_IF([test "$libnotify" != "no"], [
-		GUI_LIBS="$GUI_LIBS $LIBNOTIFY_LIBS"
-		GUI_CFLAGS="$GUI_CFLAGS $LIBNOTIFY_CFLAGS"
-		AC_DEFINE(USE_LIBNOTIFY)
-	])
-])
-
-dnl *********************************************************************
-dnl ** LIBCANBERRA ******************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$libcanberra" = "xyes"], [
-	PKG_CHECK_MODULES(LIBCANBERRA, libcanberra >= 0.22, [], [
-		libcanberra=no
-	])
-	AS_IF([test "$libcanberra" != "no"], [
-		COMMON_LIBS="$COMMON_LIBS $LIBCANBERRA_LIBS"
-		COMMON_CFLAGS="$COMMON_CFLAGS $LIBCANBERRA_CFLAGS"
-		AC_DEFINE(USE_LIBCANBERRA)
-	])
-])
-
-dnl *********************************************************************
-dnl ** SPELL ************************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$isocodes" = "xyes"], [
-	PKG_CHECK_MODULES(ISOCODES, "iso-codes", [
-		iso_codes_prefix=`$PKG_CONFIG --variable=prefix iso-codes 2>/dev/null || echo /usr`
-    	AC_MSG_NOTICE([iso-codes prefix: $iso_codes_prefix])
-    	AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX], ["$iso_codes_prefix"], [ISO codes prefix])
-    	AC_DEFINE_UNQUOTED([ISO_CODES_LOCALEDIR], ["$iso_codes_prefix/share/locale"], [ISO codes locale dir])
-    	AC_DEFINE([HAVE_ISO_CODES], [1], [iso-codes available])
-    	], [
-    	isocodes=no
-    	AC_MSG_WARN(iso-codes not found!)
-    ])
-])
-
-dnl *********************************************************************
-dnl ** Static Analysis **************************************************
-dnl *********************************************************************
-
-AS_IF([test "x$analyze" = "xyes"], [
-	AS_IF([test "$CC" != "clang"], [
-		AC_MSG_WARN(CC is not clang for static analysis)
-		analyze=no
-	])
-])
-
-dnl *********************************************************************
-dnl ** CONDITIONALS *****************************************************
-dnl *********************************************************************
-
-AM_CONDITIONAL(USE_OPENSSL, test "x$openssl" = "xyes")
-AM_CONDITIONAL(USE_LIBNOTIFY, test "x$libnotify" = "xyes")
-AM_CONDITIONAL(USE_LIBCANBERRA, test "x$libcanberra" = "xyes")
-AM_CONDITIONAL(DO_TEXT, test "x$textfe" = "xyes")
-AM_CONDITIONAL(DO_GTK, test "x$gtkfe" = "xyes")
-AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes")
-AM_CONDITIONAL(DO_LUA, test "x$lua" = "xyes")
-AM_CONDITIONAL(DO_PYTHON, test "x$python" != "xno")
-AM_CONDITIONAL(DO_PLUGIN, test "x$plugin" = "xyes")
-AM_CONDITIONAL(DO_CHECKSUM, test "x$checksum" = "xyes")
-AM_CONDITIONAL(DO_FISHLIM, test "x$fishlim" = "xyes")
-AM_CONDITIONAL(DO_SYSINFO, test "x$sysinfo" = "xyes")
-AM_CONDITIONAL(DO_STATIC_ANALYSIS, test "x$analyze" = "xyes")
-AM_CONDITIONAL(USE_DBUS, test "x$dbus" = "xyes")
-AM_CONDITIONAL(HAVE_ISO_CODES, test "x$isocodes" = "xyes")
-AM_CONDITIONAL(HAVE_GTK_MAC, test "x$_gdk_tgt" = xquartz)
-AM_CONDITIONAL(WITH_TM, test "x$theme_manager" != "xno")
-AM_CONDITIONAL(PLATFORM_OSX, test "x$platform_osx" = "xyes")
-
-dnl *********************************************************************
-dnl ** CFLAGS ***********************************************************
-dnl *********************************************************************
-
-AX_APPEND_COMPILE_FLAGS([\
-	-pipe \
-	-funsigned-char \
-	-fPIE \
-	-fPIC \
-	-Wall \
-	-Wextra \
-	-Wstrict-prototypes \
-	-Wno-unused-parameter \
-	-Wno-sign-compare \
-	-Wno-pointer-sign \
-	-Wno-missing-field-initializers \
-	-Wno-unused-result \
-	-Werror=format-security \
-	-Werror=init-self \
-	-Werror=declaration-after-statement \
-	-Werror=missing-include-dirs \
-	-Werror=date-time \
-	-Werror=implicit-function-declaration \
-	-Werror=pointer-arith \
-])
-
-AS_IF([test "$stack_protector" = "yes"], [
-	AX_APPEND_COMPILE_FLAGS([ \
-		-fstack-protector-strong \
-	])
-])
-
-AX_APPEND_LINK_FLAGS([ \
-	-pie \
-	-Wl,-z,relro \
-	-Wl,-z,now \
-])
-
-dnl *********************************************************************
-dnl ** FUNCTIONS/LIBS/CFLAGS ********************************************
-dnl *********************************************************************
-
-AC_MSG_CHECKING(for modern sigaction)
-dnl libc5 on linux and FreeBSD 3.x doesn\'t have siginfo_t
-dnl and the sa_sigation field.
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <signal.h>]], [[struct sigaction act;
-	 siginfo_t *si;
-	 act.sa_sigaction = 0;]])],[
-		AC_MSG_RESULT(yes)
-		AC_DEFINE(USE_SIGACTION) 
-	],[AC_MSG_RESULT(no)])
-
-AC_CHECK_FUNCS(memrchr)
-
-AC_CHECK_FUNC(gethostbyname, ,
-	AC_CHECK_LIB(resolv, gethostbyname, ,
-		AC_CHECK_LIB(nsl, gethostbyname)))
-
-AC_CHECK_FUNC(gethostname, , AC_CHECK_LIB(nsl, gethostname))
-
-dnl necessary for IRIX
-AC_CHECK_HEADERS(strings.h)
-
-dnl Check for type in sys/socket.h - from Squid source (GPL)
-AC_CACHE_CHECK(for socklen_t, ac_cv_type_socklen_t, [
-AC_EGREP_CPP([socklen_t[^a-zA-Z_0-9]], [#include <sys/types.h>
-#include <sys/socket.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#endif],
-ac_cv_type_socklen_t=yes,
-ac_cv_type_socklen_t=no)
-])
-AS_IF([test $ac_cv_type_socklen_t = no], [
-	AC_DEFINE(socklen_t, int)
-])
-
-dnl Mac OS X and Darwin use lookupd, which caches DNS queries by default
-AC_EGREP_CPP(lookupd, dnl
-[#if (defined(__APPLE__) && defined(__MACH__))
-	lookupd
-#endif], AC_DEFINE([LOOKUPD],1,[Define to 1 if the system uses lookupd]))
-
-dnl freebsd needs this
-LIBS="$LIBS $INTLLIBS"
-
-GUI_LIBS="$GUI_LIBS $COMMON_LIBS"
-
-dnl make these visible to all Makefiles
-AC_SUBST(GUI_LIBS)
-AC_SUBST(GUI_CFLAGS)
-AC_SUBST(COMMON_LIBS)
-AC_SUBST(COMMON_CFLAGS)
-AC_SUBST(PERL_CFLAGS)
-AC_SUBST(PERL_LDFLAGS)
-AC_SUBST(PYTHON_CPPFLAGS)
-AC_SUBST(PYTHON_LIBS)
-AC_SUBST(DBUS_CFLAGS)
-AC_SUBST(DBUS_LIBS)
-AC_SUBST(OPENSSL_LIBS)
-AC_SUBST(OPENSSL_CFLAGS)
-AC_SUBST(PLUGIN_LDFLAGS)
-
-m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
-
-dnl for plugin.c and pixmaps.c
-AS_IF([test "x$prefix" = xNONE], [
-	prefix="$ac_default_prefix"
-])
-AS_IF([test "x$exec_prefix" = xNONE], [
-	exec_prefix="$prefix"
-])
-
-AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
-
-AS_AC_EXPAND(HEXCHATLIBDIR, "${libdir}/hexchat/plugins")
-AC_DEFINE_UNQUOTED(HEXCHATLIBDIR, "$HEXCHATLIBDIR")
-
-AS_AC_EXPAND(HEXCHATSHAREDIR, "$datadir")
-AC_DEFINE_UNQUOTED(HEXCHATSHAREDIR, "$HEXCHATSHAREDIR")
-
-dnl for plugins/xxx/Makefile.am
-hexchatlibdir=${libdir}/hexchat/plugins
-AC_SUBST(hexchatlibdir)
-
-AC_CONFIG_FILES([
-Makefile
-data/Makefile
-data/icons/Makefile
-data/misc/Makefile
-data/man/Makefile
-data/man/hexchat.1
-data/pkgconfig/Makefile
-data/pkgconfig/hexchat-plugin.pc
-src/Makefile
-src/common/Makefile
-src/common/dbus/Makefile
-src/fe-text/Makefile
-src/fe-gtk/Makefile
-src/htm/Makefile
-src/htm/thememan
-osx/Info.plist
-plugins/Makefile
-plugins/lua/Makefile
-plugins/python/Makefile
-plugins/perl/Makefile
-plugins/checksum/Makefile
-plugins/fishlim/Makefile
-plugins/sysinfo/Makefile
-po/Makefile.in
-])
-
-AC_OUTPUT
-
-echo
-echo HexChat $VERSION
-echo
-echo GTK+ interface ........ : $gtkfe
-echo Text interface ........ : $textfe
-echo Theme manager ......... : $theme_manager
-echo
-echo OpenSSL support ....... : $openssl
-echo D-Bus support ......... : $dbus
-echo libnotify support ..... : $libnotify
-echo libcanberra support ... : $libcanberra
-echo Plugin interface ...... : $plugin
-echo libproxy support ...... : $libproxy
-echo
-echo Lua ................... : $lua \($LUA\)
-echo Perl .................. : $perl
-echo Python ................ : $python
-echo
-echo Checksum .............. : $checksum
-echo FiSHLiM ............... : $fishlim
-echo SysInfo ............... : $sysinfo
-echo
-echo Debug mode ............ : $enable_debug
-echo
-echo The binary will be installed in $prefix/bin
-echo
-
-if test "$gtkfe" = no; then
-	echo Warning: The GTK \(GUI\) frontend will not be built.
-	echo
-fi
-
-echo configure complete, now type \'make\' and pray.
-echo
diff --git a/data/Makefile.am b/data/Makefile.am
deleted file mode 100644
index b5077d24..00000000
--- a/data/Makefile.am
+++ /dev/null
@@ -1,16 +0,0 @@
-SUBDIRS =
-
-if DO_PLUGIN
-SUBDIRS += pkgconfig
-endif
-
-if DO_GTK
-SUBDIRS += icons misc man
-else
-if WITH_TM
-SUBDIRS += misc
-endif
-endif
-
-EXTRA_DIST = \
-	hexchat.gresource.xml
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
deleted file mode 100644
index 05eb59d5..00000000
--- a/data/icons/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-icon_DATA = hexchat.png
-icondir = $(datadir)/icons/hicolor/48x48/apps
-
-hicolor_DATA = hexchat.svg
-hicolordir = $(datadir)/icons/hicolor/scalable/apps
-
-UPDATE_ICON_CACHE = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor || :
-
-install-data-hook:
-	$(UPDATE_ICON_CACHE);
-
-uninstall-hook:
-	$(UPDATE_ICON_CACHE);
-
-EXTRA_DIST = $(icon_DATA) $(hicolor_DATA)
diff --git a/data/icons/meson.build b/data/icons/meson.build
new file mode 100644
index 00000000..d7926e83
--- /dev/null
+++ b/data/icons/meson.build
@@ -0,0 +1,9 @@
+icondir = join_paths(get_option('datadir'), 'icons/hicolor')
+install_data(
+  'hexchat.png',
+  install_dir: join_paths(icondir, '48x48/apps')
+)
+install_data(
+  'hexchat.svg',
+  install_dir: join_paths(icondir, 'scalable/apps')
+)
diff --git a/data/man/Makefile.am b/data/man/Makefile.am
deleted file mode 100644
index a967701c..00000000
--- a/data/man/Makefile.am
+++ /dev/null
@@ -1,3 +0,0 @@
-man_MANS = hexchat.1
-
-EXTRA_DIST = hexchat.1.in
diff --git a/data/man/meson.build b/data/man/meson.build
new file mode 100644
index 00000000..8f07f558
--- /dev/null
+++ b/data/man/meson.build
@@ -0,0 +1,10 @@
+man_conf = configuration_data()
+man_conf.set('VERSION', meson.project_version())
+
+configure_file(
+  input: 'hexchat.1.in',
+  output: 'hexchat.1',
+  configuration: man_conf,
+  install: true,
+  install_dir: join_paths(get_option('mandir'), 'man1')
+)
diff --git a/data/meson.build b/data/meson.build
new file mode 100644
index 00000000..b905c314
--- /dev/null
+++ b/data/meson.build
@@ -0,0 +1,11 @@
+if get_option('with-plugin')
+  subdir('pkgconfig')
+endif
+
+if get_option('with-gtk')
+  subdir('icons')
+  subdir('misc')
+  subdir('man')
+elif get_option('with-theme-manager')
+  subdir('misc')
+endif
diff --git a/data/misc/Makefile.am b/data/misc/Makefile.am
deleted file mode 100644
index 45036a3c..00000000
--- a/data/misc/Makefile.am
+++ /dev/null
@@ -1,50 +0,0 @@
-
-appdatadir = $(datadir)/appdata
-appdata_in_files =
-
-if DO_GTK
-appdata_in_files += hexchat.appdata.xml.in
-endif
-
-appdata_DATA = $(appdata_in_files:.xml.in=.xml)
-@INTLTOOL_XML_RULE@
-
-if USE_DBUS
-exec_command = 'hexchat --existing %U'
-else
-exec_command = 'hexchat %U'
-endif
-
-hexchat.desktop.in: hexchat.desktop.in.in
-	$(AM_V_GEN)sed -e s!\@exec_command\@!$(exec_command)! < $< > $@
-
-data_desktopdir = $(datadir)/applications
-data_desktop_in_files =
-
-if DO_GTK
-data_desktop_in_files += hexchat.desktop.in
-endif
-
-if WITH_TM
-data_desktop_in_files += htm.desktop.in
-mime_DATA = htm-mime.xml
-mimedir = $(datadir)/mime/packages
-endif
-
-data_desktop_DATA = $(data_desktop_in_files:.desktop.in=.desktop)
-@INTLTOOL_DESKTOP_RULE@
-
-UPDATE_MIME_DATABASE = update-mime-database "$(datadir)/mime" || :
-UPDATE_DESKTOP_DATABASE = update-desktop-database -q "$(datadir)/applications" || :
-
-install-data-hook:
-	$(UPDATE_MIME_DATABASE);
-	$(UPDATE_DESKTOP_DATABASE);
-
-uninstall-hook:
-	$(UPDATE_MIME_DATABASE);
-	$(UPDATE_DESKTOP_DATABASE);
-
-EXTRA_DIST = hexchat.appdata.xml.in hexchat.desktop.in.in htm.desktop.in htm-mime.xml
-
-CLEANFILES = $(appdata_DATA) $(data_desktop_DATA) hexchat.desktop.in
diff --git a/data/misc/hexchat.appdata.xml.in b/data/misc/hexchat.appdata.xml.in
index 8b5b3ee8..7ffaf3dc 100644
--- a/data/misc/hexchat.appdata.xml.in
+++ b/data/misc/hexchat.appdata.xml.in
@@ -8,8 +8,8 @@
   <translation type="gettext">hexchat</translation>
   <summary>IRC Client</summary>
   <description>
-    <_p>HexChat is an easy to use yet extensible IRC Client. It allows you to securely join multiple networks and talk to users privately or in channels using a customizable interface. You can even transfer files.</_p>
-    <_p>HexChat supports features such as: DCC, SASL, proxies, spellcheck, alerts, logging, custom themes, and Python/Perl scripts.</_p>
+    <p>HexChat is an easy to use yet extensible IRC Client. It allows you to securely join multiple networks and talk to users privately or in channels using a customizable interface. You can even transfer files.</p>
+    <p>HexChat supports features such as: DCC, SASL, proxies, spellcheck, alerts, logging, custom themes, and Python/Perl scripts.</p>
   </description>
   <url type="homepage">http://hexchat.github.io</url>
   <url type="bugtracker">https://github.com/hexchat/hexchat</url>
@@ -19,7 +19,7 @@
   <screenshots>
     <screenshot type="default">
       <image>http://i.imgur.com/tLMguQz.png</image>
-      <_caption>Main Chat Window</_caption>
+      <caption>Main Chat Window</caption>
     </screenshot>
   </screenshots>
   <releases>
diff --git a/data/misc/hexchat.desktop.in.in b/data/misc/hexchat.desktop.in.in
index a778e9b5..a5ff40d8 100644
--- a/data/misc/hexchat.desktop.in.in
+++ b/data/misc/hexchat.desktop.in.in
@@ -1,8 +1,8 @@
 [Desktop Entry]
-_Name=HexChat
-_GenericName=IRC Client
-_Comment=Chat with other people online
-_Keywords=IM;Chat;
+Name=HexChat
+GenericName=IRC Client
+Comment=Chat with other people online
+Keywords=IM;Chat;
 Exec=@exec_command@
 Icon=hexchat
 Terminal=false
@@ -14,5 +14,5 @@ MimeType=x-scheme-handler/irc;x-scheme-handler/ircs;
 Actions=SafeMode;
 
 [Desktop Action SafeMode]
-_Name=Open Safe Mode
+Name=Open Safe Mode
 Exec=hexchat --no-auto --no-plugins
diff --git a/data/misc/htm.desktop.in b/data/misc/htm.desktop.in
index 0971ac77..53cac289 100644
--- a/data/misc/htm.desktop.in
+++ b/data/misc/htm.desktop.in
@@ -1,5 +1,5 @@
 [Desktop Entry]
-_Name=HexChat Theme Manager
+Name=HexChat Theme Manager
 Exec=thememan %f
 Icon=hexchat
 Terminal=false
diff --git a/data/misc/meson.build b/data/misc/meson.build
new file mode 100644
index 00000000..ec79b757
--- /dev/null
+++ b/data/misc/meson.build
@@ -0,0 +1,48 @@
+appdir = join_paths(get_option('datadir'), 'applications')
+
+if get_option('with-gtk')
+  i18n.merge_file(
+    input: 'hexchat.appdata.xml.in',
+    output: 'hexchat.appdata.xml',
+    po_dir: '../../po',
+    install: true,
+    install_dir: join_paths(get_option('datadir'), 'appdata')
+  )
+
+  desktop_conf = configuration_data()
+  if get_option('with-dbus')
+    desktop_conf.set('exec_command', 'hexchat --existing %U')
+  else
+    desktop_conf.set('exec_command', 'hexchat %U')
+  endif
+
+  desktop_file = configure_file(
+    input: 'hexchat.desktop.in.in',
+    output: 'hexchat.desktop.in',
+    configuration: desktop_conf
+  )
+
+  i18n.merge_file(
+    input: desktop_file,
+    output: 'hexchat.desktop',
+    po_dir: '../../po',
+    type: 'desktop',
+    install: true,
+    install_dir: appdir
+  )
+endif
+
+if get_option('with-theme-manager')
+  i18n.merge_file(
+    input: 'htm.desktop.in',
+    output: 'htm.desktop',
+    po_dir: '../../po',
+    type: 'desktop',
+    install: true,
+    install_dir: appdir
+  )
+
+  install_data('htm-mime.xml',
+    install_dir: join_paths(get_option('datadir'), 'mime/packages')
+  )
+endif
diff --git a/data/pkgconfig/Makefile.am b/data/pkgconfig/Makefile.am
deleted file mode 100644
index 7ee0ac95..00000000
--- a/data/pkgconfig/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-pkgcfgdir = $(pkgconfigdir)
-pkgcfg_DATA = hexchat-plugin.pc
-
-EXTRA_DIST = hexchat-plugin.pc.in
diff --git a/data/pkgconfig/meson.build b/data/pkgconfig/meson.build
new file mode 100644
index 00000000..3bacf301
--- /dev/null
+++ b/data/pkgconfig/meson.build
@@ -0,0 +1,14 @@
+pkg_conf = configuration_data()
+prefix = get_option('prefix')
+pkg_conf.set('prefix', prefix)
+pkg_conf.set('VERSION', meson.project_version())
+pkg_conf.set('hexchatlibdir', join_paths(prefix, plugindir))
+pkg_conf.set('includedir', join_paths(prefix, get_option('includedir')))
+
+configure_file(
+  input: 'hexchat-plugin.pc.in',
+  output: 'hexchat-plugin.pc',
+  configuration: pkg_conf,
+  install: true,
+  install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
+)
diff --git a/fedora-mingw64.ini b/fedora-mingw64.ini
new file mode 100644
index 00000000..ce91f777
--- /dev/null
+++ b/fedora-mingw64.ini
@@ -0,0 +1,17 @@
+; dnf install mingw64-{gtk,openssl}
+
+[binaries]
+c = '/usr/bin/x86_64-w64-mingw32-gcc'
+cpp = '/usr/bin/x86_64-w64-mingw32-g++'
+ar = '/usr/bin/x86_64-w64-mingw32-gcc-ar'
+strip = '/usr/bin/x86_64-w64-mingw32-strip'
+pkgconfig = '/usr/bin/x86_64-w64-mingw32-pkg-config'
+
+[properties]
+c_args = ['-DNTDDI_VERSION=NTDDI_WIN7', '-D_WIN32_WINNT=_WIN32_WINNT_WIN7']
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86_64'
+cpu = 'x86_64'
+endian = 'little'
diff --git a/m4/as-ac-expand.m4 b/m4/as-ac-expand.m4
deleted file mode 100644
index 334c0dfa..00000000
--- a/m4/as-ac-expand.m4
+++ /dev/null
@@ -1,40 +0,0 @@
-dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
-dnl
-dnl example
-dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
-dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
-
-AC_DEFUN([AS_AC_EXPAND],
-[
-  EXP_VAR=[$1]
-  FROM_VAR=[$2]
-
-  dnl first expand prefix and exec_prefix if necessary
-  prefix_save=$prefix
-  exec_prefix_save=$exec_prefix
-
-  dnl if no prefix given, then use /usr/local, the default prefix
-  if test "x$prefix" = "xNONE"; then
-    prefix=$ac_default_prefix
-  fi
-  dnl if no exec_prefix given, then use prefix
-  if test "x$exec_prefix" = "xNONE"; then
-    exec_prefix=$prefix
-  fi
-
-  full_var="$FROM_VAR"
-  dnl loop until it doesn't change anymore
-  while true; do
-    new_full_var="`eval echo $full_var`"
-    if test "x$new_full_var" = "x$full_var"; then break; fi
-    full_var=$new_full_var
-  done
-
-  dnl clean up
-  full_var=$new_full_var
-  AC_SUBST([$1], "$full_var")
-
-  dnl restore prefix and exec_prefix
-  prefix=$prefix_save
-  exec_prefix=$exec_prefix_save
-])
diff --git a/m4/ax_check_enable_debug.m4 b/m4/ax_check_enable_debug.m4
deleted file mode 100644
index f99d75fe..00000000
--- a/m4/ax_check_enable_debug.m4
+++ /dev/null
@@ -1,124 +0,0 @@
-# ===========================================================================
-#   http://www.gnu.org/software/autoconf-archive/ax_check_enable_debug.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], [ENABLE DEBUG VARIABLES ...], [DISABLE DEBUG VARIABLES NDEBUG ...], [IS-RELEASE])
-#
-# DESCRIPTION
-#
-#   Check for the presence of an --enable-debug option to configure, with
-#   the specified default value used when the option is not present.  Return
-#   the value in the variable $ax_enable_debug.
-#
-#   Specifying 'yes' adds '-g -O0' to the compilation flags for all
-#   languages. Specifying 'info' adds '-g' to the compilation flags.
-#   Specifying 'profile' adds '-g -pg' to the compilation flags and '-pg' to
-#   the linking flags. Otherwise, nothing is added.
-#
-#   Define the variables listed in the second argument if debug is enabled,
-#   defaulting to no variables.  Defines the variables listed in the third
-#   argument if debug is disabled, defaulting to NDEBUG.  All lists of
-#   variables should be space-separated.
-#
-#   If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
-#   Should be invoked prior to any AC_PROG_* compiler checks.
-#
-#   IS-RELEASE can be used to change the default to 'no' when making a
-#   release.  Set IS-RELEASE to 'yes' or 'no' as appropriate. By default, it
-#   uses the value of $ax_is_release, so if you are using the AX_IS_RELEASE
-#   macro, there is no need to pass this parameter.
-#
-#     AX_IS_RELEASE([git-directory])
-#     AX_CHECK_ENABLE_DEBUG()
-#
-# LICENSE
-#
-#   Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
-#   Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved.
-
-#serial 5
-
-AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
-    AC_BEFORE([$0],[AC_PROG_CC])dnl
-    AC_BEFORE([$0],[AC_PROG_CXX])dnl
-    AC_BEFORE([$0],[AC_PROG_F77])dnl
-    AC_BEFORE([$0],[AC_PROG_FC])dnl
-
-    AC_MSG_CHECKING(whether to enable debugging)
-
-    ax_enable_debug_default=m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))
-    ax_enable_debug_is_release=m4_tolower(m4_normalize(ifelse([$4],,
-                                                              [$ax_is_release],
-                                                              [$4])))
-
-    # If this is a release, override the default.
-    AS_IF([test "$ax_enable_debug_is_release" = "yes"],
-      [ax_enable_debug_default="no"])
-
-    m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
-    m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
-
-    AC_ARG_ENABLE(debug,
-	[AS_HELP_STRING([--enable-debug=]@<:@yes/info/profile/no@:>@,[compile with debugging])],
-	[],enable_debug=$ax_enable_debug_default)
-
-    # empty mean debug yes
-    AS_IF([test "x$enable_debug" = "x"],
-      [enable_debug="yes"])
-
-    # case of debug
-    AS_CASE([$enable_debug],
-      [yes],[
-	AC_MSG_RESULT(yes)
-	CFLAGS="${CFLAGS} -g -O0"
-	CXXFLAGS="${CXXFLAGS} -g -O0"
-	FFLAGS="${FFLAGS} -g -O0"
-	FCFLAGS="${FCFLAGS} -g -O0"
-	OBJCFLAGS="${OBJCFLAGS} -g -O0"
-      ],
-      [info],[
-	AC_MSG_RESULT(info)
-	CFLAGS="${CFLAGS} -g"
-	CXXFLAGS="${CXXFLAGS} -g"
-	FFLAGS="${FFLAGS} -g"
-	FCFLAGS="${FCFLAGS} -g"
-	OBJCFLAGS="${OBJCFLAGS} -g"
-      ],
-      [profile],[
-	AC_MSG_RESULT(profile)
-	CFLAGS="${CFLAGS} -g -pg"
-	CXXFLAGS="${CXXFLAGS} -g -pg"
-	FFLAGS="${FFLAGS} -g -pg"
-	FCFLAGS="${FCFLAGS} -g -pg"
-	OBJCFLAGS="${OBJCFLAGS} -g -pg"
-	LDFLAGS="${LDFLAGS} -pg"
-      ],
-      [
-	AC_MSG_RESULT(no)
-	dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
-	dnl by setting any unset environment flag variables
-	AS_IF([test "x${CFLAGS+set}" != "xset"],
-	  [CFLAGS=""])
-	AS_IF([test "x${CXXFLAGS+set}" != "xset"],
-	  [CXXFLAGS=""])
-	AS_IF([test "x${FFLAGS+set}" != "xset"],
-	  [FFLAGS=""])
-	AS_IF([test "x${FCFLAGS+set}" != "xset"],
-	  [FCFLAGS=""])
-	AS_IF([test "x${OBJCFLAGS+set}" != "xset"],
-	  [OBJCFLAGS=""])
-      ])
-
-    dnl Define various variables if debugging is disabled.
-    dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
-    AS_IF([test "x$enable_debug" = "xyes"],
-      [m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])],
-      [m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])])
-    ax_enable_debug=$enable_debug
-])
diff --git a/m4/ax_is_release.m4 b/m4/ax_is_release.m4
deleted file mode 100644
index 9ec67469..00000000
--- a/m4/ax_is_release.m4
+++ /dev/null
@@ -1,69 +0,0 @@
-# ===========================================================================
-#       http://www.gnu.org/software/autoconf-archive/ax_is_release.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_IS_RELEASE(POLICY)
-#
-# DESCRIPTION
-#
-#   Determine whether the code is being configured as a release, or from
-#   git. Set the ax_is_release variable to 'yes' or 'no'.
-#
-#   If building a release version, it is recommended that the configure
-#   script disable compiler errors and debug features, by conditionalising
-#   them on the ax_is_release variable.  If building from git, these
-#   features should be enabled.
-#
-#   The POLICY parameter specifies how ax_is_release is determined. It can
-#   take the following values:
-#
-#    * git-directory:  ax_is_release will be 'no' if a '.git' directory exists
-#    * minor-version:  ax_is_release will be 'no' if the minor version number
-#                      in $PACKAGE_VERSION is odd; this assumes
-#                      $PACKAGE_VERSION follows the 'major.minor.micro' scheme
-#    * micro-version:  ax_is_release will be 'no' if the micro version number
-#                      in $PACKAGE_VERSION is odd; this assumes
-#                      $PACKAGE_VERSION follows the 'major.minor.micro' scheme
-#    * always:         ax_is_release will always be 'yes'
-#    * never:          ax_is_release will always be 'no'
-#
-#   Other policies may be added in future.
-#
-# LICENSE
-#
-#   Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
-#
-#   Copying and distribution of this file, with or without modification, are
-#   permitted in any medium without royalty provided the copyright notice
-#   and this notice are preserved.
-
-#serial 3
-
-AC_DEFUN([AX_IS_RELEASE],[
-    AC_BEFORE([AC_INIT],[$0])
-
-    m4_case([$1],
-      [git-directory],[
-        # $is_release = (.git directory does not exist)
-        AS_IF([test -d .git],[ax_is_release=no],[ax_is_release=yes])
-      ],
-      [minor-version],[
-        # $is_release = ($minor_version is even)
-        minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
-        AS_IF([test "$(( $minor_version % 2 ))" -ne 0],
-              [ax_is_release=no],[ax_is_release=yes])
-      ],
-      [micro-version],[
-        # $is_release = ($micro_version is even)
-        micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'`
-        AS_IF([test "$(( $micro_version % 2 ))" -ne 0],
-              [ax_is_release=no],[ax_is_release=yes])
-      ],
-      [always],[ax_is_release=yes],
-      [never],[ax_is_release=no],
-      [
-        AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version.])
-      ])
-])
diff --git a/m4/ax_python_devel.m4 b/m4/ax_python_devel.m4
deleted file mode 100644
index f18ed8a0..00000000
--- a/m4/ax_python_devel.m4
+++ /dev/null
@@ -1,327 +0,0 @@
-# ===========================================================================
-#      http://www.gnu.org/software/autoconf-archive/ax_python_devel.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_PYTHON_DEVEL([version])
-#
-# DESCRIPTION
-#
-#   Note: Defines as a precious variable "PYTHON_VERSION". Don't override it
-#   in your configure.ac.
-#
-#   This macro checks for Python and tries to get the include path to
-#   'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LIBS) output
-#   variables. It also exports $(PYTHON_EXTRA_LIBS) and
-#   $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
-#
-#   You can search for some particular version of Python by passing a
-#   parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
-#   note that you *have* to pass also an operator along with the version to
-#   match, and pay special attention to the single quotes surrounding the
-#   version number. Don't use "PYTHON_VERSION" for this: that environment
-#   variable is declared as precious and thus reserved for the end-user.
-#
-#   This macro should work for all versions of Python >= 2.1.0. As an end
-#   user, you can disable the check for the python version by setting the
-#   PYTHON_NOVERSIONCHECK environment variable to something else than the
-#   empty string.
-#
-#   If you need to use this macro for an older Python version, please
-#   contact the authors. We're always open for feedback.
-#
-# LICENSE
-#
-#   Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
-#   Copyright (c) 2009 Alan W. Irwin
-#   Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
-#   Copyright (c) 2009 Andrew Collier
-#   Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
-#   Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
-#   Copyright (c) 2013 Daniel Mullner <muellner@math.stanford.edu>
-#
-#   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, see <http://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 18
-
-AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
-AC_DEFUN([AX_PYTHON_DEVEL],[
-	#
-	# Allow the use of a (user set) custom python version
-	#
-	AC_ARG_VAR([PYTHON_VERSION],[The installed Python
-		version to use, for example '2.3'. This string
-		will be appended to the Python interpreter
-		canonical name.])
-
-	AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
-	if test -z "$PYTHON"; then
-	   AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
-	   PYTHON_VERSION=""
-	fi
-
-	#
-	# Check for a version of Python >= 2.1.0
-	#
-	AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
-	ac_supports_python_ver=`$PYTHON -c "import sys; \
-		ver = sys.version.split ()[[0]]; \
-		print (ver >= '2.1.0')"`
-	if test "$ac_supports_python_ver" != "True"; then
-		if test -z "$PYTHON_NOVERSIONCHECK"; then
-			AC_MSG_RESULT([no])
-			AC_MSG_FAILURE([
-This version of the AC@&t@_PYTHON_DEVEL macro
-doesn't work properly with versions of Python before
-2.1.0. You may need to re-run configure, setting the
-variables PYTHON_CPPFLAGS, PYTHON_LIBS, PYTHON_SITE_PKG,
-PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
-Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
-to something else than an empty string.
-])
-		else
-			AC_MSG_RESULT([skip at user request])
-		fi
-	else
-		AC_MSG_RESULT([yes])
-	fi
-
-	#
-	# if the macro parameter ``version'' is set, honour it
-	#
-	if test -n "$1"; then
-		AC_MSG_CHECKING([for a version of Python $1])
-		ac_supports_python_ver=`$PYTHON -c "import sys; \
-			ver = sys.version.split ()[[0]]; \
-			print (ver $1)"`
-		if test "$ac_supports_python_ver" = "True"; then
-		   AC_MSG_RESULT([yes])
-		else
-			AC_MSG_RESULT([no])
-			AC_MSG_ERROR([this package requires Python $1.
-If you have it installed, but it isn't the default Python
-interpreter in your system path, please pass the PYTHON_VERSION
-variable to configure. See ``configure --help'' for reference.
-])
-			PYTHON_VERSION=""
-		fi
-	fi
-
-	#
-	# Check if you have distutils, else fail
-	#
-	AC_MSG_CHECKING([for the distutils Python package])
-	ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
-	if test -z "$ac_distutils_result"; then
-		AC_MSG_RESULT([yes])
-	else
-		AC_MSG_RESULT([no])
-		AC_MSG_ERROR([cannot import Python module "distutils".
-Please check your Python installation. The error was:
-$ac_distutils_result])
-		PYTHON_VERSION=""
-	fi
-
-	#
-	# Check for Python include path
-	#
-	AC_MSG_CHECKING([for Python include path])
-	if test -z "$PYTHON_CPPFLAGS"; then
-		python_path=`$PYTHON -c "import distutils.sysconfig; \
-			print (distutils.sysconfig.get_python_inc ());"`
-		plat_python_path=`$PYTHON -c "import distutils.sysconfig; \
-			print (distutils.sysconfig.get_python_inc (plat_specific=1));"`
-		if test -n "${python_path}"; then
-			if test "${plat_python_path}" != "${python_path}"; then
-				python_path="-I$python_path -I$plat_python_path"
-			else
-				python_path="-I$python_path"
-			fi
-		fi
-		PYTHON_CPPFLAGS=$python_path
-	fi
-	AC_MSG_RESULT([$PYTHON_CPPFLAGS])
-	AC_SUBST([PYTHON_CPPFLAGS])
-
-	#
-	# Check for Python library path
-	#
-	AC_MSG_CHECKING([for Python library path])
-	if test -z "$PYTHON_LIBS"; then
-		# (makes two attempts to ensure we've got a version number
-		# from the interpreter)
-		ac_python_version=`cat<<EOD | $PYTHON -
-
-# join all versioning strings, on some systems
-# major/minor numbers could be in different list elements
-from distutils.sysconfig import *
-e = get_config_var('VERSION')
-if e is not None:
-	print(e)
-EOD`
-
-		if test -z "$ac_python_version"; then
-			if test -n "$PYTHON_VERSION"; then
-				ac_python_version=$PYTHON_VERSION
-			else
-				ac_python_version=`$PYTHON -c "import sys; \
-					print (sys.version[[:3]])"`
-			fi
-		fi
-
-		# Make the versioning information available to the compiler
-		AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
-                                   [If available, contains the Python version number currently in use.])
-
-		# First, the library directory:
-		ac_python_libdir=`cat<<EOD | $PYTHON -
-
-# There should be only one
-import distutils.sysconfig
-e = distutils.sysconfig.get_config_var('LIBDIR')
-if e is not None:
-	print (e)
-EOD`
-
-		# Now, for the library:
-		ac_python_library=`cat<<EOD | $PYTHON -
-
-import distutils.sysconfig
-c = distutils.sysconfig.get_config_vars()
-if 'LDVERSION' in c:
-	print ('python'+c[['LDVERSION']])
-else:
-	print ('python'+c[['VERSION']])
-EOD`
-
-		# This small piece shamelessly adapted from PostgreSQL python macro;
-		# credits goes to momjian, I think. I'd like to put the right name
-		# in the credits, if someone can point me in the right direction... ?
-		#
-		if test -n "$ac_python_libdir" -a -n "$ac_python_library"
-		then
-			# use the official shared library
-			ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
-			PYTHON_LIBS="-L$ac_python_libdir -l$ac_python_library"
-		else
-			# old way: use libpython from python_configdir
-			ac_python_libdir=`$PYTHON -c \
-			  "from distutils.sysconfig import get_python_lib as f; \
-			  import os; \
-			  print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
-			PYTHON_LIBS="-L$ac_python_libdir -lpython$ac_python_version"
-		fi
-
-		if test -z "PYTHON_LIBS"; then
-			AC_MSG_ERROR([
-  Cannot determine location of your Python DSO. Please check it was installed with
-  dynamic libraries enabled, or try setting PYTHON_LIBS by hand.
-			])
-		fi
-	fi
-	AC_MSG_RESULT([$PYTHON_LIBS])
-	AC_SUBST([PYTHON_LIBS])
-
-	#
-	# Check for site packages
-	#
-	AC_MSG_CHECKING([for Python site-packages path])
-	if test -z "$PYTHON_SITE_PKG"; then
-		PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
-			print (distutils.sysconfig.get_python_lib(0,0));"`
-	fi
-	AC_MSG_RESULT([$PYTHON_SITE_PKG])
-	AC_SUBST([PYTHON_SITE_PKG])
-
-	#
-	# libraries which must be linked in when embedding
-	#
-	AC_MSG_CHECKING(python extra libraries)
-	if test -z "$PYTHON_EXTRA_LDFLAGS"; then
-	   PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
-                conf = distutils.sysconfig.get_config_var; \
-                print (conf('LIBS') + ' ' + conf('SYSLIBS'))"`
-	fi
-	AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
-	AC_SUBST(PYTHON_EXTRA_LDFLAGS)
-
-	#
-	# linking flags needed when embedding
-	#
-	AC_MSG_CHECKING(python extra linking flags)
-	if test -z "$PYTHON_EXTRA_LIBS"; then
-		PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
-			conf = distutils.sysconfig.get_config_var; \
-			print (conf('LINKFORSHARED'))"`
-	fi
-	AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
-	AC_SUBST(PYTHON_EXTRA_LIBS)
-
-	#
-	# final check to see if everything compiles alright
-	#
-	AC_MSG_CHECKING([consistency of all components of python development environment])
-	# save current global flags
-	ac_save_LIBS="$LIBS"
-	ac_save_LDFLAGS="$LDFLAGS"
-	ac_save_CPPFLAGS="$CPPFLAGS"
-	LIBS="$ac_save_LIBS $PYTHON_LIBS $PYTHON_EXTRA_LIBS $PYTHON_EXTRA_LIBS"
-	LDFLAGS="$ac_save_LDFLAGS $PYTHON_EXTRA_LDFLAGS"
-	CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
-	AC_LANG_PUSH([C])
-	AC_LINK_IFELSE([
-		AC_LANG_PROGRAM([[#include <Python.h>]],
-				[[Py_Initialize();]])
-		],[pythonexists=yes],[pythonexists=no])
-	AC_LANG_POP([C])
-	# turn back to default flags
-	CPPFLAGS="$ac_save_CPPFLAGS"
-	LIBS="$ac_save_LIBS"
-	LDFLAGS="$ac_save_LDFLAGS"
-
-	AC_MSG_RESULT([$pythonexists])
-
-        if test ! "x$pythonexists" = "xyes"; then
-	   AC_MSG_FAILURE([
-  Could not link test program to Python. Maybe the main Python library has been
-  installed in some non-standard library path. If so, pass it to configure,
-  via the LIBS environment variable.
-  Example: ./configure LIBS="-L/usr/non-standard-path/python/lib"
-  ============================================================================
-   ERROR!
-   You probably have to install the development version of the Python package
-   for your distribution.  The exact name of this package varies among them.
-  ============================================================================
-	   ])
-	  PYTHON_VERSION=""
-	fi
-
-	#
-	# all done!
-	#
-])
diff --git a/m4/clang-analyze.am b/m4/clang-analyze.am
deleted file mode 100644
index a5765774..00000000
--- a/m4/clang-analyze.am
+++ /dev/null
@@ -1,8 +0,0 @@
-analysis_verbose = $(analysis_verbose_$(V))
-analysis_verbose_ = $(analysis_verbose_$(AM_DEFAULT_VERBOSITY))
-analysis_verbose_0 = @echo "  CCSA    " $@; $(COMPILE) --analyze $< -o $@;
-analysis_verbose_1 = $(COMPILE) --analyze $< -o $@;
-
-%.plist: %.c
-	$(analysis_verbose)
-
diff --git a/meson.build b/meson.build
new file mode 100644
index 00000000..462673fb
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,130 @@
+project('hexchat', 'c',
+  version: '2.12.4',
+  meson_version: '>= 0.37.0',
+  default_options: [
+    'c_std=gnu89',
+    'buildtype=debugoptimized',
+    'warning_level=1',
+  ]
+)
+
+i18n = import('i18n')
+gnome = import('gnome')
+cc = meson.get_compiler('c')
+
+
+libgio_dep = dependency('gio-2.0', version: '>= 2.34.0')
+libgmodule_dep = dependency('gmodule-2.0')
+if cc.get_id() == 'msvc'
+  libssl_dep = cc.find_library('libeay32')
+else
+  libssl_dep = dependency('openssl', version: '>= 0.9.8',
+                          required: get_option('with-ssl'))
+endif
+
+config_h = configuration_data()
+config_h.set_quoted('PACKAGE_VERSION', meson.project_version())
+config_h.set_quoted('PACKAGE_NAME', meson.project_name())
+config_h.set_quoted('GETTEXT_PACKAGE', 'hexchat')
+config_h.set_quoted('LOCALEDIR', join_paths(get_option('prefix'),
+                                 get_option('datadir'), 'locale'))
+config_h.set10('ENABLE_NLS', true)
+
+# Optional features
+config_h.set('USE_OPENSSL', get_option('with-ssl'))
+config_h.set('USE_LIBPROXY', get_option('with-libproxy'))
+config_h.set('USE_LIBCANBERRA', get_option('with-libcanberra'))
+config_h.set('USE_DBUS', get_option('with-dbus'))
+config_h.set('USE_PLUGIN', get_option('with-plugin'))
+
+config_h.set('G_DISABLE_SINGLE_INCLUDES', true)
+config_h.set('GTK_DISABLE_DEPRECATED', true)
+config_h.set('GTK_DISABLE_SINGLE_INCLUDES', true)
+config_h.set('GDK_PIXBUF_DISABLE_SINGLE_INCLUDES', true)
+config_h.set('GLIB_VERSION_MAX_ALLOWED', 'GLIB_VERSION_2_34')
+config_h.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_34')
+
+# Detected features
+config_h.set('HAVE_MEMRCHR', cc.has_function('memrchr'))
+config_h.set('HAVE_STRINGS_H', cc.has_header('strings.h'))
+
+if libssl_dep.found()
+  config_h.set('HAVE_X509_GET_SIGNATURE_NID',
+    cc.has_function('X509_get_signature_nid', dependencies: libssl_dep)
+  )
+  config_h.set('HAVE_SSL_CTX_GET_SSL_METHOD',
+    cc.has_function('SSL_CTX_get_ssl_method', dependencies: libssl_dep)
+  )
+  config_h.set('HAVE_DH_SET0_PQG',
+    cc.has_function('DH_set0_pqg', dependencies: libssl_dep)
+  )
+  config_h.set('HAVE_DH_GET0_KEY',
+    cc.has_function('DH_get0_key', dependencies: libssl_dep)
+  )
+  config_h.set('HAVE_DH_SET0_KEY',
+    cc.has_function('DH_set0_key', dependencies: libssl_dep)
+  )
+endif
+
+configure_file(output: 'config.h', configuration: config_h)
+config_h_include = include_directories('.')
+
+if host_machine.system() == 'windows'
+  add_project_arguments('-DWIN32', language: 'c')
+endif
+
+
+global_cflags = []
+test_cflags = [
+  '-pipe',
+  '-funsigned-char',
+  '-Wno-conversion',
+  '-Wno-pointer-sign',
+  '-Wno-padded',
+  '-Wno-unused-parameter',
+  '-Wno-missing-prototypes',
+  '-Winline',
+  '-Wstrict-prototypes',
+  '-Werror=implicit-function-declaration',
+  '-Werror=pointer-arith',
+  '-Werror=init-self',
+  ['-Werror=format-security', '-Werror=format=1'],
+  '-Werror=missing-include-dirs',
+  '-Werror=date-time',
+]
+if host_machine.system() != 'windows' and get_option('buildtype') != 'plain'
+  test_cflags += '-fstack-protector-strong'
+endif
+foreach cflag : test_cflags
+  if cc.has_multi_arguments(cflag)
+    global_cflags += cflag
+  endif
+endforeach
+add_project_arguments(global_cflags, language: 'c')
+
+if host_machine.system() != 'windows'
+  global_ldflags = []
+  test_ldflags = [
+    '-Wl,-z,relro',
+    '-Wl,-z,now',
+  ]
+  foreach ldflag : test_ldflags
+    if cc.has_argument(ldflag)
+      global_ldflags += ldflag
+    endif
+  endforeach
+  add_project_link_arguments(global_ldflags, language: 'c')
+endif
+
+subdir('src')
+if get_option('with-plugin')
+  subdir('plugins')
+endif
+if cc.get_id() != 'msvc'
+  subdir('data')
+  subdir('po') # FIXME: build xgettext
+
+  meson.add_install_script('meson_post_install.py',
+    '@0@'.format(get_option('with-theme-manager'))
+  )
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 00000000..f8131344
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,56 @@
+option('with-gtk', type: 'boolean',
+  description: 'Main graphical interface'
+)
+option('with-text', type: 'boolean', value: false,
+  description: 'Text interface (not generally useful)'
+)
+option('with-ssl', type: 'boolean',
+  description: 'Support for TLS connections, requires openssl'
+)
+option('with-plugin', type: 'boolean',
+  description: 'Support for loadable plugins'
+)
+option('with-dbus', type: 'boolean',
+  description: 'Support used for single-instance and scripting interface, Unix only'
+)
+option('with-libproxy', type: 'boolean',
+  description: 'Support for getting proxy information, Unix only'
+)
+option('with-libnotify', type: 'boolean',
+  description: 'Support for freedesktop notifications, Unix only'
+)
+option('with-libcanberra', type: 'boolean',
+  description: 'Support for sound alerts, Unix only'
+)
+option('with-theme-manager', type: 'boolean', value: false,
+  description: 'Utility to help manage themes, requires mono/.net'
+)
+
+# Plugins
+option('with-checksum', type: 'boolean',
+  description: 'DCC checksum plugin'
+)
+option('with-exec', type: 'boolean',
+  description: '/exec plugin, Windows only'
+)
+option('with-fishlim', type: 'boolean',
+  description: 'Fish encryption plugin, requires openssl'
+)
+option('with-lua', type: 'string', value: 'luajit',
+  description: 'Lua scripting plugin, value is pkg-config name to use or "false"'
+)
+option('with-perl', type: 'boolean',
+  description: 'Perl scripting plugin'
+)
+option('with-python', type: 'string', value: 'python3',
+  description: 'Python scripting plugin. value is pkg-config name to use or "false"'
+)
+option('with-sysinfo', type: 'boolean',
+  description: 'System information plugin, requires libpci on Unix'
+)
+option('with-upd', type: 'boolean',
+  description: 'Update plugin, Windows only'
+)
+option('with-winamp', type: 'boolean',
+  description: 'Winamp plugin, Windows only'
+)
diff --git a/meson_post_install.py b/meson_post_install.py
new file mode 100644
index 00000000..6944242a
--- /dev/null
+++ b/meson_post_install.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+import subprocess
+
+prefix = os.environ.get('MESON_INSTALL_PREFIX', '/usr/local')
+datadir = os.path.join(prefix, 'share')
+with_thememan = sys.argv[1] == 'true'
+
+# Packaging tools define DESTDIR and this isn't needed for them
+if 'DESTDIR' not in os.environ:
+    print('Updating icon cache...')
+    subprocess.call(['gtk-update-icon-cache', '-qtf',
+                     os.path.join(datadir, 'icons', 'hicolor')])
+
+    print('Updating desktop database...')
+    subprocess.call(['update-desktop-database', '-q',
+                     os.path.join(datadir, 'applications')])
+
+    if with_thememan:
+        print('Updating mime database...')
+        subprocess.call(['update-mime-database',
+                         os.path.join(datadir, 'mime')])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
deleted file mode 100644
index 3880f15d..00000000
--- a/plugins/Makefile.am
+++ /dev/null
@@ -1,25 +0,0 @@
-if DO_LUA
-lua = lua
-endif
-
-if DO_PYTHON
-pythondir = python
-endif
-
-if DO_PERL
-perldir = perl
-endif
-
-if DO_FISHLIM
-fishlimdir = fishlim
-endif
-
-if DO_CHECKSUM
-checksumdir = checksum
-endif
-
-if DO_SYSINFO
-sysinfodir = sysinfo
-endif
-
-SUBDIRS = $(lua) $(pythondir) $(perldir) $(checksumdir) $(fishlimdir) $(sysinfodir)
diff --git a/plugins/checksum/Makefile.am b/plugins/checksum/Makefile.am
deleted file mode 100644
index a38ab732..00000000
--- a/plugins/checksum/Makefile.am
+++ /dev/null
@@ -1,8 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = checksum.la
-checksum_la_SOURCES = checksum.c
-checksum_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-checksum_la_LIBADD = $(GLIB_LIBS)
-checksum_la_CPPFLAGS = -I$(top_srcdir)/src/common
-checksum_la_CFLAGS = $(GLIB_CFLAGS)
diff --git a/plugins/checksum/meson.build b/plugins/checksum/meson.build
new file mode 100644
index 00000000..25835457
--- /dev/null
+++ b/plugins/checksum/meson.build
@@ -0,0 +1,6 @@
+shared_module('checksum', 'checksum.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/exec/meson.build b/plugins/exec/meson.build
new file mode 100644
index 00000000..3f9e8a32
--- /dev/null
+++ b/plugins/exec/meson.build
@@ -0,0 +1,5 @@
+shared_module('exec', 'exec.c',
+  dependencies: hexchat_plugin_dep,
+  install: true,
+  install_dir: plugindir
+)
diff --git a/plugins/fishlim/Makefile.am b/plugins/fishlim/Makefile.am
deleted file mode 100644
index 96069069..00000000
--- a/plugins/fishlim/Makefile.am
+++ /dev/null
@@ -1,10 +0,0 @@
-EXTRA_DIST = LICENSE fish.h irc.h keystore.h plugin_hexchat.h dh1080.h
-
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = fishlim.la
-fishlim_la_SOURCES = fish.c irc.c keystore.c plugin_hexchat.c dh1080.c
-fishlim_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-fishlim_la_LIBADD = $(GLIB_LIBS) $(OPENSSL_LIBS)
-fishlim_la_CPPFLAGS = -I$(top_srcdir)/src/common
-fishlim_la_CFLAGS = $(GLIB_CFLAGS) $(OPENSSL_CFLAGS)
diff --git a/plugins/fishlim/meson.build b/plugins/fishlim/meson.build
new file mode 100644
index 00000000..894923aa
--- /dev/null
+++ b/plugins/fishlim/meson.build
@@ -0,0 +1,18 @@
+if not libssl_dep.found()
+  error('fish plugin requires openssl')
+endif
+
+fishlim_sources = [
+  'dh1080.c',
+  'fish.c',
+  'irc.c',
+  'keystore.c',
+  'plugin_hexchat.c'
+]
+
+shared_module('fishlim', fishlim_sources,
+  dependencies: [libgio_dep, hexchat_plugin_dep, libssl_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/lua/Makefile.am b/plugins/lua/Makefile.am
deleted file mode 100644
index b98d5f66..00000000
--- a/plugins/lua/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = lua.la
-lua_la_SOURCES = lua.c
-lua_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-lua_la_LIBADD = $(LUA_LIBS) $(GLIB_LIBS)
-lua_la_CPPFLAGS = -I$(top_srcdir)/src/common
-lua_la_CFLAGS = $(GLIB_CFLAGS) $(LUA_CFLAGS)
-
diff --git a/plugins/lua/meson.build b/plugins/lua/meson.build
new file mode 100644
index 00000000..7faa3054
--- /dev/null
+++ b/plugins/lua/meson.build
@@ -0,0 +1,12 @@
+if cc.get_id() == 'msvc'
+  lua_dep = cc.find_library('lua51')
+else
+  lua_dep = dependency(get_option('with-lua'))
+endif
+
+shared_module('lua', 'lua.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep, lua_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/meson.build b/plugins/meson.build
new file mode 100644
index 00000000..9e7fae93
--- /dev/null
+++ b/plugins/meson.build
@@ -0,0 +1,39 @@
+plugindir = join_paths(get_option('libdir'), 'hexchat/plugins')
+
+if host_machine.system() == 'windows'
+  if get_option('with-exec')
+    subdir('exec')
+  endif
+
+  if get_option('with-upd')
+    subdir('upd')
+  endif
+
+  if get_option('with-winamp')
+    subdir('winamp')
+  endif
+endif
+
+if get_option('with-checksum')
+  subdir('checksum')
+endif
+
+if get_option('with-fishlim')
+  subdir('fishlim')
+endif
+
+if get_option('with-lua') != 'false'
+  subdir('lua')
+endif
+
+if get_option('with-perl')
+  subdir('perl')
+endif
+
+if get_option('with-python') != 'false'
+  subdir('python')
+endif
+
+if get_option('with-sysinfo')
+  subdir('sysinfo')
+endif
diff --git a/plugins/perl/Makefile.am b/plugins/perl/Makefile.am
deleted file mode 100644
index af721e7e..00000000
--- a/plugins/perl/Makefile.am
+++ /dev/null
@@ -1,20 +0,0 @@
-
-EXTRA_DIST=generate_header lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm lib/HexChat/List/Network.pm \
-	lib/HexChat/List/Network/Entry.pm lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
-
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = perl.la
-perl_la_SOURCES = perl.c
-perl_la_LDFLAGS = $(PERL_LDFLAGS) $(PLUGIN_LDFLAGS) -module
-perl_la_LIBADD = $(GLIB_LIBS)
-perl_la_CPPFLAGS = -I$(top_srcdir)/src/common
-perl_la_CFLAGS = $(PERL_CFLAGS) $(GLIB_CFLAGS)
-
-BUILT_SOURCES = hexchat.pm.h irc.pm.h
-CLEANFILES = $(BUILT_SOURCES)
-
-hexchat.pm.h irc.pm.h: lib/HexChat.pm lib/Xchat.pm lib/HexChat/Embed.pm \
-	lib/HexChat/List/Network.pm lib/HexChat/List/Network/Entry.pm \
-	lib/HexChat/List/Network/AutoJoin.pm lib/IRC.pm
-	cd $(srcdir); perl generate_header
diff --git a/plugins/perl/generate_header.py b/plugins/perl/generate_header.py
new file mode 100755
index 00000000..ba7e02a3
--- /dev/null
+++ b/plugins/perl/generate_header.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+
+import sys
+from os.path import basename
+
+out_file = sys.argv[1]
+in_files = sys.argv[2:]
+
+
+def escape_perl(file):
+    ret = ''
+    for line in file:
+        # Escape " and \, strip empty space, shove in C strings.
+        ret += '"' + line.strip().replace('\\', '\\\\').replace('"', '\\"') + '\\n"\n'
+    return ret
+
+
+with open(out_file, 'w') as o:
+    o.write('"BEGIN {\\n"\n')
+    for in_file in in_files:
+        o.write("\"$INC{{'{}'}} = 'Compiled into the plugin.';\\n\"\n".format(basename(in_file)))
+    o.write('"}\\n"\n')
+
+    for in_file in in_files:
+        o.write('"{\\n"\n')
+        o.write('"#line 1 \\"{}\\"\\n"\n'.format(basename(in_file)))
+        with open(in_file) as i:
+            o.write(escape_perl(i))
+        o.write('"}\\n"\n')
diff --git a/plugins/perl/meson.build b/plugins/perl/meson.build
new file mode 100644
index 00000000..49011884
--- /dev/null
+++ b/plugins/perl/meson.build
@@ -0,0 +1,73 @@
+generate_perl_header = find_program('generate_header.py')
+
+hexchat_perl_module = custom_target('hexchat-perl-header',
+  input: [
+    'lib/HexChat.pm',
+    'lib/Xchat.pm',
+    'lib/HexChat/Embed.pm',
+    'lib/HexChat/List/Network.pm',
+    'lib/HexChat/List/Network/Entry.pm',
+    'lib/HexChat/List/Network/AutoJoin.pm',
+  ],
+  output: 'hexchat.pm.h',
+  command: [generate_perl_header, '@OUTPUT@', '@INPUT@']
+)
+
+irc_perl_module = custom_target('irc-perl-header',
+  input: 'lib/IRC.pm',
+  output: 'irc.pm.h',
+  command: [generate_perl_header, '@OUTPUT@', '@INPUT@']
+)
+
+perl = find_program('perl')
+
+ret = run_command([perl, '-MExtUtils::Embed', '-e', 'ccopts'])
+if ret.returncode() != 0
+  error('perl: Failed to get cflags')
+endif
+perl_cflags = []
+foreach flag : ret.stdout().strip().split(' ')
+  if flag.startswith('-I') or flag.startswith('-D')
+    perl_cflags += flag
+  endif
+endforeach
+
+ret = run_command([perl, '-MExtUtils::Embed', '-e', 'ldopts'])
+if ret.returncode() != 0
+  error('perl: Failed to get ldflags')
+endif
+perl_ldflags = []
+foreach flag : ret.stdout().strip().split(' ')
+  if flag.startswith('-L') or flag.startswith('-l')
+    perl_ldflags += flag
+  endif
+endforeach
+
+perl_cflags += [
+  # Perl has its own 'config.h' that we must override
+  # TODO: Just rename ours to something more unique.
+  '-include', meson.build_root() + '/config.h'
+]
+
+if not cc.links('''
+#define PERL_NO_INLINE_FUNCTIONS
+#include <EXTERN.h>
+#include <perl.h>
+
+int main(void) {
+  PerlInterpreter *my_perl = perl_alloc();
+  return 0;
+}
+''', args: perl_cflags + perl_ldflags)
+  error('found perl not suitable for plugin')
+endif
+
+shared_module('perl',
+  sources: ['perl.c', hexchat_perl_module, irc_perl_module],
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  c_args: perl_cflags,
+  link_args: perl_ldflags,
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/python/Makefile.am b/plugins/python/Makefile.am
deleted file mode 100644
index 3c574edf..00000000
--- a/plugins/python/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-libdir = $(hexchatlibdir)
-
-lib_LTLIBRARIES = python.la
-python_la_SOURCES = python.c
-python_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-python_la_LIBADD = $(PYTHON_LIBS) $(GLIB_LIBS)
-python_la_CPPFLAGS = -I$(top_srcdir)/src/common $(PYTHON_CPPFLAGS)
-python_la_CFLAGS = $(GLIB_CFLAGS)
-
diff --git a/plugins/python/meson.build b/plugins/python/meson.build
new file mode 100644
index 00000000..e24f0c6f
--- /dev/null
+++ b/plugins/python/meson.build
@@ -0,0 +1,13 @@
+python_opt = get_option('with-python')
+if python_opt.startswith('python3')
+  python_dep = dependency(python_opt, version: '>= 3.3')
+else
+  python_dep = dependency(python_opt, version: '>= 2.7')
+endif
+
+shared_module('python', 'python.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep, python_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 6d88e4dd..705fe9e6 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -69,6 +69,8 @@
 #include "hexchat-plugin.h"
 #undef _POSIX_C_SOURCE	/* Avoid warnings from /usr/include/features.h */
 #undef _XOPEN_SOURCE
+#undef HAVE_MEMRCHR /* Avoid redefinition in Python.h */
+#undef HAVE_STRINGS_H
 #include <Python.h>
 #include <structmember.h>
 #include <pythread.h>
diff --git a/plugins/sysinfo/Makefile.am b/plugins/sysinfo/Makefile.am
deleted file mode 100644
index 60042018..00000000
--- a/plugins/sysinfo/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-libdir = $(hexchatlibdir)
-
-sources = sysinfo.c format.c shared/df.c
-
-if PLATFORM_OSX
-sources += osx/backend.m
-else
-sources += unix/backend.c unix/match.c unix/parse.c unix/pci.c
-endif
-
-EXTRA_DIST = osx unix win32 shared format.h sysinfo.h sysinfo-backend.h
-
-lib_LTLIBRARIES = sysinfo.la
-sysinfo_la_SOURCES = $(sources)
-sysinfo_la_LDFLAGS = $(PLUGIN_LDFLAGS) -module
-sysinfo_la_LIBADD = $(LIBPCI_LIBS) $(GLIB_LIBS)
-AM_CPPFLAGS = -I$(top_srcdir)/src/common -I$(srcdir)/shared $(LIBPCI_CFLAGS) $(GLIB_CFLAGS)
diff --git a/plugins/sysinfo/meson.build b/plugins/sysinfo/meson.build
new file mode 100644
index 00000000..2bee3e76
--- /dev/null
+++ b/plugins/sysinfo/meson.build
@@ -0,0 +1,46 @@
+sysinfo_sources = [
+  'format.c',
+  'sysinfo.c',
+]
+
+sysinfo_deps = [
+  libgio_dep,
+  hexchat_plugin_dep
+]
+
+sysinfo_includes = []
+
+system = host_machine.system()
+if system == 'linux' or system == 'darwin'
+  sysinfo_includes += 'shared'
+  sysinfo_sources += [
+    'shared/df.c'
+  ]
+
+  if system == 'linux'
+    sysinfo_deps += dependency('libpci')
+    sysinfo_includes += 'unix'
+    sysinfo_sources += [
+      'unix/backend.c',
+      'unix/match.c',
+      'unix/parse.c',
+      'unix/pci.c',
+    ]
+  elif system == 'darwin'
+    add_languages('objc')
+    sysinfo_sources += 'osx/backend.m'
+  endif
+
+elif system == 'windows'
+  sysinfo_sources += 'win32/backend.c'
+else
+  error('sysinfo: Unknown system?')
+endif
+
+shared_module('sysinfo', sysinfo_sources,
+  dependencies: sysinfo_deps,
+  include_directories: include_directories(sysinfo_includes),
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
\ No newline at end of file
diff --git a/plugins/upd/meson.build b/plugins/upd/meson.build
new file mode 100644
index 00000000..7ab9d830
--- /dev/null
+++ b/plugins/upd/meson.build
@@ -0,0 +1,8 @@
+winsparkle_dep = cc.find_library('WinSparkle')
+
+shared_module('upd', 'upd.c',
+  dependencies: [winsparkle_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/plugins/winamp/meson.build b/plugins/winamp/meson.build
new file mode 100644
index 00000000..b07e7071
--- /dev/null
+++ b/plugins/winamp/meson.build
@@ -0,0 +1,6 @@
+shared_module('winamp', 'winamp.c',
+  dependencies: [libgio_dep, hexchat_plugin_dep],
+  install: true,
+  install_dir: plugindir,
+  name_prefix: '',
+)
diff --git a/po/Makevars b/po/Makevars
deleted file mode 100644
index 176a8416..00000000
--- a/po/Makevars
+++ /dev/null
@@ -1,7 +0,0 @@
-DOMAIN = $(PACKAGE)
-subdir = po
-top_builddir = ..
-XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
-COPYRIGHT_HOLDER = 
-MSGID_BUGS_ADDRESS = www.hexchat.org
-EXTRA_LOCALE_CATEGORIES =
diff --git a/po/POTFILES.in b/po/POTFILES
index 5bde0376..5bde0376 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES
diff --git a/po/meson.build b/po/meson.build
new file mode 100644
index 00000000..6631148a
--- /dev/null
+++ b/po/meson.build
@@ -0,0 +1 @@
+i18n.gettext('hexchat', preset: 'glib')
diff --git a/src/Makefile.am b/src/Makefile.am
deleted file mode 100644
index d870aa0d..00000000
--- a/src/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-EXTRA_DIST = version-script
-
-if DO_TEXT
-text_fe = fe-text
-endif
-
-if DO_GTK
-gtk_fe = fe-gtk
-endif
-
-SUBDIRS = common $(gtk_fe) $(text_fe)
-
-if WITH_TM
-SUBDIRS += htm
-endif
diff --git a/src/common/Makefile.am b/src/common/Makefile.am
deleted file mode 100644
index cdab7925..00000000
--- a/src/common/Makefile.am
+++ /dev/null
@@ -1,89 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-include $(top_srcdir)/m4/clang-analyze.am
-
-noinst_LIBRARIES = libhexchatcommon.a
-
-AM_CPPFLAGS = $(COMMON_CFLAGS) -I$(top_srcdir)
-
-EXTRA_DIST = \
-	cfgfiles.h \
-	chanopt.h \
-	ctcp.h \
-	dcc.h \
-	fe.h \
-	hexchat.h \
-	hexchatc.h \
-	hexchat-plugin.h \
-	history.h \
-	ignore.h \
-	inbound.h \
-	inet.h \
-	make-te.c \
-	marshalers.list \
-	modes.h \
-	network.h \
-	notify.h \
-	outbound.h \
-	plugin.h \
-	plugin-identd.h \
-	plugin-timer.h \
-	proto-irc.h \
-	server.h \
-	servlist.h \
-	ssl.h \
-	ssl.c	\
-	text.h \
-	typedef.h \
-	textenums.h \
-	textevents.h \
-	textevents.in \
-	tree.h \
-	url.h \
-	userlist.h \
-	util.h
-
-if USE_OPENSSL
-ssl_c = ssl.c
-endif
-
-if USE_DBUS
-dbusdir = dbus
-libhexchatcommon_a_LIBADD =				\
-	$(top_builddir)/src/common/dbus/dbus-*.$(OBJEXT)
-endif
-SUBDIRS = $(dbusdir) .
-
-if DO_PLUGIN
-include_HEADERS = hexchat-plugin.h
-endif
-
-noinst_PROGRAMS = make-te
-
-libhexchatcommon_a_SOURCES = cfgfiles.c chanopt.c ctcp.c dcc.c hexchat.c \
-	history.c ignore.c inbound.c marshal.c modes.c network.c notify.c \
-	outbound.c plugin.c plugin-identd.c plugin-timer.c proto-irc.c server.c servlist.c \
-	$(ssl_c) text.c tree.c url.c userlist.c util.c
-libhexchatcommon_a_CFLAGS = $(LIBPROXY_CFLAGS)
-
-textenums.h: textevents.h
-
-textevents.h: $(srcdir)/textevents.in make-te
-	$(AM_V_GEN) ./make-te < $< > $@ 2> textenums.h
-
-marshal.h: $(srcdir)/marshalers.list
-	$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --header $< > $@
-
-marshal.c: $(srcdir)/marshalers.list
-	$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_hexchat_marshal --body $< > $@
-
-
-if DO_STATIC_ANALYSIS
-analyze_plists = $(libhexchatcommon_a_SOURCES:%.c=%.plist)
-all-local: $(analyze_plists)
-MOSTLYCLEANFILES = $(analyze_plists)
-endif
-
-BUILT_SOURCES = textenums.h textevents.h marshal.c marshal.h
-
-CLEANFILES = $(BUILT_SOURCES)
diff --git a/src/common/cfgfiles.c b/src/common/cfgfiles.c
index 9ca54869..b90f5a69 100644
--- a/src/common/cfgfiles.c
+++ b/src/common/cfgfiles.c
@@ -291,8 +291,8 @@ cfg_get_int (char *cfg, char *var)
 char *xdir = NULL;	/* utf-8 encoding */
 
 #ifdef WIN32
-#include <Windows.h>
-#include <ShlObj.h>
+#include <windows.h>
+#include <shlobj.h>
 #endif
 
 char *
@@ -552,7 +552,7 @@ const struct prefs vars[] =
 	{"stamp_text", P_OFFINT (hex_stamp_text), TYPE_BOOL},
 	{"stamp_text_format", P_OFFSET (hex_stamp_text_format), TYPE_STR},
 
-	{"text_autocopy_color", P_OFFINT (hex_text_autocopy_color), TYPE_BOOL},	
+	{"text_autocopy_color", P_OFFINT (hex_text_autocopy_color), TYPE_BOOL},
 	{"text_autocopy_stamp", P_OFFINT (hex_text_autocopy_stamp), TYPE_BOOL},
 	{"text_autocopy_text", P_OFFINT (hex_text_autocopy_text), TYPE_BOOL},
 	{"text_background", P_OFFSET (hex_text_background), TYPE_STR},
@@ -635,7 +635,7 @@ get_default_language (void)
 	if (!locale)
 		locale = g_getenv ("LANG") ? g_getenv ("LANG") : "en";
 
-	/* we might end up with something like "en_US.UTF-8".  We will try to 
+	/* we might end up with something like "en_US.UTF-8".  We will try to
 	 * search for "en_US"; if it fails we search for "en".
 	 */
 	lang = g_strdup (locale);
@@ -735,7 +735,7 @@ load_default_config(void)
 	memset (&prefs, 0, sizeof (struct hexchatprefs));
 
 	/* put in default values, anything left out is automatically zero */
-	
+
 	/* BOOLEANS */
 	prefs.hex_away_show_once = 1;
 	prefs.hex_away_track = 1;
@@ -918,7 +918,7 @@ make_config_dirs (void)
 
 	if (g_mkdir_with_parents (get_xdir (), 0700) != 0)
 		return -1;
-	
+
 	buf = g_build_filename (get_xdir (), "addons", NULL);
 	if (g_mkdir (buf, 0700) != 0)
 	{
@@ -926,7 +926,7 @@ make_config_dirs (void)
 		return -1;
 	}
 	g_free (buf);
-	
+
 	buf = g_build_filename (get_xdir (), HEXCHAT_SOUND_DIR, NULL);
 	if (g_mkdir (buf, 0700) != 0)
 	{
@@ -983,7 +983,7 @@ load_config (void)
 		i++;
 	}
 	while (vars[i].name);
-	
+
 	g_free (cfg);
 
 	if (prefs.hex_gui_win_height < 138)
@@ -1009,7 +1009,7 @@ save_config (void)
 
 	config = default_file ();
 	new_config = g_strconcat (config, ".new", NULL);
-	
+
 	fh = g_open (new_config, OFLAGS | O_TRUNC | O_WRONLY | O_CREAT, 0600);
 	if (fh == -1)
 	{
@@ -1023,7 +1023,7 @@ save_config (void)
 		g_free (new_config);
 		return 0;
 	}
-		
+
 	i = 0;
 	do
 	{
diff --git a/src/common/dbus/Makefile.am b/src/common/dbus/Makefile.am
deleted file mode 100644
index 869c283e..00000000
--- a/src/common/dbus/Makefile.am
+++ /dev/null
@@ -1,35 +0,0 @@
-noinst_LIBRARIES = libhexchatdbus.a
-libhexchatdbus_a_SOURCES =			\
-	dbus-plugin.c				\
-	dbus-plugin.h				\
-	dbus-client.c				\
-	dbus-client.h
-
-EXTRA_DIST =				\
-	remote-object.xml		\
-	example.py			\
-	org.hexchat.service.service.in
-
-BUILT_SOURCES =				\
-	remote-object-glue.h
-
-# Dbus service file
-servicedir = $(DBUS_SERVICES_DIR)
-service_in_files = org.hexchat.service.service.in
-service_DATA = $(service_in_files:.service.in=.service)
-
-CLEANFILES = $(BUILT_SOURCES) $(service_DATA)
-
-AM_CPPFLAGS = -I$(top_srcdir)/src/common $(COMMON_CFLAGS) $(DBUS_CFLAGS)
-
-noinst_PROGRAMS = example
-example_SOURCES = example.c
-example_LDADD = $(DBUS_LIBS) $(GLIB_LIBS)
-
-remote-object-glue.h: remote-object.xml
-	$(AM_V_GEN) $(LIBTOOL) --mode=execute $(DBUS_BINDING_TOOL) --prefix=remote_object --mode=glib-server --output=$@ $<
-
-# Rule to make the service file with bindir expanded
-$(service_DATA): $(service_in_files) Makefile
-	@sed -e "s|\@bindir\@|$(bindir)|" $< > $@
-
diff --git a/src/common/dbus/meson.build b/src/common/dbus/meson.build
new file mode 100644
index 00000000..56443377
--- /dev/null
+++ b/src/common/dbus/meson.build
@@ -0,0 +1,44 @@
+dbus_deps = [
+  dependency('dbus-glib-1')
+]
+
+dbus_sources = [
+  'dbus-plugin.c',
+  'dbus-client.c'
+]
+
+dbus_includes = [
+ include_directories('..'),
+ config_h_include
+]
+
+dbus_service_dir = join_paths(get_option('datadir'), 'dbus-1/services')
+
+dbus_conf = configuration_data()
+dbus_conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+configure_file(
+  input: 'org.hexchat.service.service.in',
+  output: 'org.hexchat.service.service',
+  configuration: dbus_conf,
+  install: true,
+  install_dir: dbus_service_dir
+)
+
+dbus_binding_tool = find_program('dbus-binding-tool')
+dbus_remote_object = custom_target('remote-object-glue',
+  input: 'remote-object.xml',
+  output: 'remote-object-glue.h',
+  command: [dbus_binding_tool, '--prefix=remote_object', '--mode=glib-server',
+            '--output=@OUTPUT@', '@INPUT@']
+)
+
+hexchat_dbus = static_library('hexchatdbus',
+  sources: [dbus_remote_object, marshal] + dbus_sources,
+  dependencies: common_deps + dbus_deps,
+  include_directories: dbus_includes,
+  pic: true
+)
+
+hexchat_dbus_dep = declare_dependency(
+  link_with: hexchat_dbus
+)
diff --git a/src/common/make-te.py b/src/common/make-te.py
new file mode 100755
index 00000000..a1da5643
--- /dev/null
+++ b/src/common/make-te.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python3
+
+import sys
+
+inf = open(sys.argv[1])
+eventf = open(sys.argv[2], 'w')
+enumsf = open(sys.argv[3], 'w')
+
+enumsf.write(\
+'''
+/* this file is auto generated, edit textevents.in instead! */
+
+enum
+{
+''')
+
+eventf.write(\
+'''
+/* this file is auto generated, edit textevents.in instead! */
+
+const struct text_event te[] = {
+''')
+
+try:
+	while True:
+		name = inf.readline().strip()
+		event_enum = inf.readline().strip()
+		event_help = inf.readline().strip()
+		event_str = inf.readline().strip()
+		args = inf.readline().strip()
+		translate = True
+
+		if args[0] == 'n':
+			args = int(args[1]) | 128
+			translate = False
+		else:
+			args = int(args)
+
+		if translate:
+			event_str = 'N_("%s")' %event_str
+		else:
+			event_str = '"%s"' %event_str
+
+		enumsf.write('\t%s,\n' %event_enum)
+		eventf.write('\n{"%s", %s, %u,\n%s},\n' %(
+			name, event_help, args, event_str,
+		))
+
+		inf.readline() # whitespace
+except IndexError:
+    pass
+
+enumsf.write('\tNUM_XP\n};\n')
+eventf.write('};\n')
+
diff --git a/src/common/meson.build b/src/common/meson.build
new file mode 100644
index 00000000..ef59ffc3
--- /dev/null
+++ b/src/common/meson.build
@@ -0,0 +1,116 @@
+common_sources = [
+  'cfgfiles.c',
+  'chanopt.c',
+  'ctcp.c',
+  'dcc.c',
+  'hexchat.c',
+  'history.c',
+  'ignore.c',
+  'inbound.c',
+  'modes.c',
+  'network.c',
+  'notify.c',
+  'outbound.c',
+  'plugin.c',
+  'plugin-identd.c',
+  'plugin-timer.c',
+  'proto-irc.c',
+  'server.c',
+  'servlist.c',
+	'text.c',
+  'tree.c',
+  'url.c',
+  'userlist.c',
+  'util.c'
+]
+
+common_deps = [
+  libgio_dep,
+]
+
+common_includes = [
+  config_h_include,
+  include_directories('.')
+]
+
+common_cflags = [
+  '-DHAVE_CONFIG_H',
+]
+
+if host_machine.system() == 'windows'
+  common_deps += [
+    cc.find_library('ws2_32'), # winsock
+    cc.find_library('winmm'), # playsound
+    cc.find_library('wbemuuid'), # sysinfo
+  ]
+
+  common_sources += 'sysinfo/win32/backend.c'
+  common_includes += include_directories('sysinfo')
+endif
+
+marshal = gnome.genmarshal('marshal',
+  sources: 'marshalers.list',
+  prefix: '_hexchat_marshal',
+  internal: true
+)
+
+make_te = find_program('make-te.py')
+
+textevents = custom_target('textevents',
+  input: 'textevents.in',
+  output: ['textevents.h', 'textenums.h'],
+  command: [make_te, '@INPUT@', '@OUTPUT0@', '@OUTPUT1@']
+)
+
+# TODO:
+#   LOOKUPD
+#   SIGACTION
+#   HAVE_GTK_MAC
+
+if get_option('with-ssl')
+  common_sources += 'ssl.c'
+  common_deps += libssl_dep
+endif
+
+if get_option('with-libproxy')
+  common_deps += dependency('libproxy-1.0')
+endif
+
+if get_option('with-libcanberra')
+  common_deps += dependency('libcanberra', version: '>= 0.22')
+endif
+
+if get_option('with-dbus')
+  subdir('dbus')
+  common_deps += hexchat_dbus_dep
+  common_includes += include_directories('dbus')
+endif
+
+if get_option('with-plugin')
+  common_deps += libgmodule_dep
+  common_cflags += '-DHEXCHATLIBDIR="@0@"'.format(join_paths(get_option('prefix'),
+                                                  get_option('libdir'),
+                                                  'hexchat/plugins'))
+
+  install_headers('hexchat-plugin.h')
+endif
+
+hexchat_common = static_library('hexchatcommon',
+  sources: [textevents] + marshal + common_sources,
+  include_directories: config_h_include,
+  dependencies: common_deps,
+  c_args: common_cflags,
+  pic: true
+)
+
+hexchat_common_dep = declare_dependency(
+  link_with: hexchat_common,
+  include_directories: common_includes,
+  compile_args: common_cflags,
+  dependencies: libgio_dep,
+)
+
+hexchat_plugin_dep = declare_dependency(
+  include_directories: common_includes,
+  compile_args: common_cflags,
+)
diff --git a/src/common/sysinfo/win32/backend.c b/src/common/sysinfo/win32/backend.c
index c4e686a7..64e9405a 100644
--- a/src/common/sysinfo/win32/backend.c
+++ b/src/common/sysinfo/win32/backend.c
@@ -21,6 +21,7 @@
  */
 
 #include <stdio.h>
+#include <wchar.h>
 #include <windows.h>
 #include <wbemidl.h>
 
@@ -41,17 +42,17 @@ typedef enum
 	QUERY_WMI_HDD,
 } QueryWmiType;
 
-char *query_wmi (QueryWmiType mode);
-char *read_os_name (IWbemClassObject *object);
-char *read_cpu_info (IWbemClassObject *object);
-char *read_vga_name (IWbemClassObject *object);
+static char *query_wmi (QueryWmiType mode);
+static char *read_os_name (IWbemClassObject *object);
+static char *read_cpu_info (IWbemClassObject *object);
+static char *read_vga_name (IWbemClassObject *object);
 
-guint64 hdd_capacity;
-guint64 hdd_free_space;
-char *read_hdd_info (IWbemClassObject *object);
+static guint64 hdd_capacity;
+static guint64 hdd_free_space;
+static char *read_hdd_info (IWbemClassObject *object);
 
-char *bstr_to_utf8 (BSTR bstr);
-guint64 variant_to_uint64 (VARIANT *variant);
+static char *bstr_to_utf8 (BSTR bstr);
+static guint64 variant_to_uint64 (VARIANT *variant);
 
 char *
 sysinfo_get_cpu (void)
diff --git a/src/common/util.c b/src/common/util.c
index bf1acb05..8f4c3abe 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -48,7 +48,7 @@
 #include <ctype.h>
 #include "util.h"
 
-#if defined (USING_FREEBSD) || defined (__APPLE__)
+#if defined (__FreeBSD__) || defined (__APPLE__)
 #include <sys/sysctl.h>
 #endif
 
@@ -360,13 +360,13 @@ strip_hidden_attribute (char *src, char *dst)
 	return len;
 }
 
-#if defined (USING_LINUX) || defined (USING_FREEBSD) || defined (__APPLE__) || defined (__CYGWIN__)
+#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
 
 static void
 get_cpu_info (double *mhz, int *cpus)
 {
 
-#if defined(USING_LINUX) || defined (__CYGWIN__)
+#if defined(__linux__) || defined (__CYGWIN__)
 
 	char buf[256];
 	int fh;
@@ -404,7 +404,7 @@ get_cpu_info (double *mhz, int *cpus)
 		*cpus = 1;
 
 #endif
-#ifdef USING_FREEBSD
+#ifdef __FreeBSD__
 
 	int mib[2], ncpu;
 	u_long freq;
@@ -495,7 +495,7 @@ get_sys_str (int with_cpu)
 char *
 get_sys_str (int with_cpu)
 {
-#if defined (USING_LINUX) || defined (USING_FREEBSD) || defined (__APPLE__) || defined (__CYGWIN__)
+#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
 	double mhz;
 #endif
 	int cpus = 1;
@@ -507,7 +507,7 @@ get_sys_str (int with_cpu)
 
 	uname (&un);
 
-#if defined (USING_LINUX) || defined (USING_FREEBSD) || defined (__APPLE__) || defined (__CYGWIN__)
+#if defined (__linux__) || defined (__FreeBSD__) || defined (__APPLE__) || defined (__CYGWIN__)
 	get_cpu_info (&mhz, &cpus);
 	if (mhz && with_cpu)
 	{
diff --git a/src/fe-gtk/Makefile.am b/src/fe-gtk/Makefile.am
deleted file mode 100644
index 269eaa55..00000000
--- a/src/fe-gtk/Makefile.am
+++ /dev/null
@@ -1,64 +0,0 @@
-
-include $(top_srcdir)/m4/clang-analyze.am
-
-localedir = $(datadir)/locale
-
-bin_PROGRAMS = hexchat
-
-AM_CPPFLAGS = $(GUI_CFLAGS) -DLOCALEDIR=\"$(localedir)\"
-
-hexchat_LDADD = $(top_builddir)/src/common/libhexchatcommon.a $(GUI_LIBS)
-
-EXTRA_DIST = \
-	ascii.h banlist.h chanlist.h chanview.h chanview-tabs.c \
-	chanview-tree.c custom-list.h editlist.h fe-gtk.h fkeys.h gtkutil.h joind.h \
-	maingui.h menu.h notifygui.h  notifications palette.h pixmaps.h plugin-notification.h \
-	plugin-tray.h plugingui.c plugingui.h rawlog.h servlistgui.h setup.h sexy-iso-codes.h \
-	sexy-spell-entry.h textgui.h urlgrab.h userlistgui.h xtext.h
-
-BUILT_SOURCES = resources.h resources.c
-
-CLEANFILES = $(BUILT_SOURCES)
-
-if DO_PLUGIN
-plugingui_c = plugingui.c
-endif
-
-if HAVE_ISO_CODES
-iso_codes_c = sexy-iso-codes.c
-endif
-
-if USE_LIBNOTIFY
-notify_c = notifications/notification-libnotify.c
-else
-if HAVE_GTK_MAC
-notify_c = notifications/notification-osx.m
-hexchat_LDFLAGS = -framework Foundation
-else
-notify_c = notifications/notification-dummy.c
-endif
-endif
-
-nodist_hexchat_SOURCES = resources.h resources.c
-hexchat_SOURCES = ascii.c banlist.c chanlist.c chanview.c custom-list.c \
-	dccgui.c editlist.c fe-gtk.c fkeys.c gtkutil.c ignoregui.c joind.c menu.c \
-	maingui.c notifygui.c $(notify_c) palette.c pixmaps.c plugin-tray.c $(plugingui_c) \
-	plugin-notification.c rawlog.c servlistgui.c setup.c $(iso_codes_c) \
-	sexy-spell-entry.c textgui.c urlgrab.c userlistgui.c xtext.c
-hexchat_CPPFLAGS = -I$(top_builddir)/src/common $(AM_CPPFLAGS)
-
-resources_files = $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(top_srcdir)/data --generate-dependencies $(top_srcdir)/data/hexchat.gresource.xml)
-
-resources.h: $(top_srcdir)/data/hexchat.gresource.xml $(resources_files)
-	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate-header --manual-register $<
-
-resources.c: $(top_srcdir)/data/hexchat.gresource.xml $(resources_files)
-	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(top_srcdir)/data --generate-source --manual-register $<
-
-EXTRA_DIST += $(resources_files)
-
-if DO_STATIC_ANALYSIS
-analyze_plists = $(hexchat_SOURCES:%.c=%.plist)
-all-local: $(analyze_plists)
-MOSTLYCLEANFILES = $(analyze_plists)
-endif
diff --git a/src/fe-gtk/meson.build b/src/fe-gtk/meson.build
new file mode 100644
index 00000000..731709b1
--- /dev/null
+++ b/src/fe-gtk/meson.build
@@ -0,0 +1,79 @@
+hexchat_gtk_sources = [
+  'ascii.c',
+  'banlist.c',
+  'chanlist.c',
+  'chanview.c',
+  'custom-list.c',
+  'dccgui.c',
+  'editlist.c',
+  'fe-gtk.c',
+  'fkeys.c',
+  'gtkutil.c',
+  'ignoregui.c',
+  'joind.c',
+  'menu.c',
+  'maingui.c',
+  'notifygui.c',
+  'palette.c',
+  'pixmaps.c',
+  'plugin-tray.c',
+  'plugin-notification.c',
+  'rawlog.c',
+  'servlistgui.c',
+  'setup.c',
+  'sexy-spell-entry.c',
+  'textgui.c',
+  'urlgrab.c',
+  'userlistgui.c',
+  'xtext.c'
+]
+
+hexchat_gtk_deps = [
+  hexchat_common_dep,
+  libgmodule_dep, # used by libsexy
+  dependency('gtk+-2.0', version: '>= 2.24.0')
+]
+
+hexchat_gtk_cflags = [
+  '-fPIE'
+]
+
+hexchat_gtk_ldflags = [
+  '-pie'
+]
+
+if get_option('with-libnotify')
+  hexchat_gtk_sources += 'notifications/notification-libnotify.c'
+  hexchat_gtk_deps += dependency('libnotify')
+elif false # TODO HAVE_GTK_MAC
+else
+  hexchat_gtk_sources += 'notifications/notification-dummy.c'
+endif
+
+iso_codes = dependency('iso-codes', required: false)
+if iso_codes.found()
+  hexchat_gtk_sources += 'sexy-iso-codes.c'
+  iso_codes_prefix = iso_codes.get_pkgconfig_variable('prefix')
+  hexchat_gtk_cflags += '-DISO_CODES_PREFIX="@0@"'.format(iso_codes_prefix)
+  hexchat_gtk_cflags += '-DISO_CODES_LOCALEDIR="@0@"'.format(
+                        join_paths(iso_codes_prefix, 'share/locale'))
+endif
+
+if get_option('with-plugin')
+  hexchat_gtk_sources += 'plugingui.c'
+endif
+
+resources = gnome.compile_resources('resources',
+  '../../data/hexchat.gresource.xml',
+  source_dir: '../../data', # TODO: Fix upstream
+  c_name: 'hexchat',
+  extra_args: ['--manual-register']
+)
+
+executable('hexchat',
+  sources:  resources + hexchat_gtk_sources,
+  dependencies: hexchat_gtk_deps,
+  c_args: hexchat_gtk_cflags,
+  link_args: hexchat_gtk_ldflags,
+  install: true
+)
diff --git a/src/fe-text/Makefile.am b/src/fe-text/Makefile.am
deleted file mode 100644
index 0243e16f..00000000
--- a/src/fe-text/Makefile.am
+++ /dev/null
@@ -1,9 +0,0 @@
-localedir = $(datadir)/locale
-
-bin_PROGRAMS = hexchat-text
-
-AM_CPPFLAGS = $(COMMON_CFLAGS) -DLOCALEDIR=\"$(localedir)\"
-
-hexchat_text_LDADD = $(top_builddir)/src/common/libhexchatcommon.a $(COMMON_LIBS)
-hexchat_text_SOURCES = fe-text.c fe-text.h
-
diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c
index 323cf6dc..3d29533d 100644
--- a/src/fe-text/fe-text.c
+++ b/src/fe-text/fe-text.c
@@ -502,7 +502,7 @@ fe_args (int argc, char *argv[])
 
 	if (arg_show_version)
 	{
-		printf (PACKAGE_TARNAME" "PACKAGE_VERSION"\n");
+		printf (PACKAGE_NAME" "PACKAGE_VERSION"\n");
 		return 0;
 	}
 
diff --git a/src/fe-text/meson.build b/src/fe-text/meson.build
new file mode 100644
index 00000000..705d8852
--- /dev/null
+++ b/src/fe-text/meson.build
@@ -0,0 +1,7 @@
+executable('hexchat-text',
+  sources: [
+    'fe-text.c',
+  ],
+  dependencies: hexchat_common_dep,
+  install: true,
+)
diff --git a/src/htm/Makefile.am b/src/htm/Makefile.am
deleted file mode 100644
index e524bf27..00000000
--- a/src/htm/Makefile.am
+++ /dev/null
@@ -1,15 +0,0 @@
-theme_SCRIPTS = thememan.exe thememan
-themedir = $(bindir)
-
-mdtool_verbose = $(mdtool_verbose_$(V))
-mdtool_verbose_ = $(mdtool_verbose_$(AM_DEFAULT_VERBOSITY))
-mdtool_verbose_0 = @echo "  MDTOOL  " $@; $(MDTOOL) build $< > /dev/null;
-mdtool_verbose_1 = $(MDTOOL) --verbose build $<;
-
-thememan.exe: htm-mono.csproj
-	$(mdtool_verbose)
-
-clean-local:
-	rm -f thememan.exe thememan.exe.config thememan.exe.mdb thememan Main.resources
-
-EXTRA_DIST = thememan.in
diff --git a/src/htm/htm-mono.csproj b/src/htm/htm-mono.csproj
deleted file mode 100644
index 7bed3d97..00000000
--- a/src/htm/htm-mono.csproj
+++ /dev/null
@@ -1,144 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>

-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

-  <PropertyGroup>

-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>

-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

-    <ProductVersion>8.0.30703</ProductVersion>

-    <SchemaVersion>2.0</SchemaVersion>

-    <ProjectGuid>{DE87FFCA-9606-4116-B747-062D88A56A28}</ProjectGuid>

-    <OutputType>WinExe</OutputType>

-    <AppDesignerFolder>Properties</AppDesignerFolder>

-    <RootNamespace>thememan</RootNamespace>

-    <FileAlignment>512</FileAlignment>

-    <IsWebBootstrapper>false</IsWebBootstrapper>

-    <PublishUrl>publish\</PublishUrl>

-    <Install>true</Install>

-    <InstallFrom>Disk</InstallFrom>

-    <UpdateEnabled>false</UpdateEnabled>

-    <UpdateMode>Foreground</UpdateMode>

-    <UpdateInterval>7</UpdateInterval>

-    <UpdateIntervalUnits>Days</UpdateIntervalUnits>

-    <UpdatePeriodically>false</UpdatePeriodically>

-    <UpdateRequired>false</UpdateRequired>

-    <MapFileExtensions>true</MapFileExtensions>

-    <AutorunEnabled>true</AutorunEnabled>

-    <ApplicationRevision>1</ApplicationRevision>

-    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>

-    <UseApplicationTrust>false</UseApplicationTrust>

-    <PublishWizardCompleted>true</PublishWizardCompleted>

-    <BootstrapperEnabled>true</BootstrapperEnabled>

-    <AssemblyName>thememan</AssemblyName>

-  </PropertyGroup>

-  <PropertyGroup>

-    <ApplicationIcon>Resources\htm.ico</ApplicationIcon>

-  </PropertyGroup>

-  <PropertyGroup>

-    <ManifestCertificateThumbprint>25412E3EF25458D894050F8209E4D9DCCDF432D7</ManifestCertificateThumbprint>

-  </PropertyGroup>

-  <PropertyGroup>

-    <ManifestKeyFile>htm_TemporaryKey.pfx</ManifestKeyFile>

-  </PropertyGroup>

-  <PropertyGroup>

-    <GenerateManifests>false</GenerateManifests>

-  </PropertyGroup>

-  <PropertyGroup>

-    <SignManifests>false</SignManifests>

-  </PropertyGroup>

-  <PropertyGroup>

-    <TargetZone>LocalIntranet</TargetZone>

-  </PropertyGroup>

-  <PropertyGroup />

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

-    <DebugSymbols>True</DebugSymbols>

-    <DebugType>full</DebugType>

-    <Optimize>False</Optimize>

-    <OutputPath>.</OutputPath>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">

-    <DebugType>none</DebugType>

-    <Optimize>True</Optimize>

-    <OutputPath>.</OutputPath>

-    <WarningLevel>4</WarningLevel>

-  </PropertyGroup>

-  <ItemGroup>

-    <Reference Include="System" />

-    <Reference Include="System.Core" />

-    <Reference Include="System.Xml.Linq" />

-    <Reference Include="System.Data.DataSetExtensions" />

-    <Reference Include="Microsoft.CSharp" />

-    <Reference Include="System.Data" />

-    <Reference Include="System.Drawing" />

-    <Reference Include="System.Windows.Forms" />

-    <Reference Include="System.Xml" />

-    <Reference Include="WindowsBase" />

-  </ItemGroup>

-  <ItemGroup>

-    <Compile Include="Main.cs">

-      <SubType>Form</SubType>

-    </Compile>

-    <Compile Include="Main.Designer.cs">

-      <DependentUpon>Main.cs</DependentUpon>

-    </Compile>

-    <Compile Include="Program.cs" />

-    <Compile Include="Properties\AssemblyInfo.cs" />

-    <EmbeddedResource Include="Main.resx">

-      <DependentUpon>Main.cs</DependentUpon>

-    </EmbeddedResource>

-    <EmbeddedResource Include="Properties\Resources.resx">

-      <Generator>ResXFileCodeGenerator</Generator>

-      <LastGenOutput>Resources.Designer.cs</LastGenOutput>

-      <SubType>Designer</SubType>

-    </EmbeddedResource>

-    <Compile Include="Properties\Resources.Designer.cs">

-      <AutoGen>True</AutoGen>

-      <DependentUpon>Resources.resx</DependentUpon>

-      <DesignTime>True</DesignTime>

-    </Compile>

-    <None Include="app.config">

-      <SubType>Designer</SubType>

-    </None>

-    <None Include="Properties\Settings.settings">

-      <Generator>SettingsSingleFileGenerator</Generator>

-      <LastGenOutput>Settings.Designer.cs</LastGenOutput>

-    </None>

-    <Compile Include="Properties\Settings.Designer.cs">

-      <AutoGen>True</AutoGen>

-      <DependentUpon>Settings.settings</DependentUpon>

-      <DesignTimeSharedInput>True</DesignTimeSharedInput>

-    </Compile>

-  </ItemGroup>

-  <ItemGroup>

-    <BootstrapperPackage Include=".NETFramework,Version=v4.0">

-      <Visible>False</Visible>

-      <ProductName>Microsoft .NET Framework 4 Full Profile %28x86 and x64%29</ProductName>

-      <Install>true</Install>

-    </BootstrapperPackage>

-    <BootstrapperPackage Include="Microsoft.Net.Client.3.5">

-      <Visible>False</Visible>

-      <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>

-      <Install>false</Install>

-    </BootstrapperPackage>

-    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">

-      <Visible>False</Visible>

-      <ProductName>.NET Framework 3.5 SP1</ProductName>

-      <Install>false</Install>

-    </BootstrapperPackage>

-    <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">

-      <Visible>False</Visible>

-      <ProductName>Windows Installer 3.1</ProductName>

-      <Install>true</Install>

-    </BootstrapperPackage>

-  </ItemGroup>

-  <ItemGroup>

-    <Content Include="Resources\htm.ico" />

-  </ItemGroup>

-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

-       Other similar extension points exist, see Microsoft.Common.targets.

-  <Target Name="BeforeBuild">

-  </Target>

-  <Target Name="AfterBuild">

-  </Target>

-  -->

-</Project>
\ No newline at end of file
diff --git a/src/htm/meson.build b/src/htm/meson.build
new file mode 100644
index 00000000..8fa93b03
--- /dev/null
+++ b/src/htm/meson.build
@@ -0,0 +1,33 @@
+add_languages('cs')
+
+executable('thememan',
+  sources: [
+    'Program.cs',
+    'Main.cs',
+    'Main.Designer.cs',
+  ],
+  resources: [
+    # 'Main.resx', # FIXME: Allow setting resource id
+    'thememan.HTM.resources',
+  ],
+  cs_args: [
+    '-r:WindowsBase',
+    '-r:System.Data',
+    '-r:System.Drawing',
+    '-r:System.Windows.Forms',
+    '-win32icon:' + meson.current_source_dir() + '/Resources/htm.ico'
+  ],
+  install: true,
+)
+
+thememan_conf = configuration_data()
+thememan_conf.set('exec_prefix', get_option('prefix'))
+thememan_conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
+
+configure_file(
+  input: 'thememan.in',
+  output: 'thememan',
+  configuration: thememan_conf,
+  install: true,
+  install_dir: get_option('bindir'),
+)
diff --git a/src/htm/thememan.HTM.resources b/src/htm/thememan.HTM.resources
new file mode 100644
index 00000000..39374ac0
--- /dev/null
+++ b/src/htm/thememan.HTM.resources
Binary files differdiff --git a/src/htm/thememan.in b/src/htm/thememan.in
index f6f80df6..f6f80df6 100644..100755
--- a/src/htm/thememan.in
+++ b/src/htm/thememan.in
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 00000000..ff2c8871
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,13 @@
+subdir('common')
+
+if get_option('with-gtk')
+  subdir('fe-gtk')
+endif
+
+if get_option('with-text')
+  subdir('fe-text')
+endif
+
+if get_option('with-theme-manager')
+  subdir('htm')
+endif
diff --git a/win32/version-template.ps1 b/win32/version-template.ps1
index 18eb90d9..0a884906 100644
--- a/win32/version-template.ps1
+++ b/win32/version-template.ps1
@@ -1,6 +1,6 @@
 param ([string] $templateFilename, [string] $outputFilename)
 
-$versionParts = Select-String -Path "${env:SOLUTIONDIR}configure.ac" -Pattern '^AC_INIT\(\[HexChat\],\[([^]]+)\]\)$' | Select-Object -First 1 | %{ $_.Matches[0].Groups[1].Value.Split('.') }
+$versionParts = Select-String -Path "${env:SOLUTIONDIR}meson.build" -Pattern "  version: '([^']+)',$" | Select-Object -First 1 | %{ $_.Matches[0].Groups[1].Value.Split('.') }
 
 [string[]] $contents = Get-Content $templateFilename -Encoding UTF8 | %{
 	while ($_ -match '^(.*?)<#=(.*?)#>(.*?)$') {