KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Lets say I have files: Libs: one.cpp, one.h two.cpp, two.h three.cpp, three.h Program: program.cpp Is there way, to create Makefile which will compile only that *.cpp which were modified from last compilation? Currently I have something like that: SRCS = one.cpp two.cpp three.cpp OBJS = $(SRCS:.cpp=.o) all: $(OBJS) program .cpp.o: g++ -Wall -c $< program: g++ -Wall $(OBJS) program.cpp -o program clean: rm -f $(OBJS) program I works fine, but when I compile my program and then change two.cpp or two.h I need to run "make clean" first, because when I secondly run "make" I get: Nothing to be done for 'all'. I would like to change my Makefile in that way, it would recognize my changes and recompile that file and its dependencies (if one.cpp uses code from two.cpp which was modified, both files should be recompiled). So if I modify two.cpp, make should do: g++ -Wall -c two.cpp g++ -Wall $(OBJS) program.cpp -o program But if one.cpp uses code from two.cpp which was modified, make shold do: g++ -Wall -c one.cpp g++ -Wall -c two.cpp g++ -Wall $(OBJS) program.cpp -o program
Tags (comma-separated)
Save Edits
Cancel