Annotation of wikisrc/pkgsrc/how_to_convert_autotools_to_meson.mdwn, revision 1.5

1.1       nia         1: How to convert autotools to meson
                      2: =================================
                      3: 
                      4: GNU's build system ("autotools", ./configure, etc) was previously the
                      5: main one used by most of the open source world. However, lots of high
                      6: profile projects (GNOME, etc) have been switching from it to a new
                      7: python-based one, called meson.
                      8: 
                      9: Many things in pkgsrc have needed to be updated to use meson, so
                     10: here's a guide on doing it properly.
                     11: 
                     12: Basics
                     13: ------
                     14: 
                     15: You won't need the following, so delete them:
                     16: 
1.5     ! nia        17:        GNU_CONFIGURE=          yes
        !            18:        USE_LIBTOOL=            yes
        !            19:        USE_PKGLOCALEDIR=       yes
1.1       nia        20: 
                     21: Neither meson or cmake (another increasingly popular alternative) uses
                     22: libtool to make shared libraries.
                     23: 
1.5     ! nia        24: `USE_PKGLOCALEDIR` is also actively harmful here.
        !            25: 
1.1       nia        26: You will need the following:
                     27: 
                     28:        .include "../../devel/meson/build.mk"
                     29: 
                     30: Tools
                     31: -----
                     32: 
                     33: Only the following tools are generally needed:
                     34: 
                     35:        USE_TOOLS+=     pkg-config msgfmt xgettext
                     36: 
                     37: Nearly every meson package needs pkg-config, since it's the main way it
                     38: resolves dependencies. This also means that dependencies where the
                     39: buildlink isn't included won't be detected.
                     40: 
                     41: meson does not use intltool or other gettext tools than xgettext
                     42: and msgfmt. If your package uses `i18n.gettext` in a `meson.build` file
                     43: it needs xgettext, and if it uses `i18n.merge_file` it needs msgfmt.
                     44: It's easy to check this with grep.
                     45: 
                     46: Python
                     47: ------
                     48: 
                     49: Every Meson project uses Python to build, but many don't install
                     50: Python scripts and don't need it to run, so you should add the following:
                     51: 
                     52:        PYTHON_FOR_BUILD_ONLY=  tool
                     53: 
                     54: If the build process needs a `python3`, `python2`, or `python` binary to
                     55: execute scripts during the build, you should also include the following:
                     56: 
                     57:        .include "../../lang/python/tool.mk"
                     58: 
                     59: This will automatically create a python executable with the appropriate
                     60: suffix (or lack of suffix) for the duration of the build.
                     61: 
                     62: pkgconfig overrides
                     63: -------------------
                     64: 
                     65: Libraries that use meson generally generate .pc files for use
                     66: by pkg-config. This happens during the build, while previously
                     67: they would have been pregenerated.
                     68: 
                     69: You should search for .pc files after the build is complete
                     70: and set the appropriate flags:
                     71: 
                     72:        PKGCONFIG_OVERRIDE_STAGE=       pre-install
                     73:        PKGCONFIG_OVERRIDE+=            output/meson-private/glesv2.pc
                     74: 
                     75: This is necessary so that pkgsrc sets the correct runtime
                     76: path for libraries.
                     77: 
                     78: Remove any old references to nonexistent .pc files from the old
                     79: build system in the PKGCONFIG_OVERRIDE.
1.2       nia        80: 
                     81: gettext issues on NetBSD
                     82: ------------------------
                     83: 
                     84: NetBSD includes an (old, pre-GPLv3?) version of msgfmt. This doesn't
                     85: have the new --desktop or --xml flags, so you'll get a build error
                     86: if a package attempts to use these.
                     87: 
                     88: There's an easy workaround:
                     89: 
                     90:        .include "../../mk/bsd.prefs.mk"
                     91: 
                     92:        # msgfmt: unknown option -- desktop
                     93:        .if ${OPSYS} == "NetBSD"
                     94:        TOOLS_PLATFORM.msgfmt=
                     95:        .endif
                     96: 
                     97: Flags
                     98: -----
                     99: 
                    100: Flags of the following form:
                    101: 
                    102:        CONFIGURE_ARGS+=        --enable-opengl
                    103: 
                    104: Generally now take the following form:
                    105: 
                    106:        MESON_ARGS+=            -Dopengl=true
1.3       nia       107: 
                    108: Check the `meson_options.txt` file.

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb