1 # netsniff-ng build system
2 # Copyright 2012 - 2013 Daniel Borkmann <borkmann@gnumaniacs.org>
3 # Copyright 2013 - 2015 Tobias Klauser <tklauser@distanz.ch>
4 # Subject to the GNU GPL, version 2.
13 $(error
"Please run `./configure' before `make'")
22 TOOLS ?
= $(CONFIG_TOOLS
)
23 TOOLS ?
= netsniff-ng trafgen astraceroute flowtop ifpps bpfc curvetun mausezahn
25 # For packaging purposes, prefix can define a different path.
28 # Set to use ccache for compilation
31 # Location of an alternative destination directory for installation
32 # Useful when cross-compiling and installing in a dedicated target directory
35 # Location of installation paths.
36 SBINDIR
= $(PREFIX
)/sbin
37 INCDIR
= $(PREFIX
)/include
39 ETCDIRE
= $(ETCDIR
)/netsniff-ng
40 MAN8DIR
= $(PREFIX
)/share
/man
/man8
42 # Shut up make, helper warnings, parallel compilation!
43 MAKEFLAGS
+= --no-print-directory
45 MAKEFLAGS
+= --warn-undefined-variables
46 MAKEFLAGS
+= --jobs
=$(shell grep
"^processor" /proc
/cpuinfo | wc
-l
)
49 ifeq ("$(origin DEBUG)", "command line")
52 ifeq ($(CONFIG_DEBUG
), 1)
61 ifeq ($(shell $(CC
) -v
2>&1 | grep
-c
"clang version"), 1)
69 # For packaging purposes, you might want to call your own:
70 # make CFLAGS="<flags>"
71 CFLAGS_DEF
= -std
=gnu99
77 CFLAGS_DEF
+= -fno-omit-frame-pointer
80 CFLAGS_DEF
+= -fomit-frame-pointer
81 CFLAGS_DEF
+= -fno-strict-aliasing
82 CFLAGS_DEF
+= -fasynchronous-unwind-tables
83 ifneq ($(COMPILER
), clang
)
84 CFLAGS_DEF
+= -fno-delete-null-pointer-checks
88 ifeq ($(HARDENING
), 1)
89 CFLAGS_DEF
+= -fPIE
-pie
90 CFLAGS_DEF
+= -Wl
,-z
,relro
,-z
,now
91 CFLAGS_DEF
+= -fstack-protector-all
92 CFLAGS_DEF
+= -Wstack-protector
93 CFLAGS_DEF
+= --param
=ssp-buffer-size
=4
95 CFLAGS_DEF
+= -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE
=2
96 CFLAGS_DEF
+= -fexceptions
99 CFLAGS_MIN
= -D_REENTRANT
100 CFLAGS_MIN
+= -D_LARGEFILE_SOURCE
101 CFLAGS_MIN
+= -D_LARGEFILE64_SOURCE
102 CFLAGS_MIN
+= -D_FILE_OFFSET_BITS
=64
103 CFLAGS_MIN
+= -DVERSION_STRING
=\"$(VERSION_STRING
)\"
104 CFLAGS_MIN
+= -DVERSION_LONG
=\"$(VERSION_LONG
)\"
105 CFLAGS_MIN
+= -DETCDIRE_STRING
=\"$(ETCDIRE
)\"
110 CFLAGS ?
= $(CFLAGS_DEF
) $(WFLAGS_DEF
) $(CPPFLAGS
)
111 override CFLAGS
+= $(CFLAGS_MIN
) -I.
117 ifeq ("$(origin CROSS_LD_LIBRARY_PATH)", "command line")
118 LDFLAGS
+= -L
$(CROSS_LD_LIBRARY_PATH
)
121 CHECKFLAGS
= -D__linux__
-Dlinux
-D__STDC__
-Dunix
-D__unix \
122 -Wbitwise
-Wnoreturn-void
124 VERSION_SHORT
= $(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
)$(EXTRAVERSION
)
125 VERSION_STRING
= "$(VERSION_SHORT)$(CONFIG_RC)"
126 VERSION_LONG
= "$(VERSION_SHORT)$(CONFIG_RC) ($(NAME))"
128 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION
129 export DEBUG HARDENING
131 ifneq ("$(TERM)", "")
132 bold
= $(shell tput bold
)
133 normal
= $(shell tput sgr0
)
139 ifneq ("$(CROSS_COMPILE)", "")
140 WHAT
:= Cross-compiling
146 $(Q
)echo
"$(bold)$(WHAT) netsniff-ng toolkit ($(VERSION_STRING)) for" \
147 $(shell $(CCNQ
) -dumpmachine
)":$(normal)"
149 $(Q
)echo
"$(bold)Cleaning netsniff-ng toolkit ($(VERSION_STRING)):$(normal)"
151 .PHONY
: all toolkit
$(TOOLS
) clean %_prehook
%_clean
%_install
%_uninstall tag
tags cscope
152 .IGNORE
: %_clean_custom
%_install_custom
153 .NOTPARALLEL
: $(TOOLS
)
158 all: build_showinfo toolkit
159 allbutcurvetun
: $(filter-out curvetun
,$(TOOLS
))
160 allbutmausezahn
: $(filter-out mausezahn
,$(TOOLS
))
162 clean: $(foreach tool
,$(TOOLS
),$(tool
)_clean
)
164 $(Q
)$(call RM
,Config
)
165 $(Q
)$(call RM
,config.h
)
166 $(Q
)$(call RM
,config.log
)
167 $(Q
)$(call RM
,cov-int
)
168 $(Q
)$(call RM
,netsniff-ng-coverity.tgz
)
173 install_all
: $(foreach tool
,$(TOOLS
),$(tool
)_install
)
174 install_allbutcurvetun
: $(foreach tool
,$(filter-out curvetun
,$(TOOLS
)),$(tool
)_install
)
175 install_allbutmausezahn
: $(foreach tool
,$(filter-out mausezahn
,$(TOOLS
)),$(tool
)_install
)
176 uninstall: $(foreach tool
,$(TOOLS
),$(tool
)_uninstall
)
179 $(LEX
) -P
$(shell perl
-wlne
'print $$1 if /lex-func-prefix:\s([a-z]+)/' $<) \
180 -o
$(BUILD_DIR
)/$(shell basename $< .l
).yy.c
$(LEX_FLAGS
) $<
182 $(YAAC
) -p
$(shell perl
-wlne
'print $$1 if /yaac-func-prefix:\s([a-z]+)/' $<) \
183 -o
$(BUILD_DIR
)/$(shell basename $< .y
).tab.c
$(YAAC_FLAGS
) -d
$<
185 $(foreach tool
,$(TOOLS
),$(eval
$(call TOOL_templ
,$(tool
))))
190 $(LDQ
) $(LDFLAGS
) -o
$@
/$@
$(shell LC_ALL
=C ls
$@
/*.o
) $($@
-libs
)