3 # Highlevel configuration options for all
5 # $Id: Makefile.inc,v 1.43 2007/11/16 19:14:33 bernd67 Exp $
8 # activate debugging with 1 or deactivate with 0
11 # compile OLSR_PRINTF out
12 NO_DEBUG_MESSAGES ?= 0
14 # the optimize option to be set for gcc
17 # enable mudflap with 1 or deactivate with 0
18 # you need a recent enough gcc and the libmudflap installed
22 ######################
24 # Lowlevel options and rules
28 CCACHE ?= $(shell which ccache 2> /dev/null)
29 ifeq ($(origin CC),default)
43 # target directories and names
45 SBINDIR ?= $(DESTDIR)/usr/sbin
46 ETCDIR ?= $(DESTDIR)/etc
47 LIBDIR ?= $(DESTDIR)/usr/lib
48 DOCDIR ?= $(DESTDIR)/usr/share/doc
49 MANDIR ?= $(DESTDIR)/usr/share/man
51 CFGNAME ?= $(EXENAME).conf
52 CFGFILE ?= $(ETCDIR)/$(CFGNAME)
56 CPPFLAGS += -I$(TOPDIR)/src
59 # add gcc warnings and optimizations if CFLAGS not set
64 WARNINGS += -Wold-style-definition
65 WARNINGS += -Wdeclaration-after-statement
66 WARNINGS += -Wmissing-prototypes
67 WARNINGS += -Wstrict-prototypes
68 WARNINGS += -Wmissing-declarations
69 WARNINGS += -Wsign-compare
70 WARNINGS += -Waggregate-return
71 WARNINGS += -Wmissing-noreturn
72 WARNINGS += -Wmissing-format-attribute
73 WARNINGS += -Wno-multichar
74 WARNINGS += -Wno-deprecated-declarations
75 WARNINGS += -Wendif-labels
76 WARNINGS += -Wwrite-strings
77 #WARNINGS += -Wredundant-decls
79 # work around a bug in gcc-4.*
80 WARNINGS += -Wnested-externs
82 # Alas, htons() triggers this so we can't seriously activate it.
83 #WARNINGS += -Wunreachable-code
85 WARNINGS += -Wdisabled-optimization
87 WARNINGS += -finline-functions-called-once
88 WARNINGS += -fearly-inlining
90 WARNINGS += -fomit-framepointers
92 # we have small inline functions in src/lq_route.c which should always be inlined
93 WARNINGS += -finline-limit=50
94 WARNINGS := $(shell CC="$(CC)" $(TOPDIR)/gcc-warnings $(WARNINGS))
98 CFLAGS += $(EXTRA_CFLAGS)
100 # Must be specified along with -lpthread on linux
101 CPPFLAGS += $(OS_CFLAG_PTHREAD)
104 CFLAGS += -fmudflapth
108 # c and ld flags for libraries (plugins)
109 CPPFLAGS += -DOLSR_PLUGIN
110 LDFLAGS += -shared -Wl,-soname,$(PLUGIN_NAME)
111 LDFLAGS += -Wl,--version-script=version-script.txt
113 # c and ld flags for main
114 LDFLAGS += -Wl,-export-dynamic
119 LIBS += $(OS_LIB_PTHREAD)
121 ###################################
123 # options to save space on small systems
125 # we have plugins with the old interface
126 #CPPFLAGS += -DSUPPORT_OLD_PLUGIN_VERSIONS=1
128 # search sources and headers in current dir and in src/
129 SRCS += $(wildcard src/*.c *.c)
130 HDRS += $(wildcard src/*.h *.h)
133 ifeq ($(OS),Windows_NT)
137 OS := $(shell sh $(TOPDIR)/make/guess_os.sh)
142 # include OS specifics
144 include $(TOPDIR)/make/Makefile.$(OS)
147 # one object for each source file
148 OBJS += $(SRCS:%.c=%.o)
150 # debugging or non-debugging flags
157 ifeq ($(NO_DEBUG_MESSAGES),1)
158 CPPFLAGS += -DNODEBUG
161 # a make function to quote "/" and "."
162 quote = $(subst .,\.,$(subst /,\/,$1))
164 # fully automatic and working dependency generation
166 @$(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' >"$@"
168 # we always need the includes and defines
169 # for legacy since now
170 CPPFLAGS += $(INCLUDES) $(DEFINES)
172 $(warning Use CPPFLAGS instead of INCLUDES for -I)
175 $(warning Use CPPFLAGS instead of DEFINES for -D)
182 @echo '***** olsr.org olsr daemon Make ****'
183 @echo ' Automatic detection of your OS '
185 @echo ' You can provide a valid target OS '
186 @echo ' by setting the OS variable! Valid '
187 @echo ' target OSes are: '
188 @echo ' --------------------------------- '
189 @echo ' linux - GNU/Linux '
190 @echo ' win32 - MS Windows '
191 @echo ' fbsd - FreeBSD '
192 @echo ' nbsd - NetBSD '
193 @echo ' obsd - OpenBSD '
194 @echo ' osx - Mac OS X '
195 @echo ' --------------------------------- '
196 @echo ' Example - build for windows: '
197 @echo ' make OS=win32 '
198 @echo ' If you are developing olsrd code, '
199 @echo ' exporting the OS variable might '
200 @echo ' be a good idea :-) Have fun! '
201 @echo '************************************'
204 ifeq ($(filter clean% %clean, $(MAKECMDGOALS)),)
205 # include dependencies - we don't need any dependency for a everytime generated files
206 -include $(filter-out src/builddata.%,$(SRCS:%.c=%.d))