* distribute information about (upstream) DNS servers
[olsrd.git] / Makefile
index 7f8b913..84f4c76 100644 (file)
--- a/Makefile
+++ b/Makefile
+# 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
-#
-#
-# $Id: Makefile,v 1.17 2004/11/05 18:48:25 kattemat Exp $
+# 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.51 2005/03/10 06:55:44 kattemat Exp $
 
-#OS ?=         linux
-#OS =          fbsd
-#OS =          win32
-#OS =          osx
+VERS =         0.4.9
 
 CC ?=          gcc
-
-PREFIX ?=
-
 STRIP ?=       strip
-
 BISON ?=       bison
 FLEX ?=                flex
-CFGDIR =       src/cfgparser
 
-DEPFILE =      .depend
-DEPBAK =       .depend.bak
-DEPEND =       makedepend -f $(DEPFILE)
-
-all:           olsrd
-
-SRCS =         $(wildcard src/*.c) \
-               $(CFGDIR)/oparse.c $(CFGDIR)/oscan.c $(CFGDIR)/olsrd_conf.c
+CCWARNINGS = -Wall -Wmissing-prototypes -Wstrict-prototypes \
+             -Wmissing-declarations -Wsign-compare
 
-HDRS =         $(wildcard src/*.h) \
-               $(CFGDIR)/oparse.h $(CFGDIR)/olsrd_conf.h
+INSTALL_PREFIX ?=
 
-OBJS =         $(patsubst %.c,%.o,$(wildcard src/*.c)) \
-               $(CFGDIR)/oparse.o $(CFGDIR)/oscan.o $(CFGDIR)/olsrd_conf.o
+INCLUDES =     -Isrc
 
-ifeq ($(OS), linux)
+DEPFILE =      .depend
 
-SRCS +=        $(wildcard src/linux/*.c) $(wildcard src/unix/*.c)
+SRCS =         $(wildcard src/*.c)
+HDRS =         $(wildcard src/*.h)
 
-HDRS +=                $(wildcard src/linux/*.h) $(wildcard src/unix/*.h)
+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
 
-OBJS +=                $(patsubst %.c,%.o,$(wildcard src/linux/*.c)) \
-               $(patsubst %.c,%.o,$(wildcard src/unix/*.c))
+TAGCMD ?=      etags   
+TAGFILE ?=     src/TAGS
 
-CFLAGS ?=      -Isrc -Wall -Wmissing-prototypes -Wstrict-prototypes \
-               -O2 -g -Dlinux #-pg -DDEBUG #-march=i686
+ifndef OS
+all:           help
+else
+all:           cfgparser olsrd
+endif
 
-LIBS =         -lpthread -lm -ldl
+ifeq ($(OS), Windows_NT)
+OS =           win32
+endif
 
-$(DEPFILE):
-               @echo '# olsrd dependency file. AUTOGENERATED' > $(DEPFILE)
-               $(DEPEND) -Y $(CFLAGS) $(SRCS) >/dev/null 2>&1
+ifeq ($(OS), linux)
 
-olsrd:         $(OBJS)
-               $(CC) -o bin/$@ $(OBJS) $(LIBS)
+SRCS +=        $(wildcard src/linux/*.c) $(wildcard src/unix/*.c)
+HDRS +=                $(wildcard src/linux/*.h) $(wildcard src/unix/*.h)
+DEFINES =      -Dlinux
+CFLAGS ?=      $(CCWARNINGS) -O2 -g #-DDEBUG #-pg #-march=i686
+LIBS =         -lm -ldl #-pg
+MAKEDEPEND =   makedepend -f $(DEPFILE) $(DEFINES) -Y $(INCLUDES) $(SRCS) >/dev/null 2>&1
 
 else
 ifeq ($(OS), fbsd)
 
 SRCS +=                $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
-
 HDRS +=                $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
+CFLAGS ?=      $(CCWARNINGS) -O2 -g
+LIBS =         -lm
+MAKEDEPEND =   makedepend -f $(DEPFILE) -D__FreeBSD__ $(INCLUDES) $(SRCS)
 
-OBJS +=                $(patsubst %.c,%.o,$(wildcard src/bsd/*.c)) \
-               $(patsubst %.c,%.o,$(wildcard src/unix/*.c))
+else
+ifeq ($(OS), fbsd-ll)
 
-CFLAGS ?=      -Isrc -Wall -Wmissing-prototypes -Wstrict-prototypes \
-               -O2 -g
+SRCS +=                $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
+HDRS +=                $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
+CFLAGS ?=      -Wall -Wmissing-prototypes -O2 -g -DSPOOF -I/usr/local/include
+LIBS =         -lm -L/usr/local/lib -lnet
+MAKEDEPEND =   makedepend -f $(DEPFILE) -D__FreeBSD__ $(INCLUDES) $(SRCS)
 
-LIBS =         -pthread -lm
+else
+ifeq ($(OS), nbsd)
 
-$(DEPFILE):
-               @echo '# olsrd dependency file. AUTOGENERATED' > $(DEPFILE)
-               $(DEPEND) $(CFLAGS) $(SRCS)
+SRCS +=                $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
+HDRS +=                $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
+CFLAGS ?=      $(CCWARNINGS) -O2 -g
+LIBS =         -lm
+MAKEDEPEND =   makedepend -f $(DEPFILE) -D__NetBSD__ $(INCLUDES) $(SRCS)
 
-olsrd:         $(OBJS)
-               $(CC) -o bin/$@ $(OBJS) $(LIBS)
+else
+ifeq ($(OS), osx)
+
+SRCS +=                $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
+HDRS +=                $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
+DEFINES =      -D__MacOSX__
+CFLAGS ?=      $(CCWARNINGS) -O2 -g 
+LIBS =         -lm -ldl
+MAKEDEPEND =   makedepend -f $(DEPFILE) $(DEFINES) $(INCLUDES) $(SRCS)
 
 else
 ifeq ($(OS), win32)
 
 SRCS +=                $(wildcard src/win32/*.c)
-
 HDRS +=                $(wildcard src/win32/*.h)
-
-OBJS +=                $(patsubst %.c,%.o,$(wildcard src/win32/*.c))
-
-CFLAGS ?=      -Isrc -Isrc/win32 -Wall -Wmissing-prototypes \
-               -Wstrict-prototypes -mno-cygwin -O2 -g -DWIN32
-
+INCLUDES +=    -Isrc/win32
+DEFINES =      -DWIN32
+CFLAGS ?=      $(CCWARNINGS) -mno-cygwin -O2 -g
 LIBS =         -mno-cygwin -lws2_32 -liphlpapi
+MAKEDEPEND =   makedepend -f $(DEPFILE) $(DEFINES) $(INCLUDES) $(SRCS)
+
+olsr-${VERS}.zip:      gui/win32/Main/Release/Switch.exe \
+               gui/win32/Shim/Release/Shim.exe \
+               olsrd.exe \
+               src/cfgparser/olsrd_cfgparser.dll \
+               README \
+               README-Link-Quality.html \
+               gui/win32/Inst/linux-manual.txt \
+               files/olsrd.conf.default.win32 \
+               gui/win32/Main/Default.olsr \
+               lib/dot_draw/olsrd_dot_draw.dll \
+               lib/nameservice/olsrd_nameservice.dll \
+               lib/httpinfo/olsrd_httpinfo.dll
+               $(STRIP) olsrd.exe
+               $(STRIP) src/cfgparser/olsrd_cfgparser.dll
+               $(STRIP) lib/dot_draw/olsrd_dot_draw.dll
+               $(STRIP) lib/nameservice/olsrd_nameservice.dll
+               $(STRIP) lib/httpinfo/olsrd_httpinfo.dll
+               rm -rf ${TEMP}/olsr-${VERS}
+               rm -f ${TEMP}/olsr-${VERS}.zip
+               rm -f olsr-${VERS}.zip
+               mkdir ${TEMP}/olsr-${VERS}
+               cp gui/win32/Main/Release/Switch.exe ${TEMP}/olsr-${VERS}
+               cp gui/win32/Shim/Release/Shim.exe ${TEMP}/olsr-${VERS}
+               cp olsrd.exe ${TEMP}/olsr-${VERS}
+               cp src/cfgparser/olsrd_cfgparser.dll ${TEMP}/olsr-${VERS}
+               cp README ${TEMP}/olsr-${VERS}
+               cp README-Link-Quality.html ${TEMP}/olsr-${VERS}
+               cp gui/win32/Inst/linux-manual.txt ${TEMP}/olsr-${VERS}
+               cp files/olsrd.conf.default.win32 ${TEMP}/olsr-${VERS}/olsrd.conf
+               cp gui/win32/Main/Default.olsr ${TEMP}/olsr-${VERS}
+               cp lib/dot_draw/olsrd_dot_draw.dll ${TEMP}/olsr-${VERS}
+               cp lib/nameservice/olsrd_nameservice.dll ${TEMP}/olsr-${VERS}
+               cp lib/httpinfo/olsrd_httpinfo.dll ${TEMP}/olsr-${VERS}
+               cd ${TEMP}; echo y | cacls olsr-${VERS} /T /G Everyone:F
+               cd ${TEMP}; zip -q -r olsr-${VERS}.zip olsr-${VERS}
+               cp ${TEMP}/olsr-${VERS}.zip .
+               rm -rf ${TEMP}/olsr-${VERS}
+               rm -f ${TEMP}/olsr-${VERS}.zip
+
+olsr-${VERS}-setup.exe:        gui/win32/Main/Release/Switch.exe \
+               gui/win32/Shim/Release/Shim.exe \
+               olsrd.exe \
+               src/cfgparser/olsrd_cfgparser.dll \
+               README \
+               README-Link-Quality.html \
+               gui/win32/Inst/linux-manual.txt \
+               files/olsrd.conf.default.win32 \
+               gui/win32/Main/Default.olsr \
+               lib/dot_draw/olsrd_dot_draw.dll \
+               lib/nameservice/olsrd_nameservice.dll \
+               lib/httpinfo/olsrd_httpinfo.dll \
+               gui/win32/Inst/installer.nsi
+               $(STRIP) olsrd.exe
+               $(STRIP) src/cfgparser/olsrd_cfgparser.dll
+               $(STRIP) lib/dot_draw/olsrd_dot_draw.dll
+               $(STRIP) lib/nameservice/olsrd_nameservice.dll
+               $(STRIP) lib/httpinfo/olsrd_httpinfo.dll
+               rm -f olsr-setup.exe
+               rm -f olsr-${VERS}-setup.exe
+               C:/Program\ Files/NSIS/makensis gui\win32\Inst\installer.nsi
+               mv olsr-setup.exe olsr-${VERS}-setup.exe
 
-$(DEPFILE):
-               @echo '# olsrd dependency file. AUTOGENERATED' > $(DEPFILE)
-               $(DEPEND) $(CFLAGS) $(SRCS)
+else
 
-olsrd:         $(OBJS)
-               $(CC) -o bin/$@ $(OBJS) $(LIBS)
+all:   help
 
-else
-ifeq ($(OS), osx)
+endif
+endif
+endif
+endif
+endif
+endif
 
-SRCS +=                $(wildcard src/bsd/*.c) $(wildcard src/unix/*.c)
+ifneq ($(NODEBUG), )
+CFLAGS += -DNODEBUG
+endif
 
-HDRS +=                $(wildcard src/bsd/*.h) $(wildcard src/unix/*.h)
+OBJS = $(patsubst %.c,%.o,$(SRCS))
+override CFLAGS += $(INCLUDES) $(DEFINES)
+export CFLAGS
 
-OBJS +=                $(patsubst %.c,%.o,$(wildcard src/bsd/*.c)) \
-               $(patsubst %.c,%.o,$(wildcard src/unix/*.c))
 
-CFLAGS ?=      -D__MacOSX__ -Isrc -Wall -Wmissing-prototypes \
-               -Wstrict-prototypes -O2 -g 
+olsrd:         $(OBJS) $(CFGOBJS)
+               $(CC) -o $@ $(OBJS) $(CFGOBJS) $(LIBS) 
 
-LIBS =         -lm -ldl
-$(DEPFILE):
+$(DEPFILE):    $(SRCS) $(HDRS)
+ifdef MAKEDEPEND
                @echo '# olsrd dependency file. AUTOGENERATED' > $(DEPFILE)
-               $(DEPEND) $(CFLAGS) $(SRCS)
+               $(MAKEDEPEND)
+endif
 
-olsrd:         $(OBJS)
-               $(CC) -o bin/$@ $(OBJS) $(LIBS)
+cfgparser:     $(CFGDEPS)
+               $(MAKE) -C $(CFGDIR)
 
+$(CFGOBJS):
+               $(MAKE) -C $(CFGDIR)
 
-else
+.PHONY: help libs clean_libs clean uberclean install_libs install_bin install
 
-olsrd:
+help:
        @echo
        @echo '***** olsr.org olsr daemon Make ****'
        @echo ' You must provide a valid target OS '
@@ -149,8 +237,9 @@ olsrd:
        @echo ' target OSes are:                   '
        @echo ' ---------------------------------  '
        @echo ' linux - GNU/Linux                  '
-       @echo ' win32 - Windows NT family(2k/XP)   '
+       @echo ' win32 - MS Windows                 '
        @echo ' fbsd  - FreeBSD                    '
+       @echo ' nbsd  - NetBSD                     '
        @echo ' osx   - Mac OS X                   '
        @echo ' ---------------------------------  '
        @echo ' Example - build for windows:       '
@@ -160,23 +249,40 @@ olsrd:
        @echo ' be a good idea :-) Have fun!       '
        @echo '************************************'
        @echo
-endif
-endif
-endif
-endif
 
-depend:                $(DEPFILE)
+clean:
+               rm -f $(OBJS) olsrd olsrd.exe
+               $(MAKE) -C src/cfgparser clean
 
-$(CFGDIR)/oparse.c: \
-               $(CFGDIR)/oparse.y $(CFGDIR)/olsrd_conf.h
-               $(BISON) -d -o$(CFGDIR)/oparse.c $(CFGDIR)/oparse.y
+uberclean:     clean clean_libs
+               rm -f $(DEPFILE) $(DEPFILE).bak *~
+               rm -f src/*[o~] src/linux/*[o~] src/unix/*[o~] src/win32/*[o~]
+               rm -f src/bsd/*[o~] 
+               $(MAKE) -C src/cfgparser uberclean
 
-$(CFGDIR)/oparse.h: \
-               $(CFGDIR)/oparse.c
+install_bin:
+               $(STRIP) olsrd
+               mkdir -p $(INSTALL_PREFIX)/usr/sbin
+               install -m 755 olsrd $(INSTALL_PREFIX)/usr/sbin
 
-$(CFGDIR)/oscan.c: \
-               $(CFGDIR)/oscan.lex $(CFGDIR)/oparse.h $(CFGDIR)/olsrd_conf.h
-               $(FLEX) -o$(CFGDIR)/oscan.c $(CFGDIR)/oscan.lex
+install:       install_bin
+               @echo olsrd uses the configfile $(INSTALL_PREFIX)/etc/olsr.conf
+               @echo a default configfile. A sample configfile
+               @echo can be installed
+               mkdir -p $(INSTALL_PREFIX)/etc
+               cp -i files/olsrd.conf.default $(INSTALL_PREFIX)/etc/olsrd.conf
+               @echo -------------------------------------------
+               @echo Edit $(INSTALL_PREFIX)/etc/olsrd.conf before running olsrd!!
+               @echo -------------------------------------------
+               @echo Installing manpages olsrd\(8\) and olsrd.conf\(5\)
+               mkdir -p $(INSTALL_PREFIX)/usr/share/man/man8/
+               cp files/olsrd.8.gz $(INSTALL_PREFIX)/usr/share/man/man8/olsrd.8.gz
+               mkdir -p $(INSTALL_PREFIX)/usr/share/man/man5/
+               cp files/olsrd.conf.5.gz $(INSTALL_PREFIX)/usr/share/man/man5/olsrd.conf.5.gz
+
+#
+# PLUGINS
+#
 
 libs: 
                for i in lib/*; do \
@@ -188,38 +294,41 @@ clean_libs:
                        $(MAKE) -C $$i clean; \
                done; 
 
-.PHONY:                clean
-
-clean:
-               rm -f $(OBJS)
-
-uberclean:
-               rm -f $(OBJS) $(DEPFILE) $(DEPBAK)
-               rm -f $(CFGDIR)/oscan.c $(CFGDIR)/oparse.h $(CFGDIR)/oparse.c
-               rm -f bin/olsrd bin/olsrd.exe
-               rm -f src/*~ src/linux/*~ src/unix/*~ src/win32/*~
-               rm -f src/bsd/*~ src/cfgparser/*~
-
 install_libs:
                for i in lib/*; do \
-                       $(MAKE) -C $$i LIBDIR=$(PREFIX)/usr/lib install; \
+                       $(MAKE) -C $$i LIBDIR=$(INSTALL_PREFIX)/usr/lib install; \
                done;   
 
-install_bin:
-               $(STRIP) bin/olsrd
-               install -D -m 755 bin/olsrd $(PREFIX)/usr/sbin/olsrd
+httpinfo:
+               $(MAKE) -C lib/httpinfo clean
+               $(MAKE) -C lib/httpinfo 
+               $(MAKE) -C lib/httpinfo install 
 
-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
+dot_draw:
+               $(MAKE) -C lib/dot_draw clean
+               $(MAKE) -C lib/dot_draw install
 
-sinclude       $(DEPFILE)
+nameservice:
+               $(MAKE) -C lib/nameservice clean
+               $(MAKE) -C lib/nameservice install
+
+dyn_gw:
+               $(MAKE) -C lib/dyn_gw clean
+               $(MAKE) -C lib/dyn_gw
+               $(MAKE) -C lib/dyn_gw install
 
+powerinfo:
+               $(MAKE) -C lib/powerinfo clean
+               $(MAKE) -C lib/powerinfo 
+               $(MAKE) -C lib/powerinfo install
+
+secure:
+               $(MAKE) -C lib/secure clean
+               $(MAKE) -C lib/secure
+               $(MAKE) -C lib/secure install
+
+
+tags:
+               $(TAGCMD) -o $(TAGFILE) $(SRCS) $(HDRS) $(wildcard src/cfgparser/*.c) $(wildcard src/cfgparser/*.h)
+
+sinclude       $(DEPFILE)