1#! /bin/sh 2# IRC - Internet Relay Chat, ircd/buildm4 3# Copyright (C) 1993, 1994 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# $Id: buildm4,v 1.12 2002/05/19 22:46:42 jv Exp $ 20# 21 22# 23# If only this was a perl script...*sigh* 24# 25INCLUDE=`../support/config.guess` 26# Installation with absolute path now (Kratz) 27M4=$1 28/bin/rm -f $M4 29egrep "^#def[^P]*PATCHLEVEL" ../common/patchlevel.h | \ 30sed -e 's/[^\"]*\"\([^\"]*\)\"/define(VERSION,\1)/' >>$M4 31DEBUG=`egrep "^#define[ ]*DEBUGMODE" config.h` 32if [ -n "$DEBUG" ] ; then 33 echo "define(DEBUGMODE,1)" >>$M4 34else 35 echo "undefine(DEBUGMODE)" >>$M4 36fi 37HOST="`hostname | sed -e 's/\([a-zA-Z0-9\-]*\).*/\1/'`" 38echo "define(HOSTNAME,$HOST)" >> $M4 39 40echo "define(USER,$USER)" >>$M4 41 42PORT=`egrep '^#define[ ]*PORT[ ]*[0-9]*' ../$INCLUDE/config.h | \ 43 sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` 44echo "define(PORT,$PORT)" >> $M4 45 46PING=`egrep '^#define[ ]*PINGFREQUENCY[ ]*[0-9]*' ../$INCLUDE/config.h\ 47 | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` 48echo "define(PFREQ,$PING)" >> $M4 49 50CONT=`egrep '^#define[ ]*CONNECTFREQUENCY[ ]*[0-9]*' ../$INCLUDE/config.h\ 51 | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` 52echo "define(CFREQ,$CONT)" >> $M4 53 54MAXL=`egrep '^#define[ ]*MAXIMUM_LINKS[ ]*[0-9]* | head -1' \ 55 ../$INCLUDE/config.h | sed -e 's/[^0-9]*\([0-9]*\).*/\1/'` 56echo "define(MAXLINKS,$MAXL)" >> $M4 57 58DOM=`egrep '^domain' /etc/resolv.conf | \ 59 sed -e 's/^domain[ ]*\([^ ]*\).*/\1/'` 60echo "define(DOMAIN,$DOM)" >> $M4 61 62cat >>$M4 <<_EOF_ 63define(CL,\`ifelse(len(\$1),0,0,\$1)') 64define(MAXSENDQ,0) 65define(HOST,\$1) 66define(HOSTM,\$1) 67define(ID,*@\$1) 68define(PASS,\$1) 69define(PING,\`ifelse(len(\$1),0,PFREQ,\$1)') 70define(APORT,\`ifelse(len(\$1),0,PORT,\$1)') 71define(FREQ,\`ifelse(len(\$1),0,CFREQ,\$1)') 72define(SENDQ,\`ifelse(len(\$1),0,MAXSENDQ,\$1)') 73define(MAX,\`ifelse(len(\$1),0,MAXLINKS,\$1)') 74define(UID,\`ifelse(len(\$1),0,unknown,\$1)') 75define(CPORT,\$1) 76define(SERV,\$1) 77define(ADMIN,A:\$1:\$2:\$3:\$4:\$5) 78define(ALLOW,N:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\`HOSTM(\$4)':\`CL(\$5)') 79define(BAN,K:\$1:\$2:\$3:\$4:) 80define(BANIDENT,k:\$1:\$2:\`UID(\$3)':\$4:) 81define(CLASS,Y:\$1:\`PING(\$2)':\$3:\`MAX(\$4)':\`SENDQ(\$5)':\$6:\$7) 82define(CLIENT,I:\`HOST(\$1)':\`PASS(\$2)':\`ifelse(len(HOST(\$3)),0,\$1,\$3)':\ 83\`APORT(\$4)':\`CL(\$5)') 84define(RESTRICTED,i:\`HOST(\$1)':\`PASS(\$2)':\ 85\`ifelse(len(HOST(\$3)),0,\$1,\$3)':\`APORT(\$4)':\`CL(\$5)') 86define(BOUNCE,B:\$1::\$2:\$3:) 87define(CONNECT,C:\`HOST(\$1)':\`PASS(\$2)':\`SERV(\$3)':\ 88\`CPORT(\$4)':\`CL(\$5)') 89define(EXCLUDEVERSION,V:\$1:\$2:\`ifelse(len(\$3),0,*,\$3)'::) 90define(ME,M:\$1:\$2:\$3:\$4:\$5 91P:\$2:*:*:\$4) 92define(HUB,H:\`ifelse(len(\$2),0,*,\$2)':*:\$1) 93define(LEAF,L:\`ifelse(len(\$2),0,*,\$2)':*:\$1:1) 94define(SERVER,\` 95CONNECT(\$1,\$2,\$3,\$5,\$6) 96ALLOW(\$1,\$2,\$3,\$4,\$6) 97') 98define(SERVICE,S:\`HOST(\$1)':\`PASS(\$2)':\$3:\`ifelse(len(\$4),0,0,\$4)':\ 99\`CL(\$5)') 100define(EXTRAPORT,P:\`ifelse(len(\$2),0,*,\$2)':*:*:\$1) 101_EOF_ 102