--- Makefile.old	2013-06-15 10:34:21.560590739 +0800
+++ Makefile	2013-06-15 10:57:18.771590575 +0800
@@ -1,13 +1,19 @@
+prefix		=/usr/
+exec_prefix=${prefix}
+bindir		=${exec_prefix}/bin
+rulesdir	=/lib/udev/rules.d
+
 ipad_charge: ipad_charge.c
 	gcc -Wall -Wextra ipad_charge.c -lusb-1.0 -o ipad_charge
 
 install: ipad_charge
-	install -o root -g root -m 755 -s ipad_charge /usr/bin/
-	install -o root -g root -m 644 95-ipad_charge.rules /etc/udev/rules.d/
+	mkdir -p ${DESTDIR}${bindir} ${DESTDIR}${rulesdir} 
+	install -o root -g root -m 755 -s ipad_charge ${DESTDIR}${bindir}
+	install -o root -g root -m 644 95-ipad_charge.rules ${DESTDIR}${rulesdir} 
 
 uninstall:
-	rm -rf /usr/bin/ipad_charge
-	rm -rf /etc/udev/rules.d/95-ipad_charge.rules
+	rm -rf ${DESTDIR}${bindir}/ipad_charge
+	rm -rf ${DESTDIR}${rulesdir} /95-ipad_charge.rules
 
 clean:
 	rm -f ipad_charge
