From db4842c42eeb07e808c200d1038ba141d074fe23 Mon Sep 17 00:00:00 2001 From: joonicks Date: Sat, 14 Apr 2018 19:12:18 +0200 Subject: [PATCH] version githash --- .gitignore | 9 +++++++++ VERSIONS | 3 ++- configure | 5 +++++ src/Makefile.in | 15 +++++++++------ src/config.h.in | 6 ++++++ src/gencmd.c | 31 ++++++++++++++++++++++--------- src/global.h | 6 ++++-- 7 files changed, 57 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index b6bfb93..66e2f3d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ src/Makefile src/config.h src/mcmd.h src/usercombo.h +src/githash.h trivia/*.index # compiled files @@ -28,6 +29,8 @@ mech.pid mech.session root.zone* trick.conf +mech.trivscore +trivia/megatrivia.txt # developer files .use_size @@ -36,3 +39,9 @@ debug* *.log *.stats github + +src/calc.c +src/x +src/y +src/z + diff --git a/VERSIONS b/VERSIONS index bac9962..316e72c 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,6 @@ -3.0.99p4 -- WORK IN PROGRESS (~March, 2018) +3.1 -- WORK IN PROGRESS (~April, 2018) + * Added: Git version hash included in version string if git environment is found. * Added: RAND command (toybox). Usage: RAND [[min[-| ]]max|"nick"|"luser"] * Added: Energymech can now link with libmusl (--with-libmusl[=/PATH/TO/musl-gcc]) * Added: (ALPHA) Perl scripting support (PERL, PERLSCRIPT) diff --git a/configure b/configure index 7520118..354915a 100755 --- a/configure +++ b/configure @@ -1094,8 +1094,12 @@ fi # # is this a git environment # +def_git='#undef HAVE_GIT' echo $ac_n "checking for git ... "$ac_c GITEXE=`config/which git` +if [ -x $GITEXE -a -r .git ]; then + def_git='#define HAVE_GIT' +fi echo $ac_t "$GITEXE" # @@ -1469,6 +1473,7 @@ s|@DEF_URLCAPTURE@|$def_urlcapture|; s|@DEF_WEB@|$def_web|; s|@DEF_WINGATE@|$def_wingate|; +s|@DEF_GIT@|$def_git|; s|@LIT_END@|$LIT_END|; s|@BIG_END@|$BIG_END|; s|@DEF_CRYPT_FUNCTION@|$CRYPT_FUNCTION|; diff --git a/src/Makefile.in b/src/Makefile.in index c6d405e..da76d88 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -75,21 +75,24 @@ mcmd.h: gencmd usercombo.h: gencmd ./gencmd usercombo.h +githash.h: gencmd + ./gencmd githash.h + install: $(INSTALLNAME) $(CHMOD) $(INSTALLMODE) $(INSTALLNAME) $(MV) $(INSTALLNAME) $(INSTALLDIR) clean: - $(RM) $(INSTALLNAME) gencmd mcmd.h usercombo.h core $(TESTFILES) $(OFILES) + $(RM) $(INSTALLNAME) gencmd mcmd.h usercombo.h githash.h core $(TESTFILES) $(OFILES) $(INSTALLNAME): $(OFILES) $(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL) -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) +#@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) @sz@ size $(INSTALLNAME) $(INSTALLNAME)-static: $(OFILES) $(CROSS_COMPILE)$(CC) $(LFLAGS) -o $(INSTALLNAME) $(OFILES) $(LPROF) $(LIBS) $(LDSCRIPT) $(L_PERL) -static -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) +#@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment -R .got -R .got.plt $(INSTALLNAME) @sz@ size $(INSTALLNAME) @@ -105,12 +108,12 @@ mega-install: mega $(SRCFILES) $(INCS) usage.h mega: $(SRCFILES) $(INCS) usage.h $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c -DGENDATE="`./gencmd date`" -I. $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) +#@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) @sz@ size $(INSTALLNAME) mega-static: $(SRCFILES) $(INCS) usage.h $(CROSS_COMPILE)$(CC) $(CFLAGS) -o $(INSTALLNAME) mega.c -DGENDATE="`./gencmd date`" -I. $(LPROF) $(LIBS) $(LDSCRIPT) $(PYINCLUDE) $(TCLINCLUDE) $(I_PERL) $(L_PERL) -static -@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) +#@oc@ $(CROSS_COMPILE)objcopy -R .note -R .comment $(INSTALLNAME) @sz@ size $(INSTALLNAME) # @@ -185,7 +188,7 @@ irc.o: irc.c $(INCS) kicksay.o: kicksay.c $(INCS) $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< $(CPROF) -main.o: main.c $(INCS) +main.o: main.c $(INCS) githash.h $(CROSS_COMPILE)$(CC) $(CFLAGS) -c $< -DGENDATE="`./gencmd date`" $(CPROF) $(PYINCLUDE) net.o: net.c $(INCS) diff --git a/src/config.h.in b/src/config.h.in index 058f470..8b50865 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -239,6 +239,12 @@ #define SCRIPTING #endif + +/* + * define for git environments + */ +@DEF_GIT@ + /* * */ diff --git a/src/gencmd.c b/src/gencmd.c index 3f5a67d..d715d4b 100644 --- a/src/gencmd.c +++ b/src/gencmd.c @@ -510,20 +510,33 @@ void datestamp(void) t->tm_year + 1900,hourampm[t->tm_hour],t->tm_min,(t->tm_hour <= 11) ? "am" : "pm"); } +void githash(void) +{ +#ifdef HAVE_GIT + system("git log -n 1 | grep commit | sed -r 's/^commit (.{7}).*/#define GITHASH \" (git:\\1)\"/g;' > githash.h"); +#else + system("echo '#define GITHASH \"\"' > githash.h"); +#endif +} + int main(int argc, char **argv) { + if (argv[1]) + { + if (strcmp(argv[1],"usercombo.h") == 0) + make_usercombo(); - if (argv[1] && strcmp(argv[1],"usercombo.h") == 0) - make_usercombo(); + if (strcmp(argv[1],"mcmd.h") == 0) + make_mcmd(); - if (argv[1] && strcmp(argv[1],"mcmd.h") == 0) - make_mcmd(); + if (strcmp(argv[1],"testhelp") == 0) + test_help(); - if (argv[1] && strcmp(argv[1],"testhelp") == 0) - test_help(); - - if (argv[1] && strcmp(argv[1],"date") == 0) - datestamp(); + if (strcmp(argv[1],"date") == 0) + datestamp(); + if (strcmp(argv[1],"githash.h") == 0) + githash(); + } return(0); } diff --git a/src/global.h b/src/global.h index 064f7e7..542b6c5 100644 --- a/src/global.h +++ b/src/global.h @@ -33,6 +33,8 @@ #endif /* MAIN_C */ +#include "githash.h" + /* * */ @@ -40,8 +42,8 @@ #define DEFAULTCMDCHAR '-' #define MECHUSERLOGIN "v3.energymech.net" -BEG const char VERSION[] MDEF("3.0.99p4"); -BEG const char SRCDATE[] MDEF("March 13th, 2018"); +BEG const char VERSION[] MDEF("3.1p" GITHASH); +BEG const char SRCDATE[] MDEF("April 14th, 2018"); #ifdef __CYGWIN__ BEG const char BOTCLASS[] MDEF("WinMech"); #else /* ! CYGWIN */