--- Makefile.bak	2008-05-17 15:53:31.000000000 +0200
+++ Makefile	2008-05-17 15:52:19.000000000 +0200
@@ -23,7 +23,6 @@
 VERSION_DEV=$(VERSION_TRAIN)-$(shell date +%Y%m%d-%H)
 
 # Executable binary extension
-DESTDIR?=/usr
 BIN_EXT?=
 
 CC?=gcc
@@ -45,7 +44,8 @@
 	-DHAS_POSIX_MEMALIGN=$(HAS_POSIX_MEMALIGN)
 
 #PCAP_LIB=/usr/local/lib/libpcap.a
-PCAP_LIB=-lpcap
+#PCAP_LIB=-lpcap
+PCAP_LIB=$(PREFIX)/lib/libpcap.a
 
 ifeq ($(shell uname), FreeBSD)
    PTHREAD_LIBS?=-pthread
@@ -62,8 +62,9 @@
    DESTDIR=/usr
 else
 ifeq ($(shell uname -s), Darwin)
-   CFLAGS+=-I/usr/local/include -mdynamic-no-pic -D_FILE_OFFSET_BITS=64
-   LIBS=-L/usr/local/lib -L. -ldl -lelf -lpthread
+   CFLAGS+=-I$(PREFIX)/include -mdynamic-no-pic -D_FILE_OFFSET_BITS=64
+   LIBS=-L. $(PREFIX)/lib/libelf.a -lpthread
+   LIBS=-L$(PREFIX)/lib -L. -ldl -lelf -lpthread
 else
 ifeq ($(shell uname -s), SunOS)
    CFLAGS+=-I/usr/local/include -DINADDR_NONE=0xFFFFFFFF \
@@ -252,11 +253,11 @@
 
 install: $(PROG) nvram_export
 	@echo "Installing"
-	install -d $(DESTDIR)/bin $(DESTDIR)/man/man1 $(DESTDIR)/man/man7 $(DESTDIR)/etc
-	install dynamips nvram_export   $(DESTDIR)/bin
-	install -m644 dynamips.1        $(DESTDIR)/man/man1
-	install -m644 nvram_export.1    $(DESTDIR)/man/man1
-	install -m644 hypervisor_mode.7 $(DESTDIR)/man/man7
+	install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/man/man1 $(DESTDIR)$(PREFIX)/man/man7 $(DESTDIR)$(PREFIX)/etc
+	install dynamips nvram_export   $(DESTDIR)$(PREFIX)/bin
+	install -m644 dynamips.1        $(DESTDIR)$(PREFIX)/man/man1
+	install -m644 nvram_export.1    $(DESTDIR)$(PREFIX)/man/man1
+	install -m644 hypervisor_mode.7 $(DESTDIR)$(PREFIX)/man/man7
 # install -m644 example         $(DESTDIR)/etc/dynamips
 
 
