Advertisement
HimikoWerckmeister

Untitled

Feb 16th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ## This is a simple Makefile with lost of comments
  2. ## Check Unix Programming Tools handout for more info.
  3.  
  4. # Define what compiler to use and the flags.
  5. CC=cc
  6. CXX=CC
  7. CCFLAGS= -g -std=c99 -Wall -Werror
  8.  
  9. # A rule in Makefile has the form:
  10. #
  11. # target: dependencies
  12. # command
  13. #
  14. # where "target" and "dependencies" are files (most of the time).
  15. # These means that if "target" does not exist or the modification
  16. # date of the dependencies are older than the modification time of
  17. # "target" then "command" is executed.
  18. #
  19. # For example, the rule
  20. #
  21. # mystring.o : mystring.c
  22. # $(CC) -c $(CCFLAGS) mystring.c
  23. #
  24. # means that if mystring.o does not exist, or if mystring.c is older
  25. # than mystring.o, then execute "$(CC) -c $(CCFLAGS) mystring.c".
  26. #
  27. # The goal of make is to execute the minimum set of commands that
  28. # are necessary to build the target files. i.e., it does not rebuild
  29. # files that it expects need not be rebuilt because they have not changed.
  30. #
  31. # Usually, the first target in a Makefile is called "all".
  32. # The dependencies of "all" are the files (or make targets) that we want to build.
  33. #
  34.  
  35. all: test_mystring test
  36.  
  37. # Compile all .c files into .o files
  38. # % matches all (like * in a command)
  39. # $< is the source file (.c file)
  40. %.o : %.c
  41. $(CC) -c $(CCFLAGS) $<
  42.  
  43.  
  44.  
  45. # Build test_mystring if necessary
  46. shell: shell.o
  47. $(CC) -o shell shell.o
  48.  
  49. shell: shell
  50. ./shell
  51.  
  52.  
  53. clean:
  54. rm -f core *.o shell
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement