]> jfr.im git - irc/quakenet/newserv.git/blobdiff - chanserv/mkcommandlist.pl
ident comparision should use strcmp
[irc/quakenet/newserv.git] / chanserv / mkcommandlist.pl
index b8d6484c0d52ab686637afdce740a29558ef8f44..61432bdd80f38c35a99a3605f014f7b4d95bbd18 100755 (executable)
@@ -9,6 +9,7 @@ my @cmddesc;
 my @cmdfunc;
 my @protos;
 my @files;
+my @help;
 
 my @filelist = <*.c>;
 
@@ -21,11 +22,22 @@ unless (@ARGV) {
   $modname=$ARGV[0];
 }
 
+my $smallname;
+$smallname=$modname;
+$smallname=~s/\.so$//;
+
+my $cname;
+$cname=$smallname . ".c";
+$smallname=~s/^chanserv_//;
+
+
 for (@filelist) {
   next if (/commandlist.c/);
+  next if ($_ eq $cname);
   
   my $fname = $_;
-  my ($cn, $cl, $ca, $cd, $cf, $cp);
+  my ($cn, $cl, $ca, $cd, $cf, $cp, $ch);
+  $ch="";
 
   open INFILE,"<$fname";
   
@@ -55,6 +67,10 @@ for (@filelist) {
     if (/CMDPROTO: (.*)/) {
       $cp=$1;
     }
+    
+    if (/CMDHELP: (.*)/) {
+      $ch.=$1."\\n";
+    }
   }
   
   if (defined $cn and defined $cl and defined $ca and defined $cd and defined $cf and defined $cp) {
@@ -66,6 +82,7 @@ for (@filelist) {
     push @cmddesc, $cd;
     push @cmdfunc, $cf;
     push @protos, $cp;
+    push @help, $ch;
   } else {
     print "Warning: found source file $fname without complete tags, skipping...\n";
   }
@@ -92,14 +109,19 @@ foreach (@protos) {
 my @names2 = @cmdnames;
 my @func2 = @cmdfunc;
 
+print CL "void ".$smallname."_init(void);\n";
+print CL "void ".$smallname."_fini(void);\n\n";
+
 print CL "\nvoid _init() {\n";
+print CL "  ".$smallname."_init();\n";
 
 while (my $cn = shift @cmdnames) {
   print CL "  chanservaddcommand(\"".$cn."\", ".(shift @cmdlevels).", ".(shift @cmdargs).", ";
-  print CL (shift @cmdfunc).", \"".(shift @cmddesc)."\", \"\");\n";
+  print CL (shift @cmdfunc).", \"".(shift @cmddesc)."\", \"".(shift @help),"\");\n";
 }
 
 print CL "}\n\nvoid _fini() {\n";
+print CL "  ".$smallname."_fini();\n";
 
 while (my $cn = shift @names2) {
   print CL "  chanservremovecommand(\"".$cn."\", ".(shift @func2).");\n";
@@ -109,27 +131,21 @@ print CL "}\n";
 
 close CL;
 
-open MF,">Makefile";
-
-print MF "# Automatically generated Makefile, do not edit.\n\n";
-
-print MF ".PHONY: all Makefile\n";
+open MF,">autobuild.mk";
 
-print MF "all: Makefile $modname\n\n";
-
-print MF "Makefile:\n";
-print MF "\t../mkcommandlist.pl $modname\n";
+print MF "# Automatically generated Makefile, do not edit.\n";
 
 print MF "\n$modname: ";
 
 push @files,"commandlist.c";
 
+push @files,$cname;
+
 foreach (@files) {
   s/.c$/.o/;
   print MF "$_ ";
 }
 
 print MF "\n";
-print MF "\t ld -shared -Bdynamic -o \$\@ \$\^ \n";
 
 close MF;