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