# $Id: Smakefile,v 1.37 1993/11/11 23:48:08 jraja Exp $
# 
# Copyright (c) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>,
#                    Helsinki University of Technology, Finland.
#                    All rights reserved.
#
# Smakefile for AmiTCP/IP Project
#
# Created      : Mon Mar  8 03:15:42 1993 ppessi
# Last modified: Fri Nov 12 01:47:46 1993 jraja
# 
# HISTORY
# $Log: Smakefile,v $
# Revision 1.37  1993/11/11  23:48:08  jraja
# Changed assebler include dir to INCLUDE: (SAS/C standard).
# Added in_cksum.asm and mbuf.i to MISC.
#
# Revision 1.36  1993/10/21  01:58:48  ppessi
# Using optimized in_cksum() from netinet/in_cksum.asm
#
# Revision 1.35  1993/10/14  00:07:22  ppessi
# Added new target, install.
#
# Revision 1.34  1993/10/11  01:41:35  jraja
# Changed /src to /amitcp to accomodate the new directory structure.
#
# Revision 1.33  1993/08/11  05:29:15  jraja
# Removed clib/exec_protos.h
#
# Revision 1.32  1993/08/04  19:57:44  too
# Removed sana2headers
#
# Revision 1.31  1993/08/02  10:44:08  jraja
# Changed /ami to /src.
#
# Revision 1.30  1993/06/12  23:23:50  too
# Added api/allocdatabuffer.c
#
# Revision 1.29  1993/06/12  11:22:07  jraja
# Added special rule for net/sana2perror.o, which must be compiled with
# KERNEL defined, but the code resides in netlib.
#
# Revision 1.28  1993/06/12  10:17:49  jraja
# Removed net/sana2perror.c, since it was moved to the netlib.
#
# Revision 1.27  1993/06/04  11:16:15  jraja
# Fixes for first public release.
#
# Revision 1.26  1993/06/03  00:27:35  jraja
# Added apicalls*.h.
#
# Revision 1.25  1993/06/02  19:39:46  too
# fix
#
# Revision 1.24  1993/06/02  19:25:27  too
# Moved resolver stuff from kern/ to api/ -directory
#
# Revision 1.23  1993/06/01  16:28:17  too
# Added resolver sources
#
# Revision 1.22  1993/05/24  19:30:54  ppessi
# Moved sys/syslog.h into netinclude; sanitized prototypes
#
# Revision 1.21  1993/05/16  23:37:43  ppessi
# The sana2errlist.c moved to the sana2 support library.
#
#

DEST = amitcp:

MAKE = smake
RM= delete
INSTALL= copy dates all
CC= sc
LD= slink
AS= a68k

CFLAGS= IDIR=/amitcp IDIR=conf IDIR=protos IDIR=netinclude:
AFLAGS= -i/amitcp -iINCLUDE:

#
# System headers
#
SYS_H= \
	sys/cdefs.h sys/synch.h sys/uio.h  \
	sys/kernel.h sys/malloc.h sys/mbuf.h sys/queue.h \
	sys/socketvar.h sys/domain.h sys/protosw.h \
	sys/systm.h 

PROTOS_H= \
	protos/kern/amiga_api_protos.h 	protos/kern/amiga_main_protos.h \
	protos/kern/amiga_select_protos.h protos/kern/amiga_time_protos.h \
	protos/kern/amiga_userlib_protos.h protos/kern/kern_malloc_protos.h \
	protos/kern/kern_synch_protos.h protos/kern/subr_prf_protos.h \
	protos/kern/uipc_domain_protos.h \
	protos/kern/uipc_socket2_protos.h protos/kern/uipc_socket_protos.h \
	protos/net/if_loop_protos.h protos/net/if_protos.h \
	protos/net/radix_protos.h protos/net/raw_cb_protos.h \
	protos/net/raw_usrreq_protos.h protos/net/rtsock_protos.h \
	protos/netinet/in_cksum_protos.h protos/netinet/in_pcb_protos.h \
	protos/netinet/in_proto_protos.h protos/netinet/in_protos.h \
	protos/netinet/ip_icmp_protos.h protos/netinet/ip_input_protos.h \
	protos/netinet/ip_output_protos.h protos/netinet/raw_ip_protos.h \
	protos/netinet/tcp_debug_protos.h protos/netinet/tcp_input_protos.h \
	protos/netinet/tcp_output_protos.h protos/netinet/tcp_subr_protos.h \
	protos/netinet/tcp_timer_protos.h protos/netinet/tcp_usrreq_protos.h \
	protos/netinet/udp_usrreq_protos.h

