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