On Mon, Dec 19, 2022 at 10:45 AM Alejandro Colomar <alx.manpa...@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