summaryrefslogtreecommitdiffstats
path: root/make/msvc.mk
blob: c5961c037e3e8a76c72b21b793a732f22687a421 (plain) (blame)
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
# --- Required interface definitions ---

OBJ=obj
LOBJ=obj

# Usage: $(call libname,base)
define libname
$(1).lib
endef

# Usage: $(call binname,base)
define binname
$(1).exe
endef

# --- Required rule definitions ---

#                       1   2
# Usage: $(call compile,src,includes)
define compile
	cl /nologo /Zi /Gy /EHsc /MD /TP /GR $(CPPFLAGS) $(CXXFLAGS) \
		$(foreach I,$(2),-I$(I)) \
		/c $(1) /Fo$(call src_to_obj,$(1))
endef

#                       1   2
# Usage: $(call c_compile,src,includes)
define c_compile
	cl /nologo /Zi /Gy /EHsc /MD $(CPPFLAGS) $(CXXFLAGS) \
		$(foreach I,$(2),-I$(I)) \
		/c $(1) /Fo$(call c_src_to_obj,$(1))
endef

libcompile = $(compile)
c_libcompile = $(c_compile)

#                        1    2
# Usage: $(call makeslib,objs,library)
define makeslib
	lib /nologo /OUT:$(2) $(1)
endef

#                       1    2       3       4    5       6        7
# Usage: $(call makelib,objs,library,ldflags,libs,current,revision,age)
define makelib
	cl /nologo /Zi /Gy /EHsc /MD /LD /Fe$(basename $(2))$(5).dll $(1) \
		/link /incremental:no \
		$(foreach L,$(subst -L,,$(3)),/LIBPATH:$(L)) \
		$(foreach L,$(subst -l,,$(4)),$(L).lib)
	if [ -f $(basename $(2))$(5).dll.manifest ]; then \
		mt.exe -nologo -manifest $(basename $(2))$(5).dll.manifest \
			-outputresource:$(basename $(2))$(5).dll\;2; \
	fi
	mv $(2)$(5).lib $(2).lib
endef

#                       1    2      3       4
# Usage: $(call makebin,objs,binary,ldflags,libs)
define makebin
	cl /nologo /Zi /Gy /EHsc /MD $(1) \
		/link /incremental:no /OUT:$(2) \
		$(foreach L,$(subst -L,,$(3)),/LIBPATH:$(L)) \
		$(foreach L,$(subst -l,,$(4)),$(L).lib)
	if [ -f $(2).manifest ]; then \
		mt.exe -nologo -manifest $(2).manifest \
			-outputresource:$(2)\;2; \
	fi
endef