Makefile: Allow Makefile to get CXX and CXXFLAGS from environment

Should make wrapping the build a little simpler.

Plus some tidying.

Review URL: http://codereview.chromium.org/1124003
diff --git a/Makefile b/Makefile
index be6946b..97d5375 100644
--- a/Makefile
+++ b/Makefile
@@ -2,31 +2,32 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-CXX=g++
-LDFLAGS=-lbase -lpthread -lrt -lchromeos
-CXXFLAGS=-Wall -Werror -g
-INCLUDE_DIRS=-I../../third_party/chrome/files -I.. $(shell pkg-config --cflags gobject-2.0 dbus-1 dbus-glib-1)
-LIB_DIRS=-L../../third_party/chrome $(shell pkg-config --libs gobject-2.0 dbus-1 dbus-glib-1)
+CXX ?= g++
+CXXFLAGS ?= -Wall -Werror -g
 
-SESSION_COMMON_OBJS=session_manager_service.o child_job.o interface.o
+LIBS = -lbase -lpthread -lrt -lchromeos
+INCLUDE_DIRS = -I.. $(shell pkg-config --cflags gobject-2.0 dbus-1 dbus-glib-1)
+LIB_DIRS = $(shell pkg-config --libs gobject-2.0 dbus-1 dbus-glib-1)
 
-DBUS_SOURCE=session_manager.xml
-DBUS_SERVER=bindings/server.h
-DBUS_CLIENT=bindings/client.h
+SESSION_COMMON_OBJS = session_manager_service.o child_job.o interface.o
 
-SESSION_BIN=session_manager
-SESSION_OBJS=$(SESSION_COMMON_OBJS) session_manager_main.o
+DBUS_SOURCE = session_manager.xml
+DBUS_SERVER = bindings/server.h
+DBUS_CLIENT = bindings/client.h
 
-SIGNALLER_BIN=signaller
-SIGNALLER_OBJS=signaller.o
+SESSION_BIN = session_manager
+SESSION_OBJS = $(SESSION_COMMON_OBJS) session_manager_main.o
 
-TEST_BIN=session_manager_unittest
-TEST_OBJS=$(SESSION_COMMON_OBJS) session_manager_testrunner.o \
-	session_manager_unittest.o child_job_unittest.o 
+SIGNALLER_BIN = signaller
+SIGNALLER_OBJS = signaller.o
 
-BINDINGS_DIR=bindings
+TEST_BIN = session_manager_unittest
+TEST_OBJS = $(SESSION_COMMON_OBJS) session_manager_testrunner.o \
+	session_manager_unittest.o child_job_unittest.o
 
-all:	$(SESSION_BIN) $(SIGNALLER_BIN) $(TEST_BIN)
+BINDINGS_DIR = bindings
+
+all: $(SESSION_BIN) $(SIGNALLER_BIN) $(TEST_BIN)
 
 $(SESSION_OBJS) : $(DBUS_SERVER)
 $(SIGNALLER_OBJS) : $(DBUS_CLIENT)
@@ -34,15 +35,15 @@
 
 $(SESSION_BIN): $(SESSION_OBJS)
 	$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) $(LIB_DIRS) $(SESSION_OBJS) \
-	 $(LDFLAGS) -o $(SESSION_BIN)
+	$(LIBS) $(LDFLAGS) -o $(SESSION_BIN)
 
 $(SIGNALLER_BIN): $(SIGNALLER_OBJS)
 	$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) $(LIB_DIRS) $(SIGNALLER_OBJS) \
-	 $(LDFLAGS) -o $(SIGNALLER_BIN)
+	$(LIBS) $(LDFLAGS) -o $(SIGNALLER_BIN)
 
 $(TEST_BIN): $(TEST_OBJS)
 	$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) $(LIB_DIRS) $(TEST_OBJS) \
-	 $(LDFLAGS) -lgtest -lgmock -o $(TEST_BIN)
+	$(LIBS) $(LDFLAGS) -lgtest -lgmock -o $(TEST_BIN)
 
 .cc.o:
 	$(CXX) $(CXXFLAGS) $(INCLUDE_DIRS) -c $< -o $@
@@ -58,5 +59,5 @@
 	dbus-binding-tool --mode=glib-client \
 	 --prefix=`basename $(DBUS_SOURCE) .xml` $(DBUS_SOURCE) > $(DBUS_CLIENT)
 
-clean:	
+clean:
 	rm -rf *.o $(SESSION_BIN) $(SIGNALLER_BIN) $(TEST_BIN) $(BINDINGS_DIR)