The trick is to stop caring about "cflags" file as much as possible.
(Autobuilders only build the package once).
Of course, but I will not do this unless the correct solution will prove to
be excessively complex.

Hmm, I guess that by "correct" you mean here "what upstream would have done
30 years ago if he had knew about this Makefile problem at that time,
following his own coding standards and style".

In such case, please take a look at this patch which I attach now.
Explanation: In release 7.6.q-34, you changed one of the lines
to read like this:

config-check cflags:

and I think that opens the door for a race-condition: Some process
might want to redo config-check and some other process might want
to redo cflags, at the same time.

In the proposed patch, cflags has his own rule:

cflags:
       echo $(CFLAGS) > cflags

and it will only work when the file cflags does not exist.

Then we modify config-check to depend on cflags:

config-check: cflags

so it's only used to check that cflags is the same as CFLAGS when cflags
already exists, but not used to create cflags itself, as that's already
in the previous rule.

I've tested this using --shuffle a lot of times and I believe it fixes
the current issues, at the same time it tries to be "faithful" to
the original idea by the author.

Thanks.
--- a/Makefile
+++ b/Makefile
@@ -720,9 +720,12 @@
 
 LIB	= libwrap.a
 
-shared/%.o: %.c
+shared/%.o: %.c shared
 	$(CC) $(CFLAGS) $(SHCFLAGS) -c $< -o $@
 
+shared:
+	mkdir -p $@
+
 SOMAJOR = 0
 SOMINOR = 7.6
 
@@ -739,7 +742,10 @@
 
 # Invalidate all object files when the compiler options (CFLAGS) have changed.
 
-config-check cflags:
+cflags:
+	echo $(CFLAGS) > cflags
+
+config-check: cflags
 	@set +e; test -n "$(REAL_DAEMON_DIR)" || { make; exit 1; }
 	@set +e; echo $(CFLAGS) >cflags.new ; \
 	if cmp cflags cflags.new ; \

Reply via email to