# $Id: GNUmakefile,v 1.1 1992/04/28 15:14:55 steve Exp $

ysrcs		:= parser.y
csrcs		:= lib.c $(ysrcs:.y=.c) scanner.c udunits.c
INCFILES	:= udunits.h
hsrcs		:= $(INCFILES) parser.h patchlevel.h scanner.h
mansrcs		:= udunits.1src udunits.3src
MANFILES	:= $(mansrcs:src=)
ETCFILES	:= udunits.dat
MANIFEST	:= $(csrcs) $(hsrcs) $(ysrcs) $(mansrcs) $(ETCFILES) \
		   utprivate.h

CPPFLAGS	:= -DDEFAULT_PATH='"_INST_ETCDIR$(ETCFILES)"' \
		   -I../udposix/_OS -I../misc -I../udres
LINTFLAGS	:= -uz
LIBOBJS		:= $(subst .c,.o,$(filter-out udunits.c,$(csrcs)))
SA_OBJS		:= parser.o
PROGRAMS	:= udunits
GARBAGE		:= $(MANFILES)

THIS_DIR	:= ../
include $(THIS_DIR)GNUmakemaster

#
# The following yacc(1)-line generates 3 shift/reduce warning messages that 
# may safely be ignored.
#
# the sed(1)-line is necessary to avoid `redeclaration of malloc()' messages
# from the SunOS 4.1.1, /usr/5bin/cc compiler (and, perhaps, others).
#
parser.c:	parser.y
	$(YACC) $(YFLAGS) -d parser.y
	sed '/extern *char *\*malloc(), *\*realloc();/d' < y.tab.c > $@
	rm y.tab.c
	mv y.tab.h parser.h

udunits.1 \
udunits.3: \
  udunits.%:	udunits.%src
	sed 's;###DEFAULT_PATH###;$(inst_etcdir)$(ETCFILES);g' $< > $@
