Code: Select all
BINDIR =
OBJDIR =obj
HEADERS =$(wildcard *.hpp)
SOURCES =$(wildcard *.cpp)
OBJECTS =$(foreach SOURCE, $(SOURCES), $(patsubst %.cpp, %.o, $(SOURCE)))
TARGETS =number-theory
CXX =clang++
CXXFLAGS =-ggdb -std=c++0x -Wall
LD =clang++
LDFLAGS =-ggdb -lgmpxx
.PHONY : all
all : $(TARGETS)
.PHONY : clean
clean :
$ rm -f -r $(OBJECTS)
number-theory : $(OBJECTS)
$(LD) $(LDFLAGS) -o nt $(OBJECTS)
define cxx-rule
$(subst \,, $(OBJDIR)/$(strip $(shell $(CXX) -MM $(1))))
$(CXX) $(CXXFLAGS) -c -o $(OBJDIR)/$(strip $(patsubst %.cpp, %.o, $(1))) $(1)
endef
$(foreach SOURCE, $(filter %.cpp, $(SOURCES)), $(info $(call cxx-rule, $(SOURCE))))
If anyone wants help extending it to support C and asm files, I can help with that. I intend to do it anyway, whenever I get back in the mood to do some kernel programming.