#  EZinst - Easy Installation -
#  Copyright (C) 1993, 1994, 1995 Takashi MANABE
#                                     (manabe@Roy.dsl.tutics.tut.ac.jp)
#
#  EZinst 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
#  (at your option) 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.

OBJS=	rule.tab.o main.o label.o eval.o screen.o menu.o navigate.o\
	message.o package.o install.o list.o
LIBS=	-ljcurses -ltermcap #-lreadline
#LIBS=	../src/pcurses/libjcurses.a -ltermcap #-lreadline
LEX=	flex
YACC=	bison
FRULE=	categories packages japanese.dsc packages.siz
FMSG=	japanese.cat
OFLAGS=	-O2 -Wall #-g
IFLAGS=	-I/usr/include/ncurses
CFLAGS=	$(OFLAGS) #-Wall
SUBDIR=	Rules Messages

all:	subdirs ezinst

subdirs:
	@for i in $(SUBDIR);\
	do (cd $$i && echo making all in $$i && $(MAKE)) || exit;\
	done

ezinst:	$(OBJS)
	-rm ezinst
	cc $(OFLAGS) -o ezinst $(OBJS) $(LIBS)

lex.yy.c:	rule.l
	$(LEX) rule.l

rule.tab.c:	lex.yy.c rule.y
	$(YACC) rule.y

clean:
	rm -f $(OBJS) lex.yy.c rule.tab.c ezinst
	@for i in $(SUBDIR);\
	do (cd $$i && echo cleaning all in $$i && $(MAKE) clean) || exit;\
	done

install: install.rule install.bin

install.bin:
	install -cs -m 700 ezinst /sbin
	install -c -m 700 ezpkg /sbin

install.rule: subdirs
	mkdir -p /var/lib/ezinst /usr/lib/ezinst
	(cd /usr/lib/ezinst; mkdir -p Rules Messages)
	(cd /var/lib/ezinst; mkdir -p Lists installed scripts)
	(cd Rules; install -c -m 644 $(FRULE) /usr/lib/ezinst/Rules)
	(cd Messages; install -c -m 644 $(FMSG) /usr/lib/ezinst/Messages)

screen.o: version.h
