summaryrefslogtreecommitdiff
path: root/Makefile.in
blob: 4d00168dbdb63437d2ed162725dd6f1cc9f67d9d (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
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
448
449
450
451
452
453
454
455
456
457
458
459

#
# Makefile.in (at the root of net-snmp)
#

top_builddir	= .
VPATH		= @srcdir@

SUBDIRS		= snmplib @MAINSUBS@
FTSUBDIRS	= @FTMAINSUBS@ snmplib
TESTDIRS	= testing

CPP		= @CPP@ 					        \
		-Iinclude -I$(srcdir)/include -I$(srcdir)/agent/mibgroup -I. -I$(srcdir)	\
		-DDONT_INC_STRUCTS -DBINDIR=$(bindir) 		        \
		$(EXTRACPPFLAGS)

INSTALLHEADERS=version.h net-snmp-features.h
INCLUDESUBDIR=system
INCLUDESUBDIRHEADERS= aix.h bsd.h bsdi3.h bsdi4.h bsdi.h cygwin.h \
	darwin.h darwin7.h darwin8.h darwin9.h darwin10.h dragonfly.h dynix.h \
	freebsd2.h freebsd3.h freebsd4.h freebsd5.h freebsd6.h \
	freebsd7.h freebsd8.h freebsd9.h freebsd10.h freebsd.h \
        generic.h \
	hpux.h irix.h linux.h mingw32.h mips.h netbsd.h osf5.h \
	openbsd.h openbsd5.h openbsd4.h \
	solaris2.3.h solaris2.4.h solaris2.5.h solaris2.6.h \
	solaris.h sunos.h svr5.h sysv.h ultrix4.h
INCLUDESUBDIR2=machine
INCLUDESUBDIRHEADERS2=generic.h
INSTALLBUILTHEADERS=include/net-snmp/net-snmp-config.h
INSTALLBUILTINCLUDEHEADERS=@FEATUREHEADERS@
INSTALLBINSCRIPTS=net-snmp-config net-snmp-create-v3-user
INSTALLUCDHEADERS=ucd-snmp-config.h version.h mib_module_config.h

#
# other install rules.
#
OTHERINSTALL=copypersistentfiles @PERLINSTALLTARGS@ @PYTHONINSTALLTARGS@
OTHERUNINSTALL=@PERLUNINSTALLTARGS@ @PYTHONUNINSTALLTARGS@
COPY_PERSISTENT_FILES=@COPY_PERSISTENT_FILES@
PERSISTENT_DIRECTORY=@PERSISTENT_DIRECTORY@
UCDPERSISTENT_DIRECTORY=@UCDPERSISTENT_DIRECTORY@

#
# perl specific
#
# yes, order matters here.  default_store must occur before anything else
PERLMODULES=default_store SNMP ASN OID agent TrapReceiver
PERLMODULEFTS=perl/default_store/netsnmp-feature-definitions.ft \
	perl/SNMP/netsnmp-feature-definitions.ft \
	perl/ASN/netsnmp-feature-definitions.ft \
	perl/OID/netsnmp-feature-definitions.ft \
	perl/agent/netsnmp-feature-definitions.ft \
	perl/TrapReceiver/netsnmp-feature-definitions.ft
PERLARGS=@PERLARGS@

#
# python specific
#
PYTHONARGS=@PYTHONARGS@
PYTHONMODULEFTS=python/netsnmp/netsnmp-feature-definitions.ft

#
# libtool
#
LIBTOOL_DEPS = @LIBTOOL_DEPS@

#
# feature checks for optional components
#
FTOTHERTARGS=@PERLFEATURES@ @PYTHONFEATURES@

#
# targets
#
all:    sedscript EXAMPLE.conf  @FEATURETARGS@ standardall net-snmp-config-x net-snmp-create-v3-user @PERLTARGS@ @PYTHONTARGS@

start-flag:
	@touch build-in-progress-flag

end-flag:
	@rm -f build-in-progress-flag > /dev/null 2>&1 

libtool:	$(LIBTOOL_DEPS)
	$(SHELL) ./config.status --recheck


snmplib: @FEATURETARGS@
	@(cd snmplib; $(MAKE) )

agent: @FEATURETARGS@
	@(cd snmplib; $(MAKE) )
	@(cd agent; $(MAKE) )

apps: @FEATURETARGS@
	@(cd snmplib; $(MAKE) )
	@(cd agent; $(MAKE) libs)
	@(cd apps; $(MAKE) )

snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext encode_keychange snmpdf snmptrap snmptls: @FEATURETARGS@
	@(cd snmplib; $(MAKE) )
	@(cd apps; $(MAKE) $@ )

agentxtrap snmptrapd: @FEATURETARGS@
	@(cd snmplib; $(MAKE) )
	@(cd agent; $(MAKE) libs)
	@(cd apps; $(MAKE) $@ )

#
# local build rules
#
sedscript: sedscript.in include/net-snmp/net-snmp-config.h $(srcdir)/agent/mibgroup/mibdefs.h
	$(CPP) $(srcdir)/sedscript.in | egrep '^s[/#]' | sed 's/REMOVEME//g;s# */#/#g;s/ *#/#/g;s#/ *#/#g;s/# g/#g/;' > sedscript
	echo 's/VERSIONINFO/$(VERSION)/g' >> sedscript
	echo 's#DATADIR#$(datadir)#g' >> sedscript
	echo 's#LIBDIR#$(libdir)#g' >> sedscript
	echo 's#BINDIR#$(bindir)#g' >> sedscript
	echo 's#PERSISTENT_DIRECTORY#$(PERSISTENT_DIRECTORY)#g' >> sedscript
	echo 's#SYSCONFDIR#@sysconfdir@#g' >> sedscript

EXAMPLE.conf: sedscript EXAMPLE.conf.def
	$(SED) -f sedscript $(srcdir)/EXAMPLE.conf.def > EXAMPLE.conf

docs: docsdir 

docsdir: docsdox

docsdox: doxygen.conf
	srcdir=$(srcdir) VERSION=$(VERSION) doxygen $(srcdir)/doxygen.conf

net-snmp-config-x: net-snmp-config
	chmod a+x net-snmp-config
	touch net-snmp-config-x

net-snmp-create-v3-user-x: net-snmp-create-v3-user
	chmod a+x net-snmp-create-v3-user
	touch net-snmp-create-v3-user-x

#
# extra install rules
#

copypersistentfiles:
	@if test "$(COPY_PERSISTENT_FILES)" = "yes" -a -d $(UCDPERSISTENT_DIRECTORY) -a ! -d $(PERSISTENT_DIRECTORY) ; then \
		cp -pr $(UCDPERSISTENT_DIRECTORY) $(PERSISTENT_DIRECTORY) ; \
		echo "copying $(UCDPERSISTENT_DIRECTORY) to $(PERSISTENT_DIRECTORY)" ; \
	fi
#
# test targets
#
test test-mibs testall testfailed testsimple: all testdirs
	( cd testing; $(MAKE) $@ )

testdirs:
	for i in $(TESTDIRS) ; do	\
           ( cd $$i ; $(MAKE) ) ;		\
           if test $$? != 0 ; then \
              exit 1 ; \
           fi  \
	done

distall: ${srcdir}/configure ${srcdir}/include/net-snmp/net-snmp-config.h 

OTHERCLEANTARGETS=EXAMPLE.conf sedscript
OTHERCLEANTODOS=perlclean @PYTHONCLEANTARGS@ cleanfeatures perlcleanfeatures pythoncleanfeatures

#
# perl specific build rules
#
# override LD_RUN_PATH to avoid dependencies on the build directory
perlmodules: perlmakefiles subdirs
	@(cd perl ; $(MAKE) LD_RUN_PATH="$(libdir):`$(PERL) -e 'use Config; print qq($$Config{archlibexp}/CORE);'`") ; \
        if test $$? != 0 ; then \
           exit 1 ; \
        fi

perlmakefiles: net-snmp-config-x
	@if test ! -f perl/Makefile; then \
	  (dir=`pwd`; \
	   cd perl ; \
	   $(PERL) Makefile.PL -NET-SNMP-IN-SOURCE=true -NET-SNMP-CONFIG="sh $$dir/net-snmp-config" $(PERLARGS) ) ; \
        fi

perlinstall:
	@(cd perl ; $(MAKE) install) ; \
        if test $$? != 0 ; then \
           exit 1 ; \
        fi

perluninstall:
	@(cd perl ; $(MAKE) uninstall) ; \
        if test $$? != 0 ; then \
           exit 1 ; \
        fi

perltest:
	@(cd perl ; $(MAKE) test) ; \
	if test $$? != 0 ; then \
	   exit 1 ; \
	fi

perlclean:
	@if test -f perl/Makefile; then \
	   ( cd perl ; $(MAKE) clean ) ; \
	fi

perlrealclean:
	@if test -f perl/Makefile; then \
	   ( cd perl ; $(MAKE) realclean ) ; \
	fi

.h.ft:
	$(FEATURECHECK) --feature-global $(top_builddir)/include/net-snmp/feature-details.h `dirname $<` $< $@ $(CC) -I $(top_builddir)/include -I $(top_srcdir)/include -E $(CPPFLAGS) $(CFLAGS) -c

perlfeatures: $(PERLMODULEFTS)

perlcleanfeatures:
	$(RM) $(PERLMODULEFTS)


# python specific build rules
#
PYMAKE=$(PYTHON) setup.py $(PYTHONARGS)
pythonmodules: subdirs
	@(dir=`pwd`; cd python; $(PYMAKE) build --basedir=$$dir) ; \
        if test $$? != 0 ; then \
           exit 1 ; \
        fi

pythoninstall:
	@(dir=`pwd`; cd python; $(PYMAKE) install --basedir=$$dir) ; \
        if test $$? != 0 ; then \
           exit 1 ; \
        fi

pythonuninstall:
	echo "WARNING: python doesn't support uninstall"

pythontest:
	@(dir=`pwd`; cd python; $(PYMAKE) test --basedir=$$dir) ; \
	if test $$? != 0 ; then \
	   exit 1 ; \
	fi

pythonclean:
	@(dir=`pwd`; cd python; $(PYMAKE) clean --basedir=$$dir)

pythonfeatures: $(PYTHONMODULEFTS)

pythoncleanfeatures:
	$(RM) $(PYTHONMODULEFTS)

#
# make distclean completely removes all traces of building including
# any files generated by configure itself.
#
distclean: perlrealclean clean configclean tarclean

makefileclean:
	rm -f Makefile snmplib/Makefile				\
		agent/Makefile agent/mibgroup/Makefile		\
		agent/helpers/Makefile				\
		apps/Makefile  apps/snmpnetstat/Makefile	\
		man/Makefile mibs/Makefile ov/Makefile		\
		local/Makefile testing/Makefile

configclean: makefileclean
	rm -f config.cache config.status config.log \
		libtool include/net-snmp/net-snmp-config.h \
		net-snmp-config net-snmp-config-x configure-summary \
		net-snmp-create-v3-user net-snmp-create-v3-user-x
	rm -f mibs/.index
	rm -f include/net-snmp/agent/mib_module_config.h		\
		include/net-snmp/agent/agent_module_config.h		\
		include/net-snmp/library/snmpv3-security-includes.h \
		include/net-snmp/feature-details.h                  \
		snmplib/snmpsm_init.h snmplib/snmpsm_shutdown.h     \
                snmplib/transports/snmp_transport_inits.h           \
		agent/mibgroup/agent_module_includes.h 	\
		agent/mibgroup/agent_module_inits.h 	\
		agent/mibgroup/agent_module_shutdown.h 	\
		agent/mibgroup/agent_module_dot_conf.h  \
		agent/mibgroup/mib_module_includes.h 	\
		agent/mibgroup/mib_module_inits.h 	\
		agent/mibgroup/mib_module_shutdown.h 	\
		agent/mibgroup/mib_module_dot_conf.h
	rm -rf mk
	rm -f *.core

#
# Configure script related targets
#
touchit:
	touch configure include/net-snmp/net-snmp-config.h.in
	touch config.status
	touch stamp-h stamp-h.in

Makefile: Makefile.in config.status Makefile.rules Makefile.top
	@if test "x$(NOAUTODEPS)" = "x"; then \
	    echo "running config.status because the following file(s) changed:"; \
	    echo "  $?"; \
	    ./config.status; \
	else \
	    echo "WARNING: not running config.status"; \
	fi

configure_ac = configure.ac \
	configure.d/config_modules_agent \
	configure.d/config_modules_lib \
	configure.d/config_os_functions \
	configure.d/config_os_headers \
	configure.d/config_os_libs1 \
	configure.d/config_os_libs2 \
	configure.d/config_os_misc1 \
	configure.d/config_os_misc2 \
	configure.d/config_os_misc3 \
	configure.d/config_os_misc4 \
	configure.d/config_os_progs \
	configure.d/config_os_struct_members \
	configure.d/config_project_ipv6_types \
	configure.d/config_project_manual \
	configure.d/config_project_paths \
	configure.d/config_project_perl_python \
	configure.d/config_project_types \
	configure.d/config_project_with_enable

$(srcdir)/include/net-snmp/net-snmp-config.h.in: stamp-h.in
$(srcdir)/stamp-h.in: $(configure_ac) acconfig.h
	@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOHEADER)" != "x:"; then \
	    cd ${srcdir} && LC_COLLATE=C $(AUTOHEADER); \
	    echo timestamp > ${srcdir}/stamp-h.in; \
	else \
	    echo "WARNING: not running autoheader"; \
	fi

