bf33acc2d93fe340519fbbed7b76481748d3d2d5
[obnox/wireshark/wip.git] / plugins / mate / Makefile.nmake
1 # Makefile.nmake
2 # nmake file for mate plugin
3 #
4 # $Id$
5 #
6
7 include ..\..\config.nmake
8 include ..\..\Makefile.nmake.inc
9
10 include moduleinfo.nmake
11
12 include Makefile.common
13
14 LEMON=..\..\tools\lemon
15
16 # We use GENERATED_CFLAGS to get around flex's non-LLP64-compliant output
17 GENERATED_CFLAGS=/DHAVE_CONFIG_H /I../.. $(GLIB_CFLAGS) /I$(LEMON)\
18         /I$(PCAP_DIR)\include -D_U_="" $(LOCAL_CFLAGS)
19 CFLAGS=/WX $(GENERATED_CFLAGS)
20
21 .c.obj::
22         $(CC) $(CFLAGS) -Fd.\ -c $<
23
24 LDFLAGS = $(PLUGIN_LDFLAGS)
25
26 !IFDEF ENABLE_LIBWIRESHARK
27 LINK_PLUGIN_WITH=..\..\epan\libwireshark.lib ..\..\wsutil\libwsutil.lib
28 CFLAGS=/DHAVE_WIN32_LIBWIRESHARK_LIB /D_NEED_VAR_IMPORT_ $(CFLAGS)
29
30 DISSECTOR_OBJECTS = $(DISSECTOR_SRC:.c=.obj)
31
32 DISSECTOR_SUPPORT_OBJECTS = $(DISSECTOR_SUPPORT_SRC:.c=.obj)
33
34 OBJECTS = $(DISSECTOR_OBJECTS) $(DISSECTOR_SUPPORT_OBJECTS) plugin.obj
35
36 RESOURCE=$(PLUGIN_NAME).res
37
38 all: $(PLUGIN_NAME).dll
39
40 $(PLUGIN_NAME).rc : moduleinfo.nmake
41         sed -e s/@PLUGIN_NAME@/$(PLUGIN_NAME)/ \
42         -e s/@RC_MODULE_VERSION@/$(RC_MODULE_VERSION)/ \
43         -e s/@RC_VERSION@/$(RC_VERSION)/ \
44         -e s/@MODULE_VERSION@/$(MODULE_VERSION)/ \
45         -e s/@PACKAGE@/$(PACKAGE)/ \
46         -e s/@VERSION@/$(VERSION)/ \
47         -e s/@MSVC_VARIANT@/$(MSVC_VARIANT)/ \
48         < plugin.rc.in > $@
49
50 $(PLUGIN_NAME).dll $(PLUGIN_NAME).exp $(PLUGIN_NAME).lib : $(OBJECTS) $(LINK_PLUGIN_WITH) $(RESOURCE)
51         link -dll /out:$(PLUGIN_NAME).dll $(LDFLAGS) $(OBJECTS) $(LINK_PLUGIN_WITH) \
52         $(GLIB_LIBS) $(RESOURCE)
53
54 #
55 # Build plugin.c, which contains the plugin version[] string, a
56 # function plugin_register() that calls the register routines for all
57 # protocols, and a function plugin_reg_handoff() that calls the handoff
58 # registration routines for all protocols.
59 #
60 # We do this by scanning sources.  If that turns out to be too slow,
61 # maybe we could just require every .o file to have an register routine
62 # of a given name (packet-aarp.o -> proto_register_aarp, etc.).
63 #
64 # Formatting conventions:  The name of the proto_register_* routines an
65 # proto_reg_handoff_* routines must start in column zero, or must be
66 # preceded only by "void " starting in column zero, and must not be
67 # inside #if.
68 #
69 # DISSECTOR_SRC is assumed to have all the files that need to be scanned.
70 #
71 # For some unknown reason, having a big "for" loop in the Makefile
72 # to scan all the files doesn't work with some "make"s; they seem to
73 # pass only the first few names in the list to the shell, for some
74 # reason.
75 #
76 # Therefore, we have a script to generate the plugin.c file.
77 # The shell script runs slowly, as multiple greps and seds are run
78 # for each input file; this is especially slow on Windows.  Therefore,
79 # if Python is present (as indicated by PYTHON being defined), we run
80 # a faster Python script to do that work instead.
81 #
82 # The first argument is the directory in which the source files live.
83 # The second argument is "plugin", to indicate that we should build
84 # a plugin.c file for a plugin.
85 # All subsequent arguments are the files to scan.
86 #
87 !IFDEF PYTHON
88 plugin.c: $(DISSECTOR_SRC) moduleinfo.h ../../tools/make-dissector-reg.py
89         @echo Making plugin.c (using python)
90         @$(PYTHON) "../../tools/make-dissector-reg.py" . plugin $(DISSECTOR_SRC)
91 !ELSE
92 plugin.c: $(DISSECTOR_SRC) moduleinfo.h ../../tools/make-dissector-reg
93         @echo Making plugin.c (using sh)
94         @$(SH) ../../tools/make-dissector-reg . plugin $(DISSECTOR_SRC)
95 !ENDIF
96
97 !ENDIF
98
99 clean:
100         rm -f $(OBJECTS) $(RESOURCE) plugin.c *.pdb \
101             $(PLUGIN_NAME).dll $(PLUGIN_NAME).dll.manifest $(PLUGIN_NAME).lib \
102             $(PLUGIN_NAME).exp $(PLUGIN_NAME).rc
103
104 # We remove the generated files with "distclean" because one of them,
105 # "mate_parser.c", needs different #includes for UN*X and Windows
106 # (UN*X versions of Flex make it include <unistd.h>, but that's a
107 # UN*X-only header), so if you're going to build from source, you need
108 # to build "mate_parser.c" from "mate_parser.l" with Flex.
109 # This might not be necessary for "mate_grammar.{c,h}", but we handle them
110 # the same for now.
111 #
112 distclean: clean
113         rm -f mate_parser.c mate_parser_lex.h mate_grammar.c \
114         mate_grammar.h mate_grammar.out
115
116 maintainer-clean: distclean
117
118 RUNLEX = ..\..\tools\runlex.sh
119
120 mate_parser_lex.h : mate_parser.c
121 mate_parser.obj : mate_parser.c
122         $(CC) $(CVARSDLL) $(GENERATED_CFLAGS) -Fd.\ -c $?
123
124 mate_grammar.h : mate_grammar.c
125 mate_grammar.c : mate_grammar.lemon $(LEMON)\lemon.exe
126         $(LEMON)\lemon.exe t=$(LEMON)\lempar.c mate_grammar.lemon
127
128 $(LEMON)\lemon.exe:
129         cd ../../tools
130         $(MAKE) /$(MAKEFLAGS) -f makefile.nmake lemon
131         cd ../plugins/mate
132
133 checkapi:
134         $(PERL) ../../tools/checkAPIs.pl -g abort -g termoutput $(DISSECTOR_SRC)