#
# Makefile for linux IBM APE 25 Device driver.
#   This version builds the FULL STACK DRIVER ...
#

CC = gcc

TRUEROOT = /usr/src/linux
WORKROOT = /usr/src/linux

INCLS = -I$(WORKROOT)/net/atm  -I$(WORKROOT)/include

# If you are building for an SMP kernel you MUST include -D__SMP__
# If you are building for a non-SMP kernel you must NOT include it.

DEFS =  -D__KERNEL__  -DCPU=586 -DFULL_STACK -DCAPTURE_PMD -DCAPTURE_BUF

# DEFS =  -D__KERNEL__ -D__SMP__ -DCPU=586 -DDEBUG_BASE -DDEBUG_RECV -DDEBUG_XMIT -DSYNTHETIC_DROPS

OPTIONS =  -O2 -fomit-frame-pointer                \
           -fno-strength-reduce                    \
           -fvolatile                              \
           -fvolatile-global                       \
           -pipe -m486 -malign-loops=2             \
           -malign-jumps=2 -malign-functions=2

EFLAGS =  $(INCLS) $(DEFS) $(OPTIONS)
CFLAGS =  $(EFLAGS) -c
UFLAGS =  $(INCLS) -DAPP_MODE -DGLIBC_PATCH -L/usr/src/atm/lib
MFLAGS = -DMODULE -DMODVERSION $(CFLAGS)

# This section makes the driver.. It assumes that the kernel
# has been configured to support MODULES and MODVERSIONS

MOBJECT  = atmbase.o

SOBJECTS = atmxmit.o  \
           atmrecv.o  \
           atmioctl.o \
           atmxram.o  \
           atmdma.o   \
           atmape25.o

INCLUDE = ape25.h   \
          atmdd.h   \
          atmxram.h \
          atmuser.h


MODULE  = atm.o

$(MODULE): $(MOBJECT) $(SOBJECTS) $(INCLUDE)
	ld -Map atm.map -r -o $(MODULE)  $(MOBJECT) $(SOBJECTS)
	- >/var/log/messages
# 	- /sbin/rmmod atm
# 	- /sbin/insmod atm.o

$(MOBJECT): $(INCLUDE) atmbase.c
	$(CC) $(MFLAGS) atmbase.c 2>> atmbase.err

$(SOBJECTS): $(INCLUDE)
.c.o: $<
	$(CC) $(CFLAGS) $<  2>> $(@:.o=.err)

# This section makes the "ape" series of diagnostic
# and test tools

apelib.o: apelib.c $(INCLUDE)
	$(CC) $(UFLAGS) -c ${@:.o=.c} 2> ${@:.o=.err}
apelib:
	make apelib.o

APES     = apelc     apemklc   apexram \
           apelccfg  aperegs   apepmd  \
           aperfl    apestat   aperdnvr \
           apetqcfg  apetqlen  apetqdrp

${APES}: apelib.o
	$(CC) $(UFLAGS) -o $@ $(INCLS) $@.c  apelib.o 2> $@.err

apes:
	make $(APES)

# These test the ATM Linux native protocol stack over PVC's

AAS      = aasock aaconn aasend aarecv   \
           aatxrx aagen  aagengob aagobl \
           aarun

${AAS}: apelib.o
	$(CC) $(UFLAGS) -o $@ $(INCLS) $@.c  apelib.o 2> $@.err


# These test the ATM Linux native protocol stack over SVC's

ASVCS    = asvcrecv asvcsend asvcgobl asvcgen

${ASVCS}:
	$(CC) $(UFLAGS) -g -o $@  $@.c -latm  2> $@.err

# These test IP support

AIPS     = audpsend audprecv audpgen audpgobl audprun \
           atcpsend atcprecv atcpgen atcpgobl atcprun

${AIPS}: apelib.o
	$(CC) $(UFLAGS) -g -o $@  $@.c  apelib.o 2> $@.err

# These are some VERY simple test routines

TESTS    = atmtest1 atmtest2 atmtest3  \
           atmtest4 atmtest5 atmtest6  \
           atmtest7 atmtest8

${TESTS}:
	$(CC) $(UFLAGS) -o $@ $@.c 2> $@.err

tests:
	make $(TESTS)

aas:
	make $(AAS)

asvcs:
	make $(ASVCS)

aips:
	make $(AIPS)

all:
	make tests
	make apes
	make aas
	make aips
	make asvcs
	make

clean:
	- rm *.err
	- rm *.o
	- rm $(TESTS)
	- rm $(APES)
	- rm $(AAS)
	- rm $(AIPS)
	- rm $(ASVCS)
