From: nveid Date: Tue, 11 Jan 2011 02:29:07 +0000 (+0000) Subject: Incorporated mkcmds.pl from recent penn distributions. Also took out PATCHES define... X-Git-Url: https://git.theari.com/?a=commitdiff_plain;h=fbe693dbe2b2fe0dd4fd6269a21c7474781246b3;p=cobramush.git Incorporated mkcmds.pl from recent penn distributions. Also took out PATCHES define in version reporting. Ignore-this: 7483ab12f6f959aff61f759250b2584e --- diff --git a/MANIFEST b/MANIFEST index 8ffd660..03e0342 100644 --- a/MANIFEST +++ b/MANIFEST @@ -226,7 +226,7 @@ utils/fixdepend.pl utils/gentables.c utils/ln-dir.sh utils/make_access_cnf.sh -utils/mkcmds.sh.SH +utils/mkcmds.pl utils/penn-install utils/update-cnf.pl utils/update.pl diff --git a/Makefile.SH b/Makefile.SH index 37c4a23..2a8cbfe 100644 --- a/Makefile.SH +++ b/Makefile.SH @@ -93,19 +93,16 @@ options.h: options.h.dist autogen: hdrs/cmds.h hdrs/funs.h hdrs/switches.h hdrs/cmds.h: src/cmds.c src/command.c src/cque.c src/help.c src/set.c src/sql.c Patchlevel - (cd utils; sh mkcmds.sh commands) + (perl utils/mkcmds.pl commands) hdrs/switches.h: src/SWITCHES Patchlevel - (cd utils; sh mkcmds.sh switches) + (perl utils/mkcmds.pl switches) src/switchinc.c: src/SWITCHES Patchlevel - (cd utils; sh mkcmds.sh switches) + (perl utils/mkcmds.pl switches) -hdrs/funs.h: src/fun*.c src/bsd.c src/conf.c src/extmail.c src/help.c src/wiz.c src/sql.c Patchlevel - (cd utils; sh mkcmds.sh functions) - -hdrs/patches.h: patches/* - (cd utils; sh mkcmds.sh patches) +hdrs/funs.h: src/fun*.c src/bsd.c src/conf.c src/cque.c src/extmail.c src/help.c src/wiz.c src/sql.c Patchlevel + (perl utils/mkcmds.pl functions) install: localized all game/restart -rm -f game/netmush @@ -156,7 +153,7 @@ distdepend: hdrs/funs.h hdrs/cmds.h # REQUIRES GNU INDENT! DON'T INDENT WITH ANYTHING ELSE! indent: - @(cd src; make indent) +# @(cd src; make indent) protoize: (cd src; make protoize "CCFLAGS=$(CCFLAGS)") @@ -230,7 +227,7 @@ clean: distclean: (cd hdrs; rm -f *.orig *~ \#* *.rej *.bak funs.h cmds.h buildinf.h patches.h) - (cd utils; rm -f *.orig *~ \#* *.rej *.bak mkcmds.sh) + (cd utils; rm -f *.orig *~ \#* *.rej *.bak) (cd game; rm -rf *.log netmush info_slave *.orig *.rej *~ *.bak mush.cnf) (cd os2; rm -rf *.rej *.orig *~ *.bak) (cd src; make distclean; rm -f Makefile) @@ -287,14 +284,10 @@ touchswitches: dist.tar: indent distclean versions touchswitches autogen makedist -c cobramush tar -cvf /tmp/dist.tar cobramush - -pgp -sb /tmp/dist.tar +# CobraMUSH does not pgp sign distributions at this moment +# -pgp -sb /tmp/dist.tar -rm -rf cobramush -CSRImalloc.tar.Z: - (cd src/CSRI; make clean) - (tar -cvFFf /tmp/CSRImalloc.tar `cat exclude.tar`) - compress /tmp/CSRImalloc.tar - globalinstall: install (cd game/txt; make clean compose.sh) $(INSTALLDIR) $(GLOBAL_INSTALL) @@ -321,11 +314,11 @@ debianinstall: install $(INSTALL) src/netmud $(DEB_INSTALL)/netmush $(INSTALL) src/console $(DEB_INSTALL)/console $(INSTALL) src/info_slave $(DEB_INSTALL)/info_slave - $(INSTALL) utils/penn-install $(DEB_BIN)/penn-install + $(INSTALL) utils/cobramush-install $(DEB_BIN)/cobramush-install $(CHMOD) a+rX -R $(DEB_INSTALL) - $(CHMOD) a+rX $(DEB_BIN)/penn-install + $(CHMOD) a+rX $(DEB_BIN)/cobramush-install @echo "** Files installed in $(DEB_INSTALL)." - @echo "** You can run penn-install to create a user directory." + @echo "** You can run cobramush-install to create a user directory." !NO!SUBS! chmod 644 Makefile diff --git a/src/Makefile.SH b/src/Makefile.SH index 3c53fbe..c452220 100644 --- a/src/Makefile.SH +++ b/src/Makefile.SH @@ -188,10 +188,6 @@ local.c: local.dst echo "********************************************************"; \ fi -../hdrs/patches.h: - if [ ! -f ../hdrs/patches.h ]; then \ - (cd ../utils; sh mkcmds.sh patches); \ - fi ../po/pennmush.pot: $(C_FILES) $(H_FILES) xgettext -d pennmush -kT -o ../po/pennmush.pot $(C_FILES) $(H_FILES) @@ -375,7 +371,6 @@ bsd.o: ../hdrs/access.h bsd.o: ../hdrs/command.h bsd.o: ../hdrs/switches.h bsd.o: ../hdrs/version.h -bsd.o: ../hdrs/patches.h bsd.o: ../hdrs/mysocket.h bsd.o: ../hdrs/ident.h bsd.o: ../hdrs/strtree.h @@ -1442,7 +1437,6 @@ notify.o: ../hdrs/pueblo.h notify.o: ../hdrs/parse.h notify.o: ../hdrs/access.h notify.o: ../hdrs/version.h -notify.o: ../hdrs/patches.h notify.o: ../hdrs/mysocket.h notify.o: ../hdrs/ident.h notify.o: ../hdrs/strtree.h @@ -1876,7 +1870,6 @@ version.o: ../hdrs/chunk.h version.o: ../hdrs/bufferq.h version.o: ../confmagic.h version.o: ../hdrs/version.h -version.o: ../hdrs/patches.h version.o: ../hdrs/buildinf.h warnings.o: ../config.h warnings.o: ../hdrs/copyrite.h diff --git a/src/bsd.c b/src/bsd.c index 5d208ae..ab169c0 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -109,7 +109,6 @@ #include "access.h" #include "command.h" #include "version.h" -#include "patches.h" #include "mysocket.h" #include "ident.h" #include "strtree.h" @@ -3466,9 +3465,7 @@ dump_info(DESC *call_by) queue_string_eol(call_by, tprintf("Size: %d", db_top)); queue_string_eol(call_by, tprintf("Version: CobraMUSH v%s [%s]", VERSION, VBRANCH)); -#ifdef PATCHES - queue_string_eol(call_by, tprintf("Patches: %s", PATCHES)); -#endif + queue_string_eol(call_by, "### End INFO"); } diff --git a/src/notify.c b/src/notify.c index a2f22ce..ee9097d 100644 --- a/src/notify.c +++ b/src/notify.c @@ -71,7 +71,6 @@ #include "parse.h" #include "access.h" #include "version.h" -#include "patches.h" #include "mysocket.h" #include "ident.h" #include "strtree.h" diff --git a/src/switchinc.c b/src/switchinc.c index d7e57c2..ea4825e 100644 --- a/src/switchinc.c +++ b/src/switchinc.c @@ -1,4 +1,4 @@ -/* AUTOGENERATED FILE. DO NOT EDIT */ +/* AUTOGENERATED FILE. DO NOT EDIT! */ SWITCH_VALUE switch_list[] = { {"ACCESS", SWITCH_ACCESS}, {"ADD", SWITCH_ADD}, diff --git a/src/version.c b/src/version.c index e50e6b2..b8979f0 100644 --- a/src/version.c +++ b/src/version.c @@ -15,7 +15,6 @@ #include "externs.h" #include "version.h" -#include "patches.h" #ifndef WIN32 #include "buildinf.h" #endif @@ -36,9 +35,6 @@ do_version(player) notify_format(player, T("Last restarted: %s"), buff); notify_format(player, "CobraMUSH v%s [%s]", VERSION, VBRANCH); -#ifdef PATCHES - notify_format(player, "Patches: %s", PATCHES); -#endif #ifdef WIN32 notify_format(player, T("Build date: %s"), __DATE__); #else diff --git a/utils/mkcmds.pl b/utils/mkcmds.pl new file mode 100644 index 0000000..7198b24 --- /dev/null +++ b/utils/mkcmds.pl @@ -0,0 +1,209 @@ +#!/usr/bin/perl -w +# perl version of the old mkcmds.sh script. Runs faster by simply not running +# a bazillion child processes. Also uses SelfLoader to avoid compiling functions +# that are never used, since it's usually invoked with at most 1 argument. +# + +use SelfLoader; +use File::Compare; +use File::Copy; +use strict; # Please ma'am may I have another? + +# SelfLoaded functions +use subs qw/make_patches make_switches make_cmds make_funs/; +# Always present functions +use subs qw/maybemove temp_header temp_source scan_files_for_pattern/; + +print "Starting...\n"; + +# Main loop, dispatch for each command line argument. +foreach my $command (@ARGV) { + if ($command eq "switches") { + make_switches; + } elsif ($command eq "commands") { + print "Commands\n"; + make_cmds; + } elsif ($command eq "functions") { + make_funs; + } elsif ($command eq "all") { +# make_patches; + make_switches; + make_cmds; + make_funs; + } else { + warn "Unknown option '${command}'\n"; + } +} + +# Return name of a temp file in hdrs/ +sub temp_header { + return "hdrs/temp.$$.h"; +} + +# Return name of a temp file in src/ +sub temp_source { + return "src/temp.$$.c"; +} + +# maybemove(file1, file2) copies file1 to file 2 if they are different, +# otherwise just deletes file1 and leaves file2 unchanged. +sub maybemove { + my $from = shift; + my $to = shift; + + if (compare $from, $to) { + if (move $from, $to) { + print "File ${to} updated.\n"; + } else { + warn "Couldn't rename ${from} to ${to}: $!\n"; + } + } else { + print "File ${to} unchanged.\n"; + unlink $from; + } +} + +# scan_files_for_pattern(glob-pattern, re) searches all files matching +# glob-pattern for lines matching re, and returns a sorted list of +# $1's for each matching line. +sub scan_files_for_pattern { + my $filepattern = shift; + my $re = shift; + my @idents; + + foreach my $file (glob $filepattern) { + open FILE, "<", $file + or die "Cannot open ${file} for reading: $!\n"; + while () { + chomp; + push @idents, $1 if m/$re/; + } + close FILE; + } + + return sort @idents; +} + + +END { + # Make sure temp files get deleted. + my @files = (temp_header(), temp_source()); + foreach my $file (@files) { + unlink $file if -f $file; + } +} + +__DATA__ + +sub make_switches { + print "Rebuilding command switch file and header.\n"; + my $auto_msg = "/* AUTOGENERATED FILE. DO NOT EDIT! */\n"; + + my $temphdr = temp_header; + my $tempsrc = temp_source; + + open CMDHDR, "<", "hdrs/command.h" or + die "Unable to open hdrs/command.h for reading: $!\n"; + my $numbytes = 20; + while () { + if (m/^#define\s+NUM_BYTES\s+(\d+)/o) { + $numbytes = $1; + last; + } + } + close CMDHDR; + + my $MAXSWITCHES = $numbytes * 8; + + my @switches = scan_files_for_pattern "src/SWITCHES", qr/^(.+)/; + + warn "Too many switches defined!\n" if length @switches > $MAXSWITCHES; + + open HDR, ">", $temphdr or + die "Unable to open $temphdr for writing: $!\n"; + open SRC, ">", $tempsrc or + die "Unable to open $tempsrc for writing: $1\n"; + + print HDR $auto_msg; + print HDR "#ifndef SWITCHES_H\n"; + print HDR "#define SWITCHES_H\n"; + + print SRC $auto_msg; + print SRC "SWITCH_VALUE switch_list[] = {\n"; + + my $n = 1; + foreach my $switch (@switches) { + print HDR "#define SWITCH_${switch} ${n}\n"; + print SRC " {\"${switch}\", SWITCH_${switch}},\n"; + $n++; + } + + print SRC " {NULL, 0}\n"; + print SRC "};\n"; + close SRC; + + print HDR "#endif /* SWITCHES_H */\n"; + close HDR; + + maybemove $temphdr, "hdrs/switches.h"; + maybemove $tempsrc, "src/switchinc.c"; +} + +# I really should combine this and make_funs into one function that does +# the work with specific files/regexps/defines passed as arguments + +sub make_cmds { + my $auto_msg = "/* AUTOGENERATED FILE. DO NOT EDIT! */\n"; + + print "Rebuilding command prototype header.\n"; + + my $tempfile = temp_header; + + my @commands = + scan_files_for_pattern "src/*.c", qr/^\s*COMMAND\s?\(([^\)]+)\)*/; + + open HDR, ">", $tempfile + or die "Can't open ${tempfile} for writing: $!\n"; + + print HDR $auto_msg; + print HDR "#ifndef CMDS_H\n"; + print HDR "#define CMDS_H\n"; + + foreach my $command (@commands) { + print HDR "COMMAND_PROTO(${command});\n"; + } + + print HDR "#endif /* CMDS_H */\n"; + close HDR; + + maybemove $tempfile, "hdrs/cmds.h"; + +} + +sub make_funs { + my $auto_msg = "/* AUTOGENERATED FILE. DO NOT EDIT! */\n"; + + print "Rebuilding function prototype header.\n"; + + my $tempfile = temp_header; + + my @functions = + scan_files_for_pattern "src/*.c", qr/^\s*FUNCTION\(([^\)]+)\)/; + + open HDR, ">", $tempfile + or die "Can't open ${tempfile} for writing: $!\n"; + + print HDR $auto_msg; + print HDR "#ifndef FUNS_H\n"; + print HDR "#define FUNS_H\n"; + + foreach my $function (@functions) { + print HDR "FUNCTION_PROTO(${function});\n"; + } + + print HDR "#endif /* FUNS_H */\n"; + close HDR; + + maybemove $tempfile, "hdrs/funs.h"; +} + diff --git a/utils/mkcmds.sh.SH b/utils/mkcmds.sh.SH deleted file mode 100644 index e455859..0000000 --- a/utils/mkcmds.sh.SH +++ /dev/null @@ -1,163 +0,0 @@ -case $CONFIG in -'') - if test -f config.sh; then TOP=.; - elif test -f ../config.sh; then TOP=..; - elif test -f ../../config.sh; then TOP=../..; - elif test -f ../../../config.sh; then TOP=../../..; - elif test -f ../../../../config.sh; then TOP=../../../..; - else - echo "Can't find config.sh."; exit 1 - fi - . $TOP/config.sh - ;; -esac -: This forces SH files to create target in same directory as SH file. -: This is so that make depend always knows where to find SH derivatives. -case "$0" in -*/*) cd `expr X$0 : 'X\(.*\)/'` ;; -esac -echo "Extracting mkcmds.sh (with variable substitutions)" -: This section of the file will have variable substitutions done on it. -: Move anything that needs config subs from !NO!SUBS! section to !GROK!THIS!. -: Protect any dollar signs and backticks that you do not want interpreted -: by putting a backslash in front. You may delete these comments. -$spitshell >mkcmds.sh <>mkcmds.sh <<'!NO!SUBS!' -# -# Make various tables and header files. -# We run this from the utils directory. -# -if [ -f "../nocmds" ]; then - $echo "Not building" - exit -fi - -case $1 in - patches) -if [ -d ../patches ]; then - $echo "Rebuilding list of installed Patches" - for bu in ../patches/*; do - case $bu in - *~) ;; # Ignore these - *) - name=`grep "^# Patch name:" $bu | sed 's/[^:]*://'` - ver=`grep "^# Patch version:" $bu | sed 's/[^:]*://'` - name=`$echo $name` - ver=`$echo $ver` - if [ "X$name" != "X" ]; then - if [ "X$ver" != "X" ]; then - pat="${pat}${name}(${ver}) " - else - pat="${pat}${name} " - fi - fi - ;; - esac - done - pat=`$echo $pat` -fi - -rm -f ../hdrs/temp.$$.h -rm -f ../src/temp.$$.c - -$echo "/* AUTOGENERATED FILE. DO NOT EDIT */" > ../hdrs/temp.$$.h -$echo "#ifndef _PATCH_H" >> ../hdrs/temp.$$.h -$echo "#define _PATCH_H" >> ../hdrs/temp.$$.h -if [ "X$pat" = "X" ]; then - $echo "#undef PATCHES" >> ../hdrs/temp.$$.h -else - $echo "#define PATCHES \"$pat\"" >> ../hdrs/temp.$$.h -fi -$echo "#endif /* _PATCH_H */" >> ../hdrs/temp.$$.h -cmp -s ../hdrs/patches.h ../hdrs/temp.$$.h -cmpstat=$? -if [ $cmpstat -eq 0 ]; then - rm -f ../hdrs/temp.$$.h -else - mv -f ../hdrs/temp.$$.h ../hdrs/patches.h -fi - -;; -switches) - -$echo "Rebuilding command switch file" -snum=1 -$echo "/* AUTOGENERATED FILE. DO NOT EDIT */" > ../src/temp.$$.c -$echo "/* AUTOGENERATED FILE. DO NOT EDIT */" > ../hdrs/temp.$$.h -$echo "SWITCH_VALUE switch_list[] = {" >> ../src/temp.$$.c -for s in `cat ../src/SWITCHES | sort`; do - $echo "#define SWITCH_$s $snum" >> ../hdrs/temp.$$.h - $echo $n " {$c" >> ../src/temp.$$.c - $echo $n "\"$s\", SWITCH_$s$c" >> ../src/temp.$$.c - $echo $n "}$c" >> ../src/temp.$$.c - $echo "," >> ../src/temp.$$.c - $echo $n "." - snum=`expr $snum + 1` -done -$echo " {NULL, 0}" >> ../src/temp.$$.c -$echo "};" >> ../src/temp.$$.c -$echo "" - -# NUM_BYTES from command.h * 8. -if [ $snum -gt 176 ]; then - $echo "You have too many switches defined!" -fi - -mv -f ../hdrs/temp.$$.h ../hdrs/switches.h -mv -f ../src/temp.$$.c ../src/switchinc.c - -;; -commands) - -$echo "Rebuilding command prototype file" -$echo "/* AUTOGENERATED FILE. DO NOT EDIT */" > ../hdrs/temp.$$.h -for c in `grep "^COMMAND *(" ../src/*.c | grep -v cmd_local_silly | cut -f2 -d\( | cut -f1 -d\) | sort | uniq`; do - $echo >>../hdrs/temp.$$.h "COMMAND_PROTO($c);" - $echo $n "." -done -$echo "" -cmp -s ../hdrs/cmds.h ../hdrs/temp.$$.h -cmpstat=$? -if [ $cmpstat -eq 0 ]; then - rm -f ../hdrs/temp.$$.h -else - mv -f ../hdrs/temp.$$.h ../hdrs/cmds.h -fi - -if [ -d "../win32" ]; then - cp ../hdrs/cmds.h ../win32/cmds.h -fi - -;; -functions) - -$echo "Rebuilding function prototype file" -$echo "/* AUTOGENERATED FILE. DO NOT EDIT */" > ../hdrs/temp.$$.h -for c in `grep "^FUNCTION *(" ../src/*.c | grep -v local_fun_silly | cut -f2 -d\( | cut -f1 -d\) | sort | uniq`; do - $echo >>../hdrs/temp.$$.h "FUNCTION_PROTO($c);" - $echo $n "." -done -$echo "" -cmp -s ../hdrs/funs.h ../hdrs/temp.$$.h -cmpstat=$? -if [ $cmpstat -eq 0 ]; then - rm -f ../hdrs/temp.$$.h -else - mv -f ../hdrs/temp.$$.h ../hdrs/funs.h -fi - -if [ -d "../win32" ]; then - cp ../hdrs/funs.h ../win32/funs.h -fi -;; -esac -!NO!SUBS! -chmod 755 mkcmds.sh -$eunicefix mkcmds.sh