Re: [dev] getting rid of cmake builds

From: Mattias Andrée <maandree_AT_kth.se>
Date: Fri, 22 Sep 2023 17:08:15 +0200

On Fri, 22 Sep 2023 15:54:59 +0200
Laslo Hunhold <dev_AT_frign.de> wrote:

> On Thu, 21 Sep 2023 16:05:17 +0200
> David Demelier <markand_AT_malikania.fr> wrote:
>
> Dear David,
>
> > It's near to impossible to convert a CMake project to make
> > automatically, CMake is almost like a scripting language given the
> > numerous of things you can do with it.
> >
> > Keep in mind that plain make (POSIX) is enough for really simple
> > projects but can come limited when going portable. Although the use of
> > pkg-config helps there are various places where you will need to pass
> > additional compiler/linker flags. For those I like GNU make even
> > though its syntax is somewhat strange at some points.
> >
> > Which projects are you referring to?
>
> the "POSIX makefiles are not easily portable" aspect hasn't been true
> for a long time. Check out the build system of my project libgrapheme.
> It is 100% POSIX make and portable across all BSDs, macOS, Cygwin,
> MinGW and of course Linux, including automatically naming and embedding
> the semantic version as specified in the Makefile. This is done by
> providing a very simple ./configure script that automatically modifies
> config.mk and tells the user when they are working from a system that
> hasn't been ported to yet.

You can used make to run ./configure automatically, all you need to do is simply
rename Makefile to makefile.in, let ./configure run `ln -s makefile.in makefile`
and create a new file named Makefile containing:

        .POSIX:
        .DEFAULT:
                ./configure
                $(MAKE) -f makefile $_AT_

I think running ./configure isn't a big deal, however this technique is also very
useful if you want to automatically generate rules and variables for Makefile.
it's especially powerful because make(1posix) expressly states that `-f -` shall be
interpreted as using stdin as the makefile.

Extremely occasionally POSIX make can feel like it's not enough or at least not
efficient enough (at write time or build time), and GNU make can fix these issues,
however using this double makefile technique, all of these can be addressed (of
course not always as nicely as non-standard features can). Just look at this
beauty: https://codeberg.org/maandree/simple-icon-theme/src/branch/master/Makefile

>
> libgrapheme has automatic unit tests and code generators written in
> C99, so it's probably a very extreme example. You could easily adapt a
> library project using the libgraphmee configure+config.mk+Makefile as a
> basic template.
>
> Feel free to contact me if you have any questions.
>
> With best regards
>
> Laslo
>
> [0]:https://git.suckless.org/libgrapheme/
>
Received on Fri Sep 22 2023 - 17:08:15 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 22 2023 - 18:00:09 CEST