summaryrefslogtreecommitdiffstats
path: root/rules/nmap.make
blob: 48a0c38b61e93a4e033f92cc269a7f9b39c4b0ba (plain)
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
# -*-makefile-*-
# $Id$
#
# Copyright (C) 2003 Ixia Corporation (www.ixiacom.com), by Milan Bobde
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
ifdef PTXCONF_NMAP
PACKAGES += nmap
endif

#
# We depend on this package
#
ifdef PTXCONF_NMAP
PACKAGES += libpcap
endif

#
# Paths and names 
#
NMAP_VERSION		= 3.48
NMAP			= nmap-$(NMAP_VERSION)
NMAP_SUFFIX		= tgz
NMAP_URL		= http://download.insecure.org/nmap/dist/$(NMAP).$(NMAP_SUFFIX)
NMAP_SOURCE		= $(SRCDIR)/$(NMAP).$(NMAP_SUFFIX)
NMAP_DIR		= $(BUILDDIR)/$(NMAP)

# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

nmap_get: $(STATEDIR)/nmap.get

nmap_get_deps  =  $(NMAP_SOURCE)

$(STATEDIR)/nmap.get: $(nmap_get_deps)
	@$(call targetinfo, $@)
	touch $@

$(NMAP_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, $(NMAP_URL))

# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

nmap_extract: $(STATEDIR)/nmap.extract

$(STATEDIR)/nmap.extract: $(STATEDIR)/nmap.get
	@$(call targetinfo, $@)
	@$(call clean, $(NMAP_DIR))
	@$(call extract, $(NMAP_SOURCE))
	touch $@

# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

nmap_prepare: $(STATEDIR)/nmap.prepare

#
# dependencies
#
nmap_prepare_deps = \
	$(STATEDIR)/virtual-xchain.install \
	$(STATEDIR)/nmap.extract \
	$(STATEDIR)/libpcap.install

NMAP_PATH	=  PATH=$(CROSS_PATH)
NMAP_ENV = \
	$(CROSS_ENV) \
	ac_cv_linux_vers=$(KERNEL_VERSION_MAJOR)

#
# autoconf
#
NMAP_AUTOCONF =  $(CROSS_AUTOCONF)
NMAP_AUTOCONF += --prefix=/usr
NMAP_AUTOCONF += --with-pcap=linux 
#
# FIXME:
#
# nmap works only with openssh shared libs, dunnno why...
#
ifdef PTXCONF_OPENSSL_SHARED
NMAP_AUTOCONF		+= --with-openssl=$(CROSS_LIB_DIR)
nmap_prepare_deps	+= $(STATEDIR)/openssl.install
else
NMAP_AUTOCONF		+= --without-openssl
endif

$(STATEDIR)/nmap.prepare: $(nmap_prepare_deps)
	@$(call targetinfo, $@)
	cd $(NMAP_DIR) && \
		$(NMAP_PATH) $(NMAP_ENV) \
		./configure $(NMAP_AUTOCONF)
	touch $@

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

nmap_compile: $(STATEDIR)/nmap.compile

nmap_compile_deps = $(STATEDIR)/nmap.prepare

$(STATEDIR)/nmap.compile: $(nmap_compile_deps) 
	@$(call targetinfo, $@)
#
# dftables is a tool that is run during make in the host system
#
	$(NMAP_PATH) make -C $(NMAP_DIR)/libpcre $(HOSTCC_ENV) CFLAGS='' CXXFLAGS='' dftables
	$(NMAP_PATH) make -C $(NMAP_DIR) nmap
	touch $@

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

nmap_install: $(STATEDIR)/nmap.install

$(STATEDIR)/nmap.install: $(STATEDIR)/nmap.compile
	@$(call targetinfo, $@)
	touch $@

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

nmap_targetinstall: $(STATEDIR)/nmap.targetinstall

nmap_targetinstall_deps	=  $(STATEDIR)/nmap.install
ifdef PTXCONF_OPENSSL_SHARED
nmap_targetinstall_deps	+= $(STATEDIR)/openssl.targetinstall
endif

$(STATEDIR)/nmap.targetinstall: $(nmap_targetinstall_deps)
	@$(call targetinfo, $@)
	install -D $(NMAP_DIR)/nmap $(ROOTDIR)/usr/bin/nmap
	$(CROSSSTRIP) -R .note -R .comment $(ROOTDIR)/usr/bin/nmap

ifdef PTXCONF_NMAP_SERVICES
	mkdir -p $(ROOTDIR)/usr/share/nmap
	install -m 644 $(NMAP_DIR)/nmap-os-fingerprints $(ROOTDIR)/usr/share/nmap/nmap-os-fingerprints
	install -m 644 $(NMAP_DIR)/nmap-service-probes $(ROOTDIR)/usr/share/nmap/nmap-service-probes
	install -m 644 $(NMAP_DIR)/nmap-services $(ROOTDIR)/usr/share/nmap/nmap-services
	install -m 644 $(NMAP_DIR)/nmap-protocols $(ROOTDIR)/usr/share/nmap/nmap-protocols
	install -m 644 $(NMAP_DIR)/nmap-rpc $(ROOTDIR)/usr/share/nmap/nmap-rpc
endif
	touch $@

# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

nmap_clean: 
	rm -rf $(STATEDIR)/nmap.* $(NMAP_DIR)

# vim: syntax=make