# --------------------------------------------------------------------------
# Makefile:	Copyright (c) Mark P Jones 1991-1998.   All rights reserved.
#		See NOTICE for details and conditions of use etc...
#		O'Hugs version 0.5,
#		derived form Hugs version 1.3b, January 1998.
#
# Standard makefile for DOS (djgpp) and Unix (Solaris, etc.)
# --------------------------------------------------------------------------

.SUFFIXES	: .y .c .h .o .gs .s
HFILES		= prelude.h storage.h connect.h errors.h command.h
CFILES		= hugs.c storage.c input.c static.c type.c \
		  output.c compiler.c machine.c builtin.c
INCFILES	= parser.tab.c preds.c bignums.c kind.c subst.c \
		  machdep.c printer.c iomonad.c array.c runhugs.c
YFILES		= parser.y
SOURCES		= $(HFILES) $(CFILES) $(INCFILES) $(YFILES) prelude
OBJECTS		= storage.o input.o static.o type.o compiler.o
IOBJECTS	= hugs.o builtin.o  machine.o output.o $(OBJECTS)

# Edit the following settings as required.
# There are two choices of command line editor that can be used with O'Hugs:
#
# GNU readline:		usual GNU sources (e.g. bash distribution)
#  add libreadline.a -ltermcap to LDFLAGS (or maybe -lreadline -ltermcap)
#
# editline:		(comp.sources.misc, vol 31, issue 71)
#  add libedit.a to LDFLAGS (or maybe -ledit)
#
# If you don't have any of these libraries installed, you should
# add -DUSE_READLINE=1 to CFLAGS.
#
# The best bet is to `touch prelude.h' after changing these settings to
# ensure that the whole collection of files is recompiled with the correct
# settings.

CC		= gcc

# Choose your operating system
# If you don't have Tk, delete the stuff mentioning tcl, tk and X11,
# and set O_TK to 0 in prelude.h.

# Solaris
CFLAGS		= -g -I/usr/X11/include -I/usr/pd/tcl/8.0/include
LDFLAGS    	= -lm -lX11 -lsocket -lreadline -ltermcap -lnsl -R/usr/X11/lib -R/usr/pd/tcl/8.0/lib -L/usr/pd/tcl/8.0/lib -ltk8.0 -ltcl8.0 -ltix4.1.8.0

# NetBSD
#CFLAGS		= -g -I/usr/X11/include -I/usr/pkg/include/tk8.0  -I/usr/pkg/include -I/usr/pkg/include/tcl8.0
#LDFLAGS    	= -lm -lreadline -ltermcap -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11/lib -Wl,-R/usr/X11/lib -lX11 -ltk80 -ltcl80 -ltix4180

# Linux
#CFLAGS		= -g -I/usr/X11R6/include
#LDFLAGS    	= -ldl -lm -L/usr/X11R6/lib -lX11 -lreadline -ltermcap -ltk8.0 -ltcl8.0 -ltix

# CygWin
#CFLAGS		= -g
#LDFLAGS		= -ltk80 -ltcl80 -ltix4180 -liberty

# Debian GNU/Linux
#CFLAGS  = -g -I/usr/X11R6/include -I/usr/include/tk8.0 -I/usr/include/tcl8.0
#LDFLAGS = -lm -lreadline -lncurses -L/usr/X11R6/lib -lX11 -ltk8.0 -ltcl8.0 -ltix

OPTFLAGS	= 
#
# Use coff2exe with DJGPP; on other systems, use `echo' to omit this step.
#CONVERT		= coff2exe
CONVERT	= echo

all		: ohugs rohugs

ohugs		: $(IOBJECTS)
		  $(CC) $(OPTFLAGS) $(IOBJECTS) -o ohugs $(LDFLAGS)
#		  strip ohugs
		  $(CONVERT) ohugs

.c.o		:
		  $(CC) -c $(CFLAGS) $(OPTFLAGS) $<

clean		:
		  rm -f *.o parser.tab.c rohugs rohugs.exe ohugs ohugs.exe

parser.tab.c	: parser.y
		  bison parser.y
#		  -yacc parser.y
#		  mv y.tab.c parser.tab.c

hugs.o		: prelude.h storage.h connect.h errors.h \
		  command.h machdep.c
storage.o	: prelude.h storage.h connect.h errors.h
input.o		: prelude.h storage.h connect.h errors.h parser.tab.c command.h
static.o	: prelude.h storage.h connect.h errors.h
type.o		: prelude.h storage.h connect.h errors.h preds.c kind.c subst.c
output.o	: prelude.h storage.h connect.h errors.h
compiler.o	: prelude.h storage.h connect.h errors.h compiler.c
		  $(CC) -c $(CFLAGS) compiler.c
machine.o	: prelude.h storage.h connect.h errors.h
builtin.o	: prelude.h storage.h connect.h errors.h \
		  bignums.c printer.c iomonad.c array.c omonad.c tkhaskell.c
rohugs.o	: prelude.h storage.h connect.h errors.h hugs.c omonad.c
rohugs		: rohugs.o builtin.o  machine.o output.o $(OBJECTS) 
		  $(CC) $(OPTFLAGS) rohugs.o builtin.o  machine.o output.o $(OBJECTS) -o rohugs $(LDFLAGS)


syntax highlighted by Code2HTML, v. 0.9.1