Move the sources to trunk
[opencv] / _make / make_module_bc.mak
1 #
2 # This is helper makefile that can build DLL or EXE for i386, amd64 or ia64 platform.
3 # User of the makefile should specify the following symbols:
4 #    * DEBUG (1/0) - iff a debug version of the binary should be build (0 by default)
5 #    * TARGET - base name of the binary (ex.: cxcore, cv, ml, cvtest etc.)
6 #    * BINTYPE (DLL/CONSOLE/APP) - the type of application (dll/console app/app with gui), dll by default
7 #    * ROOT - the relative path to the root opencv directory
8 #    * OBJS - the list of object files, each file must be preceded with $(OBJPATH)\
9 #    * INCS - the list of include files
10 #    * CXX - the compiler to be used (cl by default)
11 #    * CXXFLAGS_PROJ - the initial compiler options
12 #           (some project-specific defines and the list of include directories)
13 #    * LIBS_PROJ - the initial linker options
14 #           (the list of linked libraries + path to the libraries)
15 #    * RES_FILE - resource file, if any
16 #
17
18 !ifndef MY_CXX
19 MY_CXX = bcc32
20 !endif
21
22 CXX = $(MY_CXX)
23
24 !ifndef MY_LINK
25 MY_LINK = bcc32
26 !endif
27
28 LINK = $(MY_LINK)
29
30 # Analyze binary type
31
32 !ifndef BINTYPE
33 BINTYPE = DLL
34 !endif
35
36 !if "$(BINTYPE)"=="DLL"
37
38 !ifndef VER
39 VER = 100
40 !endif
41
42 EXT = .dll
43 CXXFLAGS_DLL = -D"CVAPI_EXPORTS"
44 LINKFLAGS_DLL = -tWD
45
46 !else
47
48 EXT = .exe
49 CXXFLAGS_DLL =
50
51 !if "$(BINTYPE)"=="CONSOLE"
52 LINKFLAGS_DLL = -tWC
53 !else if "$(BINTYPE)"=="APP"
54 LINKFLAGS_DLL = -tW
55 !endif
56
57 !endif
58
59 # Check debug/release
60
61 !ifndef DEBUG
62 DEBUG = 0
63 !endif
64
65 !if $(DEBUG)
66
67 CXXFLAGS_DBG = -D"_DEBUG" -Od -v
68 TEMP_DBG_SUFFIX = _Dbg
69 DBG = d
70
71 !else
72
73 CXXFLAGS_DBG = -D"NDEBUG" -O2 -v
74 TEMP_DBG_SUFFIX = _Rls
75 DBG = 
76
77 !endif
78
79 OBJPATH = $(ROOT)\_temp\$(TARGET)$(TEMP_DBG_SUFFIX)_bcc
80 OUTBIN = $(ROOT)\bin\$(TARGET)$(VER)$(DBG)$(EXT)
81 OUTLIB = $(ROOT)\lib\$(TARGET)$(DBG).lib
82 LIBS = kernel32.lib user32.lib gdi32.lib advapi32.lib
83
84 I=-I
85 LIBPATH=-L
86
87 CXXFLAGS = -q -3 -a8 -b -c -d -RT- -tWM -tW -w-inl -w-aus -j200 -D"WIN32" -D"_WINDOWS" $(CXXFLAGS_DLL) $(CXXFLAGS_DBG) $(CXXFLAGS_PROJ) -o 
88 LINKFLAGS = -q -lq -v -lv -e$(OUTBIN) $(LINKFLAGS_DLL) $(LIBS_PROJ) $(MY_LINKFLAGS)
89
90 !ifndef SRCPATH
91 SRCPATH = .
92 !endif
93
94 .path.c = $(SRCPATH)
95 .path.cpp = $(SRCPATH)
96 .path.obj = $(OBJPATH)
97
98 .autodepend
99
100 !if "$(BINTYPE)"=="DLL"
101
102 $(OUTBIN): $(OBJS)
103     @echo ********* Linking $(TARGET) ...
104     @-mkdir $(ROOT)\bin 2> nul
105     @-mkdir $(ROOT)\lib 2> nul
106     @$(LINK) $(LINKFLAGS) $** $(LIBS) 
107     @implib $(OUTLIB) $(OUTBIN)
108
109 !else
110
111 $(OUTBIN): $(OBJS)
112     @echo ********* Linking $(TARGET) ...
113     @-mkdir $(ROOT)\bin 2> nul
114     @$(LINK) $(LINKFLAGS) $** $(LIBS) 
115
116 !endif
117
118 .cpp.obj:
119     @-mkdir $(OBJPATH) 2> nul
120     @$(CXX) $(CXXFLAGS)"$@" $<
121
122 .c.obj:
123     @-mkdir $(OBJPATH) 2> nul
124     @$(CXX) $(CXXFLAGS)"$@" $<
125
126 all:
127     $(OUTBIN)
128
129 clean:
130     @-del $(OUTBIN) 2> nul
131     @-del $(OUTPDB) 2> nul
132     @-del $(OUTLIB) 2> nul
133     @-rmdir /s /q $(OBJPATH) 2> nul
134
135 $(OBJS): $(INCS)