-
Notifications
You must be signed in to change notification settings - Fork 28
/
Makefile.miyoo
94 lines (76 loc) · 3.66 KB
/
Makefile.miyoo
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
PLATFORM := miyoo
PLATFORM_SUPPORT := bittboy
GAMEPAD := generic
BUILDTIME := "$(shell date +%F\ %H:%M)"
COMMIT_HASH := $(shell git rev-parse --short HEAD)
GMENU2X_HASH := -D__BUILDTIME__=$(BUILDTIME) -D__COMMIT_HASH__=$(COMMIT_HASH)
CHAINPREFIX := /opt/miyoo
CROSS_COMPILE := $(CHAINPREFIX)/usr/bin/arm-linux-
CC := $(CROSS_COMPILE)gcc
CXX := $(CROSS_COMPILE)g++
STRIP := $(CROSS_COMPILE)strip
SYSROOT := $(shell $(CC) --print-sysroot)
SDL_CFLAGS := $(shell $(SYSROOT)/usr/bin/sdl-config --cflags)
PKG_LIBS := $(shell $(SYSROOT)/../../usr/bin/pkg-config --libs sdl SDL_image SDL_ttf)
CFLAGS = -DPLATFORM=\"$(PLATFORM)\" -DLOG_LEVEL=3 $(GMENU2X_HASH)
CFLAGS += -Isrc
# Zero optimization flag due to unexpected behavior on 2022 clibs
CFLAGS += -O0 -ggdb -g3 $(SDL_CFLAGS)
CFLAGS += -DTARGET_MIYOO -DHW_LIDVOL -DIPK_SUPPORT
LDFLAGS = $(PKG_LIBS)
OBJDIR = /tmp/gmenu2x/$(PLATFORM)
DISTDIR = dist/$(PLATFORM)
TARGET = $(DISTDIR)/gmenu2x
HOMEPATH = /mnt
DEFSKIN = Default
SOURCES := $(wildcard src/*.cpp)
OBJS := $(patsubst src/%.cpp, $(OBJDIR)/%.o, $(SOURCES))
# File types rules
$(OBJDIR)/%.o: src/%.cpp src/%.h src/platform/$(PLATFORM).h
$(CXX) $(CFLAGS) -o $@ -c $<
-include $(patsubst src/%.cpp, $(OBJDIR)/%.d, $(SOURCES))
all: dir shared
dir:
@mkdir -p $(OBJDIR) $(DISTDIR)
debug: $(OBJS)
@echo "Linking gmenu2x-debug..."
$(CXX) -o $(TARGET)-debug $(OBJS) $(LDFLAGS)
shared: debug
$(STRIP) $(TARGET)-debug -o $(TARGET)
clean:
rm -rf $(OBJDIR) *.gcda *.gcno $(TARGET) $(TARGET)-debug $(DISTDIR) dist/gmenu2x-$(PLATFORM).zip dist/gmenu2x-$(PLATFORM).ipk
dist: dir shared
mkdir -p $(DISTDIR)/skins
install -m644 -D *about*.txt $(DISTDIR)/
install -m644 -D COPYING $(DISTDIR)/LICENSE
install -m644 -D CONTRIBUTORS.md $(DISTDIR)/CONTRIBUTORS
cp -RH assets/translations $(DISTDIR)
cp -RH assets/skins/* $(DISTDIR)/skins/
-find $(DISTDIR)/skins -type d -name "template" -exec rm -rf {} \;
ifneq ($(DEFSKIN), Default)
cp -RH assets/skins/Default $(DISTDIR)/skins/Legacy
cp -RH assets/skins/$(DEFSKIN)/* $(DISTDIR)/skins/Default
rm -rf $(DISTDIR)/skins/$(DEFSKIN)
sed -i '/wallpaper/d' $(DISTDIR)/skins/Default/skin.conf
endif
cp -RH assets/$(PLATFORM)/input.conf $(DISTDIR)
cp -RH assets/$(PLATFORM)/input.conf $(DISTDIR)/input_$(PLATFORM).conf
cp -RH assets/$(PLATFORM_SUPPORT)/input.conf $(DISTDIR)/input_$(PLATFORM_SUPPORT).conf
cat assets/gamepad/input_$(GAMEPAD).conf >> $(DISTDIR)/input.conf
cat assets/gamepad/input_$(GAMEPAD).conf >> $(DISTDIR)/input_$(PLATFORM).conf
cat assets/gamepad/input_$(GAMEPAD).conf >> $(DISTDIR)/input_$(PLATFORM_SUPPORT).conf
ipk: dist
mkdir -p .$(HOMEPATH)/gmenu2x && mv $(DISTDIR)/* .$(HOMEPATH)/gmenu2x && mv .$(HOMEPATH) $(DISTDIR)
rm -rf /tmp/.gmenu-ipk/; mkdir -p /tmp/.gmenu-ipk/
sed "s/^Version:.*/Version: $$(date +%Y%m%d)/" assets/control > /tmp/.gmenu-ipk/control
cp assets/conffiles /tmp/.gmenu-ipk/
echo "#!/bin/sh\nsync; echo 'Installing gmenu2x..'; rm /var/lib/opkg/info/gmenu2x.list; exit 0" > /tmp/.gmenu-ipk/preinst
echo "#!/bin/sh\nsync; echo 'Installation finished.' ; echo 'Restarting gmenu2x..'; sleep 1; killall gmenu2x; exit 0" > /tmp/.gmenu-ipk/postinst
chmod +x /tmp/.gmenu-ipk/postinst /tmp/.gmenu-ipk/preinst
tar --owner=0 --group=0 -czvf /tmp/.gmenu-ipk/control.tar.gz -C /tmp/.gmenu-ipk/ control conffiles postinst preinst
tar --owner=0 --group=0 -czvf /tmp/.gmenu-ipk/data.tar.gz -C $(DISTDIR)/ .
echo 2.0 > /tmp/.gmenu-ipk/debian-binary
ar r dist/gmenu2x-$(PLATFORM).ipk /tmp/.gmenu-ipk/control.tar.gz /tmp/.gmenu-ipk/data.tar.gz /tmp/.gmenu-ipk/debian-binary
mv $(DISTDIR)$(HOMEPATH)/gmenu2x/* $(DISTDIR) && rmdir $(DISTDIR)$(HOMEPATH)/gmenu2x $(DISTDIR)$(HOMEPATH)
zip: dist
cd $(DISTDIR)/ && zip -r ../gmenu2x-$(PLATFORM).zip *