$NetBSD: patch-Makefile,v 1.1 2018/12/31 16:35:25 chuck Exp $

--- Makefile.orig	2018-11-05 10:35:46.000000000 -0500
+++ Makefile	2018-12-31 10:21:16.000000000 -0500
@@ -575,15 +575,17 @@
 ifeq ($(target),Darwin)
 
 # default INCDIR for macOS
-INCDIR= $(shell xcrun --show-sdk-path --sdk macosx)/usr/include
+#INCDIR= $(shell xcrun --show-sdk-path --sdk macosx)/usr/include
+INCDIR= ${COMPILER_INCLUDE_DIRS}
 
 else
 #endif	/* end of skip for non-Gnu makefiles */
 
 # default INCDIR for non-macOS
-INCDIR= /usr/include
+#INCDIR= /usr/include
 #INCDIR= /usr/local/include
 #INCDIR= /dev/env/DJDIR/include
+INCDIR= ${COMPILER_INCLUDE_DIRS}
 
 #if 0	/* start of skip for non-Gnu makefiles */
 endif
@@ -638,15 +640,17 @@
 ifeq ($(target),Darwin)
 
 # default BINDIR for macOS
-BINDIR= /usr/local/bin
+#BINDIR= /usr/local/bin
+BINDIR= ${PREFIX}/bin
 
 else
 #endif	/* end of skip for non-Gnu makefiles */
 
 # default BINDIR for non-macOS
-BINDIR= /usr/bin
+#BINDIR= /usr/bin
 #BINDIR= /usr/local/bin
 #BINDIR= /dev/env/DJDIR/bin
+BINDIR= ${PREFIX}/bin
 
 #if 0	/* start of skip for non-Gnu makefiles */
 endif
@@ -654,15 +658,17 @@
 ifeq ($(target),Darwin)
 
 # default LIBDIR for macOS
-LIBDIR= /usr/local/lib
+#LIBDIR= /usr/local/lib
+LIBDIR= ${PREFIX}/lib
 
 else
 #endif	/* end of skip for non-Gnu makefiles */
 
 # default LIBDIR for non-macOS
-LIBDIR= /usr/lib
+#LIBDIR= /usr/lib
 #LIBDIR= /usr/local/lib
 #LIBDIR= /dev/env/DJDIR/lib
+LIBDIR= ${PREFIX}/lib
 
 #if 0	/* start of skip for non-Gnu makefiles */
 endif
@@ -670,15 +676,17 @@
 ifeq ($(target),Darwin)
 
 # default CALC_SHAREDIR for macOS
-CALC_SHAREDIR= /usr/local/share/calc
+#CALC_SHAREDIR= /usr/local/share/calc
+CALC_SHAREDIR= ${PREFIX}/share/calc
 
 else
 #endif	/* end of skip for non-Gnu makefiles */
 
 # default CALC_SHAREDIR for non-macOS
-CALC_SHAREDIR= /usr/share/calc
+#CALC_SHAREDIR= /usr/share/calc
 #CALC_SHAREDIR= /usr/local/lib/calc
 #CALC_SHAREDIR= /dev/env/DJDIR/share/calc
+CALC_SHAREDIR= ${PREFIX}/share/calc
 
 #if 0	/* start of skip for non-Gnu makefiles */
 endif
@@ -690,7 +698,8 @@
 #
 #CALC_INCDIR= /usr/local/include/calc
 #CALC_INCDIR= /dev/env/DJDIR/include/calc
-CALC_INCDIR= ${INCDIR}/calc
+#CALC_INCDIR= ${INCDIR}/calc
+CALC_INCDIR= ${PREFIX}/include/calc
 
 # By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
 # ---------------------------------------------------------------
@@ -760,7 +769,7 @@
 #MANDIR=
 #MANDIR= /usr/local/man/man1
 #MANDIR= /usr/man/man1
-MANDIR= /usr/share/man/man1
+MANDIR= ${PREFIX}/${PKGMANDIR}/man1
 #MANDIR= /dev/env/DJDIR/man/man1
 #MANDIR= /usr/man/u_man/man1
 #MANDIR= /usr/contrib/man/man1
@@ -771,7 +780,7 @@
 #
 # Use CATDIR= to disable installation of the calc cat (formatted) page.
 #
