#
# Makefile for fetchlog
#
# 22. Feb 2001
#
# Alexander Haderer 
#
# alexander.haderer@charite.de
#

#
# distribution version number
#
FETCHLOG_VERSION=0.92

### ------------------------------------------------------------------------
### 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 following line 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


###
### 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.Netsaint \
	fetchlog.c fetchlog.1

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

# 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
