bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [doc] MAKEOVERRIDES is undocumented


From: Alejandro Colomar
Subject: Re: [doc] MAKEOVERRIDES is undocumented
Date: Mon, 19 Dec 2022 17:02:15 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.0

Hi Jeffrey,

On 12/19/22 16:57, Jeffrey Walton wrote:
On Mon, Dec 19, 2022 at 10:45 AM Alejandro Colomar
<alx.manpages@gmail.com> wrote:

I needed to use MAKEOVERRIDES for updating a pkgconf (.pc) file.  I want it to
have the correct directory variables as used when building/installing the
library, so if the user specifies 'includedir=/foo/bar' in the command line, the
.pc file should be updated with that info.

The rule I had to use is:

$(_LIB_pc): $(_LIB_pc_u) Makefile | $$(@D)/
         $(info  SED             $@)
         sed 's/Version:.*/Version: $(DISTVERSION)/' <$< >$@
         sed -i 's,prefix=.*,prefix=$(prefix),' $@
ifneq ($(filter includedir=%,$(MAKEOVERRIDES)),)
         sed -i 's,includedir=.*,includedir=$(includedir),' $@
endif

As you can see, I need to check if it was overridden in the command line
(otherwise, the default 'includedir=${prefix}/include' in the .pc file is fine).
   And then I do override it.

I don't think you need to go to extremes. Just check if includedir is
set. If so, use it. If not, use the default of $prefix/include.

You can do this in your makefile [1,2]:

    ifeq ($(includedir),)
      includedir := $(prefix)/include
      PC_INCLUDEDIR = $${prefix}/include
    else
      PC_INCLUDEDIR = $(includedir)
    endif

     myconfig.pc:
         ...
        @echo 'includedir=$(PC_INCLUDEDIR)' >> myconfig.pc

Jeff

[1] https://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L202
[2] https://github.com/weidai11/cryptopp/blob/master/GNUmakefile#L1544

Interesting!  Thanks for the idea!

Anyway, the missing documentation bug is still a concern :)


Cheers,

Alex

--
<http://www.alejandro-colomar.es/>

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]