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