Makefile 1.33 KB
Newer Older
Peter Pentchev's avatar
Peter Pentchev committed
1 2 3 4
#!/usr/bin/make -f

SCRIPT=		ethstats
SRC=		ethstats.pl
5 6
MAN1=		${SCRIPT}.1
MAN1GZ=		${MAN1}.gz
Peter Pentchev's avatar
Peter Pentchev committed
7

8
GZIP?=		gzip -cn
Peter Pentchev's avatar
Peter Pentchev committed
9 10 11
INSTALL?=	install
COPY?=		-c
MKDIR?=		mkdir -p
Peter Pentchev's avatar
Peter Pentchev committed
12
PERL?=		perl
Peter Pentchev's avatar
Peter Pentchev committed
13 14 15 16 17
RM?=		rm -f

LOCALBASE?=	/usr/local
PREFIX?=	${LOCALBASE}
BINDIR?=	${PREFIX}/bin
18
MANDIR?=	${PREFIX}/share/man/man
Peter Pentchev's avatar
Peter Pentchev committed
19 20 21 22 23

BINOWN?=	root
BINGRP?=	root
BINMODE?=	755

24 25 26
SHAREOWN?=	root
SHAREGRP?=	root
SHAREMODE?=	644
Peter Pentchev's avatar
Peter Pentchev committed
27

28
INSTALL_DATA?=		${INSTALL} ${COPY} -o ${SHAREOWN} -g ${SHAREGRP} -m ${SHAREMODE}
Peter Pentchev's avatar
Peter Pentchev committed
29 30 31
INSTALL_EXEC?=		${INSTALL} ${COPY} -m ${BINMODE}
INSTALL_SCRIPT?=	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}

32
all:		${SCRIPT} ${MAN1GZ}
Peter Pentchev's avatar
Peter Pentchev committed
33 34

clean:
35
		${RM} ${SCRIPT} ${MAN1GZ}
Peter Pentchev's avatar
Peter Pentchev committed
36 37 38 39

install:	all
		${MKDIR} ${DESTDIR}${BINDIR}
		${INSTALL_SCRIPT} ${SCRIPT} ${DESTDIR}${BINDIR}/
40 41
		${MKDIR} ${DESTDIR}${MANDIR}1
		${INSTALL_SCRIPT} ${MAN1GZ} ${DESTDIR}${MANDIR}1/
Peter Pentchev's avatar
Peter Pentchev committed
42 43

test:		all
Peter Pentchev's avatar
Peter Pentchev committed
44 45 46
		@echo "=== Perl syntax check"
		${PERL} -c ${SCRIPT}

Peter Pentchev's avatar
Peter Pentchev committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
		@echo "=== Basic version/usage functionality"
		./${SCRIPT} -Vh
		@echo

		@echo "=== Error out on invalid options"
		! ./${SCRIPT} -X
		@echo

		@if [ -r "/proc/net/dev" ]; then \
			echo "=== A single run"; \
			./${SCRIPT} -n3 -c2; \
		else \
			echo "=== Skipping the single run"; \
		fi
		@echo
Peter Pentchev's avatar
Peter Pentchev committed
62 63 64 65

${SCRIPT}:	${SRC}
		${INSTALL_EXEC} ${SRC} ${SCRIPT}

66 67 68
${MAN1GZ}:	${MAN1}
		${GZIP} ${MAN1} > ${MAN1GZ} || (${RM} ${MAN1GZ}; false)

Peter Pentchev's avatar
Peter Pentchev committed
69
.PHONY:		all clean install test