capt_get_packet(): check for key press only every 20ms
[iptraf-ng.git] / Makefile
blob853a8279d336e997cc5c1887547cff932005f712
1 # The default target of this Makefile is this
2 all::
4 # Define V=1 to have a more verbose compile.
6 # Define NO_PANEL if you don't want to use -lpanel.
8 # Define NEEDS_NCURSES5 if you need linking with ncurses5.
10 # Define NEEDS_NCURSESW5 if you need linking with ncursesw5.
12 # Define NEEDS_NCURSES6 if you need linking with ncurses6.
14 # Define NEEDS_NCURSESW6 if you need linking with ncursesw6.
17 VERSION-FILE: FORCE
18 @$(SHELL_PATH) ./GEN-VERSION-FILE
19 -include VERSION-FILE
21 CFLAGS = -g -O2 -Wall -W -std=gnu99 -Werror=format-security -D_GNU_SOURCE
22 LDFLAGS =
23 ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
24 ALL_LDFLAGS = $(LDFLAGS)
25 STRIP ?= strip
27 prefix = $(HOME)
28 sbindir_relative = sbin
29 sbindir = $(prefix)/$(sbindir_relative)
30 mandir = $(prefix)/share/man
31 sharedir = $(prefix)/share
32 localedir = $(sharedir)/locale
33 lib = lib
34 man8dir = $(mandir)/man8
36 # DESTDIR=
37 pathsep = :
39 export prefix bindir sharedir sysconfdir gitwebdir localedir
41 CC = cc
42 RM = rm -f
43 INSTALL = install
44 RPMBUILD = rpmbuild
45 TAR = tar
47 ### --- END CONFIGURATION SECTION ---
50 # Those must not be GNU-specific; they are shared with perl/ which may
51 # be built by a different compiler. (Note that this is an artifact now
52 # but it still might be nice to keep that distinction.)
53 BASIC_CFLAGS = -I. -Isrc/
54 BASIC_LDFLAGS =
56 # Guard against environment variables
57 iptraf-h :=
58 iptraf-o :=
59 rvnamed-o :=
60 rvnamed-h :=
63 ALL_PROGRAMS =
65 # Empty...
66 EXTRA_PROGRAMS =
68 ALL_PROGRAMS += iptraf-ng rvnamed-ng
70 ifndef SHELL_PATH
71 SHELL_PATH = /bin/sh
72 endif
74 iptraf-h += src/tui/input.h
75 iptraf-h += src/tui/labels.h
76 iptraf-h += src/tui/listbox.h
77 iptraf-h += src/tui/menurt.h
78 iptraf-h += src/tui/msgboxes.h
79 iptraf-h += src/tui/winops.h
80 iptraf-h += src/iptraf-ng-compat.h
81 iptraf-h += src/parse-options.h
82 iptraf-h += src/packet.h
83 iptraf-h += src/tcptable.h
84 iptraf-h += src/othptab.h
85 iptraf-h += src/ifstats.h
86 iptraf-h += src/deskman.h
87 iptraf-h += src/hostmon.h
88 iptraf-h += src/fltedit.h
89 iptraf-h += src/cidr.h
90 iptraf-h += src/fltselect.h
91 iptraf-h += src/ipfilter.h
92 iptraf-h += src/fltmgr.h
93 iptraf-h += src/ipfrag.h
94 iptraf-h += src/serv.h
95 iptraf-h += src/servname.h
96 iptraf-h += src/timer.h
97 iptraf-h += src/ifaces.h
98 iptraf-h += src/error.h
99 iptraf-h += src/revname.h
100 iptraf-h += src/log.h
101 iptraf-h += src/pktsize.h
102 iptraf-h += src/landesc.h
103 iptraf-h += src/dirs.h
104 iptraf-h += src/getpath.h
105 iptraf-h += src/options.h
106 iptraf-h += src/promisc.h
107 iptraf-h += src/parseproto.h
108 iptraf-h += src/addproto.h
109 iptraf-h += src/arphdr.h
110 iptraf-h += src/attrs.h
111 iptraf-h += src/fltdefs.h
112 iptraf-h += src/logvars.h
113 iptraf-h += src/list.h
114 iptraf-h += src/counters.h
115 iptraf-h += src/rate.h
116 iptraf-h += src/built-in.h
117 iptraf-h += src/sockaddr.h
118 iptraf-h += src/capt.h
119 iptraf-h += src/capt-recvmsg.h
120 iptraf-h += src/capt-recvmmsg.h
121 iptraf-h += src/capt-mmap-v2.h
122 iptraf-h += src/capt-mmap-v3.h
124 iptraf-o += src/tui/input.o
125 iptraf-o += src/tui/labels.o
126 iptraf-o += src/tui/listbox.o
127 iptraf-o += src/tui/menurt.o
128 iptraf-o += src/tui/msgboxes.o
129 iptraf-o += src/tui/winops.o
130 iptraf-o += src/error.o
131 iptraf-o += src/log.o
132 iptraf-o += src/getpath.o
133 iptraf-o += src/parseproto.o
134 iptraf-o += src/fltselect.o
135 iptraf-o += src/ipfilter.o
136 iptraf-o += src/fltmgr.o
137 iptraf-o += src/ipfrag.o
138 iptraf-o += src/serv.o
139 iptraf-o += src/servname.o
140 iptraf-o += src/timer.o
141 iptraf-o += src/revname.o
142 iptraf-o += src/pktsize.o
143 iptraf-o += src/landesc.o
144 iptraf-o += src/options.o
145 iptraf-o += src/promisc.o
146 iptraf-o += src/ifaces.o
147 iptraf-o += src/usage.o
148 iptraf-o += src/iptraf.o
149 iptraf-o += src/itrafmon.o
150 iptraf-o += src/wrapper.o
151 iptraf-o += src/parse-options.o
152 iptraf-o += src/packet.o
153 iptraf-o += src/tcptable.o
154 iptraf-o += src/othptab.o
155 iptraf-o += src/ifstats.o
156 iptraf-o += src/detstats.o
157 iptraf-o += src/deskman.o
158 iptraf-o += src/hostmon.o
159 iptraf-o += src/fltedit.o
160 iptraf-o += src/cidr.o
161 iptraf-o += src/counters.o
162 iptraf-o += src/rate.o
163 iptraf-o += src/capture-pkt.o
164 iptraf-o += src/sockaddr.o
165 iptraf-o += src/capt.o
166 iptraf-o += src/capt-recvmsg.o
167 iptraf-o += src/capt-recvmmsg.o
168 iptraf-o += src/capt-mmap-v2.o
169 iptraf-o += src/capt-mmap-v3.o
171 rvnamed-o += src/rvnamed.o
172 rvnamed-o += src/getpath.o
173 rvnamed-o += src/sockaddr.o
174 rvnamed-o += src/usage.o
176 -include config.mak.autogen
177 -include config.mak
179 ifndef sysconfdir
180 ifeq ($(prefix),/usr)
181 sysconfdir = /etc
182 else
183 sysconfdir = etc
184 endif
185 endif
187 ifdef CHECK_HEADER_DEPENDENCIES
188 COMPUTE_HEADER_DEPENDENCIES = no
189 USE_COMPUTED_HEADER_DEPENDENCIES =
190 endif
192 ifndef COMPUTE_HEADER_DEPENDENCIES
193 COMPUTE_HEADER_DEPENDENCIES = auto
194 endif
196 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),auto)
197 dep_check = $(shell $(CC) $(ALL_CFLAGS) \
198 -c -MF /dev/null -MMD -MP -x c /dev/null -o /dev/null 2>&1; \
199 echo $$?)
200 ifeq ($(dep_check),0)
201 override COMPUTE_HEADER_DEPENDENCIES = yes
202 else
203 override COMPUTE_HEADER_DEPENDENCIES = no
204 endif
205 endif
207 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
208 USE_COMPUTED_HEADER_DEPENDENCIES = YesPlease
209 else
210 ifneq ($(COMPUTE_HEADER_DEPENDENCIES),no)
211 $(error please set COMPUTE_HEADER_DEPENDENCIES to yes, no, or auto \
212 (not "$(COMPUTE_HEADER_DEPENDENCIES)"))
213 endif
214 endif
216 ifndef NCURSES_LDFLAGS
217 ifdef NEEDS_NCURSES5
218 NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
219 NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
220 ifndef NO_PANEL
221 NCURSES_LDFLAGS += -lpanel
222 endif
223 endif
224 endif
226 ifndef NCURSES_LDFLAGS
227 ifdef NEEDS_NCURSESW5
228 NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
229 NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
230 ifndef NO_PANEL
231 NCURSES_LDFLAGS += -lpanelw
232 endif
233 endif
234 endif
236 ifndef NCURSES_LDFLAGS
237 ifdef NEEDS_NCURSES6
238 NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
239 NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
240 ifndef NO_PANEL
241 NCURSES_LDFLAGS += -lpanel
242 endif
243 endif
244 endif
246 ifndef NCURSES_LDFLAGS
247 ifdef NEEDS_NCURSESW6
248 NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
249 NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
250 ifndef NO_PANEL
251 NCURSES_LDFLAGS += -lpanelw
252 endif
253 endif
254 endif
256 # try find ncuses by autodetect
257 ifndef NCURSES_LDFLAGS
258 ifneq ($(shell ncursesw6-config --libs 2>/dev/null),)
259 NCURSES_CFLAGS := $(shell ncursesw6-config --cflags 2>/dev/null)
260 NCURSES_LDFLAGS := $(shell ncursesw6-config --libs 2>/dev/null)
261 ifndef NO_PANEL
262 NCURSES_LDFLAGS += -lpanelw
263 endif
264 else ifneq ($(shell ncurses6-config --libs 2>/dev/null),)
265 NCURSES_CFLAGS := $(shell ncurses6-config --cflags 2>/dev/null)
266 NCURSES_LDFLAGS := $(shell ncurses6-config --libs 2>/dev/null)
267 ifndef NO_PANEL
268 NCURSES_LDFLAGS += -lpanel
269 endif
270 else ifneq ($(shell ncursesw5-config --libs 2>/dev/null),)
271 NCURSES_CFLAGS := $(shell ncursesw5-config --cflags 2>/dev/null)
272 NCURSES_LDFLAGS := $(shell ncursesw5-config --libs 2>/dev/null)
273 ifndef NO_PANEL
274 NCURSES_LDFLAGS += -lpanelw
275 endif
276 else ifneq ($(shell ncurses5-config --libs 2>/dev/null),)
277 NCURSES_CFLAGS := $(shell ncurses5-config --cflags 2>/dev/null)
278 NCURSES_LDFLAGS := $(shell ncurses5-config --libs 2>/dev/null)
279 ifndef NO_PANEL
280 NCURSES_LDFLAGS += -lpanel
281 endif
282 endif
283 endif
285 QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
286 QUIET_SUBDIR1 =
288 ifneq ($(findstring $(MAKEFLAGS),w),w)
289 PRINT_DIR = --no-print-directory
290 else # "make -w"
291 NO_SUBDIR = :
292 endif
294 ifneq ($(findstring $(MAKEFLAGS),s),s)
295 ifndef V
296 QUIET_CC = @echo ' ' CC $@;
297 QUIET_LINK = @echo ' ' LINK $@;
298 QUIET_GEN = @echo ' ' GEN $@;
299 QUIET_SUBDIR0 = +@subdir=
300 QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
301 $(MAKE) $(PRINT_DIR) -C $$subdir
302 export V
303 export QUIET_GEN
304 export QUIET_BUILT_IN
305 endif
306 endif
309 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
310 sbindir_SQ = $(subst ','\'',$(sbindir))
312 ALL_CFLAGS += $(BASIC_CFLAGS)
313 ALL_LDFLAGS += $(BASIC_LDFLAGS)
315 export TAR INSTALL DESTDIR SHELL_PATH
317 ### Build rules
319 SHELL = $(SHELL_PATH)
321 #all:: shell_compatibility_test
322 #please_set_SHELL_PATH_to_a_more_modern_shell:
323 # @$$(:)
324 #shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
327 all:: $(ALL_PROGRAMS)
329 iptraf-ng: $(iptraf-o)
330 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ \
331 $(iptraf-o) $(ALL_LDFLAGS) $(NCURSES_LDFLAGS)
333 src/deskman.o src/iptraf.o: VERSION-FILE
334 src/deskman.o src/iptraf.o src/capture-pkt.o: EXTRA_CPPFLAGS = \
335 -DIPTRAF_VERSION='"$(IPTRAF_VERSION)"' \
336 -DIPTRAF_NAME='"iptraf-ng"'
338 rvnamed-ng: $(rvnamed-o)
339 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ \
340 $(rvnamed-o) $(ALL_LDFLAGS)
342 configure: configure.ac
343 $(QUIET_GEN)$(RM) $@ $<+ && \
344 sed -e 's/@@IPTRAF_VERSION@@/$(IPTRAF_VERSION)/g' \
345 $< > $<+ && \
346 autoconf -o $@ $<+ && \
347 $(RM) $<+
349 OBJECTS := $(sort $(iptraf-o) $(rvnamed-o))
351 dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d)
352 dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS))))
354 ifeq ($(COMPUTE_HEADER_DEPENDENCIES),yes)
355 $(dep_dirs):
356 @mkdir -p $@
358 missing_dep_dirs := $(filter-out $(wildcard $(dep_dirs)),$(dep_dirs))
359 dep_file = $(dir $@).depend/$(notdir $@).d
360 dep_args = -MF $(dep_file) -MMD -MP
361 ifdef CHECK_HEADER_DEPENDENCIES
362 $(error cannot compute header dependencies outside a normal build. \
363 Please unset CHECK_HEADER_DEPENDENCIES and try again)
364 endif
365 endif
367 .SUFFIXES:
369 ifdef PRINT_HEADER_DEPENDENCIES
370 $(OBJECTS): %.o: %.c FORCE
371 echo $^
373 ifndef CHECK_HEADER_DEPENDENCIES
374 $(error cannot print header dependencies during a normal build. \
375 Please set CHECK_HEADER_DEPENDENCIES and try again)
376 endif
377 endif
379 ifndef PRINT_HEADER_DEPENDENCIES
380 ifdef CHECK_HEADER_DEPENDENCIES
381 $(OBJECTS): %.o: %.c $(dep_files) FORCE
382 @set -e; echo CHECK $@; \
383 missing_deps="$(missing_deps)"; \
384 if test "$$missing_deps"; \
385 then \
386 echo missing dependencies: $$missing_deps; \
387 false; \
389 endif
390 endif
392 ifndef CHECK_HEADER_DEPENDENCIES
393 $(OBJECTS): %.o: %.c $(missing_dep_dirs)
394 $(QUIET_CC)$(CC) -o $*.o -c $(dep_args) $(NCURSES_CFLAGS) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
395 endif
397 ifdef USE_COMPUTED_HEADER_DEPENDENCIES
398 # Take advantage of gcc's on-the-fly dependency generation
399 # See <http://gcc.gnu.org/gcc-3.0/features.html>.
400 dep_files_present := $(wildcard $(dep_files))
401 ifneq ($(dep_files_present),)
402 include $(dep_files_present)
403 endif
404 else
405 # Dependencies on header files, for platforms that do not support
406 # the gcc -MMD option.
408 # Dependencies on automatically generated headers such as common-cmds.h
409 # should _not_ be included here, since they are necessary even when
410 # building an object for the first time.
412 # XXX. Please check occasionally that these include all dependencies
413 # gcc detects!
415 $(OBJECTS): $(iptraf-h)
416 endif
419 ### Maintainer's dist rules
421 iptraf-ng.spec: iptraf-ng.spec.in
422 sed -e 's/@@IPTRAF_VERSION@@/$(IPTRAF_VERSION)/g' < $< > $@+
423 mv $@+ $@
425 IPTRAF_TARNAME = iptraf-ng-$(IPTRAF_VERSION)
426 dist: iptraf-ng.spec configure
427 @mkdir -p $(IPTRAF_TARNAME)
428 @cp iptraf-ng.spec configure $(IPTRAF_TARNAME)
429 @cp --parents `git ls-files` $(IPTRAF_TARNAME)
430 @echo $(IPTRAF_VERSION) > $(IPTRAF_TARNAME)/version
431 $(TAR) cf $(IPTRAF_TARNAME).tar $(IPTRAF_TARNAME)
432 @$(RM) -rf $(IPTRAF_TARNAME)
433 gzip -f -9 $(IPTRAF_TARNAME).tar
435 rpm: dist
436 $(RPMBUILD) \
437 --define "_source_filedigest_algorithm md5" \
438 --define "_binary_filedigest_algorithm md5" \
439 -ta $(IPTRAF_TARNAME).tar.gz
442 ## TODO: use asciidoc to generate mans
444 ### Installation rules
445 install: all
446 @echo $(DESTDIR_SQ)$(man8dir)
447 $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(sbindir_SQ)'
448 $(INSTALL) $(ALL_PROGRAMS) '$(DESTDIR_SQ)$(sbindir_SQ)'
449 $(INSTALL) -d -m 755 $(DESTDIR)$(man8dir)
450 $(INSTALL) -m 644 src/iptraf-ng.8 $(DESTDIR)$(man8dir)
451 $(INSTALL) -m 644 src/rvnamed-ng.8 $(DESTDIR)$(man8dir)
453 ### Cleaning rules
455 distclean: clean
456 $(RM) configure
458 clean:
459 $(RM) src/*.o src/tui/*.o
460 $(RM) $(ALL_PROGRAMS)
461 $(RM) -r autom4te.cache
462 $(RM) -r $(dep_dirs)
463 $(RM) *.spec
464 $(RM) $(IPTRAF_TARNAME).tar.gz
465 $(RM) config.log config.mak.autogen config.mak.append config.status config.cache
466 $(RM) VERSION-FILE
468 .PHONY: gtags
469 gtags:
470 $(QUIET_GEN) gtags
472 .PHONY: clean distclean all install FORCE