# # GNU Makefile for nghttp2 / MSVC. # # By G. Vanem 2013 # Updated 3/2015 by Remo Eichenberger @remoe # The MIT License apply. # # # Choose your weapons: # Set 'USE_CYTHON=1' to build and install the 'nghttp2.pyd' Python extension. # USE_CYTHON = 1 _VERSION := $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV], //g') _VERSION := $(subst ., ,$(_VERSION)) VER_MAJOR = $(word 1,$(_VERSION)) VER_MINOR = $(word 2,$(_VERSION)) VER_MICRO = $(word 3,$(_VERSION)) VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_MICRO) VERSION_NUM = ($(VER_MAJOR) << 16) + ($(VER_MINOR) << 8) + $(VER_MICRO) GENERATED = 'Generated by $(realpath Makefile.MSVC)' # # Where to copy nghttp2.dll + lib + headers to. # Note: 'make install' is not in default targets. Do it explicitly. # VC_ROOT = $(realpath $(VCINSTALLDIR)) INSTALL_BIN = $(VC_ROOT)/bin INSTALL_LIB = $(VC_ROOT)/lib INSTALL_HDR = $(VC_ROOT)/include # # Build for DEBUG-model and RELEASE at the same time. # TARGETS = nghttp2.lib nghttp2.dll nghttp2_imp.lib \ nghttp2d.lib nghttp2d.dll nghttp2d_imp.lib EXT_LIBS = ws2_32.lib OBJ_DIR = MSVC_obj NGHTTP2_PDB_R = $(OBJ_DIR)/nghttp2.pdb NGHTTP2_PDB_D = $(OBJ_DIR)/nghttp2d.pdb CC = cl CFLAGS = -I./includes -DHAVE_WINSOCK2_H -Dssize_t=long -D_U_="" CFLAGS_R = -nologo -MD -W3 -Zi -Fd./$(NGHTTP2_PDB_R) CFLAGS_D = -nologo -MDd -W3 -Zi -Fd./$(NGHTTP2_PDB_D) \ -Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS LDFLAGS = -nologo -machine:x64 -map -debug -incremental:no # -verbose NGHTTP2_SRC = nghttp2_pq.c \ nghttp2_map.c \ nghttp2_queue.c \ nghttp2_frame.c \ nghttp2_buf.c \ nghttp2_stream.c \ nghttp2_outbound_item.c \ nghttp2_session.c \ nghttp2_submit.c \ nghttp2_helper.c \ nghttp2_npn.c \ nghttp2_hd.c \ nghttp2_hd_huffman.c \ nghttp2_hd_huffman_data.c \ nghttp2_version.c \ nghttp2_priority_spec.c \ nghttp2_option.c \ nghttp2_callbacks.c \ nghttp2_mem.c \ nghttp2_http.c NGHTTP2_OBJ_R = $(addprefix $(OBJ_DIR)/r_, $(notdir $(NGHTTP2_SRC:.c=.obj))) NGHTTP2_OBJ_D = $(addprefix $(OBJ_DIR)/d_, $(notdir $(NGHTTP2_SRC:.c=.obj))) all: intro $(OBJ_DIR) $(TARGETS) @echo 'Welcome to NgHTTP2 (release + debug).' @echo 'Do a "make -f Makefile.MSVC install" at own risk!' intro: @echo 'Building NgHTTP (MSVC) ver. "$(VERSION)".' test_ver: @echo '$$(VERSION): "$(VERSION)".' @echo '$$(_VERSION): "$(_VERSION)".' @echo '$$(VER_MAJOR): "$(VER_MAJOR)".' @echo '$$(VER_MINOR): "$(VER_MINOR)".' @echo '$$(VER_MICRO): "$(VER_MICRO)".' $(OBJ_DIR): - mkdir $(OBJ_DIR) install: includes/nghttp2/nghttp2.h includes/nghttp2/nghttp2ver.h \ nghttp2.dll nghttp2.lib nghttp2_imp.lib \ nghttp2d.dll nghttp2d.lib nghttp2d_imp.lib \ copy_headers_and_libs install_nghttp2_pyd_$(USE_CYTHON) # # This MUST be done before using the 'install_nghttp2_pyd_1' rule. # copy_headers_and_libs: - mkdir $(INSTALL_HDR)/nghttp2 cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h) $(INSTALL_HDR)/nghttp2 cp --update nghttp2.dll nghttp2d.dll $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN) cp --update nghttp2.lib nghttp2d.lib nghttp2_imp.lib nghttp2d_imp.lib $(INSTALL_LIB) @echo nghttp2.lib: $(NGHTTP2_OBJ_R) lib -nologo -out:$@ $^ @echo nghttp2d.lib: $(NGHTTP2_OBJ_D) lib -nologo -out:$@ $^ @echo nghttp2.dll nghttp2_imp.lib: $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res link $(LDFLAGS) -dll -out:nghttp2.dll -implib:nghttp2_imp.lib \ $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS) @echo nghttp2d.dll nghttp2d_imp.lib: $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res link $(LDFLAGS) -dll -out:nghttp2d.dll -implib:nghttp2d_imp.lib \ $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS) @echo install_nghttp2_pyd_0: ; install_nghttp2_pyd_1: $(addprefix ../python/, setup.py.in nghttp2.pyx) cd ../python ; \ echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \ sed -e 's/@top_srcdir@/../' \ -e 's/@top_builddir@/../' \ -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ; \ cython -v nghttp2.pyx ; \ python setup.py install clean_nghttp2_pyd_0: ; clean_nghttp2_pyd_1: cd ../python ; \ rm -f setup.py nghttp2.c ; \ rm -fR build/* $(OBJ_DIR)/r_%.obj: %.c $(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $< @echo $(OBJ_DIR)/d_%.obj: %.c $(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $< @echo $(OBJ_DIR)/r_nghttp2.res: nghttp2.rc rc -nologo -D_RELEASE -Fo $@ $< @echo $(OBJ_DIR)/d_nghttp2.res: nghttp2.rc rc -nologo -D_DEBUG -Fo $@ $< @echo includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in sed < includes/nghttp2/nghttp2ver.h.in \ -e 's/@PACKAGE_VERSION@/$(VERSION)/g' \ -e 's/@PACKAGE_VERSION_NUM@/($(VERSION_NUM))/g' > $@ touch --reference=includes/nghttp2/nghttp2ver.h.in $@ define RES_FILE #include VS_VERSION_INFO VERSIONINFO FILEVERSION $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0 PRODUCTVERSION $(VER_MAJOR), $(VER_MINOR), $(VER_MICRO), 0 FILEFLAGSMASK 0x3fL FILEOS 0x40004L FILETYPE 0x2L FILESUBTYPE 0x0L #ifdef _DEBUG #define VER_STR "$(VERSION).0 (MSVC debug)" #define DBG "d" FILEFLAGS 0x1L #else #define VER_STR "$(VERSION).0 (MSVC release)" #define DBG "" FILEFLAGS 0x0L #endif BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "http://tatsuhiro-t.github.io/nghttp2/" VALUE "FileDescription", "nghttp2; HTTP/2 C library" VALUE "FileVersion", VER_STR VALUE "InternalName", "nghttp2" DBG VALUE "LegalCopyright", "The MIT License" VALUE "LegalTrademarks", "" VALUE "OriginalFilename", "nghttp2" DBG ".dll" VALUE "ProductName", "NGHTTP2." VALUE "ProductVersion", VER_STR VALUE "PrivateBuild", "The privat build of ." VALUE "SpecialBuild", "" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END endef export RES_FILE nghttp2.rc: Makefile.MSVC @echo 'Generating $@...' @echo ' /* $(GENERATED). DO NOT EDIT.' > $@ @echo ' */' >> $@ @echo "$$RES_FILE" >> $@ clean: rm -f $(OBJ_DIR)/* nghttp2_imp.exp nghttp2_imp.exp \ nghttp2.map nghttp2d.map nghttp2.rc includes/nghttp2/nghttp2ver.h @echo vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON) rm -f $(TARGETS) nghttp2.pdb nghttp2d.pdb nghttp2_imp.exp nghttp2d_imp.exp .depend.MSVC - rmdir $(OBJ_DIR) # # Use gcc to generated the dependencies. No MSVC specific args please! # REPLACE_R = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/r_\1.obj: /' REPLACE_D = 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/d_\1.obj: /' depend: includes/nghttp2/nghttp2ver.h @echo '# $(GENERATED). DO NOT EDIT.' > .depend.MSVC gcc -MM $(CFLAGS) $(NGHTTP2_SRC) >> .depend.tmp @echo '#' >> .depend.MSVC @echo '# Release lib objects:' >> .depend.MSVC sed -e $(REPLACE_R) .depend.tmp >> .depend.MSVC @echo '#' >> .depend.MSVC @echo '# Debug lib objects:' >> .depend.MSVC sed -e $(REPLACE_D) .depend.tmp >> .depend.MSVC rm -f .depend.tmp -include .depend.MSVC