Revision 49e7e5ee

View differences:

Makefile
1
# Makefile for the BIRD Internet Routing Daemon
2
# (c) 1998 Martin Mares <mj@ucw.cz>
3

  
4
TOPDIR=$(shell pwd)
5
OBJDIR=obj
6

  
7
CPPFLAGS=-I$(TOPDIR)/$(OBJDIR) -I$(TOPDIR)
8
OPT=-O2
9
DEBUG=-g#gdb
10
CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
11

  
12
PROTOCOLS=rip static
13
LIBDIRS=sysdep/linux sysdep/unix lib
14
BASEDIRS=nest $(addprefix proto/,$(PROTOCOLS))
15
STDDIRS=$(BASEDIRS) $(OBJDIR)/conf
16
DIRS=$(STDDIRS) $(OBJDIR)/lib
17
PARTOBJS=$(join $(addsuffix /,$(STDDIRS)),$(subst /,_,$(addsuffix .o,$(STDDIRS))))
18
LIBS=$(OBJDIR)/lib/birdlib.a
19

  
20
export
21

  
22
all: .dep all-dirs bird
23

  
24
all-dirs:
25
	set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a this ; done
26

  
27
bird: $(PARTOBJS) $(LIBS)
28
	$(CC) $(LDFLAGS) -o $@ $^
29

  
30
.dep:
31
	$(MAKE) dep
32

  
33
dep:
34
	mkdir -p $(OBJDIR)
35
	tools/mergedirs $(OBJDIR) $(LIBDIRS)
36
#	for a in $(STDDIRS) ; do mkdir -p $(OBJDIR)/$$a ; done
37
	set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a dep ; done
38
	touch .dep
39

  
40
clean:
41
	rm -rf obj
42
	rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name .depend -or -name .#*`
43
	rm -f bird .dep
44
	rm -f config.log config.cache config.status configure sysdep/autoconf.h 
Rules
1
# Makefile for the BIRD Internet Routing Daemon
2
# (c) 1998 Martin Mares <mj@ucw.cz>
3

  
4
THISDIR=$(shell pwd)
5
RELDIR=$(subst $(TOPDIR)/,,$(THISDIR))
6
ONAME=$(subst /,_,$(RELDIR)).o
7

  
8
ifndef SRCS
9
SRCS=$(subst .o,.c,$(OBJS))
10
endif
11

  
12
.PHONY: all this dep
13

  
14
all:
15
	@echo "Please run the top-level Makefile instead."
16
	@exit 1
17

  
18
ifdef OBJS
19

  
20
ifdef LIB
21

  
22
this: $(LIB)
23

  
24
$(LIB): $(OBJS)
25
	rm -f $(LIB)
26
	ar rcs $(LIB) $(OBJS)
27
	ranlib $(LIB)
28

  
29
else
30

  
31
this: $(ONAME)
32

  
33
$(ONAME): $(OBJS)
34
	$(LD) -r -o $(ONAME) $(OBJS)
35

  
36
endif
37

  
38
dep: $(SRCS)
39
	rm -f .depend
40
	for a in $(SRCS) ; do gcc $(CPPFLAGS) -MM $$a >>.depend ; done
41

  
42
else
43

  
44
dep:
45

  
46
endif
47

  
48
ifneq ($(wildcard .depend),)
49
include .depend
50
endif
TODO
1 1
Core
2 2
~~~~
3

  
3 4
* right usage of DBG vs. debug
4 5
* cleanup debugging calls
5 6
* logging and tracing; use appropriate log levels
conf/Makefile
1
CONFS=$(TOPDIR)/conf/confbase.Y @CONFS@$(addprefix $(TOPDIR)/,$(addsuffix /config.Y,$(BASEDIRS)))
2
OBJS=cf-parse.tab.o cf-lex.o
3
CONF=$(TOPDIR)/conf
1
source=cf-parse.tab.c cf-lex.c
2
root-rel=../
3

  
4
include ../Rules
5

  
6
conf-src=$(srcdir)/conf
7
conf-fragments=$(conf-src)/confbase.Y @CONFS@ $(addsuffix /config.Y,$(static-dir-paths))
4 8

  
5 9
ifdef DEBUG
6 10
BISON_DEBUG=-t
7 11
#FLEX_DEBUG=-d
8 12
endif
9 13

  
10
include $(TOPDIR)/Rules
11

  
12 14
cf-parse.tab.c cf-parse-tab.h: cf-parse.y
13
	bison -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y
15
	$(BISON) -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y
