Implemented Debug Tag functionality
[public/netxms.git] / Makefile.inc.w32
... / ...
CommitLineData
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
6CC = cl
7CXX = cl
8LD = link
9PERL = perl
10LEX = flex
11YACC = bison
12MC = mc
13
14# Source base path
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
20
21# Architecture
22!ifndef ARCH
23ARCH = x64
24!endif
25
26!if "$(ARCH)" == "x64"
27WINDDK_ARCH = amd64
28OBJDIR = amd64
29!endif
30
31!if "$(ARCH)" == "x86"
32OBJDIR = i386
33!endif
34
35# SDK locations
36!ifndef OPENSSL_BASE
37OPENSSL_BASE = C:\SDK\OpenSSL
38!endif
39!ifndef CURL_BASE
40CURL_BASE = C:\SDK\cURL
41!endif
42!ifndef JDK_BASE
43JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
44!endif
45!ifndef LIBMOSQUITTO_BASE
46LIBMOSQUITTO_BASE = C:\SDK\libmosquitto
47!endif
48
49# Binaries directory
50NETXMS_LIBDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
51BINDIR = $(NETXMS_LIBDIR)
52
53# Component specific settings
54!if "$(COMPONENT)" == "server"
55CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
56!endif
57
58# Target specific settings
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
67!endif
68!if "$(TYPE)" == "hdlink"
69CPPFLAGS = $(CPPFLAGS) /D_USRDLL
70LDFLAGS = $(LDFLAGS) /DLL
71!endif
72!if "$(TYPE)" == "ndd"
73BINDIR = $(BINDIR)\ndd
74CPPFLAGS = $(CPPFLAGS) /D_USRDLL
75LDFLAGS = $(LDFLAGS) /DLL
76!endif
77!if "$(TYPE)" == "nsm"
78CPPFLAGS = $(CPPFLAGS) /D_USRDLL
79LDFLAGS = $(LDFLAGS) /DLL
80!endif
81
82# Common C/C++ compiler flags
83CPPFLAGS = $(CPPFLAGS) /MD /O2 /Gd /EHs- /GR- \
84 /I "$(NETXMS_BASE)\include" \
85 /I "$(NETXMS_BASE)\include\msvc" \
86 /I "$(NETXMS_BASE)\build" \
87 /I "$(CURL_BASE)\$(ARCH)\include" \
88 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
89 /I "$(LIBMOSQUITTO_BASE)\include" \
90 /D_MT /DUNICODE
91
92# Common linker flags
93MANIFEST = $(TARGET).intermediate.manifest
94LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
95 /LIBPATH:"$(NETXMS_LIBDIR)" \
96 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
97 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
98 /LIBPATH:"$(LIBMOSQUITTO_BASE)\$(ARCH)\lib"
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
121
122# Common libraries
123LIBS = $(LIBS) libssl.lib libcrypto.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
124
125# Prepare list of object files
126__sources = $(SOURCES:.cpp=.obj)
127OBJ = $(__sources:.c=.obj)
128
129# Compiled resources
130RESOBJ = $(RESOURCES:.rc=.res)
131
132# Source directory
133SRCDIR = $(MAKEDIR)
134
135# Output files
136!ifdef TARGET
137BINFILE = $(BINDIR)\$(TARGET)
138!endif
139
140all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
141
142# Build target
143!ifdef TARGET
144
145!if "$(TYPE)" == "jar"
146
147!if "$(JAR_BUILD_MODE)" == "install"
148MVNCMD=install
149!else
150MVNCMD=package
151!endif
152
153$(BINFILE): pom.xml
154 mvn clean
155 mvn $(MVNCMD) $(MVNFLAGS)
156 mv target/$(TARGET) $(BINFILE)
157
158!else
159
160$(BINFILE): objdir $(OBJ) $(RESOBJ)
161 @if not exist $(BINDIR) mkdir $(BINDIR)
162 @echo " LD " $(TARGET)
163 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
164 @rm -f $(MANIFEST)
165
166$(OBJ): $(NETXMS_BASE)\build\netxms-build-tag.h $(HEADERS)
167
168.PHONY: objdir
169
170objdir:
171 @if not exist $(OBJDIR) mkdir $(OBJDIR)
172 @cd $(OBJDIR)
173
174{$(SRCDIR)}.c.obj:
175 @echo " CC " $(<F)
176 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
177
178{$(SRCDIR)}.cpp.obj:
179 @echo " CXX" $(<F)
180 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
181
182{$(SRCDIR)}.rc.res:
183 @echo " RC " $(<F)
184 @$(RC) /nologo /r $<
185 @mv $(SRCDIR)\$@ .
186
187MSG00001.bin: messages.mc
188 @echo " MC messages.mc"
189 @$(MC) messages.mc
190 @rm -f messages.rc
191
192messages.h: messages.mc
193 @echo " MC messages.mc"
194 @$(MC) messages.mc
195 @rm -f messages.rc
196
197!endif
198!endif
199
200# Clean
201.PHONY: clean
202
203clean:
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 )
215
216# Sub-directories building rules
217.PHONY: subdirs
218
219subdirs:
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 .. \
229 )