#
# Copyright (C) 1998-2000 Roger Butenuth <butenuth@uni-paderborn.de>
#
# This is free software, placed under the terms of the
# GNU General Public License, as published by the Free Software
# Foundation.  Please see the file COPYING for details.
#
# $Id: Makefile,v 1.10 2001/01/21 12:56:52 butenuth Exp $

CFLAGS = -Wall -Wno-unused-result -O -s

## arm compiler
#CC = /opt/cross/bin/arm-linux-gcc
#LD = /opt/cross/bin/arm-linux-ld
#AR = /opt/cross/bin/arm-linux-ar

## i386 compiler
CC = gcc
LD = ld
AR=ar


LIB_SOURCES=lang_lib.c synth_buffer.c english.c german.c

SOURCES=$(LIB_SOURCES)

LIB_OBJ = $(LIB_SOURCES:%.c=%.o)

SO_SOURCES = softspeech.c 
# Compile Viavoice driver when header file of Viavoice is present:
ifeq (/usr/include/eci.h,\
      $(wildcard /usr/include/eci.h))
#SO_SOURCES += viavoice.c
endif

SO_LIBS = $(SO_SOURCES:%.c=%.so)

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

%.so:	%.c
	$(CC) $(CFLAGS) -fPIC -c $< 
	$(CC) -shared -o $@ -Wl,-soname,$@ $(shell basename $< .c).o
	-rm $(shell basename $< .c).o

all_targets:	libspeech.a $(SO_LIBS)

libspeech.a: $(LIB_OBJ)
	$(AR) -crs $@ $(LIB_OBJ)
	cp libspeech.a ../


softspeech.so: softspeech.o softspeech_server.o
	$(CC) -shared -o ../lib/$@ -Wl,-soname,$@ \
	softspeech.o softspeech_server.o

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

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

clean:
	rm -f *~ *.bak *.o *.so *.a speech speech_test .depend .depend.bak

depend:
	@echo checking dependencies...
	@gcc -MM -MG $(SOURCES) $(SO_SOURCES) >.depend

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