# ------------------ USER CONFIGURABLE SETTINGS ---------------------------
# The directories where files will be installed, you may want to change these.
BINDIR=usr/sbin
MANDIR=usr/share/man
ETCDIR=etc

# Compiler flags.
CC = gcc
CFLAGS = -O2 -g -Wall -pipe -Dlint

# If you are using gcc 2.5.8 this will get you QMAGIC executables
# later versions of gcc do this by default.
#LDFLAGS = -Xlinker -qmagic
LDFLAGS = 
# ------------------ END OF USER CONFIGURATIONS ---------------------------

OBJFILES=apcd.o parse.o upsnet.o
SOURCEFILES=apcd.c parse.c upsnet.c
HFILES=apcd.h version.h 
DOCFILES=README
DISTFILES=Makefile $(SOURCEFILES) $(HFILES) $(DOCFILES)

all:	apcd

apcd.o: 	apcd.c apcd.h
parse.o: 	parse.c apcd.h
upsnet.o:	upsnet.c apcd.h

apcd: $(OBJFILES)
	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJFILES) -o apcd

install: apcd
	install -o root -g root apcd ${DESTDIR}/${BINDIR}/apcd
	install -o root -g root -m 644 doc/apcd.man ${DESTDIR}/${MANDIR}/man8/apcd.8
	install -o root -g root -m 644 apcd.conf ${DESTDIR}/${ETCDIR}/apcd.conf
	install -o root -g root apcd.cronjob ${DESTDIR}/etc/cron.weekly/apcd

clean:
	rm -f *.o apcd

dep:
	$(CPP) -M *.c > .depend

#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
