diff --git a/Makefile b/Makefile index a694698..b7fd4ce 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,20 @@ CC = clang CFLAGS = -std=gnu99 -ggdb +UNAME_M := $(shell uname -m) + +.PHONY: x86 x86_64 arm all: - $(error Please choose an architecture to build for: "make arm", "make x86", "make x86_64") +ifeq ($(UNAME_M),x86_64) + $(MAKE) x86_64 +endif +ifeq ($(UNAME_M),x86) + $(MAKE) x64 +endif +ifneq (,$(findstring arm,$(UNAME_M))) + $(MAKE) arm +endif + arm: sample-target sample-library.so $(CC) -marm $(CFLAGS) -DARM -o inject utils.c ptrace.c inject-arm.c -ldl diff --git a/README.md b/README.md index 68c3ab0..2bfa3da 100644 --- a/README.md +++ b/README.md @@ -21,17 +21,19 @@ ## Compiling -* arm: +* Simply running `make` should automatically select and build for the correct architecture, but if this fails (or you would like to select the target manually), run one of the following make commands: - make arm + * arm: -* x86: + make arm - make x86 + * x86: -* x86_64: + make x86 - make x86_64 + * x86_64: + + make x86_64 ## Usage