tizen 2.4 release
[external/nghttp2.git] / lib / Makefile.msvc
1 #\r
2 # GNU Makefile for nghttp2 / MSVC.\r
3 #\r
4 # By G. Vanem <gvanem@yahoo.no> 2013\r
5 # The MIT License apply.\r
6 #\r
7 \r
8 #\r
9 # Choose your weapons:\r
10 #  Set 'ZLIB_ROOT' to the root of zlib.\r
11 #  Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension.\r
12 #\r
13 ZLIB_ROOT  = g:/MingW32/src/Compression/zlib-1.2.8\r
14 USE_CYTHON = 1\r
15 \r
16 _VERSION   := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV], //g')\r
17 _VERSION   := $(subst ., ,$(_VERSION))\r
18 VER_MAJOR   = $(word 1,$(_VERSION))\r
19 VER_MINOR   = $(word 2,$(_VERSION))\r
20 VER_MICRO   = $(word 3,$(_VERSION))\r
21 VERSION     = $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)\r
22 VERSION_NUM = ($(VER_MAJOR) << 16) + ($(VER_MINOR) << 8) + $(VER_MICRO)\r
23 \r
24 GENERATED   = 'Generated by $(realpath Makefile.MSVC)'\r
25 \r
26 #\r
27 # Where to copy nghttp2.dll + lib + headers to.\r
28 # Note: 'make install' is not in default targets. Do it explicitly.\r
29 #\r
30 VC_ROOT     = $(realpath $(VCINSTALLDIR))\r
31 INSTALL_BIN = $(VC_ROOT)/bin\r
32 INSTALL_LIB = $(VC_ROOT)/lib\r
33 INSTALL_HDR = $(VC_ROOT)/include\r
34 \r
35 #\r
36 # Build for DEBUG-model and RELEASE at the same time.\r
37 #\r
38 TARGETS = nghttp2.lib  nghttp2.dll  nghttp2_imp.lib \\r
39           nghttp2d.lib nghttp2d.dll nghttp2d_imp.lib\r
40 \r
41 EXT_LIBS = $(ZLIB_ROOT)/zlib.lib ws2_32.lib\r
42 \r
43 OBJ_DIR = MSVC_obj\r
44 \r
45 NGHTTP2_PDB_R = $(OBJ_DIR)/nghttp2.pdb\r
46 NGHTTP2_PDB_D = $(OBJ_DIR)/nghttp2d.pdb\r
47 \r
48 CC       = cl\r
49 CFLAGS   = -I./includes -I$(ZLIB_ROOT) -DHAVE_WINSOCK2_H -Dssize_t=long\r
50 \r
51 CFLAGS_R = -nologo -MD  -W3 -Zi -Fd./$(NGHTTP2_PDB_R)\r
52 CFLAGS_D = -nologo -MDd -W3 -Zi -Fd./$(NGHTTP2_PDB_D) \\r
53            -Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS\r
54 \r
55 LDFLAGS = -nologo -machine:i386 -map -debug -incremental:no # -verbose\r
56 \r
57 NGHTTP2_SRC = nghttp2_buf.c             \\r
58               nghttp2_callbacks.c       \\r
59               nghttp2_frame.c           \\r
60               nghttp2_helper.c          \\r
61               nghttp2_hd.c              \\r
62               nghttp2_hd_huffman.c      \\r
63               nghttp2_hd_huffman_data.c \\r
64               nghttp2_map.c             \\r
65               nghttp2_npn.c             \\r
66               nghttp2_option.c          \\r
67               nghttp2_outbound_item.c   \\r
68               nghttp2_priority_spec.c   \\r
69               nghttp2_pq.c              \\r
70               nghttp2_queue.c           \\r
71               nghttp2_session.c         \\r
72               nghttp2_stream.c          \\r
73               nghttp2_submit.c          \\r
74               nghttp2_version.c\r
75 \r
76 NGHTTP2_OBJ_R = $(addprefix $(OBJ_DIR)/r_, $(notdir $(NGHTTP2_SRC:.c=.obj)))\r
77 NGHTTP2_OBJ_D = $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj)))\r
78 \r
79 all: intro $(OBJ_DIR) $(TARGETS)\r
80         @echo 'Welcome to NgHTTP2 (release + debug).'\r
81         @echo 'Do a "make -f Makefile.MSVC install" at own risk!'\r
82 \r
83 intro:\r
84         @echo 'Building NgHTTP (MSVC) ver. "$(VERSION)".'\r
85 \r
86 test_ver:\r
87         @echo '$$(VERSION):   "$(VERSION)".'\r
88         @echo '$$(_VERSION):  "$(_VERSION)".'\r
89         @echo '$$(VER_MAJOR): "$(VER_MAJOR)".'\r
90         @echo '$$(VER_MINOR): "$(VER_MINOR)".'\r
91         @echo '$$(VER_MICRO): "$(VER_MICRO)".'\r
92 \r
93 $(OBJ_DIR):\r
94         - mkdir $(OBJ_DIR)\r
95 \r
96 install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \\r
97          nghttp2.dll  nghttp2.lib  nghttp2_imp.lib \\r
98          nghttp2d.dll nghttp2d.lib nghttp2d_imp.lib \\r
99          copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON)\r
100 \r
101 #\r
102 # This MUST be done before using the 'install_nghttp2_pyd_1' rule.\r
103 #\r
104 copy_headers_and_libs:\r
105         - mkdir $(INSTALL_HDR)/nghttp2\r
106         cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h)     $(INSTALL_HDR)/nghttp2\r
107         cp --update nghttp2.dll nghttp2d.dll $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN)\r
108         cp --update nghttp2.lib nghttp2d.lib nghttp2_imp.lib nghttp2d_imp.lib  $(INSTALL_LIB)\r
109         @echo\r
110 \r
111 nghttp2.lib: $(NGHTTP2_OBJ_R)\r
112         lib -nologo -out:$@ $^\r
113         @echo\r
114 \r
115 nghttp2d.lib: $(NGHTTP2_OBJ_D)\r
116         lib -nologo -out:$@ $^\r
117         @echo\r
118 \r
119 nghttp2.dll nghttp2_imp.lib: $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res $(OBJ_DIR)/r_nghttp2.def\r
120         link $(LDFLAGS) -dll -out:nghttp2.dll -implib:nghttp2_imp.lib -def:$(OBJ_DIR)/r_nghttp2.def \\r
121              $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS)\r
122         @echo\r
123 \r
124 nghttp2d.dll nghttp2d_imp.lib: $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(OBJ_DIR)/d_nghttp2.def\r
125         link $(LDFLAGS) -dll -out:nghttp2d.dll -implib:nghttp2d_imp.lib -def:$(OBJ_DIR)/d_nghttp2.def \\r
126              $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS)\r
127         @echo\r
128 \r
129 install_nghttp2_pyd_0: ;\r
130 \r
131 install_nghttp2_pyd_1: $(addprefix ../python/, setup.py.in nghttp2.pyx)\r
132         cd ../python ; \\r
133         echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \\r
134         sed -e 's/@top_srcdir@/../'   \\r
135             -e 's/@top_builddir@/../' \\r
136             -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ; \\r
137         cython -v nghttp2.pyx ; \\r
138         python setup.py install\r
139 \r
140 clean_nghttp2_pyd_0: ;\r
141 \r
142 clean_nghttp2_pyd_1:\r
143         cd ../python ; \\r
144         rm -f setup.py nghttp2.c ; \\r
145         rm -fR build/*\r
146 \r
147 $(OBJ_DIR)/r_%.obj: %.c\r
148         $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $<\r
149         @echo\r
150 \r
151 $(OBJ_DIR)/d_%.obj: %.c\r
152         $(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $<\r
153         @echo\r
154 \r
155 $(OBJ_DIR)/r_nghttp2.res: nghttp2.rc\r
156         rc -nologo -D_RELEASE -Fo $@ $<\r
157         @echo\r
158 \r
159 $(OBJ_DIR)/d_nghttp2.res: nghttp2.rc\r
160         rc -nologo -D_DEBUG -Fo $@ $<\r
161         @echo\r
162 \r
163 includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in\r
164         sed < includes/nghttp2/nghttp2ver.h.in     \\r
165              -e 's/@PACKAGE_VERSION@/$(VERSION)/g' \\r
166              -e 's/@PACKAGE_VERSION_NUM@/($(VERSION_NUM))/g' > $@\r
167         touch --reference=includes/nghttp2/nghttp2ver.h.in $@\r
168 \r
169 \r
170 define RES_FILE\r
171   #include <winver.h>\r
172 \r
173   VS_VERSION_INFO VERSIONINFO\r
174     FILEVERSION    $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0\r
175     PRODUCTVERSION $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0\r
176     FILEFLAGSMASK  0x3fL\r
177     FILEOS         0x40004L\r
178     FILETYPE       0x2L\r
179     FILESUBTYPE    0x0L\r
180   #ifdef _DEBUG\r
181     #define        VER_STR  "$(VERSION).0 (MSVC debug)"\r
182     #define        DBG      "d"\r
183     FILEFLAGS      0x1L\r
184   #else\r
185     #define        VER_STR  "$(VERSION).0 (MSVC release)"\r
186     #define        DBG      ""\r
187     FILEFLAGS      0x0L\r
188   #endif\r
189   BEGIN\r
190     BLOCK "StringFileInfo"\r
191     BEGIN\r
192       BLOCK "040904b0"\r
193       BEGIN\r
194         VALUE "CompanyName",      "http://tatsuhiro-t.github.io/nghttp2/"\r
195         VALUE "FileDescription",  "nghttp2; HTTP/2 C library"\r
196         VALUE "FileVersion",      VER_STR\r
197         VALUE "InternalName",     "nghttp2" DBG\r
198         VALUE "LegalCopyright",   "The MIT License"\r
199         VALUE "LegalTrademarks",  ""\r
200         VALUE "OriginalFilename", "nghttp2" DBG ".dll"\r
201         VALUE "ProductName",      "NGHTTP2."\r
202         VALUE "ProductVersion",   VER_STR\r
203         VALUE "PrivateBuild",     "The privat build of <gvanem@yahoo.no>."\r
204         VALUE "SpecialBuild",     ""\r
205       END\r
206     END\r
207   BLOCK "VarFileInfo"\r
208   BEGIN\r
209     VALUE "Translation", 0x409, 1200\r
210   END\r
211   END\r
212 endef\r
213 \r
214 export RES_FILE\r
215 \r
216 nghttp2.rc: Makefile.MSVC\r
217         @echo 'Generating $@...'\r
218         @echo ' /* $(GENERATED). DO NOT EDIT.' > $@\r
219         @echo '  */'                          >> $@\r
220         @echo "$$RES_FILE"                    >> $@\r
221 \r
222 $(OBJ_DIR)/r_nghttp2.def: Makefile.MSVC\r
223         @echo 'Generating $@...'\r
224         @echo '; $(GENERATED). DO NOT EDIT.' > $@\r
225         @echo ';'                           >> $@\r
226         @echo 'LIBRARY nghttp2.dll'         >> $@\r
227         @echo 'EXPORTS'                     >> $@\r
228         nm $(NGHTTP2_OBJ_R) | grep ' T .*_nghttp2' | sed 's/^.* _/  /' >> $@\r
229         @echo 'NGHTTP2_STATIC_TABLE_LENGTH DATA' >> $@\r
230 \r
231 $(OBJ_DIR)/d_nghttp2.def: Makefile.MSVC\r
232         @echo 'Generating $@...'\r
233         @echo '; $(GENERATED). DO NOT EDIT.' > $@\r
234         @echo ';'                           >> $@\r
235         @echo 'LIBRARY nghttp2d.dll'        >> $@\r
236         @echo 'EXPORTS'                     >> $@\r
237         nm $(NGHTTP2_OBJ_D) | grep ' T .*_nghttp2' | sed 's/^.* _/  /' >> $@\r
238         @echo 'NGHTTP2_STATIC_TABLE_LENGTH DATA' >> $@\r
239 \r
240 clean:\r
241         rm -f $(OBJ_DIR)/* nghttp2_imp.exp nghttp2_imp.exp \\r
242               nghttp2.map nghttp2d.map nghttp2.rc includes/nghttp2/nghttp2ver.h\r
243         @echo\r
244 \r
245 vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON)\r
246         rm -f $(TARGETS) nghttp2.pdb nghttp2d.pdb nghttp2_imp.exp nghttp2d_imp.exp .depend.MSVC\r
247         - rmdir $(OBJ_DIR)\r
248 \r
249 #\r
250 # Use gcc to generated the dependencies. No MSVC specific args please!\r
251 #\r
252 REPLACE_R = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/r_\1.obj: /'\r
253 REPLACE_D = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/d_\1.obj: /'\r
254 \r
255 depend: includes/nghttp2/nghttp2ver.h\r
256         @echo '# $(GENERATED). DO NOT EDIT.' > .depend.MSVC\r
257         gcc -MM $(CFLAGS) $(NGHTTP2_SRC)    >> .depend.tmp\r
258         @echo '#'                           >> .depend.MSVC\r
259         @echo '# Release lib objects:'      >> .depend.MSVC\r
260         sed -e $(REPLACE_R) .depend.tmp     >> .depend.MSVC\r
261         @echo '#'                           >> .depend.MSVC\r
262         @echo '# Debug lib objects:'        >> .depend.MSVC\r
263         sed -e $(REPLACE_D) .depend.tmp     >> .depend.MSVC\r
264         rm -f .depend.tmp\r
265 \r
266 -include .depend.MSVC