For a large project that can benefit from some refactoring one of my goals is to reduce coupling. I'm looking at coupling here as the ability to break up the code into very small/logical compile units much like how coupling is explained in This document 3.1.
So I'm writing a makefile to test the source files as I go alone.
The intent is that all object files compile to the .object/
directory. The idea is that when these large source files fail to be assembled I've found a place that needs attention.
The issue is that the makefile compiles every source every time and I can't find the rule that is causing it.
In using a makefile like this am I wrong in my approach? Is there a better way for doing this kind of refactoring - short of using an IDE with those tools built in?
CC = g++
CC_FLAGS = -std=c++0x -pthread
LI_FLAGS =
EXEC = UAVapp.o
OUT = .object/
#Types/
T = Arming.hpp JCommand.hpp
TYPES = $(T:%=Types/%)
#Extensions
HPP = Defines.hpp $(TYPES)
CPP =
#Groups
COBJ = $(CPP:.cpp=.o)
HOBJ = $(HPP:.hpp=.o)
all: PRE $(EXEC)
# Main target
$(EXEC): $(HOBJ)
touch $(EXEC)
#$(CC) $(LI_FLAGS) $(CC_FLAGS) $(OUT)$(COBJ) -o $(EXEC)
%.o:%.hpp
$(CC) -c $< $(CC_FLAGS) -o $(OUT)$(notdir $@)
%.o:%.cpp
$(CC) -c $< $(CC_FLAGS) -o $(OUT)$(notdir $@)
# Do work before compilation
PRE:
@mkdir -p $(OUT)
clean:
rm -rf ./*.o $(EXEC) ./$(OUT)*