#
# Makefile for fetchlog
#
# $Id: Makefile,v 1.2 2002/12/17 18:04:46 afrika Exp $
#
# 17. Dec 2002
#
# Alexander Haderer 
#
# alexander.haderer@charite.de
#

#
# distribution version number
#
FETCHLOG_VERSION=0.94

### ------------------------------------------------------------------------
### user settings
### ------------------------------------------------------------------------

###
### compiler

### gcc
CC=gcc
CFLAGS= -O -Wall -Wcast-qual -Wstrict-prototypes \
	-Wmissing-prototypes -Wmissing-declarations -Winline -Wcast-align 
### cc
#CC=cc
#CFLAGS=-O 

###
### file compressor (only needed when generating new dists)
FILE_COMP=gzip
#FILE_COMP=compress

###
### uncomment the line below if 
### 1. compilation fails with 'MADV_RANDOM' undeclared'
###    (This will most probably happen on Linux 2.2 systems)
### or
### 2. fetchlog fails witch  'ERROR: fetchlog: madvise: Invalid argument'
###    (This will most probably happen on SGI's IRIX using cc or gcc)
#NO_MADVISE=-DNO_MADVISE

###
### uncomment the line below if you want the exit codes prior to version 0.93:
###     0  ok no messages    (Nagios ok)
###     1  logfile messages  (Nagios warn)
###     2  fetchlog error    (Nagios critical)
###    -1  version info
### otherwise you get the new exit codes introduced in version 0.93:
###     0  ok no messages    (Nagios ok)
###     1  fetchlog error    (Nagios warn)
###     2  logfile messages  (Nagios critical)
###    -1  version info
###
#EXIT_CODES=-DPRE_093_EXIT_CODES

###
### installdir    
###   will use $INSTDIR/bin  and  $INSTDIR/man/man1, 
###   both dirs have to exist for installation
INSTDIR=/usr/local

### ------------------------------------------------------------------------
### --- end of user settings -----------------------------------------------
### ------------------------------------------------------------------------

# all files of this dist
# ----------------------
MYFILES= Makefile LICENSE CHANGES README README.SNMP README.Nagios \
	fetchlog.c fetchlog.1

# compiler stuff
# --------------
CC_OPT= $(CFLAGS) -DFETCHLOG_VERSION_NO=\"$(FETCHLOG_VERSION)\" $(NO_MADVISE) \
	$(EXIT_CODES)

# all
# ---
all: fetchlog

# fetchlog
# -------
fetchlog: fetchlog.c 
	$(CC) $(CC_OPT) fetchlog.c -o fetchlog


# install
# -------
install: fetchlog
	strip fetchlog
	cp fetchlog $(INSTDIR)/bin
	chmod 0755 $(INSTDIR)/bin/fetchlog
	cp fetchlog.1 $(INSTDIR)/man/man1
	chmod 0444 $(INSTDIR)/man/man1/fetchlog.1

# test
# ----
test: fetchlog
	@echo > ./testfile "fetchlog works!"
	@./fetchlog -f 1:100:500: `pwd`/testfile /tmp/dummy/bookmark || true
	@rm ./testfile

# clean
# -----
clean:
	rm -f *~ core *.core *.o fetchlog

# dist
# ----
dist:
	rm -rf fetchlog-$(FETCHLOG_VERSION)
	mkdir fetchlog-$(FETCHLOG_VERSION)
	cp $(MYFILES) fetchlog-$(FETCHLOG_VERSION)
	tar cf fetchlog-$(FETCHLOG_VERSION).tar \
		fetchlog-$(FETCHLOG_VERSION)
	rm -rf fetchlog-$(FETCHLOG_VERSION)
	$(FILE_COMP) fetchlog-$(FETCHLOG_VERSION).tar
