$NetBSD: patch-Makefile,v 1.1 2020/07/22 14:50:14 bacon Exp $

# Respect pkgsrc env

--- Makefile.orig	2019-12-19 09:54:30.000000000 +0000
+++ Makefile
@@ -22,44 +22,43 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
-CC     = gcc
-AR     = ar
-RANLIB = ranlib
+CC     ?= gcc
+AR     ?= ar
+RANLIB ?= ranlib
 
 # Default libraries to link if configure is not used
 htslib_default_libs = -lz -lm -lbz2 -llzma -lcurl
 
-CPPFLAGS =
+# CPPFLAGS =
 # TODO: make the 64-bit support for VCF optional via configure, for now add -DVCF_ALLOW_INT64
 #       to CFLAGS manually, here or in config.mk if the latter exists.
 # TODO: probably update cram code to make it compile cleanly with -Wc++-compat
 # For testing strict C99 support add -std=c99 -D_XOPEN_SOURCE=600
 #CFLAGS   = -g -Wall -O2 -pedantic -std=c99 -D_XOPEN_SOURCE=600
-CFLAGS   = -g -Wall -O2 -fvisibility=hidden
+CFLAGS   ?= -g -Wall -O2 -fvisibility=hidden
 EXTRA_CFLAGS_PIC = -fpic
-LDFLAGS  = -fvisibility=hidden
+LDFLAGS  ?= -fvisibility=hidden
 LIBS     = $(htslib_default_libs)
 
-prefix      = /usr/local
-exec_prefix = $(prefix)
+PREFIX      ?= /usr/local
+exec_prefix = $(PREFIX)
 bindir      = $(exec_prefix)/bin
-includedir  = $(prefix)/include
+includedir  = $(PREFIX)/include
 libdir      = $(exec_prefix)/lib
 libexecdir  = $(exec_prefix)/libexec
-datarootdir = $(prefix)/share
+datarootdir = $(PREFIX)/share
 mandir      = $(datarootdir)/man
 man1dir     = $(mandir)/man1
 man5dir     = $(mandir)/man5
 man7dir     = $(mandir)/man7
 pkgconfigdir= $(libdir)/pkgconfig
 
-MKDIR_P = mkdir -p
-INSTALL = install -p
-INSTALL_DATA    = $(INSTALL) -m 644
-INSTALL_DIR     = $(MKDIR_P) -m 755
-INSTALL_LIB     = $(INSTALL_DATA)
-INSTALL_MAN     = $(INSTALL_DATA)
-INSTALL_PROGRAM = $(INSTALL)
+MKDIR_P         = mkdir -p
+INSTALL_DATA    = ${BSD_INSTALL_DATA}
+INSTALL_DIR     = $(MKDIR_P)
+INSTALL_LIB     = ${BSD_INSTALL_LIB}
+INSTALL_MAN     = ${BSD_INSTALL_MAN}
+INSTALL_PROGRAM = ${BSD_INSTALL_PROGRAM}
 
 # Set by config.mk if plugins are enabled
 plugindir =
@@ -98,7 +97,7 @@ BUILT_THRASH_PROGRAMS = \
 	test/thrash_threads6 \
 	test/thrash_threads7
 
-all: lib-static lib-shared $(BUILT_PROGRAMS) plugins $(BUILT_TEST_PROGRAMS)
+all: lib-static lib-shared $(BUILT_PROGRAMS) plugins
 
 HTSPREFIX =
 include htslib_vars.mk
