[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Copying compiler run-time files in the makefiles
From: |
Greg Chicares |
Subject: |
Re: [lmi] Copying compiler run-time files in the makefiles |
Date: |
Thu, 21 Jul 2022 22:48:18 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 |
On 7/21/22 21:10, Vadim Zeitlin wrote:
> On Thu, 21 Jul 2022 15:02:27 +0000 Greg Chicares <gchicares@sbcglobal.net>
> wrote:
[...This:
+@for z in $(compiler_runtime_files); do \
$(INSTALL) -c -m 0775 -c $$z $(localbindir) ; \
done;
looks like a goofy way of testing a condition like this:
[ -z "$(compiler_runtime_files)" ]
and I had thought it was a workaround for a trailing spaced in that
'make' variable; but historically it was a loop that installed these
files to multiple directories, and commit aebe56bb16eae removed the
multiple directories, but retained the goofiness...]
> GC> Maybe
> GC> [ -z "$(strip $(compiler_runtime_files))" ]
> GC> would work (although I'm not sure I can do that in a recipe),
>
> Make functions can be applied anywhere and this looks like a perfectly
> reasonable solution to me.
>
> GC> but then I'd want to explain why the $(strip ...) function is used.
>
> FWIW, I think using strip for the -z argument is rather self-explanatory.
Now that you put it that way, I find that I agree.
- It looks natural enough.
- If someone removes it and catastrophe ensues, well...
http://www.catb.org/jargon/html/D/Don-t-do-that-then-.html
- Also see the "is natural anyway" comment in the "tests" section below.
And 'install' is designed to work with multiple files, so splitting
them is unnatural. Thus, I'll commit this:
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
diff --git a/GNUmakefile b/GNUmakefile
index 6e99ed135..a27baa18b 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -236,9 +236,8 @@ $(build_dir): $(gpl_files)
+@[ -d $(localbindir) ] || $(MKDIR) --parents $(localbindir)
+@[ -d $(locallibdir) ] || $(MKDIR) --parents $(locallibdir)
+@[ -d $(localincludedir) ] || $(MKDIR) --parents $(localincludedir)
- +@for z in $(compiler_runtime_files); do \
- $(INSTALL) -c -m 0775 -c $$z $(localbindir) ; \
- done;
+ +@[ -z "$(strip $(compiler_runtime_files))" ] \
+ || $(INSTALL) -c -m 0775 -c $(compiler_runtime_files) $(localbindir)
+@$(MAKETARGET)
% :: $(build_dir) ; @:
--8<----8<----8<----8<----8<----8<----8<----8<----8<----8<--
Tests, run with the '@' removed from the beginning of the
replacement line, in an environment where $LMI_TRIPLET
defaults to msw:
/opt/lmi/src/lmi[0]$rm
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/{libgcc_s_seh-1.dll,libstdc++-6.dll}
/opt/lmi/src/lmi[0]$ls -l
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/{libgcc_s_seh-1.dll,libstdc++-6.dll}
ls: cannot access
'/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/libgcc_s_seh-1.dll': No such file or
directory
ls: cannot access '/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/libstdc++-6.dll':
No such file or directory
/opt/lmi/src/lmi[2]$make show_flags 2>&1 |grep 'libstdc++'
[ -z "/usr/lib/gcc/x86_64-w64-mingw32/10-win32//libgcc_s_seh-1.dll
/usr/lib/gcc/x86_64-w64-mingw32/10-win32//libstdc++-6.dll" ] \
|| install -c -m 0775 -c
/usr/lib/gcc/x86_64-w64-mingw32/10-win32//libgcc_s_seh-1.dll
/usr/lib/gcc/x86_64-w64-mingw32/10-win32//libstdc++-6.dll
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin
/opt/lmi/src/lmi[0]$ls -l
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/{libgcc_s_seh-1.dll,libstdc++-6.dll}
-rwxrwxr-x 1 greg lmi 628507 Jul 21 21:55
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/libgcc_s_seh-1.dll
-rwxrwxr-x 1 greg lmi 26122435 Jul 21 21:55
/opt/lmi/local/gcc_x86_64-w64-mingw32/bin/libstdc++-6.dll
Same, with a non-msw $LMI_TRIPLET:
/opt/lmi/src/lmi[0]$make show_flags 2>&1 | head --lines=2
[ -z "" ] \
|| install -c -m 0775 -c /opt/lmi/local/clang_x86_64-pc-linux-gnu/bin
...which demonstrates that $(strip ...) is natural anyway, as it
avoids 'install "" /path/to/wherever', which is invalid no matter
how many blank spaces are between the double quotes.
Commit f760e3df2823, similar but without $(strip ...), mentions that
| running `make -n fardel` through shellcheck elicits:
| SC2157: Argument to -z is always false due to literal strings.
so let's try that, just to make assurance doubly sure:
/opt/lmi/src/lmi[1]$echo '#!/bin/sh' > eraseme
/opt/lmi/src/lmi[0]$make -n show_flags >> eraseme
/opt/lmi/src/lmi[0]$shellcheck eraseme 2>&1 |less -S
Okay, shellcheck is satisfied, too.