Netd (Part 2 of 2)
ry at cadre.UUCP
ry at cadre.UUCP
Sun Feb 3 20:10:14 AEST 1985
echo x - daemons.5l.man
cat > daemons.5l.man << '!Magic!Token!'
.TH DAEMONS 5l "15 January 1985"
.CA 4
.SH NAME
daemons \- netd daemon data base
.SH DESCRIPTION
The
.I daemons
file contains information regarding
the known services which are handled
by the
.I netd
server.
For each service a single line should be present
with the following information:
.HP 10
official service name
.br
.ns
.HP 10
socket type
.br
.ns
.HP 10
address family
.br
.ns
.HP 10
protocol family
.br
.ns
.HP 10
address
.br
.ns
.HP 10
user
.br
.ns
.HP 10
group
.br
.ns
.HP 10
nice
.br
.ns
.HP 10
log file name
.br
.ns
.HP 10
program
.br
.ns
.HP 10
optional arguments
.br
.PP
The
.I service name
is a unique name for the service.
.I Socket type
,
.I address family
, and
.I protocol family
are used when creating
socket for service.
The
.I address
differs depending on
.I address family
and
.I socket type.
It can be given as a '-' when an address is not needed.
Both the
.I user
and
.I group
can be short integers or names such as found in
/etc/passwd or /etc/group or a '-' which uses translates to programs
ownership and group membership
and determine the actual
.B uid
and
.B gid
under which the program will
be executed.
.I Nice
is the integer nice ( see
.I setpriority(2)
) value at which the program will be executed.
The
.I log file
may also be specified as a '-' for /dev/null, an '+' to append
.I
netd's
log file, or may contain a '$' which will have the service name
substituted for it.
An '@' in the optional arguments is substituted with the address to which the
socket is bound, in printable form.
.SH EXAMPLES
.PP
Here are a few lines from a sample configuration file:
.PP
.nf
.na
.ta 0.5i
# INTERNET SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
exec stream inet unspec *.exec root daemon 0 - rexecd @
login stream inet unspec *.login root daemon 0 - rlogind @
syslog dgram inet unspec *.syslog root daemon 0 $.log syslog
.fi
.ad
.SH FILES
%CONFFILE
.SH "SEE ALSO"
netd(8l), passwd(5), group(5), services(5)
.SH AUTHOR
Russell J. Yount
.SH BUGS
!Magic!Token!
echo x - netd.8l.man
cat > netd.8l.man << '!Magic!Token!'
.TH NETD 8L "8 January 1985"
.CA 4
.SH NAME
netd \- network daemon server
.SH SYNOPSIS
.B netd
[
.B \-extsn
] [
.B \-l
.I logfile
] [
.B \-m
.I logdir
]
.br
.B netd
[
.B \-d
.I execdir
] [
.B \-c
.I conffile
] [
.B \-p
.I logname
]
.br
.SH DESCRIPTION
.I Netd
is a generic daemon server through which specific
service daemons are invoked as needed. Incoming requests for
service are intercepted by
.I netd
which creates a process and passes the appropriate parameters to
that process.
One or more
.I netd's
are started by either
.I /etc/rc
or
.I /etc/rc.local
at boot time.
.I Netd
reads a configuration file (the default is
.I /etc/deamons
) to determine the priority, process and user groups, and
logs activity of the specific service invoked.
Programs started by
.I netd
will have stdin and stdout attached to the socket and stderr attached to
the service's logfile. In its environment,
the variable
.B DISC
will be set to the services
.I netd
discipline and
.B ADDR
will be set to the address of the socket.
.PP
When
.I netd
receives a SIGHUP signal it rereads the configuration file
and reconfigures.
When
.I Netd
receives a SIGTERM signal it exits.
.PP
The following options are available.
.IP \-c
specify configuration file
.IP \-d
specify server directory
.IP \-e
log to
.I stderr
.IP \-l
specify log file name
.IP \-m
specify log file directory
.IP \-n
do not date logfile entries
.IP \-p
specify program name to use in logging (default is %NAME)
.IP \-s
locking appends to logfile
.IP \-t
keep tty association
.IP \-x
turn on debugging information (option only available
when selected at compile time)
.PP
.SH FILES
.br
%CONFFILE - default configuration file
.br
%EXECDIR - default server directory
.br
%LOGDIR - default log directory
.br
%LOGFILE - default log file
.SH "SEE ALSO"
rc(4), daemons(5)
.SH AUTHOR
Russell J. Yount
.SH FEATURES
Each
.I netd
has a limit of about 18 services each due to
limits on number of open file descriptors. Only a small number
of arguments may be specified in the configuration file, to increase
this number
.I netd
must be recompiled.
.SH BUGS
.I
Netd
may fail to reconfigure properly when SIGHUP
is receive if there are active datagram services
that ignore SIGTERM. This is a temporary problem
and is corrected by next SIGHUP received after
active datagram service exits.
!Magic!Token!
echo x - EXAMPLE.dms
cat > EXAMPLE.dms << '!Magic!Token!'
#
# EXAMPLE NETD DAEMONS CONFIGURATION FILE
#
#
# Format of daemons file is as follows, one per line
#
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# where
# NAME is a unique service name
# TYPE is the socket type used
# AF is the socket address family used
# PF is the socket protocol family used or unspec
# ADDRESS differs with AF or can left a - if unused
# UID is the username or user-id the program will execute as
# GID is the groupname or group-id the program will execute as
# NICE is nice level the progam will execute at
# LOG will be stderr of program, may be either - for /dev/null,
# + to append to netd's logfile or a filename, if the filename
# contains a $ the $ will be expanded to be the services name
# PROGRAM is the program name and arguments, any @ argument will
# be expanded to be the connected address. The is a compile
# time limit on number of arguments.
#
#
#
#
# INTERNET SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
ftp stream inet unspec *.ftp root daemon 0 - ftpd @
telnet stream inet unspec *.telnet root daemon 0 - telnetd @
exec stream inet unspec *.exec root daemon 0 - rexecd @
login stream inet unspec *.login root daemon 0 - rlogind @
shell stream inet unspec *.shell root daemon 0 - rshd @
printer stream inet unspec *.printer root daemon 0 - lpd @
rfile stream inet unspec *.rfile root daemon 0 $.log rfiled
daytime stream inet unspec *.daytime root daemon 0 - daytimed
talk dgram inet unspec *.talk root daemon 0 - talkd
comsat dgram inet unspec *.biff root daemon 0 - comsat
syslog dgram inet unspec *.syslog root daemon 0 $.log syslog
echo dgram inet unspec *.echo root daemon 0 $.log echod
# time stream inet unspec *.time root daemon 0 $.log timed
# sink dgram inet unspec *.sink root daemon 0 $.log sinkd
#
# UNIX SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
lpd stream unix unspec /dev/printer root daemon 0 - lpd @
#
# PERQ SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
xtime raw xnet 1792 - root daemon 0 - xtimed
xftp raw xnet 256 - root daemon 0 $.log xftpd
#
# DEVELOPMENT SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
# xxxx raw inet unspec *.780 xxxx xxxxxx 0 - xxxx
# yyyy raw inet unspec - yyyy yyyyyy 0 - yyyy
#
#
!Magic!Token!
echo x - cadre.dms
cat > cadre.dms << '!Magic!Token!'
#
# NETD CONFIGURATION FILE FOR CADRE.ARPA
#
#
# INTERNET SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
ftp stream inet unspec *.ftp root daemon 0 - ftpd @
telnet stream inet unspec *.telnet root daemon 0 - telnetd @
exec stream inet unspec *.exec root daemon 0 - rexecd @
login stream inet unspec *.login root daemon 0 - rlogind @
shell stream inet unspec *.shell root daemon 0 - rshd @
printer stream inet unspec *.printer root daemon 4 - lpd @
rfile stream inet unspec *.rfile root daemon 0 - rfiled
daytime stream inet unspec *.daytime root daemon 0 - daytimed
finger stream inet unspec *.finger root daemon 0 - fingerd
talk dgram inet unspec *.talk root daemon 0 - talkd
comsat dgram inet unspec *.biff root daemon 0 - comsat
syslog dgram inet unspec *.syslog root daemon 0 $.log syslog
echo dgram inet unspec *.echo root daemon 0 $.log echod
sink dgram inet unspec *.sink root daemon 0 $.log sinkd
clock dgram inet unspec *.clock root daemon 0 $.log clockd
#
# UNIX SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
lpd stream unix unspec /dev/printer root daemon 4 - lpd @
#
# PERQ SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
xtime raw xnet 1792 - root daemon 0 - xtimed
xftp raw xnet 256 - root daemon 0 $.log xftpd
#
!Magic!Token!
echo x - prodigal.dms
cat > prodigal.dms << '!Magic!Token!'
#
# NETD CONFIGURATION FILE FOR PRODIGAL.ARPA
#
#
# INTERNET SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
ftp stream inet unspec *.ftp root daemon 0 - ftpd @
telnet stream inet unspec *.telnet root daemon 0 - telnetd @
exec stream inet unspec *.exec root daemon 0 - rexecd @
login stream inet unspec *.login root daemon 0 - rlogind @
shell stream inet unspec *.shell root daemon 0 - rshd @
printer stream inet unspec *.printer root daemon 0 - lpd @
rfile stream inet unspec *.rfile root daemon 0 - rfiled
daytime stream inet unspec *.daytime root daemon 0 - daytimed
finger stream inet unspec *.finger root daemon 0 - fingerd
talk dgram inet unspec *.talk root daemon 0 - talkd
comsat dgram inet unspec *.biff root daemon 0 - comsat
syslog dgram inet unspec *.syslog root daemon 0 $.log syslog
echo dgram inet unspec *.echo root daemon 0 $.log echod
sink dgram inet unspec *.sink root daemon 0 $.log sinkd
clock dgram inet unspec *.clock root daemon 0 $.log clockd
#
# UNIX SERVICES
# NAME TYPE AF PF ADDRESS UID GID NICE LOG PROGRAM
# ---- ------ ---- ------ ------- --- --- ---- --- -------
lpd stream unix unspec /dev/printer root daemon 0 - lpd @
#
!Magic!Token!
echo x - INSTALL.doc
cat > INSTALL.doc << '!Magic!Token!'
INSTALLATION:
Look at the Makefile, it installs 4 files:
/usr/man/manl/netd.8l - the manual entry for netd
/usr/lib/libnd.a - library used to compile servers
/etc/netd - the daemon program
/etc/daemons - the configuration for your site
also creating a directory (if it does not exist):
/usr/lib/netd - where server programs reside
If these paths do not agree with your tastes:
Edit the Makefile. It has four sections to it.
The middle section is altered by "make make" and
the tail end is created by "make depend". It will
create backup copies of itself when "make or depend" is used.
Type "make depend" followed by "make".
The file EXAMPLE.dms shows a typical configuration.
Copy it to a file with your site name and the extension ".dms",
editing it as appropriate.
Nroff the file netd.8l if you want for more information.
Type "make install"
You should now compile the server programs and install them
on /usr/lib/netd (or whatever you changed it to be)
REMEMBER: to terminate daemons netd will now replace!
Execute /etc/netd as root and check its logfile.
The file RC.doc has the lines that should be added to either
/etc/rc.local or /etc/rc to startup netd at boot time.
!Magic!Token!
echo x - RC.doc
cat > RC.doc << '!Magic!Token!'
if [ -f /etc/netd ]; then
/etc/netd
fi
!Magic!Token!
echo x - README
cat > README << '!Magic!Token!'
NETD - Network Service Daemon, Version 1.0, Jan 24, 1985
Copyright (c) 1985, Russell J. Yount, All rights reserved.
Permission for distribution is granted provided no direct commercial
advantage is gained and that this copyright notice and authors address
appears on all copies.
Netd is a network server, it listens at mutiple
network addresses for either datagrams or connects and then
fires up the appropriate programs attached to the socket.
Read the file INSTALL.doc for netd installation instructions.
The file SERVER.doc should shed some light on servers use/creation.
Russ
Russell J. Yount
(412) 624-3490
Decision Systems Laboratory, University of Pittsburgh
ry at cadre.arpa
{decvax!idis,mi-cec,pitt,vax135,akgua,cmcl2,sun}!cadre!ry
!Magic!Token!
echo x - SERVER.doc
cat > SERVER.doc << '!Magic!Token!'
NETD SERVERS NOTES
Server execution by netd:
Executed with uid/gid/nice as set in configuration file.
Working directory is same as servers directory.
No tty association normally, this can be altered with command options.
Stdin and stdout is attached to socket.
Stderr is attached to logfile which may be /dev/null.
All other descriptors are closed.
The programs environment contains only variables
"ADDR" and "DISC" as set by netd.
The library libnd.a contains a main which uses the
environment variable ADDR to get any address passed to it.
It then calls doit() passing argc,argv from main along with
a the sockets address and address length. (See libmain.c)
There may be multiple server programs executing on a connection oriented
services, but only one on a connectionless services. In either case it is
the server process itself which must terminate itself, not netd.
Connectionless services that are activated in burstes shoud likely
wait around a while before exiting to be sure their really finished.
WARNING:
WHEN DEBUGING CONNECTIONLESS SERVICES,
IF YOUR SERVICE NEVER READS INCOMING DATA
BEFORE EXITING YOU WILL GET A VERY HIGH
LOAD AVERAGE DUE TO NETD'S REPEATED EXEC'S
OF SERVER.
!Magic!Token!
echo x - XNET.doc
cat > XNET.doc << '!Magic!Token!'
Unfinished 10Mbs ethernet at dsl, used to talk with perq workstations.
Addresses are funny. Should finished route and bind problems.
Completely #ifdef AF_XNET so as to still compile without kernel modes.
!Magic!Token!
echo x - daemon.h
cat > daemon.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/daemon.h, Jan 19 23:47:41 1985 */
#define D_ZOMBIE 01
#define D_ACTIVE 02
typedef struct _d Daemon;
struct _d {
Daemon *succ, *pred;
Service *service;
Disc *disc;
int fd;
int flags;
int refer;
};
!Magic!Token!
echo x - disc.h
cat > disc.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/disc.h, Jan 19 23:47:45 1985 */
#define DISC_WILD -1
typedef int (*Func)();
typedef struct {
int type;
int af;
int pf;
Func startup;
Func shutdown;
}
Disc;
Disc *DiscLookUp();
!Magic!Token!
echo x - disc2.h
cat > disc2.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/disc2.h, Jan 19 23:47:49 1985 */
Table TableType[];
Table TableAF[];
Table TablePF[];
!Magic!Token!
echo x - image.h
cat > image.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/image.h, Jan 19 23:47:52 1985 */
typedef struct {
int length;
char *pointer;
char buffer[1]; /* variable length */
}
Image;
Image *OpenImage();
!Magic!Token!
echo x - service.h
cat > service.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/service.h, Jan 19 23:47:56 1985 */
#define MINFLDS 10
#define NARGS 4
#define MAXFLDS ( MINFLDS + NARGS - 1 )
typedef struct {
char *name;
int af, pf, type;
struct sockaddr addr;
int addrlen;
short uid, gid, nice;
char *prog;
char *args[ NARGS ];
char *log;
char strings[ 100 ];
}
Service;
Service *MakeService();
!Magic!Token!
echo x - syserr.h
cat > syserr.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/syserr.h, Jan 19 23:48:00 1985 */
extern int errno;
extern char *sys_errlist[];
extern int sys_nerr;
#define syserror ((errno >= sys_nerr) ? "unknown" : sys_errlist[ errno ])
!Magic!Token!
echo x - table.h
cat > table.h << '!Magic!Token!'
/* netd 1.0, /usr/src/net.dsl/netd/table.h, Jan 19 23:48:03 1985 */
typedef struct {
char *name;
int value;
}
Table;
!Magic!Token!
echo x - Makefile
cat > Makefile << '!Magic!Token!'
### BEGIN HEADER, DO NOT REMOVE THIS LINE
# netd 1.0, /usr/src/net.dsl/Makefile, Jan 19 23:47:50 1985
#
# Our Name
MAKEFILE=Makefile
#
# Where we belong
BIN=${DEST}/usr/local
ETC=${DEST}/etc
LIB=${DEST}/usr/lib
ADM=${DEST}/usr/adm
MAN=${DEST}/usr/man
#
# Owner of all installed files
OWNER=network
GROUP=daemon
#
#
# Complete list of source files, broken in two for usenet pdp-11's (>64K)
SOURCE1= ${CFILES} ${SFILES} ${YFILES} ${LFILES}
SOURCE2= ${MFILES} ${XFILES} ${DFILES} ${HFILES} ${MAKEFILE}
#
# CC and LD options
# for debugging use
# LDFLAGS=-g
# CCFLAGS=-g -DDEBUG -DNAME......
#
INCLUDE=.
LDFLAGS=-s
CCFLAGS=-O \
-DNAME='"${NAME}"' -DLOGDIR='"${LOGDIR}"' \
-DEXECDIR='"${EXECDIR}"' -DLOGFILE='"${LOGFILE}"' \
-DCONFFILE='"${CONFFILE}"' -DNAME='"${NAME}"'
#
# Where to tar sources
TARDEV=netd.tar
SHAR=netd.shar
MAGIC='!Magic!Token!'
#
# Package defaults
NAME=netd
CONFFILE= ${ETC}/daemons
LOGFILE= netd.log
LOGDIR= ${ADM}
EXECDIR= ${LIB}/netd
#
#
# The Section below following line is created by "make make"
### END HEADER, DO NOT REMOVE THIS LINE
CFILES= addr.c addr2.c addr3.c addr4.c conf.c daemon.c dgram.c disc.c disc2.c image.c init.c libmain.c main.c mplx.c option.c proc.c raw.c service.c stream.c table.c xnet.c
HFILES= daemon.h disc.h disc2.h image.h service.h syserr.h table.h
LFILES=
YFILES=
DFILES= INSTALL.doc RC.doc README SERVER.doc XNET.doc
MFILES= daemons.5l.man netd.8l.man
XFILES= EXAMPLE.dms cadre.dms prodigal.dms
SFILES=
OFILES= addr.o addr2.o addr3.o addr4.o conf.o daemon.o dgram.o disc.o disc2.o image.o init.o libmain.o main.o mplx.o option.o proc.o raw.o service.o stream.o table.o xnet.o
### BEGIN BODY, DO NOT REMOVE THIS LINE
#
# Everything we will need to create
ALL= netd libnd.a netd.8l daemons.5l
OBJS1= addr.o addr2.o addr4.o conf.o daemon.o dgram.o disc.o disc2.o \
image.o init.o main.o mplx.o option.o proc.o raw.o service.o \
stream.o table.o xnet.o
OBJS2= addr3.o libmain.o
#
# How to do it
all: ${ALL}
.c.o: ; cc ${CCFLAGS} -c $*.c
# Edit manual entries to reflect installation
netd.8l: ${MFILES}
for i in ${MFILES}; do \
sed -e 's;%NAME;${NAME};' \
-e 's;%LOGDIR;${LOGDIR};' \
-e 's;%EXECDIR;${EXECDIR};' \
-e 's;%LOGFILE;${LOGFILE};' \
-e 's;%CONFFILE;${CONFFILE};' \
< $$i > `echo $$i | sed -e 's/\.man//g'` ; \
done
# the daemon
netd: ${OBJS1} ; cc ${OBJS1} ${LDFLAGS} -o netd
# the library for compiling servers
libnd.a: ${OBJS2}
ar cru libnd.a ${OBJS2}
ranlib libnd.a
#
# To be tidy?
lint:
lint ${CFILES}
@echo ignore mutiple main
# How to install it, the `hostname.dms` file must exist by now
install: netd libnd.a netd.8l
-mkdir ${EXECDIR}
chown ${OWNER} ${EXECDIR}
chgrp ${GROUP} ${EXECDIR}
chmod 755 ${EXECDIR}
install -o ${OWNER} -g ${GROUP} -m 644 -c `hostname`.dms ${CONFFILE}
-install -o ${OWNER} -g ${GROUP} -m 644 -c netd.8l ${MAN}/manl/netd.8l
-install -o ${OWNER} -g ${GROUP} -m 644 -c daemons.5l ${MAN}/manl/daemons.5l
install -o ${OWNER} -g ${GROUP} -m 644 -c libnd.a ${LIB}/libnd.a
install -o ${OWNER} -g ${GROUP} -m 755 -c netd ${ETC}/netd
ranlib ${LIB}/libnd.a
ls -gl ${LIB}/libnd.a ${ETC}/netd ${CONFFILE} \
${MAN}/manl/daemons.5l ${MAN}/manl/netd.8l
#
# Purge from system
clobber:
cd ${MAN}/manl; rm -f netd.8l
cd ${ETC}; rm -f netd daemons
cd ${LIB}; rm -f libnd.a
#
# Clean up everything
clean: ; rm -f ${OFILES} ${ALL}
#
# Clean up others
purge: ; rm -f ${TARDEV} ${SHAR}
#
# Tar all sources
tar: ${SOURCE1} ${SOURCE2}; tar cf ${TARDEV} ${SOURCE1} ${SOURCE2}
#
# Make a shar File
shar: ${SOURCE1} ${SOURCE2}
rm -f ${SHAR}.1 ${SHAR}.2
for i in ${SOURCE1}; do\
echo "echo x - $$i" >> ${SHAR}.1;\
echo "cat > $$i << ${MAGIC}" >> ${SHAR}.1;\
cat $$i >> ${SHAR}.1;\
echo ${MAGIC} >> ${SHAR}.1;\
done
for i in ${SOURCE2}; do\
echo "echo x - $$i" >> ${SHAR}.2;\
echo "cat > $$i << ${MAGIC}" >> ${SHAR}.2;\
cat $$i >> ${SHAR}.2;\
echo ${MAGIC} >> ${SHAR}.2;\
done
ls -l ${SHAR}.1 ${SHAR}.2
#
# Be carefull to save original
${MAKEFILE}.org: ; cp ${MAKEFILE} ${MAKEFILE}.org
#
# Create a new makefile after looking at file on current directory
make: ${MAKEFILE}.org
sed -n -e '/^### BEGIN HEADER/,/^### END HEADER/p' \
< ${MAKEFILE} > ${MAKEFILE}.new
echo CFILES= `ls [a-zA-Z]*.c` >> ${MAKEFILE}.new
echo HFILES= `ls [a-zA-Z]*.h` >> ${MAKEFILE}.new
echo LFILES= `ls [a-zA-Z]*.l` >> ${MAKEFILE}.new
echo YFILES= `ls [a-zA-Z]*.y` >> ${MAKEFILE}.new
echo DFILES= `ls README [a-zA-Z]*.doc` >> ${MAKEFILE}.new
echo MFILES= `ls [a-zA-Z]*.man` >> ${MAKEFILE}.new
echo XFILES= `ls [a-zA-Z]*.dms` >> ${MAKEFILE}.new
echo SFILES= `ls [a-zA-Z]*.sh` >> ${MAKEFILE}.new
echo OFILES= `ls [a-zA-Z]*.c | sed -e 's/\.c/.o/g'` >> ${MAKEFILE}.new
sed -n -e '/^### BEGIN BODY/,/^### END BODY/p' \
< ${MAKEFILE} >> ${MAKEFILE}.new
mv $(MAKEFILE) $(MAKEFILE).bak
mv $(MAKEFILE).new $(MAKEFILE)
@echo remember to '"make depend"'
# Create a dependency list for makefile
depend: ${MAKEFILE}.org
sed -n -e '1,/^### END BODY/p' < $(MAKEFILE) > $(MAKEFILE).new
-for i in $(YACCFILES) $(LEXFILES) $(CFILES) $(FFILES) ; do \
base=`expr $$i ':' '\(.*\).[cylf]$$'`; \
suffix=`expr $$i ':' '.*\.\([cylf]\)$$'`;\
if /bin/test $$suffix = l ; then\
lex $$i;\
mv lex.yy.c $$base.c;\
suffix=c;\
echo "$$base.c: $$base.l" >> $(MAKEFILE).new;\
elif /bin/test $$suffix = y ; then\
yacc $(YFLAGS) $$i;\
mv y.tab.c $$base.c;\
suffix=c;\
echo "$$base.c: $$base.y" >> $(MAKEFILE).new;\
echo "y.tab.h: $$base.y" >> $(MAKEFILE).new;\
fi;\
$(CC) $(CLOCALFLAGS) -I$(INCLUDE) -E $$base.$$suffix |\
grep '^# [0-9][0-9]* ".*"$$' > /tmp/grep$$$$;\
sed -e 's/.*"\(.*\)"$$/\1/' -e 's/^.\///' < /tmp/grep$$$$ |\
sort -u |\
awk\
"BEGIN { line=\"$$base.o: \"}\
{\
if(length(line \$$0)>63)\
{\
print line,\"\\\\\";\
line=\" \"\$$0\
}\
else\
line=line\" \"\$$0\
}\
END { print line}"\
>> $(MAKEFILE).new;\
done;\
rm /tmp/grep$$$$
mv $(MAKEFILE) $(MAKEFILE).bak
mv $(MAKEFILE).new $(MAKEFILE)
#
# The section below following line is created by "make depend"
### END BODY, DO NOT REMOVE THIS LINE
!Magic!Token!
More information about the Comp.sources.unix
mailing list