diff --git a/.ci/upload_win_installer.sh b/.ci/upload_win_installer.sh
deleted file mode 100644
index 3550d7779516a1085aa8bbaf2063018d118f3f1d..0000000000000000000000000000000000000000
--- a/.ci/upload_win_installer.sh
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-dest="ftp://shelter.mahoro-net.org/aegisub-japan7"
-tag=$(git describe --exact-match)
-[ "$tag" ] || exit
-
-curl -T 'packages\win_installer\output\Aegisub-Japan7-x64.exe' --user $FTP_USER:$FTP_PASS "$dest/Aegisub-Japan7-${tag#v}-x64.exe"
-
-printf "${tag#v}\n$(git tag -l --format='%(contents)' $tag)" > latest
-curl -T latest --user "$FTP_USER:$FTP_PASS" "$dest/"
-
-url="Aegisub-Japan7-${tag#v}-x64.exe"
-printf "<!doctype html><html><head><meta http-equiv='refresh' content='0; url=$url' /></head><body><a href='$url'>$url</a></body></html>" > Aegisub-Japan7-latest-x64
-curl -T Aegisub-Japan7-latest-x64 --user "$FTP_USER:$FTP_PASS" "$dest/"
diff --git a/.gitignore b/.gitignore
index 1423a63c602333f218f654b1b3126d3f4409b8ff..a72e0bd5bcd8634022c431725065d542a5d1d087 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,3 +98,5 @@ vendor/luajit/src/luajit
 *.tmp
 cscope.files
 tags
+config.guess
+config.sub
diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config
deleted file mode 100644
index 25dfbe7ab788e25ee0206dcdbf88821c5c2847fa..0000000000000000000000000000000000000000
--- a/.nuget/NuGet.Config
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<configuration>
-  <solution>
-    <add key="disableSourceControlIntegration" value="true" />
-  </solution>
-  <config>
-    <add key="repositoryPath" value="lib" />
-  </config>
-</configuration>
diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets
deleted file mode 100644
index 2cada41fb6405ce4e98c4862e2c572d0797970d6..0000000000000000000000000000000000000000
--- a/.nuget/NuGet.targets
+++ /dev/null
@@ -1,150 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-    <PropertyGroup>
-        <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)\..\</SolutionDir>
-
-        <!-- Enable the restore command to run before builds -->
-        <RestorePackages Condition="  '$(RestorePackages)' == '' ">true</RestorePackages>
-
-        <!-- Property that enables building a package from a project -->
-        <BuildPackage Condition=" '$(BuildPackage)' == '' ">false</BuildPackage>
-
-        <!-- Determines if package restore consent is required to restore packages -->
-        <RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'false' ">false</RequireRestoreConsent>
-
-        <!-- Download NuGet.exe if it does not already exist -->
-        <DownloadNuGetExe Condition=" '$(DownloadNuGetExe)' == '' ">true</DownloadNuGetExe>
-    </PropertyGroup>
-
-    <ItemGroup Condition=" '$(PackageSources)' == '' ">
-        <!-- Package sources used to restore packages. By default will used the registered sources under %APPDATA%\NuGet\NuGet.Config -->
-        <!--
-            <PackageSource Include="https://nuget.org/api/v2/" />
-            <PackageSource Include="https://my-nuget-source/nuget/" />
-        -->
-    </ItemGroup>
-
-    <PropertyGroup Condition=" '$(OS)' == 'Windows_NT'">
-        <!-- Windows specific commands -->
-        <NuGetToolsPath>$([System.IO.Path]::Combine($(SolutionDir), ".nuget"))</NuGetToolsPath>
-        <PackagesConfig>$([System.IO.Path]::Combine($(ProjectDir), "packages.config"))</PackagesConfig>
-    </PropertyGroup>
-
-    <PropertyGroup Condition=" '$(OS)' != 'Windows_NT'">
-        <!-- We need to launch nuget.exe with the mono command if we're not on windows -->
-        <NuGetToolsPath>$(SolutionDir).nuget</NuGetToolsPath>
-        <PackagesConfig>packages.config</PackagesConfig>
-    </PropertyGroup>
-
-    <PropertyGroup>
-        <!-- NuGet command -->
-        <NuGetExePath Condition=" '$(NuGetExePath)' == '' ">$(NuGetToolsPath)\nuget.exe</NuGetExePath>
-        <PackageSources Condition=" $(PackageSources) == '' ">@(PackageSource)</PackageSources>
-
-        <NuGetCommand Condition=" '$(OS)' == 'Windows_NT'">"$(NuGetExePath)"</NuGetCommand>
-        <NuGetCommand Condition=" '$(OS)' != 'Windows_NT' ">mono --runtime=v4.0.30319 $(NuGetExePath)</NuGetCommand>
-
-        <PackageOutputDir Condition="$(PackageOutputDir) == ''">$(TargetDir.Trim('\\'))</PackageOutputDir>
-
-        <RequireConsentSwitch Condition=" $(RequireRestoreConsent) == 'true' ">-RequireConsent</RequireConsentSwitch>
-        <!-- Commands -->
-        <RestoreCommand>$(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)"  $(RequireConsentSwitch) -solutionDir "$(SolutionDir) "</RestoreCommand>
-        <BuildCommand>$(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols</BuildCommand>
-
-        <!-- We need to ensure packages are restored prior to assembly resolve -->
-        <ResolveReferencesDependsOn Condition="$(RestorePackages) == 'true'">
-            RestorePackages;
-            $(ResolveReferencesDependsOn);
-        </ResolveReferencesDependsOn>
-
-        <!-- Make the build depend on restore packages -->
-        <BuildDependsOn Condition="$(BuildPackage) == 'true'">
-            $(BuildDependsOn);
-            BuildPackage;
-        </BuildDependsOn>
-    </PropertyGroup>
-
-    <Target Name="CheckPrerequisites">
-        <!-- Raise an error if we're unable to locate nuget.exe  -->
-        <Error Condition="'$(DownloadNuGetExe)' != 'true' AND !Exists('$(NuGetExePath)')" Text="Unable to locate '$(NuGetExePath)'" />
-        <SetEnvironmentVariable EnvKey="VisualStudioVersion" EnvValue="$(VisualStudioVersion)" Condition=" '$(VisualStudioVersion)' != '' AND '$(OS)' == 'Windows_NT' " />
-        <!--
-        Take advantage of MsBuild's build dependency tracking to make sure that we only ever download nuget.exe once.
-        This effectively acts as a lock that makes sure that the download operation will only happen once and all
-        parallel builds will have to wait for it to complete.
-        -->
-        <MsBuild Targets="_DownloadNuGet" Projects="$(MSBuildThisFileFullPath)" Properties="Configuration=NOT_IMPORTANT" />
-    </Target>
-
-    <Target Name="_DownloadNuGet">
-        <DownloadNuGet OutputFilename="$(NuGetExePath)" Condition=" '$(DownloadNuGetExe)' == 'true' AND !Exists('$(NuGetExePath)')" />
-    </Target>
-
-    <Target Name="RestorePackages" DependsOnTargets="CheckPrerequisites">
-        <Exec Command="$(RestoreCommand)"
-              Condition="'$(OS)' != 'Windows_NT' And Exists('$(PackagesConfig)')" />
-
-        <Exec Command="$(RestoreCommand)"
-              LogStandardErrorAsError="true"
-              Condition="'$(OS)' == 'Windows_NT' And Exists('$(PackagesConfig)')" />
-    </Target>
-
-    <Target Name="BuildPackage" DependsOnTargets="CheckPrerequisites">
-        <Exec Command="$(BuildCommand)"
-              Condition=" '$(OS)' != 'Windows_NT' " />
-
-        <Exec Command="$(BuildCommand)"
-              LogStandardErrorAsError="true"
-              Condition=" '$(OS)' == 'Windows_NT' " />
-    </Target>
-
-    <UsingTask TaskName="DownloadNuGet" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
-        <ParameterGroup>
-            <OutputFilename ParameterType="System.String" Required="true" />
-        </ParameterGroup>
-        <Task>
-            <Reference Include="System.Core" />
-            <Using Namespace="System" />
-            <Using Namespace="System.IO" />
-            <Using Namespace="System.Net" />
-            <Using Namespace="Microsoft.Build.Framework" />
-            <Using Namespace="Microsoft.Build.Utilities" />
-            <Code Type="Fragment" Language="cs">
-                <![CDATA[
-                try {
-                    OutputFilename = Path.GetFullPath(OutputFilename);
-
-                    Log.LogMessage("Downloading latest version of NuGet.exe...");
-                    WebClient webClient = new WebClient();
-                    webClient.DownloadFile("https://nuget.org/nuget.exe", OutputFilename);
-
-                    return true;
-                }
-                catch (Exception ex) {
-                    Log.LogErrorFromException(ex);
-                    return false;
-                }
-            ]]>
-            </Code>
-        </Task>
-    </UsingTask>
-
-     <UsingTask TaskName="SetEnvironmentVariable" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
-        <ParameterGroup>
-            <EnvKey ParameterType="System.String" Required="true" />
-            <EnvValue ParameterType="System.String" Required="true" />
-        </ParameterGroup>
-        <Task>
-            <Using Namespace="System" />
-            <Code Type="Fragment" Language="cs">
-                <![CDATA[
-                try {
-                    Environment.SetEnvironmentVariable(EnvKey, EnvValue, System.EnvironmentVariableTarget.Process);
-                }
-                catch  {
-                }
-            ]]>
-            </Code>
-        </Task>
-    </UsingTask>
-</Project>
diff --git a/Makefile.target b/Makefile.target
index 516ef3c2451aa3a0fd8a643028919134183dd373..fd40d87bfe92fcac59f3b8719433ab3308e6ee25 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -1,5 +1,5 @@
 ifneq (yes, $(INCLUDING_CHILD_MAKEFILES))
-COMMANDS := all install clean distclean test depclean osx-bundle osx-dmg test-automation test-libaegisub
+COMMANDS := all install clean distclean test depclean osx-bundle osx-dmg test-automation test-libaegisub style tags
 .PHONY: $(COMMANDS)
 .DEFAULT_GOAL := all
 
@@ -89,6 +89,12 @@ depclean: clean
 
 install:
 
+style:
+	./tools/astyle.bash
+
+tags:
+	./tools/tags.bash
+
 # The actual build rules
 .SUFFIXES:
 
diff --git a/README.md b/README.md
index da528cd01fd805bc442d3859954718a1d0496dc6..02d7240232ab9e5cc8ee7c798718b7048b1d850f 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,75 @@
-# Aegisub-Japan7
-
-[![Build status](https://ci.appveyor.com/api/projects/status/5huyx72x00ytp845/branch/master?svg=true)](https://ci.appveyor.com/project/odrling/aegisub/branch/master)
+# Aegisub
 
 ## Installation
 
-The latest Windows build can be downloaded at https://mugen.karaokes.moe/downloads/aegisub-japan7/Aegisub-Japan7-latest-x64
+For now only works with install from source. Only tested on linux. Forked from
+[japan7](https://github.com/odrling/Aegisub.git).
+
+## Building Aegisub
+
+### Linux, BSD or Toasters
+
+Install all the dependencies with the package manager of your distribution:
+
+- wxGTK
+- boost
+- icu
+- ffmpegsource
+- fontconfig
+- freetype
+- libass
+- zlib
+- libiconv
+- opengl
+- openal
+- openssl or libressl
+
+Optional dependencies:
+
+- alsa-lib
+- fftw
+- openal
+- portaudio
+- pulseaudio
+- hunspell
+- luajit (can be bundled with your build)
+- astyle
+
+On debian buster, the packages are the following:
+
+- lua5.3
+- inttool inttool-debian
+- autopoint
+- gettext
+- libffms2-dev
+- libpulse-dev
+- libgtk-3-dev
+- libgl-dev
+- libglu-dev
+- libass
+- libwxgtk3.0-dev
+- libboost-dev
+- libboost-locale-dev
+- libboost-chrono-dev
+- libboost-filesystem-dev
+- libboost-regex-dev
+- libboost-thread-dev
+- astyle
 
-A package is available on the AUR for Arch Linux users: [aegisub-japan7-git](https://aur.archlinux.org/packages/aegisub-japan7-git/)
+Once all the dependencies are installed, run:
 
-An ebuild is available for Gentoo users at https://git.odrling.xyz/odrling/odrling-overlay/src/branch/master/media-video/aegisub/aegisub-9999.ebuild
+```bash
+autoreconf
+./configure --enable-debug --with-libpulse
+make -j$(nproc)
+```
 
-The default style uses the [Amaranth font](https://github.com/googlefonts/amaranth), which is installed by default when installing from the sources above.
+You may also consider the following rules:
 
-## Building Aegisub-Japan7
+- `make clean` to clean build files
+- `make deepclean` to clean build files and files generated by `autoreconf`
+- `make tags` to build the ctags and cscope databases
+- `make style` to format your code with the right style
 
 ### Windows
 
@@ -28,113 +85,103 @@ There are a few optional dependencies:
 2. WinRAR, to build the portable installer
 3. InnoSetup, to build the regular installer
 
-All other dependencies are either stored in the repository or are included as submodules.
+All other dependencies are either stored in the repository or are included as
+submodules.
 
 Building:
 
-1. Clone Aegisub's repository recursively to fetch it and all submodules: `git clone --recursive git@github.com:Aegisub/Aegisub.git` This will take quite a while and requires about 2.5 GB of disk space.
+1. Clone Aegisub's repository recursively to fetch it and all submodules: `git
+   clone --recursive git@github.com:Aegisub/Aegisub.git` This will take quite a
+   while and requires about 2.5 GB of disk space.
 2. Open Aegisub.sln
 3. Build the BuildTasks project.
 4. Build the entire solution.
 
-You should now have a `bin` directory in your Aegisub directory which contains `aegisub32d.exe`, along with a pile of other files.
+You should now have a `bin` directory in your Aegisub directory which contains
+`aegisub32d.exe`, along with a pile of other files.
 
-The Aegisub installer includes some files not built as part of Aegisub (such as Avisynth and VSFilter), so for a fully functional copy of Aegisub you now need to copy all of the files from an installed copy of Aegisub into your `bin` directory (and don't overwrite any of the files already there).
-You'll also either need to copy the `automation` directory into the `bin` directory, or edit your automation search paths to include the `automation` directory in the source tree.
+The Aegisub installer includes some files not built as part of Aegisub (such as
+Avisynth and VSFilter), so for a fully functional copy of Aegisub you now need
+to copy all of the files from an installed copy of Aegisub into your `bin`
+directory (and don't overwrite any of the files already there).  You'll also
+either need to copy the `automation` directory into the `bin` directory, or
+edit your automation search paths to include the `automation` directory in the
+source tree.
 
-After building the solution once, you'll want to switch to the Debug-MinDep configuration, which skips checking if the dependencies are out of date, as that takes a while.
+After building the solution once, you'll want to switch to the Debug-MinDep
+configuration, which skips checking if the dependencies are out of date, as
+that takes a while.
 
 ### OS X
 
-A vaguely recent version of Xcode and the corresponding command-line tools are required.
-Nothing older than Xcode 5 has been tested recently, but it is likely that some later versions of Xcode 4 are good enough.
+You may want to read the Linux, FreeBSD and toaster section for more
+information.
 
-For personal usage, you can use homebrew to install almost all of Aegisub's dependencies:
+A vaguely recent version of Xcode and the corresponding command-line tools are
+required.  Nothing older than Xcode 5 has been tested recently, but it is
+likely that some later versions of Xcode 4 are good enough.
 
-	brew install autoconf automake ffmpeg ffms2 fftw freetype fribidi gettext icu4c libass m4 pkg-config boost
-	brew install luajit --HEAD
-	brew link --force gettext
-	export LDFLAGS="-L/usr/local/opt/icu4c/lib"
-	export CPPFLAGS="-I/usr/local/opt/icu4c/include"
-	export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
-
-wxWidgets is located in vendor/wxWidgets, and can be built like so:
-
-	CPPFLAGS="$CPPFLAGS -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1" \
-	./configure --disable-aboutdlg --disable-animatectrl --disable-aui --disable-any \
-	--disable-bannerwindow --disable-base64 --disable-calendar --disable-caret \
-	--disable-cmdline --disable-colourpicker --disable-compat28 --disable-config \
-	--disable-constraints --disable-datepick --disable-dctransform --disable-debugreport \
-	--disable-dialupman --disable-docview --disable-filehistory --disable-finddlg \
-	--disable-fs_archive --disable-fs_inet --disable-fs_zip --disable-fsvolume \
-	--disable-fswatcher --disable-gif --disable-help --disable-html --disable-ipc \
-	--disable-joystick --disable-jpeg --disable-largefile --disable-markup --disable-mdi \
-	--disable-mediactrl --disable-metafiles --disable-miniframe --disable-notifmsg \
-	--disable-numberdlg --disable-pcx --disable-pnm --disable-postscript \
-	--disable-prefseditor --disable-printarch --disable-progressdlg --disable-propgrid \
-	--disable-protocol --disable-protocols --disable-rearrangectrl --disable-ribbon \
-	--disable-richtext --disable-richtooltip --disable-snglinst --disable-sockets \
-	--disable-sockets --disable-sound --disable-splash --disable-splines \
-	--disable-std_iostreams --disable-svg --disable-tarstream --disable-tiff \
-	--disable-tipdlg --disable-tipwindow --disable-url --disable-webkit --disable-webview \
-	--disable-wizarddlg --disable-xrc \
-	--enable-geometry --enable-imaglist --enable-listctrl --enable-stc --with-cocoa \
-	--with-libpng=yes --with-macosx-version-min=10.9 \
-	--with-opengl \
-	--without-libjpeg --without-libtiff --without-regex \
-	&& make
-
-Once the dependencies are installed, build Aegisub with `autoreconf && ./configure --with-wxdir=/path/to/Aegisub/vendor/wxWidgets && make && make osx-bundle`.
-`autoreconf` should be skipped if you are building from a source tarball rather than `git`.
-
-### Linux, BSD or Toasters
-
-Install all the dependencies with the package manager of your distribution:
-
-	wxGTK
-	boost
-	icu
-	ffmpegsource
-	fontconfig
-	freetype
-	libass
-	zlib
-	libiconv
-	opengl
-	openal
-	openssl or libressl
-
-Optional dependencies:
-
-	alsa-lib
-	fftw
-	openal
-	portaudio
-	pulseaudio
-	hunspell
-	luajit (can be bundled with your build)
+For personal usage, you can use homebrew to install almost all of Aegisub's
+dependencies:
 
+```bash
+brew install autoconf automake ffmpeg ffms2 fftw freetype fribidi gettext icu4c libass m4 pkg-config boost
+brew install luajit --HEAD
+brew link --force gettext
+export LDFLAGS="-L/usr/local/opt/icu4c/lib"
+export CPPFLAGS="-I/usr/local/opt/icu4c/include"
+export PKG_CONFIG_PATH="/usr/local/opt/icu4c/lib/pkgconfig"
+```
 
-Once all the dependencies are installed, run:
+wxWidgets is located in vendor/wxWidgets, and can be built like so:
 
 ```bash
-./autogen.sh
-./configure
-make -j$(nproc)
+CPPFLAGS="$CPPFLAGS -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES=1" \
+./configure --disable-aboutdlg --disable-animatectrl --disable-aui --disable-any \
+--disable-bannerwindow --disable-base64 --disable-calendar --disable-caret \
+--disable-cmdline --disable-colourpicker --disable-compat28 --disable-config \
+--disable-constraints --disable-datepick --disable-dctransform --disable-debugreport \
+--disable-dialupman --disable-docview --disable-filehistory --disable-finddlg \
+--disable-fs_archive --disable-fs_inet --disable-fs_zip --disable-fsvolume \
+--disable-fswatcher --disable-gif --disable-help --disable-html --disable-ipc \
+--disable-joystick --disable-jpeg --disable-largefile --disable-markup --disable-mdi \
+--disable-mediactrl --disable-metafiles --disable-miniframe --disable-notifmsg \
+--disable-numberdlg --disable-pcx --disable-pnm --disable-postscript \
+--disable-prefseditor --disable-printarch --disable-progressdlg --disable-propgrid \
+--disable-protocol --disable-protocols --disable-rearrangectrl --disable-ribbon \
+--disable-richtext --disable-richtooltip --disable-snglinst --disable-sockets \
+--disable-sockets --disable-sound --disable-splash --disable-splines \
+--disable-std_iostreams --disable-svg --disable-tarstream --disable-tiff \
+--disable-tipdlg --disable-tipwindow --disable-url --disable-webkit --disable-webview \
+--disable-wizarddlg --disable-xrc \
+--enable-geometry --enable-imaglist --enable-listctrl --enable-stc --with-cocoa \
+--with-libpng=yes --with-macosx-version-min=10.9 \
+--with-opengl \
+--without-libjpeg --without-libtiff --without-regex \
+&& make
 ```
 
+Once the dependencies are installed, build Aegisub with `autoreconf &&
+./configure --with-wxdir=/path/to/Aegisub/vendor/wxWidgets && make && make
+osx-bundle`.  `autoreconf` should be skipped if you are building from a source
+tarball rather than `git`.
+
 ## Updating Moonscript
 
-From within the Moonscript repository, run `bin/moon bin/splat.moon -l moonscript moonscript/ > bin/moonscript.lua`.
-Open the newly created `bin/moonscript.lua`, and within it make the following changes:
+From within the Moonscript repository, run `bin/moon bin/splat.moon -l
+moonscript moonscript/ > bin/moonscript.lua`.  Open the newly created
+`bin/moonscript.lua`, and within it make the following changes:
 
 1. Prepend the final line of the file, `package.preload["moonscript"]()`, with a `return`, producing `return package.preload["moonscript"]()`.
 2. Within the function at `package.preload['moonscript.base']`, remove references to `moon_loader`, `insert_loader`, and `remove_loader`. This means removing their declarations, definitions, and entries in the returned table.
 3. Within the function at `package.preload['moonscript']`, remove the line `_with_0.insert_loader()`.
 
-The file is now ready for use, to be placed in `automation/include` within the Aegisub repo.
+The file is now ready for use, to be placed in `automation/include` within the
+Aegisub repo.
 
 ## License
 
-All files in this repository are licensed under various GPL-compatible BSD-style licenses; see LICENCE and the individual source files for more information.
-The official Windows and OS X builds are GPLv2 due to including fftw3.
+All files in this repository are licensed under various GPL-compatible
+BSD-style licenses; see LICENCE and the individual source files for more
+information.  The official Windows and OS X builds are GPLv2 due to including
+fftw3.
diff --git a/autogen.sh b/autogen.sh
deleted file mode 100755
index 46b4be7e729fe401117c3d63265bf0142d68adf8..0000000000000000000000000000000000000000
--- a/autogen.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-set -e
-
-echo Running autoreconf...
-autoreconf -ivf "$@"
-
-echo Now run ./configure and then make to build Aegisub
diff --git a/configure.ac b/configure.ac
index 7163ab56d34889878ed6c6beb365000adb389fd8..2c1e2d9f51ee8d04d1ec29a270715ae872fdda28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,22 +1,5 @@
 AC_PREREQ(2.57)
 
-###################
-# Required packages
-###################
-m4_define([boost_required_version], [1.67.0])
-m4_define([curl_required_version], [7.18.2])
-m4_define([ffms2_required_version], [2.16])
-m4_define([fftw3_required_version], [3.3])
-m4_define([fontconfig_required_version], [2.4])
-m4_define([freetype_required_version], [9.7.0])
-m4_define([hunspell_required_version], [1.2.0])
-m4_define([icu_required_version], [4.8.1.1])
-m4_define([libass_required_version], [0.9.7])
-m4_define([libpulse_required_version], [0.5])
-m4_define([pkgconfig_required_version], [0.20])
-m4_define([portaudio_required_version], [19])
-m4_define([wx_required_version], [3.0.0])
-
 #######
 # Setup
 #######
@@ -25,10 +8,28 @@ AC_INIT([Aegisub], [aegisub_version],, [aegisub])
 : ${CXXFLAGS=""}
 AC_CONFIG_SRCDIR([src/main.cpp])
 AC_CONFIG_HEADER([acconf.h])
+AC_CONFIG_MACRO_DIR([m4macros])
 AC_GNU_SOURCE
 AC_CANONICAL_HOST
 AM_SILENT_RULES([yes])
 
+###################
+# Required packages
+###################
+m4_define([boost_required_version],      [1.67.0])
+m4_define([curl_required_version],       [7.18.2])
+m4_define([ffms2_required_version],      [2.16])
+m4_define([fftw3_required_version],      [3.3])
+m4_define([fontconfig_required_version], [2.4])
+m4_define([freetype_required_version],   [9.7.0])
+m4_define([hunspell_required_version],   [1.2.0])
+m4_define([icu_required_version],        [4.8.1.1])
+m4_define([libass_required_version],     [0.9.7])
+m4_define([libpulse_required_version],   [0.5])
+m4_define([pkgconfig_required_version],  [0.20])
+m4_define([portaudio_required_version],  [19])
+m4_define([wx_required_version],         [3.0.0])
+
 ###########################
 # Check host architecture
 ###########################
diff --git a/acinclude.m4 b/m4macros/acinclude.m4
similarity index 100%
rename from acinclude.m4
rename to m4macros/acinclude.m4
diff --git a/tools/astyle.bash b/tools/astyle.bash
new file mode 100755
index 0000000000000000000000000000000000000000..900cf32d6a7f521a1dd3ce7cc49ffb924b4f1b4b
--- /dev/null
+++ b/tools/astyle.bash
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+# OPTIONS='
+#     --style=linux -s4
+#     --pad-oper --pad-header --pad-comma
+#     --align-pointer=name --align-reference=name
+#     --break-one-line-headers
+#     --remove-braces
+#     --break-return-type
+#     --convert-tabs
+#     --close-templates
+#     --max-code-length=101
+#     --mode=c
+#     --lineend=linux
+#     --attach-inlines
+#     --indent-labels
+#     --indent-col1-comments
+#     --indent-preproc-block'
+
+OPTIONS='
+    --style=stroustrup
+    --lineend=linux
+    --attach-inlines --attach-namespaces --attach-classes --attach-extern-c --attach-closing-while --close-templates
+    --min-conditional-indent=0
+    --indent=tab
+    --pad-oper --pad-comma --pad-header
+    --align-pointer=name --align-reference=name
+    --break-closing-braces
+    --keep-one-line-blocks --keep-one-line-statements
+'
+
+SRC='./src ./automation ./libaegisub'
+
+if [ $# -gt 0 ] && [ "$1" = "--check" ] ; then
+    astyle $OPTIONS --dry-run -R ./*.c | grep Formatted
+    [ $? -eq 1 ] && exit 0 || exit 1
+fi
+
+find $SRC -name '*.c'     -exec astyle $OPTIONS --quiet {} \;
+find $SRC -name '*.h'     -exec astyle $OPTIONS --quiet {} \;
+find $SRC -name '*.hpp'   -exec astyle $OPTIONS --quiet {} \;
+find $SRC -name '*.cpp'   -exec astyle $OPTIONS --quiet {} \;
+find $SRC -name '*.orig'  -exec rm {} \;
diff --git a/tools/tags.bash b/tools/tags.bash
new file mode 100755
index 0000000000000000000000000000000000000000..8fa79397249aae0dfc679b5f6013167aa14d8db2
--- /dev/null
+++ b/tools/tags.bash
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+echo "# Create cscope.files database"
+find . -iname '*.c' -o -iname '*.h' | egrep -v '^\.\/docs|depends|build|vendor|tests.*\/' > cscope.files
+echo "# Create cscope.out database"
+cscope -b -i cscope.files -f cscope.out
+echo "# Create ctags database"
+ctags -R ./automation ./src ./libaegisub