5c93e70109c83e082b4604de3482643a038635f5
[public/netxms.git] / Makefile.inc.w32
1 # Common settings for Win32 builds
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
5
6 CC = cl
7 CXX = cl
8 LD = link
9 PERL = perl
10 LEX = flex
11 YACC = bison
12 MC = mc
13
14 # Source base path
15 # Default location is C:\Source\NetXMS
16 # It can be changed by setting NETXMS_BASE environment variable
17 !ifndef NETXMS_BASE
18 NETXMS_BASE = C:\Source\NetXMS
19 !endif
20
21 # Architecture
22 !ifndef ARCH
23 ARCH = x64
24 !endif
25
26 !if "$(ARCH)" == "x64"
27 WINDDK_ARCH = amd64
28 OBJDIR = amd64
29 !endif
30
31 !if "$(ARCH)" == "x86"
32 OBJDIR = i386
33 !endif
34
35 # SDK locations
36 !ifndef OPENSSL_BASE
37 OPENSSL_BASE = C:\SDK\OpenSSL
38 !endif
39 !ifndef CURL_BASE
40 CURL_BASE = C:\SDK\cURL
41 !endif
42 !ifndef JDK_BASE
43 JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
44 !endif
45 !ifndef LIBMOSQUITTO_BASE
46 LIBMOSQUITTO_BASE = C:\SDK\libmosquitto
47 !endif
48
49 # Binaries directory
50 NETXMS_LIBDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
51 BINDIR = $(NETXMS_LIBDIR)
52
53 # Component specific settings
54 !if "$(COMPONENT)" == "server"
55 CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
56 !endif
57
58 # Target specific settings
59 !if "$(TYPE)" == "dll"
60 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
61 IMPLIB = $(BINFILE:.dll=.lib)
62 LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
63 !endif
64 !if "$(TYPE)" == "ddr"
65 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
66 LDFLAGS = $(LDFLAGS) /DLL
67 !endif
68 !if "$(TYPE)" == "hdlink"
69 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
70 LDFLAGS = $(LDFLAGS) /DLL
71 !endif
72 !if "$(TYPE)" == "ndd"
73 BINDIR = $(BINDIR)\ndd
74 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
75 LDFLAGS = $(LDFLAGS) /DLL
76 !endif
77 !if "$(TYPE)" == "nsm"
78 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
79 LDFLAGS = $(LDFLAGS) /DLL
80 !endif
81
82 # Common C/C++ compiler flags
83 CPPFLAGS = $(CPPFLAGS) /MD /O2 /Gd /EHs- /GR- \
84 /I "$(NETXMS_BASE)\include" \
85 /I "$(NETXMS_BASE)\include\msvc" \
86 /I "$(NETXMS_BASE)\build" \
87 /I "$(CURL_BASE)\$(ARCH)\include" \
88 /I "$(OPENSSL_BASE)\$(ARCH)\include" \
89 /I "$(LIBMOSQUITTO_BASE)\include" \
90 /D_MT /DUNICODE
91
92 # Common linker flags
93 MANIFEST = $(TARGET).intermediate.manifest
94 LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
95 /LIBPATH:"$(NETXMS_LIBDIR)" \
96 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
97 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
98 /LIBPATH:"$(LIBMOSQUITTO_BASE)\$(ARCH)\lib"
99
100 # Common headers
101 HEADERS = $(HEADERS) \
102 $(NETXMS_BASE)\include\build.h \
103 $(NETXMS_BASE)\include\geolocation.h \
104 $(NETXMS_BASE)\include\jansson.h \
105 $(NETXMS_BASE)\include\netxms-regex.h \
106 $(NETXMS_BASE)\include\netxms-version.h \
107 $(NETXMS_BASE)\include\netxms_getopt.h \
108 $(NETXMS_BASE)\include\nms_common.h \
109 $(NETXMS_BASE)\include\nms_cscp.h \
110 $(NETXMS_BASE)\include\nms_threads.h \
111 $(NETXMS_BASE)\include\nms_util.h \
112 $(NETXMS_BASE)\include\nxconfig.h \
113 $(NETXMS_BASE)\include\nxcpapi.h \
114 $(NETXMS_BASE)\include\nxcrypto.h \
115 $(NETXMS_BASE)\include\nxqueue.h \
116 $(NETXMS_BASE)\include\nxstat.h \
117 $(NETXMS_BASE)\include\rwlock.h \
118 $(NETXMS_BASE)\include\unicode.h \
119 $(NETXMS_BASE)\include\uthash.h \
120 $(NETXMS_BASE)\include\uuid.h
121
122 # Common libraries
123 LIBS = $(LIBS) libssl.lib libcrypto.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
124
125 # Prepare list of object files
126 __sources = $(SOURCES:.cpp=.obj)
127 OBJ = $(__sources:.c=.obj)
128
129 # Compiled resources
130 RESOBJ = $(RESOURCES:.rc=.res)
131
132 # Source directory
133 SRCDIR = $(MAKEDIR)
134
135 # Output files
136 !ifdef TARGET
137 BINFILE = $(BINDIR)\$(TARGET)
138 !endif
139
140 all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
141
142 # Build target
143 !ifdef TARGET
144
145 !if "$(TYPE)" == "jar"
146
147 !if "$(JAR_BUILD_MODE)" == "install"
148 MVNCMD=install
149 !else
150 MVNCMD=package
151 !endif
152
153 $(BINFILE): pom.xml
154 mvn clean
155 mvn $(MVNCMD) $(MVNFLAGS)
156 mv target/$(TARGET) $(BINFILE)
157
158 !else
159
160 $(BINFILE): objdir $(OBJ) $(RESOBJ)
161 @if not exist $(BINDIR) mkdir $(BINDIR)
162 @echo " LD " $(TARGET)
163 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
164 @rm -f $(MANIFEST)
165
166 $(OBJ): $(NETXMS_BASE)\build\netxms-build-tag.h $(HEADERS)
167
168 .PHONY: objdir
169
170 objdir:
171 @if not exist $(OBJDIR) mkdir $(OBJDIR)
172 @cd $(OBJDIR)
173
174 {$(SRCDIR)}.c.obj:
175 @echo " CC " $(<F)
176 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
177
178 {$(SRCDIR)}.cpp.obj:
179 @echo " CXX" $(<F)
180 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
181
182 {$(SRCDIR)}.rc.res:
183 @echo " RC " $(<F)
184 @$(RC) /nologo /r $<
185 @mv $(SRCDIR)\$@ .
186
187 MSG00001.bin: messages.mc
188 @echo " MC messages.mc"
189 @$(MC) messages.mc
190 @rm -f messages.rc
191
192 messages.h: messages.mc
193 @echo " MC messages.mc"
194 @$(MC) messages.mc
195 @rm -f messages.rc
196
197 !endif
198 !endif
199
200 # Clean
201 .PHONY: clean
202
203 clean:
204 rm -rf $(OBJ) $(TARGET) $(BINFILE) $(OBJDIR) $(GENERATED) $(EXTRA_CLEAN)
205 @for %%s in ($(SUBDIRS)) do @( \
206 echo === Entering %%s === && \
207 cd %%s && \
208 @( \
209 $(MAKE) /NOLOGO /F Makefile.w32 clean || \
210 exit 1 \
211 ) && \
212 echo === Leaving %%s === && \
213 cd .. \
214 )
215
216 # Sub-directories building rules
217 .PHONY: subdirs
218
219 subdirs:
220 @for %%s in ($(SUBDIRS)) do @( \
221 echo === Entering %%s === && \
222 cd %%s && \
223 @( \
224 $(MAKE) /NOLOGO /F Makefile.w32 || \
225 exit 1 \
226 ) && \
227 echo === Leaving %%s === && \
228 cd .. \
229 )