aboutsummaryrefslogtreecommitdiff
path: root/src/xz/args.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2015-11-03 20:29:33 +0200
committerLasse Collin <lasse.collin@tukaani.org>2015-11-03 20:29:33 +0200
commitcb3111e3ed84152912b5138d690c8d9f00c6ef02 (patch)
treea706e5bcb842a342b8e3290e5b961e15467ee3c8 /src/xz/args.c
parentBuild: Build LZMA1/2 presets also when only decoder is wanted. (diff)
downloadxz-cb3111e3ed84152912b5138d690c8d9f00c6ef02.tar.xz
xz: Make xz buildable even when encoders or decoders are disabled.
The patch is quite long but it's mostly about adding new #ifdefs to omit code when encoders or decoders have been disabled. This adds two new #defines to config.h: HAVE_ENCODERS and HAVE_DECODERS.
Diffstat (limited to 'src/xz/args.c')
-rw-r--r--src/xz/args.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/xz/args.c b/src/xz/args.c
index 041c8007..341f29e1 100644
--- a/src/xz/args.c
+++ b/src/xz/args.c
@@ -635,6 +635,22 @@ args_parse(args_info *args, int argc, char **argv)
// Then from the command line
parse_real(args, argc, argv);
+ // If encoder or decoder support was omitted at build time,
+ // show an error now so that the rest of the code can rely on
+ // that whatever is in opt_mode is also supported.
+#ifndef HAVE_ENCODERS
+ if (opt_mode == MODE_COMPRESS)
+ message_fatal(_("Compression support was disabled "
+ "at build time"));
+#endif
+#ifndef HAVE_DECODERS
+ // Even MODE_LIST cannot work without decoder support so MODE_COMPRESS
+ // is the only valid choice.
+ if (opt_mode != MODE_COMPRESS)
+ message_fatal(_("Decompression support was disabled "
+ "at build time"));
+#endif
+
// Never remove the source file when the destination is not on disk.
// In test mode the data is written nowhere, but setting opt_stdout
// will make the rest of the code behave well.