Last active
August 29, 2015 14:16
-
-
Save good5dog5/cba057d2b1476424af7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Some pre-defined variables of make | |
# | |
# $? - updated dependencies | |
# $@ - target value | |
# $< - first dependencie | |
# $^ - all dependencies, seperated with space | |
# $* - target name without extension | |
# | |
CC = arm-linux-gnueabihf-gcc | |
AS = arm-linux-gnueabihf-as | |
CFLAGS = -O2 -ggdb -Wall | |
LDFLAGS = -fno-stack-protector | |
objects = example2.o multiply.o | |
# 1. The final target, and let make search for example2 | |
default: example2 | |
.PHONY: default clean clobber | |
# 2. Find example2, and it depends on example2.o and multiply.o. | |
# 6. All dependencies make, compile - assemble - link -> executable. | |
# - Until the link moment, extern function multiply(), multiplyadd(), multiplysub() 's address | |
# be bound. | |
example2: $(objects) | |
$(CC) -o $@ $^ | |
# 3. Find the dependency to make example2.o, but does't know the rule. | |
example2.o: example2.c | |
# 4. Find the rules to make all .o file, example2.o, so | |
# - example2.o compiled | |
%.o: %.c | |
$(CC) -c $(CFLAGS) $(LDFLAGS) -o $@ $< | |
# 5. Find the rule to make multiply.o | |
%.o: %.s | |
$(AS) -o $@ $< | |
clean: | |
rm -f $(objects) example2 | |
qemu: example2 | |
qemu-arm -L /usr/arm-linux-gnueabihf ./example2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment