Allow make install under FreeDesktop
BIN
FreeDesktop/AppIcon/128x128.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
FreeDesktop/AppIcon/16x16.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
FreeDesktop/AppIcon/256x256.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
FreeDesktop/AppIcon/32x32.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
FreeDesktop/AppIcon/512x512.png
Normal file
After Width: | Height: | Size: 36 KiB |
BIN
FreeDesktop/AppIcon/64x64.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
FreeDesktop/Cartridge/128x128.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
FreeDesktop/Cartridge/16x16.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
FreeDesktop/Cartridge/256x256.png
Normal file
After Width: | Height: | Size: 35 KiB |
BIN
FreeDesktop/Cartridge/32x32.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
FreeDesktop/Cartridge/512x512.png
Normal file
After Width: | Height: | Size: 59 KiB |
BIN
FreeDesktop/Cartridge/64x64.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
FreeDesktop/ColorCartridge/128x128.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
FreeDesktop/ColorCartridge/16x16.png
Normal file
After Width: | Height: | Size: 20 KiB |
BIN
FreeDesktop/ColorCartridge/256x256.png
Normal file
After Width: | Height: | Size: 33 KiB |
BIN
FreeDesktop/ColorCartridge/32x32.png
Normal file
After Width: | Height: | Size: 21 KiB |
BIN
FreeDesktop/ColorCartridge/512x512.png
Normal file
After Width: | Height: | Size: 56 KiB |
BIN
FreeDesktop/ColorCartridge/64x64.png
Normal file
After Width: | Height: | Size: 22 KiB |
12
FreeDesktop/sameboy.desktop
Normal file
@ -0,0 +1,12 @@
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Icon=sameboy
|
||||
Exec=sameboy
|
||||
Name=SameBoy
|
||||
Comment=Game Boy and Game Boy Color emulator
|
||||
Keywords=game;boy;gameboy;color;emulator
|
||||
Terminal=false
|
||||
StartupNotify=false
|
||||
Categories=Application;Game;
|
||||
MimeType=application/x-gameboy-rom;application/x-gameboy-color-rom
|
35
Makefile
@ -30,6 +30,14 @@ else
|
||||
DEFAULT := sdl
|
||||
endif
|
||||
|
||||
ifneq ($(shell which xdg-open),)
|
||||
# Running on an FreeDesktop environment, configure for (optional) installation
|
||||
DESTDIR ?=
|
||||
PREFIX ?= /usr/local
|
||||
DATA_DIR ?= $(PREFIX)/share/sameboy/
|
||||
CAN_INSTALL := true
|
||||
endif
|
||||
|
||||
default: $(DEFAULT)
|
||||
|
||||
ifeq ($(MAKECMDGOALS),)
|
||||
@ -421,6 +429,33 @@ $(BIN)/BootROMs/%.bin: BootROMs/%.asm $(OBJ)/BootROMs/SameBoyLogo.pb12
|
||||
libretro:
|
||||
CFLAGS="$(WARNINGS)" $(MAKE) -C libretro
|
||||
|
||||
# install for Linux/FreeDesktop/etc.
|
||||
# Does not install mimetype icons because FreeDesktop is cursed abomination with no right to exist.
|
||||
# If you somehow find a reasonable way to make associate an icon with an extension in this dumpster
|
||||
# fire of a desktop environment, open an issue or a pull request
|
||||
ifneq ($(CAN_INSTALL),)
|
||||
ICON_NAMES := apps/sameboy
|
||||
ICON_SIZES := 16x16 32x32 64x64 128x128 256x256 512x512
|
||||
ICONS := $(foreach name,$(ICON_NAMES), $(foreach size,$(ICON_SIZES),$(DESTDIR)$(PREFIX)/share/icons/hicolor/$(size)/$(name).png))
|
||||
install: sdl $(DESTDIR)$(PREFIX)/share/applications/sameboy.desktop $(ICONS)(PREFIX)/share/mime/application/x-gameboy-color-rom.xml
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/share/sameboy/
|
||||
cp -rf $(BIN)/SDL/* $(DESTDIR)$(PREFIX)/share/sameboy/
|
||||
mv $(DESTDIR)$(PREFIX)/share/sameboy/sameboy $(DESTDIR)$(PREFIX)/bin/sameboy
|
||||
ifeq ($(DESTDIR),)
|
||||
-xdg-icon-resource forceupdate --mode system
|
||||
-xdg-desktop-menu forceupdate --mode system
|
||||
endif
|
||||
|
||||
$(DESTDIR)$(PREFIX)/share/icons/hicolor/%/apps/sameboy.png: FreeDesktop/AppIcon/%.png
|
||||
-@$(MKDIR) -p $(dir $@)
|
||||
cp -f $^ $@
|
||||
|
||||
|
||||
$(DESTDIR)$(PREFIX)/share/applications/sameboy.desktop: FreeDesktop/sameboy.desktop
|
||||
-@$(MKDIR) -p $(dir $@)
|
||||
cp -f $^ $@
|
||||
endif
|
||||
|
||||
# Clean
|
||||
clean:
|
||||
rm -rf build
|
||||
|
14
SDL/utils.c
@ -1,13 +1,11 @@
|
||||
#include <SDL.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "utils.h"
|
||||
|
||||
const char *resource_folder(void)
|
||||
static const char *resource_folder(void)
|
||||
{
|
||||
#ifdef DATA_DIR
|
||||
return DATA_DIR;
|
||||
#else
|
||||
static const char *ret = NULL;
|
||||
if (!ret) {
|
||||
ret = SDL_GetBasePath();
|
||||
@ -16,13 +14,19 @@ const char *resource_folder(void)
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
char *resource_path(const char *filename)
|
||||
{
|
||||
static char path[1024];
|
||||
|
||||
snprintf(path, sizeof(path), "%s%s", resource_folder(), filename);
|
||||
#ifdef DATA_DIR
|
||||
if (access(path, F_OK) == 0) {
|
||||
return path;
|
||||
}
|
||||
snprintf(path, sizeof(path), "%s%s", DATA_DIR, filename);
|
||||
#endif
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
#define utils_h
|
||||
#include <stddef.h>
|
||||
|
||||
const char *resource_folder(void);
|
||||
char *resource_path(const char *filename);
|
||||
void replace_extension(const char *src, size_t length, char *dest, const char *ext);
|
||||
|
||||
|