diff --git a/.gitignore b/.gitignore index 94d6e05..fdb7e57 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.[oa] bin/* obj/* +version.h diff --git a/Makefile b/Makefile index 8802ecb..fb96662 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,9 @@ all: debug release clean: clean_debug clean_release +gen_version: + echo "#define VERSION_STRING \"LGOGDownloader $(shell grep VERSION_NUMBER < main.cpp | head -n 1 | sed -e 's/.*\([0-9]\+\.[0-9]\+\).*/\1/')$(shell if [ -e .git/HEAD ]; then if git status | grep -q 'modified:'; then echo -n 'M'; fi && echo -n ' git ' && git rev-parse --short HEAD; fi)\"" > version.h + before_debug: test -d bin/Debug || mkdir -p bin/Debug test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG) @@ -55,7 +58,7 @@ before_debug: after_debug: -debug: before_debug out_debug after_debug +debug: before_debug gen_version out_debug after_debug out_debug: $(OBJ_DEBUG) $(DEP_DEBUG) $(LD) $(LDFLAGS_DEBUG) $(LIBDIR_DEBUG) $(OBJ_DEBUG) $(LIB_DEBUG) -o $(OUT_DEBUG) @@ -80,6 +83,7 @@ clean_debug: rm -rf bin/Debug rm -rf $(OBJDIR_DEBUG) rm -rf $(OBJDIR_DEBUG)/src + rm -f version.h before_release: test -d bin/Release || mkdir -p bin/Release @@ -88,7 +92,7 @@ before_release: after_release: -release: before_release out_release after_release +release: before_release gen_version out_release after_release out_release: $(OBJ_RELEASE) $(DEP_RELEASE) $(LD) $(LDFLAGS_RELEASE) $(LIBDIR_RELEASE) $(OBJ_RELEASE) $(LIB_RELEASE) -o $(OUT_RELEASE) @@ -113,6 +117,7 @@ clean_release: rm -rf bin/Release rm -rf $(OBJDIR_RELEASE) rm -rf $(OBJDIR_RELEASE)/src + rm -f version.h install: install $(OUT_RELEASE) /usr/bin @@ -120,5 +125,5 @@ install: uninstall: rm /usr/bin/lgogdownloader -.PHONY: before_debug after_debug clean_debug before_release after_release clean_release +.PHONY: gen_version before_debug after_debug clean_debug before_release after_release clean_release diff --git a/main.cpp b/main.cpp index ccc3520..ef0b104 100644 --- a/main.cpp +++ b/main.cpp @@ -7,12 +7,11 @@ #include "downloader.h" #include "config.h" #include "util.h" +#include "version.h" // generated by Makefile -#include // getpass #include #include #include -#include #if __GNUC__ # if __x86_64__ || __ppc64__ || __LP64__ @@ -22,12 +21,18 @@ # endif #endif +#define VERSION_NUMBER "2.3" + +#ifndef VERSION_STRING +# define VERSION_STRING "LGOGDownloader " VERSION_NUMBER +#endif + namespace bpo = boost::program_options; int main(int argc, char *argv[]) { Config config; - config.sVersionString = "LGOGDownloader 2.2+git"; + config.sVersionString = VERSION_STRING; config.sHome = (std::string)getenv("HOME"); config.sCookiePath = config.sHome + "/.gogdownloader/cookies.txt"; config.sConfigFilePath = config.sHome + "/.gogdownloader/config.cfg";