clean up build system

This fixes the compile/link steps to respect all the right flags.

BUG=chromium-os:31625
TEST=`make` still works

Change-Id: Ic70feedd20122b9bccb18e0f3e121c9dd82187ed
diff --git a/Makefile b/Makefile
index f32f072..c7da651 100644
--- a/Makefile
+++ b/Makefile
@@ -15,14 +15,17 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
 #
 
-CFLAGS=-O2 -Wall -g
+CFLAGS?=-O2 -g
+CFLAGS+=-Wall
 CC?=gcc
+PKG_CONFIG?=pkg-config
 
 em100: em100.c em100pro_chips.h
-	$(CC) $(CFLAGS) -o $@ $< $(shell pkg-config --cflags --libs libusb-1.0)
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< \
+		$(shell $(PKG_CONFIG) --cflags --libs libusb-1.0)
 
 makechips: makechips.c
-	$(CC) $(CFLAGS) -o $@ $<
+	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
 
 em100pro_chips.h: makechips
 	./makechips.sh