From 20348ed1e9edef9f98495530c14b25d663330031 Mon Sep 17 00:00:00 2001 From: H Hautakoski Date: Wed, 9 Jun 2010 14:30:51 +0200 Subject: [PATCH] wrapperscript generation from makefile --- Makefile | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index e214abb..8c34218 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,20 @@ # Archive Makefile # +# uncomment and edit this to match your system +#DB_HOST := localhost +#DB_USER := dbusr +#DB_PASS := dbpass +#DB_NAME := dbname +#DB_TBL := dbtable + +ifdef DEBUG +CFLAGS := -g DEFS := -D__DEBUG__ +endif + LIBS := `mysql_config --libs` -CFLAGS := -Werror -g $(LIBS) $(DEFS) +CFLAGS := -Werror $(LIBS) $(DEFS) CC := gcc SOURCES := \ @@ -20,11 +31,23 @@ SOURCES := \ BUILD := ./build all : - make me - -me : - mkdir -p $(BUILD) + @mkdir -p $(BUILD) +ifdef DB_HOST + make wrapper +else + @echo "Tip: edit this Makefile DB_* macros to enable generation of a wrapper shellscript" +endif $(CC) $(CFLAGS) $(SOURCES) -o $(BUILD)/arch + +wrapper : + @echo "#!/bin/sh" > $(BUILD)/wrapper + @echo "if [ \$$# -lt 1 ]; then" >> $(BUILD)/wrapper + @echo " echo \"usage: \$$0 \"" >> $(BUILD)/wrapper + @echo " exit" >> $(BUILD)/wrapper + @echo "fi" >> $(BUILD)/wrapper + @echo "./arch \"\$$1\" \"$(DB_HOST)\" \"$(DB_USER)\" \"$(DB_PASS)\" \"$(DB_NAME)\" \"$(DB_TBL)\"" >> $(BUILD)/wrapper + @chmod 755 $(BUILD)/wrapper + @echo "generated $(BUILD)/wrapper" clean : rm -fr $(BUILD)