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
79 # the following 5 do not work yet and need more work on it
81 #WARNINGS += -Wpointer-arith
82 #WARNINGS += -Wcast-align
83 #WARNINGS += -Wconversion
84 #WARNINGS += -Wredundant-decls
86 # work around a bug in gcc-4.*
87 WARNINGS += -Wnested-externs
89 # Alas, htons() triggers this so we can't seriously activate it.
90 #WARNINGS += -Wunreachable-code
92 WARNINGS += -Wdisabled-optimization
94 WARNINGS += -finline-functions-called-once
95 WARNINGS += -fearly-inlining
97 WARNINGS += -fomit-frame-pointer
99 # we have small inline functions in src/lq_route.h which should always be inlined
100 WARNINGS += -finline-limit=350
101 # These tell gcc to put each function and global variable in a separate section.
102 # The linker can than remove all unreferenced section. But in the olsrd binary
103 # unused doesn't imply unused at all since the function may be used by plugins,
104 # e.g. the ones in src/plugin_utils.c.
105 # So we can use that featuer at most to identify unused functions and remove them
106 # from the source by hand.
107 #WARNINGS += -ffunction-sections
108 #WARNINGS += -fdata-sections
109 WARNINGS := $(shell CC="$(CC)" $(TOPDIR)/gcc-warnings $(WARNINGS))
111 CFLAGS += $(WARNINGS)
112 CFLAGS += $(OPTIMIZE)
113 CFLAGS += $(EXTRA_CFLAGS)
115 # Must be specified along with -lpthread on linux
116 CPPFLAGS += $(OS_CFLAG_PTHREAD)
119 CFLAGS += -fmudflapth
123 # c and ld flags for libraries (plugins)
124 CPPFLAGS += -DOLSR_PLUGIN
126 LDFLAGS += -Wl,-soname,$(PLUGIN_NAME)
127 LDFLAGS += -Wl,--version-script=version-script.txt
129 # c and ld flags for main
130 LDFLAGS += -Wl,-export-dynamic
131 LDFLAGS += -Wl,-rpath,$(LIBDIR)
134 LDFLAGS += -Wl,--warn-common
135 # See above at "-ffunction-sections" for an explanation (and why it is disabled).
136 #LDOPTS += -Wl,--gc-sections
137 #LDOPTS += -Wl,--print-gc-sections
138 #LDFLAGS += $(shell CC="$(CC)" $(TOPDIR)/ld-warnings $(LDOPTS))
142 LIBS += $(OS_LIB_PTHREAD)
144 # extra options from the outside
145 CPPFLAGS += $(EXTRA_CPPFLAGS)
147 ###################################
149 # options to save space on small systems
151 # we have plugins with the old interface
152 #CPPFLAGS += -DSUPPORT_OLD_PLUGIN_VERSIONS=1
154 # use the new fixed point math stuff
155 CPPFLAGS += -DUSE_FPM
157 # search sources and headers in current dir and in src/
158 SRCS += $(wildcard src/common/*.c src/*.c *.c)
159 HDRS += $(wildcard src/common/*.h src/*.h *.h)
162 ifeq ($(OS),Windows_NT)
166 OS := $(shell sh $(TOPDIR)/make/guess_os.sh)
171 # include OS specifics
173 include $(TOPDIR)/make/Makefile.$(OS)
176 # one object for each source file
177 OBJS += $(SRCS:%.c=%.o)
179 # debugging or non-debugging flags
186 ifeq ($(NO_DEBUG_MESSAGES),1)
187 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))