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 ######################
23 # Lowlevel options and rules
27 CCACHE ?= $(shell IFS=:; for i in $$PATH;do test -x "$$i/ccache" && echo "$$i/ccache" && break; done)
28 ifeq ($(origin CC),default)
42 # target directories and names
44 SBINDIR ?= $(DESTDIR)/usr/sbin
45 ETCDIR ?= $(DESTDIR)/etc
46 LIBDIR ?= $(DESTDIR)/usr/lib
47 DOCDIR ?= $(DESTDIR)/usr/share/doc
48 MANDIR ?= $(DESTDIR)/usr/share/man
50 CFGNAME ?= $(EXENAME).conf
51 CFGFILE ?= $(ETCDIR)/$(CFGNAME)
55 CPPFLAGS += -I$(TOPDIR)/src
58 # add gcc warnings and optimizations if CFLAGS not set
63 WARNINGS += -Wold-style-definition
64 WARNINGS += -Wdeclaration-after-statement
65 WARNINGS += -Wmissing-prototypes
66 WARNINGS += -Wstrict-prototypes
67 WARNINGS += -Wmissing-declarations
68 WARNINGS += -Wsign-compare
69 WARNINGS += -Waggregate-return
70 WARNINGS += -Wmissing-noreturn
71 WARNINGS += -Wmissing-format-attribute
72 WARNINGS += -Wno-multichar
73 WARNINGS += -Wno-deprecated-declarations
74 WARNINGS += -Wendif-labels
75 WARNINGS += -Wwrite-strings
76 WARNINGS += -Wbad-function-cast
77 WARNINGS += -Wpointer-arith
78 WARNINGS += -Wcast-qual
80 WARNINGS += -Wformat-2
81 WARNINGS += -Wsequence-point
82 WARNINGS += -Wpointer-arith
83 WARNINGS += -Wcast-align
84 # the following 2 do not work yet and need more work on it
85 #WARNINGS += -Wconversion
86 #WARNINGS += -Wredundant-decls
88 # work around a bug in gcc-4.*
89 WARNINGS += -Wnested-externs
91 # Alas, htons() triggers this so we can't seriously activate it.
92 #WARNINGS += -Wunreachable-code
94 WARNINGS += -Wdisabled-optimization
96 WARNINGS += -finline-functions-called-once
97 WARNINGS += -funit-at-a-time
98 WARNINGS += -fearly-inlining
100 WARNINGS += -fomit-frame-pointer
102 # we have small inline functions in src/lq_route.h which should always be inlined
103 WARNINGS += -finline-limit=350
104 # These tell gcc to put each function and global variable in a separate section.
105 # The linker can than remove all unreferenced section. But in the olsrd binary
106 # unused doesn't imply unused at all since the function may be used by plugins,
107 # e.g. the ones in src/plugin_utils.c.
108 # So we can use that featuer at most to identify unused functions and remove them
109 # from the source by hand.
110 #WARNINGS += -ffunction-sections
111 #WARNINGS += -fdata-sections
112 WARNINGS := $(shell CC="$(CC)" $(TOPDIR)/gcc-warnings $(WARNINGS))
114 CFLAGS += $(WARNINGS)
115 CFLAGS += $(OPTIMIZE)
116 CFLAGS += $(EXTRA_CFLAGS)
118 # Must be specified along with -lpthread on linux
119 CPPFLAGS += $(OS_CFLAG_PTHREAD)
122 CFLAGS += -fmudflapth
126 # c and ld flags for libraries (plugins)
127 CPPFLAGS += -DOLSR_PLUGIN
129 LDFLAGS += -Wl,-soname,$(PLUGIN_NAME)
130 LDFLAGS += -Wl,--version-script=version-script.txt
132 # c and ld flags for main
133 LDFLAGS += -Wl,-export-dynamic
134 LDFLAGS += -Wl,-rpath,$(LIBDIR)
137 LDFLAGS += -Wl,--warn-common
138 # See above at "-ffunction-sections" for an explanation (and why it is disabled).
139 #LDOPTS += -Wl,--gc-sections
140 #LDOPTS += -Wl,--print-gc-sections
141 #LDFLAGS += $(shell CC="$(CC)" $(TOPDIR)/ld-warnings $(LDOPTS))
145 LIBS += $(OS_LIB_PTHREAD)
147 # extra options from the outside
148 CPPFLAGS += $(EXTRA_CPPFLAGS)
150 ###################################
152 # options to save space on small systems
154 # we have plugins with the old interface
155 #CPPFLAGS += -DSUPPORT_OLD_PLUGIN_VERSIONS=1
157 # use the new fixed point math stuff
158 CPPFLAGS += -DUSE_FPM
160 # search sources and headers in current dir and in src/
161 SRCS += $(wildcard src/common/*.c src/*.c *.c)
162 HDRS += $(wildcard src/common/*.h src/*.h *.h)
165 ifeq ($(OS),Windows_NT)
169 OS := $(shell sh $(TOPDIR)/make/guess_os.sh)
174 # include OS specifics
176 include $(TOPDIR)/make/Makefile.$(OS)
179 # one object for each source file
180 OBJS += $(SRCS:%.c=%.o)
182 # debugging or non-debugging flags
189 ifeq ($(NO_DEBUG_MESSAGES),1)
190 CPPFLAGS += -DNODEBUG
193 # a make function to quote "/" and "."
194 quote = $(subst .,\.,$(subst /,\/,$1))
196 # fully automatic and working dependency generation
198 @$(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' >"$@"
200 # we always need the includes and defines
201 # for legacy since now
202 CPPFLAGS += $(INCLUDES) $(DEFINES)
204 $(warning Use CPPFLAGS instead of INCLUDES for -I)
207 $(warning Use CPPFLAGS instead of DEFINES for -D)
214 @echo '***** olsr.org olsr daemon Make ****'
215 @echo ' Automatic detection of your OS '
217 @echo ' You can provide a valid target OS '
218 @echo ' by setting the OS variable! Valid '
219 @echo ' target OSes are: '
220 @echo ' --------------------------------- '
221 @echo ' linux - GNU/Linux '
222 @echo ' win32 - MS Windows '
223 @echo ' fbsd - FreeBSD '
224 @echo ' nbsd - NetBSD '
225 @echo ' obsd - OpenBSD '
226 @echo ' osx - Mac OS X '
227 @echo ' --------------------------------- '
228 @echo ' Example - build for windows: '
229 @echo ' make OS=win32 '
230 @echo ' If you are developing olsrd code, '
231 @echo ' exporting the OS variable might '
232 @echo ' be a good idea :-) Have fun! '
233 @echo '************************************'
236 ifeq ($(filter clean% %clean, $(MAKECMDGOALS)),)
237 # include dependencies - we don't need any dependency for a everytime generated files
238 -include $(filter-out src/builddata.%,$(SRCS:%.c=%.d))