include/net-snmp/net-snmp-config.h: stamp-h
stamp-h: include/net-snmp/net-snmp-config.h.in config.status
	@if test "x$(NOAUTODEPS)" = "x"; then \
	    echo "running config.status because the following file(s) changed:"; \
	    echo "  $?"; \
	    ./config.status; \
	    echo timestamp > stamp-h; \
	else \
	    echo "WARNING: not running config.status"; \
	fi

$(srcdir)/configure: $(configure_ac) aclocal.m4
	@if test "x$(NOAUTODEPS)" = "x" -a "x$(AUTOCONF)" != "x:"; then \
	    cd ${srcdir} && $(AUTOCONF); \
	    echo "Please run configure now."; \
	    sh -c exit 2; \
	else \
	    echo "WARNING: not running autoconf"; \
	fi

gendir=dist/generation-scripts
generation-scripts: generation-scripts-dirs $(gendir)/gen-transport-headers $(gendir)/gen-security-headers

$(gendir)/gen-variables: $(gendir)/gen-variables.in
	./config.status

generation-scripts-dirs:
	@if [ ! -d dist ] ; then \
	    mkdir dist ;        \
	fi
	@if [ ! -d dist/generation-scripts ] ; then \
	    mkdir dist/generation-scripts ;        \
	fi

$(gendir)/gen-transport-headers: $(gendir)/gen-transport-headers.in $(gendir)/gen-variables
	rm -f $@
	autoconf -o $@ $<
	chmod a+x $@

$(gendir)/gen-security-headers: $(gendir)/gen-security-headers.in $(gendir)/gen-variables
	rm -f $@
	autoconf -o $@ $<
	chmod a+x $@

config.status: configure
	@if test "x$(NOAUTODEPS)" = "x"; then \
	    echo "running config.status because $? changed"; \
	    ./config.status --recheck; \
	else \
	    echo "WARNING: not running config.status --recheck"; \
	fi

#
# Emacs TAGS file
#
TAGS:
	$(FIND) $(srcdir) -path $(srcdir)/dist/rpm -prune -o -name '*.[ch]' -print | etags -

#
# Internal distribution packaging, etc.
#
#tag:
#	@if test "x$(VERSION)" = "x"; then \
#	  echo "you need to supply a VERSION string."; \
#	  exit 2; \
#	fi
#	${srcdir}/agent/mibgroup/versiontag $(VERSION) tag

tar:
	@if test "x$(VERSION)" = "x"; then \
	  echo "you need to supply a VERSION string."; \
	  exit 2; \
	fi
	${srcdir}/agent/mibgroup/versiontag $(VERSION) tar

tarclean:
	@if test -x ${srcdir}/agent/mibgroup/versiontag ; then \
	  ${srcdir}/agent/mibgroup/versiontag Ext clean ; \
	fi

checks:
	$(MAKE) -k makefilecheck commentcheck warningcheck dependcheck \
	assertcheck perlcalloccheck

dependcheck:
	@echo "Checking for full paths in dependency files..."
	@if grep -n -E "^/" `$(FIND) $(top_srcdir) -name Makefile.depend`; then false; fi

warningcheck:
	@echo "Checking for cpp warnings..."
	@if grep -n "#warning" `$(FIND) $(top_srcdir) -name \*.\[ch\]`; then false; fi

assertcheck:
	@echo "Checking for non-snmp asserts..."
	@if grep -n -w "assert" `$(FIND) $(top_srcdir) -name \*.\[ch\] | grep -v snmp_assert.h | egrep -v 'perl/.*c' | grep -v openssl`; then false; fi

commentcheck:
	@echo "Checking for C++ style comments..."
	@if grep -n -E "([^:)n]|^)//" `$(FIND) $(top_srcdir) -path './win32' -prune -o -name \*.\[ch\] | grep -v agent/mibgroup/winExtDLL.c`; then false; fi

makefilecheck:
	@echo "Checking for non-portable Makefile constructs..."
	@if grep -n "\.c=" `$(FIND) $(top_srcdir) -name .svn -prune -o -path ./Makefile.in -prune -o -name "Makefile.*" -print`; then false; fi

# Invoking calloc() directly or indirectly from a Perl XSUB and freeing that
# memory by calling free() from the XSUB is a sure way to trigger "Free to
# wrong pool" errors on Windows.
perlcalloccheck:
	@echo "Checking for calloc() in Perl's external subroutines ..."
	@if grep -nwE 'calloc|SNMP_MALLOC_STRUCT|SNMP_MALLOC_TYPEDEF' `$(FIND) $(top_srcdir) -name '*.xs'`; then false; fi

dist: tar

FAQ.html:
	local/FAQ2HTML FAQ

.PHONY: docs docsdir mancp testdirs test TAGS
# note: tags and docs are phony to force rebulding
.PHONY: snmplib agent apps \
	snmpget snmpbulkget snmpwalk snmpbulkwalk snmptranslate snmpstatus \
	snmpdelta snmptable snmptest snmpset snmpusm snmpvacm snmpgetnext \
	encode_keychange snmpdf snmptrap snmptrapd
.PHONY: perlfeatures pythonfeatures