preparation for clang build support on Windows
[public/netxms.git] / Makefile.inc.w32
1 # Common settings for Win32 builds
2
3 CC=clang
4 CXX=clang++
5 LD=lld-link
6 MAKE=make
7
8 # Source base path
9 BASE_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
10
11 # Architecture
12 ifndef ARCH
13 ARCH = x64
14 endif
15 ifeq (${ARCH},x64)
16 WINDDK_ARCH = amd64
17 WINSDK_LIB = Lib\x64
18 WINSDK_BIN = Bin\x64
19 endif
20 ifeq ({$ARCH},x86)
21 WINDDK_ARCH = i386
22 WINSDK_LIB = Lib
23 WINSDK_BIN = Bin
24 endif
25
26 # SDK locations
27 -include ${BASE_PATH}winsdk.inc
28
29 ifndef WINSDK_BASE
30 WINSDK_BASE := C:\SDK\Windows 7 SDK
31 endif
32 ifndef WINDDK_BASE
33 WINDDK_BASE := C:\SDK\WinDDK
34 endif
35 ifndef OPENSSL_BASE
36 OPENSSL_BASE := C:\SDK\OpenSSL
37 endif
38
39 export Path := ${WINSDK_BASE}\${WINSDK_BIN};$(Path)
40
41 # Common C/C++ compiler flags
42 CPPFLAGS += -fms-compatibility -Wno-microsoft-enum-value -Wno-comment -Wno-microsoft-anon-tag -Wno-nonportable-include-path \
43 -Wno-ignored-attributes -Wno-int-to-void-pointer-cast -Wno-unused-value -Wno-inconsistent-dllimport -Wno-invalid-token-paste \
44 -Wno-reserved-user-defined-literal -Wno-expansion-to-defined \
45 -I${BASE_PATH}include -I "${WINSDK_BASE}\include" -I "${WINDDK_BASE}\inc\crt" \
46 -I "${OPENSSL_BASE}\${ARCH}\include" \
47 -D_MT -DUNICODE
48 CXXFLAGS += -fno-cxx-exceptions
49
50 # Common linker flags
51 ifeq (${TYPE},dll)
52 IMPLIB := $(TARGET:.dll=.lib)
53 LDFLAGS += -dll -implib:${IMPLIB}
54 endif
55 MANIFEST := $(TARGET).intermediate.manifest
56 LDFLAGS += -subsystem:windows -machine:${ARCH} -manifestfile:${MANIFEST} -libpath:"${OPENSSL_BASE}\${ARCH}\lib" -libpath:"${WINDDK_BASE}\lib\wnet\${WINDDK_ARCH}" -libpath:"${WINSDK_BASE}\${WINSDK_LIB}"
57
58 # Common libraries
59 LIBS += ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib msvcrt.lib
60
61 # Prepare list of object files
62 __sources = $(SOURCES:.c=.obj)
63 OBJ = $(__sources:.cpp=.obj)
64
65 all: subdirs ${GENERATED} ${TARGET}
66
67 ${TARGET}: ${OBJ}
68 ${LD} ${LDFLAGS} /out:${TARGET} ${OBJ} ${LIBS}
69 rm -f ${MANIFEST}
70
71 %.obj: %.c
72 ${CC} ${CPPFLAGS} ${CFLAGS} -c $< -o $@
73
74 %.obj: %.cpp
75 ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c $< -o $@
76
77 messages.cpp: messages.mc
78 ${MC} $< -cpp
79
80 clean:
81 rm -f ${OBJ} ${TARGET} ${GENERATED} ${EXTRA_CLEAN}
82
83 # Sub-directories building rules
84 .PHONY: subdirs $(SUBDIRS)
85
86 subdirs: $(SUBDIRS)
87
88 $(SUBDIRS):
89 $(MAKE) -C $@ -f Makefile.w32