diff --git a/FreeDesktop/AppIcon/128x128.png b/FreeDesktop/AppIcon/128x128.png new file mode 100644 index 0000000..6303f23 Binary files /dev/null and b/FreeDesktop/AppIcon/128x128.png differ diff --git a/FreeDesktop/AppIcon/16x16.png b/FreeDesktop/AppIcon/16x16.png new file mode 100644 index 0000000..6c3f81d Binary files /dev/null and b/FreeDesktop/AppIcon/16x16.png differ diff --git a/FreeDesktop/AppIcon/256x256.png b/FreeDesktop/AppIcon/256x256.png new file mode 100644 index 0000000..e2a6cee Binary files /dev/null and b/FreeDesktop/AppIcon/256x256.png differ diff --git a/FreeDesktop/AppIcon/32x32.png b/FreeDesktop/AppIcon/32x32.png new file mode 100644 index 0000000..d7f2e4e Binary files /dev/null and b/FreeDesktop/AppIcon/32x32.png differ diff --git a/FreeDesktop/AppIcon/512x512.png b/FreeDesktop/AppIcon/512x512.png new file mode 100644 index 0000000..1608c71 Binary files /dev/null and b/FreeDesktop/AppIcon/512x512.png differ diff --git a/FreeDesktop/AppIcon/64x64.png b/FreeDesktop/AppIcon/64x64.png new file mode 100644 index 0000000..4a54e94 Binary files /dev/null and b/FreeDesktop/AppIcon/64x64.png differ diff --git a/FreeDesktop/Cartridge/128x128.png b/FreeDesktop/Cartridge/128x128.png new file mode 100644 index 0000000..bc14d79 Binary files /dev/null and b/FreeDesktop/Cartridge/128x128.png differ diff --git a/FreeDesktop/Cartridge/16x16.png b/FreeDesktop/Cartridge/16x16.png new file mode 100644 index 0000000..3cbd9ae Binary files /dev/null and b/FreeDesktop/Cartridge/16x16.png differ diff --git a/FreeDesktop/Cartridge/256x256.png b/FreeDesktop/Cartridge/256x256.png new file mode 100644 index 0000000..14258ea Binary files /dev/null and b/FreeDesktop/Cartridge/256x256.png differ diff --git a/FreeDesktop/Cartridge/32x32.png b/FreeDesktop/Cartridge/32x32.png new file mode 100644 index 0000000..c8ef62f Binary files /dev/null and b/FreeDesktop/Cartridge/32x32.png differ diff --git a/FreeDesktop/Cartridge/512x512.png b/FreeDesktop/Cartridge/512x512.png new file mode 100644 index 0000000..71314f7 Binary files /dev/null and b/FreeDesktop/Cartridge/512x512.png differ diff --git a/FreeDesktop/Cartridge/64x64.png b/FreeDesktop/Cartridge/64x64.png new file mode 100644 index 0000000..8835f79 Binary files /dev/null and b/FreeDesktop/Cartridge/64x64.png differ diff --git a/FreeDesktop/ColorCartridge/128x128.png b/FreeDesktop/ColorCartridge/128x128.png new file mode 100644 index 0000000..da4757e Binary files /dev/null and b/FreeDesktop/ColorCartridge/128x128.png differ diff --git a/FreeDesktop/ColorCartridge/16x16.png b/FreeDesktop/ColorCartridge/16x16.png new file mode 100644 index 0000000..50e6b2b Binary files /dev/null and b/FreeDesktop/ColorCartridge/16x16.png differ diff --git a/FreeDesktop/ColorCartridge/256x256.png b/FreeDesktop/ColorCartridge/256x256.png new file mode 100644 index 0000000..186f5d3 Binary files /dev/null and b/FreeDesktop/ColorCartridge/256x256.png differ diff --git a/FreeDesktop/ColorCartridge/32x32.png b/FreeDesktop/ColorCartridge/32x32.png new file mode 100644 index 0000000..47e45b5 Binary files /dev/null and b/FreeDesktop/ColorCartridge/32x32.png differ diff --git a/FreeDesktop/ColorCartridge/512x512.png b/FreeDesktop/ColorCartridge/512x512.png new file mode 100644 index 0000000..715d68f Binary files /dev/null and b/FreeDesktop/ColorCartridge/512x512.png differ diff --git a/FreeDesktop/ColorCartridge/64x64.png b/FreeDesktop/ColorCartridge/64x64.png new file mode 100644 index 0000000..403e307 Binary files /dev/null and b/FreeDesktop/ColorCartridge/64x64.png differ diff --git a/FreeDesktop/sameboy.desktop b/FreeDesktop/sameboy.desktop new file mode 100644 index 0000000..d42f395 --- /dev/null +++ b/FreeDesktop/sameboy.desktop @@ -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 \ No newline at end of file diff --git a/Makefile b/Makefile index a03f417..5335f33 100644 --- a/Makefile +++ b/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 diff --git a/SDL/utils.c b/SDL/utils.c index 8cdd00b..603e34a 100644 --- a/SDL/utils.c +++ b/SDL/utils.c @@ -1,13 +1,11 @@ #include #include #include +#include #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; } diff --git a/SDL/utils.h b/SDL/utils.h index 216e723..5c0383d 100644 --- a/SDL/utils.h +++ b/SDL/utils.h @@ -2,7 +2,6 @@ #define utils_h #include -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);