# FxGLUT version 0.12 - GLUT for Voodoo 1 and 2 under Linux
# Copyright (C) 1999 Christopher John Purnell
#                    cjp@lost.org.uk
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

SONAME = libfxglut.so
SUFFIX = 0.12

# For a shared library

LIB=$(SONAME).$(SUFFIX)
PIC=-fPIC

# For a static library

#LIB=libfxglut.a
#PIC=

#

CC=gcc
CFLAGS=-O2 -Wall -Werror $(PIC)
LDFLAGS=-s
SHARED=-shared -Wl,-soname,$(SONAME)
CPPFLAGS=-DGLIDE3 -I/usr/include/glide -I/usr/local/glide/include -I.
LEX=flex
YACC=bison
LEXLIB=-lfl

OFILES=	init.o game.o window.o mainloop.o swap.o keyboard.o mouse.o \
	menu.o cursor.o callback.o get.o misc.o null.o \
	shapes.o teapot.o bitmap.o stroke.o \
	f9x15.o f8x13.o tr10.o tr24.o hel10.o hel12.o hel18.o \
	Roman.o MonoRoman.o
CFILES=	init.c game.c window.c mainloop.c swap.c keyboard.c mouse.c \
	menu.c cursor.c callback.c get.c misc.c null.c \
	shapes.c teapot.c bitmap.c stroke.c 
CFONTS=	f9x15.c f8x13.c tr10.c tr24.c hel10.c hel12.c hel18.c \
	Roman.c MonoRoman.c to_stroke.c to_stroke.h
PROGS =	bdf_convert to_stroke

all: $(LIB)

libfxglut.a: $(OFILES)
	rm -f $@
	ar cr $@ $(OFILES)
	ranlib $@

$(SONAME).$(SUFFIX): $(OFILES)
	rm -f $@
	$(CC) $(SHARED) -o $@ $(OFILES)

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

bdf_convert: bdf_convert.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $<

f9x15.c: 9x15.bdf bdf_convert bitmap.h
	./bdf_convert 9By15 $< $@

f8x13.c: 8x13.bdf bdf_convert bitmap.h 
	./bdf_convert 8By13 $< $@

tr10.c: timR10.bdf bdf_convert bitmap.h
	./bdf_convert TimesRoman10 $< $@

tr24.c: timR24.bdf bdf_convert bitmap.h
	./bdf_convert TimesRoman24 $< $@

hel10.c: helvR10.bdf bdf_convert bitmap.h
	./bdf_convert Helvetica10 $< $@

hel12.c: helvR12.bdf bdf_convert bitmap.h
	./bdf_convert Helvetica12 $< $@

hel18.c: helvR18.bdf bdf_convert bitmap.h
	./bdf_convert Helvetica18 $< $@

to_stroke: to_stroke.c to_stroke.h wfont.h
	$(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o $@ $< $(LEXLIB)

to_stroke.h: to_stroke.l
	$(LEX) -o$@ $<

to_stroke.c: to_stroke.y
	$(YACC) -o $@ $<

Roman.c: Roman.src to_stroke stroke.h
	./to_stroke -o $@ $<

MonoRoman.c: MonoRoman.src to_stroke stroke.h
	./to_stroke -o $@ $<

distclean: clean
	rm -f $(LIB) $(PROGS) $(CFONTS) .depend

clean: tidy
	rm -f *.o

tidy:
	rm -f *~ *.bak *.orig

depend:
	$(CC) $(CPPFLAGS) -M $(CFILES) > .depend

ifeq (.depend, $(wildcard .depend))
include .depend
endif
