Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve 'make install' for distros. #131

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 18 additions & 23 deletions bsnes/target-bsnes/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,36 @@ verbose: hiro.verbose ruby.verbose nall.verbose all;

install: all
ifeq ($(platform),windows)
else ifeq ($(shell id -un),root)
$(error "make install should not be run as root")
else ifeq ($(platform),macos)
mkdir -p ~/Library/Application\ Support/$(name)/
mkdir -p ~/Library/Application\ Support/$(name)/Database/
mkdir -p ~/Library/Application\ Support/$(name)/Firmware/
mkdir -p ~/Library/Application\ Support/$(name)/Shaders/
cp -R out/$(name).app /Applications/$(name).app
else ifneq ($(filter $(platform),linux bsd),)
mkdir -p $(prefix)/bin/
mkdir -p $(prefix)/share/applications/
mkdir -p $(prefix)/share/icons/hicolor/256x256/apps/
mkdir -p $(prefix)/share/icons/hicolor/scalable/apps/
mkdir -p $(prefix)/share/$(name)/
mkdir -p $(prefix)/share/$(name)/Database/
mkdir -p $(prefix)/share/$(name)/Firmware/
mkdir -p $(prefix)/share/$(name)/Shaders/
cp out/$(name) $(prefix)/bin/$(name)
cp $(ui)/resource/$(name).desktop $(prefix)/share/applications/$(name).desktop
cp $(ui)/resource/$(name).png $(prefix)/share/icons/hicolor/256x256/apps/$(name).png
cp $(ui)/resource/$(name).svg $(prefix)/share/icons/hicolor/scalable/apps/$(name).svg
cp Database/* $(prefix)/share/$(name)/Database/
cp -r ../shaders/* $(prefix)/share/$(name)/Shaders/
mkdir -p $(DESTDIR)$(bindir)
mkdir -p $(DESTDIR)$(datarootdir)/applications
mkdir -p $(DESTDIR)$(datarootdir)/icons/hicolor/256x256/apps
mkdir -p $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps
mkdir -p $(DESTDIR)$(datadir)/$(name)/Database
mkdir -p $(DESTDIR)$(datadir)/$(name)/Firmware
mkdir -p $(DESTDIR)$(datadir)/$(name)/Shaders
cp out/$(name) $(DESTDIR)$(bindir)/$(name)
cp $(ui)/resource/$(name).desktop $(DESTDIR)$(datarootdir)/applications/$(name).desktop
cp $(ui)/resource/$(name).png $(DESTDIR)$(datarootdir)/icons/hicolor/256x256/apps/$(name).png
cp $(ui)/resource/$(name).svg $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/$(name).svg
cp Database/* $(DESTDIR)$(datadir)/$(name)/Database/
cp -r ../shaders/* $(DESTDIR)$(datadir)/$(name)/Shaders/
endif

uninstall:
ifeq ($(platform),windows)
else ifeq ($(shell id -un),root)
$(error "make uninstall should not be run as root")
else ifeq ($(platform),macos)
rm -rf /Applications/$(name).app
else ifneq ($(filter $(platform),linux bsd),)
rm -f $(prefix)/bin/$(name)
rm -f $(prefix)/share/applications/$(name).desktop
rm -f $(prefix)/share/icons/hicolor/256x256/apps/$(name).png
rm -f $(prefix)/share/icons/hicolor/scalable/apps/$(name).svg
rm -rf $(prefix)/share/$(name)
rm -f $(DESTDIR)$(bindir)/$(name)
rm -f $(DESTDIR)$(datarootdir)/applications/$(name).desktop
rm -f $(DESTDIR)$(datarootdir)/icons/hicolor/256x256/apps/$(name).png
rm -f $(DESTDIR)$(datarootdir)/icons/hicolor/scalable/apps/$(name).svg
rm -rf $(DESTDIR)$(datadir)/$(name)
endif
3 changes: 3 additions & 0 deletions bsnes/target-bsnes/bsnes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ auto locate(string name) -> string {
location = {Path::userData(), "bsnes/", name};
if(inode::exists(location)) return location;

location = {Path::sharedData(), "bsnes/", name};
if(inode::exists(location)) return location;

directory::create({Path::userSettings(), "bsnes/"});
return {Path::userSettings(), "bsnes/", name};
}
Expand Down
6 changes: 5 additions & 1 deletion nall/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,9 @@ strne = $(if $(filter-out xx,x$(subst $1,,$2)$(subst $2,,$1)x),1,)
ifeq ($(platform),windows)
prefix := $(subst $([space]),\$([space]),$(strip $(call strtr,$(LOCALAPPDATA),\,/)))
else
prefix := $(HOME)/.local
prefix ?= /usr/local
bindir ?= $(prefix)/bin
datarootdir ?= $(prefix)/share
datadir ?= $(datarootdir)
flags += -DDATADIR=\"$(datadir)\"
endif
2 changes: 2 additions & 0 deletions nall/path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ inline auto sharedData() -> string {
result.transform("\\", "/");
#elif defined(PLATFORM_MACOS)
string result = "/Library/Application Support/";
#elif defined(DATADIR)
string result = DATADIR;
#else
string result = "/usr/share/";
#endif
Expand Down