summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-01-10 01:18:32 +0100
committerMartin Mares <mj@ucw.cz>1999-01-10 01:18:32 +0100
commit49e7e5ee0b2848f5bf120a962e2e7eb11b86566a (patch)
tree56e7c215f49ab59792b5cf0194fa5045a66943c7
parent2f9bcf9713523f6fefecd143cc2aa2a8dda7f27f (diff)
downloadbird-49e7e5ee0b2848f5bf120a962e2e7eb11b86566a.tar
bird-49e7e5ee0b2848f5bf120a962e2e7eb11b86566a.zip
New makefiles. Includes support for out-of-source-tree builds.
-rw-r--r--Makefile44
-rw-r--r--Rules50
-rw-r--r--TODO1
-rw-r--r--conf/Makefile26
-rw-r--r--conf/cf-lex.l2
-rw-r--r--configure.in54
-rw-r--r--nest/Makefile5
-rw-r--r--proto/rip/Makefile5
-rw-r--r--proto/static/Makefile6
-rw-r--r--sysdep/cf/linux-20.h1
-rw-r--r--sysdep/cf/linux-21.h1
-rw-r--r--sysdep/cf/linux-v6.h1
-rw-r--r--tools/Makefile-top.in15
-rw-r--r--tools/Makefile.in33
-rw-r--r--tools/Rules.in66
-rwxr-xr-xtools/mergedirs41
16 files changed, 211 insertions, 140 deletions
diff --git a/Makefile b/Makefile
deleted file mode 100644
index d2c04e6..0000000
--- a/Makefile
+++ /dev/null
@@ -1,44 +0,0 @@
-# Makefile for the BIRD Internet Routing Daemon
-# (c) 1998 Martin Mares <mj@ucw.cz>
-
-TOPDIR=$(shell pwd)
-OBJDIR=obj
-
-CPPFLAGS=-I$(TOPDIR)/$(OBJDIR) -I$(TOPDIR)
-OPT=-O2
-DEBUG=-g#gdb
-CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
-
-PROTOCOLS=rip static
-LIBDIRS=sysdep/linux sysdep/unix lib
-BASEDIRS=nest $(addprefix proto/,$(PROTOCOLS))
-STDDIRS=$(BASEDIRS) $(OBJDIR)/conf
-DIRS=$(STDDIRS) $(OBJDIR)/lib
-PARTOBJS=$(join $(addsuffix /,$(STDDIRS)),$(subst /,_,$(addsuffix .o,$(STDDIRS))))
-LIBS=$(OBJDIR)/lib/birdlib.a
-
-export
-
-all: .dep all-dirs bird
-
-all-dirs:
- set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a this ; done
-
-bird: $(PARTOBJS) $(LIBS)
- $(CC) $(LDFLAGS) -o $@ $^
-
-.dep:
- $(MAKE) dep
-
-dep:
- mkdir -p $(OBJDIR)
- tools/mergedirs $(OBJDIR) $(LIBDIRS)
-# for a in $(STDDIRS) ; do mkdir -p $(OBJDIR)/$$a ; done
- set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a dep ; done
- touch .dep
-
-clean:
- rm -rf obj
- rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name .depend -or -name .#*`
- rm -f bird .dep
- rm -f config.log config.cache config.status configure sysdep/autoconf.h
diff --git a/Rules b/Rules
deleted file mode 100644
index d038f80..0000000
--- a/Rules
+++ /dev/null
@@ -1,50 +0,0 @@
-# Makefile for the BIRD Internet Routing Daemon
-# (c) 1998 Martin Mares <mj@ucw.cz>
-
-THISDIR=$(shell pwd)
-RELDIR=$(subst $(TOPDIR)/,,$(THISDIR))
-ONAME=$(subst /,_,$(RELDIR)).o
-
-ifndef SRCS
-SRCS=$(subst .o,.c,$(OBJS))
-endif
-
-.PHONY: all this dep
-
-all:
- @echo "Please run the top-level Makefile instead."
- @exit 1
-
-ifdef OBJS
-
-ifdef LIB
-
-this: $(LIB)
-
-$(LIB): $(OBJS)
- rm -f $(LIB)
- ar rcs $(LIB) $(OBJS)
- ranlib $(LIB)
-
-else
-
-this: $(ONAME)
-
-$(ONAME): $(OBJS)
- $(LD) -r -o $(ONAME) $(OBJS)
-
-endif
-
-dep: $(SRCS)
- rm -f .depend
- for a in $(SRCS) ; do gcc $(CPPFLAGS) -MM $$a >>.depend ; done
-
-else
-
-dep:
-
-endif
-
-ifneq ($(wildcard .depend),)
-include .depend
-endif
diff --git a/TODO b/TODO
index 2d4cbab..9fbf2d5 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,6 @@
Core
~~~~
+
* right usage of DBG vs. debug
* cleanup debugging calls
* logging and tracing; use appropriate log levels
diff --git a/conf/Makefile b/conf/Makefile
index e448189..270d556 100644
--- a/conf/Makefile
+++ b/conf/Makefile
@@ -1,24 +1,26 @@
-CONFS=$(TOPDIR)/conf/confbase.Y @CONFS@$(addprefix $(TOPDIR)/,$(addsuffix /config.Y,$(BASEDIRS)))
-OBJS=cf-parse.tab.o cf-lex.o
-CONF=$(TOPDIR)/conf
+source=cf-parse.tab.c cf-lex.c
+root-rel=../
+
+include ../Rules
+
+conf-src=$(srcdir)/conf
+conf-fragments=$(conf-src)/confbase.Y @CONFS@ $(addsuffix /config.Y,$(static-dir-paths))
ifdef DEBUG
BISON_DEBUG=-t
#FLEX_DEBUG=-d
endif
-include $(TOPDIR)/Rules
-
cf-parse.tab.c cf-parse-tab.h: cf-parse.y
- bison -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y
+ $(BISON) -bcf-parse -dv -pcf_ $(BISON_DEBUG) cf-parse.y
-cf-parse.y: $(CONFS) $(CONF)/gen_parser.m4
- m4 -P $(CONF)/gen_parser.m4 $(CONFS) >cf-parse.y
+cf-parse.y: $(conf-fragments) $(conf-src)/gen_parser.m4
+ $(M4) -P $(conf-src)/gen_parser.m4 $(conf-fragments) >cf-parse.y
-keywords.h: $(CONFS) $(CONF)/gen_keywords.m4
- m4 -P $(CONF)/gen_keywords.m4 $(CONFS) >keywords.h
+keywords.h: $(conf-fragments) $(conf-src)/gen_keywords.m4
+ $(M4) -P $(conf-src)/gen_keywords.m4 $(conf-fragments) >keywords.h
cf-lex.c: cf-lex.l
- flex $(FLEX_DEBUG) -sB8 -ocf-lex.c -Pcf_ cf-lex.l
+ $(FLEX) $(FLEX_DEBUG) -sB8 -ocf-lex.c -Pcf_ cf-lex.l
-dep: keywords.h
+depend: keywords.h cf-parse.tab.c cf-lex.c
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index 9e6b120..7c37a00 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -24,7 +24,7 @@ static struct keyword {
int value;
struct keyword *next;
} keyword_list[] = {
-#include "keywords.h"
+#include "conf/keywords.h"
{ NULL, -1 } };
#define KW_HASH_SIZE 64
diff --git a/configure.in b/configure.in
index 014c83d..e2c92c7 100644
--- a/configure.in
+++ b/configure.in
@@ -10,31 +10,61 @@ AC_ARG_ENABLE(debug,[ --enable-debug enable internal debugging routine
AC_ARG_WITH(sysconfig,[ --with-sysconfig=FILE use specified BIRD system configuration file])
AC_ARG_WITH(protocols,[ --with-protocols=LIST include specified routing protocols (default: rip,static)],,[with_protocols="rip,static"])
+if test "$srcdir" = . ; then
+ # Building in current directory => create obj directory holding all objects
+ objdir=obj
+ mkdir -p obj
+ srcdir_rel=..
+ makefiles="Makefile:tools/Makefile-top.in obj/Makefile:tools/Makefile.in obj/Rules:tools/Rules.in"
+ exedir=..
+else
+ # Building in separate directory
+ objdir=.
+ srcdir_rel=$srcdir
+ makefiles="Makefile:tools/Makefile.in Rules:tools/Rules.in"
+ exedir=.
+fi
+case $srcdir_rel in
+ /*) srcdir_rel_mf=$srcdir_rel ;;
+ *) srcdir_rel_mf="\$(root-rel)$srcdir_rel" ;;
+esac
+AC_SUBST(objdir)
+AC_SUBST(exedir)
+AC_SUBST(srcdir_rel_mf)
+
AC_CANONICAL_HOST
AC_MSG_CHECKING([which OS configuration should we use])
if test -n "$with_sysconfig" -a "$with_sysconfig" != no ; then
- case "$with_sysconfig" in *.h) ;; *) with_sysconfig="$with_sysconfig.h" ;; esac
if test -f $with_sysconfig ; then
- SYSDESC=$with_sysconfig
+ sysdesc=$with_sysconfig
else
- SYSDESC=sysdep/cf/$with_sysconfig
+ sysdesc=$srcdir/sysdep/cf/$with_sysconfig
+ if ! test -f $sysdesc ; then
+ sysdesc=$sysdesc.h
+ fi
fi
elif test -f sysconfig.h ; then
- SYSDESC=sysconfig
+ sysdesc=sysconfig
else
case "$host_os" in
- linux*) SYSDESC=linux-20 ;;
+ linux*) sysdesc=linux-20 ;;
*) AC_MSG_RESULT(unknown)
AC_MSG_ERROR([Cannot determine correct system configuration.])
;;
esac
- SYSDESC=sysdep/cf/$SYSDESC.h
+ sysdesc=$srcdir/sysdep/cf/$sysdesc.h
fi
-AC_MSG_RESULT($SYSDESC)
-if ! test -f $SYSDESC ; then
+AC_MSG_RESULT($sysdesc)
+if ! test -f $sysdesc ; then
AC_MSG_ERROR([The system configuration file is missing.])
fi
-AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$SYSDESC")
+sysname=`echo $sysdesc | sed 's/\.h$//'`
+AC_DEFINE_UNQUOTED(SYSCONF_INCLUDE, "$sysdesc")
+
+AC_MSG_CHECKING([system-dependent directories])
+sysdep_dirs="`sed <$sysdesc '/^Link: /!d;s/^Link: \(.*\)$/\1/' | tr '\012' ' '` lib"
+AC_MSG_RESULT($sysdep_dirs)
+AC_SUBST(sysdep_dirs)
AC_MSG_CHECKING([protocols])
protocols=`echo "$with_protocols" | sed 's/,/ /g'`
@@ -46,6 +76,7 @@ for a in $protocols ; do
AC_DEFINE_UNQUOTED(CONFIG_`echo $a | tr 'a-z' 'A-Z'`)
done
AC_MSG_RESULT(ok)
+AC_SUBST(protocols)
AC_PROG_CC
if test -z "$GCC" ; then
@@ -82,12 +113,13 @@ else
fi
AC_CONFIG_HEADER(sysdep/autoconf.h)
-AC_OUTPUT
+AC_OUTPUT_COMMANDS(,[$srcdir/tools/mergedirs $srcdir $srcdir_rel $objdir $sysdep_dirs])
+AC_OUTPUT($makefiles)
cat >&AC_FD_MSG <<EOF
BIRD was configured with the following options:
- System configuration: $SYSDESC
+ System configuration: $sysdesc
Debugging: $enable_debug
Routing protocols: $protocols
EOF
diff --git a/nest/Makefile b/nest/Makefile
index 3990a89..46bcd17 100644
--- a/nest/Makefile
+++ b/nest/Makefile
@@ -1,4 +1,5 @@
-THISDIR=nest
-OBJS=rt-table.o rt-fib.o rt-attr.o proto.o iface.o rt-dev.o
+source=rt-table.c rt-fib.c rt-attr.c proto.c iface.c rt-dev.c
+root-rel=../
+dir-name=nest
include ../Rules
diff --git a/proto/rip/Makefile b/proto/rip/Makefile
index 0555c38..16bfe0f 100644
--- a/proto/rip/Makefile
+++ b/proto/rip/Makefile
@@ -1,4 +1,5 @@
-THISDIR=proto/rip
-OBJS=rip.o
+source=rip.c
+root-rel=../../
+dir-name=proto/rip
include ../../Rules
diff --git a/proto/static/Makefile b/proto/static/Makefile
index 7771c2f..61fadbe 100644
--- a/proto/static/Makefile
+++ b/proto/static/Makefile
@@ -1,4 +1,6 @@
-THISDIR=proto/static
-OBJS=static.o
+source=static.c
+root-rel=../../
+dir-name=proto/static
include ../../Rules
+
diff --git a/sysdep/cf/linux-20.h b/sysdep/cf/linux-20.h
index 8c06c76..807ddcd 100644
--- a/sysdep/cf/linux-20.h
+++ b/sysdep/cf/linux-20.h
@@ -14,4 +14,5 @@
/*
Link: sysdep/linux
+Link: sysdep/unix
*/
diff --git a/sysdep/cf/linux-21.h b/sysdep/cf/linux-21.h
index 4883abd..a88d0ad 100644
--- a/sysdep/cf/linux-21.h
+++ b/sysdep/cf/linux-21.h
@@ -14,4 +14,5 @@
/*
Link: sysdep/linux
+Link: sysdep/unix
*/
diff --git a/sysdep/cf/linux-v6.h b/sysdep/cf/linux-v6.h
index d4611e6..c381e38 100644
--- a/sysdep/cf/linux-v6.h
+++ b/sysdep/cf/linux-v6.h
@@ -16,4 +16,5 @@
/*
Link: sysdep/linux
+Link: sysdep/unix
*/
diff --git a/tools/Makefile-top.in b/tools/Makefile-top.in
new file mode 100644
index 0000000..0b201a5
--- /dev/null
+++ b/tools/Makefile-top.in
@@ -0,0 +1,15 @@
+# Makefile for in place build of BIRD
+# (c) 1999 Martin Mares <mj@ucw.cz>
+
+objdir=@objdir@
+
+all:
+ $(MAKE) -C $(objdir) $@
+
+clean:
+ $(MAKE) -C $(objdir) clean
+ rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core -or -name depend -or -name .#*`
+
+distclean: clean
+ rm -rf $(objdir)
+ rm -f config.* configure sysdep/autoconf.h Makefile
diff --git a/tools/Makefile.in b/tools/Makefile.in
new file mode 100644
index 0000000..246872c
--- /dev/null
+++ b/tools/Makefile.in
@@ -0,0 +1,33 @@
+# Makefile for the BIRD Internet Routing Daemon
+# (c) 1999 Martin Mares <mj@ucw.cz>
+
+include Rules
+
+srcdir_abs := $(shell cd $(srcdir) ; pwd)
+
+.PHONY: all subdir depend clean distclean
+
+all: .dir-stamp .dep-stamp subdir $(exedir)/bird
+
+subdir depend:
+ set -e ; for a in $(dynamic-dirs) ; do $(MAKE) -C $$a $@ ; done
+ set -e ; for a in $(static-dirs) ; do $(MAKE) -C $$a -f $(srcdir_abs)/$$a/Makefile $@ ; done
+
+$(exedir)/bird: $(addsuffix /all.o, $(static-dirs)) conf/all.o lib/birdlib.a
+ $(CC) $(LDFLAGS) -o $@ $^
+
+.dir-stamp:
+ mkdir -p $(static-dirs)
+ touch .dir-stamp
+
+.dep-stamp:
+ $(MAKE) depend
+ touch .dep-stamp
+
+clean:
+ rm -f `find . -name "*.[oa]" -or -name core -or -name depend`
+ rm -f $(exedir)/bird .dep-stamp
+
+distclean: clean
+ rm -f config.* configure sysdep/autoconf.h Makefile Rules
+ rm -rf .dir-stamp $(clean-dirs)
diff --git a/tools/Rules.in b/tools/Rules.in
new file mode 100644
index 0000000..56c0903
--- /dev/null
+++ b/tools/Rules.in
@@ -0,0 +1,66 @@
+# Makefile fragments for the BIRD Internet Routing Daemon
+# (c) 1999 Martin Mares <mj@ucw.cz>
+
+srcdir=@srcdir_rel_mf@
+objdir=@objdir@
+exedir=@exedir@
+
+protocols=@protocols@
+static-dirs := nest $(addprefix proto/,$(protocols))
+static-dir-paths := $(addprefix $(srcdir)/,$(static-dirs))
+dynamic-dirs := lib conf
+dynamic-dir-paths := $(dynamic-dirs)
+dir-makefiles := $(addsuffix /Makefile,$(static-dir-paths) $(dynamic-dir-paths))
+
+all-dirs:=$(static-dirs) $(dynamic-dirs)
+clean-dirs:=$(all-dirs) proto sysdep
+dir-objs:=$(addprefix $(objdir)/,$(all-dirs))
+
+CPPFLAGS=-I$(root-rel) -I$(srcdir)
+CFLAGS=$(CPPFLAGS) @CFLAGS@
+CC=@CC@
+M4=@M4@
+BISON=@BISON@
+FLEX=@FLEX@
+RANLIB=@RANLIB@
+
+ifdef source
+
+objs := $(subst .c,.o,$(source))
+
+ifdef dir-name
+src-path := $(srcdir)/$(dir-name)/
+endif
+
+all:
+ cd $(root-rel) && make
+
+ifdef lib-dest
+
+subdir: $(lib-dest)
+
+$(lib-dest): $(objs)
+ rm -f $@
+ ar rcs $@ $^
+ $(RANLIB) $@
+
+else
+
+subdir: all.o
+
+all.o: $(objs)
+ $(LD) -r -o $@ $^
+
+endif
+
+%.o: $(src-path)%.c
+ $(CC) $(CFLAGS) -o $@ -c $^
+
+depend:
+ gcc $(CPPFLAGS) -MM $(addprefix $(src-path),$(source)) >depend
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
+
+endif
diff --git a/tools/mergedirs b/tools/mergedirs
index 3a085fd..25fc6bf 100755
--- a/tools/mergedirs
+++ b/tools/mergedirs
@@ -1,10 +1,17 @@
#!/bin/sh
-if [ -z "$2" ] ; then
- echo "Usage: mergedirs <obj-dir> <list-of-dirs>"
+if [ -z "$4" ] ; then
+ echo "Usage: mergedirs <src-dir> <src-dir-rel> <obj-dir> <list-of-dirs>"
exit 1
fi
-TOPDIR=`pwd`
+SRCDIR=$1
+shift
+SRCREL=$1
+case $SRCDIR in
+ /*) ;;
+ *) SRCREL="../$SRCREL" ;;
+ esac
+shift
OBJDIR=$1
LIBDIR=$OBJDIR/lib
CONFDIR=$OBJDIR/conf
@@ -12,26 +19,25 @@ shift
echo "Merging system-dependent modules"
MODULES=`for a in $@ ; do
- sed <$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
+ sed <$SRCDIR/$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
done |
sort +0 -1 -u |
cut -d ' ' -f 2`
rm -rf $LIBDIR $CONFDIR
mkdir -p $LIBDIR $CONFDIR
for a in $MODULES ; do
- echo $a
b=`basename $a`
case $b in
- *.h) ln -s $TOPDIR/$a $LIBDIR/$b
+ *.h) ln -s $SRCREL/$a $LIBDIR/$b
;;
*.c) OBJ=`echo $b | sed 's/\.c$/\.o/'`
OBJS="$OBJS $OBJ"
SRCS="$SRCS \\
- \$(TOPDIR)/$a"
- ln -s $TOPDIR/$a $LIBDIR/$b
+ $b"
+ ln -s $SRCREL/$a $LIBDIR/$b
;;
- *.Y) CONFS="$CONFS\$(TOPDIR)/$a "
- ln -s $TOPDIR/$a $CONFDIR/$b
+ *.Y) CONFS="$CONFS\$(srcdir)/$a "
+ ln -s $SRCREL/$a $CONFDIR/$b
;;
*) echo "$b: Unknown file type"
exit 1
@@ -40,12 +46,15 @@ for a in $MODULES ; do
done
cat >$LIBDIR/Makefile <<EOF
-OBJS=$OBJS
-SRCS=$SRCS
-LIB=birdlib.a
+source=$SRCS
+lib-dest=birdlib.a
+root-rel=../
-include \$(TOPDIR)/Rules
+include ../Rules
EOF
-sed <$TOPDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
-ln -s $TOPDIR/conf/*.[chl] $CONFDIR/
+sed <$SRCDIR/conf/Makefile >$CONFDIR/Makefile "s|@CONFS@|$CONFS|"
+CONFS=`cd $SRCDIR ; ls conf/*.[chl]`
+for a in $CONFS ; do
+ ln -s $SRCREL/$a $CONFDIR/
+done