Skip to content

Commit 4239dbe

Browse files
committed
Optional install to /opt.
1 parent 2c60dd7 commit 4239dbe

File tree

1 file changed

+31
-10
lines changed

1 file changed

+31
-10
lines changed

snm.pro

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,43 @@ SOURCES += \
4141
RESOURCES += data/icons/Icons.qrc
4242
RC_FILE = data/icons/Windows.rc
4343

44-
# Check if PREFIX environment variable is set.
45-
# If not, then assume /usr.
46-
_PREFIX = $$(PREFIX)
47-
isEmpty(_PREFIX) {
48-
_PREFIX = /usr
44+
# Install to /opt by calling "OPT=1 qmake" or to wanted prefix
45+
# by e.g. "PREFIX=/usr qmake".
46+
47+
_OPT = $$(OPT)
48+
_BIN = ""
49+
_DAT = ""
50+
if (!isEmpty(_OPT)) {
51+
message("Installs to /opt")
52+
_BIN = /opt/snm
53+
_DAT = /usr
54+
} else {
55+
# Check if PREFIX environment variable is set.
56+
# If not, then assume /usr.
57+
_PREFIX = $$(PREFIX)
58+
isEmpty(_PREFIX) {
59+
_PREFIX = /usr
60+
}
61+
message("Installs to "$$_PREFIX)
62+
_BIN = $$_PREFIX
63+
_DAT = $$_PREFIX
4964
}
5065

5166
unix {
52-
target.path = $$_PREFIX/bin
53-
desktop.path = $$_PREFIX/share/applications
67+
target.path = $$_BIN/bin
68+
desktop.path = $$_DAT/share/applications
5469
desktop.name = snm.desktop
5570
desktop.files += data/snm.desktop
56-
desktop.extra = cp data/snm.desktop.in data/snm.desktop
57-
icon1.path = $$_PREFIX/share/icons/hicolor/64x64/apps
71+
72+
if (!isEmpty(_OPT)) {
73+
desktop.extra = cp data/snm.desktop.opt.in data/snm.desktop
74+
} else {
75+
desktop.extra = cp data/snm.desktop.in data/snm.desktop
76+
}
77+
78+
icon1.path = $$_DAT/share/icons/hicolor/64x64/apps
5879
icon1.files += data/icons/snm.png
59-
icon2.path = $$_PREFIX/share/pixmaps
80+
icon2.path = $$_DAT/share/pixmaps
6081
icon2.files += data/icons/snm.png
6182
INSTALLS += target desktop icon1 icon2
6283
}

0 commit comments

Comments
 (0)