# $Id: Makefile,v 1.1 1999/03/01 15:23:09 roca Exp $
#
# Makefile
#
#	Created by  : V.Roca
#	Date	    : February 1999
#


###### OS dependant variables ######

# Which OS do you want bench/benchd to execute ?
# Change the LIBRARIES variable too...
# NB:	in case of IRIX, produce a (old) ELF32 executable for portability
#	across SGI's platforms
#
OSFLAGS = -DLINUX
#OSFLAGS = -DSOLARIS
#OSFLAGS = -DIRIX -32

# Linux version
#
LIBRARIES = -lc -lm

# Solaris version:
#
#LIBRARIES = -lc -lm

# IRIX version
#
#LIBRARIES = -lc -lm



###### Other variables ######

# Prefer gcc if available (eg. Linux), otherwise revert to cc.
# If you choose cc, you may need to change the CFLAGS too.
#CC = cc
#LD = ld
CC = gcc
LD = gcc

# Local CFLAGS.

# gcc version
#CFLAGS_stats  = -O -g -Wall ${OSFLAGS} -DDEBUG
CFLAGS_stats  = -O -g -Wall ${OSFLAGS}

# cc version
# -fullwarn for IRIX c compiler
#CFLAGS_stats  = -O -fullwarn ${OSFLAGS} -DDEBUG


# List of source and object files that comprise a program.
# chstksiz.o removed
#
stats_OFILES    = descr_stats.o
stats_SRCFILES  = descr_stats.c

INC_FILES =


###### Dependancies ######

all: descr_stats

descr_stats : ${stats_SRCFILES} ${INC_FILES}
	@echo "** Compile ${stats_SRCFILES} files..."
	@for f in ${stats_SRCFILES} ; do \
		of=`basename $${f} '.c'`.o; \
		echo "${CC} ${CFLAGS_stats} -c $${f}"; \
		${CC} ${CFLAGS_stats} -c $${f}; \
	done
	@echo "done"
	@echo "** Now create descr_stats..."
	${LD} ${LIBRARIES} ${stats_OFILES} -o descr_stats
	@echo "done"
	@echo "** Remove useless ${stats_OFILES} files..."
	@for f in ${stats_OFILES} ; do \
		if [ -f "$${f}" ] ; then \
			rm "$${f}"; \
		fi \
	done
	@echo "done"

clean :
	@for f in core ${stats_OFILES} ; do \
		if [ -f "$${f}" ] ; then \
			rm "$${f}"; \
		fi \
	done

cleanall : clean
	@for f in descr_stats descr_stats.linux descr_stats.solaris ; do \
		if [ -f "$${f}" ] ; then \
			rm $${f} ; \
		fi \
	done

linux : all
	mv descr_stats  descr_stats.linux
	@if [ -L ${HOME}/bin/descr_stats.linux ] ; then \
		rm ${HOME}/bin/descr_stats.linux ; \
	fi
	ln -s "`pwd`/descr_stats.linux"  ${HOME}/bin/descr_stats.linux  

solaris : all
	mv descr_stats descr_stats.solaris
	# NB: error below to fix, not crucial since most of the
	#     work has been done !
	@if [ -L ${HOME}/bin/descr_stats.solaris ] then \
		rm ${HOME}/bin/descr_stats.solaris \
	fi
	ln -s "`pwd`/descr_stats.solaris"  ${HOME}/bin/descr_stats.solaris

irix:
	# NB: using "make irix" is compulsory. "make" leads to errors!
	# reason: we don't manage to do compilation/linkage in two steps
	# with irix, so we do everything is here for the present!!!
	#
	@echo "** Compile ${descr_stats} files..."
	${CC} ${CFLAGS_stats} ${stats_SRCFILES} ${LIBRARIES} -o descr_stats
	@echo "done"
	@echo "** Remove useless ${stats_OFILES} files..."
	@for f in ${stats_OFILES} ; do \
		if [ -f "$${f}" ] ; then \
			rm "$${f}"; \
		fi \
	done
	@echo "done"
	mv descr_stats descr_stats.irix
	@if [ -L ${HOME}/bin/descr_stats.irix ] ; then \
		rm ${HOME}/bin/descr_stats.irix ; \
	fi
	@if [ -d ${HOME}/bin ] ; then \
		ln -s "`pwd`/descr_stats.irix"  ${HOME}/bin/descr_stats.irix ; \
	fi
