support for struct dirent.d_type added to Linux readdir wrapper
[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
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
VK
85 /I "$(NETXMS_BASE)\include" \
86 /I "$(NETXMS_BASE)\build" \
87 /I "$(CURL_BASE)\$(ARCH)\include" \
88 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
89 /D_MT /DUNICODE
90
91# Common linker flags
7cf94f18
VK
92MANIFEST = $(TARGET).intermediate.manifest
93LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
d9654419 94 /LIBPATH:"$(NETXMS_LIBDIR)" \
bf826019
VK
95 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
96 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
97 /LIBPATH:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)"
64a055a2
VK
98
99# Common libraries
7cf94f18 100LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
101
102# Prepare list of object files
7cf94f18
VK
103__sources = $(SOURCES:.cpp=.obj)
104OBJ = $(__sources:.c=.obj)
48e08d41 105
91c1f188
VK
106# Compiled resources
107RESOBJ = $(RESOURCES:.rc=.res)
108
48e08d41 109# Source directory
7cf94f18 110SRCDIR = $(MAKEDIR)
48e08d41 111
d9654419
VK
112# Output files
113!ifdef TARGET
114BINFILE = $(BINDIR)\$(TARGET)
115!endif
116
7cf94f18 117all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
118
119# Build target
120!ifdef TARGET
64a055a2 121
8b27778f
VK
122!if "$(TYPE)" == "jar"
123
124$(BINFILE): pom.xml
125 mvn clean
126 mvn install
127 mv target/$(TARGET) $(BINFILE)
128
129!else
130
91c1f188 131$(BINFILE): objdir $(OBJ) $(RESOBJ)
7cf94f18
VK
132 @if not exist $(BINDIR) mkdir $(BINDIR)
133 @echo " LD " $(TARGET)
e3738c4b 134 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
7cf94f18 135 @rm -f $(MANIFEST)
64a055a2 136
48e08d41 137.PHONY: objdir
64a055a2 138
48e08d41
VK
139objdir:
140 @if not exist $(OBJDIR) mkdir $(OBJDIR)
141 @cd $(OBJDIR)
64a055a2 142
48e08d41 143{$(SRCDIR)}.c.obj:
7cf94f18
VK
144 @echo " CC " $(<F)
145 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
146
147{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
148 @echo " CXX" $(<F)
149 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
150
91c1f188 151{$(SRCDIR)}.rc.res:
7cf94f18 152 @echo " RC " $(<F)
bf826019 153 @$(RC) /nologo /r $<
91c1f188 154 @mv $(SRCDIR)\$@ .
7cf94f18
VK
155
156MSG00001.bin: messages.mc
157 @echo " MC messages.mc"
158 @$(MC) messages.mc
9dd277ba 159 @rm -f messages.rc
64a055a2 160
7cf94f18
VK
161messages.h: messages.mc
162 @echo " MC messages.mc"
163 @$(MC) messages.mc
9dd277ba 164 @rm -f messages.rc
48e08d41
VK
165
166!endif
8b27778f 167!endif
64a055a2 168
48e08d41 169# Clean
7cf94f18
VK
170.PHONY: clean
171
64a055a2 172clean:
7cf94f18
VK
173 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
174 @for %%s in ($(SUBDIRS)) do @( \
175 echo === Entering %%s === && \
176 cd %%s && \
177 @( \
178 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
179 exit 1 \
180 ) && \
181 echo === Leaving %%s === && \
182 cd .. \
183 )
64a055a2
VK
184
185# Sub-directories building rules
48e08d41
VK
186.PHONY: subdirs
187
188subdirs:
7cf94f18
VK
189 @for %%s in ($(SUBDIRS)) do @( \
190 echo === Entering %%s === && \
191 cd %%s && \
192 @( \
193 $(MAKE) /NOLOGO /F Makefile.w32 || \
194 exit 1 \
195 ) && \
196 echo === Leaving %%s === && \
197 cd .. \
48e08d41 198 )