2 # GNU Makefile for nghttp2 / MSVC.
\r
4 # By G. Vanem <gvanem@yahoo.no> 2013
\r
5 # The MIT License apply.
\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
13 ZLIB_ROOT = g:/MingW32/src/Compression/zlib-1.2.8
\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
24 GENERATED = 'Generated by $(realpath Makefile.MSVC)'
\r
27 # Where to copy nghttp2.dll + lib + headers to.
\r
28 # Note: 'make install' is not in default targets. Do it explicitly.
\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
36 # Build for DEBUG-model and RELEASE at the same time.
\r
38 TARGETS = nghttp2.lib nghttp2.dll nghttp2_imp.lib \
\r
39 nghttp2d.lib nghttp2d.dll nghttp2d_imp.lib
\r
41 EXT_LIBS = $(ZLIB_ROOT)/zlib.lib ws2_32.lib
\r
45 NGHTTP2_PDB_R = $(OBJ_DIR)/nghttp2.pdb
\r
46 NGHTTP2_PDB_D = $(OBJ_DIR)/nghttp2d.pdb
\r
49 CFLAGS = -I./includes -I$(ZLIB_ROOT) -DHAVE_WINSOCK2_H -Dssize_t=long
\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
55 LDFLAGS = -nologo -machine:i386 -map -debug -incremental:no # -verbose
\r
57 NGHTTP2_SRC = nghttp2_buf.c \
\r
58 nghttp2_callbacks.c \
\r
62 nghttp2_hd_huffman.c \
\r
63 nghttp2_hd_huffman_data.c \
\r
67 nghttp2_outbound_item.c \
\r
68 nghttp2_priority_spec.c \
\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
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
84 @echo 'Building NgHTTP (MSVC) ver. "$(VERSION)".'
\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
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
102 # This MUST be done before using the 'install_nghttp2_pyd_1' rule.
\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
111 nghttp2.lib: $(NGHTTP2_OBJ_R)
\r
112 lib -nologo -out:$@ $^
\r
115 nghttp2d.lib: $(NGHTTP2_OBJ_D)
\r
116 lib -nologo -out:$@ $^
\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
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
129 install_nghttp2_pyd_0: ;
\r
131 install_nghttp2_pyd_1: $(addprefix ../python/, setup.py.in nghttp2.pyx)
\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
140 clean_nghttp2_pyd_0: ;
\r
142 clean_nghttp2_pyd_1:
\r
144 rm -f setup.py nghttp2.c ; \
\r
147 $(OBJ_DIR)/r_%.obj: %.c
\r
148 $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $<
\r
151 $(OBJ_DIR)/d_%.obj: %.c
\r
152 $(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $<
\r
155 $(OBJ_DIR)/r_nghttp2.res: nghttp2.rc
\r
156 rc -nologo -D_RELEASE -Fo $@ $<
\r
159 $(OBJ_DIR)/d_nghttp2.res: nghttp2.rc
\r
160 rc -nologo -D_DEBUG -Fo $@ $<
\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
171 #include <winver.h>
\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
181 #define VER_STR "$(VERSION).0 (MSVC debug)"
\r
185 #define VER_STR "$(VERSION).0 (MSVC release)"
\r
190 BLOCK "StringFileInfo"
\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
207 BLOCK "VarFileInfo"
\r
209 VALUE "Translation", 0x409, 1200
\r
216 nghttp2.rc: Makefile.MSVC
\r
217 @echo 'Generating $@...'
\r
218 @echo ' /* $(GENERATED). DO NOT EDIT.' > $@
\r
220 @echo "$$RES_FILE" >> $@
\r
222 $(OBJ_DIR)/r_nghttp2.def: Makefile.MSVC
\r
223 @echo 'Generating $@...'
\r
224 @echo '; $(GENERATED). DO NOT EDIT.' > $@
\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
231 $(OBJ_DIR)/d_nghttp2.def: Makefile.MSVC
\r
232 @echo 'Generating $@...'
\r
233 @echo '; $(GENERATED). DO NOT EDIT.' > $@
\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
241 rm -f $(OBJ_DIR)/* nghttp2_imp.exp nghttp2_imp.exp \
\r
242 nghttp2.map nghttp2d.map nghttp2.rc includes/nghttp2/nghttp2ver.h
\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
250 # Use gcc to generated the dependencies. No MSVC specific args please!
\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
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
266 -include .depend.MSVC