--- a/Makefile
+++ b/Makefile
@@ -14,14 +14,14 @@
 endif
 
 ifndef MANDIR
-MANDIR     = $(ROOT)$(PREFIX)/man
+MANDIR     = $(PREFIX)/man
 endif
 
-ELOGDIR    = $(ROOT)$(PREFIX)/elog
-DESTDIR    = $(ROOT)$(PREFIX)/bin
-SDESTDIR   = $(ROOT)$(PREFIX)/sbin
-RCDIR      = $(ROOT)/etc/rc.d/init.d
-SRVDIR     = $(ROOT)/usr/lib/systemd/system
+ELOGDIR    = $(PREFIX)/elog
+BINDIR     = $(PREFIX)/bin
+SBINDIR    = $(PREFIX)/sbin
+RCDIR      = /etc/rc.d/init.d
+SRVDIR     = $(PREFIX)/lib/systemd/system
 
 # flag for SSL support
 USE_SSL    = 1
@@ -50,7 +50,7 @@
 # Option to use our own implementation of strlcat, strlcpy
 NEED_STRLCPY = 1
 
-INSTALL = `which install`
+INSTALL = /usr/bin/install
 RM = /bin/rm -f
 
 OSTYPE = $(shell uname)
@@ -134,28 +134,28 @@
 	type git &> /dev/null; if [ $$? -eq 1 ]; then REV="unknown" ;else REV=`git log -n 1 --pretty=format:"%ad - %h"`; fi; echo \#define GIT_REVISION \"$$REV\" > $(GIT_REVISION)
 
 crypt.o: src/crypt.cxx
-	$(CC) $(CFLAGS) -w -c -o crypt.o src/crypt.cxx
+	$(CXX) $(CXXFLAGS) -w -c -o crypt.o src/crypt.cxx
 
 auth.o: src/auth.cxx
-	$(CC) $(CFLAGS) -w -c -o auth.o src/auth.cxx
+	$(CXX) $(CXXFLAGS) -w -c -o auth.o src/auth.cxx
 
 mxml.o: mxml/mxml.cxx mxml/mxml.h
-	$(CC) $(CFLAGS) -c -o mxml.o mxml/mxml.cxx
+	$(CXX) $(CXXFLAGS) -c -o mxml.o mxml/mxml.cxx
 
 strlcpy.o: mxml/strlcpy.cxx mxml/strlcpy.h
-	$(CC) $(CFLAGS) -c -o strlcpy.o mxml/strlcpy.cxx
+	$(CXX) $(CXXFLAGS) -c -o strlcpy.o mxml/strlcpy.cxx
 
 elogd: src/elogd.cxx auth.o $(OBJS) $(GIT_REVISION)
-	$(CC) $(CFLAGS) -o elogd src/elogd.cxx auth.o $(OBJS) $(LIBS)
+	$(CXX) $(CXXFLAGS) -o elogd src/elogd.cxx auth.o $(OBJS) $(LIBS)
 
 elog: src/elog.cxx $(OBJS) $(GIT_REVISION)
-	$(CC) $(CFLAGS) -o elog src/elog.cxx $(OBJS) $(LIBS)
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o elog src/elog.cxx $(OBJS) $(LIBS)
 
 debug: src/elogd.cxx auth.o $(OBJS)
-	$(CC) -g $(CFLAGS) -O0 -o elogd src/elogd.cxx auth.o $(OBJS) $(LIBS)
+	$(CXX) -CXX $(CFLAGS) -O0 -o elogd src/elogd.cxx auth.o $(OBJS) $(LIBS)
 
 %: src/%.cxx
-	$(CC) $(CFLAGS) -o $@ $< $(LIBS)
+	$(CXX) $(CXXFLAGS) -o $@ $< $(LIBS)
 
 ifeq ($(OSTYPE),CYGWIN_NT-5.1)
 loc: locext.exe
@@ -171,60 +171,60 @@
 endif
 
 update: $(EXECS)
-	@$(INSTALL) -v -m 0755 ${BINFLAGS} elogd $(SDESTDIR)
+	@$(INSTALL) -v -m 0755 ${BINFLAGS} elogd $(SBINDIR)
 
 install: $(EXECS)
