Make some generic print routines that take, as an argument, a pointer to
[obnox/wireshark/wip.git] / Makefile.nmake
1 ## Makefile for building ethereal.exe with Microsoft C and nmake
2 ## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
3 #
4 # $Id$
5
6 include config.nmake
7 include <win32.mak>
8
9 ############### no need to modify below this line #########
10
11 CC = cl
12 LINK= link
13
14 LDFLAGS = /NOLOGO /INCREMENTAL:no /MACHINE:I386 $(LOCAL_LDFLAGS)
15
16 CFLAGS=-DHAVE_CONFIG_H $(LOCAL_CFLAGS) $(GLIB_CFLAGS) /I. /Iwiretap \
17         $(ZLIB_CFLAGS) /I$(PCAP_DIR)\include \
18         /I$(NET_SNMP_DIR)\include /I$(NET_SNMP_DIR)\win32 \
19         $(ADNS_CFLAGS) $(PCRE_CFLAGS) -D_U_=""
20
21 CVARSDLL=-DWIN32 -DNULL=0 -D_MT -D_DLL
22
23 .c.obj::
24         $(CC) $(CVARSDLL) $(CFLAGS) -Fd.\ -c $<
25
26 PLATFORM_SRC = capture-wpcap.c
27
28 include Makefile.common
29
30 #include epan\Makefile.common
31
32 BUILT_SOURCES = $(BUILT_SOURCES) \
33         svnversion.h
34
35 #DISSECTOR_SUPPORT_SRC = $(DISSECTOR_SUPPORT_SRC:../=)
36 #DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj)
37 #DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_OBJECTS:../=)
38
39 ethereal_OBJECTS = $(ethereal_SOURCES:.c=.obj)
40 tethereal_OBJECTS = $(tethereal_SOURCES:.c=.obj)
41 dftest_OBJECTS = $(dftest_SOURCES:.c=.obj)
42
43 randpkt_OBJECTS = $(randpkt_SOURCES:.c=.obj)
44
45 EXTRA_OBJECTS = \
46 #       snprintf.obj    \
47 #       strerror.obj    \
48         mkstemp.obj     \
49         strptime.obj
50
51 ethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
52         wsock32.lib user32.lib shell32.lib \
53         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib \
54 !IFDEF ENABLE_LIBETHEREAL
55         epan\libethereal.lib \
56 !ELSE
57         epan\dissectors\dissectors.lib \
58         epan\ethereal.lib \
59         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
60         $(ADNS_LIBS) \
61         $(PCRE_LIBS) \
62         $(ZLIB_LIBS)
63 !ENDIF
64 #       $(PCAP_DIR)\lib\wpcap.lib
65
66 tethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
67         wsock32.lib user32.lib \
68         $(GLIB_LIBS) \
69         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib \
70 !IFDEF ENABLE_LIBETHEREAL
71         epan\libethereal.lib \
72 !ELSE
73         epan\dissectors\dissectors.lib \
74         epan\ethereal.lib \
75         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
76         $(ADNS_LIBS) \
77         $(PCRE_LIBS) \
78         $(ZLIB_LIBS)
79 !ENDIF
80
81 editcap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
82         wsock32.lib user32.lib \
83         $(GLIB_LIBS)
84
85 mergecap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
86         wsock32.lib user32.lib \
87         $(GLIB_LIBS)
88
89 dftest_LIBS=  wiretap\wiretap-$(WTAP_VERSION).lib \
90         wsock32.lib user32.lib \
91         $(GLIB_LIBS) \
92         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib \
93 !IFDEF ENABLE_LIBETHEREAL
94         epan\libethereal.lib \
95 !ELSE
96         epan\dissectors\dissectors.lib \
97         epan\ethereal.lib \
98         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
99         $(ADNS_LIBS) \
100         $(PCRE_LIBS) \
101         $(ZLIB_LIBS)    
102 !ENDIF
103
104 randpkt_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
105         user32.lib \
106         $(GLIB_LIBS) \
107         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib
108
109 EXECUTABLES=ethereal.exe ethereal-gtk2.exe tethereal.exe editcap.exe mergecap.exe text2pcap.exe
110
111 RESOURCES=image\ethereal.res image\libethereal.res image\tethereal.res image\editcap.res image\mergecap.res image\text2pcap.res image\wiretap.res
112
113 all: config.h tools image wiretap epan $(EXECUTABLES) $(RESOURCES) doc
114
115 packaging: all
116         cd packaging
117         cd nsis
118         nmake -f makefile.nmake
119         cd ..
120         cd ..
121
122 separate_packaging: all
123         cd packaging
124         cd nsis
125 !IFDEF GTK1_DIR
126         nmake -f makefile.nmake GTK1_ONLY="USE"
127 !ENDIF
128 !IFDEF GTK2_DIR
129         nmake -f makefile.nmake GTK2_ONLY="USE"
130 !ENDIF
131         cd ..
132         cd ..
133
134 $(RESOURCES): image
135
136 wiretap\wiretap-$(WTAP_VERSION).lib: wiretap
137
138 !IFNDEF GTK1_DIR
139 ethereal.exe    : 
140 !ELSE
141 ethereal.exe    : config.h svnversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk\libui.lib plugins
142         @echo Linking $@
143         $(LINK) @<<
144                 /OUT:ethereal.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK1_LIBS) gtk\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
145 <<
146 !ENDIF
147
148 !IFNDEF GTK2_DIR
149 ethereal-gtk2.exe       : 
150 !ELSE
151 ethereal-gtk2.exe       : config.h svnversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk2 image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk2.tmp\libui.lib plugins
152         @echo Linking $@
153         $(LINK) @<<
154                 /OUT:ethereal-gtk2.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK2_LIBS) gtk2.tmp\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
155 <<
156 !ENDIF
157
158 tethereal.exe   : config.h svnversion.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) epan image\tethereal.res wiretap\wiretap-$(WTAP_VERSION).lib plugins
159         @echo Linking $@
160         $(LINK) @<<
161                 /OUT:tethereal.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(tethereal_LIBS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res
162 <<
163
164 editcap.exe     : config.h editcap.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\editcap.res
165         @echo Linking $@
166         $(LINK) @<<
167                 /OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console editcap.obj getopt.obj $(editcap_LIBS) image\editcap.res
168 <<
169
170 mergecap.exe    : config.h svnversion.h mergecap.obj merge.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
171         @echo Linking $@
172         $(LINK) @<<
173                 /OUT:mergecap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console mergecap.obj merge.obj getopt.obj $(mergecap_LIBS) image\mergecap.res
174 <<
175
176 text2pcap.exe   : config.h text2pcap.obj text2pcap-scanner.obj getopt.obj strptime.obj image\text2pcap.res
177         @echo Linking $@
178         $(LINK) @<<
179                 /OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console text2pcap.obj text2pcap-scanner.obj getopt.obj strptime.obj image\text2pcap.res
180 <<
181
182 dftest.exe      : $(dftest_OBJECTS) $(EXTRA_OBJECTS) epan
183         $(LINK) @<<
184                 /OUT:dftest.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dftest_LIBS) $(dftest_OBJECTS) $(EXTRA_OBJECTS)
185 <<
186
187 randpkt.exe     : $(randpkt_OBJECTS) $(EXTRA_OBJECTS)
188         $(LINK) @<<
189                 /OUT:randpkt.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(randpkt_LIBS) $(randpkt_OBJECTS)
190 <<
191
192 config.h        : config.h.win32 config.nmake
193         sed -e s/@VERSION@/$(VERSION)/ \
194             -e "s/@HAVE_GNU_ADNS@/$(ADNS_CONFIG)/" \
195             -e "s/@HAVE_PCRE@/$(PCRE_CONFIG)/" \
196             -e "s/@HAVE_LIBZ@/$(ZLIB_CONFIG)/" \
197             -e "s/@HAVE_LIBPCAP@/$(WINPCAP_CONFIG)/" \
198             -e "s/@HAVE_PCAP_FINDALLDEVS@/$(PCAP_FINDALLDEVS_CONFIG)/" \
199             -e "s/@HAVE_LIBETHEREALDLL@/$(LIBETHEREAL_CONFIG)/" \
200             -e "s/@WPCAP_CONSTIFIED@/$(WPCAP_CONSTIFIED_CONFIG)/" \
201             -e "s/@HAVE_LIBETHEREALDLL@/$(LIBETHEREAL_CONFIG)/" \
202             < config.h.win32 > $@
203
204 ps.c    : rdps.exe print.ps
205         rdps print.ps ps.c
206
207
208 #
209 # Build the version string
210 #
211 svnversion.h:
212         $(PERL) make-version.pl
213
214 #
215 # Build the short version of the authors file for the about dialog
216 #
217 AUTHORS-SHORT: AUTHORS make-authors-short.pl
218         $(PERL) make-authors-short.pl < AUTHORS > AUTHORS-SHORT
219
220
221 #
222 # Build "tethereal-tap-register.c", which contains a function 
223 # "register_all_tap_listeners()"
224 # that calls the register routines for all tehtereal tap listeners.
225 #
226 # We do this by grepping through sources.
227 #
228 # Formatting conventions:  The name of the tap_listener_register_* 
229 # routines must start in column zero, or must be preceded only by 
230 # "void " starting in column zero, and must not be inside #if.
231 #
232 # The first argument is the name of the file to write.
233 # The second argument is the directory in which the source files live.
234 # All subsequent arguments are the files to scan.
235 #
236 tethereal-tap-register.c: $(TETHEREAL_TAP_SRC) make-tapreg-dotc
237         @echo Making tethereal-tap-register.c
238         @$(SH) make-tapreg-dotc tethereal-tap-register.c . $(TETHEREAL_TAP_SRC)
239
240 text2pcap-scanner.c : text2pcap-scanner.l
241         $(LEX) -otext2pcap-scanner.c text2pcap-scanner.l
242
243 gtk2_distclean:
244         rm -f gtk2.tmp/*.*
245         if exist gtk2.tmp rmdir gtk2.tmp
246
247 clean: gtk2_distclean
248         rm -f $(ethereal_OBJECTS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) \
249                 $(EXECUTABLES) $(PDB_FILE) \
250                 editcap.obj mergecap.obj text2pcap.obj getopt.obj\
251                 text2pcap-scanner.obj text2pcap-scanner.c rdps.obj \
252                 rdps.pdb rdps.exe rdps.ilk config.h ps.c AUTHORS-SHORT \
253                 dftest.obj dftest.exe randpkt.obj randpkt.ext doxygen.cfg \
254                 $(RESOURCES)
255         cd wiretap
256         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
257         cd ../gtk
258         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
259         cd ../epan
260         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
261         cd ../plugins
262         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
263         cd ../tools
264         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
265         cd ../image
266         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
267         cd ../doc
268         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
269         cd ../help
270         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
271         cd ../packaging/nsis
272         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
273         cd ../..
274
275 # Call distclean only, if you would like to remove ALL generated files.
276 # Be sure to have python and perl installed to regenerate them.
277 distclean: clean gtk2_distclean
278         rm -f $(BUILT_SOURCES) \
279                 tethereal-tap-register.c 
280         cd wiretap
281         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
282         cd ../gtk
283         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
284         cd ../epan
285         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
286         cd ../plugins
287         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
288         cd ../tools
289         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
290         cd ../image
291         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
292         cd ../doc
293         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
294         cd ../help
295         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
296         cd ../packaging/nsis
297         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
298         cd ../..
299
300 tools::
301         cd tools
302         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
303         cd ..
304
305 image::
306         cd image
307         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
308         cd ..
309
310 wiretap::
311         cd wiretap
312         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
313         cd ..
314
315 gtk:: help config.h svnversion.h AUTHORS-SHORT doxygen
316         cd gtk
317         $(MAKE) /$(MAKEFLAGS) /f Makefile.nmake GTK_CFLAGS="$(GTK1_CFLAGS)" GTK_LIBS="$(GTK1_LIBS)" libui.lib
318         cd ..
319
320 # copy all required files to gtk2.tmp (but only when newer than existing) and compile in that dir
321 gtk2:: help config.h svnversion.h AUTHORS-SHORT
322         if not exist gtk2.tmp mkdir gtk2.tmp
323         cd gtk
324         cp --update --preserve Makefile.* *.c *.h ..\gtk2.tmp
325         cd ..\gtk2.tmp
326         $(MAKE) /$(MAKEFLAGS) /f Makefile.nmake GTK_CFLAGS="$(GTK2_CFLAGS)" GTK_LIBS="$(GTK2_LIBS)" libui.lib
327         cd ..
328
329 epan:: $(DISSECTOR_SUPPORT_OBJECTS) $(EXTRA_OBJECTS) $(RESOURCES) $(BUILT_SOURCES) doxygen
330         cd epan
331         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
332         cd ..
333
334 plugins::
335         cd plugins
336         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
337         cd ..
338
339 doc::
340         cd doc
341         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
342         cd ..
343
344 help::
345         cd help
346         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
347         cd ..
348
349 doxygen.cfg: config.nmake doxygen.cfg.in
350         sed -e s/@VERSION@/$(VERSION)/ \
351             < doxygen.cfg.in > $@
352
353 doxygen-run:
354 !IFDEF DOXYGEN
355         $(DOXYGEN) doxygen.cfg
356 !ENDIF
357
358 doxygen: doxygen.cfg doxygen-run
359
360 REQUIRED_APPS=\
361         $(SH)   \
362         $(YACC) \
363         $(LEX)  \
364         grep    \
365         $(PERL) \
366         $(PYTHON)       \
367         sed     \
368         unzip   \
369         wget
370
371 verify_apps:
372         @$(SH) tools\win32-setup.sh --appverify $(REQUIRED_APPS)
373
374 setup: verify_apps
375 !IF "$(GTK2_INST_VERSION)" == "2.4"
376         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
377                 glib gtk2.4/glib-2.4.2.zip
378         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
379                 glib gtk2.4/glib-dev-2.4.2.zip
380 !ELSE
381         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
382                 glib glib-2.2.3-20040116.zip
383         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
384                 glib glib-dev-2.2.3-20040116.zip
385 !ENDIF
386 !IFDEF GTK1_DIR
387         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
388                 gtk+ gtk+-1.3.0-20030717.zip
389         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
390                 gtk+ gtk+-dev-1.3.0-20030115.zip
391 !ENDIF
392         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
393                 libiconv-1.9.1.bin.woe32 libiconv-1.9.1.bin.woe32.zip
394         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
395                 gettext-runtime-0.13.1 gettext-runtime-0.13.1.zip
396 !IFDEF NET_SNMP_DIR
397         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
398                 . net-snmp-5.1.zip
399 !ENDIF
400 !IFDEF PCAP_DIR
401         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
402                 . wpdpack_3_0.zip
403 !ENDIF
404 !IFDEF ADNS_DIR
405         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
406                 . adns-1.0-win32-03.zip
407 !ENDIF
408 !IFDEF PCRE_DIR
409         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
410                 . pcre-4.4.zip
411 !ENDIF
412 !IFDEF ZLIB_DIR
413         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
414                 zlib121-dll zlib121-dll.zip
415 !ENDIF
416 !IFDEF GTK2_DIR
417 !IF "$(GTK2_INST_VERSION)" == "2.4"
418         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
419                 gtk2 gtk2.4/gtk+-2.4.3.zip
420         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
421                 gtk2 gtk2.4/gtk+-dev-2.4.3.zip
422         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
423                 gtk2 gtk2.4/atk-1.6.0.zip
424         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
425                 gtk2 gtk2.4/atk-dev-1.6.0.zip
426 !ELSE
427         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
428                 gtk2 gtk2/gtk+-2.2.4-20040124.zip
429         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
430                 gtk2 gtk2/gtk+-dev-2.2.4-20040124.zip
431         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
432                 gtk2 gtk2/atk-1.4.0.zip
433         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
434                 gtk2 gtk2/atk-dev-1.4.0.zip
435 !ENDIF
436 !IF "$(PANGO_INST_VERSION)" == "1.4"
437         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
438                 gtk2 gtk2.4/pango-1.4.0.zip
439         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
440                 gtk2 gtk2.4/pango-dev-1.4.0.zip
441 !ELSE
442         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
443                 gtk2 gtk2/pango-1.2.5-20040124.zip
444         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
445                 gtk2 gtk2/pango-dev-1.2.5-20040124.zip
446 !ENDIF
447 !ENDIF
448 !IFDEF GTK_WIMP_DIR
449         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
450                 gtk-wimp gtk2/gtk-wimp-0.5.4-bin.zip
451 !ENDIF
452         @echo.
453         @echo Ethereal is ready to build.
454
455 update_plugin_api: config.h
456         cd plugins
457         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake xyzzy
458         cd ..
459