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

Use a Makefile that does a more portable installation. #130

Merged
merged 1 commit into from
Jan 8, 2024
Merged
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
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
PREFIX ?= /usr/local
MAN_PREFIX ?= ${PREFIX}/man
BINDIR ?= ${PREFIX}/bin
LIBDIR ?= ${PREFIX}/lib
SHAREDIR ?= ${PREFIX}/share
EXAMPLESDIR ?= ${SHAREDIR}/examples

MANDIR.${PREFIX} = ${PREFIX}/share/man
MANDIR./usr/local = /usr/local/man
MANDIR. = /usr/share/man
MANDIR ?= ${MANDIR.${PREFIX}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your GNU foo is better than mine. How does this alter the man directory based on platform? Does it rely on one of the platforms passing ${PREFIX} at build time?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a suggestion by someone else -- I wouldn't have thought of this! Basically if you pass PREFIX=/usr/local then MANDIR is set to /usr/local/man, otherwise it's set to /usr/share/man. It's very cunning!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I bet there's a platform where PREFIX=/usr/local/, but the manuals go into /usr/local/share/man, but let's not worry about it until we see it.

I thought FreeBSD did it this way, but I just check and I was wrong.


.PHONY: all install distrib

all:
cargo build --release

install:
cargo build --release
install -d ${PREFIX}/bin
install -c -m 555 target/release/snare ${PREFIX}/bin/snare
install -d ${MAN_PREFIX}/man/man1
install -d ${MAN_PREFIX}/man/man5
install -c -m 444 snare.1 ${MAN_PREFIX}/man/man1/snare.1
install -c -m 444 snare.conf.5 ${MAN_PREFIX}/man/man5/snare.conf.5
install -d ${PREFIX}/share/examples/snare
install -c -m 444 snare.conf.example ${PREFIX}/share/examples/snare
install -d ${DESTDIR}${BINDIR}
install -c -m 555 target/release/snare ${DESTDIR}${BINDIR}/snare
install -d ${DESTDIR}${MANDIR}/man1
install -d ${DESTDIR}${MANDIR}/man5
install -c -m 444 snare.1 ${DESTDIR}${MANDIR}/man1/snare.1
install -c -m 444 snare.conf.5 ${DESTDIR}${MANDIR}/man5/snare.conf.5
install -d ${DESTDIR}${EXAMPLESDIR}/pizauth
install -c -m 444 snare.conf.example ${DESTDIR}${EXAMPLESDIR}/snare

distrib:
test "X`git status --porcelain`" = "X"
Expand Down