lrzip/lzma/C/Makefile.am
Eli Schwartz dc6342ea61
build: fix incorrect use of shell commands in handmade libtool file
The "echo" command was soft-deprecated from the shell programming
language in ~1992. There is no way to use it correctly if:

- the "-e" or "-n" or "-E" or any other options are used
- backslash escape sequences are used
- the printed string contains shell variables containing either of the
  above

In recognition of the fact that echo was historically used in many
scripts, some of which avoided these issues and therefore succeeded when
run, the "echo" command was NOT marked as obsolescent, out of fear that
marking it as obsolescent would lead to vendors removing "echo" entirely
and breaking existing scripts (or at least, the subset of scripts which
managed to work correctly).

However, it is warned against, that after 1992 you should avoid writing
new code that uses "echo" and instead use "printf".

printf has an actual definition of its behavior, which echo did not, and
that behavior is to interpret backslash escapes in the first parameter,
which is necessary by this Makefile.am in order to embed newlines into
the generated libtool file. Simply replacing "echo -e" with "printf"
will therefore correctly and reliably do the intended functionality. We
also add one final embedded newline to avoid producing a file without an
end-of-line character on the last line of the file.

Fixes: https://github.com/ckolivas/lrzip/issues/257
Signed-off-by: Eli Schwartz <eschwartz@gentoo.org>
2025-02-06 10:53:48 -05:00

65 lines
1.2 KiB
Makefile

MAINTAINERCLEANFILES = Makefile.in
# Update -D
AM_CFLAGS = \
-D_REENTRANT \
-I@top_builddir@ \
-I@top_srcdir@
ASM_S =
ASM_7z =
C_S =
if USE_ASM
ASM_7z += 7zCrcOpt_asm
ASM_S += @abs_top_srcdir@/lzma/ASM/x86/$(ASM_7z).asm
C_S += 7zCrcT8.c
else
C_S += 7zCrc.c
endif
noinst_LTLIBRARIES = liblzma.la
# need separate variable for ASM so that make will compile later
# to prevent an error even if -j## is used.
liblzma_la_SOURCES = \
$(C_S) \
7zCrc.h \
LzmaDec.h \
LzmaEnc.h \
LzFind.c \
LzFind.h \
LzFindMt.c \
LzFindMt.h \
LzmaDec.c \
LzmaEnc.c \
LzmaLib.c \
LzmaLib.h \
Alloc.c \
Alloc.h \
Threads.c \
Threads.h \
Types.h \
LzHash.h \
windows.h \
basetyps.h \
MyWindows.h \
MyGuidDef.h
## hack to force asm compilation and to trick libtool with .lo file
if USE_ASM
liblzma_la_LIBADD = $(ASM_7z).lo
7ZIPASMLOFILE := \
\# $(ASM_7z).lo - a libtool object file\
\n\# Generated by libtool -- hack to allow asm linking\
\n\# Peter Hyman\
\npic_object='.libs/$(ASM_7z).o'\
\nnon_pic_object='$(ASM_7z).o'\
\n
$(ASM_7z).lo: $(ASM_S)
$(ASM_PROG) $(ASM_OPT) -o $(ASM_7z).o $(ASM_S)
mkdir -p .libs
cp $(ASM_7z).o .libs/
@printf "$(7ZIPASMLOFILE)" > $(ASM_7z).lo
endif