14 16

  
15
cf-parse.y: $(CONFS) $(CONF)/gen_parser.m4
16
	m4 -P $(CONF)/gen_parser.m4 $(CONFS) >cf-parse.y
17
cf-parse.y: $(conf-fragments) $(conf-src)/gen_parser.m4
18
	$(M4) -P $(conf-src)/gen_parser.m4 $(conf-fragments) >cf-parse.y
17 19

  
18
keywords.h: $(CONFS) $(CONF)/gen_keywords.m4
19
	m4 -P $(CONF)/gen_keywords.m4 $(CONFS) >keywords.h
20
keywords.h: $(conf-fragments) $(conf-src)/gen_keywords.m4
21
	$(M4) -P $(conf-src)/gen_keywords.m4 $(conf-fragments) >keywords.h
20 22

  
21 23
cf-lex.c: cf-lex.l
22
	flex $(FLEX_DEBUG) -sB8 -ocf-lex.c -Pcf_ cf-lex.l
24
	$(FLEX) $(FLEX_DEBUG) -sB8 -ocf-lex.c -Pcf_ cf-lex.l
23 25

  
24
dep: keywords.h
26
depend: keywords.h cf-parse.tab.c cf-lex.c
conf/cf-lex.l
24 24
  int value;
25 25
  struct keyword *next;
26 26
} keyword_list[] = {
27
#include "keywords.h"
27
#include "conf/keywords.h"
28 28
  { NULL, -1 } };
29 29

  
30 30
#define KW_HASH_SIZE 64
configure.in
10 10
AC_ARG_WITH(sysconfig,[  --with-sysconfig=FILE   use specified BIRD system configuration file])
11 11
AC_ARG_WITH(protocols,[  --with-protocols=LIST   include specified routing protocols (default: rip,static)],,[with_protocols="rip,static"])
12 12

  
13
if test "$srcdir" = . ; then
14
	# Building in current directory => create obj directory holding all objects
15
	objdir=obj
16
	mkdir -p obj
17
	srcdir_rel=..
18
	makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
19
	exedir=..
20
else
21
	# Building in separate directory
22
	objdir=.
23
	srcdir_rel=$srcdir
24
	makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
25
	exedir=.
26
fi
27
case $srcdir_rel in
28
	/*)	srcdir_rel_mf=$srcdir_rel ;;
29
	*)	srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
30
esac
31
AC_SUBST(objdir)
32
AC_SUBST(exedir)
33
AC_SUBST(srcdir_rel_mf)
34

  
13 35
AC_CANONICAL_HOST
14 36
AC_MSG_CHECKING([which OS configuration should we use])
15 37
if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
16
	case "$with_sysconfig" in *.h) ;; *) with_sysconfig="$with_sysconfig.h" ;; esac
17 38
	if test -f $with_sysconfig ; then
18
		SYSDESC=$with_sysconfig
39
		sysdesc=$with_sysconfig
19 40
	else
20
		SYSDESC=sysdep/cf/$with_sysconfig
41
		sysdesc=$srcdir/sysdep/cf/$with_sysconfig
42
		if ! test -f $sysdesc ; then
43
			sysdesc=$sysdesc.h
44
		fi
21 45
	fi
22 46
elif test -f sysconfig.h ; then
23
	SYSDESC=sysconfig
47
	sysdesc=sysconfig
24 48
else
25 49
	case "$host_os" in
26
		linux*)		SYSDESC=linux-20 ;;
50
		linux*)		sysdesc=linux-20 ;;
27 51
		*)		AC_MSG_RESULT(unknown)
28 52
				AC_MSG_ERROR([Cannot determine correct system configuration.])
29 53
				;;
30 54
		esac
31
	SYSDESC=sysdep/cf/$SYSDESC.h
55
	sysdesc=$srcdir/sysdep/cf/$sysdesc.h
32 56
fi
33
AC_MSG_RESULT($SYSDESC)
34
if ! test -f $SYSDESC ; then
57
AC_MSG_RESULT($sysdesc)
58
if ! test -f $sysdesc ; then
35 59
	AC_MSG_ERROR([The system configuration file is missing.])
36 60
fi
37
AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$SYSDESC")
61
sysname=`echo $sysdesc | sed 's/\.h$//'`
62
AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
63

  
64
AC_MSG_CHECKING([system-dependent directories])
65
sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
66
AC_MSG_RESULT($sysdep_dirs)
67
AC_SUBST(sysdep_dirs)
38 68

  
39 69
AC_MSG_CHECKING([protocols])
40 70
protocols=`echo "$with_protocols" | sed 's/,/ /g'`
......
46 76
	AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
47 77
	done
48 78
AC_MSG_RESULT(ok)
79
AC_SUBST(protocols)
49 80

  
50 81
AC_PROG_CC
51 82
if test -z "$GCC" ; then
......
82 113
fi
83 114

  
84 115
AC_CONFIG_HEADER(sysdep/autoconf.h)
85
AC_OUTPUT
116
AC_OUTPUT_COMMANDS(,[$srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs])
117
AC_OUTPUT($makefiles)
86 118

  
87 119
cat >&AC_FD_MSG <<EOF
88 120

  
89 121
BIRD was configured with the following options:
90
	System configuration:	$SYSDESC
122
	System configuration:	$sysdesc
91 123
	Debugging:		$enable_debug
92 124
	Routing protocols:	$protocols
93 125
EOF
nest/Makefile
1
THISDIR=nest
2
OBJS=rt-table.o rt-fib.o rt-attr.o proto.o iface.o rt-dev.o
1
source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c
2
root-rel=../
3
dir-name=nest
3 4

  
4 5
include ../Rules
proto/rip/Makefile
1
THISDIR=proto/rip
2
OBJS=rip.o
1
source=rip.c
2
root-rel=../../
3
dir-name=proto/rip
3 4

  
4 5
include ../../Rules
proto/static/Makefile
1
THISDIR=proto/static
2
OBJS=static.o
1
source=static.c
2
root-rel=../../
3
dir-name=proto/static
3 4

  
4 5
include ../../Rules
6

  
sysdep/cf/linux-20.h
14 14

  
15 15
/*
16 16
Link: sysdep/linux
17
Link: sysdep/unix
17 18
 */
