0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-10-09 05:34:11 +00:00

New makefiles. Includes support for out-of-source-tree builds.

This commit is contained in:
Martin Mares 1999-01-10 00:18:32 +00:00
parent 2f9bcf9713
commit 49e7e5ee0b
16 changed files with 211 additions and 140 deletions

View File

@ -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

50
Rules
View File

@ -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

1
TODO
View File

@ -1,5 +1,6 @@
Core
~~~~
* right usage of DBG vs. debug
* cleanup debugging calls
* logging and tracing; use appropriate log levels

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,4 +1,5 @@
THISDIR=proto/rip
OBJS=rip.o
source=rip.c
root-rel=../../
dir-name=proto/rip
include ../../Rules

View File

@ -1,4 +1,6 @@
THISDIR=proto/static
OBJS=static.o
source=static.c
root-rel=../../
dir-name=proto/static
include ../../Rules

View File

@ -14,4 +14,5 @@
/*
Link: sysdep/linux
Link: sysdep/unix
*/

View File

@ -14,4 +14,5 @@
/*
Link: sysdep/linux
Link: sysdep/unix
*/

View File

@ -16,4 +16,5 @@
/*
Link: sysdep/linux
Link: sysdep/unix
*/

15
tools/Makefile-top.in Normal file
View File

@ -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

33
tools/Makefile.in Normal file
View File

@ -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)

66
tools/Rules.in Normal file
View File

@ -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

View File

@ -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