diff options
author | Martin Mares <mj@ucw.cz> | 1999-01-10 01:18:32 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 1999-01-10 01:18:32 +0100 |
commit | 49e7e5ee0b2848f5bf120a962e2e7eb11b86566a (patch) | |
tree | 56e7c215f49ab59792b5cf0194fa5045a66943c7 /tools | |
parent | 2f9bcf9713523f6fefecd143cc2aa2a8dda7f27f (diff) | |
download | bird-49e7e5ee0b2848f5bf120a962e2e7eb11b86566a.tar bird-49e7e5ee0b2848f5bf120a962e2e7eb11b86566a.zip |
New makefiles. Includes support for out-of-source-tree builds.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile-top.in | 15 | ||||
-rw-r--r-- | tools/Makefile.in | 33 | ||||
-rw-r--r-- | tools/Rules.in | 66 | ||||
-rwxr-xr-x | tools/mergedirs | 41 |
4 files changed, 139 insertions, 16 deletions
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 |