Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (69 loc) · 2.94 KB
/
Copy pathMakefile
File metadata and controls
84 lines (69 loc) · 2.94 KB
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
78
79
80
81
82
83
84
# Either "linux" or "darwin", windows is built via mstools atm
OS_NAME := $(shell uname -s | tr A-Z a-z)
ARCH := $(shell uname -m)
VERSION := $(shell awk -F'"' '/define VERSION/{print $$2}' sgdboop.c)
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
USER_LIB_PATH := /usr/lib
ifdef FLATPAK_BUILDER_BUILDDIR
USER_LIB_PATH := /app/lib
endif
PKG_CONFIG ?= pkg-config
all: build
.PHONY: build
build: build-$(OS_NAME)
@echo "Built for target: $(OS_NAME)"
.PHONY: build-linux build-darwin
build-linux:
$(CC) -O3 -g sgdboop.c curl-helper.c gui-helper-gtk.c string-helpers.c crc.c $(shell $(PKG_CONFIG) --cflags --libs gtk+-3.0 libcurl) -o SGDBoop $(LDFLAGS)
chmod +x SGDBoop
build-darwin:
mkdir -p SGDBoop.app/Contents/MacOS
mkdir -p SGDBoop.app/Contents/Resources
cp LICENSE SGDBoop.app/Contents/Resources/LICENSE.txt
cp res/mac/AppIcon.icns SGDBoop.app/Contents/Resources/AppIcon.icns
cp res/mac/Assets.car SGDBoop.app/Contents/Resources/Assets.car
cp res/mac/Info.plist SGDBoop.app/Contents/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $(VERSION)" SGDBoop.app/Contents/Info.plist
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $(VERSION)" SGDBoop.app/Contents/Info.plist
$(CC) -Wno-pointer-sign -fobjc-arc -arch arm64 -arch x86_64 -g sgdboop.c curl-helper.c gui-helper-mac.m string-helpers.c crc.c $(shell $(PKG_CONFIG) --cflags --libs libcurl) -framework Cocoa -o SGDBoop.app/Contents/MacOS/SGDBoop $(LDFLAGS)
chmod +x SGDBoop.app/Contents/MacOS/SGDBoop
.PHONY: install install-linux install-flatpak
ifdef FLATPAK_BUILDER_BUILDDIR
install: install-flatpak
else
install: install-$(OS_NAME)
endif
install-linux: build
install -Dm755 SGDBoop -t $(DESTDIR)$(PREFIX)/bin
desktop-file-install res/linux/com.steamgriddb.SGDBoop.desktop --rebuild-mime-info-cache
@su - $(SUDO_USER)
xdg-mime default com.steamgriddb.SGDBoop.desktop x-scheme-handler/sgdb
install-flatpak: build
install -Dm644 res/linux/com.steamgriddb.SGDBoop-flatpak.desktop /app/share/applications/com.steamgriddb.SGDBoop.desktop
install -Dm644 com.steamgriddb.SGDBoop.appdata.xml -t /app/share/metainfo
install -Dm755 SGDBoop -t /app/bin
install -Dm644 res/com.steamgriddb.SGDBoop.svg -t /app/share/icons/hicolor/scalable/apps
.PHONY: dist
dist: build
mkdir -p dist/
# if mac delete symbols before archiving
ifeq ($(OS_NAME),darwin)
rm -r SGDBoop.app/Contents/MacOS/*.dSYM
ditto -c -k --keepParent $(shell $(MAKE) -s print-dists-darwin) dist/sgdboop-$(OS_NAME)-universal.zip
else
mkdir -p dist/$(OS_NAME)
cp $(shell $(MAKE) -s print-dists-$(OS_NAME)) dist/$(OS_NAME)/
tar -czvf $(CURDIR)/dist/sgdboop-$(OS_NAME)-$(ARCH).tar.gz -C dist/$(OS_NAME) .
rm -rf dist/$(OS_NAME)
endif
.PHONY: print-dists print-dists-linux print-dists-darwin
print-dists: print-dists-$(OS_NAME)
print-dists-linux:
@echo "SGDBoop" "LICENSE" "res/linux/com.steamgriddb.SGDBoop.desktop" "res/linux/install.sh"
print-dists-darwin:
@echo "SGDBoop.app"
.PHONY: clean
clean:
rm -rf SGDBoop.app SGDBoop dist