# Makefile fragments for the BIRD Internet Routing Daemon
# (c) 1999--2000 Martin Mares <mj@ucw.cz>

srcdir=$(root-rel)..
srcdir_abs := $(shell cd $(srcdir) ; pwd)
objdir=obj
exedir=..

protocols=bgp ospf pipe rip static
static-dirs := nest filter $(addprefix proto/,$(protocols))
static-dir-paths := $(addprefix $(srcdir)/,$(static-dirs))
dynamic-dirs := lib conf
dynamic-dir-paths := $(dynamic-dirs)
client-dirs := 
client-dir-paths := $(client-dirs)
doc-dirs := doc
doc-dir-paths := $(doc-dirs)

all-dirs:=$(static-dirs) $(dynamic-dirs) $(client-dirs) $(doc-dirs)
clean-dirs:=$(all-dirs) proto sysdep

CPPFLAGS=-I$(root-rel) -I$(srcdir) 
CFLAGS=$(CPPFLAGS) -Os
LDFLAGS=
LIBS=
CLIENT_LIBS=
CC=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-gcc
LD=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-ld
AR=/opt/brcm/hndtools-mipsel-uclibc/bin/mipsel-uclibc-ar
M4=m4
BISON=bison
FLEX=flex
RANLIB=ranlib
INSTALL=/usr/bin/install -c
INSTALL_PROGRAM=${INSTALL}
INSTALL_DATA=${INSTALL} -m 644

prefix=/usr
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
sbindir=${exec_prefix}/sbin
sysconfdir=/tmp/bird
localstatedir=/tmp/bird
docdir=/usr/doc

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:
	$(CC) $(CPPFLAGS) -MM $(addprefix $(src-path),$(source)) >depend

ifneq ($(wildcard depend),)
include depend
endif

endif
