Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 'all' is called by default when the user invokes the 'make' command without any arguements
- # It does not actually represent a file so its called a 'phony' target
- all: main.exe
- # Variable name. Value can be accessed using $(EXEC_NAME)
- EXEC_NAME = main.exe
- # Link everything together
- # '$^' represents the default variable '^' which contains all dependencies seperated by spaces
- main.exe: main.o func.o
- gcc -o $(EXEC_NAME) $^
- make clean
- # Compile func.c into an object file
- func.o: func.c
- gcc -c $< -o $@
- # Compile main.c into an object file
- main.o: main.c
- gcc -c $< -o $@
- # Delete all object files
- clean:
- rm func.o main.o
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement