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 ETCDIR ?= $(DESTDIR)/etc
52 USRDIR ?= $(DESTDIR)/usr
53 INCLUDEDIR ?= $(DESTDIR)/usr/include
54 LIBDIR ?= $(USRDIR)/lib
55 SBINDIR ?= $(USRDIR)/sbin
56 SHAREDIR ?= $(USRDIR)/share
57 DOCDIR ?= $(SHAREDIR)/doc
58 MANDIR ?= $(SHAREDIR)/man
60 CFGNAME ?= $(EXENAME).conf
61 CFGFILE ?= $(ETCDIR)/$(CFGNAME)
63 DOCDIR_OLSRD ?= $(DOCDIR)/$(EXENAME)
68 CPPFLAGS += -I$(TOPDIR)/src
71 # add gcc warnings and optimizations if CFLAGS not set
76 WARNINGS += -Wold-style-definition
77 WARNINGS += -Wdeclaration-after-statement
78 WARNINGS += -Wmissing-prototypes
79 WARNINGS += -Wstrict-prototypes
80 WARNINGS += -Wmissing-declarations
81 WARNINGS += -Wsign-compare
82 WARNINGS += -Waggregate-return
83 WARNINGS += -Wmissing-noreturn
84 WARNINGS += -Wmissing-format-attribute
85 WARNINGS += -Wno-multichar
86 WARNINGS += -Wno-deprecated-declarations
87 WARNINGS += -Wendif-labels
88 WARNINGS += -Wwrite-strings
89 WARNINGS += -Wbad-function-cast
90 WARNINGS += -Wpointer-arith
91 WARNINGS += -Wcast-qual
94 WARNINGS += -Wsequence-point
95 WARNINGS += -Wcast-align
96 WARNINGS += -Wformat-security
97 WARNINGS += -Wformat-y2k
98 WARNINGS += -Winit-self
99 WARNINGS += -Wswitch-default
100 WARNINGS += -Wsync-nand
102 WARNINGS += -Wlogical-op
103 ifneq ($(OS),android)
104 WARNINGS += -Wdouble-promotion
105 WARNINGS += -Wjump-misses-init
106 WARNINGS += -Wtrampolines
108 WARNINGS += -Wunused-parameter
109 # the following 2 do not work yet and need more work on it
110 #WARNINGS += -Wconversion
111 #WARNINGS += -Wredundant-decls
113 # work around a bug in gcc-4.*
114 WARNINGS += -Wnested-externs
116 # Alas, htons() triggers this so we can't seriously activate it.
117 #WARNINGS += -Wunreachable-code
119 WARNINGS += -Wdisabled-optimization
120 # WARNINGS += -Werror
121 WARNINGS += -finline-functions-called-once
122 WARNINGS += -funit-at-a-time
123 WARNINGS += -fearly-inlining
125 WARNINGS += -fomit-frame-pointer
127 # we have small inline functions in src/lq_route.h which should always be inlined
128 WARNINGS += -finline-limit=350
129 # These tell gcc to put each function and global variable in a separate section.
130 # The linker can than remove all unreferenced section. But in the olsrd binary
131 # unused doesn't imply unused at all since the function may be used by plugins,
132 # e.g. the ones in src/plugin_utils.c.
133 # So we can use that featuer at most to identify unused functions and remove them
134 # from the source by hand.
135 #WARNINGS += -ffunction-sections
136 #WARNINGS += -fdata-sections
137 WARNINGS := $(shell CC="$(CC)" "$(TOPDIR)/gcc-warnings" $(WARNINGS))
139 CFLAGS += $(WARNINGS)
140 CFLAGS += $(OPTIMIZE)
141 CFLAGS += $(EXTRA_CFLAGS)
143 # Must be specified along with -lpthread on linux
144 CPPFLAGS += $(OS_CFLAG_PTHREAD)
147 CFLAGS += -fmudflapth
151 # c and ld flags for libraries (plugins)
152 CPPFLAGS += -DOLSR_PLUGIN
154 LDFLAGS += -Wl,-export-all-symbols,--enable-auto-import
157 LDFLAGS += -Wl,-soname,$(PLUGIN_SONAME)
158 LDFLAGS += -Wl,--version-script=version-script.txt
160 # c and ld flags for main
162 LDFLAGS += -Wl,-export-all-symbols
164 LDFLAGS += -Wl,-export-dynamic
166 LDFLAGS += -Wl,-rpath,$(LIBDIR)
169 LDFLAGS += -Wl,--warn-common
170 # See above at "-ffunction-sections" for an explanation (and why it is disabled).
171 #LDOPTS += -Wl,--gc-sections
172 #LDOPTS += -Wl,--print-gc-sections
173 #LDFLAGS += $(shell CC="$(CC)" $(TOPDIR)/ld-warnings $(LDOPTS))
177 LIBS += $(OS_LIB_PTHREAD)
179 # extra options from the outside
180 CPPFLAGS += $(EXTRA_CPPFLAGS)
182 ###################################
184 # options to save space on small systems
186 # we have plugins with the old interface
187 #CPPFLAGS += -DSUPPORT_OLD_PLUGIN_VERSIONS=1
189 # use the new fixed point math stuff
190 CPPFLAGS += -DUSE_FPM
192 # search sources and headers in current dir and in src/
193 SRCS += $(wildcard src/common/*.c src/*.c *.c)
194 HDRS += $(wildcard src/common/*.h src/*.h *.h)
199 # include OS specifics
201 include $(TOPDIR)/make/Makefile.$(OS)
204 # one object for each source file
205 OBJS += $(SRCS:%.c=%.o)
207 # debugging or non-debugging flags
214 ifeq ($(NO_DEBUG_MESSAGES),1)
215 CPPFLAGS += -DNODEBUG
219 CPPFLAGS+=-DHTTPINFO_PUD -I$(TOPDIR)/lib -I$(TOPDIR)/lib/pud/nmealib/include -I$(TOPDIR)/lib/pud/wireformat/include
222 # a make function to quote "/" and "."
223 quote = $(subst .,\.,$(subst /,\/,$1))
225 # fully automatic and working dependency generation
227 @$(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' >"$@"
231 @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
233 # we always need the includes and defines
234 # for legacy since now
235 CPPFLAGS += $(INCLUDES) $(DEFINES)
237 $(warning Use CPPFLAGS instead of INCLUDES for -I)
240 $(warning Use CPPFLAGS instead of DEFINES for -D)
247 @echo '***** olsr.org olsr daemon Make ****'
248 @echo ' Automatic detection of your OS '
250 @echo ' You can provide a valid target OS '
251 @echo ' by setting the OS variable! Valid '
252 @echo ' target OSes are: '
253 @echo ' --------------------------------- '
254 @echo ' linux - GNU/Linux '
255 @echo ' win32 - MS Windows '
256 @echo ' fbsd - FreeBSD '
257 @echo ' nbsd - NetBSD '
258 @echo ' obsd - OpenBSD '
259 @echo ' osx - Mac OS X '
260 @echo ' android - Android '
261 @echo ' --------------------------------- '
262 @echo ' Example - build for windows: '
263 @echo ' make OS=win32 '
264 @echo ' If you are developing olsrd code, '
265 @echo ' exporting the OS variable might '
266 @echo ' be a good idea :-) Have fun! '
267 @echo '************************************'
270 ifeq ($(filter clean% %clean, $(MAKECMDGOALS)),)
271 # include dependencies - we don't need any dependency for a everytime generated files
272 -include $(filter-out src/builddata.%,$(SRCS:%.c=%.d))