LIJI32 / SameBoy

Game Boy and Game Boy Color emulator written in C
https://sameboy.github.io/
Other
1.68k stars 211 forks source link

make install #340

Open basxto opened 3 years ago

basxto commented 3 years ago

This is based on the discussion on https://github.com/LIJI32/SameBoy/pull/320

I'd like to make SameBoy installable on Linux via compilation, perhaps a Linux make install command should be added where by default it installs everything to /opt/sameboy/? This should solve the lack of location information while still being overridable so maintainers can customize all of these. This should also allow actual GUI integration (appearing in application menus, having an icon, etc).

-- @LIJI32

I would go for a

DESTDIR := 
PREFIX := usr/local

that installs to $(DESTDIR)/$(PREFIX)/share/applications/sameboy.desktop, $(DESTDIR)/$(PREFIX)/share/thumbnailers/sameboy.thumbnailer, $(DESTDIR)/$(PREFIX)/share/icons/hicolor/$(size)x$(size)/apps/sameboy.png, $(DESTDIR)/$(PREFIX)/share/sameboy/ or $(DESTDIR)/$(PREFIX)/share/games/sameboy/ (other data) and $(DESTDIR)/$(PREFIX)/bin/sameboy. Paths in .thumbnailer and .desktop can easily be updated with sed. $(PREFIX)/share is where all files will point to, if the user directly uses make install it should install to /usr/local/share and if it's installed via package manager it will end up in /usr/share. (see Filesystem Hierarchy Standard) $(DESTDIR) is needed by packagers, since they “install” it to a temporary folder.

If no $(DESTDIR) is defined, the makefile should use xdg-icon-resource forceupdate --mode system and xdg-desktop-menu forceupdate --mode system to update the caches, there might be one for thumbnailers, I haven't worked with those yet. If dest $(DESTDIR) is defined, package managers will update those caches with hooks after installation.

Now more details about icons and such:

$(DESTDIR)/$(PREFIX)/share/icons/hicolor/$(size)x$(size)/apps/sameboy.png are various sizes of the icon in PNG format. $XDG_DATA_DIRS/icons/hicolor from Icon Theme Specification's Directory Layout is by default set to /usr/share/icons/hicolor//usr/local/share/icons/hicolor (hicolor being the default theme).

$(DESTDIR)/$(PREFIX)/share/applications/sameboy.desktop is specified in Desktop Entry Specification. It does connect name, description, executable and icon. That way you can have something to click onto on the desktop, application menu etc. It also has categories for sorting it into application menus and can me associated with mimetypes, so you can open roms with a double click or it will appear in the right click menu if you have mutliple emulators installed. The mimetypes for sameboy would be application/x-gameboy-rom;application/x-gameboy-color-rom.

I don't know where $(DESTDIR)/$(PREFIX)/share/thumbnailers/sameboy.thumbnailer is specified, it does not appear to be Thumbnail Managing Standard, that reads like being for the filemanagers. But there is an example for PCManFM in the arch wiki and that's probably how it works for thunar etc. too. This again uses mime types, so we can just use the mime types from the .desktop file.

Jan200101 commented 3 years ago

an install target has been added as of 2b263937da9d89c105ac7b36b057ac635dbd1386