#
# Makefile  -  makefile for utility program to generate bootrom
#
# Copyright (C) 1997-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.2 2003/03/30 10:02:35 gkminix Exp $
#


# Include makefile configuration
include ../make.config
include ../make.rules


# MANEXT is the manual section number
MANEXT = 8



# Source and object files for the host system
SRCS      = main.c doconfig.c getdb.c user.c passes.c netdrv.c freeze.c \
		protini.c makeflash.c makehex.c flash_c.c console.c md5.c
OBJS      = $(SRCS:.c=.o)
TARGET    = makerom



# Also include some bootrom header files
CMODFLAGS = -I $(ROMDIR)/headers



# Rules to make the target
all:		$(TARGET)

$(TARGET):	$(OBJS) $(LIBNBA)
		$(CC) -o makerom $(LDFLAGS) $(OBJS) $(LIBS)



# Rules to generate a new bootrom
$(MISCDIR)/netboot.config $(MISCDIR)/netboot.drivers:
		(cd $(MISCDIR) && $(MAKE) netboot.config) || exit 1
		(cd $(MISCDIR) && $(MAKE) netboot.drivers) || exit 1


bootrom:	makerom $(MISCDIR)/netboot.config $(MISCDIR)/netboot.drivers
		@./makerom -C $(MISCDIR)/netboot.config -N $(ROMDIR) \
				-d $(MISCDIR)/netboot.drivers



# Generate C source file from FlashCard loader binary source
flash_c.c:	stamp-flash-$(GNU16BIT)

flash/flash.b86:
		@echo making all in flash
		@(cd flash && $(MAKE) all) || exit1

stamp-flash-gnu:	flash/flash.b86 $(MAKEC)
		$(MAKEC) flash <flash/flash.b86 >flash_c.c
		@touch stamp-flash-gnu

stamp-flash-nognu:
		@touch flash_c.c
		@touch stamp-flash-nognu


# distrib generates all files which will not be removed by distclean
distrib:	stamp-flash-gnu

install:	all
		$(INSTALL) -d $(bindir)
		$(INSTALL) -d $(mandir)/man$(MANEXT)
		$(INSTALL) -o bin -g bin -d $(nblibdir)
		$(INSTALL) -m 511 makerom $(bindir)/$(TARGET)
		$(INSTALL) -m 644 -o bin -g bin makerom.man $(mandir)/man$(MANEXT)/$(TARGET).$(MANEXT)


clean:		clean-local clean-recursive

clean-local:	clean-general
		rm -f image.rom image.flo image.flash image.bin image.hex


distclean:	distclean-local distclean-recursive

distclean-local:	clean-local


realclean:	realclean-local realclean-recursive

realclean-local:	distclean-local
		rm -f flash_c.c




syntax highlighted by Code2HTML, v. 0.9.1