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