initial WIndows makefile version for VC++ Build Tools
[public/netxms.git] / Makefile.inc.w32
1 # Common settings for Win32 builds
2
3 CC=cl
4 CXX=cl
5 LD=link
6 MAKE=nmake
7
8 # Source base path
9 #BASE_PATH := $(dir $(lastword $(MAKEFILE_LIST)))
10
11 # Architecture
12 !ifndef ARCH
13 ARCH=x64
14 !endif
15
16 !if "$(ARCH)"=="x64"
17 WINDDK_ARCH=amd64
18 WINSDK_LIB=Lib\x64
19 WINSDK_BIN=Bin\x64
20 OBJDIR=amd64
21 !endif
22
23 !if "$(ARCH)"=="x86"
24 WINDDK_ARCH=i386
25 WINSDK_LIB=Lib
26 WINSDK_BIN=Bin
27 OBJDIR=i386
28 !endif
29
30 # SDK locations
31 #-include ${BASE_PATH}winsdk.inc
32
33 !ifndef VCBUILD_BASE
34 VCBUILD_BASE=C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC
35 !endif
36 !ifndef WINSDK_BASE
37 WINSDK_BASE=C:\SDK\Windows 7 SDK
38 !endif
39 !ifndef WINDDK_BASE
40 WINDDK_BASE=C:\SDK\WinDDK
41 !endif
42 !ifndef OPENSSL_BASE
43 OPENSSL_BASE=C:\SDK\OpenSSL
44 !endif
45
46 # Common C/C++ compiler flags
47 CPPFLAGS=$(CPPFLAGS) /O2 /Gd -I "$(BASE_PATH)include" -I "$(WINSDK_BASE)\include" -I "$(VCBUILD_BASE)\include" \
48 -I "$(OPENSSL_BASE)\$(ARCH)\include" \
49 -D_MT -DUNICODE
50
51 # Common linker flags
52 !if "$(TYPE)"=="dll"
53 IMPLIB=$(TARGET:.dll=.lib)
54 LDFLAGS=$(LDFLAGS) -dll -implib:$(IMPLIB)
55 !endif
56 MANIFEST=$(TARGET).intermediate.manifest
57 LDFLAGS=$(LDFLAGS) -subsystem:windows -machine:$(ARCH) -manifestfile:$(MANIFEST) -libpath:"$(OPENSSL_BASE)\$(ARCH)\lib" -libpath:"$(WINDDK_BASE)\lib\wnet\$(WINDDK_ARCH)" -libpath:"$(WINSDK_BASE)\$(WINSDK_LIB)"
58
59 # Common libraries
60 LIBS=$(LIBS) ssleay32.lib libeay32.lib uuid.lib kernel32.lib user32.lib advapi32.lib shell32.lib
61
62 # Prepare list of object files
63 __sources=$(SOURCES:.cpp=.obj)
64 OBJ=$(__sources:.c=.obj)
65
66 # Source directory
67 SRCDIR=$(MAKEDIR)
68
69 all: subdirs $(GENERATED) $(TARGET)
70
71 # Build target
72 !ifdef TARGET
73
74 $(TARGET): objdir $(OBJ)
75 $(LD) $(LDFLAGS) /out:$(TARGET) $(OBJ) $(LIBS)
76 rm -f $(MANIFEST)
77
78 .PHONY: objdir
79
80 objdir:
81 @if not exist $(OBJDIR) mkdir $(OBJDIR)
82 @cd $(OBJDIR)
83
84 {$(SRCDIR)}.c.obj:
85 $(CC) $(CPPFLAGS) $(CFLAGS) /c $< /Fo$@
86
87 {$(SRCDIR)}.cpp.obj:
88 $(CXX) $(CPPFLAGS) $(CXXFLAGS) /c $< /Fo$@
89
90 messages.cpp: messages.mc
91 $(MC) $< -cpp
92
93 !endif
94
95 # Clean
96 clean:
97 rm -f $(OBJ) $(TARGET) $(GENERATED) $(EXTRA_CLEAN)
98
99 # Sub-directories building rules
100 .PHONY: subdirs
101
102 subdirs:
103 @for %%s in ($(SUBDIRS)) do @( \
104 echo === Entering %%s === && \
105 cd %%s && \
106 $(MAKE) /NOLOGO /F Makefile.w32 && \
107 echo === Leaving %%s === \
108 )