########################################################################
# File: Makefile
# 	(Extracted from
#	   "$Id: Makefile,v 1.4 2009/05/30 14:50:33 maoyam Exp maoyam $")
#
# Abstracts:
#  This make file builds the floating_point test programs.
#
# Copyright (C) 2005-2007 Maoyam Tokyo, Japan (mailto:maoyam@mail.goo.ne.jp)
#
#  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., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
########################################################################

## CC=g++
CC=gcc -std=c99

PROG=floating_point.USE_long_long.exe
PROG2=floating_point.NO_LONG_LONG_LITTLE_ENDIAN.exe
PROG3=floating_point.LONG_DOUBLE_LITTLE_ENDIAN.exe
SRCS= floating_point.c
CFLAGS= -DUnitTest -Wall -pedantic -Wshadow -Wredundant-decls -Werror
LDFLAGS=-lm
SPLINTOPTS=+posix_lib -duplicatequals +ignorequals +ignoresigns	\
		-realcompare -unrecog -fcnuse -exportlocal

$(PROG): $(SRCS)
	$(CC) -g $(CFLAGS) -o $(PROG) $(SRCS) $(LDFLAGS)
	$(CC) -g -DNO_LONG_LONG -DLITTLE_ENDIAN $(CFLAGS) -o $(PROG2) $(SRCS) $(LDFLAGS)
	$(CC) -g -DLONG_DOUBLE -DLITTLE_ENDIAN $(CFLAGS) -o $(PROG3) $(SRCS) $(LDFLAGS)

splint:
	-splint $(SPLINTOPTS) $(SRCS)

utest:
	./test.bash

valgrind:
	make clean;
	make;
	(date; uname -a; $(CC) --version; echo; valgrind -v --read-var-info=yes --track-origins=yes --leak-check=full ./$(PROG) ) < /dev/null > valgrind.$(PROG).out`date +'%Y%m%d'`.txt 2>&1
	(date; uname -a; $(CC) --version; echo; valgrind -v --read-var-info=yes --track-origins=yes --leak-check=full ./$(PROG2) ) < /dev/null > valgrind.$(PROG2).out`date +'%Y%m%d'`.txt 2>&1
	(date; uname -a; $(CC) --version; echo; valgrind -v --read-var-info=yes --track-origins=yes --leak-check=full ./$(PROG3) ) < /dev/null > valgrind.$(PROG3).out`date +'%Y%m%d'`.txt 2>&1

gprof:
	make clean;
	$(CC) -pg $(CFLAGS) -o $(PROG) $(SRCS) $(LDFLAGS)
	$(CC) -pg -DNO_LONG_LONG -DLITTLE_ENDIAN $(CFLAGS) -o $(PROG2) $(SRCS) $(LDFLAGS)
	$(CC) -pg -DLONG_DOUBLE -DLITTLE_ENDIAN $(CFLAGS) -o $(PROG3) $(SRCS) $(LDFLAGS)
	./$(PROG) -P < /dev/null > /dev/null 2>&1;
	(date; uname -a; $(CC) --version; echo; gprof --version; gprof $(PROG) gmon.out) > gprof.$(PROG).out`date +'%Y%m%d'`.txt 2>&1;
	./$(PROG2) -P < /dev/null > /dev/null 2>&1;
	(date; uname -a; $(CC) --version; echo; gprof --version; gprof $(PROG2) gmon.out) > gprof.$(PROG2).out`date +'%Y%m%d'`.txt 2>&1;
	./$(PROG3) -P < /dev/null > /dev/null 2>&1;
	(date; uname -a; $(CC) --version; echo; gprof --version; gprof $(PROG3) gmon.out) > gprof.$(PROG3).out`date +'%Y%m%d'`.txt 2>&1;
	rm gmon.out;
	make clean;

clean:
	rm -rf floating_point.*.exe

rcs:
	ci						\
		GPL.txt				\
		Makefile			\
		floating_point.c	\
		floating_point.h	\
		index.html			\
		test.bash
	co -l					\
		GPL.txt				\
		Makefile			\
		floating_point.c	\
		floating_point.h	\
		index.html			\
		test.bash
	rlog					\
		GPL.txt				\
		Makefile			\
		floating_point.c	\
		floating_point.h	\
		index.html			\
		test.bash			> CHANGE_LOGS.txt

