Guest User

Untitled

a guest
Jun 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #Main makefile which does the build
  2.  
  3. #makedepend flags
  4. DFLAGS =
  5.  
  6. #Compiler flags
  7. #if mode variable is empty, setting debug build mode
  8. ifeq ($(mode),release)
  9. CFLAGS = -Wall
  10. else
  11. mode = debug
  12. CFLAGS = -g -Wall
  13. endif
  14.  
  15. CC = g++
  16. PROG = fooexe
  17.  
  18. #each module will append the source files to here
  19. SRC := main.cpp
  20.  
  21. #including the description
  22. include bar/module.mk
  23. include foo/module.mk
  24.  
  25. OBJ := $(patsubst %.cpp, %.o, $(filter %.cpp,$(SRC)))
  26.  
  27. .PHONY:all
  28. all: information fooexe
  29.  
  30. information:
  31. ifneq ($(mode),release)
  32. ifneq ($(mode),debug)
  33. @echo "Invalid build mode."
  34. @echo "Please use 'make mode=release' or 'make mode=debug'"
  35. @exit 1
  36. endif
  37. endif
  38. @echo "Building on "$(mode)" mode"
  39. @echo ".........................."
  40.  
  41. #linking the program
  42. fooexe: $(OBJ)
  43. $(CC) -o $(PROG) $(OBJ)
  44.  
  45. %.o:%.cpp
  46. $(CC) $(CFLAGS) -c $< -o $@
  47.  
  48. depend:
  49. makedepend -- $(DFLAGS) -- $(SRC)
  50.  
  51. .PHONY:clean
  52. clean:
  53. find . -name "*.o" | xargs rm -vf
  54. rm -vf fooexe
  55.  
  56. for debugger: -O0 -g -Wall
  57. for development and internal release: -O2 -g -Wall
  58. for release outside the company: -O2 -Wall
Add Comment
Please, Sign In to add comment