This page uses [AppStream-glib](https://github.com/hughsie/appstream-glib/) as an example project. AppStream-Glib contains some libraries, GObject Introspection data, tests, man pages, i18n, bash-completion with optional flags to build/notbuild support for some things.
as_version = meson.project_version() # set in project() below
ver_arr = as_version.split('.')
as_major_version = ver_arr[0]
as_minor_version = ver_arr[1]
as_micro_version = ver_arr[2]
```
### Initializing project and setting compilers
`configure.ac`:
```autoconf
AC_INIT([appstream-glib],[as_version])
AC_PROG_CC
```
`meson.build`:
```meson
project('appstream-glib', 'c', version : '0.3.6')
```
Note that this must be the first line of your `meson.build` file.
### AC_SUBST
`configure.ac`:
```autoconf
AC_SUBST(AS_MAJOR_VERSION)
AC_SUBST(AS_MINOR_VERSION)
AC_SUBST(AS_MICRO_VERSION)
AC_SUBST(AS_VERSION)
```
You don't need to do the same in Meson, because it does not have two different types of files (Makefile, configure).
### Auto headers
`configure.ac`:
```autoconf
AC_CONFIG_HEADERS([config.h])
```
`meson.build`:
```meson
conf = configuration_data()
# Surround the version in quotes to make it a C string
conf.set_quoted('VERSION', as_version)
configure_file(output : 'config.h',
configuration : conf)
```
Meson doesn't support autoheaders, you need to manually specify what do you want to see in header file, write `configuration_data()` object and use `configure_file()`.
You can also substitute variables of type `@SOME_VAR@` with configure data. The details are on the [configuration page](Configuration.md).
### Finding programs
`configure.ac`:
```autoconf
AC_PATH_PROG(GPERF, [gperf], [no])
if test x$GPERF != xno ; then
AC_DEFINE(HAVE_GPERF,[1], [Use gperf])
fi
AM_CONDITIONAL(HAVE_GPERF, [test x$GPERF != xno])
```
`meson.build`:
```meson
gperf = find_program('gperf', required : false)
if gperf.found()
conf.set('HAVE_GPERF', 1)
endif
```
### Finding pkgconfig modules
`configure.ac`:
```autoconf
PKG_CHECK_MODULES(SOUP, libsoup-2.4 >= 2.24)
```
`meson.build`:
```meson
soup = dependency('libsoup-2.4', version : '>= 2.24')
option('enable-dep11', type : 'boolean', value : true, description : 'enable DEP-11')
```
## Makefile.am
Next step is `Makefile.am`. In meson you don't need to have other file, you still use `meson.build`.
### Sub directories
`Makefile.am`:
```make
SUBDIRS = \
libappstream-glib
```
`meson.build`:
```meson
subdir('libappstream-glib')
```
### *CLEANFILES, EXTRA_DIST, etc.
`Makefile.am`:
```make
DISTCLEANFILES = \
appstream-glib-*.tar.xz
MAINTAINERCLEANFILES = \
*~ \
ABOUT-NLS \
aclocal.m4 \
ChangeLog \
compile \
config.guess \
config.h.* \
config.rpath
EXTRA_DIST = \
COPYING \
MAINTAINERS \
AUTHORS \
README.md \
NEWS \
autogen.sh \
config.h
```
In Meson you don't need have `*CLEANFILES`, because in meson you are building in temporary directory (usually called `build`), you manually removing it. You also not need to use `EXTRA_DIST`, because you will make tarballs via `git archive` or something like this.