home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / in4wjcxu / other / irc / ircd / buildm4 next >
Encoding:
Text File  |  1996-08-14  |  3.1 KB  |  85 lines

  1. #!/bin/sh
  2. # IRC - Internet Relay Chat, ircd/buildm4
  3. # Copyright (C) 1993 Darren Reed
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 1, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #
  20. # If only this was a perl script...*sigh*
  21. #
  22. IRCDDIR=$1
  23. M4=$IRCDDIR/ircd.m4
  24. /bin/rm -f $M4
  25. egrep "^#def[^P]*PATCHLEVEL" ../include/patchlevel.h | \
  26. sed -e 's/[^\"]*\"\([^\"]*\)\"/define(VERSION,\1)/' >>$M4
  27. DEBUG=`egrep "^#define[        ]*DEBUGMODE" ../include/config.h`
  28. if [ -n "$DEBUG" ] ; then
  29.     echo "define(DEBUGMODE,1)" >>$M4
  30. else
  31.     echo "undefine(DEBUGMODE)" >>$M4
  32. fi
  33. echo -n "define(HOSTNAME," >> $M4
  34. echo "`hostname`" | sed -e 's/\([a-zA-Z0-9\-]*\).*/\1)/' >> $M4
  35. echo "define(USER,$USER)" >>$M4
  36. echo -n 'define(PORT,' >>$M4
  37. PORT=`egrep '^#define[     ]*PORT[     ]*[0-9]*' ../include/config.h`
  38. echo "$PORT" | sed -e 's/[^0-9]*\([0-9]*\).*/\1)/' >> $M4
  39. echo -n 'define(PFREQ,' >>$M4
  40. PING=`egrep '^#define[     ]*PINGFREQUENCY[     ]*[0-9]*' ../include/config.h`
  41. echo "$PING" | sed -e 's/[^0-9]*\([0-9]*\).*/\1)/' >> $M4
  42. echo -n 'define(CFREQ,' >>$M4
  43. CONT=`egrep '^#define[     ]*CONNECTFREQUENCY[     ]*[0-9]*' ../include/config.h`
  44. echo "$CONT" | sed -e 's/[^0-9]*\([0-9]*\).*/\1)/' >> $M4
  45. echo -n "define(MAXSENDQ," >>$M4
  46. MAXQ=`egrep '^#define[     ]*MAXSENDQLENGTH[     ]*[0-9]*' ../include/config.h`
  47. echo "$MAXQ" | sed -e 's/[^0-9]*\([0-9]*\).*/\1)/' >> $M4
  48. echo -n "define(MAXLINKS," >>$M4
  49. MAXL=`egrep '^#define[     ]*MAXIMUM_LINKS[     ]*[0-9]* | head -1' \
  50. ../include/config.h`
  51. echo "$MAXL" | sed -e 's/[^0-9]*\([0-9]*\).*/\1)/' >> $M4
  52. DOM=`egrep '^domain' /etc/resolv.conf | \
  53. sed -e 's/^domain[     ]*\([a-zA-Z\-\.0-9]*\).*/\1/'`
  54. echo "define(DOMAIN,$DOM)" >> $M4
  55.  
  56. cat >>$M4 <<_EOF_
  57. define(CL,\`ifelse(len(\$1),0,0,\$1)')
  58. define(HOST,\$1)
  59. define(HOSTM,\$1)
  60. define(ID,*@\$1)
  61. define(PASS,\$1)
  62. define(PING,\`ifelse(len(\$1),0,PFREQ,\$1)')
  63. define(APORT,\`ifelse(len(\$1),0,PORT,\$1)')
  64. define(FREQ,\`ifelse(len(\$1),0,CFREQ,\$1)')
  65. define(SENDQ,\`ifelse(len(\$1),0,MAXSENDQ,\$1)')
  66. define(MAX,\`ifelse(len(\$1),0,MAXLINKS,\$1)')
  67. define(CPORT,\$1)
  68. define(SERV,\$1)
  69. define(ADMIN,A:\$1:\$2:\$3:\$4:\$5)
  70. define(ALLOW,N:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\`HOSTM(\$4)':\`CL(\$5)')
  71. define(BAN,K:\$1:\$2:\$3)
  72. define(CLASS,Y:\$1:\`PING(\$2)':\$3:\`MAX(\$4)':\`SENDQ(\$5)')
  73. define(CLIENT,I:\`HOST(\$1)':\`PASS(\$2)':\`ifelse(len(HOST(\$3)),0,\$1,\$3)':\
  74. \`APORT(\$4)':\`CL(\$5)')
  75. define(CONNECT,C:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\
  76. \`CPORT(\$4)':\`CL(\$5)')
  77. define(ME,M:\$1:\$2:\$3:\$4:\$5)
  78. define(HUB,H:\`ifelse(len(\$2),0,*,\$2)':*:\$1)
  79. define(LEAF,L:\`ifelse(len(\$2),0,*,\$2)':*:\$1:1)
  80. define(SERVER,\`
  81. CONNECT(\$1,\$2,\$3,\$5,\$6)
  82. ALLOW(\$1,\$2,\$3,\$4,\$6)
  83. ')
  84. _EOF_
  85.