#
# Makefile: schedutils
# Robert Love, 20020425
# Last updated 20040323
#

ver = "1.4.0"

# user configurable settings
PREFIX		= /usr/local
BINDIR		= ${PREFIX}/bin
MANDIR		= ${PREFIX}/share/man
MAN1DIR		= ${MANDIR}/man1/
DOCDIR		= ${PREFIX}/share/doc/schedutils-${ver}

ANAL_WARN	= -Wconversion -Wshadow -Waggregate-return -Wcast-qual \
-Wmissing-prototypes -Wmissing-declarations -Wcast-align -Wbad-function-cast \
-Wdisabled-optimization -Wpointer-arith -Wwrite-strings -Wredundant-decls

CC		= gcc
CFLAGS		= -O2 -Wall -W -Wstrict-prototypes ${ANAL_WARN}

INSTALLBIN	= install
INSTALLMAN	= install --mode a=r
INSTALLDOC	= install --mode a=r
INSTALLDOCDIR	= install --directory

PROGS		= chrt taskset
MANPAGES	= chrt.1 taskset.1
DOCS		= AUTHORS ChangeLog COPYING INSTALL README

all: chrt taskset

chrt: chrt.c
	$(CC) $(CFLAGS) -DVERSION=\"$(ver)\" -o chrt chrt.c

taskset: taskset.c
	$(CC) $(CFLAGS) -DVERSION=\"$(ver)\" -o taskset taskset.c

clean:
	@-rm -f ${PROGS}

distclean: clean
	@-find . -name SCCS -prune -o -name BitKeeper -prune -o \
		\( -not -type d \) -and \
		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
		-o -name '*.bak' -o -name core -o -name '*.o' \
		-o -name '*.tmp' -o -size 0 \) \
		-type f -print | xargs rm -rf

install: ${PROGS}
	@echo Install binaries to: ${BINDIR}
	@echo Install manpage to: ${MAN1DIR}

	@${INSTALLBIN} ${PROGS} ${BINDIR}
	@cd man/ && ${INSTALLMAN} ${MANPAGES} ${MAN1DIR}

	@echo Done!  Do 'make installdoc' if you wish to install the docs.

installdoc: ${PROGS}
	@echo Install documentation to: ${DOCDIR}
	@${INSTALLDOCDIR} ${DOCDIR}
	@${INSTALLDOC} ${DOCS} ${DOCDIR}
	
uninstall:
	@cd ${BINDIR} && \
	rm -f ${PROGS}

	@cd ${MAN1DIR} && \
	gzip -d ${MANPAGES} && \
	rm -f ${MANPAGES}

	@rm -rf ${DOCDIR}
