created BEAR_CASSERT and renamed dassert to BEAR_DASSERT
[libbear.git] / vars.mk
1
2 # cause the fancy SS_ directory rules to work out
3 .SECONDEXPANSION:
4
5 # The SS rules need to be 'recursive' so they evaluate the @ variables at
6 # secondary expansion time
7 SS_DIR     = ${@D}
8
9 # Warning this secondary expansion rule is very very sensitive
10 #  tricks are needed to make things work because the stem % does not match
11 #  empty also, it is used by the call syntax as the package variable needs to be
12 #  invoked as usage time while the rest has to be delayed till secondary
13 #  expansion.
14 SS_DEPSDIR = $(patsubst %/,%,$(patsubst ${OBJSDIR_$(1)}%,${DEPSDIR_$(1)}%,$(dir $@)))
15
16
17 B_DEBUG    := DEBUG
18 B_FINAL    := FINAL
19 B_WIN32    := WIN32
20
21 # set this on the command line to get a WIN32 or a FINAL build
22 G_BUILD    := ${B_DEBUG}
23
24 ifeq (${G_BUILD},${B_DEBUG})
25 else
26 ifeq (${G_BUILD},${B_FINAL})
27 else
28 ifeq (${G_BUILD},${B_WIN32})
29 else
30     $(error 'G_BUILD = ${G_BUILD}' is invalid. Valid types are '${B_DEBUG}', '${B_FINAL}' or '${B_WIN32}')
31 endif
32 endif
33 endif
34
35
36 T_OPTFLAGS := -O2
37 T_DBGFLAGS := -ggdb
38 T_PRFFLAGS := ${T_DBGFLAGS} -pg
39
40 T_WARFLAGS :=
41 T_WARFLAGS += -Wall
42 T_WARFLAGS += -Wextra
43 T_WARFLAGS += -pedantic
44 T_WARFLAGS += -ansi
45 T_WARFLAGS += -Wshadow
46 T_WARFLAGS += -Wswitch-enum
47 T_WARFLAGS += -Wfloat-equal
48 T_WARFLAGS += -Wundef
49 T_WARFLAGS += -Wswitch-enum
50
51 G_CXXFLAGS := ${T_WARFLAGS}
52 ifeq (${G_BUILD},${B_DEBUG})
53     G_CXXFLAGS    += ${T_DBGFLAGS}
54 else
55 ifeq (${G_BUILD},${B_FINAL})
56     G_CXXFLAGS    += ${T_OPTFLAGS}
57 else
58 ifeq (${G_BUILD},${B_WIN32})
59     G_CXXFLAGS    += ${T_OPTFLAGS}
60 else
61     $(error 'G_BUILD = ${G_BUILD}' is invalid.)
62 endif
63 endif
64 endif
65
66 T_OPTFLAGS :=
67 T_DBGFLAGS :=
68 T_PRFFLAGS :=
69 T_WARFLAGS :=
70
71 G_LNKFLAGS :=
72
73 ifeq (${G_BUILD},${B_WIN32})
74     G_CXX := mingw32-g++
75 else
76     G_CXX := g++
77 endif
78
79 ifeq (${G_BUILD},${B_WIN32})
80     G_LIBGL   := -lopengl32 -lglu32
81     G_LIBSDL  := `/usr/mingw32/bin/sdl-config --libs`
82 else
83     G_LIBGL   := -lGL -lGLU
84     G_LIBSDL  := `sdl-config --libs`
85 endif
86
87 G_SRCSDIR := src
88 G_DEPSDIR := deps
89
90 ifeq (${G_BUILD},${B_DEBUG})
91     G_OBJSDIR := objsd
92     G_BINDIR  := bind
93 else
94 ifeq (${G_BUILD},${B_FINAL})
95     G_OBJSDIR := objs
96     G_BINDIR  := bin
97 else
98 ifeq (${G_BUILD},${B_WIN32})
99     G_OBJSDIR := objs-mingw32
100     G_BINDIR  := bin-mingw32
101 else
102     $(error 'G_BUILD = ${G_BUILD}' is invalid.)
103 endif
104 endif
105 endif
106
107 LOGFILE := bld.log
108
109 $(shell rm -f ${LOGFILE}) # remove the log file from last run
110
111 ifeq (${G_BUILD},${B_WIN32})
112     PRNTFMT := printf "%-12s: %s\n"
113     PRNTLOG := printf "\n\#\#  %-12s: %s\n"
114 else
115     PRNTFMT := printf "%-8s: %s\n"
116     PRNTLOG := printf "\n\#\#  %-8s: %s\n"
117 endif
118
119 VERBOSE := 0
120
121 ifeq (${VERBOSE},0)
122     # log the printf command
123     Q1s := @
124     Q1e := >> ${LOGFILE}
125     # quiet the printf command
126     Q2s := @
127     Q2e :=
128                 # log the command
129     Q3s := @echo # NOTE: the space between @echo and the # is VERY important!!
130     Q3e := >> ${LOGFILE}
131     # quiet the command
132     Q4s := @
133     Q4e :=
134 else
135     # EAT the logging printf command
136     Q1s := @true # NOTE: the space between @true and the # is VERY important!!
137     Q1e :=
138     # EAT the quiet printf command
139     Q2s := @true # NOTE: the space between @true and the # is VERY important!!
140     Q2e :=
141                 # EAT the logging command
142     Q3s := @true # NOTE: the space between @true and the # is VERY important!!
143     Q3e :=
144     # do not quiet the command
145     Q4s :=
146     Q4e :=
147 endif
148
149
150 ifeq (${G_BUILD},${B_WIN32})
151     prefix      := /usr/mingw32
152 else
153     prefix      := /usr
154 endif
155 exec_prefix := ${prefix}
156 includedir  := ${prefix}/include
157 libdir      := ${exec_prefix}/lib
158 INSTALL     := install
159