3 # Highlevel configuration options for all
7 # activate debugging with 1 or deactivate with 0
10 # compile OLSR_PRINTF out
11 NO_DEBUG_MESSAGES ?= 0
13 # the optimize option to be set for gcc
16 # enable mudflap with 1 or deactivate with 0
17 # you need a recent enough gcc and the libmudflap installed
21 ifeq ($(OS),Windows_NT)
25 OS := $(shell sh $(TOPDIR)/make/guess_os.sh)
28 ######################
30 # Lowlevel options and rules
34 CCACHE ?= $(shell IFS=:; for i in $$PATH;do test -x "$$i/ccache" && echo "$$i/ccache" && break; done)
35 ifeq ($(origin CC),default)
49 # target directories and names
51 SBINDIR ?= $(DESTDIR)/usr/sbin
52 ETCDIR ?= $(DESTDIR)/etc
53 LIBDIR ?= $(DESTDIR)/usr/lib
54 DOCDIR ?= $(DESTDIR)/usr/share/doc
55 MANDIR ?= $(DESTDIR)/usr/share/man
57 CFGNAME ?= $(EXENAME).conf
58 CFGFILE ?= $(ETCDIR)/$(CFGNAME)
62 CPPFLAGS += -I$(TOPDIR)/src
65 # add gcc warnings and optimizations if CFLAGS not set
70 WARNINGS += -Wold-style-definition
71 WARNINGS += -Wdeclaration-after-statement
72 WARNINGS += -Wmissing-prototypes
73 WARNINGS += -Wstrict-prototypes
74 WARNINGS += -Wmissing-declarations
75 WARNINGS += -Wsign-compare
76 WARNINGS += -Waggregate-return
77 WARNINGS += -Wmissing-noreturn
78 WARNINGS += -Wmissing-format-attribute
79 WARNINGS += -Wno-multichar
80 WARNINGS += -Wno-deprecated-declarations
81 WARNINGS += -Wendif-labels
82 WARNINGS += -Wwrite-strings
83 WARNINGS += -Wbad-function-cast
84 WARNINGS += -Wpointer-arith
85 WARNINGS += -Wcast-qual
87 WARNINGS += -Wformat-2
88 WARNINGS += -Wsequence-point
89 WARNINGS += -Wpointer-arith
90 WARNINGS += -Wcast-align
91 # the following 2 do not work yet and need more work on it
92 #WARNINGS += -Wconversion
93 #WARNINGS += -Wredundant-decls
95 # work around a bug in gcc-4.*
96 WARNINGS += -Wnested-externs
98 # Alas, htons() triggers this so we can't seriously activate it.
99 #WARNINGS += -Wunreachable-code
101 WARNINGS += -Wdisabled-optimization
103 WARNINGS += -finline-functions-called-once
104 WARNINGS += -funit-at-a-time
105 WARNINGS += -fearly-inlining
107 WARNINGS += -fomit-frame-pointer
109 # we have small inline functions in src/lq_route.h which should always be inlined
110 WARNINGS += -finline-limit=350
111 # These tell gcc to put each function and global variable in a separate section.
112 # The linker can than remove all unreferenced section. But in the olsrd binary
113 # unused doesn't imply unused at all since the function may be used by plugins,
114 # e.g. the ones in src/plugin_utils.c.
115 # So we can use that featuer at most to identify unused functions and remove them
116 # from the source by hand.
117 #WARNINGS += -ffunction-sections
118 #WARNINGS += -fdata-sections
119 WARNINGS := $(shell CC="$(CC)" $(TOPDIR)/gcc-warnings $(WARNINGS))
121 CFLAGS += $(WARNINGS)
122 CFLAGS += $(OPTIMIZE)
123 CFLAGS += $(EXTRA_CFLAGS)
125 # Must be specified along with -lpthread on linux
126 CPPFLAGS += $(OS_CFLAG_PTHREAD)
129 CFLAGS += -fmudflapth
133 # c and ld flags for libraries (plugins)
134 CPPFLAGS += -DOLSR_PLUGIN
136 LDFLAGS += -Wl,-export-all-symbols,--enable-auto-import
139 LDFLAGS += -Wl,-soname,$(PLUGIN_NAME)
140 LDFLAGS += -Wl,--version-script=version-script.txt
142 # c and ld flags for main
144 LDFLAGS += -Wl,-export-all-symbols
146 LDFLAGS += -Wl,-export-dynamic
148 LDFLAGS += -Wl,-rpath,$(LIBDIR)
151 LDFLAGS += -Wl,--warn-common
152 # See above at "-ffunction-sections" for an explanation (and why it is disabled).
153 #LDOPTS += -Wl,--gc-sections
154 #LDOPTS += -Wl,--print-gc-sections
155 #LDFLAGS += $(shell CC="$(CC)" $(TOPDIR)/ld-warnings $(LDOPTS))
159 LIBS += $(OS_LIB_PTHREAD)
161 # extra options from the outside
162 CPPFLAGS += $(EXTRA_CPPFLAGS)
164 ###################################
166 # options to save space on small systems
168 # we have plugins with the old interface
169 #CPPFLAGS += -DSUPPORT_OLD_PLUGIN_VERSIONS=1
171 # use the new fixed point math stuff
172 CPPFLAGS += -DUSE_FPM
174 # search sources and headers in current dir and in src/
175 SRCS += $(wildcard src/common/*.c src/*.c *.c)
176 HDRS += $(wildcard src/common/*.h src/*.h *.h)
181 # include OS specifics
183 include $(TOPDIR)/make/Makefile.$(OS)
186 # one object for each source file
187 OBJS += $(SRCS:%.c=%.o)
189 # debugging or non-debugging flags
196 ifeq ($(NO_DEBUG_MESSAGES),1)
197 CPPFLAGS += -DNODEBUG
200 # a make function to quote "/" and "."
201 quote = $(subst .,\.,$(subst /,\/,$1))
203 # fully automatic and working dependency generation
205 @$(filter-out $(CCACHE),$(CC)) -M $(strip $(CPPFLAGS)) "$<" | sed -e '1s/\($(call quote,$(*F))\.o\)[ :]*/$(call quote,$(*D)/\1 $@: Makefile $(TOPDIR)$(if $(TOPDIR),/)Makefile.inc) /g' >"$@"
207 # we always need the includes and defines
208 # for legacy since now
209 CPPFLAGS += $(INCLUDES) $(DEFINES)
211 $(warning Use CPPFLAGS instead of INCLUDES for -I)
214 $(warning Use CPPFLAGS instead of DEFINES for -D)
221 @echo '***** olsr.org olsr daemon Make ****'
222 @echo ' Automatic detection of your OS '
224 @echo ' You can provide a valid target OS '
225 @echo ' by setting the OS variable! Valid '
226 @echo ' target OSes are: '
227 @echo ' --------------------------------- '
228 @echo ' linux - GNU/Linux '
229 @echo ' win32 - MS Windows '
230 @echo ' fbsd - FreeBSD '
231 @echo ' nbsd - NetBSD '
232 @echo ' obsd - OpenBSD '
233 @echo ' osx - Mac OS X '
234 @echo ' --------------------------------- '
235 @echo ' Example - build for windows: '
236 @echo ' make OS=win32 '
237 @echo ' If you are developing olsrd code, '
238 @echo ' exporting the OS variable might '
239 @echo ' be a good idea :-) Have fun! '
240 @echo '************************************'
243 ifeq ($(filter clean% %clean, $(MAKECMDGOALS)),)
244 # include dependencies - we don't need any dependency for a everytime generated files
245 -include $(filter-out src/builddata.%,$(SRCS:%.c=%.d))