From: Patrik Gornicz Date: Sun, 16 Nov 2008 03:08:47 +0000 (-0500) Subject: cleaning of the Makefile X-Git-Tag: v0.07 X-Git-Url: http://gitweb.pgornicz.com/?a=commitdiff_plain;h=24679442f374b34f2a411375f02005859dfcc6c3;p=physics.git cleaning of the Makefile --- diff --git a/src/Makefile b/src/Makefile index ec5ce8e..b9dc85d 100644 --- a/src/Makefile +++ b/src/Makefile @@ -7,14 +7,12 @@ OPTFLAGS := -O2 DBGFLAGS := -ggdb PRFFLAGS := ${DBGFLAGS} -pg MYFLAGS := -Wall -pedantic -ansi -CXXFLAGS := ${MYFLAGS} ${DBGFLAGS} VALFLAGS := --leak-check=full +CXXFLAGS := ${MYFLAGS} ${DBGFLAGS} CXX := g++ -SRCS := # := start - DIRS := # := start DIRS += ./ DIRS += Entities/ @@ -24,8 +22,11 @@ DIRS += config/ DIRS += input/ DIRS += graphics/ +SRCS := # := start include $(addsuffix /files.mk,${DIRS}) +WORKINGDIR := ../bin/ + OBJSDIR := ../objs/ OBJS := ${SRCS:.cpp=.o} OBJS := $(addprefix ${OBJSDIR},${OBJS}) @@ -34,22 +35,21 @@ DEPSDIR := ../deps/ DEPS := ${SRCS:.cpp=.d} DEPS := $(addprefix ${DEPSDIR},${DEPS}) -WORKINGDIR := ../bin/ +CFGDIRNAME := configs/ +SRCCFGDIR := ../${CFGDIRNAME} +DSTCFGDIR := ${WORKINGDIR}${CFGDIRNAME} + +CFGS := # := start +CFGS += keys.cfg +CFGS := $(addprefix ${DSTCFGDIR},${CFGS}) + TARGETNAME := run_physics TARGETTMP := ${OBJSDIR}${TARGETNAME} TARGET := ${WORKINGDIR}${TARGETNAME} -CONFIGDIRNAME := configs/ -CONFIGDIR := ../${CONFIGDIRNAME} -CONFIGDEST := ${WORKINGDIR}${CONFIGDIRNAME} - -CONFIGS := # := start -CONFIGS += keys.cfg -CONFIGS := $(addprefix ${CONFIGDEST},${CONFIGS}) - DEPSBLDDIRS := $(addprefix ${DEPSDIR},${DIRS}) OBJSBLDDIRS := $(addprefix ${OBJSDIR},${DIRS}) -BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${CONFIGDEST} +BLDDIRS := ${OBJSBLDDIRS} ${DEPSBLDDIRS} ${WORKINGDIR} ${DSTCFGDIR} VERBOSE := 0 @@ -67,36 +67,36 @@ else endif .PHONY: all -all: ${TARGET} ${CONFIGS} +all: ${TARGET} ${CFGS} -# rule to copy the config files into the working directory -${CONFIGDEST}%.cfg: ${CONFIGDIR}%.cfg | ${CONFIGDEST} ${WORKINGDIR} - ${Q1}echo "cp: $@" - ${Q2}cp $< $@ +# how to link the main target +${TARGETTMP}: ${OBJS} + ${Q1}echo "${CXX}: $@" + ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} # rule to copy tmp target to working directory ${TARGET}: ${TARGETTMP} | ${WORKINGDIR} ${Q1}echo "cp: $@" ${Q2}cp $< $@ -# how to link the main target -${TARGETTMP}: ${OBJS} - ${Q1}echo "${CXX}: $@" - ${Q2}${CXX} ${CXXFLAGS} -o $@ $^ ${LIBS} - # how to make a directory ${BLDDIRS}: ${Q2}mkdir -p $@ +# rule to make an object file from a .cpp +${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS} + ${Q1}echo "${CXX}: $@" + ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< + # rule to make a depend file from a .cpp ${DEPSDIR}%.d: %.cpp | ${DEPSBLDDIRS} ${Q1}echo "DEP: $@" ${Q2}${CXX} -MM ${CXXFLAGS} $< | sed 's,\(^.*\):,${OBJSDIR}\1 $@:,' > $@ -# rule to make an object file from a .cpp -${OBJSDIR}%.o: %.cpp | ${OBJSBLDDIRS} - ${Q1}echo "${CXX}: $@" - ${Q2}${CXX} ${CXXFLAGS} -c -o $@ $< +# rule to copy the config files into the working directory +${DSTCFGDIR}%.cfg: ${SRCCFGDIR}%.cfg | ${DSTCFGDIR} + ${Q1}echo "cp: $@" + ${Q2}cp $< $@ tags: ${SRCS}