| 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 | B_CYGWIN := CYGWIN |
| 21 | |
| 22 | # set this on the command line to get a WIN32 or a FINAL build |
| 23 | G_BUILD := ${B_DEBUG} |
| 24 | |
| 25 | ifeq (${G_BUILD},${B_DEBUG}) |
| 26 | else |
| 27 | ifeq (${G_BUILD},${B_FINAL}) |
| 28 | else |
| 29 | ifeq (${G_BUILD},${B_WIN32}) |
| 30 | else |
| 31 | ifeq (${G_BUILD},${B_CYGWIN}) |
| 32 | else |
| 33 | $(error 'G_BUILD = ${G_BUILD}' is invalid. Valid types are '${B_DEBUG}', '${B_FINAL}', '${B_CYGWIN}', or '${B_WIN32}') |
| 34 | endif |
| 35 | endif |
| 36 | endif |
| 37 | endif |
| 38 | |
| 39 | |
| 40 | T_OPTFLAGS := -O2 |
| 41 | T_DBGFLAGS := -ggdb |
| 42 | T_PRFFLAGS := ${T_DBGFLAGS} -pg |
| 43 | |
| 44 | T_WARFLAGS := |
| 45 | T_WARFLAGS += -Wall |
| 46 | T_WARFLAGS += -Wextra |
| 47 | T_WARFLAGS += -pedantic |
| 48 | T_WARFLAGS += -ansi |
| 49 | T_WARFLAGS += -Wshadow |
| 50 | T_WARFLAGS += -Wswitch-enum |
| 51 | T_WARFLAGS += -Wfloat-equal |
| 52 | T_WARFLAGS += -Wundef |
| 53 | T_WARFLAGS += -Wswitch-enum |
| 54 | |
| 55 | G_CXXFLAGS := ${T_WARFLAGS} |
| 56 | ifeq (${G_BUILD},${B_DEBUG}) |
| 57 | G_CXXFLAGS += ${T_DBGFLAGS} |
| 58 | else |
| 59 | ifeq (${G_BUILD},${B_FINAL}) |
| 60 | G_CXXFLAGS += ${T_OPTFLAGS} |
| 61 | else |
| 62 | ifeq (${G_BUILD},${B_WIN32}) |
| 63 | G_CXXFLAGS += ${T_OPTFLAGS} |
| 64 | else |
| 65 | ifeq (${G_BUILD},${B_CYGWIN}) |
| 66 | G_CXXFLAGS += ${T_OPTFLAGS} |
| 67 | else |
| 68 | $(error 'G_BUILD = ${G_BUILD}' is invalid.) |
| 69 | endif |
| 70 | endif |
| 71 | endif |
| 72 | endif |
| 73 | |
| 74 | T_OPTFLAGS := |
| 75 | T_DBGFLAGS := |
| 76 | T_PRFFLAGS := |
| 77 | T_WARFLAGS := |
| 78 | |
| 79 | G_LNKFLAGS := |
| 80 | |
| 81 | ifeq (${G_BUILD},${B_WIN32}) |
| 82 | G_CXX := mingw32-g++ |
| 83 | else |
| 84 | G_CXX := g++ |
| 85 | endif |
| 86 | |
| 87 | ifeq (${G_BUILD},${B_DEBUG}) |
| 88 | G_LIBGL := -lGL -lGLU |
| 89 | G_LIBSDL := `sdl-config --libs` |
| 90 | else |
| 91 | ifeq (${G_BUILD},${B_FINAL}) |
| 92 | G_LIBGL := -lGL -lGLU |
| 93 | G_LIBSDL := `sdl-config --libs` |
| 94 | else |
| 95 | ifeq (${G_BUILD},${B_WIN32}) |
| 96 | G_LIBGL := -lopengl32 -lglu32 |
| 97 | G_LIBSDL := `/usr/mingw32/bin/sdl-config --libs` |
| 98 | else |
| 99 | ifeq (${G_BUILD},${B_CYGWIN}) |
| 100 | G_LIBGL := -lopengl32 -lglu32 |
| 101 | G_LIBSDL := `sdl-config --libs` |
| 102 | else |
| 103 | $(error 'G_BUILD = ${G_BUILD}' is invalid.) |
| 104 | endif |
| 105 | endif |
| 106 | endif |
| 107 | endif |
| 108 | |
| 109 | G_SRCSDIR := src |
| 110 | |
| 111 | ifeq (${G_BUILD},${B_DEBUG}) |
| 112 | G_OBJSDIR := objsd |
| 113 | G_BINDIR := bind |
| 114 | G_DEPSDIR := depsd |
| 115 | else |
| 116 | ifeq (${G_BUILD},${B_FINAL}) |
| 117 | G_OBJSDIR := objs |
| 118 | G_BINDIR := bin |
| 119 | G_DEPSDIR := deps |
| 120 | else |
| 121 | ifeq (${G_BUILD},${B_WIN32}) |
| 122 | G_OBJSDIR := objs-mingw32 |
| 123 | G_BINDIR := bin-mingw32 |
| 124 | G_DEPSDIR := deps-mingw32 |
| 125 | else |
| 126 | ifeq (${G_BUILD},${B_CYGWIN}) |
| 127 | G_OBJSDIR := objs-cygwin |
| 128 | G_BINDIR := bin-cygwin |
| 129 | G_DEPSDIR := deps-cygwin |
| 130 | else |
| 131 | $(error 'G_BUILD = ${G_BUILD}' is invalid.) |
| 132 | endif |
| 133 | endif |
| 134 | endif |
| 135 | endif |
| 136 | |
| 137 | LOGFILE := bld.log |
| 138 | |
| 139 | $(shell rm -f ${LOGFILE}) # remove the log file from last run |
| 140 | |
| 141 | ifeq (${G_BUILD},${B_WIN32}) |
| 142 | PRNTFMT := printf "%-12s: %s\n" |
| 143 | PRNTLOG := printf "\n\#\# %-12s: %s\n" |
| 144 | else |
| 145 | PRNTFMT := printf "%-8s: %s\n" |
| 146 | PRNTLOG := printf "\n\#\# %-8s: %s\n" |
| 147 | endif |
| 148 | |
| 149 | VERBOSE := 0 |
| 150 | |
| 151 | ifeq (${VERBOSE},0) |
| 152 | # log the printf command |
| 153 | Q1s := |
| 154 | Q1e := >> ${LOGFILE} |
| 155 | # quiet the printf command |
| 156 | Q2s := |
| 157 | Q2e := |
| 158 | # log the command |
| 159 | Q3s := echo # NOTE: the space between @echo and the # is VERY important!! |
| 160 | Q3e := >> ${LOGFILE} |
| 161 | # quiet the command, log the output |
| 162 | Q4s := set -o pipefail && |
| 163 | Q4e := 2>&1 | tee -a ${LOGFILE} |
| 164 | else |
| 165 | # EAT the logging printf command |
| 166 | Q1s := true # NOTE: the space between @true and the # is VERY important!! |
| 167 | Q1e := |
| 168 | # EAT the quiet printf command |
| 169 | Q2s := true # NOTE: the space between @true and the # is VERY important!! |
| 170 | Q2e := |
| 171 | # EAT the logging command |
| 172 | Q3s := true # NOTE: the space between @true and the # is VERY important!! |
| 173 | Q3e := |
| 174 | # do not quiet the command |
| 175 | Q4s := |
| 176 | Q4e := |
| 177 | endif |
| 178 | |
| 179 | |
| 180 | ifeq (${G_BUILD},${B_WIN32}) |
| 181 | prefix := /usr/mingw32 |
| 182 | else |
| 183 | prefix := /usr |
| 184 | endif |
| 185 | exec_prefix := ${prefix} |
| 186 | includedir := ${prefix}/include |
| 187 | libdir := ${exec_prefix}/lib |
| 188 | INSTALL := install |
| 189 | |