-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Makefile: Fix check for pkg-config + fix compilation with non-GNU make (e.g. bmake and bsdmake) #124
Makefile: Fix check for pkg-config + fix compilation with non-GNU make (e.g. bmake and bsdmake) #124
Conversation
This happens because: ttyplot.o: require_pkgconfig means that ttyplot has There are 3 general solutions here:
|
@eli-schwartz that is understood, yes.
I didn't like that option too much e.g. because pkg-config could be uninstalled after the stamp file is created. We can argue how likely of a scenario that is, but I'm not a fan.
I knew order-only dependencies and like them but even with nothing to rebuild, The diff: diff --git a/Makefile b/Makefile
index aea08f0..3d7dde1 100755
--- a/Makefile
+++ b/Makefile
@@ -22,10 +22,10 @@ clean:
rm -f ttyplot stresstest *.o
require_pkgconfig:
- which pkg-config
+ command -v pkg-config >/dev/null
-ttyplot.o: require_pkgconfig
+ttyplot.o: | require_pkgconfig
-stresstest.o: require_pkgconfig
+stresstest.o: | require_pkgconfig
.PHONY: all clean install uninstall require_pkgconfig The make: # make --version | head -n1
GNU Make 4.4.1 The output: # make ; make
command -v pkg-config
command -v pkg-config It's a bit less output than what we have in the pull request right now, but it's calling
I'd be with you here personally but #65 (comment) . |
But running it once in the
My suggestion was based off of the fact that the current Makefile is GNU specific already. Has it been tested with other Make implementations? My usual goto here is to run
???
Foiled... it is not running the I don't usually try to give suggestions that work with portable non-GNU make implementations if the existing Makefile doesn't appear to handle that to begin with. ... This is another reason to prefer a real build system.
Hmm
@tenox7 Is there a specific reason you don't like the complexity that autotools brings? Because I poked at it for a couple of minutes:
autotools can be really, really, really simple. I didn't even use automake, so the Makefile barely changed at all. Here's what Makefile looks like after running configure: prefix = /usr/local
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
datarootdir = ${prefix}/share
mandir = ${datarootdir}/man
CFLAGS = -Wall -Wextra -g -O2 -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600
LDFLAGS = -lncurses -ltinfo
torture: LDLIBS = -lm
all: ttyplot
install: ttyplot ttyplot.1
install -d $(DESTDIR)$(bindir)
install -d $(DESTDIR)$(mandir)/man1
install -m755 ttyplot $(DESTDIR)$(bindir)
install -m644 ttyplot.1 $(DESTDIR)$(mandir)/man1
uninstall:
rm -f $(DESTDIR)$(bindir)/ttyplot
rm -f $(DESTDIR)$(mandir)/man1/ttyplot.1
clean:
rm -f ttyplot torture *.o
.PHONY: all clean install uninstall require_pkgconfig The only thing configure does, is set the 7 variable assignments at the top of the file by doing system probing. |
A few things I learned in the meantime:
Hence:
|
I know (how) it can be fixed -- I just don't really consider it worth the time lol. My motto is "if it ain't tested, or used by a core developer, don't think you actually support it". I'd just move it to GNUmakefile. Pretty much regardless of your platform, you'll be able to manually install gmake. It may not be installed by default, but it will be available. This is a much more worthwhile time investment than fixing bsdmake bugs on the rare occasion they are reported, then regressing again. |
@eli-schwartz full ack, well said. |
6739534
to
819fda9
Compare
@eli-schwartz: Thanks for bringing this up, and thanks also for the analysis of the always-rebuild problem, and for the tip about testing with @hartwork wrote:
My take on this is that changing the build system, whether that may be explicitly requiring GNU make or going with autotools/cmake/whatever, is a decision that belongs to @tenox7. He may not be very active on this right now, but my understanding is that he owns a few non-Linux Unix boxes (macOS and others) and he does care about portability to these Unices. In the mean time, I suggest adding this suffix rule, which works with both GNU make and bmake: .c:
@pkg-config --version > /dev/null
$(CC) $(CFLAGS) $< $(LDLIBS) -o $@ The |
@edgar-bonet I think this picture i missing that we already have
The prefix rule you mention would need to include I should also not that we have things in the code now that required POSIX >=2008 and C99 so supporting non-GNU make older than those two is potential "money out the window", at least with moderately consistent setups in mind. What do you think? |
@edgar-bonet PS: For proof of that, I'm tricking GNU make to print its implicit rules for direct "app.c -> app" compilation to make it reveal use of # cd "$(mktemp -d)" && echo missing{,.c} | xargs -n1 touch && CC='true $${CC}' CFLAGS='$${CFLAGS}' LDFLAGS='$${LDFLAGS}' LDLIBS='$${LDLIBS}' make missing | sed 's,^true ,,'
${CC} ${CFLAGS} ${LDFLAGS} missing.c ${LDLIBS} -o missing
# make --version | head -n1
GNU Make 4.4.1 I should have started with LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)
.c:
$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@ After inlining and dropping .c:
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@ …but |
4a27898
to
2ef8535
Compare
@edgar-bonet I have put your idea into place now, adding |
Addresses two issues: - "which" is not the best choice for portability (reported by Eli Schwartz) - .c files would keep getting recompiled for no good reason (reported by Edgar Bonet) Co-authored-by: Edgar Bonet <[email protected]>
New coverage as of today: - bmake 20200710 (Ubuntu 22.04) - bmake 20230909 (homebrew) - bsdmake 24 (homebrew) - GNU make 3.81 (homebrew) - GNU make 4.3 (Ubuntu 22.04)
.. to protect against future build system regressions with reguard to as-needed.
2ef8535
to
89dd141
Compare
In reaction to #109 (review)
Addresses two issues:
which
is not the best choice for portability (reported by @eli-schwartz).c
files would keep getting recompiled for no good reason (reported by @edgar-bonet)