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