Makefile: Use 'tr' if 'fmt' is not available
authorBart Van Assche <bvanassche@acm.org>
Mon, 6 Jan 2020 02:16:54 +0000 (18:16 -0800)
committerBart Van Assche <bvanassche@acm.org>
Mon, 6 Jan 2020 18:07:34 +0000 (10:07 -0800)
NetBSD is not the only OS that does not provide 'fmt'. A native MinGW shell
does not provide 'fmt' either. Hence detect at runtime whether or not 'fmt'
is available.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Makefile

index 271269f9256485ac16364a6f41aee6092f3c0987..45ce6f20b7b22c530bf4b3e9fe194fe2a71cbaea 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -387,13 +387,14 @@ override CFLAGS += -DFIO_VERSION='"$(FIO_VERSION)"'
        @$(CC) -MM $(CFLAGS) $(CPPFLAGS) $(SRCDIR)/$*.c > $*.d
        @mv -f $*.d $*.d.tmp
        @sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
-ifeq ($(CONFIG_TARGET_OS), NetBSD)
-       @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | tr -cs "[:graph:]" "\n" | \
-               sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d
-else
-       @sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 | \
-               sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
-endif
+       @if type -p fmt >/dev/null 2>&1; then                           \
+               sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -w 1 |  \
+               sed -e 's/^ *//' -e 's/$$/:/' >> $*.d;                  \
+       else                                                            \
+               sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp |             \
+               tr -cs "[:graph:]" "\n" |                               \
+               sed -e 's/^ *//' -e '/^$$/ d' -e 's/$$/:/' >> $*.d;     \
+       fi
        @rm -f $*.d.tmp
 
 ifdef CONFIG_ARITHMETIC