Implemented Debug Tag functionality
[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
0e8667f4
VK
45!ifndef LIBMOSQUITTO_BASE
46LIBMOSQUITTO_BASE = C:\SDK\libmosquitto
47!endif
7cf94f18
VK
48
49# Binaries directory
d9654419
VK
50NETXMS_LIBDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
51BINDIR = $(NETXMS_LIBDIR)
bf826019 52
d9654419 53# Component specific settings
bf826019
VK
54!if "$(COMPONENT)" == "server"
55CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
56!endif
64a055a2 57
d9654419 58# Target specific settings
7cf94f18
VK
59!if "$(TYPE)" == "dll"
60CPPFLAGS = $(CPPFLAGS) /D_USRDLL
61IMPLIB = $(BINFILE:.dll=.lib)
62LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
63!endif
64!if "$(TYPE)" == "ddr"
65CPPFLAGS = $(CPPFLAGS) /D_USRDLL
66LDFLAGS = $(LDFLAGS) /DLL
48e08d41 67!endif
e3738c4b
VK
68!if "$(TYPE)" == "hdlink"
69CPPFLAGS = $(CPPFLAGS) /D_USRDLL
70LDFLAGS = $(LDFLAGS) /DLL
71!endif
d9654419
VK
72!if "$(TYPE)" == "ndd"
73BINDIR = $(BINDIR)\ndd
74CPPFLAGS = $(CPPFLAGS) /D_USRDLL
75LDFLAGS = $(LDFLAGS) /DLL
76!endif
7cf94f18
VK
77!if "$(TYPE)" == "nsm"
78CPPFLAGS = $(CPPFLAGS) /D_USRDLL
79LDFLAGS = $(LDFLAGS) /DLL
80!endif
d9654419
VK
81
82# Common C/C++ compiler flags
91c1f188 83CPPFLAGS = $(CPPFLAGS) /MD /O2 /Gd /EHs- /GR- \
d9654419 84 /I "$(NETXMS_BASE)\include" \
8e9db1a9 85 /I "$(NETXMS_BASE)\include\msvc" \
d9654419
VK
86 /I "$(NETXMS_BASE)\build" \
87 /I "$(CURL_BASE)\$(ARCH)\include" \
88 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
0e8667f4 89 /I "$(LIBMOSQUITTO_BASE)\include" \
d9654419
VK
90 /D_MT /DUNICODE
91
92# Common linker flags
7cf94f18
VK
93MANIFEST = $(TARGET).intermediate.manifest
94LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
d9654419 95 /LIBPATH:"$(NETXMS_LIBDIR)" \
bf826019 96 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
0e8667f4
VK
97 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
98 /LIBPATH:"$(LIBMOSQUITTO_BASE)\$(ARCH)\lib"
96259f10
VK
99
100# Common headers
101HEADERS = $(HEADERS) \
102 $(NETXMS_BASE)\include\build.h \
103 $(NETXMS_BASE)\include\geolocation.h \
104 $(NETXMS_BASE)\include\jansson.h \
105 $(NETXMS_BASE)\include\netxms-regex.h \
106 $(NETXMS_BASE)\include\netxms-version.h \
107 $(NETXMS_BASE)\include\netxms_getopt.h \
108 $(NETXMS_BASE)\include\nms_common.h \
109 $(NETXMS_BASE)\include\nms_cscp.h \
110 $(NETXMS_BASE)\include\nms_threads.h \
111 $(NETXMS_BASE)\include\nms_util.h \
112 $(NETXMS_BASE)\include\nxconfig.h \
113 $(NETXMS_BASE)\include\nxcpapi.h \
114 $(NETXMS_BASE)\include\nxcrypto.h \
115 $(NETXMS_BASE)\include\nxqueue.h \
116 $(NETXMS_BASE)\include\nxstat.h \
117 $(NETXMS_BASE)\include\rwlock.h \
118 $(NETXMS_BASE)\include\unicode.h \
119 $(NETXMS_BASE)\include\uthash.h \
120 $(NETXMS_BASE)\include\uuid.h
64a055a2
VK
121
122# Common libraries
0e8667f4 123LIBS = $(LIBS) libssl.lib libcrypto.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
124
125# Prepare list of object files
7cf94f18
VK
126__sources = $(SOURCES:.cpp=.obj)
127OBJ = $(__sources:.c=.obj)
48e08d41 128
91c1f188
VK
129# Compiled resources
130RESOBJ = $(RESOURCES:.rc=.res)
131
48e08d41 132# Source directory
7cf94f18 133SRCDIR = $(MAKEDIR)
48e08d41 134
d9654419
VK
135# Output files
136!ifdef TARGET
137BINFILE = $(BINDIR)\$(TARGET)
138!endif
139
7cf94f18 140all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
141
142# Build target
143!ifdef TARGET
64a055a2 144
8b27778f
VK
145!if "$(TYPE)" == "jar"
146
7c2fbeea
VK
147!if "$(JAR_BUILD_MODE)" == "install"
148MVNCMD=install
149!else
150MVNCMD=package
151!endif
152
8b27778f
VK
153$(BINFILE): pom.xml
154 mvn clean
7c2fbeea 155 mvn $(MVNCMD) $(MVNFLAGS)
8b27778f
VK
156 mv target/$(TARGET) $(BINFILE)
157
158!else
159
91c1f188 160$(BINFILE): objdir $(OBJ) $(RESOBJ)
7cf94f18
VK
161 @if not exist $(BINDIR) mkdir $(BINDIR)
162 @echo " LD " $(TARGET)
e3738c4b 163 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
7cf94f18 164 @rm -f $(MANIFEST)
64a055a2 165
96259f10 166$(OBJ): $(NETXMS_BASE)\build\netxms-build-tag.h $(HEADERS)
55108637 167
48e08d41 168.PHONY: objdir
64a055a2 169
48e08d41
VK
170objdir:
171 @if not exist $(OBJDIR) mkdir $(OBJDIR)
172 @cd $(OBJDIR)
64a055a2 173
48e08d41 174{$(SRCDIR)}.c.obj:
7cf94f18
VK
175 @echo " CC " $(<F)
176 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
177
178{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
179 @echo " CXX" $(<F)
180 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
181
91c1f188 182{$(SRCDIR)}.rc.res:
7cf94f18 183 @echo " RC " $(<F)
bf826019 184 @$(RC) /nologo /r $<
91c1f188 185 @mv $(SRCDIR)\$@ .
7cf94f18
VK
186
187MSG00001.bin: messages.mc
188 @echo " MC messages.mc"
189 @$(MC) messages.mc
9dd277ba 190 @rm -f messages.rc
64a055a2 191
7cf94f18
VK
192messages.h: messages.mc
193 @echo " MC messages.mc"
194 @$(MC) messages.mc
9dd277ba 195 @rm -f messages.rc
48e08d41
VK
196
197!endif
8b27778f 198!endif
64a055a2 199
48e08d41 200# Clean
7cf94f18
VK
201.PHONY: clean
202
64a055a2 203clean:
7cf94f18
VK
204 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
205 @for %%s in ($(SUBDIRS)) do @( \
206 echo === Entering %%s === && \
207 cd %%s && \
208 @( \
209 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
210 exit 1 \
211 ) && \
212 echo === Leaving %%s === && \
213 cd .. \
214 )
64a055a2
VK
215
216# Sub-directories building rules
48e08d41
VK
217.PHONY: subdirs
218
219subdirs:
7cf94f18
VK
220 @for %%s in ($(SUBDIRS)) do @( \
221 echo === Entering %%s === && \
222 cd %%s && \
223 @( \
224 $(MAKE) /NOLOGO /F Makefile.w32 || \
225 exit 1 \
226 ) && \
227 echo === Leaving %%s === && \
228 cd .. \
48e08d41 229 )