bundled zlib updated to version 1.2.11
[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
51BINDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
52
53# Output files
54!ifdef TARGET
55BINFILE = $(BINDIR)\$(TARGET)
48e08d41 56!endif
64a055a2
VK
57
58# Common C/C++ compiler flags
7cf94f18 59CPPFLAGS = $(CPPFLAGS) /O2 /Gd /EHs- /GR- \
bf826019
VK
60 /I "$(NETXMS_BASE)\include" \
61 /I "$(NETXMS_BASE)\build" \
62 /I "$(CURL_BASE)\$(ARCH)\include" \
63 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
7cf94f18 64 /D_MT /DUNICODE
bf826019
VK
65
66!if "$(COMPONENT)" == "server"
67CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
68!endif
64a055a2
VK
69
70# Common linker flags
7cf94f18
VK
71!if "$(TYPE)" == "dll"
72CPPFLAGS = $(CPPFLAGS) /D_USRDLL
73IMPLIB = $(BINFILE:.dll=.lib)
74LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
75!endif
76!if "$(TYPE)" == "ddr"
77CPPFLAGS = $(CPPFLAGS) /D_USRDLL
78LDFLAGS = $(LDFLAGS) /DLL
48e08d41 79!endif
7cf94f18
VK
80!if "$(TYPE)" == "nsm"
81CPPFLAGS = $(CPPFLAGS) /D_USRDLL
82LDFLAGS = $(LDFLAGS) /DLL
83!endif
84MANIFEST = $(TARGET).intermediate.manifest
85LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
bf826019
VK
86 /LIBPATH:"$(BINDIR)" \
87 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
88 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
89 /LIBPATH:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)"
64a055a2
VK
90
91# Common libraries
7cf94f18 92LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
93
94# Prepare list of object files
7cf94f18
VK
95__sources = $(SOURCES:.cpp=.obj)
96OBJ = $(__sources:.c=.obj)
48e08d41
VK
97
98# Source directory
7cf94f18 99SRCDIR = $(MAKEDIR)
48e08d41 100
7cf94f18 101all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
102
103# Build target
104!ifdef TARGET
64a055a2 105
8b27778f
VK
106!if "$(TYPE)" == "jar"
107
108$(BINFILE): pom.xml
109 mvn clean
110 mvn install
111 mv target/$(TARGET) $(BINFILE)
112
113!else
114
7cf94f18
VK
115$(BINFILE): objdir $(OBJ)
116 @if not exist $(BINDIR) mkdir $(BINDIR)
117 @echo " LD " $(TARGET)
118 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(LIBS)
119 @rm -f $(MANIFEST)
64a055a2 120
48e08d41 121.PHONY: objdir
64a055a2 122
48e08d41
VK
123objdir:
124 @if not exist $(OBJDIR) mkdir $(OBJDIR)
125 @cd $(OBJDIR)
64a055a2 126
48e08d41 127{$(SRCDIR)}.c.obj:
7cf94f18
VK
128 @echo " CC " $(<F)
129 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
130
131{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
132 @echo " CXX" $(<F)
133 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
134
135.rc.res:
136 @echo " RC " $(<F)
bf826019 137 @$(RC) /nologo /r $<
7cf94f18
VK
138
139MSG00001.bin: messages.mc
140 @echo " MC messages.mc"
141 @$(MC) messages.mc
9dd277ba 142 @rm -f messages.rc
64a055a2 143
7cf94f18
VK
144messages.h: messages.mc
145 @echo " MC messages.mc"
146 @$(MC) messages.mc
9dd277ba 147 @rm -f messages.rc
48e08d41
VK
148
149!endif
8b27778f 150!endif
64a055a2 151
48e08d41 152# Clean
7cf94f18
VK
153.PHONY: clean
154
64a055a2 155clean:
7cf94f18
VK
156 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
157 @for %%s in ($(SUBDIRS)) do @( \
158 echo === Entering %%s === && \
159 cd %%s && \
160 @( \
161 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
162 exit 1 \
163 ) && \
164 echo === Leaving %%s === && \
165 cd .. \
166 )
64a055a2
VK
167
168# Sub-directories building rules
48e08d41
VK
169.PHONY: subdirs
170
171subdirs:
7cf94f18
VK
172 @for %%s in ($(SUBDIRS)) do @( \
173 echo === Entering %%s === && \
174 cd %%s && \
175 @( \
176 $(MAKE) /NOLOGO /F Makefile.w32 || \
177 exit 1 \
178 ) && \
179 echo === Leaving %%s === && \
180 cd .. \
48e08d41 181 )