summaryrefslogtreecommitdiff
path: root/deps/nghttp2/lib/Makefile.msvc
blob: f649c0bda4bcd7ba7971221c0b8b8128a8a96b78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
#
# GNU Makefile for nghttp2 / MSVC.
#
# By G. Vanem <gvanem@yahoo.no> 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.
#
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))

USE_CYTHON := 0
#USE_CYTHON := 1

_VERSION	:= $(shell grep AC_INIT ../configure.ac | cut -d'[' -f3 | sed -e 's/-DEV//g' -e 's/], //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)'

OBJ_DIR := MSVC_obj
#SUFFIX :=-vc90-mt-x86

#
# Where to copy nghttp2.dll + lib + headers to.
# Note: 'make install' is not in default targets. Do it explicitly.
#
TARGET_DIR  ?= ../_VC_ROOT
VC_ROOT     := $(abspath $(TARGET_DIR))
INSTALL_BIN := $(VC_ROOT)/bin
INSTALL_LIB := $(VC_ROOT)/lib
INSTALL_HDR := $(VC_ROOT)/include
DLL_R	:= $(OBJ_DIR)/nghttp2$(SUFFIX).dll
DLL_D	:= $(OBJ_DIR)/nghttp2d$(SUFFIX).dll
LIB_R	:= $(OBJ_DIR)/nghttp2-static.lib
LIB_D	:= $(OBJ_DIR)/nghttp2d-static.lib
IMP_R	:= $(OBJ_DIR)/nghttp2.lib
IMP_D	:= $(OBJ_DIR)/nghttp2d.lib

#
# Build for DEBUG-model and RELEASE at the same time.
#
TARGETS := $(LIB_R) $(DLL_R) $(IMP_R) \
          $(LIB_D) $(DLL_D) $(IMP_D)

EXT_LIBS = 

NGHTTP2_PDB_R := $(OBJ_DIR)/nghttp2.pdb
NGHTTP2_PDB_D := $(OBJ_DIR)/nghttp2d.pdb

CC       = cl
LD		 := link
AR		 := lib
#CC       := icl
#LD		 := xilink
#AR		 := xilib
RC		 := rc
CFLAGS   := -I./includes -Dssize_t=long

CFLAGS_R := -nologo -MD  -W3 -Z7 -DBUILDING_NGHTTP2
CFLAGS_D := -nologo -MDd -W3 -Z7 -DBUILDING_NGHTTP2 \
           -Ot -D_DEBUG -GF -RTCs -RTCu # -RTCc -GS

LDFLAGS := -nologo -MAP -debug -incremental:no -opt:ref,icf -MANIFEST # -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_rcbuf.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)))

.PHONY: all intro test_ver install copy_headers_and_libs \
	install_nghttp2_pyd_0 install_nghttp2_pyd_1 \
	build_nghttp2_pyd_0 build_nghttp2_pyd_1 \
	clean_nghttp2_pyd_0 clean_nghttp2_pyd_1


all: intro includes/nghttp2/nghttp2ver.h $(OBJ_DIR) $(TARGETS) build_nghttp2_pyd_$(USE_CYTHON)
	@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 \
         $(TARGETS) \
         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 -p $(INSTALL_HDR)/nghttp2 $(INSTALL_BIN) $(INSTALL_LIB)
	cp --update $(addprefix includes/nghttp2/, nghttp2.h nghttp2ver.h)     $(INSTALL_HDR)/nghttp2
	cp --update $(DLL_R) $(DLL_D) $(NGHTTP2_PDB_R) $(NGHTTP2_PDB_D) $(INSTALL_BIN)
	cp --update $(IMP_R) $(IMP_D) $(LIB_R) $(LIB_D) $(INSTALL_LIB)
	@echo

$(LIB_R): $(NGHTTP2_OBJ_R)
	$(AR) -nologo -out:$@ $^
	@echo

$(LIB_D): $(NGHTTP2_OBJ_D)
	$(AR) -nologo -out:$@ $^
	@echo


$(IMP_R): $(DLL_R)

$(DLL_R): $(NGHTTP2_OBJ_R) $(OBJ_DIR)/r_nghttp2.res 
	$(LD) $(LDFLAGS) -dll -out:$@ -implib:$(IMP_R) $(NGHTTP2_OBJ_R) -PDB:$(NGHTTP2_PDB_R) $(OBJ_DIR)/r_nghttp2.res $(EXT_LIBS)
	mt -nologo -manifest $@.manifest -outputresource:$@\;2
	@echo

$(IMP_D): $(DLL_D)
	
$(DLL_D): $(NGHTTP2_OBJ_D) $(OBJ_DIR)/d_nghttp2.res 
	$(LD) $(LDFLAGS) -dll -out:$@ -implib:$(IMP_D) $(NGHTTP2_OBJ_D) -PDB:$(NGHTTP2_PDB_D) $(OBJ_DIR)/d_nghttp2.res $(EXT_LIBS)
	mt -nologo -manifest $@.manifest -outputresource:$@\;2
	@echo


WIN_OBJDIR:=$(shell cygpath -w $(abspath $(OBJ_DIR)))
WIN_OBJDIR:=$(subst \,/,$(WIN_OBJDIR))

../python/setup.py: ../python/setup.py.in $(THIS_MAKEFILE)
	cd ../python ; \
	echo '# $(GENERATED). DO NOT EDIT.' > setup.py ; \
	sed -e 's/@top_srcdir@/../'   \
	    -e 's%@top_builddir@%$(WIN_OBJDIR)%' \
	    -e 's/@PACKAGE_VERSION@/$(VERSION)/' setup.py.in >> setup.py ;

build_nghttp2_pyd_0: ;

build_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx)
	cd ../python ; \
	python setup.py build_ext -i -f bdist_wininst

