Skip to content

Commit

Permalink
auto-select make based on current architecture
Browse files Browse the repository at this point in the history
The best way to make it auto-select an architecture (without duplicating
the compile code) is to have it call a recursive make. I don't know of a
way to have make 'jump' to a target based on a conditional without doing
it this way.
  • Loading branch information
Eriner committed Nov 8, 2015
1 parent 433babc commit c0edfb4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
14 changes: 13 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit c0edfb4

Please sign in to comment.