Advertisement
Guest User

Untitled

a guest
Apr 13th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 0.64 KB | None | 0 0
  1. # 'all' is called by default when the user invokes the 'make' command without any arguements
  2. # It does not actually represent a file so its called a 'phony' target
  3. all: main.exe
  4.  
  5. # Variable name. Value can be accessed using $(EXEC_NAME)
  6. EXEC_NAME = main.exe
  7.  
  8. # Link everything together
  9. # '$^' represents the default variable '^' which contains all dependencies seperated by spaces
  10. main.exe: main.o func.o
  11.     gcc -o $(EXEC_NAME) $^
  12.     make clean
  13.  
  14. # Compile func.c into an object file
  15. func.o: func.c
  16.     gcc -c $< -o $@
  17.  
  18. # Compile main.c into an object file
  19. main.o: main.c
  20.     gcc -c $< -o $@
  21.  
  22. # Delete all object files
  23. clean:
  24.     rm func.o main.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement