1 # netsniff-ng build system
2 # Copyright 2012 - 2013 Daniel Borkmann <borkmann@gnumaniacs.org>
3 # Copyright 2013 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 # Disable if you don't want it
29 CCACHE ?
= $(CONFIG_CCACHE
)
31 # Location of installation paths.
32 SBINDIR
= $(PREFIX
)/usr
/sbin
33 INCDIR
= $(PREFIX
)/usr
/include
34 ETCDIR
= $(PREFIX
)/etc
35 ETCDIRE
= $(ETCDIR
)/netsniff-ng
36 MAN8DIR
= $(PREFIX
)/usr
/share
/man
/man8
38 # Shut up make, helper warnings, parallel compilation!
39 MAKEFLAGS
+= --no-print-directory
41 MAKEFLAGS
+= --warn-undefined-variables
42 MAKEFLAGS
+= --jobs
=$(shell grep
"^processor" /proc
/cpuinfo | wc
-l
)
45 ifeq ("$(origin DEBUG)", "command line")
51 # For packaging purposes, you might want to call your own:
52 # make CFLAGS="<flags>"
53 CFLAGS_DEF
= -std
=gnu99
63 CFLAGS_DEF
+= -march
=native
64 CFLAGS_DEF
+= -mtune
=native
68 ifeq ($(HARDENING
), 1)
69 CFLAGS_DEF
+= -fPIE
-pie
70 CFLAGS_DEF
+= -Wl
,-z
,relro
,-z
,now
71 CFLAGS_DEF
+= -fstack-protector-all
72 CFLAGS_DEF
+= -Wstack-protector
73 CFLAGS_DEF
+= --param
=ssp-buffer-size
=4
75 CFLAGS_DEF
+= -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE
=2
76 CFLAGS_DEF
+= -fexceptions
79 CFLAGS_DEF
+= -fomit-frame-pointer
80 CFLAGS_DEF
+= -fno-strict-aliasing
81 CFLAGS_DEF
+= -fasynchronous-unwind-tables
82 CFLAGS_DEF
+= -fno-delete-null-pointer-checks
84 CFLAGS_MIN
= -D_REENTRANT
85 CFLAGS_MIN
+= -D_LARGEFILE_SOURCE
86 CFLAGS_MIN
+= -D_LARGEFILE64_SOURCE
87 CFLAGS_MIN
+= -D_FILE_OFFSET_BITS
=64
88 CFLAGS_MIN
+= -DVERSION_STRING
=\"$(VERSION_STRING
)\"
89 CFLAGS_MIN
+= -DVERSION_LONG
=\"$(VERSION_LONG
)\"
90 CFLAGS_MIN
+= -DPREFIX_STRING
=\"$(PREFIX
)\"
95 CFLAGS ?
= $(CFLAGS_DEF
) $(WFLAGS_DEF
) $(CPPFLAGS
)
96 override CFLAGS
+= $(CFLAGS_MIN
) -I.
102 ifeq ("$(origin CROSS_LD_LIBRARY_PATH)", "command line")
103 LDFLAGS
+= -L
$(CROSS_LD_LIBRARY_PATH
)
106 VERSION_SHORT
= $(VERSION
).
$(PATCHLEVEL
).
$(SUBLEVEL
)$(EXTRAVERSION
)
107 VERSION_STRING
= "$(VERSION_SHORT)$(CONFIG_RC)"
108 VERSION_LONG
= "$(VERSION_SHORT)$(CONFIG_RC) ($(NAME))"
110 export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION
112 export DEBUG DISTRO HARDENING
114 bold
= $(shell tput bold
)
115 normal
= $(shell tput sgr0
)
117 ifeq ("$(origin CROSS_COMPILE)", "command line")
118 WHAT
:= Cross compiling
124 $(Q
)echo
"$(bold)$(WHAT) netsniff-ng toolkit ($(VERSION_STRING)) for" \
125 $(shell $(CCNQ
) -dumpmachine
)":$(normal)"
127 $(Q
)echo
"$(bold)Cleaning netsniff-ng toolkit ($(VERSION_STRING)):$(normal)"
129 .PHONY
: all toolkit
$(TOOLS
) clean %_prehook
%_clean
%_install
%_uninstall tag
tags cscope
130 .IGNORE
: %_clean_custom
%_install_custom
131 .NOTPARALLEL
: $(TOOLS
)
136 all: build_showinfo toolkit
137 allbutcurvetun
: $(filter-out curvetun
,$(TOOLS
))
138 allbutmausezahn
: $(filter-out mausezahn
,$(TOOLS
))
140 clean: $(foreach tool
,$(TOOLS
),$(tool
)_clean
)
142 $(Q
)$(call RM
,Config
)
143 $(Q
)$(call RM
,config.h
)
144 $(Q
)$(call RM
,config.log
)
145 $(Q
)$(call RM
,cov-int
)
146 $(Q
)$(call RM
,netsniff-ng-coverity.tgz
)
151 install_all
: $(foreach tool
,$(TOOLS
),$(tool
)_install
)
152 install_allbutcurvetun
: $(foreach tool
,$(filter-out curvetun
,$(TOOLS
)),$(tool
)_install
)
153 install_allbutmausezahn
: $(foreach tool
,$(filter-out mausezahn
,$(TOOLS
)),$(tool
)_install
)
154 uninstall: $(foreach tool
,$(TOOLS
),$(tool
)_uninstall
)
157 $(LEX
) -P
$(shell perl
-wlne
'print $$1 if /lex-func-prefix:\s([a-z]+)/' $<) \
158 -o
$(BUILD_DIR
)/$(shell basename $< .l
).yy.c
$(LEX_FLAGS
) $<
160 $(YAAC
) -p
$(shell perl
-wlne
'print $$1 if /yaac-func-prefix:\s([a-z]+)/' $<) \
161 -o
$(BUILD_DIR
)/$(shell basename $< .y
).tab.c
$(YAAC_FLAGS
) -d
$<
163 $(foreach tool
,$(TOOLS
),$(eval
$(call TOOL_templ
,$(tool
))))
168 $(LD
) $(LDFLAGS
) -o
$@
/$@
$@
/*.o
$($@
-libs
)