chinachippatcher: convert to use libtools.make.

While at it break some long lines in the program output as well.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31282 a1c6a512-1295-4272-9138-f99709370657
diff --git a/rbutil/chinachippatcher/Makefile b/rbutil/chinachippatcher/Makefile
index af1e32a..7575cd9 100644
--- a/rbutil/chinachippatcher/Makefile
+++ b/rbutil/chinachippatcher/Makefile
@@ -4,93 +4,15 @@
 #   Jukebox    |    |   (  <_> )  \___|    < | \_\ (  <_> > <  <
 #   Firmware   |____|_  /\____/ \___  >__|_ \|___  /\____/__/\_ \
 #                     \/            \/     \/    \/            \/
+# $Id$
+#
+CFLAGS = -g -Wall
+CC = gcc
 
-#change for releases
-TARGET_DIR ?= $(shell pwd)/
-CFLAGS=-Wall -g
+OUTPUT = chinachip
 
-ifndef V
-SILENT = @
-endif
+LIBSOURCES = chinachip.c
+SOURCES = $(LIBSOURCES) main.c
 
-ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN)
-OUTPUT=chinachip.exe
-CFLAGS+=-mno-cygwin
-else
-ifeq ($(findstring MINGW,$(shell uname)),MINGW)
-OUTPUT=chinachip.exe
-else
-ifeq ($(findstring mingw,$(CC)),mingw)
-OUTPUT=chinachip.exe
-else
-OUTPUT=chinachip
-endif
-endif
-endif
+include ../libtools.make
 
-ifdef RBARCH
-CFLAGS += -arch $(RBARCH)
-OBJDIR = $(TARGET_DIR)build/$(RBARCH)/
-else
-OBJDIR = $(TARGET_DIR)build/
-endif
-
-
-all: $(OUTPUT)
-
-# inputs
-LIBSOURCES := chinachip.c
-SOURCES := $(LIBSOURCES) main.c
-OBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(SOURCES)))
-LIBOBJS := $(patsubst %.c,%.o,$(addprefix $(OBJDIR),$(LIBSOURCES)))
-EXTRADEPS :=
-
-$(OBJDIR)%.o: %.c
-	@echo CC $<
-	$(SILENT)mkdir -p $(dir $@)
-	$(SILENT)$(CC) $(CFLAGS) -c -o $@ $<
-
-libchinachip$(RBARCH).a: $(TARGET_DIR)libchinachip$(RBARCH).a
-
-$(TARGET_DIR)libchinachip$(RBARCH).a: $(LIBOBJS)
-	@echo AR $(notdir $@)
-	$(SILENT)$(AR) rucs $@ $^
-
-# building the standalone executable
-$(OUTPUT): $(OBJS) $(EXTRADEPS)
-	@echo LD $@
-	$(SILENT)$(CC) $(CFLAGS) -o $(OUTPUT) $(OBJS) $(EXTRADEPS)
-
-# some trickery to build ppc and i386 from a single call
-ifeq ($(RBARCH),)
-$(TARGET_DIR)libchinachipi386.a:
-	make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) libchinachipi386.a
-
-$(TARGET_DIR)libchinachipppc.a:
-	make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) libchinachipppc.a
-endif
-
-libchinachip-universal: $(TARGET_DIR)libchinachipi386.a $(TARGET_DIR)libchinachipppc.a
-	@echo lipo $(TARGET_DIR)libchinachip.a
-	$(SILENT) rm -f $(TARGET_DIR)libchinachip.a
-	$(SILENT)lipo -create $(TARGET_DIR)libchinachipppc.a $(TARGET_DIR)libchinachipi386.a -output $(TARGET_DIR)libchinachip.a
-
-clean:
-	rm -f $(OBJS) $(OUTPUT) libchinachip.o $(TARGET_DIR)libchinachip*.a chinachip.dmg
-	rm -rf chinachip-* i386 ppc $(OBJDIR)
-
-chinachip-i386:
-	$(MAKE) RBARCH=i386
-	mv chinachip chinachip-i386
-
-chinachip-ppc:
-	$(MAKE) RBARCH=ppc
-	mv chinachip chinachip-ppc
-
-chinachip-mac: chinachip-i386 chinachip-ppc
-	$(SILENT)lipo -create chinachip-ppc chinachip-i386 -output chinachip-mac
-
-chinachip.dmg: chinachip-mac
-	mkdir -p chinachip-dmg
-	cp -p chinachip-mac chinachip-dmg
-	hdiutil create -srcfolder chinachip-dmg chinachip.dmg
diff --git a/rbutil/chinachippatcher/main.c b/rbutil/chinachippatcher/main.c
index 0553b7d..e777977 100644
--- a/rbutil/chinachippatcher/main.c
+++ b/rbutil/chinachippatcher/main.c
@@ -22,7 +22,9 @@
 #include <stdarg.h>
 #include "chinachip.h"
 
+#ifndef VERSION /* allow setting version from outside for svn builds */
 #define VERSION         "0.1"
+#endif
 #define PRINT(fmt, ...) fprintf(stderr, fmt"\n", ##__VA_ARGS__)
 
 void usage(char* name)
@@ -31,16 +33,16 @@
     PRINT(" %s <firmware> <bootloader> <firmware_output> [backup]", name);
     PRINT("\nExample:");
     PRINT(" %s VX747.HXF bootloader.bin output.HXF ccpmp.bak", name);
-    PRINT(" This will copy ccpmp.bin in VX747.HXF as ccpmp.old and replace it"
-          " with bootloader.bin, the output will get written to output.HXF."
-          " The old ccpmp.bin will get written to ccpmp.bak.");
+    PRINT(" This will copy ccpmp.bin in VX747.HXF as ccpmp.old and replace it\n"
+          " with bootloader.bin, the output will get written to output.HXF.\n"
+          " The old ccpmp.bin will get written to ccpmp.bak.\n");
 }
 
 int main(int argc, char* argv[])
 {
     PRINT("ChinaChipPatcher v" VERSION " - (C) Maurus Cuelenaere 2009");
     PRINT("This is free software; see the source for copying conditions. There is NO");
-    PRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n");
+    PRINT("warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.");
 
     if(argc < 4)
     {