Skip to content

Commit cf5f593

Browse files
committed
Makefile BSD compat improved
In the workaround rules, try to use first word of $+ (list of prerequisities) in place of $<, which is part of POSIX Issue 8 (2024) but not yet implemented by BSDs. On contrary, it is implemented by GNU Make. For the first case, use $@ (target) as a fallback.
1 parent 5dbf920 commit cf5f593

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Makefile.in

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,12 +289,14 @@ POSTPROCESS_DEPS = \
289289
@$(REAL_CUDA_COMPILER) $(CUDA_FLAGS) $(CUDA_INC) -M $< > $*.d
290290
$(POSTPROCESS_DEPS)
291291

292-
# rules specialized for some files below
293-
# using C[XX]_NO_SUFF because $< unavailable in non-suffix rules (except GNUmake)
294-
CC_NO_SUFF_0 = @echo "Compiling $@..."; $(REAL_CC)
292+
# rules specialized for the targets below; using C[XX]_NO_SUFF because $<
293+
# unavailable in non-suffix rules except GNUmake. $+ (list of prerequisities)
294+
# is defined by POSIX Issue 8 but not yet available in BSD's Make so using $@ as
295+
# a workaround.
296+
CC_NO_SUFF_0 = @N=$$(echo $+ | awk '{print $$1}'); echo "Compiling $${N:-$@}..."; $(REAL_CC)
295297
CC_NO_SUFF_1 = $(REAL_CC)
296298
CC_NO_SUFF = $(CC_NO_SUFF_$(VERBOSE))
297-
CXX_NO_SUFF_0 = @echo "Compiling $@..."; $(REAL_CXX)
299+
CXX_NO_SUFF_0 = @N=$$(echo $+ | awk '{print $$1}'); echo "Compiling $${N:-$@}..."; $(REAL_CXX)
298300
CXX_NO_SUFF_1 = $(REAL_CXX)
299301
CXX_NO_SUFF = $(CXX_NO_SUFF_$(VERBOSE))
300302

0 commit comments

Comments
 (0)