MariaDB driver added to Windows build and installer
[public/netxms.git] / Makefile.inc.w32
CommitLineData
64a055a2 1# Common settings for Win32 builds
bf826019
VK
2# This makefile expects that path to build tools and environment variables
3# LIB and INCLUDE for target architecture set before running make
4# They can be set using build\msvc_setenv_* scripts
64a055a2 5
7cf94f18
VK
6CC = cl
7CXX = cl
8LD = link
9PERL = perl
10LEX = flex
11YACC = bison
12MC = mc
64a055a2
VK
13
14# Source base path
7cf94f18
VK
15# Default location is C:\Source\NetXMS
16# It can be changed by setting NETXMS_BASE environment variable
17!ifndef NETXMS_BASE
18NETXMS_BASE = C:\Source\NetXMS
19!endif
64a055a2
VK
20
21# Architecture
48e08d41 22!ifndef ARCH
7cf94f18 23ARCH = x64
48e08d41
VK
24!endif
25
7cf94f18
VK
26!if "$(ARCH)" == "x64"
27WINDDK_ARCH = amd64
7cf94f18 28OBJDIR = amd64
48e08d41
VK
29!endif
30
7cf94f18 31!if "$(ARCH)" == "x86"
7cf94f18 32OBJDIR = i386
48e08d41 33!endif
64a055a2
VK
34
35# SDK locations
48e08d41 36!ifndef OPENSSL_BASE
7cf94f18
VK
37OPENSSL_BASE = C:\SDK\OpenSSL
38!endif
bf826019
VK
39!ifndef CURL_BASE
40CURL_BASE = C:\SDK\cURL
41!endif
8b27778f
VK
42!ifndef JDK_BASE
43JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
44!endif
7cf94f18
VK
45
46# Binaries directory
d9654419
VK
47NETXMS_LIBDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
48BINDIR = $(NETXMS_LIBDIR)
bf826019 49
d9654419 50# Component specific settings
bf826019
VK
51!if "$(COMPONENT)" == "server"
52CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
53!endif
64a055a2 54
d9654419 55# Target specific settings
7cf94f18
VK
56!if "$(TYPE)" == "dll"
57CPPFLAGS = $(CPPFLAGS) /D_USRDLL
58IMPLIB = $(BINFILE:.dll=.lib)
59LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
60!endif
61!if "$(TYPE)" == "ddr"
62CPPFLAGS = $(CPPFLAGS) /D_USRDLL
63LDFLAGS = $(LDFLAGS) /DLL
48e08d41 64!endif
e3738c4b
VK
65!if "$(TYPE)" == "hdlink"
66CPPFLAGS = $(CPPFLAGS) /D_USRDLL
67LDFLAGS = $(LDFLAGS) /DLL
68!endif
d9654419
VK
69!if "$(TYPE)" == "ndd"
70BINDIR = $(BINDIR)\ndd
71CPPFLAGS = $(CPPFLAGS) /D_USRDLL
72LDFLAGS = $(LDFLAGS) /DLL
73!endif
7cf94f18
VK
74!if "$(TYPE)" == "nsm"
75CPPFLAGS = $(CPPFLAGS) /D_USRDLL
76LDFLAGS = $(LDFLAGS) /DLL
77!endif
d9654419
VK
78
79# Common C/C++ compiler flags
91c1f188 80CPPFLAGS = $(CPPFLAGS) /MD /O2 /Gd /EHs- /GR- \
d9654419
VK
81 /I "$(NETXMS_BASE)\include" \
82 /I "$(NETXMS_BASE)\build" \
83 /I "$(CURL_BASE)\$(ARCH)\include" \
84 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
85 /D_MT /DUNICODE
86
87# Common linker flags
7cf94f18
VK
88MANIFEST = $(TARGET).intermediate.manifest
89LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
d9654419 90 /LIBPATH:"$(NETXMS_LIBDIR)" \
bf826019 91 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
b85caada 92 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib"
96259f10
VK
93
94# Common headers
95HEADERS = $(HEADERS) \
96 $(NETXMS_BASE)\include\build.h \
97 $(NETXMS_BASE)\include\geolocation.h \
98 $(NETXMS_BASE)\include\jansson.h \
99 $(NETXMS_BASE)\include\netxms-regex.h \
100 $(NETXMS_BASE)\include\netxms-version.h \
101 $(NETXMS_BASE)\include\netxms_getopt.h \
102 $(NETXMS_BASE)\include\nms_common.h \
103 $(NETXMS_BASE)\include\nms_cscp.h \
104 $(NETXMS_BASE)\include\nms_threads.h \
105 $(NETXMS_BASE)\include\nms_util.h \
106 $(NETXMS_BASE)\include\nxconfig.h \
107 $(NETXMS_BASE)\include\nxcpapi.h \
108 $(NETXMS_BASE)\include\nxcrypto.h \
109 $(NETXMS_BASE)\include\nxqueue.h \
110 $(NETXMS_BASE)\include\nxstat.h \
111 $(NETXMS_BASE)\include\rwlock.h \
112 $(NETXMS_BASE)\include\unicode.h \
113 $(NETXMS_BASE)\include\uthash.h \
114 $(NETXMS_BASE)\include\uuid.h
64a055a2
VK
115
116# Common libraries
7cf94f18 117LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
118
119# Prepare list of object files
7cf94f18
VK
120__sources = $(SOURCES:.cpp=.obj)
121OBJ = $(__sources:.c=.obj)
48e08d41 122
91c1f188
VK
123# Compiled resources
124RESOBJ = $(RESOURCES:.rc=.res)
125
48e08d41 126# Source directory
7cf94f18 127SRCDIR = $(MAKEDIR)
48e08d41 128
d9654419
VK
129# Output files
130!ifdef TARGET
131BINFILE = $(BINDIR)\$(TARGET)
132!endif
133
7cf94f18 134all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
135
136# Build target
137!ifdef TARGET
64a055a2 138
8b27778f
VK
139!if "$(TYPE)" == "jar"
140
141$(BINFILE): pom.xml
142 mvn clean
143 mvn install
144 mv target/$(TARGET) $(BINFILE)
145
146!else
147
91c1f188 148$(BINFILE): objdir $(OBJ) $(RESOBJ)
7cf94f18
VK
149 @if not exist $(BINDIR) mkdir $(BINDIR)
150 @echo " LD " $(TARGET)
e3738c4b 151 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
7cf94f18 152 @rm -f $(MANIFEST)
64a055a2 153
96259f10 154$(OBJ): $(NETXMS_BASE)\build\netxms-build-tag.h $(HEADERS)
55108637 155
48e08d41 156.PHONY: objdir
64a055a2 157
48e08d41
VK
158objdir:
159 @if not exist $(OBJDIR) mkdir $(OBJDIR)
160 @cd $(OBJDIR)
64a055a2 161
48e08d41 162{$(SRCDIR)}.c.obj:
7cf94f18
VK
163 @echo " CC " $(<F)
164 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
165
166{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
167 @echo " CXX" $(<F)
168 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
169
91c1f188 170{$(SRCDIR)}.rc.res:
7cf94f18 171 @echo " RC " $(<F)
bf826019 172 @$(RC) /nologo /r $<
91c1f188 173 @mv $(SRCDIR)\$@ .
7cf94f18
VK
174
175MSG00001.bin: messages.mc
176 @echo " MC messages.mc"
177 @$(MC) messages.mc
9dd277ba 178 @rm -f messages.rc
64a055a2 179
7cf94f18
VK
180messages.h: messages.mc
181 @echo " MC messages.mc"
182 @$(MC) messages.mc
9dd277ba 183 @rm -f messages.rc
48e08d41
VK
184
185!endif
8b27778f 186!endif
64a055a2 187
48e08d41 188# Clean
7cf94f18
VK
189.PHONY: clean
190
64a055a2 191clean:
7cf94f18
VK
192 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
193 @for %%s in ($(SUBDIRS)) do @( \
194 echo === Entering %%s === && \
195 cd %%s && \
196 @( \
197 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
198 exit 1 \
199 ) && \
200 echo === Leaving %%s === && \
201 cd .. \
202 )
64a055a2
VK
203
204# Sub-directories building rules
48e08d41
VK
205.PHONY: subdirs
206
207subdirs:
7cf94f18
VK
208 @for %%s in ($(SUBDIRS)) do @( \
209 echo === Entering %%s === && \
210 cd %%s && \
211 @( \
212 $(MAKE) /NOLOGO /F Makefile.w32 || \
213 exit 1 \
214 ) && \
215 echo === Leaving %%s === && \
216 cd .. \
48e08d41 217 )