--- Makefile.orig	2015-03-12 16:23:05.000000000 -0700
+++ Makefile	2015-09-15 09:39:41.000000000 -0700
@@ -2,17 +2,17 @@
 # --- Change the settings below to suit your environment. See explanations in
 # --- the build documentation for more details. ---
 
-PREFIX=/usr/local
-MODDIR=$(PREFIX)/lib/lua/5.2
+#PREFIX=/usr/local
+#MODDIR=$(PREFIX)/lib/lua/5.2
 DOCDIR=$(PREFIX)/share/doc/luahpdf
-LUALIB=-llua5.2
-LUAINC=-I/usr/include/lua5.2
+LUALIB=-llua
+LUAINC=
 HPDFLIB=-lhpdf
 HPDFINC=
 LUA=lua
 LUAC=luac
-PLATFORM=linux
-# PLATFORM=macosx
+# PLATFORM=linux
+PLATFORM=macosx
 
 # --- End of user settings, no need to change anything below this line. ---
 
@@ -22,8 +22,8 @@
 linux_COMPILE=cc -DHPDF_SHARED $(LUAINC) $(HPDFINC) -Wall -O2 -fomit-frame-pointer -shared -fPIC -c -o $@ $<
 linux_LINK=cc -shared -fPIC -o $@ $^ $(HPDFLIB) -lz -lpng -lm
 linux_REPORT=ldd ./$(TARGET)
-macosx_COMPILE=cc -DHPDF_SHARED $(LUAINC) $(HPDFINC) -DLUA_USE_MACOSX -Wall -O2 -fomit-frame-pointer -fPIC -c -o $@ $<
-macosx_LINK=cc -bundle -undefined dynamic_lookup -DLUA_USE_MACOSX $(HPDFLIB) -lz -lpng -o hpdf.so hpdf.o
+macosx_COMPILE=$(CC) $(CFLAGS) -DHPDF_SHARED $(LUAINC) $(HPDFINC) -DLUA_USE_MACOSX -Wall -fomit-frame-pointer -fPIC -c -o $@ $<
+macosx_LINK=$(CC) $(LDFLAGS) -bundle -undefined dynamic_lookup -DLUA_USE_MACOSX $(HPDFLIB) -lz -lpng -o hpdf.so hpdf.o
 macosx_REPORT=otool -L ./$(TARGET)
 
 PDF = \
@@ -58,7 +58,7 @@
 	$($(PLATFORM)_COMPILE)
 
 dump :
-	cc -E -dM -ansi -DHPDF_SHARED -pedantic -Wall -O2 $(CFLAGS) $(LUAINC) $(HPDFINC) -shared hpdf.c > $@
+	$(CC) -E -dM -ansi -DHPDF_SHARED -pedantic -Wall -O2 $(CFLAGS) $(LUAINC) $(HPDFINC) -shared hpdf.c > $@
 
 test : $(TARGET)
 	$(LUA) -e "package.path=[[]] package.cpath=[[./?.so;./?.dll]] local hpdf = require [[hpdf]] print(hpdf.VERSION_TEXT)"
@@ -71,7 +71,7 @@
 	install -m 0755 -d "$(DESTDIR)$(DOCDIR)"
 	install -m 0755 -d "$(DESTDIR)$(DOCDIR)/text"
 	install -m 0755 -d "$(DESTDIR)$(DOCDIR)/html"
-	install -m 0644 README doc/*.lua "$(DESTDIR)$(DOCDIR)"
+	install -m 0644 README.md doc/*.lua "$(DESTDIR)$(DOCDIR)"
 	install -m 0644 doc/text/*.txt "$(DESTDIR)$(DOCDIR)/text"
 	install -m 0644 doc/html/*.html doc/html/*.css doc/html/*.png "$(DESTDIR)$(DOCDIR)/html"