Description: Minimal change to make htsutil a bedtools subcommand
 Inline the test tool htsutil into bedtools to reduce the memory footprint of
 the bedtools package.  Details initially discussed on Debian Med mailing list:
 .
 https://lists.debian.org/debian-med/2021/01/msg00189.html
Author: John Marshall <jmarshall@hey.com>
Forwarded: no
Reviewed-by: Étienne Mollier <etienne.mollier@mailoo.org>
Last-Update: 2021-01-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- bedtools.orig/Makefile
+++ bedtools/Makefile
@@ -133,11 +133,11 @@
 ALL_LIBS     = $(BT_LIBS) $(LIBS)
 
 
-all: print_banner $(BIN_DIR)/bedtools $(BIN_DIR)/intersectBed test/htsutil
+all: print_banner $(BIN_DIR)/bedtools $(BIN_DIR)/intersectBed
 
 static: print_banner $(BIN_DIR)/bedtools.static
 
-BUILT_OBJECTS = $(OBJ_DIR)/bedtools.o
+BUILT_OBJECTS = $(OBJ_DIR)/bedtools.o $(OBJ_DIR)/htsutil.o
 # Include all the Makefile fragments, which add to $(BUILT_OBJECTS)
 include $(patsubst %,%/Makefile.frag,$(SUBDIRS) $(UTIL_SUBDIRS))
 
--- bedtools.orig/src/bedtools.cpp
+++ bedtools/src/bedtools.cpp
@@ -86,6 +86,7 @@
 int windowmaker_main(int argc, char* argv[]); //
 int bedtools_help(void);
 int bedtools_faq(void);
+int htsutil_main(int argc, char **argv);
 
 const char* cram_reference = NULL;
 
@@ -174,6 +175,7 @@
     else if (subCmd == "links")       return links_main(argc-1, argv+1);
     else if (subCmd == "makewindows") return windowmaker_main(argc-1, argv+1);
     else if (subCmd == "expand")      return expand_main(argc-1, argv+1);
+    else if (subCmd == "htsutil")     return htsutil_main(argc-1, argv+1);
     else if (subCmd == "regresstest")  return regress_test_main(argc, argv); //this command does need all the orig args.
     // help
     else if (subCmd == "-h" || subCmd == "--help" ||
--- bedtools.orig/src/htsutil.cpp
+++ bedtools/src/htsutil.cpp
@@ -127,7 +127,7 @@
     return 0;
 }
 
-int main(int argc, char **argv)
+int htsutil_main(int argc, char **argv)
 {
     std::string cmd = (argc >= 2)? argv[1] : "--help";
     const char *src = (argc >= 3)? argv[2] : "-";