install_nghttp2_pyd_0: ;
		
install_nghttp2_pyd_1: $(addprefix ../python/, setup.py nghttp2.pyx)
	cd ../python ; \
	pip install .

clean_nghttp2_pyd_0: ;

clean_nghttp2_pyd_1:
	cd ../python ; \
	rm -fR build dist

$(OBJ_DIR)/r_%.obj: %.c $(THIS_MAKEFILE)
	$(CC) $(CFLAGS_R) $(CFLAGS) -Fo$@ -c $<
	@echo

$(OBJ_DIR)/d_%.obj: %.c $(THIS_MAKEFILE)
	$(CC) $(CFLAGS_D) $(CFLAGS) -Fo$@ -c $<
	@echo

$(OBJ_DIR)/r_nghttp2.res: $(OBJ_DIR)/nghttp2.rc $(THIS_MAKEFILE)
	$(RC) -D_RELEASE -Fo $@ $<
	@echo

$(OBJ_DIR)/d_nghttp2.res: $(OBJ_DIR)/nghttp2.rc $(THIS_MAKEFILE)
	$(RC) -D_DEBUG -Fo $@ $<
	@echo

includes/nghttp2/nghttp2ver.h: includes/nghttp2/nghttp2ver.h.in $(THIS_MAKEFILE)
	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 <winver.h>

  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
      END
    END
  BLOCK "VarFileInfo"
  BEGIN
    VALUE "Translation", 0x409, 1200
  END
  END
endef

export RES_FILE

$(OBJ_DIR)/nghttp2.rc: Makefile.MSVC
	@echo 'Generating $@...'
	@echo ' /* $(GENERATED). DO NOT EDIT.' > $@
	@echo '  */'                          >> $@
	@echo "$$RES_FILE"                    >> $@

clean:
	rm -f $(OBJ_DIR)/* includes/nghttp2/nghttp2ver.h
	@echo

vclean realclean: clean clean_nghttp2_pyd_$(USE_CYTHON)
	- rm -rf $(OBJ_DIR)
	- rm -f .depend.MSVC

#
# 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