-
Notifications
You must be signed in to change notification settings - Fork 39
/
makefile
141 lines (111 loc) · 3.87 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
TARGET := apkenv
# Default target, make sure this is always first
all: $(TARGET) modules platform_targets
PKG_CONFIG ?= $(CROSS_COMPILE)pkg-config
ifeq ($(shell which $(PKG_CONFIG) 2>/dev/null),)
$(error $(PKG_CONFIG) not found)
endif
ifeq ($(origin SDL_CFLAGS) $(origin SDL_LDLIBS), undefined undefined)
SDL_CONFIG = $(CROSS_COMPILE)sdl2-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
SDL_CONFIG = $(CROSS_COMPILE)sdl-config
ifeq ($(shell which $(SDL_CONFIG) 2>/dev/null),)
$(error No SDL development libraries found!)
else
$(warning Using SDL 1.2 libraries)
endif
endif
SDL_CFLAGS += $(shell $(SDL_CONFIG) --cflags)
SDL_LDLIBS += $(shell $(SDL_CONFIG) --libs)
endif
CFLAGS += $(SDL_CFLAGS)
LDFLAGS += $(SDL_LDLIBS)
# Compatibility fix for newer Debian/Ubuntu versions with
# 64-bit time_t on armhf. We could wrap all functions and
# translate all structs as part of the wrapping process,
# but this is a little simpler for now.
CFLAGS += -D_TIME_BITS=32
SHELL := bash
HOSTCC ?= cc
PLATFORM_TARGETS :=
# Build configuration
include config.mk
SOURCES := $(TARGET).c
SOURCES += $(wildcard linker/*.c)
SOURCES += $(wildcard compat/*.c)
SOURCES += $(wildcard apklib/*.c)
SOURCES += $(wildcard jni/*.c)
SOURCES += $(wildcard imagelib/*.c)
SOURCES += $(wildcard debug/*.c)
SOURCES += $(wildcard debug/wrappers/*.c)
SOURCES += $(wildcard accelerometer/*.c)
SOURCES += $(wildcard audio/*.c)
SOURCES += $(wildcard mixer/*.c)
GENERATED_FILES += compat/gen/gles_serialize.c
SOURCES += $(GENERATED_FILES)
# Platform-specific targets and configuration
PLATFORM_INSTALL_TARGETS :=
include platform/$(PLATFORM).mk
SOURCES += $(wildcard platform/common/*.c)
# Support modules for specific applications
MODULES_SOURCES := $(wildcard modules/*.c)
MODULES :=
ifeq ($(STATIC_MODULES),1)
CFLAGS += -DAPKENV_STATIC_MODULES
SOURCES += $(MODULES_SOURCES)
else
MODULES += $(patsubst modules/%.c,%.apkenv.so,$(MODULES_SOURCES))
endif
OBJS := $(patsubst %.c,%.o,$(SOURCES))
DEPS := $(patsubst %.c,%.d,$(SOURCES)) $(patsubst %.c,%.d,$(MODULES_SOURCES))
modules: $(MODULES)
platform_targets: $(PLATFORM_TARGETS)
$(TARGET): $(OBJS)
$(SILENTMSG) -e "\tLINK\t$@"
$(SILENTCMD)$(CC) $(OBJS) $(LDFLAGS) -o $@
compat/gen/gles_serialize.c: compat/wrapgen2.py compat/gles_vtable.h
$(SILENTMSG) -e "\tGEN\t$@"
$(SILENTCMD)mkdir -p $(dir $@)
$(SILENTCMD)python3 $+ $@
debug/wrappers/%_thumb.o: debug/wrappers/%_thumb.c
$(SILENTMSG) -e "\tCC (TH)\t$@"
ifeq ($(PLATFORM),osmesa)
$(SILENTCMD)$(CC) -O0 -c -o $@ $<
else
$(SILENTCMD)$(CC) -mthumb -march=armv7-a -O0 -c -o $@ $<
endif
debug/wrappers/%_arm.o: debug/wrappers/%_arm.c
$(SILENTMSG) -e "\tCC\t$@"
$(SILENTCMD)$(CC) -marm -O0 -c -o $@ $<
%.o: %.c %.d
$(SILENTMSG) -e "\tCC\t$@"
$(SILENTCMD)$(CC) $(CFLAGS) -c -o $@ $<
modules/%.d: modules/%.c
$(SILENTMSG) -e "\tDEP\t$@"
$(SILENTCMD)$(CC) $(CFLAGS) -MF [email protected] -MM $<
$(SILENTCMD)sed -e 's|.*:|$*.o:|' < [email protected] | sed -e 's|\.o|\.apkenv\.so|' > $@
$(SILENTCMD)rm -rf modules/$*.d.tmp
%.d: %.c
$(SILENTMSG) -e "\tDEP\t$@"
$(SILENTCMD)$(CC) $(CFLAGS) -MF [email protected] -MM $<
$(SILENTCMD)sed -e 's|.*:|$*.o:|' < [email protected] > $@
$(SILENTCMD)rm -rf $*.d.tmp
%.apkenv.so: modules/%.c
$(SILENTMSG) -e "\tMOD\t$@"
$(SILENTCMD)$(CC) -fPIC -shared $(CFLAGS) -o $@ $<
install: $(TARGET) $(MODULES) $(PLATFORM_INSTALL_TARGETS)
$(SILENTMSG) -e "\tINSTALL\t$(TARGET)"
$(SILENTCMD)mkdir -p $(DESTDIR)$(PREFIX)/bin
$(SILENTCMD)install -m755 $(TARGET) $(DESTDIR)$(PREFIX)/bin
$(SILENTMSG) -e "\tINSTALL\tMODULES"
$(SILENTCMD)mkdir -p $(DESTDIR)$(PREFIX)/lib/$(TARGET)/modules
$(SILENTCMD)install -m644 $(MODULES) $(DESTDIR)$(PREFIX)/lib/$(TARGET)/modules
clean:
$(SILENTMSG) -e "\tCLEAN"
$(SILENTCMD)rm -rf $(TARGET) $(OBJS) $(MODULES) $(DEPS) hostui $(GENERATED_FILES)
distclean: clean
ifneq ($(MAKECMDGOALS),clean)
-include $(DEPS)
endif
.DEFAULT: all
.PHONY: all modules install clean distclean platform_targets