# Protocol inspecific network routines:
# network interfaces, input queue scheduling, 
# raw sockets, routing
NET_C= \
	net/if.c net/if_loop.c \
	net/raw_cb.c net/raw_usrreq.c \
	net/route.c net/rtsock.c net/radix.c \
	net/if_sana.c net/netisr.c net/sana2tags.c \
	net/sana2copybuff.c net/sana2arp.c

NET_O=  net/sana2perror.o \
	net/if.o net/if_loop.o \
	net/raw_cb.o net/raw_usrreq.o \
	net/route.o net/rtsock.o net/radix.o \
	net/if_sana.o net/netisr.o net/sana2tags.o \
	net/sana2copybuff.o net/sana2arp.o

NET_H= \
	net/if_types.h net/if_dl.h \
	net/if_sana.h net/sana2request.h net/sana2arp.h \
	net/netisr.h net/raw_cb.h net/radix.h 

# netinet -- internet protocols (ip, icmp, tcp, udp, arp)
NETINET_C= \
	netinet/in.c netinet/in_cksum.c netinet/in_pcb.c netinet/in_proto.c \
	netinet/ip_icmp.c \
	netinet/ip_input.c netinet/ip_output.c netinet/raw_ip.c \
	netinet/tcp_debug.c netinet/tcp_input.c netinet/tcp_output.c \
	netinet/tcp_subr.c netinet/tcp_timer.c netinet/tcp_usrreq.c \
	netinet/udp_usrreq.c

NETINET_O= \
	netinet/in.o netinet/in_cksum.o netinet/in_pcb.o netinet/in_proto.o \
	netinet/ip_icmp.o \
	netinet/ip_input.o netinet/ip_output.o netinet/raw_ip.o \
	netinet/tcp_debug.o netinet/tcp_input.o netinet/tcp_output.o \
	netinet/tcp_subr.o netinet/tcp_timer.o netinet/tcp_usrreq.o \
	netinet/udp_usrreq.o 

NETINET_H= \
	netinet/in_pcb.h netinet/in_var.h netinet/icmp_var.h  \
	netinet/tcpip.h netinet/tcp_debug.h netinet/tcp_fsm.h \
	netinet/tcp_seq.h netinet/tcp_timer.h netinet/tcp_var.h \
	netinet/udp_var.h 

# "Kernel" sources
# main, timeouts, syncronization, memory management,
# BSD socket ("Unix interprocess communication") routines,
# logging and netstat rexx interface 
KERN_C= \
	kern/amiga_main.c kern/amiga_time.c \
	kern/amiga_config.c kern/amiga_netdb.c \
	kern/kern_synch.c kern/kern_malloc.c kern/uipc_mbuf.c \
	kern/uipc_domain.c kern/uipc_socket.c kern/uipc_socket2.c \
	kern/amiga_log.c kern/amiga_cstat.c kern/amiga_rexx.c \
	kern/subr_prf.c 

KERN_O= \
	kern/config_var.o \
	kern/amiga_main.o kern/amiga_time.o \
	kern/amiga_config.o kern/amiga_netdb.o \
	kern/kern_synch.o kern/kern_malloc.o kern/uipc_mbuf.o \
	kern/uipc_domain.o kern/uipc_socket.o kern/uipc_socket2.o \
	kern/amiga_log.o kern/amiga_cstat.o kern/amiga_rexx.o \
	kern/subr_prf.o 

KERN_H= \
	kern/amiga_includes.h kern/amiga_time.h kern/amiga_config.h \
	kern/amiga_netdb.h kern/amiga_log.h kern/amiga_rexx.h \
	kern/amiga_subr.h 

