-LIBGL := -lGL -lGLU
-LIBSDL := `sdl-config --libs`
-LIBS := ${LIBSDL} ${LIBGL}
+# The first and therefor default rule
+.PHONY: default
+default:
-OPTFLAGS := -O2
-DBGFLAGS := -ggdb
-PRFFLAGS := ${DBGFLAGS} -pg
-MYFLAGS := -Wall -pedantic -ansi
+# Suppress all builtin variables and rules
+MAKEFLAGS += -rR
-VALFLAGS := --leak-check=full
-CXXFLAGS := ${MYFLAGS} ${DBGFLAGS}
+# Suppress all command printing
+MAKEFLAGS += -s
-CXX := g++
+G_DIRMK := dir.mk
+G_VARSMK := vars.mk
+G_FILESMK := files.mk
+G_RULESMK := rules.mk
+G_LISTSMK := lists.mk
+G_TVARSMK := tvars.mk
-DIRS := # := start
+include Makefile.d/${G_VARSMK}
-SRCSDIR := src/
-SRCS := # := start
+include ${G_LISTSMK}
+include ${G_VARSMK}
-OBJSDIR := objsd/
-OBJS := # := start
+include packages.mk
-DEPSDIR := deps/
-DEPS := # := start
+include lib/${G_VARSMK}
-# include all of the dir.mk
-DIRMK := dir.mk
-include ${SRCSDIR}${DIRMK}
-
-WORKINGDIR := bind/
-
-TARGETNAME := libpg.so
-TARGETTMP := ${OBJSDIR}${TARGETNAME}
-TARGET := ${WORKINGDIR}${TARGETNAME}
-
-DEPSBLDDIRS := ${DEPSDIR} $(addprefix ${DEPSDIR},${DIRS})
-OBJSBLDDIRS := ${OBJSDIR} $(addprefix ${OBJSDIR},${DIRS})
-BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR}
-
-INCDIRS := ${SRCSDIR} inc/
-INCFLAGS := $(addprefix -I, ${INCDIRS})
-
-
-PRNTFMT := printf "%-5s: %s\n"
-
-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
-
-.PHONY: all
-all: ${TARGET}
-
-install:
-
+include targets.mk
-# cause the fancy $$ directory rules to work out
-.SECONDEXPANSION:
-
-# how to link the main target
-${TARGETTMP}: ${OBJS}
- ${Q1}${PRNTFMT} "${CXX}" "$@"
- ${Q2}${CXX} -shared ${CXXFLAGS} -o $@ $^ ${LIBS}
-
-# rule to copy tmp target to working directory
-${TARGET}: ${TARGETTMP} | ${WORKINGDIR}
- ${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 | $$(dir $$@)
- ${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 | $$(dir $$@)
- ${Q1}${PRNTFMT} "DEP" "$@"
- ${Q2}${CXX} -MM ${CXXFLAGS} $< ${INCFLAGS} | \
- sed 's/\(^.*\):/$(subst /,\/,${OBJSDIR}\1 $@):/' > $@
-
-.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
-
-.PHONY: cleanall
-cleanall: clean cleanbin cleandeps
+# include all of the dir.mk
+include lib/${G_DIRMK}
-.PHONY: gitclean
-gitclean:
- ${Q1}${PRNTFMT} "git clean" "showing; use gitcleanf to force removal"
- ${Q2}git clean -nxd
+include tests/${G_DIRMK}
+include physics/${G_DIRMK}
-.PHONY: gitcleanf
-gitcleanf:
- ${Q1}${PRNTFMT} "git clean" "forcing"
- ${Q2}git clean -fxd
- cd ${WORKINGDIR}; gprof -b ${TARGETNAME} > prof
- cd ${WORKINGDIR}; kprof -f prof
+include ${G_RULESMK}
+# Do not warn or error if not found, dependencies will get created with the object files
+-include ${L_DEPS}
--include ${DEPS}