sysdep/cf/linux-21.h
14 14

  
15 15
/*
16 16
Link: sysdep/linux
17
Link: sysdep/unix
17 18
 */
sysdep/cf/linux-v6.h
16 16

  
17 17
/*
18 18
Link: sysdep/linux
19
Link: sysdep/unix
19 20
 */
tools/Makefile-top.in
1
# Makefile for in place build of BIRD
2
# (c) 1999 Martin Mares <mj@ucw.cz>
3

  
4
objdir=@objdir@
5

  
6
all:
7
	$(MAKE) -C $(objdir) $@
8

  
9
clean:
10
	$(MAKE) -C $(objdir) clean
11
	rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name depend -or -name .#*`
12

  
13
distclean: clean
14
	rm -rf $(objdir)
15
	rm -f config.* configure sysdep/autoconf.h Makefile
tools/Makefile.in
1
# Makefile for the BIRD Internet Routing Daemon
2
# (c) 1999 Martin Mares <mj@ucw.cz>
3

  
4
include Rules
5

  
6
srcdir_abs := $(shell cd $(srcdir) ; pwd)
7

  
8
.PHONY: all subdir depend clean distclean
9

  
10
all: .dir-stamp .dep-stamp subdir $(exedir)/bird
11

  
12
subdir depend:
13
	set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done
