-
Notifications
You must be signed in to change notification settings - Fork 42
/
Makefile
87 lines (72 loc) · 2.75 KB
/
Makefile
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
85
86
87
VERSION=1.5.1
VERSION_HEADER=src/version.h
BUILD_DIR = build
DEBUG_DIR = "${BUILD_DIR}/debug"
RELEASE_DIR = "${BUILD_DIR}/release"
PKG_DIR = pkg
BINNAME = xclicker
TARGET = build/debug/src/${BINNAME}
DESKFILE = assets/xclicker.desktop
debpkgdir="./${PKG_DIR}/deb/package"
appimgdir="${PKG_DIR}/AppImage/XClicker.AppDir"
ifeq ($(TARGET_ARCH),)
TARGET_ARCH := amd64
endif
.PHONY: build
build:
@if test -d "./${DEBUG_DIR}"; then echo "Build dir is already made"; else meson ${DEBUG_DIR}; fi
# Not "meson compile" since it doesn't work in workflow
ninja install -C ${DEBUG_DIR}
.PHONY: run
run:
./${TARGET}
.PHONY: all
all: build run
.PHONY: version
version:
@echo "// Do not edit this file, it is auto generated by the makefile" > ${VERSION_HEADER}
@echo "#ifndef __VERSION_H" >> ${VERSION_HEADER}
@echo "#define __VERSION_H" >> ${VERSION_HEADER}
@echo "static const char *XCLICKER_VERSION = \"v${VERSION}\";" >> ${VERSION_HEADER}
@echo "#endif" >> ${VERSION_HEADER}
.PHONY: release
release: version
@if test -d "./${RELEASE_DIR}"; then echo "Build dir is already made"; else meson ${RELEASE_DIR} --buildtype release; fi
ninja install -C ${RELEASE_DIR}
.PHONY: install
install: release
@sudo install -Dm 755 ./${RELEASE_DIR}/src/${BINNAME} /usr/bin/${BINNAME}
@sudo install -Dm 755 ./${DESKFILE} /usr/share/applications/xclicker.desktop
@sudo install -Dm 644 ./assets/icon.png /usr/share/pixmaps/${BINNAME}.png
@echo "Installed XClicker"
.PHONY: uninstall
uninstall:
@sudo rm /usr/bin/${BINNAME}
@sudo rm /usr/share/applications/xclicker.desktop
@sudo rm /usr/share/pixmaps/${BINNAME}.png
@echo "Uninstalled XClicker :("
.PHONY: deb
deb: release
@rm -rf ${debpkgdir}
@rm -f ${PKG_DIR}/deb/*.deb
@mkdir -p ${debpkgdir}
@install -Dm 644 ./${PKG_DIR}/deb/control ${debpkgdir}/DEBIAN/control
@sed -i 's/%VERSION%/${VERSION}/g' ${debpkgdir}/DEBIAN/control
@sed -i 's/%ARCH%/${TARGET_ARCH}/g' ${debpkgdir}/DEBIAN/control
@install -Dm 755 ./${RELEASE_DIR}/src/${BINNAME} ${debpkgdir}/usr/bin/${BINNAME}
@install -Dm 644 ./${DESKFILE} ${debpkgdir}/usr/share/applications/xclicker.desktop
@install -Dm 644 ./assets/icon.png ${debpkgdir}/usr/share/pixmaps/${BINNAME}.png
@dpkg-deb --build ${debpkgdir}
@dpkg-name ${PKG_DIR}/deb/package.deb -o
.PHONY: appimg
appimg: release
@rm -rf ${PKG_DIR}/AppImage/*.AppImage
@mkdir -p ${appimgdir}
@install -Dm 755 ./${RELEASE_DIR}/src/${BINNAME} ${appimgdir}/${BINNAME}
@install -Dm 755 ./${DESKFILE} ${appimgdir}/xclicker.desktop
@install -Dm 755 ./${PKG_DIR}/AppImage/AppRun ${appimgdir}/AppRun
@install -Dm 644 ./assets/icon.png ${appimgdir}/${BINNAME}.png
@cd ${PKG_DIR}/AppImage; appimagetool ./XClicker.AppDir; mv *.AppImage ${BINNAME}_${VERSION}_${TARGET_ARCH}.AppImage
.PHONY: clean
clean:
@$(RM) -rv ${BUILD_DIR}