Re: Python recompile

Lawrence D'Oliveiro <[email protected]>
Newsgroups comp.lang.c,comp.lang.python
Organization A noiseless patient Spider
Message-ID <[email protected]>
On Thu, 6 Mar 2025 19:21:45 -0000 (UTC), Waldek Hebisch wrote:

> Per platform Makefile-s do not scale when one wants to support multiple
> system and multiple configurations (there is exponential growth of
> possible combinations).  And even of single configuration for supposedly
> single system like Linux there are troubles.
> In one project there was someting like 20 Makefile.linux_x files where x
> represented one Linux flavour.  Yet regularly somebody would come and
> say: "build fails on my Linux x.y.z".  If enough information was
> provided new Makefile was added, or possibly some similar Makefile was
> modified to cover more cases.

Can you offer more details on the project in question? I ask because
there are things that can be done in GNU Makefiles to deal more
dynamically with environmental differences in some simpler cases,
without resorting to a full-on meta-build system like Autotools or
CMake, and perhaps the maintainers of this project aren’t aware of
that.

Here’s a simple example, building an extension module for Python:

    CFLAGS=-g $(shell python3-config --includes) -fPIC -Wall -Wno-switch -Wno-parentheses

    gxscript_lexer.so : gxscript_lexer.o
        $(CC) $^ $(shell python3-config --ldflags) -shared -o $@

    gxscript_lexer.o : gxscript_lexer.c

    clean :
        rm -f gxscript_lexer.so gxscript_lexer.o
        rm -rf __pycache__

    .PHONY : clean

Note how it uses the “python3-config” command to figure out the right
flags (including file/directory locations) for compilation and
linking. So it doesn’t have to know that the libraries are in /usr/lib
on one system, and /usr/local/lib on another.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.