intermediate release
[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
VK
31!if "$(ARCH)" == "x86"
32WINDDK_ARCH = i386
7cf94f18 33OBJDIR = i386
48e08d41 34!endif
64a055a2
VK
35
36# SDK locations
48e08d41 37!ifndef WINDDK_BASE
7cf94f18 38WINDDK_BASE = C:\SDK\WinDDK
48e08d41
VK
39!endif
40!ifndef OPENSSL_BASE
7cf94f18
VK
41OPENSSL_BASE = C:\SDK\OpenSSL
42!endif
bf826019
VK
43!ifndef CURL_BASE
44CURL_BASE = C:\SDK\cURL
45!endif
8b27778f
VK
46!ifndef JDK_BASE
47JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
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
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
80CPPFLAGS = $(CPPFLAGS) /O2 /Gd /EHs- /GR- \
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
VK
91 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
92 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
93 /LIBPATH:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)"
64a055a2
VK
94
95# Common libraries
7cf94f18 96LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
97
98# Prepare list of object files
7cf94f18
VK
99__sources = $(SOURCES:.cpp=.obj)
100OBJ = $(__sources:.c=.obj)
48e08d41
VK
101
102# Source directory
7cf94f18 103SRCDIR = $(MAKEDIR)
48e08d41 104
d9654419
VK
105# Output files
106!ifdef TARGET
107BINFILE = $(BINDIR)\$(TARGET)
108!endif
109
7cf94f18 110all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
111
112# Build target
113!ifdef TARGET
64a055a2 114
8b27778f
VK
115!if "$(TYPE)" == "jar"
116
117$(BINFILE): pom.xml
118 mvn clean
119 mvn install
120 mv target/$(TARGET) $(BINFILE)
121
122!else
123
7cf94f18
VK
124$(BINFILE): objdir $(OBJ)
125 @if not exist $(BINDIR) mkdir $(BINDIR)
126 @echo " LD " $(TARGET)
d9654419 127 $(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(LIBS)
7cf94f18 128 @rm -f $(MANIFEST)
64a055a2 129
48e08d41 130.PHONY: objdir
64a055a2 131
48e08d41
VK
132objdir:
133 @if not exist $(OBJDIR) mkdir $(OBJDIR)
134 @cd $(OBJDIR)
64a055a2 135
48e08d41 136{$(SRCDIR)}.c.obj:
7cf94f18
VK
137 @echo " CC " $(<F)
138 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
139
140{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
141 @echo " CXX" $(<F)
142 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
143
144.rc.res:
145 @echo " RC " $(<F)
bf826019 146 @$(RC) /nologo /r $<
7cf94f18
VK
147
148MSG00001.bin: messages.mc
149 @echo " MC messages.mc"
150 @$(MC) messages.mc
9dd277ba 151 @rm -f messages.rc
64a055a2 152
7cf94f18
VK
153messages.h: messages.mc
154 @echo " MC messages.mc"
155 @$(MC) messages.mc
9dd277ba 156 @rm -f messages.rc
48e08d41
VK
157
158!endif
8b27778f 159!endif
64a055a2 160
48e08d41 161# Clean
7cf94f18
VK
162.PHONY: clean
163
64a055a2 164clean:
7cf94f18
VK
165 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
166 @for %%s in ($(SUBDIRS)) do @( \
167 echo === Entering %%s === && \
168 cd %%s && \
169 @( \
170 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
171 exit 1 \
172 ) && \
173 echo === Leaving %%s === && \
174 cd .. \
175 )
64a055a2
VK
176
177# Sub-directories building rules
48e08d41
VK
178.PHONY: subdirs
179
180subdirs:
7cf94f18
VK
181 @for %%s in ($(SUBDIRS)) do @( \
182 echo === Entering %%s === && \
183 cd %%s && \
184 @( \
185 $(MAKE) /NOLOGO /F Makefile.w32 || \
186 exit 1 \
187 ) && \
188 echo === Leaving %%s === && \
189 cd .. \
48e08d41 190 )