#
# Makefile  -  makefile for boot rom network drivers
#
# Copyright (C) 1998-2003 Gero Kuhlmann <gero@gkminix.han.de>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# $Id: Makefile,v 1.7 2003/01/25 23:29:41 gkminix Exp $
#


#
#  Include user configuration:
#
include ../make.config


#
# Name of this module
#
MODULE		= netdrvr


#
#  List of subdirectories
#
SUBDIRS		= init lib dossim pktdrvr ndis2 undi


#
#  List of source and object files:
#
PKTLIBS		= libpktdrv.a libdos.a libnet.a
NDISLIBS	= libndis2.a libdos.a libnet.a
UNDILIBS	= libundi.a libnet.a
INITOBJS	= netdrv.o
SEGEND		= segend.o
TARGETS		= netpkt.bin netndis.bin netundi.bin MD5SUMS


#
#  Include system dependent definitions:
#
include ../make.defs


#
#  The checksize script verifies that the network driver images don't grow
#  too large in order to fit into a certain amount of memory. MAXSIZE defines
#  that amount of memory. It represents the number of kB in the network driver
#  load area as defined in memory.h. STACKSIZE is not the actual stack size
#  but the amount of kB required to be free after the network driver has been
#  loaded (for example for DOS programs etc.).
#
MAXSIZE		= 62
STACKSIZE_PKT	= 51200
STACKSIZE_NDIS	= 51200
STACKSIZE_UNDI	= 32768


#
#  Target rules.
#
all:	$(TARGETS)


netpkt.bin:	subdirs
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $@ $(INITOBJS) $(PKTLIBS:lib%.a=-l%) $(SEGEND) | $(MAPSORT) >netpkt.map; \
	  chmod 0644 $@; \
	  cp $@ $(bindestdir)/netpkt.bin \
	)
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(@:%.bin=%86.bin) $(INITOBJS:.o=.o16) $(PKTLIBS:lib%.a=-l%-16) $(SEGEND:.o=.o16) | $(MAPSORT) >netpkt86.map; \
	  chmod 0644 $(@:%.bin=%86.bin); \
	  cp $(@:%.bin=%86.bin) $(bindestdir)/netpkt86.bin \
	)


netndis.bin:	subdirs
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $@ $(INITOBJS) $(NDISLIBS:lib%.a=-l%) $(SEGEND) | $(MAPSORT) >netndis.map; \
	  chmod 0644 $@; \
	  cp $@ $(bindestdir)/netndis.bin \
	)
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(@:%.bin=%86.bin) $(INITOBJS:.o=.o16) $(NDISLIBS:lib%.a=-l%-16) $(SEGEND:.o=.o16) | $(MAPSORT) >netndis86.map; \
	  chmod 0644 $(@:%.bin=%86.bin); \
	  cp $(@:%.bin=%86.bin) $(bindestdir)/netndis86.bin \
	)


netundi.bin:	subdirs
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $@ $(INITOBJS) $(UNDILIBS:lib%.a=-l%) $(SEGEND) | $(MAPSORT) >netundi.map; \
	  chmod 0644 $@; \
	  cp $@ $(bindestdir)/netundi.bin \
	)
	(cd $(MODOBJDIR); \
	  $(LD86) $(LD86FLAGS) -M -o $(@:%.bin=%86.bin) $(INITOBJS:.o=.o16) $(UNDILIBS:lib%.a=-l%-16) $(SEGEND:.o=.o16) | $(MAPSORT) >netundi86.map; \
	  chmod 0644 $(@:%.bin=%86.bin); \
	  cp $(@:%.bin=%86.bin) $(bindestdir)/netundi86.bin \
	)


MD5SUMS:
	cat `find . -name '*.md5'` >$@


.PHONY:	subdirs
subdirs:
	@for subdir in $(SUBDIRS); do \
	  echo making all in $$subdir; \
	  (cd $$subdir && $(MAKE) all) || exit 1; \
	done


#
#  Maintenance rules
#
#  The installation rule just steps down into the subdirectories. The network
#  driver interface binaries will be copied into the destination by the
#  main bootrom Makefile.
#
.PHONY:	dep install clean realclean distclean
.PHONY:	clean-recursive realclean-recursive distclean-recursive

dep install:
	@for subdir in $(SUBDIRS); do \
	  echo making $@ in $$subdir; \
	  (cd $$subdir && $(MAKE) $@) || exit 1; \
	done


clean:	clean-recursive
	rm -f $(MODOBJDIR)/*.o
	rm -f $(MODOBJDIR)/*.o16
	rm -f $(MODOBJDIR)/*.om
	rm -f $(MODOBJDIR)/*.a
	rm -f $(MODOBJDIR)/*.bin
	rm -f $(MODOBJDIR)/*.map


distclean:	distclean-recursive
	rm -f $(MODOBJDIR)/*.o
	rm -f $(MODOBJDIR)/*.o16
	rm -f $(MODOBJDIR)/*.om
	rm -f $(MODOBJDIR)/*.a
	rm -f $(MODOBJDIR)/*.bin
	rm -f $(MODOBJDIR)/*.map


realclean:	realclean-recursive
	rm -f $(MODOBJDIR)/*.o
	rm -f $(MODOBJDIR)/*.o16
	rm -f $(MODOBJDIR)/*.om
	rm -f $(MODOBJDIR)/*.a
	rm -f $(MODOBJDIR)/*.bin
	rm -f $(MODOBJDIR)/*.map


clean-recursive realclean-recursive distclean-recursive:
	@for subdir in $(SUBDIRS); do \
	  target=`echo $@ | sed 's/-recursive//'`; \
	  echo making $$target in $$subdir; \
	  (cd $$subdir && $(MAKE) $$target) || exit 1; \
	done



syntax highlighted by Code2HTML, v. 0.9.1