From Fulko Hew via https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=4615 :
[obnox/wireshark/wip.git] / epan / Makefile.nmake
1 ## Makefile for building wireshark.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 include ..\Makefile.nmake.inc
9
10 include Makefile.common
11
12 LINK= link
13
14 # We use GENERATED_CFLAGS to get around flex's non-LLP64-compliant output
15 GENERATED_CFLAGS=-DHAVE_CONFIG_H /I. /I.. /I../wiretap $(GLIB_CFLAGS) \
16         $(ZLIB_CFLAGS) $(C_ARES_CFLAGS) $(ADNS_CFLAGS) $(PCRE_CFLAGS) \
17         $(LUA_CFLAGS) $(GNUTLS_CFLAGS) /I$(PCAP_DIR)\include \
18         $(SMI_CFLAGS) $(GEOIP_CFLAGS) -D_U_="" $(LOCAL_CFLAGS)
19 CFLAGS=-WX $(GENERATED_CFLAGS)
20
21 CVARSDLL=-DWIN32 -DNULL=0 -D_MT -D_DLL
22
23 !IFDEF LUA_DIR
24 WSLUA_LIB=wslua\wslua.lib
25 WSLUA_DIR=wslua
26 !ELSE
27 WSLUA_LIB=
28 WSLUA_DIR=
29 !ENDIf
30
31 !IFDEF PYTHON_DIR
32 WSPYTHON_LIB=wspython\wspython.lib
33 WSPYTHON_DIR=wspython
34 !ELSE
35 WSPYTHON_LIB=
36 WSPYTHON_DIR=
37 !ENDIf
38
39 # For use when making libwireshark.dll
40 libwireshark_LIBS = \
41         $(GLIB_LIBS)    \
42         $(C_ARES_LIBS) \
43         $(ADNS_LIBS) \
44         $(PCRE_LIBS) \
45         $(KFW_LIBS) \
46         $(NETTLE_LIBS) \
47         $(ZLIB_LIBS) \
48         $(GNUTLS_LIBS) \
49         $(LUA_LIBS) \
50         $(PYTHON_LIBS) \
51         $(SMI_LIBS) \
52         $(GEOIP_LIBS) \
53         ..\wsutil\libwsutil.lib \
54         ..\wiretap\wiretap-$(WTAP_VERSION).lib \
55         crc\crc.lib \
56         crypt\airpdcap.lib \
57         ftypes\ftypes.lib \
58         dfilter\dfilter.lib \
59         $(WSLUA_LIB) \
60         $(WSPYTHON_LIB) \
61         dissectors\dissectors.lib
62
63 .c.obj::
64         $(CC) $(CVARSDLL) $(CFLAGS) -Fd.\ -c $<
65
66 LIBWIRESHARK_OBJECTS = $(LIBWIRESHARK_ALL_SRC:.c=.obj)
67
68 EXTRA_OBJECTS = \
69 !IF defined(NASM) && "$(WIRESHARK_TARGET_PLATFORM)" == "win32"
70         asm_utils_win32_x86.obj
71 !ELSE
72         asm_utils.obj
73 !ENDIF
74
75 !IFDEF DOXYGEN
76 DOXYGEN_DEP=doxygen
77 !ENDIF
78
79 !IFDEF ENABLE_LIBWIRESHARK
80 all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.dll
81 !ELSE
82 all: crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors libwireshark.lib
83 !ENDIF
84
85 # For use when making libwireshark.dll
86 libwireshark.lib: libwireshark.dll
87 libwireshark.exp: libwireshark.dll
88
89 libwireshark.dll: ..\config.h $(LIBWIRESHARK_OBJECTS) libwireshark.def crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
90                  crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib dissectors\dissectors.lib $(WSLUA_LIB) $(WSPYTHON_LIB) ..\image\libwireshark.res
91         @echo Linking libwireshark.dll
92         $(link) $(dlllflags) $(conlibsdll) shell32.lib \
93                 $(LOCAL_LDFLAGS) $(DLL_LDFLAGS) \
94                 /DEF:libwireshark.def /OUT:libwireshark.dll \
95                 /IMPLIB:libwireshark.lib $(LIBWIRESHARK_OBJECTS) \
96                 $(libwireshark_LIBS) ..\image\libwireshark.res \
97                 dissectors\register.obj \
98                 $(EXTRA_OBJECTS)
99
100 libwireshark.lib        : ..\config.h $(LIBWIRESHARK_OBJECTS) crc crypt ftypes dfilter $(WSLUA_DIR) $(WSPYTHON_DIR) dissectors $(DOXYGEN_DEP) $(EXTRA_OBJECTS) \
101                   crc\crc.lib crypt\airpdcap.lib ftypes\ftypes.lib dfilter\dfilter.lib $(WSLUA_LIB) $(WSPYTHON_LIB) dissectors\dissectors.lib
102         link /lib /out:libwireshark.lib $(LIBWIRESHARK_OBJECTS) \
103                 $(EXTRA_OBJECTS)
104
105 ..\config.h     : ..\config.h.win32 ..\config.nmake
106         cd ..
107         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake config.h
108         cd epan
109
110 clean-local:
111         rm -f $(LIBWIRESHARK_OBJECTS) $(EXTRA_OBJECTS) \
112                 libwireshark.lib libwireshark.dll *.manifest libwireshark.exp \
113                 *.pdb doxygen.cfg html/*.* \
114                 exntest.obj exntest.exe reassemble_test.obj reassemble_test.exe tvbtest.obj tvbtest.exe
115         if exist html rmdir html
116
117 clean:  clean-local
118         cd crc
119         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
120         cd ../crypt
121         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
122         cd ../ftypes
123         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
124         cd ../dfilter
125         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
126         cd ../dissectors
127         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
128         cd ../wslua
129         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
130         cd ../wspython
131         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake clean
132         cd ..
133
134 #
135 # We remove the Flex-generated files with "distclean" because they need
136 # different #includes for UN*X and Windows (UN*X versions of Flex make it
137 # include <unistd.h>, but that's a UN*X-only header), so if you're going
138 # to build from source, you need to build those scanners from the
139 # corresponding ".l" files with Flex.
140 # This might not be necessary for "dtd_grammar.{c,h}", but we handle them
141 # the same for now.
142 #
143 distclean-local: clean-local
144         rm -f config.h register.c mkstemp.c \
145                 $(LIBWIRESHARK_DISTCLEAN_GENERATED_SRC) \
146                 $(LIBWIRESHARK_DISTCLEAN_GENERATED_INCLUDES) \
147                 $(LIBWIRESHARK_NODISTCLEAN_GENERATED_SRC) \
148                 $(LIBWIRESHARK_NODISTCLEAN_GENERATED_INCLUDES) \
149                 dtd_grammar.out sminmpec.c
150
151 distclean: distclean-local
152         cd crc
153         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
154         cd ../crypt
155         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
156         cd ../ftypes
157         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
158         cd ../dfilter
159         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
160         cd ../dissectors
161         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
162         cd ../wslua
163         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
164         cd ../wspython
165         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake distclean
166         cd ..
167
168 maintainer-clean-local: distclean-local
169
170 maintainer-clean: maintainer-clean-local
171         cd crc
172         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
173         cd ../crypt
174         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
175         cd ../ftypes
176         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
177         cd ../dfilter
178         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
179         cd ../dissectors
180         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
181         cd ../wslua
182         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
183         cd ../wspython
184         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake maintainer-clean
185         cd ..
186
187 crc:: ..\config.h
188         cd crc
189         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
190         cd ..
191
192 crypt:: ..\config.h
193         cd crypt
194         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
195         cd ..
196
197 ftypes:: ..\config.h
198         cd ftypes
199         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
200         cd ..
201
202 dfilter:: ..\config.h
203         cd dfilter
204         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
205         cd ..
206
207 dissectors:: ..\config.h
208         cd dissectors
209         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
210         cd ..
211
212 wslua:: ..\config.h
213         cd wslua
214         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
215         cd ..
216
217 wspython:: ..\config.h
218         cd wspython
219         $(MAKE) /$(MAKEFLAGS) -f Makefile.nmake
220         cd ..
221
222 doxygen.cfg: ..\config.nmake doxygen.cfg.in
223         sed -e s/@VERSION@/$(VERSION)/ \
224             < doxygen.cfg.in > $@
225
226 doxygen-run:
227 !IFDEF DOXYGEN
228         $(DOXYGEN) doxygen.cfg
229 !ENDIF
230
231 doxygen: doxygen.cfg doxygen-run
232
233 # Rules for making unit tests
234 exntest: exntest.exe
235 reassemble_test: reassemble_test.exe
236 tvbtest: tvbtest.exe
237
238 # Object files for exntest
239 EXNTEST_OBJ=exntest.obj except.obj
240
241 exntest.exe: $(EXNTEST_OBJ)
242         @echo Linking $@
243         $(LINK) /OUT:$@ $(conflags) $(conlibsdll) $(LOCAL_LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console \
244                 $(GLIB_LIBS) $(EXNTEST_OBJ)
245 !IFDEF MANIFEST_INFO_REQUIRED
246         mt.exe -nologo -manifest "$@.manifest" -outputresource:$@;1
247 !ENDIF
248
249 # Object files for tvbtest
250 TVBTEST_OBJ=tvbtest.obj \
251         tvbuff.obj \
252         except.obj \
253         to_str.obj \
254         strutil.obj \
255         emem.obj
256
257 tvbtest.exe: $(TVBTEST_OBJ)
258         @echo Linking $@
259         $(LINK) /OUT:$@ $(conflags) $(conlibsdll) $(LOCAL_LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console \
260                 $(GLIB_LIBS) $(ZLIB_LIBS) $(TVBTEST_OBJ)
261 !IFDEF MANIFEST_INFO_REQUIRED
262         mt.exe -nologo -manifest "$@.manifest" -outputresource:$@;1
263 !ENDIF
264
265 # Object files for reassemble_test
266 REASSEMBLE_TEST_OBJ=reassemble_test.obj \
267         tvbuff.obj \
268         except.obj \
269         to_str.obj \
270         strutil.obj \
271         emem.obj \
272         reassemble.obj
273
274 reassemble_test.exe: $(REASSEMBLE_TEST_OBJ)
275         @echo Linking $@
276         $(LINK) /OUT:$@ $(conflags) $(conlibsdll) $(LOCAL_LDFLAGS) /LARGEADDRESSAWARE /SUBSYSTEM:console \
277                 $(GLIB_LIBS) $(ZLIB_LIBS) $(REASSEMBLE_TEST_OBJ)
278 !IFDEF MANIFEST_INFO_REQUIRED
279         mt.exe -nologo -manifest "$@.manifest" -outputresource:$@;1
280 !ENDIF
281
282 exntest_install:
283         set copycmd=/y
284         if exist exntest.exe          xcopy exntest.exe          $(INSTALL_DIR) /d
285
286 tvbtest_install:
287         set copycmd=/y
288         if exist tvbtest.exe          xcopy tvbtest.exe          $(INSTALL_DIR) /d
289
290 reassemble_test_install:
291         set copycmd=/y
292         if exist reassemble_test.exe          xcopy reassemble_test.exe          $(INSTALL_DIR) /d
293
294
295 #
296 # Compile some time critical code from assembler if NASM available
297 #
298 !IFDEF NASM
299 asm_utils_win32_x86.obj: asm_utils_win32_x86.asm
300         $(NASM) -f $(WIRESHARK_TARGET_PLATFORM) -o $@ $?
301 !ENDIF
302
303 sminmpec.c: enterprise-numbers ..\tools\make-sminmpec.pl
304         $(PERL) ../tools/make-sminmpec.pl enterprise-numbers sminmpec.c
305
306 RUNLEX=..\tools\runlex.sh
307
308 diam_dict_lex.h: diam_dict.c
309 diam_dict.obj : diam_dict.c
310         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
311
312 dtd_parse_lex.h: dtd_parse.c
313 dtd_parse.obj : dtd_parse.c
314         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
315
316 dtd_preparse_lex.h: dtd_preparse.c
317 dtd_preparse.obj : dtd_preparse.c
318         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
319
320 radius_dict_lex.h: radius_dict.c
321 radius_dict.obj : radius_dict.c
322         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
323
324 uat_load_lex.h: uat_load.c
325 uat_load.obj : uat_load.c
326         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
327
328 LEMON=..\tools\lemon
329
330 dtd_grammar.h: dtd_grammar.c
331 dtd_grammar.c: $(LEMON)\lemon.exe $(LEMON)\lempar.c dtd_grammar.lemon
332         $(LEMON)\lemon t=$(LEMON)\lempar.c dtd_grammar.lemon
333
334 checkapi:
335         $(PERL) ../tools/checkAPIs.pl -g termoutput $(LIBWIRESHARK_SRC)