Disable patches for the moment.
Stop depending on CDBS and quilt.
Use the single-debian-patch option.
Stop providing the static libbam, replaced by the dynamic libhts.
razip was removed from samtools.
Breaks and replace tabix for the bgzip program.
Rely on the new upstream Makefile.

For the moment it still needs to be extensively patched.

diff --git a/Makefile b/Makefile
index bf5557f..ec464d3 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,6 @@ all: $(PROGRAMS) $(BUILT_MISC_PROGRAMS)

 # Adjust $(HTSDIR) to point to your top-level htslib directory
 HTSDIR = ../htslib
-include $(HTSDIR)/htslib.mk
 HTSLIB = $(HTSDIR)/libhts.a

@@ -95,48 +94,48 @@ bgzip: bgzip.o $(HTSLIB)

 bam_h = bam.h $(htslib_bgzf_h) $(htslib_sam_h)
 bam2bcf_h = bam2bcf.h errmod.h
-bam_tview_h = bam_tview.h $(bam_h) $(htslib_faidx_h) $(bam2bcf_h) sam_header.h $(HTSDIR)/htslib/khash.h
+bam_tview_h = bam_tview.h $(bam_h) $(htslib_faidx_h) $(bam2bcf_h) sam_header.h $(HTSDIR)/khash.h
 sam_h = sam.h $(htslib_sam_h) $(bam_h)
-sample_h = sample.h $(HTSDIR)/htslib/kstring.h
+sample_h = sample.h $(HTSDIR)/kstring.h

 bam.o: bam.c $(bam_h) sam_header.h
-bam2bcf.o: bam2bcf.c bam2bcf.h $(HTSDIR)/htslib/kfunc.h
+bam2bcf.o: bam2bcf.c bam2bcf.h $(HTSDIR)/kfunc.h
 bam2bcf_indel.o: bam2bcf_indel.c bam2bcf.h
 bam2depth.o: bam2depth.c
 bam_aux.o: bam_aux.c
 bam_cat.o: bam_cat.c $(htslib_bgzf_h) $(bam_h)
 bam_color.o: bam_color.c $(bam_h)
-bam_import.o: bam_import.c $(HTSDIR)/htslib/kstring.h $(bam_h) $(HTSDIR)/htslib/kseq.h
+bam_import.o: bam_import.c $(HTSDIR)/kstring.h $(bam_h) $(HTSDIR)/kseq.h
 bam_index.o: bam_index.c $(bam_h)
-bam_lpileup.o: bam_lpileup.c $(bam_h) $(HTSDIR)/htslib/ksort.h
+bam_lpileup.o: bam_lpileup.c $(bam_h) $(HTSDIR)/ksort.h
 bam_mate.o: bam_mate.c $(bam_h)
 bam_md.o: bam_md.c $(htslib_faidx_h) $(sam_h) kaln.h kprobaln.h
 bam_pileup.o: bam_pileup.c $(sam_h)
 bam_plcmd.o: bam_plcmd.c $(sam_h) $(htslib_faidx_h) sam_header.h $(bam2bcf_h) $(sample_h)
 bam_reheader.o: bam_reheader.c $(htslib_bgzf_h) $(bam_h)
-bam_rmdup.o: bam_rmdup.c $(sam_h) $(HTSDIR)/htslib/khash.h
-bam_rmdupse.o: bam_rmdupse.c $(sam_h) $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/klist.h
-bam_sort.o: bam_sort.c $(bam_h) $(HTSDIR)/htslib/ksort.h
+bam_rmdup.o: bam_rmdup.c $(sam_h) $(HTSDIR)/khash.h
+bam_rmdupse.o: bam_rmdupse.c $(sam_h) $(HTSDIR)/khash.h $(HTSDIR)/klist.h
+bam_sort.o: bam_sort.c $(bam_h) $(HTSDIR)/ksort.h
 bam_stat.o: bam_stat.c $(bam_h)
 bam_tview.o: bam_tview.c $(bam_tview_h)
 bam_tview_curses.o: bam_tview_curses.c $(bam_tview_h)
 bam_tview_html.o: bam_tview_html.c $(bam_tview_h)
