##
#
# Makefile of libaio
#   Makefile of libaio, pasky's asynchronous I/O library
#
# $Id: Makefile.in,v 1.2 2002/02/03 14:42:46 pasky Exp $
#
# Copyright (C) 2001,2002  Petr Baudis <pasky@ji.cz>
# Copyright (C) 2002       Jan Sembera <fis@ji.cz>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
##

prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sysconfdir = @sysconfdir@
libdir = @libdir@
datadir = @datadir@
includedir = @includedir@
VERSION = @VERSION@
install = @INSTALL@

CC = @CC@
MAKE = @MAKE@
CFLAGS = @CFLAGS@ -I../../include -Wall -Werror -pedantic
LDFLAGS = @LDFLAGS@ -L.
DEFS = @DEFS@
LIBS = @LIBS@

LIBAIO_OBJS=socket.o addr.o select.o bufio.o



all: libaio

libaio: libaio.a

libaio-clean:
	rm -f libaio.a $(LIBAIO_OBJS)

libaio-distclean:
	rm -f libaio.a $(LIBAIO_OBJS) Makefile

.PHONY: libaio.a
libaio.a: $(LIBAIO_OBJS)
	ar r $@ $(LIBAIO_OBJS)
	ranlib $@
	cp libaio.a ..
	
clean:	libaio-clean test-clean

distclean: libaio-distclean

.PHONY: install
install:
	@echo "Nothing to do in this directory, good bye" 


## TEST SUITE


test: libaio test-compile test-do test-clean
test-compile: test1 test2 test3
test-do: test1-do test2-do test3-do
test-clean: test1-clean test2-clean test3-clean


test1: test1.o libaio
	$(CC) $(CFLAGS) -o $@ $@.o $(LDFLAGS) -laio

test2: test2.o libaio
	$(CC) $(CFLAGS) -o $@ $@.o $(LDFLAGS) -laio

test3: test3.o libaio
	$(CC) $(CFLAGS) -o $@ $@.o $(LDFLAGS) -laio

test1-do: test1
	ln -fs test1 _t1srv
	./_t1srv >/dev/null &
	./test1 >/dev/null
	killall -9 _t1srv
	rm -f _t1srv

test2-do: test2
	ln -fs test2 _t2srv
	./_t2srv >/dev/null &
	./test2 >/dev/null
	killall -9 _t2srv
	rm -f _t2srv

test3-do: test3
	ln -fs test3 _t3srv
	./_t3srv >/dev/null &
	./test3 >/dev/null
	killall -9 _t3srv
	rm -f _t3srv

test1-clean:
	rm -f test1 test1.o _t1srv

test2-clean:
	rm -f test2 test2.o _t2srv

test3-clean:
	rm -f test3 test3.o _t3srv
