+# The olsr.org Optimized Link-State Routing daemon(olsrd)
+# Copyright (c) 2004, Andreas Tønnesen(andreto@olsr.org)
+# All rights reserved.
#
-# OLSR ad-hoc routing table management protocol
-# Copyright (C) 2003-2004 Andreas Tønnesen (andreto@ifi.uio.no)
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
#
-# This file is part of the olsr.org OLSR daemon.
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# * Neither the name of olsr.org, olsrd nor the names of its
+# contributors may be used to endorse or promote products derived
+# from this software without specific prior written permission.
#
-# olsr.org is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
#
-# olsr.org is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# Visit http://www.olsr.org for more information.
#
-# You should have received a copy of the GNU General Public License
-# along with olsr.org; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# If you find this software useful feel free to make a donation
+# to the project. For more information see the website or contact
+# the copyright holders.
#
-#
-# $Id: Makefile,v 1.12 2004/11/05 02:06:13 tlopatic Exp $
-#
-
-OS = linux
-#OS = fbsd
-#OS = win32
-
-CC ?= gcc
-
-PREFIX ?=
-
-STRIP ?= strip
-
-BISON ?= bison
-FLEX ?= flex
-CFGDIR = src/cfgparser
-
-DEPFILE = .depend
-DEPEND = makedepend -f $(DEPFILE) -- $(CFLAGS)
+# $Id: Makefile,v 1.76 2007/04/01 21:44:14 bernd67 Exp $
-SRCS = $(wildcard src/*.c) \
- $(CFGDIR)/oparse.c $(CFGDIR)/oscan.c $(CFGDIR)/olsrd_conf.c
+VERS = 0.5.0
-HDRS = $(wildcard src/*.h) \
- $(CFGDIR)/oparse.h $(CFGDIR)/olsrd_conf.h
+TOPDIR = .
+include Makefile.inc
-OBJS = $(patsubst %.c,%.o,$(wildcard src/*.c)) \
- $(CFGDIR)/oparse.o $(CFGDIR)/oscan.o $(CFGDIR)/olsrd_conf.o
-
-ifeq ($(OS), linux)
-
-SRCS += $(wildcard src/linux/*.c) $(wildcard src/unix/*.c)
-
-HDRS += $(wildcard src/linux/*.h) $(wildcard src/unix/*.h)
-
-OBJS += $(patsubst %.c,%.o,$(wildcard src/linux/*.c)) \
- $(patsubst %.c,%.o,$(wildcard src/unix/*.c))
-
-CFLAGS ?= -Isrc -Wall -Wmissing-prototypes -Wstrict-prototypes \
- -O2 -g -Dlinux #-pg -DDEBUG #-march=i686
-
-LIBS = -lpthread -lm -ldl
+LIBS += $(OS_LIB_DYNLOAD)
+ifeq ($(OS), win32)
+LDFLAGS += -Wl,--out-implib=libolsrd.a -Wl,--export-all-symbols
endif
-ifeq ($(OS), fbsd)
-
-SRCS += $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
-
-HDRS += $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
-
-OBJS += $(patsubst %.c,%.o,$(wildcard src/bsd/*.c)) \
- $(patsubst %.c,%.o,$(wildcard src/unix/*.c))
+SWITCHDIR = src/olsr_switch
+CFGDIR = src/cfgparser
+CFGOBJS = $(CFGDIR)/oscan.o $(CFGDIR)/oparse.o $(CFGDIR)/olsrd_conf.o
+CFGDEPS = $(wildcard $(CFGDIR)/*.c) $(wildcard $(CFGDIR)/*.h) $(CFGDIR)/oparse.y $(CFGDIR)/oscan.lex
+TAG_SRCS = $(SRCS) $(HDRS) $(wildcard src/cfgparser/*.c) $(wildcard src/cfgparser/*.h) $(wildcard src/olsr_switch/*.c) $(wildcard src/olsr_switch/*.h)
-CFLAGS ?= -Isrc -Wall -Wmissing-prototypes -Wstrict-prototypes \
- -O2 -g
+default_target: cfgparser olsrd
-LIBS = -pthread -lm
+olsrd: $(OBJS) $(CFGOBJS)
+ $(CC) $(LDFLAGS) -o $@ $(OBJS) $(CFGOBJS) $(LIBS)
-endif
-
-ifeq ($(OS), win32)
+cfgparser: $(CFGDEPS)
+ $(MAKE) -C $(CFGDIR)
-SRCS += $(wildcard src/win32/*.c)
+switch:
+ $(MAKE) -C $(SWITCHDIR)
-HDRS += $(wildcard src/win32/*.h)
+$(CFGOBJS):
+ $(MAKE) -C $(CFGDIR)
-OBJS += $(patsubst %.c,%.o,$(wildcard src/win32/*.c))
+.PHONY: help libs clean_libs libs_clean clean uberclean install_libs libs_install install_bin install_olsrd install build_all install_all clean_all
-CFLAGS ?= -Isrc -Isrc/win32 -Wall -Wmissing-prototypes \
- -Wstrict-prototypes -mno-cygwin -O2 -g -DWIN32
+clean:
+ -rm -f $(OBJS) $(SRCS:%.c=%.d) olsrd olsrd.exe
+ $(MAKE) -C $(CFGDIR) clean
+ $(MAKE) -C $(SWITCHDIR) clean
-LIBS = -mno-cygwin -lws2_32 -liphlpapi
+uberclean: clean clean_libs
+ -rm -f $(TAGFILE)
+ -rm -f src/*.[od~]
+ -rm -f src/linux/*.[od~] src/unix/*.[od~] src/win32/*.[od~] src/bsd/*.[od~]
+ $(MAKE) -C $(CFGDIR) uberclean
+ $(MAKE) -C $(SWITCHDIR) clean
-endif
+install: install_olsrd
-all: olsrd
+install_bin:
+ mkdir -p $(SBINDIR)
+ install -m 755 $(EXENAME) $(SBINDIR)
+ $(STRIP) $(SBINDIR)/$(EXENAME)
+
+install_olsrd: install_bin
+ @echo ========= C O N F I G U R A T I O N - F I L E ============
+ @echo olsrd uses the configfile $(CFGFILE)
+ @echo a default configfile. A sample RFC-compliance aimed
+ @echo configfile can be installed. Note that a LQ-based configfile
+ @echo can be found at files/olsrd.conf.default.lq
+ @echo ==========================================================
+ mkdir -p $(ETCDIR)
+ -cp -i files/olsrd.conf.default.rfc $(CFGFILE)
+ @echo -------------------------------------------
+ @echo Edit $(CFGFILE) before running olsrd!!
+ @echo -------------------------------------------
+ @echo Installing manpages olsrd\(8\) and olsrd.conf\(5\)
+ mkdir -p $(MANDIR)/man8/
+ cp files/olsrd.8.gz $(MANDIR)/man8/olsrd.8.gz
+ mkdir -p $(MANDIR)/man5/
+ cp files/olsrd.conf.5.gz $(MANDIR)/man5/olsrd.conf.5.gz
+
+tags:
+ $(TAGCMD) -o $(TAGFILE) $(TAG_SRCS)
+
+rpm:
+ @$(RM) olsrd-current.tar.bz2
+ @echo "Creating olsrd-current.tar.bz2 ..."
+ @./list-excludes.sh | tar --exclude-from=- --exclude="olsrd-current.tar.bz2" -C .. -cjf olsrd-current.tar.bz2 olsrd-current
+ @echo "Building RPMs..."
+ @rpmbuild -ta olsrd-current.tar.bz2
+#
+# PLUGINS
+#
-olsrd: $(OBJS)
- $(CC) -o bin/$@ $(OBJS) $(LIBS)
+libs:
+ $(MAKE) -C lib LIBDIR=$(LIBDIR)
-depend: $(DEPFILE)
+libs_clean clean_libs:
+ $(MAKE) -C lib LIBDIR=$(LIBDIR) clean
-$(DEPFILE):
- @echo '# olsrd dependency file. AUTOGENERATED' > $(DEPFILE)
- $(DEPEND) -- $(SRCS)
+libs_install install_libs:
+ $(MAKE) -C lib LIBDIR=$(LIBDIR) install
-$(CFGDIR)/oparse.c: \
- $(CFGDIR)/oparse.y $(CFGDIR)/olsrd_conf.h
- $(BISON) -d -o$(CFGDIR)/oparse.c $(CFGDIR)/oparse.y
+httpinfo:
+ $(MAKE) -C lib/httpinfo clean
+ $(MAKE) -C lib/httpinfo
+ $(MAKE) -C lib/httpinfo DESTDIR=$(DESTDIR) install
-$(CFGDIR)/oparse.h: \
- $(CFGDIR)/oparse.c
+tas:
+ $(MAKE) -C lib/tas clean
+ $(MAKE) -C lib/tas DESTDIR=$(DESTDIR) install
-$(CFGDIR)/oscan.c: \
- $(CFGDIR)/oscan.lex $(CFGDIR)/oparse.h $(CFGDIR)/olsrd_conf.h
- $(FLEX) -o$(CFGDIR)/oscan.c $(CFGDIR)/oscan.lex
+dot_draw:
+ $(MAKE) -C lib/dot_draw clean
+ $(MAKE) -C lib/dot_draw DESTDIR=$(DESTDIR) install
-libs:
- for i in lib/*; do \
- $(MAKE) -C $$i; \
- done;
+nameservice:
+ $(MAKE) -C lib/nameservice clean
+ $(MAKE) -C lib/nameservice DESTDIR=$(DESTDIR) install
-clean_libs:
- for i in lib/*; do \
- $(MAKE) -C $$i clean; \
- done;
+dyn_gw:
+ $(MAKE) -C lib/dyn_gw clean
+ $(MAKE) -C lib/dyn_gw
+ $(MAKE) -C lib/dyn_gw DESTDIR=$(DESTDIR) install
-.PHONY: clean
+dyn_gw_plain:
+ $(MAKE) -C lib/dyn_gw_plain clean
+ $(MAKE) -C lib/dyn_gw_plain
+ $(MAKE) -C lib/dyn_gw_plain DESTDIR=$(DESTDIR) install
-clean:
- rm -f $(OBJS)
+secure:
+ $(MAKE) -C lib/secure clean
+ $(MAKE) -C lib/secure
+ $(MAKE) -C lib/secure DESTDIR=$(DESTDIR) install
-uberclean:
- rm -f $(OBJS) $(DEPFILE)
- rm -f $(CFGDIR)/oscan.c $(CFGDIR)/oparse.h $(CFGDIR)/oparse.c
- rm -f bin/olsrd
- rm -f src/*~ src/linux/*~ src/unix/*~ src/win32/*~
- rm -f src/bsd/*~ src/cfgparser/*~
+pgraph:
+ $(MAKE) -C lib/pgraph clean
+ $(MAKE) -C lib/pgraph
+ $(MAKE) -C lib/pgraph DESTDIR=$(DESTDIR) install
-install_libs:
- for i in lib/*; do \
- $(MAKE) -C $$i LIBDIR=$(PREFIX)/usr/lib install; \
- done;
+bmf:
+ $(MAKE) -C lib/bmf clean
+ $(MAKE) -C lib/bmf
+ $(MAKE) -C lib/bmf DESTDIR=$(DESTDIR) install
-install_bin:
- $(STRIP) bin/olsrd
- install -D -m 755 bin/olsrd $(PREFIX)/usr/sbin/olsrd
-
-install: install_bin
- @echo olsrd uses the configfile $(PREFIX)/etc/olsr.conf
- @echo a default configfile. A sample configfile
- @echo can be installed
- mkdir -p $(PREFIX)/etc
- cp -i files/olsrd.conf.default $(PREFIX)/etc/olsrd.conf
- @echo -------------------------------------------
- @echo Edit $(PREFIX)/etc/olsrd.conf before running olsrd!!
- @echo -------------------------------------------
- mkdir -p $(PREFIX)/usr/share/man/man8/
- cp files/olsrd.8.gz $(PREFIX)/usr/share/man/man8/olsrd.8.gz
+quagga:
+ $(MAKE) -C lib/quagga clean
+ $(MAKE) -C lib/quagga
+ $(MAKE) -C lib/quagga DESTDIR=$(DESTDIR) install
-sinclude $(DEPFILE)
+build_all: cfgparser olsrd libs
+install_all: install install_libs
+clean_all: uberclean clean_libs