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