Makefile
author Saverio Proto <zioproto@gmail.com>
Thu Mar 26 01:25:34 2009 +0100 (3 years ago)
changeset 2289 10ad22c88dbb
parent 222408824ce0906a
child 231338a34a10de08
permissions -rw-r--r--
Adding first version of the OLSR mdns plugin written by Saverio Proto and
Claudio Pisa (Ninux.org)
     1 # The olsr.org Optimized Link-State Routing daemon(olsrd)
     2 # Copyright (c) 2004-2009, the olsr.org team - see HISTORY file
     3 # All rights reserved.
     4 #
     5 # Redistribution and use in source and binary forms, with or without
     6 # modification, are permitted provided that the following conditions
     7 # are met:
     8 #
     9 # * Redistributions of source code must retain the above copyright
    10 #   notice, this list of conditions and the following disclaimer.
    11 # * Redistributions in binary form must reproduce the above copyright
    12 #   notice, this list of conditions and the following disclaimer in
    13 #   the documentation and/or other materials provided with the
    14 #   distribution.
    15 # * Neither the name of olsr.org, olsrd nor the names of its
    16 #   contributors may be used to endorse or promote products derived
    17 #   from this software without specific prior written permission.
    18 #
    19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
    22 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
    23 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    24 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
    25 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
    26 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
    27 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    28 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
    29 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    30 # POSSIBILITY OF SUCH DAMAGE.
    31 #
    32 # Visit http://www.olsr.org for more information.
    33 #
    34 # If you find this software useful feel free to make a donation
    35 # to the project. For more information see the website or contact
    36 # the copyright holders.
    37 #
    38 
    39 # Please also write a new version to:
    40 # gui/win32/Main/Frontend.rc (line 71, around "CAPTION [...]")
    41 # gui/win32/Inst/installer.nsi (line 57, around "MessageBox MB_YESNO [...]")
    42 VERS =		pre-0.5.7
    43 
    44 TOPDIR = .
    45 include Makefile.inc
    46 
    47 # pass generated variables to save time
    48 MAKECMD = $(MAKE) OS="$(OS)" WARNINGS="$(WARNINGS)"
    49 
    50 LIBS +=		$(OS_LIB_DYNLOAD)
    51 
    52 ifeq ($(OS), win32)
    53 LDFLAGS +=	-Wl,--out-implib=libolsrd.a
    54 LDFLAGS +=	-Wl,--export-all-symbols
    55 endif
    56 
    57 TAG_SRCS =	$(SRCS) $(HDRS)
    58 
    59 .PHONY: default_target
    60 default_target: $(EXENAME)
    61 
    62 $(EXENAME):	$(OBJS) src/builddata.o
    63 ifeq ($(LD_HAS_DYN), yes)
    64 		$(SHELL) olsrd-exports.sh $$(find src -name "*.h") > $(EXENAME).exports
    65 endif
    66 		$(CC) $(LDFLAGS) $(LDFLAGS_EXE) -o $@ $^ $(LIBS)
    67 
    68 CONFDIR = src/config
    69 include $(CONFDIR)/local.mk
    70 
    71 show-ignored-warnings:
    72 	CC="$(CC)" $(TOPDIR)/gcc-warnings $(ALL_WARNINGS) > /dev/null
    73 
    74 # generate it always
    75 .PHONY: src/builddata.c
    76 src/builddata.c:
    77 	@$(RM) "$@"
    78 	@echo "#include \"defs.h\"" >> "$@"
    79 	@echo "const char olsrd_version[] = \"olsr.org - $(VERS)`hg log -r tip|grep changeset|sed -e s/changeset:\ */\ changeset\ /`\";"  >> "$@"
    80 	@date +"const char build_date[] = \"%Y-%m-%d %H:%M:%S\";" >> "$@"
    81 	@echo "const char build_host[] = \"$(shell hostname)\";" >> "$@"
    82 
    83 
    84 .PHONY: help libs clean_libs libs_clean clean uberclean install_libs libs_install install_bin install_olsrd install build_all install_all clean_all
    85 
    86 clean:
    87 	-rm -f $(OBJS) $(SRCS:%.c=%.d) $(EXENAME) $(EXENAME).exe src/builddata.c $(TMPFILES)
    88 	-rm -f $(EXENAME).exports
    89 ifeq ($(OS), win32)
    90 	-rm -f libolsrd.a
    91 	-rm -f gui/win32/Main/olsrd_cfgparser.lib
    92 	-rm -f olsr-setup.exe
    93 	-rm -fr gui/win32/Main/Release
    94 	-rm -fr gui/win32/Shim/Release
    95 endif
    96 
    97 install: install_olsrd
    98 
    99 install_bin:
   100 		mkdir -p '$(SBINDIR)'
   101 		install -m 755 '$(EXENAME)' '$(SBINDIR)'
   102 		$(STRIP) '$(SBINDIR)/$(EXENAME)'
   103 
   104 install_olsrd:	install_bin
   105 		@echo '========= C O N F I G U R A T I O N - F I L E ============'
   106 		@echo '$(EXENAME) uses the configfile $(CFGFILE)'
   107 		@echo 'a default configfile. A sample RFC-compliance aimed'
   108 		@echo 'configfile can be found in olsrd.conf.default.rfc.'
   109 		@echo 'However none of the larger OLSRD using networks use that'
   110 		@echo 'so install a configfile with activated link quality exstensions'
   111 		@echo 'per default.'
   112 		@echo 'can be found at files/olsrd.conf.default.lq'
   113 		@echo '=========================================================='
   114 		mkdir -p '$(ETCDIR)'
   115 		-cp -i 'files/olsrd.conf.default.lq' '$(CFGFILE)'
   116 		@echo '-------------------------------------------'
   117 		@echo 'Edit $(CFGFILE) before running olsrd!!'
   118 		@echo '-------------------------------------------'
   119 		@echo 'Installing manpages $(EXENAME)(8) and $(CFGNAME)(5)'
   120 		mkdir -p '$(MANDIR)/man3'
   121 		cp 'files/olsrd-metrics.3.gz' '$(MANDIR)/man3/olsrd-metrics.3.gz'
   122 		mkdir -p '$(MANDIR)/man5'
   123 		cp 'files/olsrd.conf.5.gz' '$(MANDIR)/man5/$(CFGNAME).5.gz'
   124 		mkdir -p '$(MANDIR)/man8'
   125 		cp 'files/olsrd.8.gz' '$(MANDIR)/man8/$(EXENAME).8.gz'
   126 
   127 tags:
   128 		$(TAGCMD) -o $(TAGFILE) $(TAG_SRCS)
   129 
   130 RPMVER = $(patsubst pre-%,%pre,$(VERS))
   131 RPMDIR = ../olsrd-$(RPMVER)
   132 RPMRELEASE = $(shell hg tip | { read tag val && echo "$$val"; })
   133 redhat/olsrd.spec: redhat/olsrd.spec.in Makefile Makefile.inc
   134 	@sed -e 's/@VERSION@/$(RPMVER)/' -e 's/@RELEASE@/$(RPMRELEASE)/' < "$<" > "$@"
   135 
   136 rpm: redhat/olsrd.spec
   137 	@echo "Creating $(RPMDIR).tar.bz2 ..."
   138 	@hg archive --type "tar" "$(RPMDIR).tar"
   139 	@tar --file "$(RPMDIR).tar" --append "$<"
   140 	@echo "Building RPMs..."
   141 	@rpmbuild -ta "$(RPMDIR).tar"
   142 	@bzip2 --best --force "$(RPMDIR).tar"
   143 
   144 #
   145 # PLUGINS
   146 #
   147 
   148 # This is quite ugly but at least it works
   149 ifeq ($(OS),linux)
   150 SUBDIRS = $(notdir $(shell find lib -maxdepth 2 -name Makefile -not -path lib/Makefile -printf "%h\n"|sort))
   151 else
   152 ifeq ($(OS),win32)
   153 SUBDIRS := dot_draw httpinfo lq_etx_ff lq_etx_float lq_etx_fpm lq_rfc mini secure txtinfo watchdog
   154 else
   155 SUBDIRS := bmf dot_draw dyn_gw dyn_gw_plain httpinfo lq_etx_ff lq_etx_float lq_etx_fpm lq_rfc mdns mini nameservice secure txtinfo watchdog
   156 endif
   157 endif
   158 
   159 libs:
   160 		set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR);done
   161 
   162 libs_clean clean_libs:
   163 		-for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) clean;done
   164 ifeq ($(OS), win32)
   165 		-rm -f lib/txtinfo/olsrd_txtinfo.dll
   166 		-rm -f lib/httpinfo/olsrd_httpinfo.dll
   167 		-rm -f lib/secure/olsrd_secure.dll
   168 		-rm -f lib/dot_draw/olsrd_dot_draw.dll
   169 		-rm -f lib/mini/olsrd_mini.dll
   170 endif
   171 
   172 libs_install install_libs:
   173 		set -e;for dir in $(SUBDIRS);do $(MAKECMD) -C lib/$$dir LIBDIR=$(LIBDIR) install;done
   174 
   175 httpinfo:
   176 		$(MAKECMD) -C lib/httpinfo clean
   177 		$(MAKECMD) -C lib/httpinfo
   178 		$(MAKECMD) -C lib/httpinfo DESTDIR=$(DESTDIR) install
   179 
   180 dot_draw:
   181 		$(MAKECMD) -C lib/dot_draw clean
   182 		$(MAKECMD) -C lib/dot_draw
   183 		$(MAKECMD) -C lib/dot_draw DESTDIR=$(DESTDIR) install
   184 
   185 nameservice:
   186 		$(MAKECMD) -C lib/nameservice clean
   187 		$(MAKECMD) -C lib/nameservice
   188 		$(MAKECMD) -C lib/nameservice DESTDIR=$(DESTDIR) install
   189 
   190 dyn_gw:
   191 		$(MAKECMD) -C lib/dyn_gw clean
   192 		$(MAKECMD) -C lib/dyn_gw
   193 		$(MAKECMD) -C lib/dyn_gw DESTDIR=$(DESTDIR) install
   194 
   195 dyn_gw_plain:
   196 		$(MAKECMD) -C lib/dyn_gw_plain clean
   197 		$(MAKECMD) -C lib/dyn_gw_plain
   198 		$(MAKECMD) -C lib/dyn_gw_plain DESTDIR=$(DESTDIR) install
   199 
   200 secure:
   201 		$(MAKECMD) -C lib/secure clean
   202 		$(MAKECMD) -C lib/secure
   203 		$(MAKECMD) -C lib/secure DESTDIR=$(DESTDIR) install
   204 
   205 bmf:
   206 		$(MAKECMD) -C lib/bmf clean
   207 		$(MAKECMD) -C lib/bmf
   208 		$(MAKECMD) -C lib/bmf DESTDIR=$(DESTDIR) install
   209 
   210 mdns:
   211 		$(MAKECMD) -C lib/mdns clean
   212 		$(MAKECMD) -C lib/mdns
   213 		$(MAKECMD) -C lib/mdns DESTDIR=$(DESTDIR) install
   214 quagga:
   215 		$(MAKECMD) -C lib/quagga clean
   216 		$(MAKECMD) -C lib/quagga
   217 		$(MAKECMD) -C lib/quagga DESTDIR=$(DESTDIR) install
   218 
   219 txtinfo:
   220 		$(MAKECMD) -C lib/txtinfo clean
   221 		$(MAKECMD) -C lib/txtinfo
   222 		$(MAKECMD) -C lib/txtinfo DESTDIR=$(DESTDIR) install
   223 
   224 arprefresh:
   225 		$(MAKECMD) -C lib/arprefresh clean
   226 		$(MAKECMD) -C lib/arprefresh
   227 		$(MAKECMD) -C lib/arprefresh DESTDIR=$(DESTDIR) install
   228 
   229 watchdog:
   230 		$(MAKECMD) -C lib/watchdog clean
   231 		$(MAKECMD) -C lib/watchdog
   232 		$(MAKECMD) -C lib/watchdog DESTDIR=$(DESTDIR) install
   233 
   234 build_all:	all libs config-verify
   235 install_all:	install install_libs config-verify_install
   236 clean_all:	clean clean_libs config-verify_clean
   237 
   238 uberclean: clean_all
   239 	-rm -f $(TAGFILE)
   240 #	BSD-xargs has no "--no-run-if-empty" aka "-r"
   241 	find . \( -name '*.[od]' -o -name '*~' \) -not -path "*/.hg*" -print0 | xargs -0 rm -f