Get rid of epan/config.h.win32.
[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: Makefile.nmake,v 1.416 2004/05/06 20:48:35 obiot Exp $
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         cvsversion.h
34
35 DISSECTOR_SRC = $(DISSECTOR_SRC:../=)
36 DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
37
38 DISSECTOR_SUPPORT_SRC = $(DISSECTOR_SUPPORT_SRC:../=)
39 DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj)
40
41 # remove register.obj from "DISSECTOR_SUPPORT_OBJECTS". 
42 # creation and compilation of register.c has been moved to epan.  
43 DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_OBJECTS:register.obj=)
44
45 ethereal_OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) $(ethereal_SOURCES:.c=.obj)
46
47 tethereal_OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) $(tethereal_SOURCES:.c=.obj)
48
49 dftest_OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) $(dftest_SOURCES:.c=.obj)
50
51 randpkt_OBJECTS = $(randpkt_SOURCES:.c=.obj)
52
53 EXTRA_OBJECTS = \
54 #       snprintf.obj    \
55 #       strerror.obj    \
56         mkstemp.obj     \
57         strptime.obj
58
59 ethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
60         epan\ethereal.lib \
61         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
62         wsock32.lib user32.lib \
63         $(ADNS_LIBS) \
64         $(PCRE_LIBS) \
65         $(ZLIB_LIBS) \
66         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib
67 #       $(PCAP_DIR)\lib\wpcap.lib
68
69 tethereal_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
70         epan\ethereal.lib \
71         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
72         wsock32.lib user32.lib \
73         $(GLIB_LIBS) \
74         $(ADNS_LIBS) \
75         $(PCRE_LIBS) \
76         $(ZLIB_LIBS) \
77         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib
78
79 editcap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
80         wsock32.lib user32.lib \
81         $(GLIB_LIBS)
82
83 mergecap_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
84         wsock32.lib user32.lib \
85         $(GLIB_LIBS)
86
87 dftest_LIBS=  wiretap\wiretap-$(WTAP_VERSION).lib epan\ethereal.lib \
88         epan\dfilter\dfilter.lib epan\ftypes\ftypes.lib \
89         wsock32.lib user32.lib \
90         wiretap\wiretap-$(WTAP_VERSION).lib \
91         $(GLIB_LIBS) \
92         $(ADNS_LIBS) \
93         $(PCRE_LIBS) \
94         $(ZLIB_LIBS) \
95         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib
96
97 randpkt_LIBS= wiretap\wiretap-$(WTAP_VERSION).lib \
98         user32.lib \
99         $(GLIB_LIBS) \
100         $(NET_SNMP_DIR)\win32\lib\netsnmp.lib
101
102 EXECUTABLES=ethereal.exe ethereal-gtk2.exe tethereal.exe editcap.exe mergecap.exe text2pcap.exe
103
104 RESOURCES=image\ethereal.res image\tethereal.res image\editcap.res image\mergecap.res image\text2pcap.res
105
106 all: config.h tools wiretap epan image $(EXECUTABLES) $(RESOURCES) doc
107
108 packaging: all
109         cd packaging
110         cd nsis
111         nmake -f makefile.nmake
112         cd ..
113         cd ..
114
115 seperate_packaging: all
116         cd packaging
117         cd nsis
118 !IFDEF GTK1_DIR
119         nmake -f makefile.nmake GTK1_ONLY="USE"
120 !ENDIF
121 !IFDEF GTK2_DIR
122         nmake -f makefile.nmake GTK2_ONLY="USE"
123 !ENDIF
124         cd ..
125         cd ..
126
127 $(RESOURCES): image
128
129 wiretap\wiretap-$(WTAP_VERSION).lib: wiretap
130
131 !IFNDEF GTK1_DIR
132 ethereal.exe    : 
133 !ELSE
134 ethereal.exe    : config.h cvsversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk\libui.lib plugins
135         @echo Linking $@
136         $(LINK) @<<
137                 /OUT:ethereal.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK1_LIBS) gtk\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
138 <<
139 !ENDIF
140
141 !IFNDEF GTK2_DIR
142 ethereal-gtk2.exe       : 
143 !ELSE
144 ethereal-gtk2.exe       : config.h cvsversion.h $(ethereal_OBJECTS) $(EXTRA_OBJECTS) epan gtk2 image\ethereal.res wiretap\wiretap-$(WTAP_VERSION).lib gtk2.tmp\libui.lib plugins
145         @echo Linking $@
146         $(LINK) @<<
147                 /OUT:ethereal-gtk2.exe $(guiflags) $(guilibsdll) $(LDFLAGS) /SUBSYSTEM:windows $(ethereal_LIBS) $(GTK2_LIBS) gtk2.tmp\libui.lib $(ethereal_OBJECTS) $(EXTRA_OBJECTS) image\ethereal.res
148 <<
149 !ENDIF
150
151 tethereal.exe   : config.h cvsversion.h $(tethereal_OBJECTS) $(EXTRA_OBJECTS) epan image\tethereal.res wiretap\wiretap-$(WTAP_VERSION).lib plugins
152         @echo Linking $@
153         $(LINK) @<<
154                 /OUT:tethereal.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(tethereal_LIBS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) image\tethereal.res
155 <<
156
157 editcap.exe     : config.h editcap.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\editcap.res
158         @echo Linking $@
159         $(LINK) @<<
160                 /OUT:editcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console editcap.obj getopt.obj $(editcap_LIBS) image\editcap.res
161 <<
162
163 mergecap.exe    : config.h cvsversion.h mergecap.obj getopt.obj wiretap\wiretap-$(WTAP_VERSION).lib image\mergecap.res
164         @echo Linking $@
165         $(LINK) @<<
166                 /OUT:mergecap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console mergecap.obj getopt.obj $(mergecap_LIBS) image\mergecap.res
167 <<
168
169 text2pcap.exe   : config.h text2pcap.obj text2pcap-scanner.obj getopt.obj strptime.obj image\text2pcap.res
170         @echo Linking $@
171         $(LINK) @<<
172                 /OUT:text2pcap.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console text2pcap.obj text2pcap-scanner.obj getopt.obj strptime.obj image\text2pcap.res
173 <<
174
175 dftest.exe      : $(dftest_OBJECTS) $(EXTRA_OBJECTS)
176         $(LINK) @<<
177                 /OUT:dftest.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(dftest_LIBS) $(dftest_OBJECTS) $(EXTRA_OBJECTS)
178 <<
179
180 randpkt.exe     : $(randpkt_OBJECTS) $(EXTRA_OBJECTS)
181         $(LINK) @<<
182                 /OUT:randpkt.exe $(conflags) $(conlibsdll) $(LDFLAGS) /SUBSYSTEM:console $(randpkt_LIBS) $(randpkt_OBJECTS)
183 <<
184
185 config.h        : config.h.win32 config.nmake
186         sed -e s/@VERSION@/$(VERSION)/ \
187             -e "s/@HAVE_GNU_ADNS@/$(ADNS_CONFIG)/" \
188             -e "s/@HAVE_PCRE@/$(PCRE_CONFIG)/" \
189             -e "s/@HAVE_LIBZ@/$(ZLIB_CONFIG)/" \
190             -e "s/@HAVE_LIBPCAP@/$(WINPCAP_CONFIG)/" \
191             -e "s/@HAVE_PCAP_FINDALLDEVS@/$(PCAP_FINDALLDEVS_CONFIG)/" \
192             -e "s/@WPCAP_CONSTIFIED@/$(WPCAP_CONSTIFIED_CONFIG)/" \
193             < config.h.win32 > $@
194
195 ps.c    : rdps.exe print.ps
196         rdps print.ps ps.c
197
198
199 #
200 # Build the version string
201 #
202 cvsversion.h:
203         $(PERL) make-version.pl
204
205 #
206 # The header files listed here are built from x11-fields using Perl;
207 # we declare a dependency here so that they get built.
208 #
209 packet-x11.obj  : packet-x11.c x11-declarations.h x11-register-info.h
210
211 #
212 # Build various header files for the X11 dissector.
213 #
214 x11-declarations.h x11-register-info.h: x11-fields process-x11-fields.pl
215         $(PERL) process-x11-fields.pl <x11-fields
216
217 packet-ncp2222.c : ncp2222.py
218 !IFDEF PYTHON
219         @echo Making packet-ncp2222.c
220         $(PYTHON) ncp2222.py -o packet-ncp2222.c
221 !ELSE
222         @echo Faking packet-ncp2222.c...
223         @echo Python is required to build the NCP disector
224         @echo Hiding packet-ncp.c...
225         mv packet-ncp.c packet-ncp.c.save
226         touch packet-ncp.c $@
227 !ENDIF
228
229 #
230 # Build "tethereal-tap-register.c", which contains a function 
231 # "register_all_tap_listeners()"
232 # that calls the register routines for all tehtereal tap listeners.
233 #
234 # We do this by grepping through sources.
235 #
236 # Formatting conventions:  The name of the tap_listener_register_* 
237 # routines must start in column zero, or must be preceded only by 
238 # "void " starting in column zero, and must not be inside #if.
239 #
240 # The first argument is the name of the file to write.
241 # The second argument is the directory in which the source files live.
242 # All subsequent arguments are the files to scan.
243 #
244 tethereal-tap-register.c: $(TETHEREAL_TAP_SRC) make-tapreg-dotc
245         @echo Making tethereal-tap-register.c
246         @$(SH) make-tapreg-dotc tethereal-tap-register.c . $(TETHEREAL_TAP_SRC)
247
248 text2pcap-scanner.c : text2pcap-scanner.l
249         $(LEX) -otext2pcap-scanner.c text2pcap-scanner.l
250
251 gtk2_distclean:
252         rm -f gtk2.tmp/*.*
253         if exist gtk2.tmp rmdir gtk2.tmp
254
255 clean: gtk2_distclean
256         rm -f $(ethereal_OBJECTS) $(tethereal_OBJECTS) $(EXTRA_OBJECTS) \
257                 $(EXECUTABLES) $(PDB_FILE) \
258                 editcap.obj mergecap.obj text2pcap.obj getopt.obj\
259                 text2pcap-scanner.obj text2pcap-scanner.c rdps.obj \
260                 rdps.pdb config.h ps.c \
261                 rdps.exe rdps.ilk dftest.obj dftest.exe randpkt.obj randpkt.ext \
262                 $(RESOURCES)
263         cd wiretap
264         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
265         cd ../gtk
266         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
267         cd ../epan
268         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
269         cd ../plugins
270         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
271         cd ../tools
272         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
273         cd ../image
274         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
275         cd ../doc
276         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
277         cd ../help
278         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
279         cd ../packaging/nsis
280         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
281         cd ../..
282
283 # Call distclean only, if you would like to remove ALL generated files.
284 # Be sure to have python and perl installed to regenerate them.
285 distclean: clean gtk2_distclean
286         rm -f $(BUILT_SOURCES) \
287                 packet-ncp2222.c tethereal-tap-register.c 
288         cd wiretap
289         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
290         cd ../gtk
291         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
292         cd ../epan
293         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
294         cd ../plugins
295         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
296         cd ../tools
297         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
298         cd ../image
299         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
300         cd ../doc
301         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
302         cd ../help
303         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
304         cd ../packaging/nsis
305         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
306         cd ../..
307
308 tools::
309         cd tools
310         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
311         cd ..
312
313 image::
314         cd image
315         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
316         cd ..
317
318 wiretap::
319         cd wiretap
320         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
321         cd ..
322
323 gtk:: help config.h cvsversion.h
324         cd gtk
325         $(MAKE) /$(MAKEFLAGS) /f Makefile.nmake GTK_CFLAGS="$(GTK1_CFLAGS)" GTK_LIBS="$(GTK1_LIBS)" libui.lib
326         cd ..
327
328 # copy all required files to gtk2.tmp (but only when newer than existing) and compile in that dir
329 gtk2:: help config.h cvsversion.h
330         if not exist gtk2.tmp mkdir gtk2.tmp
331         cd gtk
332         cp --update --preserve Makefile.* *.c *.h ..\gtk2.tmp
333         cd ..\gtk2.tmp
334         $(MAKE) /$(MAKEFLAGS) /f Makefile.nmake GTK_CFLAGS="$(GTK2_CFLAGS)" GTK_LIBS="$(GTK2_LIBS)" libui.lib
335         cd ..
336
337 epan:: packet-ncp2222.c x11-declarations.h x11-register-info.h
338         cd epan
339         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
340         cd ..
341
342 plugins::
343         cd plugins
344         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
345         cd ..
346
347 doc::
348         cd doc
349         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
350         cd ..
351
352 help::
353         cd help
354         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
355         cd ..
356
357 REQUIRED_APPS=\
358         $(SH)   \
359         $(YACC) \
360         $(LEX)  \
361         grep    \
362         $(PERL) \
363         $(PYTHON)       \
364         sed     \
365         unzip   \
366         wget
367
368 verify_apps:
369         @$(SH) tools\win32-setup.sh --appverify $(REQUIRED_APPS)
370
371 setup: verify_apps
372         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
373                 glib glib-2.2.3-20040116.zip
374         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
375                 glib glib-dev-2.2.3-20040116.zip
376 !IFDEF GTK1_DIR
377         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
378                 gtk+ gtk+-1.3.0-20030717.zip
379         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
380                 gtk+ gtk+-dev-1.3.0-20030115.zip
381 !ENDIF
382         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
383                 libiconv-1.9.1.bin.woe32 libiconv-1.9.1.bin.woe32.zip
384         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
385                 gettext-runtime-0.13.1 gettext-runtime-0.13.1.zip
386 !IFDEF NET_SNMP_DIR
387         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
388                 . net-snmp-5.1.zip
389 !ENDIF
390 !IFDEF PCAP_DIR
391         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
392                 . wpdpack_3_0.zip
393 !ENDIF
394 !IFDEF ADNS_DIR
395         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
396                 . adns-1.0-win32-03.zip
397 !ENDIF
398 !IFDEF PCRE_DIR
399         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
400                 . pcre-4.4.zip
401 !ENDIF
402 !IFDEF ZLIB_DIR
403         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
404                 zlib121-dll zlib121-dll.zip
405 !ENDIF
406 !IFDEF GTK2_DIR
407         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
408                 gtk2 gtk2/gtk+-2.2.4-20040124.zip
409         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
410                 gtk2 gtk2/gtk+-dev-2.2.4-20040124.zip
411         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
412                 gtk2 gtk2/pango-1.2.5-20040124.zip
413         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
414                 gtk2 gtk2/pango-dev-1.2.5-20040124.zip
415         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
416                 gtk2 gtk2/atk-1.4.0.zip
417         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
418                 gtk2 gtk2/atk-dev-1.4.0.zip
419         @$(SH) tools\win32-setup.sh --download "$(ETHEREAL_LIBS)" \
420                 gtk-wimp gtk2/gtk-wimp-0.5.3-bin.zip
421 !ENDIF
422         @echo.
423         @echo Ethereal is ready to build.
424
425 update_plugin_api: config.h
426         cd plugins
427         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake xyzzy
428         cd ..
429