-	@$(INSTALL) -m 0755 -d $(DESTDIR) $(SDESTDIR) $(MANDIR)/man1/ $(MANDIR)/man8/
-	@$(INSTALL) -m 0755 -d $(ELOGDIR)/scripts/ $(ELOGDIR)/resources/ $(ELOGDIR)/ssl/ $(ELOGDIR)/themes/default/icons
-	@$(INSTALL) -m 0755 -d $(ELOGDIR)/logbooks/demo
-	@$(INSTALL) -m 0755 -d $(ELOGDIR)/logbooks/demo/2001
-	@$(INSTALL) -v -m 0755 ${BINFLAGS} elog elconv $(DESTDIR)
-	@$(INSTALL) -v -m 0755 ${BINFLAGS} elogd $(SDESTDIR)
-	@$(INSTALL) -v -m 0644 man/elog.1 man/elconv.1 $(MANDIR)/man1/
-	@$(INSTALL) -v -m 0644 man/elogd.8 $(MANDIR)/man8/
-	@$(INSTALL) -v -m 0644 scripts/*.js $(ELOGDIR)/scripts/
-
-	@echo "Installing CKeditor to $(ELOGDIR)/scripts/ckeditor"
-	@cp -r scripts/* $(ELOGDIR)/scripts
-
-	@echo "Installing resources to $(ELOGDIR)/resources"
-	@$(INSTALL) -m 0644 resources/* $(ELOGDIR)/resources/
-	@if [ ! -f $(ELOGDIR)/ssl/server.crt ]; then  \
-	  $(INSTALL) -v -m 0644 ssl/server.crt $(ELOGDIR)/ssl/ ;\
+	@$(INSTALL) -m 0755 -d $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(MANDIR)/man1/ $(DESTDIR)$(MANDIR)/man8/
+	@$(INSTALL) -m 0755 -d $(DESTDIR)/$(ELOGDIR)/scripts/ $(DESTDIR)/$(ELOGDIR)/resources/ $(DESTDIR)/$(ELOGDIR)/ssl/ $(DESTDIR)/$(ELOGDIR)/themes/default/icons
+	@$(INSTALL) -m 0755 -d $(DESTDIR)/$(ELOGDIR)/logbooks/demo
+	@$(INSTALL) -m 0755 -d $(DESTDIR)/$(ELOGDIR)/logbooks/demo/2001
+	@$(INSTALL) -v -m 0755 ${BINFLAGS} elog elconv $(DESTDIR)/$(BINDIR)
+	@$(INSTALL) -v -m 0755 ${BINFLAGS} elogd $(DESTDIR)/$(SBINDIR)
+	@$(INSTALL) -v -m 0644 man/elog.1 man/elconv.1 $(DESTDIR)/$(MANDIR)/man1/
+	@$(INSTALL) -v -m 0644 man/elogd.8 $(DESTDIR)/$(MANDIR)/man8/
+	@$(INSTALL) -v -m 0644 scripts/*.js $(DESTDIR)/$(ELOGDIR)/scripts/
+
+	@echo "Installing CKeditor to $(DESTDIR)/$(ELOGDIR)/scripts/ckeditor"
+	@cp -r scripts/* $(DESTDIR)/$(ELOGDIR)/scripts
+
+	@echo "Installing resources to $(DESTDIR)/$(ELOGDIR)/resources"
+	@$(INSTALL) -m 0644 resources/* $(DESTDIR)/$(ELOGDIR)/resources/
+	@if [ ! -f $(DESTDIR)/$(ELOGDIR)/ssl/server.crt ]; then  \
+	  $(INSTALL) -v -m 0644 ssl/server.crt $(DESTDIR)/$(ELOGDIR)/ssl/ ;\
 	fi
-	@if [ ! -f $(ELOGDIR)/ssl/server.key ]; then  \
-	  $(INSTALL) -v -m 0644 ssl/server.key $(ELOGDIR)/ssl/ ;\
+	@if [ ! -f $(DESTDIR)/$(ELOGDIR)/ssl/server.key ]; then  \
+	  $(INSTALL) -v -m 0644 ssl/server.key $(DESTDIR)/$(ELOGDIR)/ssl/ ;\
 	fi
 
-	@echo "Installing themes to $(ELOGDIR)/themes"
-	@cp -r themes/* $(ELOGDIR)/themes
+	@echo "Installing themes to $(DESTDIR)/$(ELOGDIR)/themes"
+	@cp -r themes/* $(DESTDIR)/$(ELOGDIR)/themes
 
-	@echo "Installing example logbook to $(ELOGDIR)/logbooks/demo"
-	@if [ ! -f $(ELOGDIR)/logbooks/demo/2001 ]; then  \
-	  $(INSTALL) -v -m 0644 logbooks/demo/2001/* $(ELOGDIR)/logbooks/demo/2001 ; \
+	@echo "Installing example logbook to $(DESTDIR)/$(ELOGDIR)/logbooks/demo"
+	@if [ ! -f $(DESTDIR)/$(ELOGDIR)/logbooks/demo/2001 ]; then  \
+	  $(INSTALL) -v -m 0644 logbooks/demo/2001/* $(DESTDIR)/$(ELOGDIR)/logbooks/demo/2001 ; \
 	fi
 
-	@if [ ! -f $(ELOGDIR)/elogd.cfg ]; then  \
-	  $(INSTALL) -v -m 644 elogd.cfg.example $(ELOGDIR)/elogd.cfg ; \
+	@if [ ! -f $(DESTDIR)/$(ELOGDIR)/elogd.cfg ]; then  \
+	  $(INSTALL) -v -m 644 elogd.cfg.example $(DESTDIR)/$(ELOGDIR)/elogd.cfg ; \
 	fi
 
 
 ifneq ($(OSTYPE),darwin)
 	@sed "s#\@PREFIX\@#$(PREFIX)#g" elogd.init_template > elogd.init
-	@if [ ! -f $(RCDIR)/elogd ]; then  \
-	  $(INSTALL) -v -m 0755 -D elogd.init $(RCDIR)/elogd ; \
+	@if [ ! -f $(DESTDIR)/$(RCDIR)/elogd ]; then  \
+	  $(INSTALL) -v -m 0755 -D elogd.init $(DESTDIR)/$(RCDIR)/elogd ; \
 	fi
 endif
 
 ifneq ("$(wildcard $(SRVDIR))", "")
 	@$(INSTALL) -v -m 0644 -D elogd.service $(SRVDIR)
-	@echo The elogd service can now be started with 
+	@echo The elogd service can now be started with
 	@echo "  sudo systemctl start elogd"
 endif
 
 ifeq ($(OSTYPE),darwin)
 	@$(INSTALL) -v -m 0644 elogd.plist /Library/LaunchDaemons/ch.psi.elogd.plist
-	@echo The elogd service can now be started with 
+	@echo The elogd service can now be started with
 	@echo "  sudo launchctl load /Library/LaunchDaemons/ch.psi.elogd.plist"
 endif
 
