-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile.in
278 lines (232 loc) · 10.3 KB
/
Makefile.in
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
# Extract the version string from nmap.h.
export NMAP_VERSION := $(shell grep '^\#[ \t]*define[ \t]\+NMAP_VERSION' nmap.h | sed -e 's/.*"\(.*\)".*/\1/' -e 'q')
NMAP_NAME= Nmap
NMAP_URL= http://nmap.org
NMAP_PLATFORM=@host@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
mandir = @mandir@
srcdir = @srcdir@
nmaplibexecdir = @libexecdir@/nmap
nmapdatadir = @datadir@/nmap
deskdir = $(prefix)/share/applications
NMAPDEVDIR=~/nmap-dev
export NBASEDIR=@NBASEDIR@
export NSOCKDIR=@NSOCKDIR@
export LIBLUADIR = @LIBLUADIR@
export NDIR=$(shell pwd)
export LIBLUA_LIBS = @LIBLUA_LIBS@
CC = @CC@
CXX = @CXX@
CCOPT =
DBGFLAGS =
STRIP = @STRIP@
LIBPCAPDIR = @libpcapdir@
LIBPCREDIR = @LIBPCREDIR@
export LIBDNETDIR = @LIBDNETDIR@
ZENMAPDIR = zenmap
PYTHON = @PYTHON@
DEFS = @DEFS@ -DNMAP_NAME=\"$(NMAP_NAME)\" -DNMAP_URL=\"$(NMAP_URL)\" -DNMAP_PLATFORM=\"$(NMAP_PLATFORM)\" -DNMAPDATADIR=\"$(nmapdatadir)\" -DNMAPLIBEXECDIR=\"$(nmaplibexecdir)\"
# For mtrace debugging -- see MTRACE define in main.cc for instructions
# Should only be enabled during debugging and not in any real release.
# DEFS += -DMTRACE=1
CXXFLAGS = @CXXFLAGS@ $(DBGFLAGS) $(CCOPT) $(DEFS)
CPPFLAGS = @CPPFLAGS@
export CFLAGS = $(CXXFLAGS)
# CFLAGS = $(DEFS) $(INCLS)
STATIC =
LDFLAGS = @LDFLAGS@ $(DBGFLAGS) $(STATIC)
LIBS = @LIBNBASE_LIBS@ @LIBNSOCK_LIBS@ @LIBPCRE_LIBS@ @LIBPCAP_LIBS@ @OPENSSL_LIBS@ @LIBDNET_LIBS@ @LIBLUA_LIBS@ @LIBS@
# LIBS = -lefence @LIBS@
# LIBS = -lrmalloc @LIBS@
SHTOOL = ./shtool
INSTALL = $(SHTOOL) install
# MAKEDEPEND = @MAKEDEPEND@
export RPMTDIR=$(HOME)/rpm
# DESTDIR is used by some package maintainers to install Nmap under
# its usual directory structure into a different tree. See the
# CHANGELOG for more info.
DESTDIR =
TARGET = nmap
INSTALLNSE=@INSTALLNSE@
BUILDZENMAP=@BUILDZENMAP@
INSTALLZENMAP=@INSTALLZENMAP@
UNINSTALLZENMAP=@UNINSTALLZENMAP@
ifneq (@LIBLUA_LIBS@,)
NSE_SRC=nse_main.cc nse_auxiliar.cc nse_nsock.cc nse_init.cc nse_nmaplib.cc nse_debug.cc nse_pcrelib.cc nse_string.cc
NSE_HDRS=nse_main.h nse_auxiliar.h nse_nsock.h nse_init.h nse_nmaplib.h nse_debug.h nse_macros.h nse_pcrelib.h nse_string.h
NSE_OBJS=nse_main.o nse_auxiliar.o nse_nsock.o nse_init.o nse_nmaplib.o nse_debug.o nse_pcrelib.o nse_string.o
NSESTDLIB=nsestdlib
endif
export SRCS = main.cc nmap.cc targets.cc tcpip.cc nmap_error.cc utils.cc idle_scan.cc osscan.cc osscan2.cc output.cc scan_engine.cc timing.cc charpool.cc services.cc protocols.cc nmap_rpc.cc portlist.cc NmapOps.cc TargetGroup.cc Target.cc FingerPrintResults.cc service_scan.cc NmapOutputTable.cc MACLookup.cc nmap_tty.cc nmap_dns.cc traceroute.cc portreasons.cc $(NSE_SRC) @COMPAT_SRCS@
export HDRS = charpool.h FingerPrintResults.h global_structures.h idle_scan.h MACLookup.h nmap_amigaos.h nmap_dns.h nmap_error.h nmap.h NmapOps.h NmapOutputTable.h nmap_rpc.h nmap_tty.h nmap_winconfig.h osscan.h osscan2.h output.h portlist.h protocols.h scan_engine.h service_scan.h services.h TargetGroup.h Target.h targets.h tcpip.h timing.h utils.h traceroute.h portreasons.h $(NSE_HDRS)
OBJS = main.o nmap.o targets.o tcpip.o nmap_error.o utils.o idle_scan.o osscan.o osscan2.o output.o scan_engine.o timing.o charpool.o services.o protocols.o nmap_rpc.o portlist.o NmapOps.o TargetGroup.o Target.o FingerPrintResults.o service_scan.o NmapOutputTable.o MACLookup.o nmap_tty.o nmap_dns.o traceroute.o portreasons.o $(NSE_OBJS) @COMPAT_OBJS@
# %.o : %.cc -- nope this is a GNU extension
.cc.o:
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $< -o $@
all: @LUA_BUILD@ @PCAP_BUILD@ @PCRE_BUILD@ @DNET_BUILD@ @NBASE_BUILD@ @NSOCK_BUILD@
$(MAKE) $(TARGET) $(NSESTDLIB) $(BUILDZENMAP)
$(TARGET): @LUA_DEPENDS@ @PCAP_DEPENDS@ @PCRE_DEPENDS@ @DNET_DEPENDS@ $(NBASEDIR)/libnbase.a $(NSOCKDIR)/src/libnsock.a $(OBJS)
echo Compiling nmap
rm -f $@
$(CXX) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
nsestdlib: nselib-bin/Makefile
@echo Compiling nse-standard-library; cd nselib-bin && $(MAKE)
pcre_build: $(LIBPCREDIR)/Makefile
@echo Compiling libpcre; cd $(LIBPCREDIR) && $(MAKE)
dnet_build: $(LIBDNETDIR)/Makefile
@echo Compiling libdnet; cd $(LIBDNETDIR) && $(MAKE)
pcap_build: $(LIBPCAPDIR)/Makefile
@echo Compiling libpcap; cd $(LIBPCAPDIR) && $(MAKE)
nbase_build: $(NBASEDIR)/Makefile
@echo Compiling libnbase;
cd $(NBASEDIR) && $(MAKE)
nsock_build: $(NSOCKDIR)/src/Makefile
@echo Compiling libnsock;
cd $(NSOCKDIR)/src && $(MAKE)
lua_build: $(LIBLUADIR)/Makefile
@echo Compiling liblua; cd $(LIBLUADIR) && $(MAKE) liblua.a CC="$(CC)" MYCFLAGS="$(CFLAGS) @LUA_CFLAGS@"
#$(LIBPCAPDIR)/Makefile:
# @echo Configuring libpcap; cd $(LIBPCAPDIR); ./configure
# Make a statically compiled binary for portability between distributions
static:
$(MAKE) STATIC=-static
debug:
$(MAKE) DBGFLAGS="-O0 -g -pg -ftest-coverage -fprofile-arcs"
# Make the Nmap tarball
distro:
cd $(NMAPDEVDIR) && $(MAKE) distro
# Update the web site
web:
cd $(NMAPDEVDIR) && $(MAKE) web
clean: @LUA_CLEAN@ @PCAP_CLEAN@ @PCRE_CLEAN@ @DNET_CLEAN@ nsock_clean nbase_clean my_clean @NSELIB_CLEAN@ @ZENMAP_CLEAN@
my_clean:
rm -f dependencies.mk
rm -f $(OBJS) $(TARGET) config.cache
pcap_clean:
-cd $(LIBPCAPDIR) && $(MAKE) clean
pcre_clean:
-cd $(LIBPCREDIR) && $(MAKE) clean
dnet_clean:
-cd $(LIBDNETDIR) && $(MAKE) clean
nbase_clean:
-cd $(NBASEDIR) && $(MAKE) clean
nsock_clean:
-cd $(NSOCKDIR)/src && $(MAKE) clean
lua_clean:
-cd $(LIBLUADIR) && $(MAKE) clean
nselib_clean:
-cd nselib-bin && $(MAKE) clean
zenmap_clean:
-cd $(ZENMAPDIR) && $(PYTHON) setup.py clean --all
pcap_dist_clean:
-cd $(LIBPCAPDIR) && $(MAKE) distclean
pcre_dist_clean:
-cd $(LIBPCREDIR) && $(MAKE) distclean
dnet_dist_clean:
-cd $(LIBDNETDIR) && $(MAKE) distclean
lua_dist_clean:
-cd $(LIBLUADIR) && $(MAKE) clean
nselib_dist_clean:
-cd nselib-bin && $(MAKE) distclean
nbase_dist_clean:
-cd $(NBASEDIR) && $(MAKE) distclean
nsock_dist_clean:
-cd $(NSOCKDIR)/src && $(MAKE) distclean
zenmap_dist_clean: zenmap_clean
-cd $(ZENMAPDIR) && rm -rf MANIFEST build/ dist/
debugclean:
rm -f *.gcov *.gcda *.gcno gmon.out
distclean: my_clean my_distclean @LUA_DIST_CLEAN@ @PCAP_DIST_CLEAN@ @PCRE_DIST_CLEAN@ @DNET_DIST_CLEAN@ nbase_dist_clean nsock_dist_clean @NSELIB_DIST_CLEAN@ @ZENMAP_DIST_CLEAN@
my_distclean:
rm -f Makefile Makefile.bak makefile.dep nmap_config.h stamp-h stamp-h.in \
config.cache config.log config.status
install-nmap: $(TARGET)
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1 $(DESTDIR)$(nmapdatadir)
$(INSTALL) -c -m 755 nmap $(DESTDIR)$(bindir)/nmap
# Use strip -x to avoid stripping dynamically loaded NSE functions. See
# http://seclists.org/nmap-dev/2007/q4/0272.html.
$(STRIP) -x $(DESTDIR)$(bindir)/nmap
$(INSTALL) -c -m 644 docs/$(TARGET).1 $(DESTDIR)$(mandir)/man1/
$(INSTALL) -c -m 644 docs/nmap.xsl $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 docs/nmap.dtd $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-services $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-rpc $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-os-db $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-service-probes $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-protocols $(DESTDIR)$(nmapdatadir)/
$(INSTALL) -c -m 644 nmap-mac-prefixes $(DESTDIR)$(nmapdatadir)/
$(ZENMAPDIR)/setup.py:
cd $(ZENMAPDIR) && install_scripts/unix/setup.sh
# Update the version number used by Zenmap.
$(ZENMAPDIR)/zenmapCore/Version.py $(ZENMAPDIR)/share/zenmap/config/zenmap_version: nmap.h
cd $(ZENMAPDIR) && $(PYTHON) install_scripts/utils/version_update.py "$(NMAP_VERSION)"
# By default distutils rewrites installed scripts to hardcode the
# location of the Python interpreter they were built with (something
# like #!/usr/bin/python2.4). This is the wrong thing to do when
# installing on a machine other than the one used to do the build. Use
# this as the location of the interpreter whenever we're not doing a
# local installation.
DEFAULT_PYTHON_PATH = /usr/bin/env python
build-zenmap: $(ZENMAPDIR)/setup.py $(ZENMAPDIR)/zenmapCore/Version.py
# When DESTDIR is defined, assume we're building an executable
# distribution rather than a local installation and force a generic
# Python interpreter location.
cd $(ZENMAPDIR) && $(PYTHON) setup.py build $(if $(DESTDIR),--executable "$(DEFAULT_PYTHON_PATH)")
install-zenmap: $(ZENMAPDIR)/setup.py
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(bindir) $(DESTDIR)$(mandir)/man1
cd $(ZENMAPDIR) && $(PYTHON) setup.py install --prefix "$(prefix)" $(if $(DESTDIR),--root "$(DESTDIR)")
$(INSTALL) -c -m 644 docs/zenmap.1 $(DESTDIR)$(mandir)/man1/
# Create a symlink from nmapfe to zenmap if nmapfe doesn't exist or is
# already a link.
if [ ! -e $(DESTDIR)$(bindir)/nmapfe -o -L $(DESTDIR)$(bindir)/nmapfe ]; then \
ln -sf zenmap $(DESTDIR)$(bindir)/nmapfe; \
fi
# Create a symlink from xnmap to zenmap unconditionally.
ln -sf zenmap $(DESTDIR)$(bindir)/xnmap
NSE_FILES = scripts/script.db scripts/*.nse
NSE_LIB_LUA_FILES = nselib/*.lua
NSE_LIB_SO_FILES = nselib-bin/*.so
install-nse: $(TARGET)
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(nmapdatadir)/scripts
cp -f $(NSE_FILES) $(DESTDIR)$(nmapdatadir)/scripts
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(nmapdatadir)/nselib
cp -f $(NSE_LIB_LUA_FILES) $(DESTDIR)$(nmapdatadir)/nselib
$(SHTOOL) mkdir -f -p -m 755 $(DESTDIR)$(nmaplibexecdir)/nselib-bin
cp -f $(NSE_LIB_SO_FILES) $(DESTDIR)$(nmaplibexecdir)/nselib-bin
install: install-nmap $(INSTALLNSE) $(INSTALLZENMAP)
@echo "NMAP SUCCESSFULLY INSTALLED"
uninstall: uninstall-nmap $(UNINSTALLZENMAP)
uninstall-nmap:
rm -f $(DESTDIR)$(bindir)/$(TARGET)
rm -f $(DESTDIR)$(mandir)/man1/$(TARGET).1
rm -rf $(DESTDIR)$(nmapdatadir) $(DESTDIR)$(nmaplibexecdir)
uninstall-zenmap:
cd $(ZENMAPDIR) && $(PYTHON) setup.py uninstall
rm -f $(DESTDIR)$(mandir)/man1/zenmap.1
# Uninstall nmapfe only if it's a symlink.
if [ -L $(DESTDIR)$(bindir)/nmapfe ]; then \
rm -f $(DESTDIR)$(bindir)/nmapfe; \
fi
rm -f $(DESTDIR)$(bindir)/xnmap
${srcdir}/configure: configure.ac
cd ${srcdir} && autoconf
## autoheader might not change config.h.in, so touch a stamp file.
#${srcdir}/config.h.in: stamp-h.in
#${srcdir}/stamp-h.in: configure.ac acconfig.h \
# config.h.top config.h.bot
# cd ${srcdir} && autoheader
# echo timestamp > ${srcdir}/stamp-h.in
#
#config.h: stamp-h
#stamp-h: config.h.in config.status
# ./config.status
Makefile: Makefile.in config.status
./config.status
config.status: configure
./config.status --recheck
makefile.dep:
$(CXX) -MM $(CPPFLAGS) $(SRCS) > $@
include makefile.dep