#
# Crackerjack Project
#
# Copyright (C) 2007, Hitachi, Ltd.
# Author(s): Takahiro Yasui <takahiro.yasui.mp@hitachi.com>,
#            Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
#            Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# $Id:$
#

TARGET		:= test
COMPARE		:= compare
CFLAGS		:= -W -Wall -O2
SRCS		:= $(wildcard *.c) $(wildcard ../../common.j.h/*.c)
CC		:= gcc
RM		:= /bin/rm

SYSCALL		:= $(notdir $(shell cd ..; pwd))
TESTCASE	:= $(notdir $(shell pwd))

RESULT_DIR	:= result
RESULT_LOG	:= $(RESULT_DIR)/result.log
DETAIL_LOG	:= $(RESULT_DIR)/detail.log

ERESULT_DIR	:= expect
ERESULT_LOG	:= $(ERESULT_DIR)/result.log
EDETAIL_LOG	:= $(ERESULT_DIR)/detail.log

FRESULT_DIR	:= result^expect
FRESULT_LOG	:= $(FRESULT_DIR)/result.log
FDETAIL_LOG	:= $(FRESULT_DIR)/detail.log

ifeq ($(shell ls /proc/sys/kernel/ostype),)
  CFLAGS	+= -DSYSCTL_NOT_SUPPORTED
endif


$(TARGET): $(SRCS)
	$(CC) $(CFLAGS) -o $(TARGET) $(SRCS)

all:	$(TARGET)

expect:
	mkdir -p $(ERESULT_DIR)
	./$(TARGET) 1>$(ERESULT_LOG) 2>$(EDETAIL_LOG)
	@ echo "--- result.log ---"; cat $(ERESULT_LOG); echo "------------------"; 
	@ echo "--- detail.log ---"; cat $(EDETAIL_LOG); echo "------------------"; 

result:
	mkdir -p $(RESULT_DIR)
	./$(TARGET) 1>$(RESULT_LOG) 2>$(DETAIL_LOG)
	@ echo "--- result.log ---"; cat $(RESULT_LOG); echo "------------------"; 
	@ echo "--- detail.log ---"; cat $(DETAIL_LOG); echo "------------------"; 

comp:
	mkdir -p $(FRESULT_DIR)
	./$(COMPARE) $(ERESULT_LOG) $(RESULT_LOG) 1>$(FRESULT_LOG) 2>$(FDETAIL_LOG)
	@ echo "--- result.log ---"; cat $(FRESULT_LOG); echo "------------------"; 
	@ echo "--- detail.log ---"; cat $(FDETAIL_LOG); echo "------------------"; 

clean:
	$(RM) -rf $(TARGET) $(RESULT_DIR) $(ERESULT_DIR) $(FRESULT_DIR)
