Re: no library dependency in Makefile? - Mailing list pgsql-hackers

From Noah Misch
Subject Re: no library dependency in Makefile?
Date
Msg-id 20241113181005.d5.nmisch@google.com
Whole thread Raw
In response to Re: no library dependency in Makefile?  (高增琦 <pgf00a@gmail.com>)
List pgsql-hackers
This burned me recently.

On Sun, Nov 26, 2017 at 02:18:16PM +0800, 高增琦 wrote:
> Update version:
> 1. Re-base with head of master
> 2. Add some basic support for PGXS
> 
> After replacing submake-libpgport/submake-libpgfeutils with
> $(stlib_pgport)/$(stlib_pgfeutils) in
> Makefiles of client programs, I think, may be we should add static lib
> dependency for PGXS.

Maybe.  Naming an installed file as a Make prerequisite can break if installed
to a directory containing a space.  If that works now, we shouldn't break it
for this.  Otherwise, naming the installed prerequisites sounds fine.

> I can think two ways to do that: first, add  a new PG_STLIBS variable, user
> need to
> add static libs to it; second, we generate static lib dependency
> automatically
> from PG_LIBS variable. Which one is better?

I prefer the second one.  With the first one, it's easy to miss omissions.  I
think that concept is useful beyond PG_LIBS and beyond PGXS.  For example:

> -initdb: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
> +initdb: $(OBJS) $(stlib_pgport) $(stlib_pgfeutils) | submake-libpq
>      $(CC) $(CFLAGS) $(OBJS) $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)

This could look like

  initdb: $(OBJS) $(call lib_prereq,$(LDFLAGS) $(LDFLAGS_EX) $(LIBS))

where lib_prereq is a GNU make function that translates -lpgcommon to
SOMEDIR/libpgcommon.a, translates unrecognized arguments to nothing, etc.
This avoids the need to edit the "initdb" rule every time you edit LIBS.  It's
easy to miss doing that, due to distance between the places that edit LIBS and
the places that read it.  For example, Makefile.global is one of the editors
of LIBS.  How do you see it?

Thanks,
nm



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Skip collecting decoded changes of already-aborted transactions
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: schema variables