diff --git Makefile Makefile
index c32ed6b..fb2e7a3 100644
--- Makefile
+++ Makefile
@@ -1,13 +1,22 @@
-all: xkblayout-state
+PROG=xkblayout-state
 
-XKeyboard.o: XKeyboard.cpp XKeyboard.h X11Exception.h
-	g++ -c -Wall -O2 XKeyboard.cpp -o XKeyboard.o
+SRC = wrapper.cpp XKeyboard.cpp
+OBJS = ${SRC:.cpp=.o}
 
-wrapper.o: wrapper.cpp XKeyboard.h
-	g++ -c -Wall -O2 wrapper.cpp -o wrapper.o
+all: ${PROG}
 
-xkblayout-state: XKeyboard.o wrapper.o
-	g++ XKeyboard.o wrapper.o -lX11 -o xkblayout-state
+.cpp.o:
+	${CXX} -c ${CXXFLAGS} $<
+
+${PROG}: ${OBJS}
+	${CXX} -o $@ ${OBJS} ${LDFLAGS} -lX11
 
 clean: 
-	rm -f xkblayout-state XKeyboard.o wrapper.o
+	rm -f ${PROG} ${OBJS}
+
+dist:
+	tar cfa xkblayout-state-v1b.tar.gz Makefile README.md wrapper.cpp X11Exception.h XKeyboard.cpp XKeyboard.h
+
+install:
+	install -Dm755 ${PROG} ${DESTDIR}/usr/bin/${PROG}
+

