# 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 = libi8k

AR = ar
ARFLAGS = rv

# add $(LinPAC) value for x86 LinPAC(LX800 and Atom)
PROCESSOR = $(shell uname -p)
CPU_TYPE = i$(shell echo $(PROCESSOR) | sed -ne 's/^i[3456].*/X/p')86
ifeq ($(CPU_TYPE), iX86)
        LinPAC = x86
endif

#CROSS_COMPILE  =
ifeq ($(LinPAC), x86)
        CROSS_COMPILE =
else
        CROSS_COMPILE = arm-linux-
endif

AS		= $(CROSS_COMPILE)as
LD		= $(CROSS_COMPILE)ld
CC		= $(CROSS_COMPILE)gcc 
CPP		= $(CC) -E
AR		= $(CROSS_COMPILE)ar
NM		= $(CROSS_COMPILE)nm
STRIP		= $(CROSS_COMPILE)strip
OBJCOPY		= $(CROSS_COMPILE)objcopy
OBJDUMP		= $(CROSS_COMPILE)objdump

#CDEBUG = -g
ifeq ($(LinPAC), x86)
	CFLAGS = $(CDEBUG) -I. -I../include -I/lib/modules/`uname -r`/build/include
else
	CFLAGS = $(CDEBUG) -I. -I../include
endif

#CFLAGS = -msoft-float $(CDEBUG) -I. -I../include 
LDFLAGS = -g

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

libdir = ../lib/

SRCS = i8050.c timer.c slot.c sio.c msw.c i87000.c i8080eep.c i8000.c i7000.c i7k.c 8080_204.c 93c46202.c i87123cpm.c i87120can.c 8084W.c
#SRCS = *.c
all: 	$(libdir)/$(PJ).a

$(libdir)/$(PJ).a: $(SRCS)
	$(CC) -c $(CFLAGS) $?  
	$(AR) $(ARFLAGS) $@ i8050.o timer.o slot.o sio.o msw.o i87000.o i8080eep.o i8000.o i7000.o i7k.o 8080_204.o 93c46202.o i87123cpm.o i87120can.o 8084W.o
	rm -f *.o


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
