$NetBSD$

# Respect build env and filesystem hierarchy

--- Makefile.orig	2015-12-15 16:34:33 UTC
+++ Makefile
@@ -22,16 +22,7 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
-CC     = gcc
-AR     = ar
-RANLIB = ranlib
-
-CPPFLAGS =
-# TODO: probably update cram code to make it compile cleanly with -Wc++-compat
-CFLAGS   = -g -Wall -O2
 EXTRA_CFLAGS_PIC = -fpic
-LDFLAGS  =
-LIBS     =
 
 # For now these don't work too well as samtools also needs to know to
 # add -lbz2 and -llzma if linking against the static libhts.a library.
@@ -58,16 +49,10 @@ includedir  = $(prefix)/include
 libdir      = $(exec_prefix)/lib
 libexecdir  = $(exec_prefix)/libexec
 datarootdir = $(prefix)/share
-mandir      = $(datarootdir)/man
+mandir      = $(prefix)/man
 man1dir     = $(mandir)/man1
 man5dir     = $(mandir)/man5
-pkgconfigdir= $(libdir)/pkgconfig
-
-MKDIR_P = mkdir -p
-INSTALL = install -p
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA    = $(INSTALL) -m 644
-INSTALL_DIR     = $(MKDIR_P) -m 755
+pkgconfigdir= $(exec_prefix)/libdata/pkgconfig
 
 # Set by config.mk if plugins are enabled
 plugindir =
@@ -86,7 +71,7 @@ BUILT_TEST_PROGRAMS = \
 	test/test-vcf-api \
 	test/test-vcf-sweep
 
-all: lib-static lib-shared $(BUILT_PROGRAMS) plugins $(BUILT_TEST_PROGRAMS)
+all: lib-static lib-shared $(BUILT_PROGRAMS) plugins
 
 HTSPREFIX =
 include htslib_vars.mk
@@ -361,7 +346,7 @@ installdirs:
 # and libhts.so.NN (used by client executables at runtime).
 
 install-so: libhts.so installdirs
-	$(INSTALL_DATA) libhts.so $(DESTDIR)$(libdir)/libhts.so.$(PACKAGE_VERSION)
+	$(INSTALL_LIB) libhts.so $(DESTDIR)$(libdir)/libhts.so.$(PACKAGE_VERSION)
 	ln -sf libhts.so.$(PACKAGE_VERSION) $(DESTDIR)$(libdir)/libhts.so
 	ln -sf libhts.so.$(PACKAGE_VERSION) $(DESTDIR)$(libdir)/libhts.so.$(LIBHTS_SOVERSION)
 
