forked from jweyrich/t50
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
175 lines (151 loc) · 4.41 KB
/
Makefile
File metadata and controls
175 lines (151 loc) · 4.41 KB
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
# vim: set ts=2 noet sw=2 :
#
# if DEBUG is defined on make call (ex: make DEBUG=1), then compile with
# __HAVE_DEBUG__ defined, asserts and debug information.
#
# Define HAVE_TURBO if you want T50 to use 2 processes.
# Define EXPERIMENTAL if you want new features not yet tested.
#
# The final executable will be created at release/ sub-directory.
#
HAVE_TURBO = 1
#EXPERIMENTAL = 1
#DEBUG = 1
.PHONY: all doxygen distclean clean install uninstall
INSTALLPROG = /usr/bin/install
#
# T50 directories structure:
# .
# ├── build
# │ ├── help
# │ └── modules
# ├── doc
# ├── release
# └── src
# ├── help
# ├── include
# │ └── protocol
# └── modules
#
SRC_DIR = ./src
OBJ_DIR = ./build
RELEASE_DIR = ./release
MAN_DIR = /usr/share/man/man8
INCLUDE_DIR = $(SRC_DIR)/include
SBIN_DIR = /usr/sbin
# 't50' executable is our target!
TARGET = $(RELEASE_DIR)/t50
OBJS = $(OBJ_DIR)/modules/ip.o \
$(OBJ_DIR)/modules/igmpv3.o \
$(OBJ_DIR)/modules/dccp.o \
$(OBJ_DIR)/modules/ripv2.o \
$(OBJ_DIR)/modules/udp.o \
$(OBJ_DIR)/modules/tcp.o \
$(OBJ_DIR)/modules/ospf.o \
$(OBJ_DIR)/modules/ripv1.o \
$(OBJ_DIR)/modules/egp.o \
$(OBJ_DIR)/modules/rsvp.o \
$(OBJ_DIR)/modules/ipsec.o \
$(OBJ_DIR)/modules/eigrp.o \
$(OBJ_DIR)/modules/gre.o \
$(OBJ_DIR)/modules/igmpv1.o \
$(OBJ_DIR)/modules/icmp.o \
$(OBJ_DIR)/common.o \
$(OBJ_DIR)/cksum.o \
$(OBJ_DIR)/cidr.o \
$(OBJ_DIR)/main.o \
$(OBJ_DIR)/resolv.o \
$(OBJ_DIR)/sock.o \
$(OBJ_DIR)/usage.o \
$(OBJ_DIR)/config.o \
$(OBJ_DIR)/modules.o \
$(OBJ_DIR)/help/general_help.o \
$(OBJ_DIR)/help/gre_help.o \
$(OBJ_DIR)/help/tcp_udp_dccp_help.o \
$(OBJ_DIR)/help/ip_help.o \
$(OBJ_DIR)/help/icmp_help.o \
$(OBJ_DIR)/help/egp_help.o \
$(OBJ_DIR)/help/rip_help.o \
$(OBJ_DIR)/help/rsvp_help.o \
$(OBJ_DIR)/help/ipsec_help.o \
$(OBJ_DIR)/help/eigrp_help.o \
$(OBJ_DIR)/help/ospf_help.o
DEPS = $(SRC_DIR)/include/config.h \
$(SRC_DIR)/include/common.h \
$(SRC_DIR)/include/protocol/eigrp.h \
$(SRC_DIR)/include/protocol/gre.h \
$(SRC_DIR)/include/protocol/egp.h \
$(SRC_DIR)/include/protocol/ip.h \
$(SRC_DIR)/include/protocol/igmp.h \
$(SRC_DIR)/include/protocol/tcp_options.h \
$(SRC_DIR)/include/protocol/rsvp.h \
$(SRC_DIR)/include/protocol/rip.h \
$(SRC_DIR)/include/protocol/ospf.h \
$(SRC_DIR)/include/typedefs.h \
$(SRC_DIR)/include/help.h \
$(SRC_DIR)/include/defines.h \
$(SRC_DIR)/include/modules.h
#--- This will give us a lot of warnings. Useful to check if the code is alright (not quite!). Use carefully!
#--- As seen on OWASP cheat sheet!
#EXTRA_WARNINGS=-Wsign-conversion -Wcast-align -Wformat=2 -Wformat-security -fno-common -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes -Wstrict-overflow -Wtrampolines
CFLAGS = -I$(INCLUDE_DIR) -std=gnu99 -Wall -Wextra $(EXTRA_WARNINGS)
ifdef EXPERIMENTAL
CFLAGS += -D_EXPERIMENTAL_
endif
LDFLAGS =
#
# You can define DEBUG if you want to use GDB.
#
ifdef DEBUG
CFLAGS += -g -O0 -D__HAVE_DEBUG__
#
# Define DUMP_DATA if you want to view a big log file...
#
# CFLAGS += -DDUMP_DATA -g
else
CFLAGS += -O2 -DNDEBUG
ifdef HAVE_TURBO
CFLAGS += -D__HAVE_TURBO__
endif
# Get architecture
ARCH = $(shell arch)
ifneq ($(ARCH),x86_64)
CFLAGS += -msse -mfpmath=sse
endif
LDFLAGS += -s
# FIX: BMI2 isn't very useful for us, but MOVBE is!
ifeq ($(shell grep movbe /proc/cpuinfo 2>&1 > /dev/null; echo $$?), 0)
CFLAGS += -mmovbe
endif
endif
all: $(TARGET)
# link
$(TARGET): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
# Compile main
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<
# Compile Help
$(OBJ_DIR)/help/%.o: $(SRC_DIR)/help/%.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<
# Compile modules
$(OBJ_DIR)/modules/%.o: $(SRC_DIR)/modules/%.c $(DEPS)
$(CC) $(CFLAGS) -c -o $@ $<
doxygen:
doxygen
distclean: clean
-if [ -f $(RELEASE_DIR)/t50.8.gz ]; then rm $(RELEASE_DIR)/t50.8.gz; fi
-if [ -f $(RELEASE_DIR)/t50 ]; then rm $(RELEASE_DIR)/t50; fi
-if [ -d doc/html ]; then rm -rf doc/html; fi
-if [ -d doc/latex ]; then rm -rf doc/latex; fi
-if [ -f doc/doxy*.db ]; then rm -f doc/doxy*.db; fi
clean:
-rm $(OBJS)
install:
@[ "`id -u`" -ne 0 ] && ( echo "Need root privilege"; exit 1 )
@gzip -9c doc/t50.8 > $(RELEASE_DIR)/t50.8.gz
$(INSTALLPROG) $(RELEASE_DIR)/t50 $(SBIN_DIR)/
$(INSTALLPROG) -m 0644 $(RELEASE_DIR)/t50.8.gz $(MAN_DIR)/
uninstall:
@[ "`id -u`" -ne 0 ] && ( echo "Need root privilege"; exit 1 )
-rm -f $(MAN_DIR)/t50.8.gz $(SBIN_DIR)/t50