Advertisement
obernardovieira

[Updated] Compile files in multiple folders

Jun 28th, 2014
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 0.49 KB | None | 0 0
  1. #MY NEW MAKEFILE
  2. #YOU CAN ADD MUCH MORE THINGS
  3. #THE "extra" IS ANOTHER FOLDER IN THE SAME PLACE HAS THIS MAKEFILE
  4. BUILD_FILE = hello
  5. CFLAGS=-c -Wall
  6. LDFLAGS=
  7.  
  8. MAIN_OBJ = *.o
  9. MAIN_CPP = *.cpp
  10. EXTRA_OBJ = extra/*.o
  11. EXTRA_CPP = extra/*.cpp
  12.  
  13. all: $(BUILD_FILE)
  14.  
  15. $(BUILD_FILE): $(MAIN_OBJ) $(EXTRA_OBJ)
  16.     g++ $(LDFLAGS) *.o -o $(BUILD_FILE)
  17.  
  18. $(MAIN_OBJ): $(MAIN_CPP)
  19.     g++ $(CFLAGS) $(MAIN_CPP)
  20.  
  21. $(EXTRA_OBJ): $(EXTRA_CPP)
  22.     g++ $(CFLAGS) $(EXTRA_CPP)
  23.  
  24. clean:
  25.     rm -rf *o $(BUILD_FILE)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement