--- makefile.orig	2021-04-06 21:42:27.000000000 +0800
+++ makefile	2023-04-08 01:17:29.000000000 +0800
@@ -191,8 +191,8 @@
 #### end "BSD-aware"
 
 ## PREFIX is only set if not supplied
-## for other locations use e.g.  "make install PREFIX=/opt/"
-PREFIX ?= /usr/local/
+## for other locations use e.g. "make install PREFIX=/opt/"
+PREFIX ?= @PREFIX@
 LIBDIR=$(PREFIX)/lib
 INCDIR=$(PREFIX)/include/fxt
 .PHONY: install  ## install to $(PREFIX)/lib/ and $(PREFIX)/include/fxt/
@@ -200,27 +200,27 @@
 	: '[$@]'
 	@echo 'PREFIX=$(PREFIX)  LIBDIR=$(LIBDIR)  INCDIR=$(INCDIR)'
 	@:
-	@test -d $(INCDIR)  ||  mkdir $(INCDIR)
-	@$(FXT_INSTALL) $(FXTIDIR)/*.h $(INCDIR)/
-	@cd src && for f in $(SHFXTSRCDIRS); do mkdir -p $(INCDIR)/$$f; done
-	@cd src && for f in $(SHFXTSRCDIRS); do $(FXT_INSTALL) $$f/*.h $(INCDIR)/$$f; done
+	@test -d $(DESTDIR)$(INCDIR)  ||  mkdir $(DESTDIR)$(INCDIR)
+	@$(FXT_INSTALL) $(FXTIDIR)/*.h $(DESTDIR)$(INCDIR)/
+	@cd src && for f in $(SHFXTSRCDIRS); do mkdir -p $(DESTDIR)$(INCDIR)/$$f; done
+	@cd src && for f in $(SHFXTSRCDIRS); do $(FXT_INSTALL) $$f/*.h $(DESTDIR)$(INCDIR)/$$f; done
 	@:
-	@test -d $(LIBDIR)  ||  mkdir $(LIBDIR)
-	@$(FXT_INSTALL) $(FXTLIB) $(LIBDIR)/
+	@test -d $(DESTDIR)$(LIBDIR)  ||  mkdir $(DESTDIR)$(LIBDIR)
+	@$(FXT_INSTALL) $(FXTLIB) $(DESTDIR)$(LIBDIR)/
 	: '[$@ OK]'
 
 .PHONY: chk-install ##x print whether installed header files are up to date
 chk-install:
 	@(cd src  &&  find . -maxdepth 2 -name \*.h | sort) > tmp-hdr1
-	@(cd $(INCDIR)/  &&  find . -name \*.h | sort) > tmp-hdr2
+	@(cd $(DESTDIR)$(INCDIR)/  &&  find . -name \*.h | sort) > tmp-hdr2
 	@-diff tmp-hdr1 tmp-hdr2
 	@rm tmp-hdr1 tmp-hdr2
 
-.PHONY: uninstall  ## uninstall headers and lib, but leave directory $(INCDIR)
+.PHONY: uninstall  ## uninstall headers and lib, but leave directory $(DESTDIR)$(INCDIR)
 uninstall:
-	: '[$@]'  ## note: we do not remove $(INCDIR)
-	rm -rf $(INCDIR)/*
-	rm -f $(LIBDIR)/$(FXTLIB)
+	: '[$@]'  ## note: we do not remove $(DESTDIR)$(INCDIR)
+	rm -rf $(DESTDIR)$(INCDIR)/*
+	rm -f $(DESTDIR)$(LIBDIR)/$(FXTLIB)
 
 .PHONY: reinstall  ## uninstall and install
 reinstall: # uninstall install
