astraceroute: zsh: add auto-completion entry
[netsniff-ng.git] / Makefile
blob07a6d76143545124e44ab399fdb6a1e9ce385943
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.
6 -include Config
7 -include Cmds
8 -include Extra
9 -include Template
10 -include Misc
12 ifndef CONFIG_OK
13 $(error "Please run `./configure' before `make'")
14 endif
16 VERSION = 0
17 PATCHLEVEL = 5
18 SUBLEVEL = 8
19 EXTRAVERSION = -rc2
20 NAME = Ziggomatic
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.
26 PREFIX ?=
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
40 MAKEFLAGS += -rR
41 MAKEFLAGS += --warn-undefined-variables
42 MAKEFLAGS += --jobs=$(shell grep "^processor" /proc/cpuinfo | wc -l)
44 # Debugging option
45 ifeq ("$(origin DEBUG)", "command line")
46 DEBUG := 1
47 else
48 DEBUG := 0
49 endif
51 # For packaging purposes, you might want to call your own:
52 # make CFLAGS="<flags>"
53 CFLAGS_DEF = -std=gnu99
54 CFLAGS_DEF += -pipe
56 ifeq ($(DEBUG), 1)
57 CFLAGS_DEF += -O2
58 CFLAGS_DEF += -g
59 else
60 ifeq ($(DISTRO), 1)
61 CFLAGS_DEF += -O2
62 else
63 CFLAGS_DEF += -march=native
64 CFLAGS_DEF += -mtune=native
65 CFLAGS_DEF += -O3
66 endif
67 endif
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
74 CFLAGS_DEF += -ftrapv
75 CFLAGS_DEF += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
76 CFLAGS_DEF += -fexceptions
77 endif
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)\"
92 WFLAGS_DEF = -Wall
94 CPPFLAGS ?=
95 CFLAGS ?= $(CFLAGS_DEF) $(WFLAGS_DEF) $(CPPFLAGS)
96 override CFLAGS += $(CFLAGS_MIN) -I.
98 LEX_FLAGS =
99 YAAC_FLAGS =
101 LDFLAGS ?=
102 ifeq ("$(origin CROSS_LD_LIBRARY_PATH)", "command line")
103 LDFLAGS += -L$(CROSS_LD_LIBRARY_PATH)
104 endif
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
111 export CROSS_COMPILE
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
119 else
120 WHAT := Building
121 endif
123 build_showinfo:
124 $(Q)echo "$(bold)$(WHAT) netsniff-ng toolkit ($(VERSION_STRING)) for" \
125 $(shell $(CCNQ) -dumpmachine)":$(normal)"
126 clean_showinfo:
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)
132 .DEFAULT_GOAL := all
133 .DEFAULT:
134 .FORCE:
136 all: build_showinfo toolkit
137 allbutcurvetun: $(filter-out curvetun,$(TOOLS))
138 allbutmausezahn: $(filter-out mausezahn,$(TOOLS))
139 toolkit: $(TOOLS)
140 clean: $(foreach tool,$(TOOLS),$(tool)_clean)
141 distclean: 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)
147 mrproper: distclean
148 $(Q)$(GIT_REM)
150 install: install_all
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)
156 %.yy.o: %.l
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) $<
159 %.tab.o: %.y
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))))
165 %:: ;
167 $(TOOLS):
168 $(LD) $(LDFLAGS) -o $@/$@ $@/*.o $($@-libs)
169 $(STRIP) $@/$@