# Hey Emacs, this is a -*- makefile -*-

# Makefile for the nlsutils
# Copyright (C) 1994 Jochen Hein (Hein@Student.TU-Clausthal.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, 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.

CC=gcc
CFLAGS=-Wall -Wno-unused -ansi -I../lib -O2 -m486 -fomit-frame-pointer -fno-strength-reduce # -g 
# -pedantic -Wmissing-prototypes -Wstrict-prototypes
LDFLAGS=-s # -N
# LDFLAGS=-g
INSTALL=install
LFLAGS=-8 -d
YFLAGS=-d -t
LIBS=-lfl
YACC=bison
LEX=flex

DISTFILES=dspcat.c \
	  dspmsg.c \
	  locale.c \
	  gencat.c gencat.h genlib.c msgcat.h \
	  xtract.l \
          localedef.c \
          utility.c parse.y  lexer.l    cm-lex.l  cm-parse.y \
          utility.h \
          charmap.c collate.c ctype.c  monetary.c numeric.c response.c time.c \
          charmap.h collate.h ctype_.h monetary.h numeric.h response.h time.h \
	  Makefile \
	  version.c version.h

all: dspcat dspmsg gencat locale localedef xtract

install: all
	$(INSTALL) -o root -g root -m 755 dspcat    ${DEBDIR}/usr/bin/dspcat
	$(INSTALL) -o root -g root -m 755 dspmsg    ${DEBDIR}/usr/bin/dspmsg
	$(INSTALL) -o root -g root -m 755 gencat    ${DEBDIR}/usr/bin/gencat
	$(INSTALL) -o root -g root -m 755 locale    ${DEBDIR}/usr/bin/locale
	$(INSTALL) -o root -g root -m 755 localedef ${DEBDIR}/usr/bin/localedef
	$(INSTALL) -o root -g root -m 755 -s xtract    ${DEBDIR}/usr/bin/xtract

clean:
	rm -f core dspcat dspmsg gencat locale localedef xtract *.o *~
	rm -f cm-parse.h cm-parse.c parse.c parse.h cm-lex.c lexer.c xtract.c
 
dist: $(DISTFILES)
	ln $(DISTFILES) ../`cat ../.fname`/src

xtract: xtract.o
	$(CC) $(CFLAGS) -o xtract xtract.o -lfl

cm-parse.c: cm-parse.y
	$(YACC) $(YFLAGS) -pcm cm-parse.y
	mv -f cm-parse.tab.c cm-parse.c
	mv -f cm-parse.tab.h cm-parse.h

parse.c: parse.y
	$(YACC) $(YFLAGS) parse.y
	mv -f parse.tab.c parse.c
	mv -f parse.tab.h parse.h

cm-lex.c: cm-lex.l
	$(LEX) $(LFLAGS) -Pcm cm-lex.l
	mv -f lex.cm.c cm-lex.c

cm-parse.h: cm-parse.y
cm-lex.c: cm-parse.h
parse.h: parse.y
lexer.c: parse.h
charmap.o: charmap.c charmap.h
dspcat: dspcat.o version.o
dspmsg: dspmsg.o version.o
locale: locale.o charmap.o collate.o ctype.o numeric.o monetary.o response.o \
	 time.o version.o utility.o cm-parse.o cm-lex.o ../lib/langinfo.o
	${CC} ${LDFLAGS} -o $@ $^ -lfl
gencat: gencat.o genlib.o
xtract.c: xtract.l
localedef: localedef.o collate.o ctype.o monetary.o numeric.o response.o \
     time.o utility.o parse.o lexer.o version.o charmap.o \
      cm-parse.o cm-lex.o ../lib/langinfo.o
	${CC} ${LDFLAGS} -o $@ $^ -lfl
