preparation for clang build support on Windows
[public/netxms.git] / Makefile.inc.w32
CommitLineData
64a055a2
VK
1# Common settings for Win32 builds
2
3CC=clang
4CXX=clang++
5LD=lld-link
6MAKE=make
7
8# Source base path
9BASE_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
10
11# Architecture
12ifndef ARCH
13 ARCH = x64
14endif
15ifeq (${ARCH},x64)
16 WINDDK_ARCH = amd64
17 WINSDK_LIB = Lib\x64
18 WINSDK_BIN = Bin\x64
19endif
20ifeq ({$ARCH},x86)
21 WINDDK_ARCH = i386
22 WINSDK_LIB = Lib
23 WINSDK_BIN = Bin
24endif
25
26# SDK locations
27-include ${BASE_PATH}winsdk.inc
28
29ifndef WINSDK_BASE
30 WINSDK_BASE := C:\SDK\Windows 7 SDK
31endif
32ifndef WINDDK_BASE
33 WINDDK_BASE := C:\SDK\WinDDK
34endif
35ifndef OPENSSL_BASE
36 OPENSSL_BASE := C:\SDK\OpenSSL
37endif
38
39export Path := ${WINSDK_BASE}\${WINSDK_BIN};$(Path)
40
41# Common C/C++ compiler flags
42CPPFLAGS += -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
48CXXFLAGS += -fno-cxx-exceptions
49
50# Common linker flags
51ifeq (${TYPE},dll)
52 IMPLIB := $(TARGET:.dll=.lib)
53 LDFLAGS += -dll -implib:${IMPLIB}
54endif
55MANIFEST := $(TARGET).intermediate.manifest
56LDFLAGS += -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
59LIBS += 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)
63OBJ = $(__sources:.cpp=.obj)
64
65all: 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
77messages.cpp: messages.mc
78 ${MC} $< -cpp
79
80clean:
81 rm -f ${OBJ} ${TARGET} ${GENERATED} ${EXTRA_CLEAN}
82
83# Sub-directories building rules
84.PHONY: subdirs $(SUBDIRS)
85
86subdirs: $(SUBDIRS)
87
88$(SUBDIRS):
89 $(MAKE) -C $@ -f Makefile.w32