# cause the fancy SS_ directory rules to work out .SECONDEXPANSION: # The SS rules need to be 'recursive' so they evaluate the @ variables at # secondary expansion time SS_DIR = ${@D} # Warning this secondary expansion rule is very very sensitive # tricks are needed to make things work because the stem % does not match # empty also, it is used by the call syntax as the package variable needs to be # invoked as usage time while the rest has to be delayed till secondary # expansion. SS_DEPSDIR = $(patsubst %/,%,$(patsubst ${OBJSDIR_$(1)}%,${DEPSDIR_$(1)}%,$(dir $@))) B_DEBUG := DEBUG B_FINAL := FINAL B_WIN32 := WIN32 B_CYGWIN := CYGWIN # set this on the command line to get a WIN32 or a FINAL build G_BUILD := ${B_DEBUG} ifeq (${G_BUILD},${B_DEBUG}) else ifeq (${G_BUILD},${B_FINAL}) else ifeq (${G_BUILD},${B_WIN32}) else ifeq (${G_BUILD},${B_CYGWIN}) else $(error 'G_BUILD = ${G_BUILD}' is invalid. Valid types are '${B_DEBUG}', '${B_FINAL}', '${B_CYGWIN}', or '${B_WIN32}') endif endif endif endif T_OPTFLAGS := -O2 T_DBGFLAGS := -ggdb T_PRFFLAGS := ${T_DBGFLAGS} -pg T_WARFLAGS := T_WARFLAGS += -Wall T_WARFLAGS += -Wextra T_WARFLAGS += -pedantic T_WARFLAGS += -ansi T_WARFLAGS += -Wshadow T_WARFLAGS += -Wswitch-enum T_WARFLAGS += -Wfloat-equal T_WARFLAGS += -Wundef T_WARFLAGS += -Wswitch-enum G_CXXFLAGS := ${T_WARFLAGS} ifeq (${G_BUILD},${B_DEBUG}) G_CXXFLAGS += ${T_DBGFLAGS} else ifeq (${G_BUILD},${B_FINAL}) G_CXXFLAGS += ${T_OPTFLAGS} else ifeq (${G_BUILD},${B_WIN32}) G_CXXFLAGS += ${T_OPTFLAGS} else ifeq (${G_BUILD},${B_CYGWIN}) G_CXXFLAGS += ${T_OPTFLAGS} else $(error 'G_BUILD = ${G_BUILD}' is invalid.) endif endif endif endif T_OPTFLAGS := T_DBGFLAGS := T_PRFFLAGS := T_WARFLAGS := G_LNKFLAGS := ifeq (${G_BUILD},${B_WIN32}) G_CXX := mingw32-g++ else G_CXX := g++ endif ifeq (${G_BUILD},${B_DEBUG}) G_LIBGL := -lGL -lGLU G_LIBSDL := `sdl-config --libs` else ifeq (${G_BUILD},${B_FINAL}) G_LIBGL := -lGL -lGLU G_LIBSDL := `sdl-config --libs` else ifeq (${G_BUILD},${B_WIN32}) G_LIBGL := -lopengl32 -lglu32 G_LIBSDL := `/usr/mingw32/bin/sdl-config --libs` else ifeq (${G_BUILD},${B_CYGWIN}) G_LIBGL := -lopengl32 -lglu32 G_LIBSDL := `sdl-config --libs` else $(error 'G_BUILD = ${G_BUILD}' is invalid.) endif endif endif endif G_SRCSDIR := src ifeq (${G_BUILD},${B_DEBUG}) G_OBJSDIR := objsd G_BINDIR := bind G_DEPSDIR := depsd else ifeq (${G_BUILD},${B_FINAL}) G_OBJSDIR := objs G_BINDIR := bin G_DEPSDIR := deps else ifeq (${G_BUILD},${B_WIN32}) G_OBJSDIR := objs-mingw32 G_BINDIR := bin-mingw32 G_DEPSDIR := deps-mingw32 else ifeq (${G_BUILD},${B_CYGWIN}) G_OBJSDIR := objs-cygwin G_BINDIR := bin-cygwin G_DEPSDIR := deps-cygwin else $(error 'G_BUILD = ${G_BUILD}' is invalid.) endif endif endif endif LOGFILE := bld.log $(shell rm -f ${LOGFILE}) # remove the log file from last run ifeq (${G_BUILD},${B_WIN32}) PRNTFMT := printf "%-12s: %s\n" PRNTLOG := printf "\n\#\# %-12s: %s\n" else PRNTFMT := printf "%-8s: %s\n" PRNTLOG := printf "\n\#\# %-8s: %s\n" endif VERBOSE := 0 ifeq (${VERBOSE},0) # log the printf command Q1s := Q1e := >> ${LOGFILE} # quiet the printf command Q2s := Q2e := # log the command Q3s := echo # NOTE: the space between @echo and the # is VERY important!! Q3e := >> ${LOGFILE} # quiet the command, log the output Q4s := set -o pipefail && Q4e := 2>&1 | tee -a ${LOGFILE} else # EAT the logging printf command Q1s := true # NOTE: the space between @true and the # is VERY important!! Q1e := # EAT the quiet printf command Q2s := true # NOTE: the space between @true and the # is VERY important!! Q2e := # EAT the logging command Q3s := true # NOTE: the space between @true and the # is VERY important!! Q3e := # do not quiet the command Q4s := Q4e := endif ifeq (${G_BUILD},${B_WIN32}) prefix := /usr/mingw32 else prefix := /usr endif exec_prefix := ${prefix} includedir := ${prefix}/include libdir := ${exec_prefix}/lib INSTALL := install