-CATDIR=
+CATDIR= ${PREFIX}/man/cat1
 #CATDIR= /usr/local/man/cat1
 #CATDIR= /usr/local/catman/cat1
 #CATDIR= /usr/man/cat1
@@ -792,9 +801,9 @@
 #
 # This is ignored if CATDIR is empty.
 #
-CATEXT= 1
+#CATEXT= 1
 #CATEXT= 1.gz
-#CATEXT= 0
+CATEXT= 0
 #CATEXT= l
 
 # how to format a man page
@@ -820,8 +829,8 @@
 # and CATDIR to empty and ignore the NROFF, NROFF_ARG and MANMAKE
 # lines below.
 #
-#NROFF= nroff
-NROFF=
+NROFF= nroff
+#NROFF=
 #NROFF= groff
 NROFF_ARG= -man
 #NROFF_ARG= -mandoc
@@ -895,13 +904,14 @@
 #
 # If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
 #
-USE_READLINE=
-#USE_READLINE= -DUSE_READLINE
+#USE_READLINE=
+USE_READLINE= -DUSE_READLINE
 #
 READLINE_LIB=
 READLINE_EXTRAS=
 #
-#READLINE_LIB= -lreadline
+READLINE_LIB= -lreadline
+READLINE_EXTRAS= -lncurses
 #READLINE_EXTRAS= -lhistory -lncurses
 #
 #READLINE_LIB= -L/usr/gnu/lib -lreadline
@@ -963,7 +973,7 @@
 #
 #DEBUG= -O3
 #DEBUG= -O3 -g
-DEBUG= -O3 -g3
+#DEBUG= -O3 -g3
 #DEBUG= -O3 -ipa
 #DEBUG= -O3 -g3 -ipa
 
@@ -1604,10 +1614,10 @@
 # LDFLAGS for ${CC} in linking calc programs other than intermediate programs
 #
 ICFLAGS= ${COMMON_CFLAGS} ${CC_STATIC}
-CFLAGS= ${ICFLAGS} ${CCOPT}
+CFLAGS+= ${ICFLAGS} ${CCOPT}
 #
 ILDFLAGS= ${COMMON_LDFLAGS} ${LD_STATIC}
-LDFLAGS= ${LD_DEBUG} ${ILDFLAGS} ${LIBCALC_STATIC} ${LIBCUSTCALC_STATIC}
+LDFLAGS+= ${LD_DEBUG} ${ILDFLAGS} ${LIBCALC_STATIC} ${LIBCUSTCALC_STATIC}
 #
 #if 0	/* start of skip for non-Gnu makefiles */
 endif
@@ -1668,7 +1678,7 @@
 # NOTE: This is the default generic host target.  Used when no other
 #	host target matches.
 
-ifeq ($(target),)
+ifeq ($(target),pkgsrc)
 #
 BLD_TYPE= calc-static-only
 #
@@ -1734,7 +1744,7 @@
 else
 ICFLAGS= ${COMMON_CFLAGS} ${CC_SHARE}
 endif
-CFLAGS= ${ICFLAGS} ${CCOPT}
+CFLAGS= ${ICFLAGS} ${CCOPT} ${CPPFLAGS}
 
 # Required flags to link files for calc
 #
@@ -4645,9 +4655,9 @@
 	${Q}# NOTE: The this makefile installs libcustcalc${LIB_EXT_VERSION}
 	${Q}#       because we only want to perform one ${LDCONFIG} for both
 	${Q}#       libcalc${LIB_EXT_VERSION} and libcustcalc${LIB_EXT_VERSION}.
-	-${Q} if ${CMP} -s libcalc${LIB_EXT_VERSION} \
+	-${Q} if true ${CMP} -s libcalc${LIB_EXT_VERSION} \
 		     ${T}${LIBDIR}/libcalc${LIB_EXT_VERSION} && \
-	   ${CMP} -s custom/libcustcalc${LIB_EXT_VERSION} \
+	   true ${CMP} -s custom/libcustcalc${LIB_EXT_VERSION} \
 		     ${T}${LIBDIR}/libcustcalc${LIB_EXT_VERSION}; then \
 	    ${TRUE}; \
 	else \
