#
# Makefile  -  makefile for mknbi program
#
# Copyright (C) 1995 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.
#

CC	= cc
CPP	= $(CC) -E
AS86	= as86 -0 -a
LD86	= ld86 -0

DEBUG	= -O2
CFLAGS	= -Wall -Wno-parentheses $(DEBUG)
LDFLAGS	= -s
ADEBUG	= # -DASM_DEBUG

OBJS	= mknbi.o first_c.o
TARGET	= mknbi


.SUFFIXES:	.img .b

all:		$(TARGET)

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

.s.o:
		$(AS86) -w -o $*.o $*.s

.o.img:
		$(LD86) -s -o $*.img $*.o

.img.b:
		dd if=$*.img of=$*.b bs=32 skip=1


mknbi:		$(OBJS)
		$(CC) -o mknbi $(LDFLAGS) $(OBJS)

makec:		makec.c
		$(CC) -o makec makec.c

first.s:	first.S first.inc
		$(CPP) $(ADEBUG) first.S -o first.s

first_c.c:	first.b makec
		makec <first.b >first_c.c

dep:
		sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
		$(CPP) $(CFLAGS) -MM *.c >>tmp_make
		mv tmp_make Makefile

clean:
		rm -f *.o *.b *.img first.s first_c.* makec $(TARGET)

### Dependencies
makec.o : makec.c 
mknbi.o : mknbi.c mknbi.h 
