$OpenBSD$

Index: system-autodetect.mk
--- system-autodetect.mk.orig
+++ system-autodetect.mk
@@ -9,8 +9,8 @@ PKG_CONFIG ?= pkg-config
 ## Installation paths
 ##
 
-#DIST: PREFIX=/usr/local
-PREFIX ?= /usr/local
+DIST: PREFIX=/usr/local
+#PREFIX ?= /usr/local
 
 # Unless you are creating a package conforming to some OS's standards, you
 # probably do not want to modify the following directories:
@@ -61,7 +61,7 @@ endif
 #PRELOAD_MODULES=1
 
 # Flags to link with libdl.
-DL_LIBS=-ldl
+#DL_LIBS=-ldl
 
 
 ##
@@ -75,7 +75,7 @@ include $(TOPDIR)/build/lua-detect.mk
 ##
 
 # Paths
-X11_PREFIX ?= /usr/X11R6
+X11_PREFIX ?= $(X11BASE)
 # SunOS/Solaris
 #X11_PREFIX ?= /usr/openwin
 
@@ -144,6 +144,8 @@ HAS_SYSTEM_ASPRINTF=1
 # On some other systems you may something like this:
 #EXTRA_LIBS += -lintl
 #EXTRA_INCLUDES +=
+EXTRA_LIBS += -L$(LOCALBASE)/lib -lintl -liconv
+EXTRA_INCLUDES += -I$(LOCALBASE)/include -I/usr/local/include/lua-5.1
 
 
 ##
@@ -158,7 +160,7 @@ HAS_SYSTEM_ASPRINTF ?= 1
 # The following setting is needed with GNU libc for clock_gettime and the
 # monotonic clock. Other systems may not need it, or may not provide a
 # monotonic clock at all (which Ion can live with, and usually detect).
-EXTRA_LIBS += -lrt
+#EXTRA_LIBS += -lrt
 
 # Cygwin needs this. Also when you disable _BSD_SOURCE you may need it.
 #DEFINES += -DCF_NO_GETLOADAVG
@@ -175,9 +177,9 @@ EXTRA_LIBS += -lrt
 ## C compiler.
 ##
 
-CC ?= gcc
+#CC ?= gcc
 
-WARN=-W -Wall -pedantic
+#WARN=-W -Wall -pedantic
 
 #
 # For increased debug info, pass DEBUG=1 to make
@@ -187,10 +189,10 @@ ifeq ($(DEBUG),1)
 else
     CFLAGS+= -g -Os
 endif
-CFLAGS += $(WARN) $(DEFINES) $(INCLUDES) $(EXTRA_INCLUDES) \
+CFLAGS += $(WARN) $(DEFINES) $(EXTRA_INCLUDES) $(INCLUDES) \
           -DHAS_SYSTEM_ASPRINTF=$(HAS_SYSTEM_ASPRINTF)
 
-LDFLAGS += -Wl,--as-needed $(LIBS) $(EXTRA_LIBS)
+LDFLAGS += -Wl,--as-needed $(EXTRA_LIBS) $(LIBS)
 EXPORT_DYNAMIC=-Xlinker --export-dynamic
 
 # The following options are mainly for development use and can be used
