-LDFLAGS += -D_LARGEFILE64_SOURCE
-LDFLAGS += $(shell getconf LFS64_LDFLAGS)
-LDFLAGS += $(shell getconf LFS64_LIBS)
+LDFLAGS += -L/usr/local/lib
+
+PREFIX ?= /usr/local
+
+
+ifeq (,$(findstring BSD,$(uname_S)))
+ CPPFLAGS += -D_LARGEFILE64_SOURCE
+ CPPFLAGS += $(shell getconf LFS64_CFLAGS)
+ LDFLAGS += -D_LARGEFILE64_SOURCE
+ LDFLAGS += $(shell getconf LFS64_LDFLAGS)
+ LDFLAGS += $(shell getconf LFS64_LIBS)
+ CPPFLAGS += -DHAVE_STAT64=1
+endif