fixed Windows build issues
[public/netxms.git] / Makefile.inc.w32
CommitLineData
64a055a2
VK
1# Common settings for Win32 builds
2
7cf94f18
VK
3CC = cl
4CXX = cl
5LD = link
6PERL = perl
7LEX = flex
8YACC = bison
9MC = mc
64a055a2
VK
10
11# Source base path
7cf94f18
VK
12# Default location is C:\Source\NetXMS
13# It can be changed by setting NETXMS_BASE environment variable
14!ifndef NETXMS_BASE
15NETXMS_BASE = C:\Source\NetXMS
16!endif
64a055a2
VK
17
18# Architecture
48e08d41 19!ifndef ARCH
7cf94f18 20ARCH = x64
48e08d41
VK
21!endif
22
7cf94f18
VK
23!if "$(ARCH)" == "x64"
24WINDDK_ARCH = amd64
25WINSDK_LIB = Lib\x64
26WINSDK_BIN = Bin\x64
27VCBUILD_LIB = Lib\amd64
28OBJDIR = amd64
48e08d41
VK
29!endif
30
7cf94f18
VK
31!if "$(ARCH)" == "x86"
32WINDDK_ARCH = i386
33WINSDK_LIB = Lib
34WINSDK_BIN = Bin
35VCBUILD_LIB = Lib
36OBJDIR = i386
48e08d41 37!endif
64a055a2
VK
38
39# SDK locations
48e08d41
VK
40#-include ${BASE_PATH}winsdk.inc
41
42!ifndef VCBUILD_BASE
7cf94f18 43VCBUILD_BASE = C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
48e08d41
VK
44!endif
45!ifndef WINSDK_BASE
7cf94f18 46WINSDK_BASE = C:\SDK\Windows 7 SDK
48e08d41
VK
47!endif
48!ifndef WINDDK_BASE
7cf94f18 49WINDDK_BASE = C:\SDK\WinDDK
48e08d41
VK
50!endif
51!ifndef OPENSSL_BASE
7cf94f18
VK
52OPENSSL_BASE = C:\SDK\OpenSSL
53!endif
8b27778f
VK
54!ifndef JDK_BASE
55JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
56!endif
7cf94f18
VK
57
58# Binaries directory
59BINDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
60
61# Output files
62!ifdef TARGET
63BINFILE = $(BINDIR)\$(TARGET)
48e08d41 64!endif
64a055a2
VK
65
66# Common C/C++ compiler flags
7cf94f18
VK
67CPPFLAGS = $(CPPFLAGS) /O2 /Gd /EHs- /GR- \
68 /I "$(NETXMS_BASE)\include" \
69 /I "$(NETXMS_BASE)\build" \
70 /I "$(WINSDK_BASE)\include" \
71 /I "$(VCBUILD_BASE)\include" \
72 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
73 /D_MT /DUNICODE
64a055a2
VK
74
75# Common linker flags
7cf94f18
VK
76!if "$(TYPE)" == "dll"
77CPPFLAGS = $(CPPFLAGS) /D_USRDLL
78IMPLIB = $(BINFILE:.dll=.lib)
79LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
80!endif
81!if "$(TYPE)" == "ddr"
82CPPFLAGS = $(CPPFLAGS) /D_USRDLL
83LDFLAGS = $(LDFLAGS) /DLL
48e08d41 84!endif
7cf94f18
VK
85!if "$(TYPE)" == "nsm"
86CPPFLAGS = $(CPPFLAGS) /D_USRDLL
87LDFLAGS = $(LDFLAGS) /DLL
88!endif
89MANIFEST = $(TARGET).intermediate.manifest
90LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
91 /LIBPATH:"$(BINDIR)" \
92 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
93 /LIBPATH:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)" \
94 /LIBPATH:"$(WINSDK_BASE)\$(WINSDK_LIB)" \
95 /LIBPATH:"$(VCBUILD_BASE)\$(VCBUILD_LIB)"
64a055a2
VK
96
97# Common libraries
7cf94f18 98LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
64a055a2
VK
99
100# Prepare list of object files
7cf94f18
VK
101__sources = $(SOURCES:.cpp=.obj)
102OBJ = $(__sources:.c=.obj)
48e08d41
VK
103
104# Source directory
7cf94f18 105SRCDIR = $(MAKEDIR)
48e08d41 106
7cf94f18 107all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
48e08d41
VK
108
109# Build target
110!ifdef TARGET
64a055a2 111
8b27778f
VK
112!if "$(TYPE)" == "jar"
113
114$(BINFILE): pom.xml
115 mvn clean
116 mvn install
117 mv target/$(TARGET) $(BINFILE)
118
119!else
120
7cf94f18
VK
121$(BINFILE): objdir $(OBJ)
122 @if not exist $(BINDIR) mkdir $(BINDIR)
123 @echo " LD " $(TARGET)
124 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(LIBS)
125 @rm -f $(MANIFEST)
64a055a2 126
48e08d41 127.PHONY: objdir
64a055a2 128
48e08d41
VK
129objdir:
130 @if not exist $(OBJDIR) mkdir $(OBJDIR)
131 @cd $(OBJDIR)
64a055a2 132
48e08d41 133{$(SRCDIR)}.c.obj:
7cf94f18
VK
134 @echo " CC " $(<F)
135 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
48e08d41
VK
136
137{$(SRCDIR)}.cpp.obj:
7cf94f18
VK
138 @echo " CXX" $(<F)
139 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
140
141.rc.res:
142 @echo " RC " $(<F)
143 @$(RC) /nologo /r /i "$(WINSDK_BASE)\include" /i "$(VCBUILD_BASE)\include" $<
144
145MSG00001.bin: messages.mc
146 @echo " MC messages.mc"
147 @$(MC) messages.mc
64a055a2 148
7cf94f18
VK
149messages.h: messages.mc
150 @echo " MC messages.mc"
151 @$(MC) messages.mc
48e08d41
VK
152
153!endif
8b27778f 154!endif
64a055a2 155
48e08d41 156# Clean
7cf94f18
VK
157.PHONY: clean
158
64a055a2 159clean:
7cf94f18
VK
160 rm -rf $(OBJ) $(TARGET) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
161 @for %%s in ($(SUBDIRS)) do @( \
162 echo === Entering %%s === && \
163 cd %%s && \
164 @( \
165 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
166 exit 1 \
167 ) && \
168 echo === Leaving %%s === && \
169 cd .. \
170 )
64a055a2
VK
171
172# Sub-directories building rules
48e08d41
VK
173.PHONY: subdirs
174
175subdirs:
7cf94f18
VK
176 @for %%s in ($(SUBDIRS)) do @( \
177 echo === Entering %%s === && \
178 cd %%s && \
179 @( \
180 $(MAKE) /NOLOGO /F Makefile.w32 || \
181 exit 1 \
182 ) && \
183 echo === Leaving %%s === && \
184 cd .. \
48e08d41 185 )