2 # GNU Makefile for nghttp2 / MSVC.
\r
4 # By G. Vanem <gvanem@yahoo.no> 2013
\r
5 # Updated 3/2015 by Remo Eichenberger @remoe
\r
6 # The MIT License apply.
\r
10 # Choose your weapons:
\r
11 # Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension.
\r
15 _VERSION := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV], //g')
\r
16 _VERSION := $(subst ., ,$(_VERSION))
\r
17 VER_MAJOR = $(word 1,$(_VERSION))
\r
18 VER_MINOR = $(word 2,$(_VERSION))
\r
19 VER_MICRO = $(word 3,$(_VERSION))
\r
20 VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO)
\r
21 VERSION_NUM = ($(VER_MAJOR) << 16) + ($(VER_MINOR) << 8) + $(VER_MICRO)
\r
23 GENERATED = 'Generated by $(realpath Makefile.MSVC)'
\r
26 # Where to copy nghttp2.dll + lib + headers to.
\r
27 # Note: 'make install' is not in default targets. Do it explicitly.
\r
29 VC_ROOT = $(realpath $(VCINSTALLDIR))
\r
30 INSTALL_BIN = $(VC_ROOT)/bin
\r
31 INSTALL_LIB = $(VC_ROOT)/lib
\r
32 INSTALL_HDR = $(VC_ROOT)/include
\r
35 # Build for DEBUG-model and RELEASE at the same time.
\r
37 TARGETS = nghttp2.lib nghttp2.dll nghttp2_imp.lib \
\r
38 nghttp2d.lib nghttp2d.dll nghttp2d_imp.lib
\r
44 NGHTTP2_PDB_R = $(OBJ_DIR)/nghttp2.pdb
\r
45 NGHTTP2_PDB_D = $(OBJ_DIR)/nghttp2d.pdb
\r
48 CFLAGS = -I./includes -Dssize_t=long -D_U_=""
\r
50 CFLAGS_R = -nologo -MD -W3 -Zi -Fd./$(NGHTTP2_PDB_R)
\r
51 CFLAGS_D = -nologo -MDd -W3 -Zi -Fd./$(NGHTTP2_PDB_D) \
\r
52 -Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS
\r
54 LDFLAGS = -nologo -machine:x64 -map -debug -incremental:no # -verbose
\r
56 NGHTTP2_SRC = nghttp2_pq.c \
\r
62 nghttp2_outbound_item.c \
\r
68 nghttp2_hd_huffman.c \
\r
69 nghttp2_hd_huffman_data.c \
\r
71 nghttp2_priority_spec.c \
\r
73 nghttp2_callbacks.c \
\r
77 NGHTTP2_OBJ_R = $(addprefix $(OBJ_DIR)/r_, $(notdir $(NGHTTP2_SRC:.c=.obj)))
\r
78 NGHTTP2_OBJ_D = $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj)))
\r
80 all: intro $(OBJ_DIR) $(TARGETS)
\r
81 @echo 'Welcome to NgHTTP2 (release + debug).'
\r
82 @echo 'Do a "make -f Makefile.MSVC install" at own risk!'
\r
85 @echo 'Building NgHTTP (MSVC) ver. "$(VERSION)".'
\r
88 @echo '$$(VERSION): "$(VERSION)".'
\r
89 @echo '$$(_VERSION): "$(_VERSION)".'
\r
90 @echo '$$(VER_MAJOR): "$(VER_MAJOR)".'
\r
91 @echo '$$(VER_MINOR): "$(VER_MINOR)".'
\r
92 @echo '$$(VER_MICRO): "$(VER_MICRO)".'
\r
97 install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \
\r
98 nghttp2.dll nghttp2.lib nghttp2_imp.lib \
\r
99 nghttp2d.dll nghttp2d.lib nghttp2d_imp.lib \
\r
100 copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON)
\r
103 # This MUST be done before using the 'install_nghttp2_pyd_1' rule.
\r
105 copy_headers_and_libs:
\r
106 - mkdir $(INSTALL_HDR)/nghttp2
\r
107 cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h) $(INSTALL_HDR)/nghttp2
\r
108 cp --update nghttp2.dll nghttp2d.dll $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN)
\r
109 cp --update nghttp2.lib nghttp2d.lib nghttp2_imp.lib nghttp2d_imp.lib $(INSTALL_LIB)
\r
112 nghttp2.lib: $(NGHTTP2_OBJ_R)
\r
113 lib -nologo -out:$@ $^
\r
116 nghttp2d.lib: $(NGHTTP2_OBJ_D)
\r
117 lib -nologo -out:$@ $^
\r
120 nghttp2.dll nghttp2_imp.lib: $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res
\r
121 link $(LDFLAGS) -dll -out:nghttp2.dll -implib:nghttp2_imp.lib \
\r
122 $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS)
\r
125 nghttp2d.dll nghttp2d_imp.lib: $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res
\r
126 link $(LDFLAGS) -dll -out:nghttp2d.dll -implib:nghttp2d_imp.lib \
\r
127 $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS)
\r
130 install_nghttp2_pyd_0: ;
\r
132 install_nghttp2_pyd_1: $(addprefix ../python/, setup.py.in nghttp2.pyx)
\r
134 echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \
\r
135 sed -e 's/@top_srcdir@/../' \
\r
136 -e 's/@top_builddir@/../' \
\r
137 -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ; \
\r
138 cython -v nghttp2.pyx ; \
\r
139 python setup.py install
\r
141 clean_nghttp2_pyd_0: ;
\r
143 clean_nghttp2_pyd_1:
\r
145 rm -f setup.py nghttp2.c ; \
\r
148 $(OBJ_DIR)/r_%.obj: %.c
\r
149 $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $<
\r
152 $(OBJ_DIR)/d_%.obj: %.c
\r
153 $(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $<
\r
156 $(OBJ_DIR)/r_nghttp2.res: nghttp2.rc
\r
157 rc -nologo -D_RELEASE -Fo $@ $<
\r
160 $(OBJ_DIR)/d_nghttp2.res: nghttp2.rc
\r
161 rc -nologo -D_DEBUG -Fo $@ $<
\r
164 includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in
\r
165 sed < includes/nghttp2/nghttp2ver.h.in \
\r
166 -e 's/@PACKAGE_VERSION@/$(VERSION)/g' \
\r
167 -e 's/@PACKAGE_VERSION_NUM@/($(VERSION_NUM))/g' > $@
\r
168 touch --reference=includes/nghttp2/nghttp2ver.h.in $@
\r
172 #include <winver.h>
\r
174 VS_VERSION_INFO VERSIONINFO
\r
175 FILEVERSION $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0
\r
176 PRODUCTVERSION $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0
\r
177 FILEFLAGSMASK 0x3fL
\r
182 #define VER_STR "$(VERSION).0 (MSVC debug)"
\r
186 #define VER_STR "$(VERSION).0 (MSVC release)"
\r
191 BLOCK "StringFileInfo"
\r
195 VALUE "CompanyName", "http://tatsuhiro-t.github.io/nghttp2/"
\r
196 VALUE "FileDescription", "nghttp2; HTTP/2 C library"
\r
197 VALUE "FileVersion", VER_STR
\r
198 VALUE "InternalName", "nghttp2" DBG
\r
199 VALUE "LegalCopyright", "The MIT License"
\r
200 VALUE "LegalTrademarks", ""
\r
201 VALUE "OriginalFilename", "nghttp2" DBG ".dll"
\r
202 VALUE "ProductName", "NGHTTP2."
\r
203 VALUE "ProductVersion", VER_STR
\r
204 VALUE "PrivateBuild", "The privat build of <gvanem@yahoo.no>."
\r
205 VALUE "SpecialBuild", ""
\r
208 BLOCK "VarFileInfo"
\r
210 VALUE "Translation", 0x409, 1200
\r
217 nghttp2.rc: Makefile.MSVC
\r
218 @echo 'Generating $@...'
\r
219 @echo ' /* $(GENERATED). DO NOT EDIT.' > $@
\r
221 @echo "$$RES_FILE" >> $@
\r
224 rm -f $(OBJ_DIR)/* nghttp2_imp.exp nghttp2_imp.exp \
\r
225 nghttp2.map nghttp2d.map nghttp2.rc includes/nghttp2/nghttp2ver.h
\r
228 vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON)
\r
229 rm -f $(TARGETS) nghttp2.pdb nghttp2d.pdb nghttp2_imp.exp nghttp2d_imp.exp .depend.MSVC
\r
233 # Use gcc to generated the dependencies. No MSVC specific args please!
\r
235 REPLACE_R = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/r_\1.obj: /'
\r
236 REPLACE_D = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/d_\1.obj: /'
\r
238 depend: includes/nghttp2/nghttp2ver.h
\r
239 @echo '# $(GENERATED). DO NOT EDIT.' > .depend.MSVC
\r
240 gcc -MM $(CFLAGS) $(NGHTTP2_SRC) >> .depend.tmp
\r
241 @echo '#' >> .depend.MSVC
\r
242 @echo '# Release lib objects:' >> .depend.MSVC
\r
243 sed -e $(REPLACE_R) .depend.tmp >> .depend.MSVC
\r
244 @echo '#' >> .depend.MSVC
\r
245 @echo '# Debug lib objects:' >> .depend.MSVC
\r
246 sed -e $(REPLACE_D) .depend.tmp >> .depend.MSVC
\r
249 -include .depend.MSVC
\r