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