Add "make gen" target to regenerate em100pro_chips.h

This downloads the Windows release from dediprog.com and extracts
the per-chip data into em100pro_chips.h.  It can be used to refresh
the list when new chip types are added upstream.

"make gen" will be invoked automatically if em100pro_chips.h is
somehow absent, but it will not be invoked during a normal build from
git sources.

BUG=chromium:213898
TEST=run "make gen"

Change-Id: I703fc8332502d4731645b5c652e5b7cbb24e0e56
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
diff --git a/Makefile b/Makefile
index bdf9722..ddc162e 100644
--- a/Makefile
+++ b/Makefile
@@ -20,21 +20,29 @@
 CC?=gcc
 PKG_CONFIG?=pkg-config
 
+# This affects the glob sort order for "configs/*.cfg"
+export LANG=C
+
 em100: em100.c em100pro_chips.h
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< \
 		$(shell $(PKG_CONFIG) --cflags --libs libusb-1.0)
 
+# create generated files (currently just em100pro_chips.h)
+gen: makechips
+	./makechips.sh
+	./makechips configs/*.cfg > em100pro_chips.h.tmp
+	mv -f em100pro_chips.h.tmp em100pro_chips.h
+
+em100pro_chips.h:
+	$(MAKE) gen
+
 makechips: makechips.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<
 
-em100pro_chips.h: makechips
-	./makechips.sh
-	./makechips configs/*.cfg > $@
-
 clean:
 	rm -f em100
 
 distclean: clean
 	rm -rf configs makechips
 
-.PHONY: clean distclean
+.PHONY: gen clean distclean
diff --git a/makechips.sh b/makechips.sh
index 7fe8872..a837712 100755
--- a/makechips.sh
+++ b/makechips.sh
@@ -49,6 +49,7 @@
 run_unrar $FILE ${FILE%.rar}.msi > /dev/null
 7z x ${FILE%.rar}.msi PRO_* > /dev/null
 echo  Copying...
+rm -rf $WD/configs
 mkdir -p $WD/configs
 for i in PRO_*; do
   cp $i $WD/configs/${i#PRO_}.cfg