# Application interface sources
# Amiga "struct Library" interface, API functions,
API_C=\
	api/amiga_api.c api/amiga_libtables.c \
	api/amiga_syscalls.c api/amiga_generic.c api/amiga_libcalls.c \
	api/getxbyy.c api/gethostnamadr.c api/allocdatabuffer.c \
	api/res_comp.c api/res_debug.c api/res_init.c \
	api/res_mkquery.c api/res_query.c api/res_send.c #api/gethna_nores.c

API_O=\
	api/amiga_api.o api/amiga_libtables.o \
	api/amiga_syscalls.o api/amiga_generic.o api/amiga_libcalls.o \
	api/getxbyy.o api/gethostnamadr.o api/allocdatabuffer.o \
	api/res_comp.o api/res_debug.o api/res_init.o \
	api/res_mkquery.o api/res_query.o api/res_send.o #api/gethna_nores.o

API_H=\
	api/amiga_raf.h api/amiga_api.h api/amiga_libcallentry.h \
	api/allocdatabuffer.h api/gethtbynamadr.h \
	api/arpa_nameser.h api/resolv.h \
	api/apicalls.h api/apicalls_sasc.h api/apicalls_gnuc.h

#
# Misc headers
#
MISC_H=\
	all_includes.h \
	conf/conf.h conf/rcs.h

#
# Misc sources
#
MISC= \
	all_includes.c GNUmakefile Smakefile GCCOPTS SCOPTIONS \
	kern/variables.src kern/config_var.awk \
	netinet/in_cksum.asm sys/mbuf.i

CSRCS=	$(KERN_C) $(NETINET_C) $(NET_C) $(API_C)
OBJS=   $(API_O) $(KERN_O) $(NETINET_O) $(NET_O)
SRCS=	$(CSRCS) $(SYS_H) $(API_H) $(KERN_H) $(NET_H) $(NETINET_H)\
	$(MISC_H) $(MISC) $(PROTOS_H)
LIBSRC= 
LIBS=  LIB netlib:sana2.lib

all: amitcp

dirs: net netinet kern api
net:	$(NET_O)
netinet:  $(NETINET_O)
kern:	$(KERN_O)
api:	$(API_O)
amitcp: dirs
	$(CC) LINK MAP BATCH to=$@ $(LIBSRC) $(LIBS) <WITH <
$(OBJS)
<

foo:	
	type <from <
$(OBJS)
<

echo:
	 list quick files nohead $(OBJS) lformat="%p%n"

gst: 	$(SYS_H) $(API_H) $(KERN_H) $(NET_H) $(NETINET_H) $(MISC_H) $(PROTOS_H)
	-gst unload `list AmiTCP.gst LFORMAT="%f%n"` 
	-$(RM) AmiTCP.gst
	$(CC) $(CFLAGS) MGST=AmiTCP.gst all_includes.c

# special rule for the net/sana2perror.o
net/sana2perror.o: /netlib/sana2perror.c
        $(CC) $(CFLAGS) $*.c objectname=$@

netinet/in_cksum.o: netinet/in_cksum.asm
	$(AS) $(AFLAGS) netinet/in_cksum.asm -o$@

# Special rule for variables
kern/config_var.o: kern/config_var.c

kern/config_var.c: kern/variables.src kern/config_var.awk
	gawk -f kern/config_var.awk -v TARGETTI=C $< > $@

# Special rule for TeX
kern/config_var.tex: kern/variables.src kern/config_var.awk
	gawk -f kern/config_var.awk -v TARGETTI=TEX $< > $@ 

#
install: all 
	$(INSTALL) amitcp $(DEST)

clean:
	-$(RM) net/\#?.o netinet/\#?.o kern/\#?.o api/\#?.o \#?.o \#?.(map|lnk)

veryclean: clean
	-$(RM) amitcp.gst amitcp
 	
date:
	date

TAGS:
	etags $(SRCS)

.c.o:
	$(CC) $(CFLAGS) $*.c

.c.s:
	$(CC) $(CFLAGS) $*.c DISASM=$@

# DO NOT DELETE THIS LINE -- make depend depends on it.
