# This program is free software; you can redistribute
# it and/or modify it under the terms of the GNU
# General Public License ...
# ...
# ...

SHELL = /bin/sh

# If you use gcc, you should either run the
# fixincludes script that comes with it or else use
# gcc with the -traditional option.  Otherwise ioctl
# calls will be compiled incorrectly on some systems.
# CC = gcc -O
# YACC = bison -y

PJ = libi7k

AR = ar
ARFLAGS = rv

CDEBUG = -g
CFLAGS = $(CDEBUG) -I. -I../include
CFLAGS_1 = $(CDEBUG) -I. -I../include -O2 -fPIC
LDFLAGS = -m elf_i386 -shared -soname 

INSTALL = install -c
INSTALLDATA = install -c -m 644

libdir = ../lib/

SRCS = timer.c sio.c i7k.c msw.c i7000.c i8000.c i87000.c

all:	$(libdir)/$(PJ).a $(libdir)/$(PJ).so.1.0

$(libdir)/$(PJ).a: $(SRCS)
	$(CC) -c $(CFLAGS) $?
	$(AR) $(ARFLAGS) $@ *.o
	rm -f *.o

$(libdir)/$(PJ).so.1.0:$(SRCS)
	$(CC) -c $(CFLAGS_1) $?
	ld $(LDFLAGS) $(libdir)/$(PJ).so.1 -o $(libdir)/$(PJ).so.1.0 *.o
	rm -f *.o
	ln -sf $(libdir)/$(PJ).so.1.0 $(libdir)/$(PJ).so.1
	ln -sf $(libdir)/$(PJ).so.1 $(libdir)/$(PJ).so

install: all
	$(INSTALL) $(PJ) $(bindir)/$(binprefix)$(PJ)

TAGS:   $(SRCS)
	etags $(SRCS)

indent:
	indent -kr -ts4 *.c

clean:
	rm -f *.o *~ *.tmp *.bak \#* .\#* $(libdir)/$(PJ).a $(libdir)/$(PJ).so*
