# If you want to use a copy of the shhopt option processing library already
# on your system, delete the shhopt.h file from the
# hwclock source directory and modify the following variables if shhopt
# is not in your default include and link search paths.  Leave everything
# as-is to use the copy of shhopt shipped with hwclock.
SHHOPT_LINK_PATH = .
SHHOPT_HEADER_PATH = .
SHHOPT_DEPENDENCY = libshhopt.a
# To use existing system copy of shhopt library:
#SHHOPT_LINK_PATH = 
#SHHOPT_HEADER_PATH = 
#SHHOPT_DEPENDENCY = 

CFLAGS = -s -Wall -Wwrite-strings -Wstrict-prototypes -Werror -Winline\
   $(CDEBUG)

LDFLAGS+= -Wl,-warn-common 

hwclock: hwclock.o rtc.o directio.o kd.o util.o $(SHHOPT_DEPENDENCY)
	gcc $(LDFLAGS) -o $@ $^ -L$(SHHOPT_LINK_PATH) -lshhopt

CFLAGS+= -O2 -I$(SHHOPT_HEADER_PATH) 

hwclock.o: hwclock.c hwclock.h

rtc.o: rtc.c hwclock.h

directio.o: directio.c hwclock.h

kd.o: kd.c hwclock.h

util.o: util.c hwclock.h

#Note that we build libshhopt for convenience here.  It would be more
#appropriate to use a copy of the library already installed (e.g. in 
#/usr/lib).  The authoritative libshhopt comes from:
#  (ftp://sunsite.unc.edu/pub/Linux/libs/shhopt-X.Y).

libshhopt.a: shhopt.o
	ar rc libshhopt.a shhopt.o
	ranlib libshhopt.a || true

shhopt.o: shhopt.c
	$(CC) -c -s -Wall -O2 -I. shhopt.c -o shhopt.o

clean: 
	rm *.o *.a

