# Makefile for c-tools 0.4

# Copyright (C) 1995 Sandro Sigala - <sansig@freenet.hut.fi>

# $Id: Makefile,v 1.28 1995/08/12 15:14:13 sandro Exp $

#
# type `make' for making the binaries
# type `make install' for installing the binaries
# type `make maninstall' for installing the man pages
# type `make clean' to clean-up the source tree
#

CC = gcc # your C compiler
LEX = flex # your scanner generator

BINDIR = /usr/bin
LIBDIR = /usr/lib
MANDIR = /usr/man

CINFODIR = $(LIBDIR)/cinfo

YYWRAP = 1 # can be 1 or 0. if one do not work, try the other. (=

OPTFLAGS = -O2 -fomit-frame-pointer
CFLAGS = -ansi -pedantic -Wall $(OPTFLAGS)
LDFLAGS =

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

BINARIES = obscure highlight hsort cinfo
MANPAGES = obscure.1 highlight.1 hsort.1 cinfo.1
CINFOFILES = cinfo.lib cinfo.lib.standardc

all: $(BINARIES)

obscure: obscure.o hash.o misc.o lex.o
	$(CC) $(LDFLAGS) -o $@ obscure.o hash.o misc.o lex.o

highlight: highlight.o misc.o lex.o
	$(CC) $(LDFLAGS) -o $@ highlight.o misc.o lex.o

cinfo: cinfo.o cinfolib.o misc.o
	$(CC) $(LDFLAGS) -o $@ cinfo.o cinfolib.o misc.o

cinfo.o: cinfo.c
	$(CC) -c -DDEFAULT_SEARCH_PATH=\"$(CINFODIR)\" $(CFLAGS) $<

hsort.o: hsort.c
	$(CC) -c -DREPLACE_YYWRAP=$(YYWRAP) $(CFLAGS) $<

hsort: hsort.o
	$(CC) $(LDFLAGS) -o $@ hsort.o

hsort.c: hsort.l
	$(LEX) hsort.l
	mv lex.yy.c hsort.c

hashtest: hashtest.o hash.o misc.o

install: $(BINARIES) $(CINFOFILES)
	mkdir -p $(BINDIR)
	mkdir -p $(CINFODIR)
	install -s $(BINARIES) $(BINDIR)
	install -m 0644 $(CINFOFILES) $(CINFODIR)

maninstall: $(MANPAGES)
	mkdir -p $(MANDIR)/man1
	install -m 0644 $(MANPAGES) $(MANDIR)/man1

clean:
	@(cd examples; $(MAKE) clean)
	rm -f core *.o *~
	rm -f hsort.c
	rm -f $(BINARIES)

# Automatically generated dependencies
cinfo.o: cinfo.c misc.h cinfolib.h version.h
cinfolib.o: cinfolib.c misc.h cinfolib.h
hash.o: hash.c hash.h misc.h
hashtest.o: hashtest.c hash.h
highlight.o: highlight.c lex.h misc.h version.h highlight.h
hsort.o: hsort.c version.h
lex.o: lex.c lex.h misc.h
misc.o: misc.c
obscure.o: obscure.c lex.h hash.h misc.h version.h obscure.h
# Makefile ends here
