# Makefile for TeX-project WEB sources to C conversion programs.
# Written by Jakob Stoklund Olesen

CC = cc
LINK = drlink -o $@
LIBFILE = MakeALF -o $@
LEX = flex -B
LEXLIB =
LEX_OUTPUT_ROOT = lexyy
YACC = bison -y
YACC_OUTPUT_ROOT = y_tab

# The alloca hack shouldn't matter
CPPFLAGS = -DRISCOS -DHAVE_CONFIG_H -Dalloca=xmalloc -I,^,C:
CCFLAGS = -fah -wad ${CPPFLAGS} -depend !Depend -throwback

DLIBS = ^.lib.o.lib kpathsea:o.kpathsea 
LIBS = C:o.stubs -lib ${DLIBS} OSLib:o.OSLib

# VPATH=@ riscos

.SUFFIXES: .c .o

.c.o:;	${CC} -o $@ -c $< ${CCFLAGS}

programs = web2c fixwrites splitup

web2c_objects = o.main o.${YACC_OUTPUT_ROOT} o.${LEX_OUTPUT_ROOT}

# Primary target:
all: $(programs)
web2c: $(web2c_objects) ${DLIBS}
	$(LINK) $(web2c_objects) $(LEXLIB) $(LIBS)

# We use y_tab.* for the sake of MS-DOS.
o.main: c.main h.${YACC_OUTPUT_ROOT}
c.${YACC_OUTPUT_ROOT} h.${YACC_OUTPUT_ROOT}: y.web2c
	@echo Expect one shift/reduce conflict.
	$(YACC) -d y.web2c
	-Wipe Bsn* ~c
o.$(LEX_OUTPUT_ROOT): c.${LEX_OUTPUT_ROOT}
c.$(LEX_OUTPUT_ROOT): l.web2c
	$(LEX) l.web2c

fixwrites: o.fixwrites
	$(LINK) o.fixwrites $(LIBS)
splitup: o.splitup
	$(LINK) o.splitup $(LIBS)
regfix: o.regfix
	$(LINK) o.regfix $(LIBS)

$(programs): ${DLIBS}

