forked from thp/apkenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
93 lines (70 loc) · 1.98 KB
/
makefile
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Android Gingerbread linker
LINKER_SOURCES=$(wildcard linker/*.c)
# Compatibility wrappers and hooks
COMPAT_SOURCES=$(wildcard compat/*.c)
# Library for getting files out of .apk files
APKLIB_SOURCES=$(wildcard apklib/*.c)
# Our own JNI environment implementation
JNIENV_SOURCES=$(wildcard jni/*.c)
# Support modules for specific applications
MODULES_SOURCES=$(wildcard modules/*.c)
TARGET = apkenv
DESTDIR ?= /
PREFIX ?= /opt/$(TARGET)/
BIONIC_LIBS = $(wildcard libs/*.so)
SOURCES += $(TARGET).c
SOURCES += $(LINKER_SOURCES)
SOURCES += $(COMPAT_SOURCES)
SOURCES += $(APKLIB_SOURCES)
SOURCES += $(JNIENV_SOURCES)
OBJS = $(patsubst %.c,%.o,$(SOURCES))
MODULES = $(patsubst modules/%.c,%.apkenv.so,$(MODULES_SOURCES))
LDFLAGS = -fPIC -ldl -lz -lSDL -lSDL_mixer -pthread
# Selection of OpenGL ES version support (if any) to include
GLES ?= 1
ifeq ($(GLES),2)
CFLAGS += -DAPKENV_GLES2
LDFLAGS += -lGLESv2
else
CFLAGS += -DAPKENV_GLES
LDFLAGS += -lGLES_CM
endif
FREMANTLE ?= 0
ifeq ($(FREMANTLE),1)
CFLAGS += -DFREMANTLE
LDFLAGS += -lSDL_gles
endif
DEBUG ?= 0
ifeq ($(DEBUG),1)
CFLAGS += -g -Wall -DLINKER_DEBUG=1 -DAPKENV_DEBUG -Wformat=0
else
CFLAGS += -O2 -DLINKER_DEBUG=0
endif
all: $(TARGET) $(MODULES)
%.o: %.c
@echo -e "\tCC\t$@"
@$(CC) $(CFLAGS) -c -o $@ $<
$(TARGET): $(OBJS)
@echo -e "\tLINK\t$@"
@$(CC) $(LDFLAGS) $(OBJS) -o $@
%.apkenv.so: modules/%.c
@echo -e "\tMOD\t$@"
@$(CC) -fPIC -shared $(CFLAGS) -o $@ $<
strip:
@echo -e "\tSTRIP"
@strip $(TARGET) $(MODULES)
install: $(TARGET) $(MODULES)
@echo -e "\tMKDIR"
@mkdir -p $(DESTDIR)$(PREFIX)/{modules,bionic}
@mkdir -p $(DESTDIR)/usr/bin
@echo -e "\tINSTALL\t$(TARGET)"
@install -m755 $(TARGET) $(DESTDIR)/usr/bin
@echo -e "\tINSTALL\tMODULES"
@install -m644 $(MODULES) $(DESTDIR)$(PREFIX)/modules
@echo -e "\tINSTALL\tBIONIC"
@install -m644 $(BIONIC_LIBS) $(DESTDIR)$(PREFIX)/bionic
clean:
@echo -e "\tCLEAN"
@rm -rf $(TARGET) $(OBJS) $(MODULES)
.DEFAULT: all
.PHONY: strip install clean