# set this on the command line to get a WIN32 or a FINAL build
BUILD := DEBUG
-
-SRCSDIR := src/
-DEPSDIR := deps/
-INCDIRS := ${SRCSDIR} inc/
-
-ifeq (${BUILD},WIN32)
- OBJSDIR := objs-mingw32/
-else
-ifeq (${BUILD},FINAL)
- OBJSDIR := objs/
-else
- OBJSDIR := objsd/
-endif
-endif
-
-ifeq (${BUILD},WIN32)
- WORKINGDIR := bin-mingw32/
-else
-ifeq (${BUILD},FINAL)
- WORKINGDIR := bin/
-else
- WORKINGDIR := bind/
-endif
-endif
-
-
-ifeq (${BUILD},WIN32)
- LIBGL := -lopengl32 -lglu32
- LIBSDL := `/usr/mingw32/bin/sdl-config --libs`
-else
- LIBGL := -lGL -lGLU
- LIBSDL := `sdl-config --libs`
-endif
-LIBS := ${LIBSDL} ${LIBGL}
-
-
-ifeq (${BUILD},WIN32)
- LINKERNAME := bear.dll
- SONAME := bear.dll
- REALNAME := bear.dll
-else
- LINKERNAME := libbear.so
- SONAME := libbear.so.0
- REALNAME := libbear.so.0.0
-endif
-
-TARGETTMP := ${OBJSDIR}${REALNAME}
-TARGET := ${WORKINGDIR}${REALNAME}
-
-
-OPTFLAGS := -O2
-DBGFLAGS := -ggdb
-PRFFLAGS := ${DBGFLAGS} -pg
-LIBFLAGS := -fPIC
-MYFLAGS := -Wall -Wextra -pedantic -ansi
-INCFLAGS := $(addprefix -I, ${INCDIRS})
-LNKFLAGS := -shared -Wl,-soname,${SONAME}
-
-CXXFLAGS := ${MYFLAGS} ${LIBFLAGS}
-ifeq (${BUILD},WIN32)
- CXXFLAGS += ${OPTFLAGS}
-else
-ifeq (${BUILD},FINAL)
- CXXFLAGS += ${OPTFLAGS}
-else
- CXXFLAGS += ${DBGFLAGS}
-endif
-endif
-
-ifeq (${BUILD},WIN32)
- CXX := mingw32-g++
-else
- CXX := g++
-endif
-
-
-
-ifeq (${BUILD},WIN32)
- prefix := /usr/mingw32
-else
- prefix := /usr
-endif
-exec_prefix := ${prefix}
-includedir := ${prefix}/include
-libdir := ${exec_prefix}/lib
-
-ifeq (${BUILD},WIN32)
- PRNTFMT := printf "%-12s: %s\n"
-else
- PRNTFMT := printf "%-8s: %s\n"
-endif
-
-VERBOSE := 0
-
-ifeq (${VERBOSE},0)
- # quiet the printf command
- Q1 := @
- # quiet the command that is `replaced' by an echo
- Q2 := @
-else
- # EAT the printf command as if it was not there
- Q1 := @true # NOTE: the space between @true and the # is VERY important!!
- # do not quiet the command output
- Q2 :=
-endif
-
-
# cause the fancy $${@D} directory rules to work out
.SECONDEXPANSION:
# The first and therefor default rule
+# targets append themselves to this to be built by all
.PHONY: all
-all: ${TARGET}
+all:
+#all: ${TARGET}
+
+DIRMK := dir.mk
+VARSMK := vars.mk
+FILESMK := files.mk
+RULESMK := rules.mk
+include ${VARSMK}
# lists populated by dir.mk files in subdirectories
SRCS := # := start
OBJS := # := start
DEPS := # := start
-DIRMK := dir.mk
+BLDDIRS := # := start
# include all of the dir.mk files in src
-include ${SRCSDIR}${DIRMK}
-
-
-DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
-OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
-
-BLDDIRS := # := start
-BLDDIRS += ${OBJSBLDDIRS}
-BLDDIRS += ${DEPSBLDDIRS}
-BLDDIRS += ${WORKINGDIR}
-
-
-INSTALL := install
-
-# HACK install
-install:
- ${INSTALL} -d ${includedir}/bear
- ${INSTALL} -t ${includedir}/bear inc/*
- ln -sfn ${REALNAME} ${libdir}/${LINKERNAME}
- ln -sfn ${REALNAME} ${libdir}/${SONAME}
- ${INSTALL} -t ${libdir} ${WORKINGDIR}${REALNAME}
-
-# HACK uninstall
-uninstall:
- rm -rf /usr/include/bear
- rm /usr/lib/${REALNAME}
- rm /usr/lib/${LINKERNAME}
- rm /usr/lib/${SONAME}
-
-# how to link the main target
-${TARGETTMP}: ${OBJS} | $${@D}
- ${Q1}${PRNTFMT} "${CXX}" "$@"
- ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
-
-# rule to copy tmp target to working directory
-${TARGET}: ${TARGETTMP} | $${@D}
- ${Q1}${PRNTFMT} "cp" "$@"
- ${Q2}cp $< $@
-
-# how to make a directory
-${BLDDIRS}:
- ${Q1}${PRNTFMT} "mkdir" "$@"
- ${Q2}mkdir -p $@
-
-# rule to make an object file from a .cpp
-${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $${@D}
- ${Q1}${PRNTFMT} "${CXX}" "$@"
- ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
-
-# rule to make a depend file from a .cpp
-# be clever and escape the / chars in file paths
-# DON'T simply use another sed delimiter or it can't appear in the file paths
-${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $${@D}
- ${Q1}${PRNTFMT} "DEP" "$@"
- ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
- sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
-
-CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
-
-.PHONY: cleanbin
-cleanbin:
- ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
- ${Q2}rm -rf ${WORKINGDIR}
-
-.PHONY: cleanobjs
-cleanobjs:
- ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
- ${Q2}rm -rf ${OBJSDIR}
-
-.PHONY: cleandeps
-cleandeps:
- ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
- ${Q2}rm -rf ${DEPSDIR}
-
-.PHONY: clean
-clean: cleanobjs
- ${Q1}${PRNTFMT} "rm" "${TARGET}"
- ${Q2}rm -f ${TARGET}
-
-.PHONY: cleanall
-cleanall: cleanbin cleanobjs cleandeps
-
-# Do not include deps files when doing a _single_ clean operation
-ifeq ($(findstring ${MAKECMDGOALS},${CLEANCMDS}),)
- -include ${DEPS}
-endif
+include src/${DIRMK}
-NEWSRCS := # := start; empty
-NEWSRCS += Vector2.cpp
-NEWSRCS += mathw.cpp
-NEWSRCS += debug.cpp
-NEWSRCS += Timer.cpp
-NEWSRCS += Ticks.cpp
-
-NEWDIRS := # := start; empty
-NEWDIRS += locks/
-
-# Post dir setup
-
CURDIR :=
-NEWSRCS := $(addprefix ${CURDIR},${NEWSRCS})
-NEWDIRS := $(addprefix ${CURDIR},${NEWDIRS})
-NEWOBJS := ${NEWSRCS:.cpp=.o}
-NEWDEPS := ${NEWSRCS:.cpp=.d}
+include src/${VARSMK}
+include src/${FILESMK}
+include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
-# Append to lists
-SRCS += ${NEWSRCS}
-DIRS += ${CURDIR}
-OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
-DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
+BLDDIRS += ${OBJSDIR}
+BLDDIRS += ${DEPSDIR}
+BLDDIRS += ${WORKINGDIR}
-include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
+include src/${RULESMK}
+
+# Do not include deps files when doing a clean operation
+ifeq ($(filter ${CLEANCMDS},${MAKECMDGOALS}),)
+ -include ${DEPS}
+endif
--- /dev/null
+
+NEWSRCS := # := start; empty
+NEWSRCS += Vector2.cpp
+NEWSRCS += mathw.cpp
+NEWSRCS += debug.cpp
+NEWSRCS += Timer.cpp
+NEWSRCS += Ticks.cpp
+
+NEWDIRS := # := start; empty
+NEWDIRS += locks/
+
+################################################################################
+
+NEWSRCS := $(addprefix ${CURDIR},${NEWSRCS})
+NEWDIRS := $(addprefix ${CURDIR},${NEWDIRS})
+NEWOBJS := ${NEWSRCS:.cpp=.o}
+NEWDEPS := ${NEWSRCS:.cpp=.d}
+
+# Append to lists
+
+SRCS += ${NEWSRCS}
+DIRS += ${CURDIR}
+OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
+DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
+
+BLDDIRS += $(addprefix ${OBJSDIR},${NEWDIRS})
+BLDDIRS += $(addprefix ${DEPSDIR},${NEWDIRS})
+
-NEWSRCS := # := start; empty
-NEWSRCS += Autolock.cpp
-NEWSRCS += Lock.cpp
-
-NEWDIRS := # := start; empty
-
-# Post dir setup
-
CURDIR := locks/
-NEWSRCS := $(addprefix ${CURDIR},${NEWSRCS})
-NEWDIRS := $(addprefix ${CURDIR},${NEWDIRS})
-NEWOBJS := ${NEWSRCS:.cpp=.o}
-NEWDEPS := ${NEWSRCS:.cpp=.d}
-
-# Append to lists
-
-SRCS += ${NEWSRCS}
-DIRS += ${CURDIR}
-OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
-DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
-
-
+include src/locks/${FILESMK}
include $(addprefix ${SRCSDIR},$(addsuffix ${DIRMK},${NEWDIRS}))
--- /dev/null
+
+NEWSRCS := # := start; empty
+NEWSRCS += Autolock.cpp
+NEWSRCS += Lock.cpp
+
+NEWDIRS := # := start; empty
+
+################################################################################
+
+NEWSRCS := $(addprefix ${CURDIR},${NEWSRCS})
+NEWDIRS := $(addprefix ${CURDIR},${NEWDIRS})
+NEWOBJS := ${NEWSRCS:.cpp=.o}
+NEWDEPS := ${NEWSRCS:.cpp=.d}
+
+# Append to lists
+
+SRCS += ${NEWSRCS}
+DIRS += ${CURDIR}
+OBJS += $(addprefix ${OBJSDIR},${NEWOBJS})
+DEPS += $(addprefix ${DEPSDIR},${NEWDEPS})
+
+BLDDIRS += $(addprefix ${OBJSDIR},${NEWDIRS})
+BLDDIRS += $(addprefix ${DEPSDIR},${NEWDIRS})
+
--- /dev/null
+
+# HACK install
+install:
+ ${INSTALL} -d ${includedir}/bear
+ ${INSTALL} -t ${includedir}/bear inc/*
+ ln -sfn ${REALNAME} ${libdir}/${LINKERNAME}
+ ln -sfn ${REALNAME} ${libdir}/${SONAME}
+ ${INSTALL} -t ${libdir} ${WORKINGDIR}${REALNAME}
+
+# HACK uninstall
+uninstall:
+ rm -rf /usr/include/bear
+ rm /usr/lib/${REALNAME}
+ rm /usr/lib/${LINKERNAME}
+ rm /usr/lib/${SONAME}
+
+# how to link the main target
+${TARGETTMP}: ${OBJS} | $${@D}
+ ${Q1}${PRNTFMT} "${CXX}" "$@"
+ ${Q2}${CXX} ${CXXFLAGS} ${LNKFLAGS} -o $@ $^ ${LIBS}
+
+# TARGET will be built by default
+all: ${TARGET}
+
+# rule to copy tmp target to working directory
+${TARGET}: ${TARGETTMP} | $${@D}
+ ${Q1}${PRNTFMT} "cp" "$@"
+ ${Q2}cp $< $@
+
+# how to make a directory
+${BLDDIRS}:
+ ${Q1}${PRNTFMT} "mkdir" "$@"
+ ${Q2}mkdir -p $@
+
+# rule to make an object file from a .cpp
+${OBJSDIR}%.o: ${SRCSDIR}%.cpp | $${@D}
+ ${Q1}${PRNTFMT} "${CXX}" "$@"
+ ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< ${INCFLAGS}
+
+# rule to make a depend file from a .cpp
+# be clever and escape the / chars in file paths
+# DON'T simply use another sed delimiter or it can't appear in the file paths
+${DEPSDIR}%.d: ${SRCSDIR}%.cpp | $${@D}
+ ${Q1}${PRNTFMT} "DEP" "$@"
+ ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
+ sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
+
+CLEANCMDS := cleanbin cleanobjs cleandeps clean cleanall
+
+.PHONY: cleanbin
+cleanbin:
+ ${Q1}${PRNTFMT} "rm" "${WORKINGDIR}"
+ ${Q2}rm -rf ${WORKINGDIR}
+
+.PHONY: cleanobjs
+cleanobjs:
+ ${Q1}${PRNTFMT} "rm" "${OBJSDIR}"
+ ${Q2}rm -rf ${OBJSDIR}
+
+.PHONY: cleandeps
+cleandeps:
+ ${Q1}${PRNTFMT} "rm" "${DEPSDIR}"
+ ${Q2}rm -rf ${DEPSDIR}
+
+.PHONY: clean
+clean: cleanobjs
+ ${Q1}${PRNTFMT} "rm" "${TARGET}"
+ ${Q2}rm -f ${TARGET}
+
+.PHONY: cleanall
+cleanall: cleanbin cleanobjs cleandeps
--- /dev/null
+
+SRCSDIR := src/
+DEPSDIR := deps/
+INCDIRS := ${SRCSDIR} inc/
+
+ifeq (${BUILD},WIN32)
+ OBJSDIR := objs-mingw32/
+else
+ifeq (${BUILD},FINAL)
+ OBJSDIR := objs/
+else
+ OBJSDIR := objsd/
+endif
+endif
+
+ifeq (${BUILD},WIN32)
+ WORKINGDIR := bin-mingw32/
+else
+ifeq (${BUILD},FINAL)
+ WORKINGDIR := bin/
+else
+ WORKINGDIR := bind/
+endif
+endif
+
+
+ifeq (${BUILD},WIN32)
+ LIBGL := -lopengl32 -lglu32
+ LIBSDL := `/usr/mingw32/bin/sdl-config --libs`
+else
+ LIBGL := -lGL -lGLU
+ LIBSDL := `sdl-config --libs`
+endif
+LIBS := ${LIBSDL} ${LIBGL}
+
+
+ifeq (${BUILD},WIN32)
+ LINKERNAME := bear.dll
+ SONAME := bear.dll
+ REALNAME := bear.dll
+else
+ LINKERNAME := libbear.so
+ SONAME := libbear.so.0
+ REALNAME := libbear.so.0.0
+endif
+
+TARGETTMP := ${OBJSDIR}${REALNAME}
+TARGET := ${WORKINGDIR}${REALNAME}
+
+
+ifeq (${BUILD},WIN32)
+ prefix := /usr/mingw32
+else
+ prefix := /usr
+endif
+exec_prefix := ${prefix}
+includedir := ${prefix}/include
+libdir := ${exec_prefix}/lib
+INSTALL := install
+
+
+LIBFLAGS := -fPIC
+INCFLAGS := $(addprefix -I, ${INCDIRS})
+LNKFLAGS := -shared -Wl,-soname,${SONAME}
+
+CXXFLAGS += ${LIBFLAGS}
+ifeq (${BUILD},WIN32)
+ CXXFLAGS += ${OPTFLAGS}
+else
+ifeq (${BUILD},FINAL)
+ CXXFLAGS += ${OPTFLAGS}
+else
+ CXXFLAGS += ${DBGFLAGS}
+endif
+endif
+
--- /dev/null
+
+OPTFLAGS := -O2
+DBGFLAGS := -ggdb
+PRFFLAGS := ${DBGFLAGS} -pg
+WARFLAGS := -Wall -Wextra -pedantic -ansi
+
+CXXFLAGS := ${WARFLAGS}
+
+ifeq (${BUILD},WIN32)
+ CXX := mingw32-g++
+else
+ CXX := g++
+endif
+
+ifeq (${BUILD},WIN32)
+ PRNTFMT := printf "%-12s: %s\n"
+else
+ PRNTFMT := printf "%-8s: %s\n"
+endif
+
+VERBOSE := 0
+
+ifeq (${VERBOSE},0)
+ # quiet the printf command
+ Q1 := @
+ # quiet the command that is `replaced' by an echo
+ Q2 := @
+else
+ # EAT the printf command as if it was not there
+ Q1 := @true # NOTE: the space between @true and the # is VERY important!!
+ # do not quiet the command output
+ Q2 :=
+endif
+