-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (40 loc) · 1.21 KB
/
Copy pathMakefile
File metadata and controls
54 lines (40 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
ARCH ?= $(shell uname -m)
TARGET ?= macosx
CFLAGS := -arch $(ARCH) -Iinclude -flto=full -fvisibility=hidden -Os -Wall -Wshadow
LDFLAGS := -arch $(ARCH) -flto=full -lobjc
SRC := $(shell find src -name "*.c")
OBJ := $(patsubst %.c,%.o,$(wildcard $(SRC)))
LIB_STATIC := libtinyhook.a
LIB_SHARED := libtinyhook.dylib
ifdef MIN_OSVER
ifeq ($(TARGET), macosx)
export MACOSX_DEPLOYMENT_TARGET=$(MIN_OSVER)
endif
ifeq ($(TARGET), iphoneos)
export IPHONEOS_DEPLOYMENT_TARGET=$(MIN_OSVER)
endif
endif
ifeq ($(TARGET), iphoneos)
CFLAGS += -isysroot $(shell xcrun --sdk $(TARGET) --show-sdk-path)
LDFLAGS += -isysroot $(shell xcrun --sdk $(TARGET) --show-sdk-path)
endif
CFLAGS += $(if $(DEBUG),-g)
CFLAGS += $(if $(COMPACT),-DCOMPACT)
CFLAGS += $(if $(NO_EXPORT),-DNO_EXPORT)
static: $(LIB_STATIC)
shared: $(LIB_SHARED)
all: static shared
$(LIB_STATIC): $(OBJ)
ar -rcs $@ $^
ranlib $@
$(LIB_SHARED): $(OBJ)
$(CC) $(LDFLAGS) -shared -o $@ $^
install: $(LIB_STATIC)
cp $(LIB_STATIC) /usr/local/lib
cp include/tinyhook.h /usr/local/include
test: $(LIB_STATIC)
cd test && $(MAKE) run ARCH=$(ARCH)
clean:
cd test && $(MAKE) clean
rm -f $(LIB_STATIC) $(LIB_SHARED) $(OBJ)
.PHONY: all static shared install test clean