# Dynamic dependencies:
o.main:	c.main
o.main:	h.web2c
o.main:	^.h.config
o.main:	kpathsea:h.config
o.main:	^.h.c-auto
o.main:	kpathsea:h.c-std
o.main:	kpathsea:h.c-unistd
o.main:	kpathsea:h.systypes
o.main:	kpathsea:h.c-std
o.main:	kpathsea:h.c-memstr
o.main:	kpathsea:h.c-errno
o.main:	kpathsea:h.c-minmax
o.main:	kpathsea:h.c-limits
o.main:	kpathsea:h.c-proto
o.main:	kpathsea:h.debug
o.main:	kpathsea:h.c-proto
o.main:	kpathsea:h.c-std
o.main:	kpathsea:h.types
o.main:	kpathsea:h.lib
o.main:	kpathsea:h.types
o.main:	kpathsea:h.types
o.main:	kpathsea:h.progname
o.main:	kpathsea:h.c-proto
o.main:	kpathsea:h.types
o.main:	kpathsea:h.c-fopen
o.main:	h.y_tab
o.lexyy:	c.lexyy
o.lexyy:	h.web2c
o.lexyy:	^.h.config
o.lexyy:	kpathsea:h.config
o.lexyy:	^.h.c-auto
o.lexyy:	kpathsea:h.c-std
o.lexyy:	kpathsea:h.c-unistd
o.lexyy:	kpathsea:h.systypes
o.lexyy:	kpathsea:h.c-std
o.lexyy:	kpathsea:h.c-memstr
o.lexyy:	kpathsea:h.c-errno
o.lexyy:	kpathsea:h.c-minmax
o.lexyy:	kpathsea:h.c-limits
o.lexyy:	kpathsea:h.c-proto
o.lexyy:	kpathsea:h.debug
o.lexyy:	kpathsea:h.c-proto
o.lexyy:	kpathsea:h.c-std
o.lexyy:	kpathsea:h.types
o.lexyy:	kpathsea:h.lib
o.lexyy:	kpathsea:h.types
o.lexyy:	kpathsea:h.types
o.lexyy:	kpathsea:h.progname
o.lexyy:	kpathsea:h.c-proto
o.lexyy:	kpathsea:h.types
o.lexyy:	kpathsea:h.c-fopen
o.lexyy:	h.y_tab
o.fixwrites:	c.fixwrites
o.fixwrites:	^.h.config
o.fixwrites:	kpathsea:h.config
o.fixwrites:	^.h.c-auto
o.fixwrites:	kpathsea:h.c-std
o.fixwrites:	kpathsea:h.c-unistd
o.fixwrites:	kpathsea:h.systypes
o.fixwrites:	kpathsea:h.c-std
o.fixwrites:	kpathsea:h.c-memstr
o.fixwrites:	kpathsea:h.c-errno
o.fixwrites:	kpathsea:h.c-minmax
o.fixwrites:	kpathsea:h.c-limits
o.fixwrites:	kpathsea:h.c-proto
o.fixwrites:	kpathsea:h.debug
o.fixwrites:	kpathsea:h.c-proto
o.fixwrites:	kpathsea:h.c-std
o.fixwrites:	kpathsea:h.types
o.fixwrites:	kpathsea:h.lib
o.fixwrites:	kpathsea:h.types
o.fixwrites:	kpathsea:h.types
o.fixwrites:	kpathsea:h.progname
o.fixwrites:	kpathsea:h.c-proto
o.fixwrites:	kpathsea:h.types
o.fixwrites:	kpathsea:h.c-fopen
o.fixwrites:	kpathsea:h.c-pathmx
o.fixwrites:	kpathsea:h.c-limits
o.splitup:	c.splitup
o.splitup:	^.h.config
o.splitup:	kpathsea:h.config
o.splitup:	^.h.c-auto
o.splitup:	kpathsea:h.c-std
o.splitup:	kpathsea:h.c-unistd
o.splitup:	kpathsea:h.systypes
o.splitup:	kpathsea:h.c-std
o.splitup:	kpathsea:h.c-memstr
o.splitup:	kpathsea:h.c-errno
o.splitup:	kpathsea:h.c-minmax
o.splitup:	kpathsea:h.c-limits
o.splitup:	kpathsea:h.c-proto
o.splitup:	kpathsea:h.debug
o.splitup:	kpathsea:h.c-proto
o.splitup:	kpathsea:h.c-std
o.splitup:	kpathsea:h.types
o.splitup:	kpathsea:h.lib
o.splitup:	kpathsea:h.types
o.splitup:	kpathsea:h.types
o.splitup:	kpathsea:h.progname
o.splitup:	kpathsea:h.c-proto
o.splitup:	kpathsea:h.types
o.splitup:	kpathsea:h.c-fopen
o.y_tab:	c.y_tab
o.y_tab:	h.web2c
o.y_tab:	^.h.config
o.y_tab:	kpathsea:h.config
o.y_tab:	^.h.c-auto
o.y_tab:	kpathsea:h.c-std
o.y_tab:	kpathsea:h.c-unistd
o.y_tab:	kpathsea:h.systypes
o.y_tab:	kpathsea:h.c-std
o.y_tab:	kpathsea:h.c-memstr
o.y_tab:	kpathsea:h.c-errno
o.y_tab:	kpathsea:h.c-minmax
o.y_tab:	kpathsea:h.c-limits
o.y_tab:	kpathsea:h.c-proto
o.y_tab:	kpathsea:h.debug
o.y_tab:	kpathsea:h.c-proto
o.y_tab:	kpathsea:h.c-std
o.y_tab:	kpathsea:h.types
o.y_tab:	kpathsea:h.lib
o.y_tab:	kpathsea:h.types
o.y_tab:	kpathsea:h.types
o.y_tab:	kpathsea:h.progname
o.y_tab:	kpathsea:h.c-proto
o.y_tab:	kpathsea:h.types
o.y_tab:	kpathsea:h.c-fopen
