# Makefile --
# Copyright 2002
# Lionel, trollhunter Bouchpan-Lerust-Juery <trollhunter@linuxfr.org>
#
# 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, 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.,
# 675 Mass Ave, Cambridge, MA 02139, USA.
#
 
# *************************************************************
# Change this section as needed.
# the -O flag is needed by inb(2) and outb(2)

CC		=	gcc
CFLAGS		=	-W -Wall -O -pedantic -fstrict-prototypes
DESTDIR		=	
MANDIR		=	${DESTDIR}/man/man3
INCDIR		=	${DESTDIR}/include
LIBDIR		=	${DESTDIR}/lib

# Do not change anything below this line
# *************************************************************

VERSION		=	1
SRC		=	kemo-M104.c my_errors.c
OBJS		=	kemo-M104.o my_errors.o
INSTALL		=	install
FULLNAME	=	libkemo-m104.so.${VERSION}
NAME		=	libkemo-m104.so
STATICNAME	=	libkemo-m104.a
HEADERNAME	=	kemo-M104.h
RM		=	rm -f 
MANPAGES	=	M104.3 M104_reset.3 M104_close.3\
			M104_open.3 M104_check.3 

all: static shared

test:  static_test shared_test

re: clean all

static: 
	${CC} -c ${CFLAGS} ${SRC}
	ar cr ${STATICNAME} ${OBJS}
	ranlib ${STATICNAME} 

shared:
	${CC} -c -fPIC ${CFLAGS} ${SRC}
	${CC} -shared ${OBJS} -o ${FULLNAME}

static_test:  clean 
	 ${CC} -static ${CFLAGS} -DSTATIC main.c  -lkemo-m104 -o static_test  
	./static_test 

shared_test: clean  
	${CC} -L. ${CFLAGS} -DSHARED main.c -o shared_test -lkemo-m104
	./shared_test

install: uninstall
	${INSTALL} -m 644 ${MANPAGES} ${MANDIR}
	${INSTALL} -m 644 ${HEADERNAME} ${INCDIR}
	${INSTALL} -m 644 ${STATICNAME} ${LIBDIR}
	${INSTALL} -m 644 ${FULLNAME} ${LIBDIR}
	ln -s ${LIBDIR}/${FULLNAME} ${LIBDIR}/${NAME}
	ldconfig -n

uninstall:
	find  ${MANDIR} -name "*M104*" -exec ${RM} {} \;
	${RM} ${INCDIR}/${HEADERNAME}
	${RM} ${LIBDIR}/${NAME}
	${RM} ${LIBDIR}/${STATICNAME}
	${RM} ${LIBDIR}/${FULLNAME}

clean:
	${RM} *~
	${RM} *.o 
	${RM} \#*
	${RM} ${FULLNAME}
	${RM} ${STATICNAME}
	${RM} shared_test static_test








