forked from soarqin/PocketSNES
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
77 lines (62 loc) · 3.26 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
# Define the applications properties here:
TARGET = ./dist/PocketSNES.dge
CROSS_COMPILE ?= mipsel-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)
SDL_LIBS := $(shell $(SYSROOT)/usr/bin/sdl-config --libs)
INCLUDE = -I pocketsnes \
-I sal/linux/include -I sal/include \
-I pocketsnes/include \
-I menu -I pocketsnes/linux -I pocketsnes/snes9x
CFLAGS = $(INCLUDE) -DRC_OPTIMIZED -DGCW_ZERO -D__LINUX__ -D__DINGUX__ -DFOREVER_16_BIT -DFOREVER_16_BIT_SOUND $(SDL_CFLAGS)
# CFLAGS += -ggdb3 -Og
CFLAGS += -O3 -fdata-sections -ffunction-sections -mips32r2 -mno-mips16 -fomit-frame-pointer -fno-builtin
CFLAGS += -fno-common -Wno-write-strings -Wno-sign-compare -ffast-math -ftree-vectorize -floop-interchange
CFLAGS += -funswitch-loops -fno-strict-aliasing
CFLAGS += -DFAST_LSB_WORD_ACCESS -DNO_ROM_BROWSER
ifdef PROFILE_GEN
CFLAGS += -fprofile-generate -fprofile-dir=/media/data/profile/pocketsnes
else
CFLAGS += -fprofile-use -fprofile-dir=./profile
endif
CXXFLAGS = $(CFLAGS) -std=gnu++03 -fno-exceptions -fno-rtti -fno-math-errno -fno-threadsafe-statics
LDFLAGS = $(CXXFLAGS) -lz -lpng $(SDL_LIBS) -Wl,--as-needed
ifndef PROFILE_GEN
LDFLAGS += -Wl,--gc-sections -s
endif
# Find all source files
SOURCE = pocketsnes/snes9x menu sal/linux sal
SRC_CPP = $(foreach dir, $(SOURCE), $(wildcard $(dir)/*.cpp))
SRC_C = $(foreach dir, $(SOURCE), $(wildcard $(dir)/*.c))
OBJ_CPP = $(patsubst %.cpp, %.o, $(SRC_CPP))
OBJ_C = $(patsubst %.c, %.o, $(SRC_C))
OBJS = $(OBJ_CPP) $(OBJ_C)
.PHONY : all
all : $(TARGET)
$(TARGET) : $(OBJS)
$(CMD)$(CXX) $(CXXFLAGS) $^ $(LDFLAGS) -o $@
ipk: $(TARGET)
@rm -rf /tmp/.pocketsnes-ipk/ && mkdir -p /tmp/.pocketsnes-ipk/root/home/retrofw/emus/pocketsnes /tmp/.pocketsnes-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators /tmp/.pocketsnes-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
@cp dist/PocketSNES.dge dist/PocketSNES.man.txt dist/PocketSNES.png dist/backdrop.png /tmp/.pocketsnes-ipk/root/home/retrofw/emus/pocketsnes
@cp dist/pocketsnes.lnk /tmp/.pocketsnes-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators
@cp dist/snes.pocketsnes.lnk /tmp/.pocketsnes-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems
# @sed "s/^Version:.*/Version: $$(date +%Y%m%d)/" dist/control > /tmp/.pocketsnes-ipk/control
@sed "s/^Version:.*/Version: 20190304/" dist/control > /tmp/.pocketsnes-ipk/control
@cp dist/conffiles /tmp/.pocketsnes-ipk/
# echo -e "#!/bin/sh\nmkdir -p /home/retrofw/profile/pocketsnes; exit 0" > /tmp/.pocketsnes-ipk/preinst
# chmod +x /tmp/.gmenu-ipk/postinst /tmp/.pocketsnes-ipk/preinst
@tar --owner=0 --group=0 -czvf /tmp/.pocketsnes-ipk/control.tar.gz -C /tmp/.pocketsnes-ipk/ control conffiles #preinst
@tar --owner=0 --group=0 -czvf /tmp/.pocketsnes-ipk/data.tar.gz -C /tmp/.pocketsnes-ipk/root/ .
@echo 2.0 > /tmp/.pocketsnes-ipk/debian-binary
@ar r dist/pocketsnes.ipk /tmp/.pocketsnes-ipk/control.tar.gz /tmp/.pocketsnes-ipk/data.tar.gz /tmp/.pocketsnes-ipk/debian-binary
%.o: %.c
$(CMD)$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp
$(CMD)$(CXX) $(CFLAGS) -c $< -o $@
.PHONY : clean
clean :
$(CMD)rm -f $(OBJS) $(TARGET)
$(CMD)rm -rf .opk_data $(TARGET).opk dist/pocketsnes.ipk