nvtool: fix compiler flag settings

This makes the build respect CPPFLAGS and LDFLAGS correctly.

It also drops the hardcoded -L path to the host system's libraries.

BUG=None
TEST=`emerge-x86-alex tpm` still works and uses right flags

Change-Id: I86f2904dc3975ffce18aa456e5adbb92a886c375
Reviewed-on: https://gerrit.chromium.org/gerrit/60836
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/nvtool/Makefile b/nvtool/Makefile
index 4403e8b..19dbee7 100644
--- a/nvtool/Makefile
+++ b/nvtool/Makefile
@@ -7,14 +7,14 @@
 OSNAME = $(shell uname)
 
 CC ?= gcc
-CFLAGS += -Wall -g -I. -L/usr/local/lib
+CPPFLAGS += -I.
+CFLAGS += -Wall -g
 LIBS = -ltspi
 
 ifeq ($(OSNAME), Darwin)
-ARCHS = -arch i386
+CPPFLAGS += -arch i386
+LDFLAGS += -arch i386
 LIBS += -liconv
-else
-ARCHS =
 endif
 
 TPM_NVTOOL_OBJS = main.o          \
@@ -27,13 +27,13 @@
 	@/bin/sh ./help/help-gen.sh
 
 $(TPM_NVTOOL): $(TPM_NVTOOL_OBJS)
-	$(CC) $(CFLAGS) $(ARCHS) -o $@ $^ $(LIBS)
+	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
 
 -include $(OBJS:.o=.d)
 
 %.o: %.c
-	$(CC) $(CFLAGS) $(ARCHS) $*.c -c -o $*.o
-	$(CC) $(CFLAGS) $(ARCHS) -MM $*.c > $*.d
+	$(CC) $(CFLAGS) $(CPPFLAGS) $*.c -c -o $*.o
+	$(CC) $(CFLAGS) $(CPPFLAGS) -MM $*.c > $*.d
 	@mv -f $*.d $*.d.tmp
 	@sed -e 's|.*:|$*.o:|' < $*.d.tmp > $*.d
 	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $*.d