-bamshuf.o: bamshuf.c $(htslib_sam_h) $(HTSDIR)/htslib/ksort.h
+bamshuf.o: bamshuf.c $(htslib_sam_h) $(HTSDIR)/ksort.h
 bamtk.o: bamtk.c $(bam_h) version.h samtools.h
-bedcov.o: bedcov.c $(htslib_bgzf_h) $(bam_h) $(HTSDIR)/htslib/kseq.h
-bedidx.o: bedidx.c $(HTSDIR)/htslib/ksort.h $(HTSDIR)/htslib/kseq.h $(HTSDIR)/htslib/khash.h
+bedcov.o: bedcov.c $(htslib_bgzf_h) $(bam_h) $(HTSDIR)/kseq.h
+bedidx.o: bedidx.c $(HTSDIR)/ksort.h $(HTSDIR)/kseq.h $(HTSDIR)/khash.h
 bgzip.o: bgzip.c $(htslib_bgzf_h)
 cut_target.o: cut_target.c $(bam_h) errmod.h $(htslib_faidx_h)
-errmod.o: errmod.c errmod.h $(HTSDIR)/htslib/ksort.h
+errmod.o: errmod.c errmod.h $(HTSDIR)/ksort.h
 kaln.o: kaln.c kaln.h
 kprobaln.o: kprobaln.c kprobaln.h
 padding.o: padding.c sam_header.h $(sam_h) $(bam_h) $(htslib_faidx_h)
-phase.o: phase.c $(bam_h) errmod.h $(HTSDIR)/htslib/kseq.h $(HTSDIR)/htslib/khash.h $(HTSDIR)/htslib/ksort.h
+phase.o: phase.c $(bam_h) errmod.h $(HTSDIR)/kseq.h $(HTSDIR)/khash.h $(HTSDIR)/ksort.h
 sam.o: sam.c $(htslib_faidx_h) $(sam_h)
-sam_header.o: sam_header.c sam_header.h $(HTSDIR)/htslib/khash.h
-sam_view.o: sam_view.c sam_header.h $(sam_h) $(htslib_faidx_h) $(HTSDIR)/htslib/khash.h
-sample.o: sample.c $(sample_h) $(HTSDIR)/htslib/khash.h
-stats.o: stats.c $(sam_h) sam_header.h khash_utils.h samtools.h $(HTSDIR)/htslib/khash.h $(htslib_faidx_h)
+sam_header.o: sam_header.c sam_header.h $(HTSDIR)/khash.h
+sam_view.o: sam_view.c sam_header.h $(sam_h) $(htslib_faidx_h) $(HTSDIR)/khash.h
+sample.o: sample.c $(sample_h) $(HTSDIR)/khash.h
+stats.o: stats.c $(sam_h) sam_header.h khash_utils.h samtools.h $(HTSDIR)/khash.h $(htslib_faidx_h)

 # test programs
@@ -165,10 +164,10 @@ misc/md5sum-lite: misc/md5sum-lite.o
 misc/wgsim: misc/wgsim.o
        $(CC) $(LDFLAGS) -o $@ misc/wgsim.o $(LDLIBS) -lm -lz

-misc/ace2sam.o: misc/ace2sam.c $(HTSDIR)/htslib/kstring.h $(HTSDIR)/htslib/kseq.h
+misc/ace2sam.o: misc/ace2sam.c $(HTSDIR)/kstring.h $(HTSDIR)/kseq.h
 misc/md5.o: misc/md5.c misc/md5.h
-misc/md5fa.o: misc/md5fa.c misc/md5.h $(HTSDIR)/htslib/kseq.h
-misc/wgsim.o: misc/wgsim.c $(HTSDIR)/htslib/kseq.h
+misc/md5fa.o: misc/md5fa.c misc/md5.h $(HTSDIR)/kseq.h
+misc/wgsim.o: misc/wgsim.c $(HTSDIR)/kseq.h

 misc/maq2sam-short.o: misc/maq2sam.c
        $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ misc/maq2sam.c
@@ -189,7 +188,7 @@ install: $(PROGRAMS) $(BUILT_MISC_PROGRAMS)
 mostlyclean:
        -rm -f *.o misc/*.o version.h

-clean: mostlyclean clean-htslib
+clean: mostlyclean
        -rm -f $(PROGRAMS) libbam.a $(BUILT_MISC_PROGRAMS)

 distclean: clean
(END)