# $Id: Makefile,v 1.12 1997/04/09 04:57:12 dps Exp $
#
#Makefile for word2x
#Test system is Linux 2.1.30, gcc 2.7.2, libc 5.4.27

#if you are compiling on SUNOS, use the following
#CPPFLAGS=-g -Wall -DSUNOS=1
#LD=./sunos_link

#For normal systems try this instead
CPPFLAGS=-g -Wall
LD=ld

CCFLAGS=-O3
LIBOBJS=wordwrap.o nullproc.o tblock.o scan_num.o map_chars.o col-align.o \
       ukdate.o usdate.o
AR=ar
RANLIB=ranlib
MYLIBS=liboutfmt.a
READER=reader.o
FMTS=fmt-text.o fmt-latex.o
CPP=g++
#Set to gopt.o if you lack getopt_long
GETOPT=
PROGOBJS=$(READER) word2x.o $(FMTS) $(GETOPT) $(MYLIBS)
TARGETS=word2x rtest2

all:    $(TARGETS)

clean:
       rm -f *.o
       rm -f $(MYLIBS)

clobber: clean
       rm -f $(TARGETS)

word2x.tar.gz:
       tar -C .. -czf word2x.tar.gz word2x \
           --exclude word2x/RCS --exclude word2x/word2x.tar.gz


liboutfmt.a: $(LIBOBJS)
       $(AR) rc $@ $(LIBOBJS)
       $(RANLIB) $@

rtest2: rtest2.o reader.o tblock.o
       g++ -o rtest2 rtest2.o reader.o tblock.o

fmt-text.o: text-fmt.o text-table.o
       $(LD) -r -o $@ text-fmt.o text-table.o

fmt-latex.o: latex-fmt.o latex-table.o latex-embed.o
       $(LD) -r -o $@ latex-fmt.o latex-table.o latex-embed.o

getopt.o: getopt.c
       $(CC) $(CFLAGS) -D_LIBC=1 -c -o $@ $<

getopt1.o: getopt1.c
       $(CC) $(CFLAGS) -D_LIBC=1 -c -o $@ $<

gopt.o: getopt.o getopt1.o
       $(LD) -r -o gopt.o getopt.o getopt1.o

word2x: $(PROGOBJS)
       $(CPP) -o $@ $(PROGOBJS)

%.o: %.cc
       $(CPP) $(CPPFLAGS) -c -o $@ $<