support for struct dirent.d_type added to Linux readdir wrapper
[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 WINDDK_ARCH = i386
33 OBJDIR = i386
34 !endif
35
36 # SDK locations
37 !ifndef WINDDK_BASE
38 WINDDK_BASE = C:\SDK\WinDDK
39 !endif
40 !ifndef OPENSSL_BASE
41 OPENSSL_BASE = C:\SDK\OpenSSL
42 !endif
43 !ifndef CURL_BASE
44 CURL_BASE = C:\SDK\cURL
45 !endif
46 !ifndef JDK_BASE
47 JDK_BASE = C:\Program Files\Java\jdk1.8.0_121
48 !endif
49
50 # Binaries directory
51 NETXMS_LIBDIR = $(NETXMS_BASE)\bin\$(OBJDIR)
52 BINDIR = $(NETXMS_LIBDIR)
53
54 # Component specific settings
55 !if "$(COMPONENT)" == "server"
56 CPPFLAGS = $(CPPFLAGS) /I "$(NETXMS_BASE)\src\server\include"
57 !endif
58
59 # Target specific settings
60 !if "$(TYPE)" == "dll"
61 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
62 IMPLIB = $(BINFILE:.dll=.lib)
63 LDFLAGS = $(LDFLAGS) /DLL /IMPLIB:$(IMPLIB)
64 !endif
65 !if "$(TYPE)" == "ddr"
66 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
67 LDFLAGS = $(LDFLAGS) /DLL
68 !endif
69 !if "$(TYPE)" == "hdlink"
70 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
71 LDFLAGS = $(LDFLAGS) /DLL
72 !endif
73 !if "$(TYPE)" == "ndd"
74 BINDIR = $(BINDIR)\ndd
75 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
76 LDFLAGS = $(LDFLAGS) /DLL
77 !endif
78 !if "$(TYPE)" == "nsm"
79 CPPFLAGS = $(CPPFLAGS) /D_USRDLL
80 LDFLAGS = $(LDFLAGS) /DLL
81 !endif
82
83 # Common C/C++ compiler flags
84 CPPFLAGS = $(CPPFLAGS) /MD /O2 /Gd /EHs- /GR- \
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
92 MANIFEST = $(TARGET).intermediate.manifest
93 LDFLAGS = $(LDFLAGS) /SUBSYSTEM:CONSOLE /MACHINE:$(ARCH) /MANIFESTFILE:$(MANIFEST) \
94 /LIBPATH:"$(NETXMS_LIBDIR)" \
95 /LIBPATH:"$(CURL_BASE)\$(ARCH)\lib" \
96 /LIBPATH:"$(OPENSSL_BASE)\$(ARCH)\lib" \
97 /LIBPATH:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)"
98
99 # Common libraries
100 LIBS = $(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
101
102 # Prepare list of object files
103 __sources = $(SOURCES:.cpp=.obj)
104 OBJ = $(__sources:.c=.obj)
105
106 # Compiled resources
107 RESOBJ = $(RESOURCES:.rc=.res)
108
109 # Source directory
110 SRCDIR = $(MAKEDIR)
111
112 # Output files
113 !ifdef TARGET
114 BINFILE = $(BINDIR)\$(TARGET)
115 !endif
116
117 all: Makefile.w32 subdirs $(GENERATED) $(BINFILE)
118
119 # Build target
120 !ifdef TARGET
121
122 !if "$(TYPE)" == "jar"
123
124 $(BINFILE): pom.xml
125 mvn clean
126 mvn install
127 mv target/$(TARGET) $(BINFILE)
128
129 !else
130
131 $(BINFILE): objdir $(OBJ) $(RESOBJ)
132 @if not exist $(BINDIR) mkdir $(BINDIR)
133 @echo " LD " $(TARGET)
134 @$(LD) /NOLOGO $(LDFLAGS) /out:$(BINFILE) $(OBJ) $(RESOBJ) $(LIBS)
135 @rm -f $(MANIFEST)
136
137 .PHONY: objdir
138
139 objdir:
140 @if not exist $(OBJDIR) mkdir $(OBJDIR)
141 @cd $(OBJDIR)
142
143 {$(SRCDIR)}.c.obj:
144 @echo " CC " $(<F)
145 @$(CC) /nologo $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@ | tail -n +2
146
147 {$(SRCDIR)}.cpp.obj:
148 @echo " CXX" $(<F)
149 @$(CXX) /nologo $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@ | tail -n +2
150
151 {$(SRCDIR)}.rc.res:
152 @echo " RC " $(<F)
153 @$(RC) /nologo /r $<
154 @mv $(SRCDIR)\$@ .
155
156 MSG00001.bin: messages.mc
157 @echo " MC messages.mc"
158 @$(MC) messages.mc
159 @rm -f messages.rc
160
161 messages.h: messages.mc
162 @echo " MC messages.mc"
163 @$(MC) messages.mc
164 @rm -f messages.rc
165
166 !endif
167 !endif
168
169 # Clean
170 .PHONY: clean
171
172 clean:
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 )
184
185 # Sub-directories building rules
186 .PHONY: subdirs
187
188 subdirs:
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 .. \
198 )