14
	set -e ; for a in $(static-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done
15

  
16
$(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a
17
	$(CC) $(LDFLAGS) -o $@ $^
18

  
19
.dir-stamp:
20
	mkdir -p $(static-dirs)
21
	touch .dir-stamp
22

  
23
.dep-stamp:
24
	$(MAKE) depend
25
	touch .dep-stamp
26

  
27
clean:
28
	rm -f `find . -name "*.[oa]" -or -name core -or -name depend`
29
	rm -f $(exedir)/bird .dep-stamp
30

  
31
distclean: clean
32
	rm -f config.* configure sysdep/autoconf.h Makefile Rules
33
	rm -rf .dir-stamp $(clean-dirs)
tools/Rules.in
1
# Makefile fragments for the BIRD Internet Routing Daemon
2
# (c) 1999 Martin Mares <mj@ucw.cz>
3

  
4
srcdir=@srcdir_rel_mf@
5
objdir=@objdir@
6
exedir=@exedir@
7

  
8
protocols=@protocols@
9
static-dirs := nest $(addprefix proto/,$(protocols))
10
static-dir-paths := $(addprefix $(srcdir)/,$(static-dirs))
11
dynamic-dirs := lib conf
12
dynamic-dir-paths := $(dynamic-dirs)
13
dir-makefiles := $(addsuffix /Makefile,$(static-dir-paths) $(dynamic-dir-paths))
14

  
15
all-dirs:=$(static-dirs) $(dynamic-dirs)
16
clean-dirs:=$(all-dirs) proto sysdep
17
dir-objs:=$(addprefix $(objdir)/,$(all-dirs))
18

  
19
CPPFLAGS=-I$(root-rel) -I$(srcdir)
20
CFLAGS=$(CPPFLAGS) @CFLAGS@
21
CC=@CC@
22
M4=@M4@
23
BISON=@BISON@
24
FLEX=@FLEX@
25
RANLIB=@RANLIB@
26

  
27
ifdef source
28

  
29
objs := $(subst .c,.o,$(source))
30

  
31
ifdef dir-name
32
src-path := $(srcdir)/$(dir-name)/
33
endif
34

  
35
all:
36
	cd $(root-rel) && make
37

  
38
ifdef lib-dest
39

  
40
subdir: $(lib-dest)
41

  
42
$(lib-dest): $(objs)
43
	rm -f $@
44
	ar rcs $@ $^
45
	$(RANLIB) $@
46

  
47
else
48

  
49
subdir: all.o
50

  
51
all.o: $(objs)
52
	$(LD) -r -o $@ $^
53

  
54
endif
55

  
56
%.o: $(src-path)%.c
57
	$(CC) $(CFLAGS) -o $@ -c $^
58

  
59
depend:
60
	gcc $(CPPFLAGS) -MM $(addprefix $(src-path),$(source)) >depend
61

  
62
ifneq ($(wildcard .depend),)
63
include .depend
64
endif
65

  
66
endif
tools/mergedirs
1 1
#!/bin/sh
2 2

  
3
if [ -z "$2" ] ; then
4
	echo "Usage: mergedirs <obj-dir> <list-of-dirs>"
3
if [ -z "$4" ] ; then
4
	echo "Usage: mergedirs <src-dir> <src-dir-rel> <obj-dir> <list-of-dirs>"
5 5
	exit 1
6 6
	fi
7
TOPDIR=`pwd`
7
SRCDIR=$1
8
shift
9
SRCREL=$1
10
case $SRCDIR in
11
	/*) ;;
12
	*) SRCREL="../$SRCREL" ;;
13
	esac
14
shift
8 15
OBJDIR=$1
9 16
LIBDIR=$OBJDIR/lib
10 17
CONFDIR=$OBJDIR/conf
......
12 19

  
13 20
echo "Merging system-dependent modules"
14 21
MODULES=`for a in $@ ; do
15
		sed <$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
22
		sed <$SRCDIR/$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
16 23
		done |
17 24
	sort +0 -1 -u |
18 25
	cut -d ' ' -f 2`
19 26
rm -rf $LIBDIR $CONFDIR
20 27
mkdir -p $LIBDIR $CONFDIR
21 28
for a in $MODULES ; do
22
	echo $a
23 29
	b=`basename $a`
24 30
	case $b in
25
		*.h)	ln -s $TOPDIR/$a $LIBDIR/$b
31
		*.h)	ln -s $SRCREL/$a $LIBDIR/$b
26 32
			;;
27 33
		*.c)	OBJ=`echo $b | sed 's/\.c$/\.o/'`
28 34
			OBJS="$OBJS $OBJ"
29 35
			SRCS="$SRCS \\
30
	\$(TOPDIR)/$a"
31
			ln -s $TOPDIR/$a $LIBDIR/$b
36
	$b"
37
			ln -s $SRCREL/$a $LIBDIR/$b
32 38
			;;
33
		*.Y)	CONFS="$CONFS\$(TOPDIR)/$a "
34
			ln -s $TOPDIR/$a $CONFDIR/$b
39
		*.Y)	CONFS="$CONFS\$(srcdir)/$a "
40
			ln -s $SRCREL/$a $CONFDIR/$b
35 41
			;;
36 42
		*)	echo "$b: Unknown file type"
37 43
			exit 1
......
40 46
	done
41 47

  
42 48
cat >$LIBDIR/Makefile <<EOF
43
OBJS=$OBJS
44
SRCS=$SRCS
45
LIB=birdlib.a
49
source=$SRCS
50
lib-dest=birdlib.a
51
root-rel=../
46 52

  
47
include \$(TOPDIR)/Rules
53
include ../Rules
48 54
EOF
49 55

  
50
sed <$TOPDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
51
ln -s $TOPDIR/conf/*.[chl] $CONFDIR/
56
sed <$SRCDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
57
CONFS=`cd $SRCDIR ; ls conf/*.[chl]`
58
for a in $CONFS ; do
59
	ln -s $SRCREL/$a $CONFDIR/
60
done

Also available in: Unified diff