]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
The library is now glued together from generic and OS-dependent parts
authorMartin Mares <mj@ucw.cz>
Fri, 15 May 1998 07:56:13 +0000 (07:56 +0000)
committerMartin Mares <mj@ucw.cz>
Fri, 15 May 1998 07:56:13 +0000 (07:56 +0000)
by the `mergedirs' script. Few more IP address manipulation functions
and some fixes.

20 files changed:
Makefile
Rules
lib/Makefile [deleted file]
lib/Modules [new file with mode: 0644]
lib/birdlib.h
lib/ip.h
lib/ipv4.c
lib/ipv4.h
lib/ipv6.c
lib/ipv6.h
sysdep/cf/linux-20.h
sysdep/cf/linux-21.h
sysdep/cf/linux-v6.h
sysdep/linux/Makefile [deleted file]
sysdep/linux/Modules [new file with mode: 0644]
sysdep/unix/Makefile [deleted file]
sysdep/unix/Modules [new file with mode: 0644]
sysdep/unix/main.c [new file with mode: 0644]
sysdep/unix/timer.h [moved from lib/timer.h with 100% similarity]
tools/mergedirs [new file with mode: 0755]

index 45e69afaf7a6ab53fb2ba8f2ae5b5a90d4f1ae79..3a74205baa994f9f4aad304bfc616f004fcc96d0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,32 +2,41 @@
 # (c) 1998 Martin Mares <mj@ucw.cz>
 
 TOPDIR=$(shell pwd)
+OBJDIR=obj
+
 CPPFLAGS=-I$(TOPDIR)/sysdep/linux -I$(TOPDIR)
 OPT=-O2
 DEBUG=-g#gdb
 CFLAGS=$(OPT) $(DEBUG) -Wall -W -Wstrict-prototypes -Wno-unused -Wno-parentheses
 
 PROTOCOLS=
-DIRS=nest $(PROTOCOLS) lib sysdep/linux sysdep/unix
-ARCHS=$(join $(addsuffix /,$(DIRS)),$(subst /,_,$(addsuffix .a,$(DIRS))))
+LIBDIRS=sysdep/linux sysdep/unix lib
+STDDIRS=nest $(PROTOCOLS)
+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 ; done
+       set -e ; for a in $(DIRS) ; do $(MAKE) -C $$a all ; done
 
-bird: $(ARCHS)
+bird: $(PARTOBJS) $(LIBS)
        $(CC) $(LDFLAGS) -o $@ $^
 
 .dep:
        $(MAKE) dep
-       touch .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
diff --git a/Rules b/Rules
index a0a1418a6b8526959be7fa9eb328ab2bf19f07cb..2d9c0a8a4a7fe7f1f5bd4879ca21b7e78a7d70e9 100644 (file)
--- a/Rules
+++ b/Rules
@@ -3,16 +3,31 @@
 
 THISDIR=$(shell pwd)
 RELDIR=$(subst $(TOPDIR)/,,$(THISDIR))
-ANAME=$(subst /,_,$(RELDIR)).a
+ONAME=$(subst /,_,$(RELDIR)).o
+
+ifndef SRCS
 SRCS=$(subst .o,.c,$(OBJS))
+endif
+
+ifdef OBJS
 
-all: $(ANAME)
+ifdef LIB
 
-$(ANAME): $(OBJS)
-       rm -f $(ANAME)
-       ar rcs $(ANAME) $(OBJS)
+all: $(LIB)
 
-ifdef OBJS
+$(LIB): $(OBJS)
+       rm -f $(LIB)
+       ar rcs $(LIB) $(OBJS)
+       ranlib $(LIB)
+
+else
+
+all: $(ONAME)
+
+$(ONAME): $(OBJS)
+       $(LD) -r -o $(ONAME) $(OBJS)
+
+endif
 
 dep: $(SRCS)
        rm -f .depend
diff --git a/lib/Makefile b/lib/Makefile
deleted file mode 100644 (file)
index 6eb14e1..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-OBJS=lists.o bitops.o resource.o xmalloc.o mempool.o slab.o md5.o
-
-ifdef IPV6
-OBJS += ipv6.o
-else
-OBJS += ipv4.o
-endif
-
-include $(TOPDIR)/Rules
diff --git a/lib/Modules b/lib/Modules
new file mode 100644 (file)
index 0000000..18447e1
--- /dev/null
@@ -0,0 +1,19 @@
+birdlib.h
+bitops.c
+bitops.h
+ip.h
+ipv4.c
+ipv4.h
+ipv6.c
+ipv6.h
+lists.c
+lists.h
+md5.c
+md5.h
+mempool.c
+resource.c
+resource.h
+slab.c
+socket.h
+unaligned.h
+xmalloc.c
index 5e533b66a28458d17c650dd600d84056375f5b67..842fce86b16dfde23d4b991390003d648fa443de 100644 (file)
@@ -21,8 +21,8 @@
 
 /* Logging and dying */
 
-void log(char *msg, ...);
-void die(char *msg, ...) NORET;
+void log(char *msg, ...) __attribute__((format(printf,1,2)));
+void die(char *msg, ...) __attribute__((format(printf,1,2))) NORET;
 
 #define L_DEBUG "\001"                 /* Debugging messages */
 #define L_INFO "\002"                  /* Informational messages */
index c36839923c361dc471043e93f0029d935660efda..87cd3aa9324f35a4d3eae9788589ebceefde6975 100644 (file)
--- a/lib/ip.h
+++ b/lib/ip.h
 #define SCOPE_SITE 2
 #define SCOPE_UNIVERSE 3
 
+/*
+ *     Is it a valid network prefix?
+ */
+
+#define ip_is_prefix(a,l) (!ipa_nonzero(ipa_and(a, ipa_not(ipa_mkmask(l)))))
+
 #endif
index 52f5b0b229ff98bcb1d0dd3f8de548e3bccb2b99..cc673733c034739e47f67bdaaee3191457f9970b 100644 (file)
@@ -6,6 +6,8 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+#ifndef IPV6
+
 #include "nest/bird.h"
 #include "lib/ip.h"
 
@@ -27,3 +29,5 @@ ipv4_classify(u32 a)
     return IADDR_BROADCAST | SCOPE_LINK;
   return IADDR_INVALID;
 }
+
+#endif
index fa8a27b5c8f726755661969e3c4054b44bd1efa2..de9f4e5706b31af0aa1b4dee818a5c8e67cb5725 100644 (file)
@@ -25,7 +25,7 @@ typedef struct ipv4_addr {
 } ip_addr;
 
 #define _I(x) (x).addr
-#define _MI(x) ((struct ip_addr) { x })
+#define _MI(x) ((struct ipv4_addr) { x })
 
 #else
 
@@ -36,6 +36,8 @@ typedef u32 ip_addr;
 
 #endif
 
+#define BITS_PER_IP_ADDRESS 32
+
 #define IPA_NONE (_MI(0))
 
 #define ipa_equal(x,y) (_I(x) == _I(y))
@@ -50,8 +52,6 @@ typedef u32 ip_addr;
 #define ipa_ntoh(x) x = _MI(ntohl(_I(x)))
 #define ipa_classify(x) ipv4_classify(_I(x))
 
-unsigned ipv4_mklen(u32);
-u32 ipv4_mkmask(unsigned);
 int ipv4_classify(u32);
 
 /* FIXME: Is this hash function uniformly distributed over standard routing tables? */
index e612af72480ec2aaa5a203b163cd8899cedc1143..2d01e839d8b067375108d0fc144529908a4dc068 100644 (file)
@@ -6,7 +6,11 @@
  *     Can be freely distributed and used under the terms of the GNU GPL.
  */
 
+#ifdef IPV6
+
 #include "nest/bird.h"
 #include "lib/ip.h"
 
 #error "Ought to implement these."
+
+#endif
index 845955f482c3752b3a69bf2e051c1a06f72634b7..08ed5f8816769fef2b0d4a6b9adf0cce4f6680e2 100644 (file)
@@ -22,6 +22,8 @@ typedef struct ipv4_addr {
 #define _I2(a) ((a).addr[2])
 #define _I3(a) ((a).addr[3])
 
+#define BITS_PER_IP_ADDRESS 128
+
 #define IPA_NONE _MI(0,0,0,0)
 
 #define ipa_equal(x,y) (!memcmp(&(x),&(y),sizeof(ip_addr)))
index 6100add382beca4ee1653a5affb8f08d91f0c71a..092ab71f776a7d5694aeca97282226b0268584ba 100644 (file)
@@ -9,3 +9,7 @@
 #undef CONFIG_TOS
 #undef CONFIG_MULTIPATH
 #undef CONFIG_NETLINK
+
+/*
+Link: sysdep/linux
+ */
index a2afcbbd390f0619f92e1001c141544651060d62..c810ec1a5cff213c89e2cbc536a959925fb766eb 100644 (file)
@@ -9,3 +9,7 @@
 #define CONFIG_TOS
 #define CONFIG_MULTIPATH
 #define CONFIG_NETLINK
+
+/*
+Link: sysdep/linux
+ */
index de397fc1aa81d40492b15194d7ec47c137db4279..21939b8623ffc46ccd6cca576cfa11d3314bc43e 100644 (file)
@@ -11,3 +11,7 @@
 #define CONFIG_TOS
 #define CONFIG_MULTIPATH
 #define CONFIG_NETLINK
+
+/*
+Link: sysdep/linux
+ */
diff --git a/sysdep/linux/Makefile b/sysdep/linux/Makefile
deleted file mode 100644 (file)
index a81db06..0000000
+++ /dev/null
@@ -1 +0,0 @@
-include $(TOPDIR)/Rules
diff --git a/sysdep/linux/Modules b/sysdep/linux/Modules
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sysdep/unix/Makefile b/sysdep/unix/Makefile
deleted file mode 100644 (file)
index 60f8057..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-OBJS=log.o
-
-include $(TOPDIR)/Rules
diff --git a/sysdep/unix/Modules b/sysdep/unix/Modules
new file mode 100644 (file)
index 0000000..450f579
--- /dev/null
@@ -0,0 +1,3 @@
+log.c
+main.c
+timer.h
diff --git a/sysdep/unix/main.c b/sysdep/unix/main.c
new file mode 100644 (file)
index 0000000..f3b01d4
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ *     BIRD Internet Routing Daemon -- Unix Entry Point
+ *
+ *     (c) 1998 Martin Mares <mj@ucw.cz>
+ *
+ *     Can be freely distributed and used under the terms of the GNU GPL.
+ */
+
+#include <stdio.h>
+
+#include "nest/bird.h"
+#include "lib/lists.h"
+#include "lib/resource.h"
+#include "nest/route.h"
+
+int
+main(void)
+{
+  log(L_INFO "Launching BIRD -1.-1-pre-omega...");
+
+  log_init_debug(NULL);
+  resource_init();
+
+  return 0;
+}
similarity index 100%
rename from lib/timer.h
rename to sysdep/unix/timer.h
diff --git a/tools/mergedirs b/tools/mergedirs
new file mode 100755 (executable)
index 0000000..581ea4c
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+if [ -z "$2" ] ; then
+       echo "Usage: mergedirs <obj-dir> <list-of-dirs>"
+       exit 1
+       fi
+TOPDIR=`pwd`
+OBJDIR=$1
+LIBDIR=$OBJDIR/lib
+shift
+echo "Merging system-dependent modules"
+MODULES=`for a in $@ ; do
+               sed <$a/Modules "s@\\(.*\\)@\\1 $a/\\1@"
+               done |
+       sort +0 -1 -u |
+       cut -d ' ' -f 2`
+rm -rf $LIBDIR
+mkdir -p $LIBDIR
+for a in $MODULES ; do
+       echo $a
+       b=`basename $a`
+       ln -s $TOPDIR/$a $LIBDIR/$b
+       OBJ=`echo $b | sed '/\.c$/!d;s/\.c$/\.o/'`
+       if [ -n "$OBJ" ] ; then
+               OBJS="$OBJS $OBJ"
+               SRCS="$SRCS \\
+       \$(TOPDIR)/$a"
+               fi
+       done
+cat >$LIBDIR/Makefile <<EOF
+OBJS=$OBJS
+SRCS=$SRCS
+LIB=birdlib.a
+
+include \$(TOPDIR)/Rules
+EOF