typo fix

typo fix

#!/usr/bin/env gnuplot

# graph of humidity (and temperature)

# datafile
ifnameh = "/tmp/domod/mysql/sql22h.csv"
ifnamed = "/tmp/domod/mysql/sql22d.csv"
ifnamew = "/tmp/domod/mysql/sql22w.csv"
set output ofname = "/tmp/domod/site/img/day22.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera" 9 size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 4 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 4 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 2 name "X" nooutput
Xw_min = X_min + utc_offset - 946684800
Xw_max = X_max + utc_offset - 946684800

# stats for Y-axis
stats ifnamew using 3 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

# stats for Y2-axis
stats ifnamew using 4 name "Y2" nooutput
Y2w_min = Y2_min -1
Y2w_max = Y2_max +1

set multiplot layout 1, 3 title "Humidity & Temperature (DHT22) -=- ".strftime("%Y-%m-%d %H:%M", time(0))

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Humidity [%]"
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label " "
set y2tics format " "
set y2range [ Y2_min : Y2_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):3 title " Humidity [%]"      with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 title " Temperature [degC]" axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label " "
set y2tics format " "
set y2range [ Y2_min : Y2_max ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label "Temperature [degC]"
set y2tics format "%2.1f"
set y2range [ Y2_min : Y2_max ]
set y2tics border

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot

#!/usr/bin/env gnuplot

# graph of humidity (and temperature)

# datafile
ifnameh = "/tmp/domod/mysql/sql22h.csv"
ifnamed = "/tmp/domod/mysql/sql22d.csv"
ifnamew = "/tmp/domod/mysql/sql22w.csv"
set output ofname = "/tmp/domod/site/img/day22.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera" 9 size 1280,320
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
# Positions of split between graphs
LMPOS = 0.40
MRPOS = 0.75

# ********************************************************* Statistics (R) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnameh using 2 name "X" nooutput

Xh_min = X_min + utc_offset - 946684800
Xh_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnameh using 4 name "Y" nooutput
#Yh_min = Y_min * 0.90
#Yh_max = Y_max * 1.10

# ********************************************************* Statistics (M) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamed using 2 name "X" nooutput

Xd_min = X_min + utc_offset - 946684800
Xd_max = X_max + utc_offset - 946684800

# stats to be calculated here for Y-axes
#stats ifnamed using 4 name "Y" nooutput
#Yd_min = Y_min * 0.90
#Yd_max = Y_max * 1.10

# ********************************************************* Statistics (L) *****
# stats to be calculated here of column 2 (UX-epoch)
stats ifnamew using 2 name "X" nooutput
Xw_min = X_min + utc_offset - 946684800
Xw_max = X_max + utc_offset - 946684800

# stats for Y-axis
stats ifnamew using 3 name "Y" nooutput
Yw_min = Y_min -1
Yw_max = Y_max +1

# stats for Y2-axis
stats ifnamew using 4 name "Y2" nooutput
Y2w_min = Y2_min -1
Y2w_max = Y2_max +1

set multiplot layout 1, 3 title "Humidity & Temperature (DHT22) -=- ".strftime("%Y-%m-%d %H:%M", time(0))

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       LEFT PLOT: past week
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past week"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%a %d"            # Display time in 24 hour notation on the X axis
set xrange [ Xw_min : Xw_max ]

# ***************************************************************** Y-axis *****
set ylabel "Humidity [%]"
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label " "
set y2tics format " "``
set y2range [ Y2_min : Y2_max ]

# ***************************************************************** Legend *****
set key inside top left horizontal box
set key samplen 1
set key reverse Left

# ***************************************************************** Output *****
set arrow from graph 0,graph 0 to graph 0,graph 1 nohead lc rgb "red" front
# set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
#set object 1 rect from screen 0,0 to screen 1,1 behind
#set object 1 rect fc rgb "#eeeeee" fillstyle solid 1.0 noborder
#set object 2 rect from graph 0,0 to graph 1,1 behind
#set object 2 rect fc rgb "#ffffff" fillstyle solid 1.0 noborder
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):3 title " Humidity [%]"      with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 title " Temperature [degC]" axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     MIDDLE PLOT:  past day
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past day"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xd_min : Xd_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label " "
set y2tics format " "
set y2range [ Y2_min : Y2_max ]

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set lmargin at screen LMPOS+0.001
set rmargin at screen MRPOS

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      RIGHT PLOT: past hour
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

# ***************************************************************** X-axis *****
set xlabel "past hour"       # X-axis label
set xdata time               # Data on X-axis should be interpreted as time
set timefmt "%s"             # Time in log-file is given in Unix format
set format x "%R"            # Display time in 24 hour notation on the X axis
set xrange [ Xh_min : Xh_max ]

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Yw_min : Yw_max ]

# **************************************************************** Y2-axis *****
set y2label "Temperature [degC]"
set y2tics format "%2.1f"
set y2range [ Y2_min : Y2_max ]
set y2tics border

# ***************************************************************** Legend *****
unset key

# ***************************************************************** Output *****
set arrow from graph 1,graph 0 to graph 1,graph 1 nohead lc rgb "green" front
set lmargin at screen MRPOS+0.001
set rmargin -1

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):3 with points pt 5 ps 0.2 fc rgb "#ccbb0000" \
  ,'' using ($2+utc_offset):4 axes x1y2  with dots

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                                 FINALIZING
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

unset multiplot


get rid of 'echo -e'

get rid of 'echo -e'

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@2430 4e380d45-d1fd-0310-85a7-d18ec86df0ad

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  make.settings.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2006-2008 Johannes Singler <singler@ira.uka.de>
#  Copyright (C) 2007-2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_MACOSX	?= no	# set 'yes' if you run Mac OS X, 'no' otherwise
USE_FREEBSD	?= no	# set 'yes' if you run FreeBSD, 'no' otherwise
ENABLE_SHARED	?= no   # set 'yes' to build a shared library instead of a static library (EXPERIMENTAL)
USE_PMODE	?= no	# will be overridden from main Makefile
USE_MCSTL	?= no	# will be overridden from main Makefile
USE_ICPC	?= no	# will be overridden from main Makefile

STXXL_ROOT	?= $(TOPDIR)

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_PMODE)),yes)
COMPILER_GCC	?= g++-4.4.x
MODEBASE	?= pmstxxl
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
MODEBASE	?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

ifeq ($(strip $(USE_BOOST)),yes)
#BOOST_ROOT	?= /usr/local/boost-1.34.1
LIBEXTRA	?= _boost
endif

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT_LEVEL	?= 3
OPT		?= -O$(OPT_LEVEL) # compiler optimization level
WARNINGS	?= -W -Wall -Woverloaded-virtual -Wundef
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBBASE		?= stxxl
LIBEXTRA	?=
MODEBASE	?= stxxl

LIBNAME		?= $(LIBBASE)$(LIBEXTRA)
MODENAME	?= $(MODEBASE)$(LIBEXTRA)

# Hint: for g++-4.4 with c++0x support, enable the following:
#STXXL_SPECIFIC	+= -std=c++0x

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.
#
# FIXME: documentation needed
#
#STXXL_SPECIFIC += -DSTXXL_DEBUGMON

#### You usually shouldn't need to change the sections below #####

#### MACOSX CONFIGURATION ########################################

ifeq ($(strip $(USE_MACOSX)),yes)

PTHREAD_FLAG	?=

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### FREEBSD CONFIGURATION #######################################

ifeq ($(strip $(USE_FREEBSD)),yes)

PTHREAD_FLAG	?= -pthread

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### LINUX (DEFAULT) CONFIGURATION ###############################

PTHREAD_FLAG	?= -pthread

# get a unique identifier for a file or directory,
# e.g. device number + inode number
GET_FILE_ID	?= stat -L -c '%d:%i' $1

##################################################################

#### SHARED LIBRARY ###############################################

ifeq ($(strip $(ENABLE_SHARED)),yes)

LIBEXT	?= so
LIBGEN	?= false  # see lib/GNUmakefile
STXXL_LIBRARY_SPECIFIC	+= -fPIC

endif

###################################################################

#### STXXL CONFIGURATION #########################################

# create make.settings.local in the root directory
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifeq (,$(STXXL_AUTOCONFIG))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
endif
cmt	= \#
$(shell echo '$(cmt)STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '$(cmt)MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.2' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.4 -std=c++0x' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)USE_BOOST	 = no' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)BOOST_ROOT	 = ' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell echo 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
ifeq (FreeBSD,$(strip $(shell uname)))
$(shell echo 'USE_FREEBSD	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_FREEBSD	 = no' >> $(CURDIR)/make.settings.local)
endif
include make.settings.local
endif
endif

# check, whether stxxl is configured correctly
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
$(warning *** WARNING: Please check make.settings.local)
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell $(call GET_FILE_ID, ./))
stat2	 = $(shell $(call GET_FILE_ID, $(STXXL_ROOT)/))

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

##################################################################

#### STXXL OPTIONS ###############################################

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-I$(strip $(STXXL_ROOT))/include \
	-include stxxl/bits/defines.h \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

STXXL_LIBRARY_SPECIFIC	+= -D_IN_LIBSTXXL

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### PARALLEL_MODE OPTIONS ###############################################

ifeq ($(strip $(USE_PMODE)),yes)

OPENMPFLAG			?= -fopenmp

PARALLEL_MODE_CPPFLAGS		+= $(OPENMPFLAG) -D_GLIBCXX_PARALLEL
PARALLEL_MODE_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_INCLUDE			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/include)
BOOST_COMPILER_OPTIONS		+= $(foreach inc,$(BOOST_INCLUDE),-I$(inc))
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_CONFIG
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_FILESYSTEM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_RANDOM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_THREADS
#BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_TIMESTAMP   # probably less efficient than gettimeofday()

BOOST_LIB_PATH			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/lib)
BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	$(foreach lib,$(BOOST_LIB_PATH),-L$(lib)) \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_system$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS #############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h
HEADER_FILES_BITS	+= compat_unique_ptr.h parallel.h singleton.h defines.h
HEADER_FILES_BITS	+= verbose.h unused.h compat_type_traits.h
HEADER_FILES_BITS	+= msvc_compatibility.h

HEADER_FILES_COMMON	+= aligned_alloc.h new_alloc.h
HEADER_FILES_COMMON	+= mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h error_handling.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h debug.h tuple.h
HEADER_FILES_COMMON	+= types.h settings.h seed.h is_sorted.h exithandler.h

HEADER_FILES_IO		+= io.h iostats.h completion_handler.h
HEADER_FILES_IO		+= request.h request_waiters_impl_basic.h
HEADER_FILES_IO		+= request_state_impl_basic.h request_impl_basic.h
HEADER_FILES_IO		+= disk_queues.h
HEADER_FILES_IO		+= request_queue.h request_queue_impl_worker.h
HEADER_FILES_IO		+= request_queue_impl_qwqr.h
HEADER_FILES_IO		+= request_queue_impl_1q.h
HEADER_FILES_IO		+= file.h disk_queued_file.h
HEADER_FILES_IO		+= ufs_file_base.h syscall_file.h mmap_file.h simdisk_file.h
HEADER_FILES_IO		+= wfs_file_base.h wincall_file.h
HEADER_FILES_IO		+= boostfd_file.h mem_file.h fileperblock_file.h
HEADER_FILES_IO		+= wbtl_file.h

HEADER_FILES_MNG	+= adaptor.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= bid.h typed_block.h diskallocator.h config.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h read_write_pool.h
HEADER_FILES_MNG	+= block_alloc.h block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h
#EADER_FILES_CONTAINERS	+= pq_helpers.h pq_mergers.h pq_ext_merger.h
#EADER_FILES_CONTAINERS	+= pq_losertree.h
HEADER_FILES_CONTAINERS	+= queue.h map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h ksort.h sort_base.h sort_helper.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

# extension of object files
OBJEXT		?= $(MODENAME).o
# extension of object files for the library
LIBOBJEXT	?= lib$(LIBNAME).o
IIEXT		?= $(MODENAME).ii
# static library file extension
LIBEXT		?= a
# executable file extension
EXEEXT		?= $(MODENAME).bin
# static library generation
LIBGEN		?= ar cr
# output file option for the compiler and linker
OUT		?= -o

o	?= $(strip $(OBJEXT))
lo	?= $(strip $(LIBOBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

define COMPILE_STXXL
	@$(RM) $@ $(@:.o=).d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $(@:.o=).dT -c $(OUTPUT_OPTION) $< && mv $(@:.o=).dT $(@:.o=).d
endef

DEPS_MAKEFILES		:= $(wildcard $(TOPDIR)/Makefile.subdir.gnu $(TOPDIR)/make.settings $(TOPDIR)/make.settings.local GNUmakefile Makefile Makefile.common Makefile.local)
EXTRA_DEPS_COMPILE	?= $(DEPS_MAKEFILES)
%.$o: %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(lo): PARALLEL_MODE_CPPFLAGS=
%.$(lo): MCSTL_CPPFLAGS=
%.$(lo): STXXL_COMPILER_OPTIONS += $(STXXL_LIBRARY_SPECIFIC)
%.$(lo): o=$(lo)
%.$(lo): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(ii): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

# $1=infix $2=additional CPPFLAGS
define COMPILE_VARIANT
%.$1.$$o: CPPFLAGS += $2
%.$1.$$o: %.cpp $$(EXTRA_DEPS_COMPILE)
	$$(COMPILE_STXXL)
endef

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

# last resort rules to ignore header files missing due to renames etc.
$(STXXL_ROOT)/include/%::
	@echo "MISSING HEADER: '$@' (ignored)"

%.h::
	@echo "MISSING HEADER: '$@' (ignored)"

/%::
	@echo "MISSING FILE:   '$@' (ignored)"

###################################################################

STXXL_SPECIFIC		+= $(STXXL_EXTRA)
WARNINGS		+= $(WARNINGS_EXTRA)

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_PMODE)),yes)
STXXL_COMPILER_OPTIONS	+= $(PARALLEL_MODE_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(PARALLEL_MODE_LDFLAGS)
endif

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)

# vim: syn=make

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  make.settings.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2006-2008 Johannes Singler <singler@ira.uka.de>
#  Copyright (C) 2007-2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_MACOSX	?= no	# set 'yes' if you run Mac OS X, 'no' otherwise
USE_FREEBSD	?= no	# set 'yes' if you run FreeBSD, 'no' otherwise
ENABLE_SHARED	?= no   # set 'yes' to build a shared library instead of a static library (EXPERIMENTAL)
USE_PMODE	?= no	# will be overridden from main Makefile
USE_MCSTL	?= no	# will be overridden from main Makefile
USE_ICPC	?= no	# will be overridden from main Makefile

STXXL_ROOT	?= $(TOPDIR)

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_PMODE)),yes)
COMPILER_GCC	?= g++-4.4.x
MODEBASE	?= pmstxxl
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
MODEBASE	?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

ifeq ($(strip $(USE_BOOST)),yes)
#BOOST_ROOT	?= /usr/local/boost-1.34.1
LIBEXTRA	?= _boost
endif

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT_LEVEL	?= 3
OPT		?= -O$(OPT_LEVEL) # compiler optimization level
WARNINGS	?= -W -Wall -Woverloaded-virtual -Wundef
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBBASE		?= stxxl
LIBEXTRA	?=
MODEBASE	?= stxxl

LIBNAME		?= $(LIBBASE)$(LIBEXTRA)
MODENAME	?= $(MODEBASE)$(LIBEXTRA)

# Hint: for g++-4.4 with c++0x support, enable the following:
#STXXL_SPECIFIC	+= -std=c++0x

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.
#
# FIXME: documentation needed
#
#STXXL_SPECIFIC += -DSTXXL_DEBUGMON

#### You usually shouldn't need to change the sections below #####

#### MACOSX CONFIGURATION ########################################

ifeq ($(strip $(USE_MACOSX)),yes)

PTHREAD_FLAG	?=

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### FREEBSD CONFIGURATION #######################################

ifeq ($(strip $(USE_FREEBSD)),yes)

PTHREAD_FLAG	?= -pthread

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### LINUX (DEFAULT) CONFIGURATION ###############################

PTHREAD_FLAG	?= -pthread

# get a unique identifier for a file or directory,
# e.g. device number + inode number
GET_FILE_ID	?= stat -L -c '%d:%i' $1

##################################################################

#### SHARED LIBRARY ###############################################

ifeq ($(strip $(ENABLE_SHARED)),yes)

LIBEXT	?= so
LIBGEN	?= false  # see lib/GNUmakefile
STXXL_LIBRARY_SPECIFIC	+= -fPIC

endif

###################################################################

#### STXXL CONFIGURATION #########################################

# create make.settings.local in the root directory
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifeq (,$(STXXL_AUTOCONFIG))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
endif
$(shell /bin/echo -e '\043STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell /bin/echo -e '\043MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell /bin/echo -e '\043COMPILER_GCC	 = g++-4.2' >> $(CURDIR)/make.settings.local)
$(shell /bin/echo -e '\043COMPILER_GCC	 = g++-4.4 -std=c++0x' >> $(CURDIR)/make.settings.local)
$(shell /bin/echo -e '\043COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(shell /bin/echo -e '\043USE_BOOST	 = no' >> $(CURDIR)/make.settings.local)
$(shell /bin/echo -e '\043BOOST_ROOT	 = ' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell /bin/echo -e 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell /bin/echo -e '\043USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
ifeq (FreeBSD,$(strip $(shell uname)))
$(shell /bin/echo -e 'USE_FREEBSD	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell /bin/echo -e '\043USE_FREEBSD	 = no' >> $(CURDIR)/make.settings.local)
endif
include make.settings.local
endif
endif

# check, whether stxxl is configured correctly
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
$(warning *** WARNING: Please check make.settings.local)
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell $(call GET_FILE_ID, ./))
stat2	 = $(shell $(call GET_FILE_ID, $(STXXL_ROOT)/))

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

##################################################################

#### STXXL OPTIONS ###############################################

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-I$(strip $(STXXL_ROOT))/include \
	-include stxxl/bits/defines.h \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

STXXL_LIBRARY_SPECIFIC	+= -D_IN_LIBSTXXL

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### PARALLEL_MODE OPTIONS ###############################################

ifeq ($(strip $(USE_PMODE)),yes)

OPENMPFLAG			?= -fopenmp

PARALLEL_MODE_CPPFLAGS		+= $(OPENMPFLAG) -D_GLIBCXX_PARALLEL
PARALLEL_MODE_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_INCLUDE			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/include)
BOOST_COMPILER_OPTIONS		+= $(foreach inc,$(BOOST_INCLUDE),-I$(inc))
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_CONFIG
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_FILESYSTEM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_RANDOM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_THREADS
#BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_TIMESTAMP   # probably less efficient than gettimeofday()

BOOST_LIB_PATH			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/lib)
BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	$(foreach lib,$(BOOST_LIB_PATH),-L$(lib)) \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_system$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS #############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h
HEADER_FILES_BITS	+= compat_unique_ptr.h parallel.h singleton.h defines.h
HEADER_FILES_BITS	+= verbose.h unused.h compat_type_traits.h
HEADER_FILES_BITS	+= msvc_compatibility.h

HEADER_FILES_COMMON	+= aligned_alloc.h new_alloc.h
HEADER_FILES_COMMON	+= mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h error_handling.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h debug.h tuple.h
HEADER_FILES_COMMON	+= types.h settings.h seed.h is_sorted.h exithandler.h

HEADER_FILES_IO		+= io.h iostats.h completion_handler.h
HEADER_FILES_IO		+= request.h request_waiters_impl_basic.h
HEADER_FILES_IO		+= request_state_impl_basic.h request_impl_basic.h
HEADER_FILES_IO		+= disk_queues.h
HEADER_FILES_IO		+= request_queue.h request_queue_impl_worker.h
HEADER_FILES_IO		+= request_queue_impl_qwqr.h
HEADER_FILES_IO		+= request_queue_impl_1q.h
HEADER_FILES_IO		+= file.h disk_queued_file.h
HEADER_FILES_IO		+= ufs_file_base.h syscall_file.h mmap_file.h simdisk_file.h
HEADER_FILES_IO		+= wfs_file_base.h wincall_file.h
HEADER_FILES_IO		+= boostfd_file.h mem_file.h fileperblock_file.h
HEADER_FILES_IO		+= wbtl_file.h

HEADER_FILES_MNG	+= adaptor.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= bid.h typed_block.h diskallocator.h config.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h read_write_pool.h
HEADER_FILES_MNG	+= block_alloc.h block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h
#EADER_FILES_CONTAINERS	+= pq_helpers.h pq_mergers.h pq_ext_merger.h
#EADER_FILES_CONTAINERS	+= pq_losertree.h
HEADER_FILES_CONTAINERS	+= queue.h map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h ksort.h sort_base.h sort_helper.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

# extension of object files
OBJEXT		?= $(MODENAME).o
# extension of object files for the library
LIBOBJEXT	?= lib$(LIBNAME).o
IIEXT		?= $(MODENAME).ii
# static library file extension
LIBEXT		?= a
# executable file extension
EXEEXT		?= $(MODENAME).bin
# static library generation
LIBGEN		?= ar cr
# output file option for the compiler and linker
OUT		?= -o

o	?= $(strip $(OBJEXT))
lo	?= $(strip $(LIBOBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

define COMPILE_STXXL
	@$(RM) $@ $(@:.o=).d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $(@:.o=).dT -c $(OUTPUT_OPTION) $< && mv $(@:.o=).dT $(@:.o=).d
endef

DEPS_MAKEFILES		:= $(wildcard $(TOPDIR)/Makefile.subdir.gnu $(TOPDIR)/make.settings $(TOPDIR)/make.settings.local GNUmakefile Makefile Makefile.common Makefile.local)
EXTRA_DEPS_COMPILE	?= $(DEPS_MAKEFILES)
%.$o: %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(lo): PARALLEL_MODE_CPPFLAGS=
%.$(lo): MCSTL_CPPFLAGS=
%.$(lo): STXXL_COMPILER_OPTIONS += $(STXXL_LIBRARY_SPECIFIC)
%.$(lo): o=$(lo)
%.$(lo): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(ii): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

# $1=infix $2=additional CPPFLAGS
define COMPILE_VARIANT
%.$1.$$o: CPPFLAGS += $2
%.$1.$$o: %.cpp $$(EXTRA_DEPS_COMPILE)
	$$(COMPILE_STXXL)
endef

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

# last resort rules to ignore header files missing due to renames etc.
$(STXXL_ROOT)/include/%::
	@echo "MISSING HEADER: '$@' (ignored)"

%.h::
	@echo "MISSING HEADER: '$@' (ignored)"

/%::
	@echo "MISSING FILE:   '$@' (ignored)"

###################################################################

STXXL_SPECIFIC		+= $(STXXL_EXTRA)
WARNINGS		+= $(WARNINGS_EXTRA)

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_PMODE)),yes)
STXXL_COMPILER_OPTIONS	+= $(PARALLEL_MODE_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(PARALLEL_MODE_LDFLAGS)
endif

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)

# vim: syn=make


Tweaked cavity.plt.

Tweaked cavity.plt.

# Terminal type is: 0 - X11, 1 - PS, 2 - PNG, 3 - JPG
term_type = 1;

# On-axis long. E-field [V/m] vs. z [mm].
file1 = "axisData_41.txt";

# Transverse higher order E-field [V/m] ([V] for dipole) vs. z [mm].
# Dipole.
file2 = "Multipole41/CaviMlp_EDipole_41.txt";
# First half of defocusing component.
file3 = "Multipole41/CaviMlp_EFocus1_41.txt";
# Second half of defocusing component.
file4 = "Multipole41/CaviMlp_EFocus2_41.txt";
# Quadrupole.
file5 = "Multipole41/CaviMlp_EQuad_41.txt";

# Tranverse higher order H-field [A/m] ([A] for dipole) vs. z [mm]
file6 = "Multipole41/CaviMlp_HDipole_41.txt";
file7 = "Multipole41/CaviMlp_HMono_41.txt";
file8 = "Multipole41/CaviMlp_HQuad_41.txt";
file9 = "Multipole41/thinlenlon_41.txt";

if (term_type == 0) set terminal x11;
if (term_type == 1) set terminal postscript landscape enhanced color solid \
  lw 2 "Times-Roman" 15;
#if (term_type == 2) set terminal pngcairo size 350, 262 enhanced \
#  font 'Verdana,10';
if (term_type == 2) set terminal pngcairo enhanced font "Times-Roman";
if (term_type == 3) set terminal jpeg enhanced;

set grid;

set style line 1 lt 1 lw 1 lc rgb "blue";
set style line 2 lt 1 lw 1 lc rgb "cyan";
set style line 3 lt 1 lw 1 lc rgb "green";
set style line 4 lt 1 lw 1 lc rgb "red";
set style line 5 lt 1 lw 1 lc rgb "dark-green";
set style line 6 lt 1 lw 1 lc rgb "dark-orange";
set style line 7 lt 1 lw 1 lc rgb "dark-violet";
set style line 8 lt 1 lw 1 lc rgb "orange-red";

if (term_type == 1) set output "cavity_1.ps"
if (term_type == 2) set output "cavity_1.png"
if (term_type == 3) set output "cavity_1.jpg"

set title "Cavity Fundamental Mode: axisData";
set xlabel "z [cm]"; set ylabel "E_{/Symbol \174\174} [MV/m]";
plot file1 using (1e-1*$1):(1e-6*$2) notitle with lines ls 1;

if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_2.ps"
if (term_type == 2) set output "cavity_2.png"
if (term_type == 3) set output "cavity_2.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: EDipole";
set xlabel "r [cm]"; set ylabel "E_{/Symbol \\136} [MV]";
plot file2 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: EQuad";
set xlabel "r [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file5 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity: EFocus1 & EFocus2";
set xlabel "r [cm]"; set ylabel "E_{/Symbol \\136} [MV/m]";
plot file3 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3, \
     file4 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_3.ps"
if (term_type == 2) set output "cavity_3.png"
if (term_type == 3) set output "cavity_3.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: HDipole";
set xlabel "r [cm]"; set ylabel "H_{/Symbol \\136} [A]";
plot file6 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: HMono";
set xlabel "r [cm]"; set ylabel "H_{/Symbol \\136} [A/m]";
plot file7 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity Mode: HQuad";
set xlabel "r [cm]"; set ylabel "H_{/Symbol \\136} [A/m]";
plot file8 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_4.ps"
if (term_type == 2) set output "cavity_4.png"
if (term_type == 3) set output "cavity_4.jpg"

set multiplot;

set size 1.0, 0.5; set origin 0.0, 0.5;
set title "Cavity Thin Lens Model: Longitudinal Kick";
set xlabel "z [cm]"; set ylabel "{/Symbol q}_{/Symbol \174\174} [mrad?]";
set xrange [-13:];
plot file9 using (1e-1*$1):($4) notitle with impulses ls 1;

set origin 0.0, 0.0;
set title "Transverse Kick";
set xlabel "z [cm]"; set ylabel "{/Symbol q}_{/Symbol \\136} [mrad?]";
set xrange [-13:];
plot file9 using (1e-1*$1):($6) axis x1y2 notitle with impulses ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

# Terminal type is: 0 - X11, 1 - PS, 2 - PNG, 3 - JPG
term_type = 0;

# On-axis long. E-field [V/m] vs. z [mm].
file1 = "axisData_41.txt";

# Transverse higher order E-field [V/m] ([V] for dipole) vs. z [mm].
# Dipole.
file2 = "Multipole41/CaviMlp_EDipole_41.txt";
#  First half of defocusing component.
file3 = "Multipole41/CaviMlp_EFocus1_41.txt";
#  Second half of defocusing component.
file4 = "Multipole41/CaviMlp_EFocus2_41.txt";
file5 = "Multipole41/CaviMlp_EQuad_41.txt";

file6 = "Multipole41/CaviMlp_HDipole_41.txt";
file7 = "Multipole41/CaviMlp_HMono_41.txt";
file8 = "Multipole41/CaviMlp_HQuad_41.txt";
file9 = "Multipole41/thinlenlon_41.txt";

if (term_type == 0) set terminal x11;
if (term_type == 1) set terminal postscript landscape enhanced color solid \
  lw 2 "Times-Roman" 15;
#if (term_type == 2) set terminal pngcairo size 350, 262 enhanced \
#  font 'Verdana,10';
if (term_type == 2) set terminal pngcairo enhanced font "Times-Roman";
if (term_type == 3) set terminal jpeg enhanced;

set grid;

set style line 1 lt 1 lw 1 lc rgb "blue";
set style line 2 lt 1 lw 1 lc rgb "cyan";
set style line 3 lt 1 lw 1 lc rgb "green";
set style line 4 lt 1 lw 1 lc rgb "red";
set style line 5 lt 1 lw 1 lc rgb "dark-green";
set style line 6 lt 1 lw 1 lc rgb "dark-orange";
set style line 7 lt 1 lw 1 lc rgb "dark-violet";
set style line 8 lt 1 lw 1 lc rgb "orange-red";

if (term_type == 1) set output "cavity_1.ps"
if (term_type == 2) set output "cavity_1.png"
if (term_type == 3) set output "cavity_1.jpg"

set title "Cavity Fundamental Mode: axisData";
set xlabel "z [cm]"; set ylabel "E_=? [MV/m]";
plot file1 using (1e-1*$1):(1e-6*$2) notitle with lines ls 1;

if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_2.ps"
if (term_type == 2) set output "cavity_2.png"
if (term_type == 3) set output "cavity_2.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: EDipole";
set xlabel "r [cm]"; set ylabel "E_{perp}? [MV]";
plot file2 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity: EFocus1";
set xlabel "r [cm]"; set ylabel "E_{perp}? [MV/m]";
plot file3 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity: EFocus2";
set xlabel "r [cm]"; set ylabel "E_{perp}? [MV/m]";
plot file4 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

set origin 0.5, 0.0;
set title "Cavity Mode: EQuad";
set xlabel "r [cm]"; set ylabel "E_{perp}? [MV/m]";
plot file5 using (1e-1*$1):(1e-6*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_3.ps"
if (term_type == 2) set output "cavity_3.png"
if (term_type == 3) set output "cavity_3.jpg"

set multiplot;

set size 0.5, 0.5; set origin 0.0, 0.5;
set title "Cavity Mode: HDipole";
set xlabel "r [cm]"; set ylabel "E_{perp}? [kV?]";
plot file6 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.5, 0.5;
set title "Cavity Mode: HMono";
set xlabel "r [cm]"; set ylabel "E_{perp}? [kV?]";
plot file7 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

set origin 0.0, 0.0;
set title "Cavity Mode: HQuad";
set xlabel "r [cm]"; set ylabel "E_{perp}? [kV?]";
plot file8 using (1e-1*$1):(1e-3*$2) notitle with lines ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";

if (term_type == 1) set output "cavity_4.ps"
if (term_type == 2) set output "cavity_4.png"
if (term_type == 3) set output "cavity_4.jpg"

set multiplot;

set size 1.0, 0.5; set origin 0.0, 0.5;
set title "Cavity Thin Lens Model: Longitudinal Kick";
set xlabel "z [cm]"; set ylabel "{/Symbol q}_=? [mrad?]";
set xrange [-13:];
plot file9 using (1e-1*$1):($4) notitle with impulses ls 1;

set origin 0.0, 0.0;
set title "Transverse Kick";
set xlabel "z [cm]"; set ylabel "{/Symbol q}_=? [mrad?]";
set xrange [-13:];
plot file9 using (1e-1*$1):($6) axis x1y2 notitle with impulses ls 3;

unset multiplot;
if (term_type == 0) pause mouse "click on graph to cont.\n";


Good!

Good!

#!/usr/bin/env gnuplot
set term postscript enhanced color 20

set log xy
se gri
set out "benchmark-stream-xeon.eps"
set xlabel "memory footprint(MB)"
set ylabel "load bandwidth (GB/s)"
set arrow from 40,10 to 40,1000 nohead lc 2
set arrow from 4,10 to 4,1000 nohead lc 2
set label 1 at first 100,12 "Memory"
set label 3 at first 10,12 "L3"
set label 2 at first 1,12 "L2"
plot 'benchmark-stream-xeon.txt' u (8*$1/2**20):(2*$4) lw 2 ps 4 t ""

#!/usr/bin/env gnuplot
set term postscript enhanced color 20

set log xy
se gri
set out "benchmark-stream-xeon.eps"
set xlabel "memory footprint(MB)"
set ylabel "load bandwidth (GB/s)"
set arrow from 40,10 to 40,1000 nohead lc 2
set arrow from 4,10 to 4,1000 nohead lc 2
set label 1 at first 100,12 "Memory"
set label 3 at first 10,12 "L3"
set label 2 at first 1,12 "L2"
plot 'benchmark-stream-xeon.txt' u (4*$1/2**20):(2*$4) lw 2 ps 4 t ""


minor detial enegy plt

minor detial enegy plt


Adjusting titile

Adjusting titile

#!/usr/bin/gnuplot -persist
#
#
#    	G N U P L O T
#    	Version 5.0 patchlevel 3    last modified 2016-02-21
#
#    	Copyright (C) 1986-1993, 1998, 2004, 2007-2016
#    	Thomas Williams, Colin Kelley and many others
#
#    	gnuplot home:     http://www.gnuplot.info
#    	faq, bugs, etc:   type "help FAQ"
#    	immediate help:   type "help"  (plot window: hit 'h')
GNUTERM = "qt"
# set terminal qt 0 size 500, 300 enhanced font "serif,10" persist
set terminal pdfcairo enhanced mono size 3.5in, 2.62in font "serif, 10"
set style line 1 linecolor rgb "#0060ad" linewidth 1.500 dashtype solid pointtype 7 pointsize 0.55 pointinterval 0
set style line 2 linecolor rgb "#0060ad" linewidth 0.500 dashtype solid pointtype 7 pointsize 0.55 pointinterval 0
set xlabel  font "serif,12"
set ylabel  font "serif,12"
set xtics nomirror
set ytics nomirror
set border 3
set grid x y
unset logscale
unset contour
unset key
set output "init_time_graph.pdf"
# set title "Playback Start Time"
set title
set xlabel "Simultaneous video streams being served"
set ylabel "Video startup time (ms)"
set xrange [ 0.750000 : 9.25000 ] noreverse nowriteback
set yrange [ 0.00000 : 1200.00 ] noreverse nowriteback
plot "gnuplot.txt" using 1:2:3 w yerrorbars ls 2, '' using 1:2 w lines ls 1
# EOF

#!/usr/bin/gnuplot -persist
#
#
#    	G N U P L O T
#    	Version 5.0 patchlevel 3    last modified 2016-02-21
#
#    	Copyright (C) 1986-1993, 1998, 2004, 2007-2016
#    	Thomas Williams, Colin Kelley and many others
#
#    	gnuplot home:     http://www.gnuplot.info
#    	faq, bugs, etc:   type "help FAQ"
#    	immediate help:   type "help"  (plot window: hit 'h')
GNUTERM = "qt"
# set terminal qt 0 size 500, 300 enhanced font "serif,10" persist
set terminal pdfcairo enhanced mono size 3.5in, 2.62in font "serif, 10"
set style line 1 linecolor rgb "#0060ad" linewidth 1.500 dashtype solid pointtype 7 pointsize 0.55 pointinterval 0
set style line 2 linecolor rgb "#0060ad" linewidth 0.500 dashtype solid pointtype 7 pointsize 0.55 pointinterval 0
set xlabel  font "serif,12"
set ylabel  font "serif,12"
set xtics nomirror
set ytics nomirror
set border 3
set grid x y
unset logscale
unset contour
unset key
set output "init_time_graph.pdf"
# set title "Video Startup Time"
set title
set xlabel "Simultaneous video streams being served"
set ylabel "Video startup time (ms)"
set xrange [ 0.750000 : 9.25000 ] noreverse nowriteback
set yrange [ 0.00000 : 1200.00 ] noreverse nowriteback
plot "gnuplot.txt" using 1:2:3 w yerrorbars ls 2, '' using 1:2 w lines ls 1
# EOF


Update plots.

Update plots.

# Note you need gnuplot 4.4 for the pdfcairo terminal.

# set terminal pdfcairo font "Gill Sans,9" linewidth 4 rounded fontscale 1.0
set terminal pdfcairo font "Gill Sans,7" linewidth 1 rounded fontscale 0.8

set border 3 front linewidth 1.000
set boxwidth 0.8 absolute
set style fill   solid 1.00 noborder
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault   lt 0 linewidth 0.500,  lt 0 linewidth 0.500
set key bmargin center horizontal Left reverse noenhanced autotitle columnhead nobox maxcols 2 maxrows 1
set style histogram rowstacked title textcolor lt -1 offset character 2, 0.25, 0
set style data histograms
set cbtics border in scale 0,0 mirror norotate  autojustify
set rtics axis in scale 0,0 nomirror norotate  autojustify
set title "Advertisement Impression Counter"
set xlabel "(Client Number)"
set xlabel  offset character 0, -1, 0 font "" textcolor lt -1 norotate
set ylabel "GB Transmitted"
set yrange [0:*]
set ytics nomirror

##set yrange [ 0.00000 : 900000. ] noreverse nowriteback

set linetype 1 lc rgb "#A00000"
set linetype 2 lc rgb "#2c3e50"
set linetype 3 lc rgb "#5060D0"
set linetype 4 lc rgb "#F25900"
set datafile separator ","
set output outputname
# plot newhistogram "32", inputname using "32_s":xtic(1) t 'State' lc 3, '' u "32_p" t 'Protocol' lc 4, \
#      newhistogram "64", '' u "64_s":xtic(1) t '' lc 3, '' u "64_p" t '' lc 4, \
#      newhistogram "128", '' u "128_s":xtic(1) t '' lc 3, '' u "128_p" t '' lc 4, \
#      newhistogram "256", '' u "256_s":xtic(1) t '' lc 3, '' u "256_p" t '' lc 4, \
#      newhistogram "512", '' u "512_s":xtic(1) t '' lc 3, '' u "512_p" t '' lc 4, \
#      newhistogram "1024", '' u "1024_s":xtic(1) t '' lc 3, '' u "1024_p" t '' lc 4
plot newhistogram "128", inputname u "128_s":xtic(1) t '' lc 3, '' u "128_p" t '' lc 4, \
     newhistogram "256", '' u "256_s":xtic(1) t '' lc 3, '' u "256_p" t '' lc 4, \
     newhistogram "512", '' u "512_s":xtic(1) t '' lc 3, '' u "512_p" t '' lc 4, \
     newhistogram "1024", '' u "1024_s":xtic(1) t '' lc 3, '' u "1024_p" t '' lc 4
# plot newhistogram "32", inputname using "32_s":xtic(1) t 'State' lc 3, '' u "32_p" t 'Protocol' lc 4, \
#      newhistogram "64", '' u "64_s":xtic(1) t '' lc 3, '' u "64_p" t '' lc 4

# Note you need gnuplot 4.4 for the pdfcairo terminal.

# set terminal pdfcairo font "Gill Sans,9" linewidth 4 rounded fontscale 1.0
set terminal pdfcairo font "Gill Sans,7" linewidth 1 rounded fontscale 0.5

set border 3 front linewidth 1.000
set boxwidth 0.8 absolute
set style fill   solid 1.00 noborder
set grid nopolar
set grid noxtics nomxtics ytics nomytics noztics nomztics \
 nox2tics nomx2tics noy2tics nomy2tics nocbtics nomcbtics
set grid layerdefault   lt 0 linewidth 0.500,  lt 0 linewidth 0.500
set key bmargin center horizontal Left reverse noenhanced autotitle columnhead nobox maxcols 2 maxrows 1
set style histogram rowstacked title textcolor lt -1 offset character 2, 0.25, 0
set style data histograms
set cbtics border in scale 0,0 mirror norotate  autojustify
set rtics axis in scale 0,0 nomirror norotate  autojustify
set title "Advertisement Impression Counter"
set xlabel "(Client Number)"
set xlabel  offset character 0, -1, 0 font "" textcolor lt -1 norotate
set ylabel "GB Transmitted"
set yrange [0:*]
##set yrange [ 0.00000 : 900000. ] noreverse nowriteback

set linetype 1 lc rgb "#A00000"
set linetype 2 lc rgb "#2c3e50"
set linetype 3 lc rgb "#5060D0"
set linetype 4 lc rgb "#F25900"
set datafile separator ","
set output outputname
plot newhistogram "32", inputname using "32_s":xtic(1) t 'State' lc 3, '' u "32_p" t 'Protocol' lc 4, \
     newhistogram "64", '' u "64_s":xtic(1) t '' lc 3, '' u "64_p" t '' lc 4, \
     newhistogram "128", '' u "128_s":xtic(1) t '' lc 3, '' u "128_p" t '' lc 4, \
     newhistogram "256", '' u "256_s":xtic(1) t '' lc 3, '' u "256_p" t '' lc 4


added check, not sure if correct

added check, not sure if correct

file_notempty(file) = system("[ -s '".file."' ] && echo '1' || echo '0'") + 0

if( file_notempty(".temp") ) {
    set xrange [400:1000]
    set yrange [0:600000]
    set xlabel 'Wavelength/nm'
    set ylabel 'Arbitrary Intensity /unit'
    pause 0.5
    replot
    reread
} else {
    pause 0.5
    reread
}


add custom LDFLAGS

add custom LDFLAGS

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@2933 4e380d45-d1fd-0310-85a7-d18ec86df0ad

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  make.settings.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2006-2008 Johannes Singler <singler@ira.uka.de>
#  Copyright (C) 2007-2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_MACOSX	?= no	# set 'yes' if you run Mac OS X, 'no' otherwise
USE_FREEBSD	?= no	# set 'yes' if you run FreeBSD, 'no' otherwise
ENABLE_SHARED	?= no   # set 'yes' to build a shared library instead of a static library (EXPERIMENTAL)
USE_PMODE	?= no	# will be overridden from main Makefile
USE_MCSTL	?= no	# will be overridden from main Makefile
USE_ICPC	?= no	# will be overridden from main Makefile

STXXL_ROOT	?= $(TOPDIR)

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_PMODE)),yes)
COMPILER_GCC	?= g++-4.4.x
MODEBASE	?= pmstxxl
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
MODEBASE	?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

ifeq ($(strip $(USE_BOOST)),yes)
#BOOST_ROOT	?= /usr/local/boost-1.34.1
LIBEXTRA	?= _boost
endif

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT_LEVEL	?= 3
OPT		?= -O$(OPT_LEVEL) # compiler optimization level
WARNINGS	?= -W -Wall -Woverloaded-virtual -Wundef
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBBASE		?= stxxl
LIBEXTRA	?=
MODEBASE	?= stxxl

LIBNAME		?= $(LIBBASE)$(LIBEXTRA)
MODENAME	?= $(MODEBASE)$(LIBEXTRA)

# Hint: for g++-4.4 with c++0x support, enable the following:
#STXXL_SPECIFIC	+= -std=c++0x

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.

#### You usually shouldn't need to change the sections below #####

#### MACOSX CONFIGURATION ########################################

ifeq ($(strip $(USE_MACOSX)),yes)

PTHREAD_FLAG	?=

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### FREEBSD CONFIGURATION #######################################

ifeq ($(strip $(USE_FREEBSD)),yes)

PTHREAD_FLAG	?= -pthread

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### LINUX (DEFAULT) CONFIGURATION ###############################

PTHREAD_FLAG	?= -pthread

# get a unique identifier for a file or directory,
# e.g. device number + inode number
GET_FILE_ID	?= stat -L -c '%d:%i' $1

##################################################################

#### SHARED LIBRARY ###############################################

ifeq ($(strip $(ENABLE_SHARED)),yes)

LIBEXT	?= so
LIBGEN	?= false  # see lib/GNUmakefile
STXXL_LIBRARY_SPECIFIC	+= -fPIC

endif

###################################################################

#### STXXL CONFIGURATION #########################################

# create make.settings.local in the root directory
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifeq (,$(STXXL_AUTOCONFIG))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
endif
cmt	= \#
$(shell echo '$(cmt)STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '$(cmt)MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.2' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.4 -std=c++0x' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)USE_BOOST	 = no' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)BOOST_ROOT	 = ' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell echo 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
ifeq (FreeBSD,$(strip $(shell uname)))
$(shell echo 'USE_FREEBSD	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_FREEBSD	 = no' >> $(CURDIR)/make.settings.local)
endif
include make.settings.local
endif
endif

# check, whether stxxl is configured correctly
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
$(warning *** WARNING: Please check make.settings.local)
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell $(call GET_FILE_ID, ./))
stat2	 = $(shell $(call GET_FILE_ID, $(STXXL_ROOT)/))

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

##################################################################

#### STXXL OPTIONS ###############################################

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-I$(strip $(STXXL_ROOT))/include \
	-include stxxl/bits/defines.h \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

STXXL_LIBRARY_SPECIFIC	+= -D_IN_LIBSTXXL

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### PARALLEL_MODE OPTIONS ###############################################

ifeq ($(strip $(USE_PMODE)),yes)

OPENMPFLAG			?= -fopenmp

PARALLEL_MODE_CPPFLAGS		+= $(OPENMPFLAG) -D_GLIBCXX_PARALLEL
PARALLEL_MODE_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_INCLUDE			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/include)
BOOST_COMPILER_OPTIONS		+= $(foreach inc,$(BOOST_INCLUDE),-I$(inc))
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_CONFIG
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_FILESYSTEM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_RANDOM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_THREADS
#BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_TIMESTAMP   # probably less efficient than gettimeofday()

BOOST_LIB_PATH			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/lib)
BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	$(foreach lib,$(BOOST_LIB_PATH),-L$(lib)) \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_system$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS #############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h
HEADER_FILES_BITS	+= compat_unique_ptr.h parallel.h singleton.h defines.h
HEADER_FILES_BITS	+= verbose.h unused.h compat_type_traits.h
HEADER_FILES_BITS	+= msvc_compatibility.h deprecated.h libstxxl.h

HEADER_FILES_COMMON	+= aligned_alloc.h new_alloc.h
HEADER_FILES_COMMON	+= mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h error_handling.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h tuple.h
HEADER_FILES_COMMON	+= types.h settings.h seed.h is_sorted.h exithandler.h

HEADER_FILES_IO		+= io.h iostats.h completion_handler.h
HEADER_FILES_IO		+= request.h request_waiters_impl_basic.h
HEADER_FILES_IO		+= request_state_impl_basic.h request_impl_basic.h
HEADER_FILES_IO		+= disk_queues.h
HEADER_FILES_IO		+= request_queue.h request_queue_impl_worker.h
HEADER_FILES_IO		+= request_queue_impl_qwqr.h
HEADER_FILES_IO		+= request_queue_impl_1q.h
HEADER_FILES_IO		+= file.h disk_queued_file.h
HEADER_FILES_IO		+= ufs_file_base.h syscall_file.h mmap_file.h simdisk_file.h
HEADER_FILES_IO		+= wfs_file_base.h wincall_file.h
HEADER_FILES_IO		+= boostfd_file.h mem_file.h fileperblock_file.h
HEADER_FILES_IO		+= wbtl_file.h
HEADER_FILES_IO		+= create_file.h

HEADER_FILES_MNG	+= adaptor.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= bid.h typed_block.h diskallocator.h config.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h read_write_pool.h
HEADER_FILES_MNG	+= block_alloc.h block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h
#EADER_FILES_CONTAINERS	+= pq_helpers.h pq_mergers.h pq_ext_merger.h
#EADER_FILES_CONTAINERS	+= pq_losertree.h
HEADER_FILES_CONTAINERS	+= queue.h map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h ksort.h sort_base.h sort_helper.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h
HEADER_FILES_STREAM	+= choose.h unique.h
HEADER_FILES_STREAM	+= sorted_runs.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

# extension of object files
OBJEXT		?= $(MODENAME).o
# extension of object files for the library
LIBOBJEXT	?= lib$(LIBNAME).o
IIEXT		?= $(MODENAME).ii
# static library file extension
LIBEXT		?= a
# executable file extension
EXEEXT		?= $(MODENAME).bin
# static library generation
LIBGEN		?= ar cr
# output file option for the compiler and linker
OUT		?= -o

o	?= $(strip $(OBJEXT))
lo	?= $(strip $(LIBOBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

define COMPILE_STXXL
	@$(RM) $@ $(@:.o=).d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $(@:.o=).dT -c $(OUTPUT_OPTION) $< && mv $(@:.o=).dT $(@:.o=).d
endef

DEPS_MAKEFILES		:= $(wildcard $(TOPDIR)/Makefile.subdir.gnu $(TOPDIR)/make.settings $(TOPDIR)/make.settings.local GNUmakefile Makefile Makefile.common Makefile.local)
EXTRA_DEPS_COMPILE	?= $(DEPS_MAKEFILES)
%.$o: %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(lo): PARALLEL_MODE_CPPFLAGS=
%.$(lo): MCSTL_CPPFLAGS=
%.$(lo): STXXL_COMPILER_OPTIONS += $(STXXL_LIBRARY_SPECIFIC)
%.$(lo): o=$(lo)
%.$(lo): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(ii): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

# $1=infix $2=additional CPPFLAGS
define COMPILE_VARIANT
%.$1.$$o: CPPFLAGS += $2
%.$1.$$o: %.cpp $$(EXTRA_DEPS_COMPILE)
	$$(COMPILE_STXXL)
endef

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

# last resort rules to ignore header files missing due to renames etc.
$(STXXL_ROOT)/include/%::
	@echo "MISSING HEADER: '$@' (ignored)"

%.h::
	@echo "MISSING HEADER: '$@' (ignored)"

/%::
	@echo "MISSING FILE:   '$@' (ignored)"

###################################################################

STXXL_SPECIFIC		+= $(STXXL_EXTRA)
WARNINGS		+= $(WARNINGS_EXTRA)

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_PMODE)),yes)
STXXL_COMPILER_OPTIONS	+= $(PARALLEL_MODE_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(PARALLEL_MODE_LDFLAGS)
endif

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(LDFLAGS)

# vim: syn=make

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  make.settings.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2006-2008 Johannes Singler <singler@ira.uka.de>
#  Copyright (C) 2007-2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= $(error TOPDIR not defined) # DO NOT CHANGE! This is set elsewhere.

# Change this file according to your paths.

# Instead of modifying this file, you could also set your modified variables
# in make.settings.local (needs to be created first).
-include $(TOPDIR)/make.settings.local

USE_BOOST	?= no	# set 'yes' to use Boost libraries or 'no' to not use Boost libraries
USE_MACOSX	?= no	# set 'yes' if you run Mac OS X, 'no' otherwise
USE_FREEBSD	?= no	# set 'yes' if you run FreeBSD, 'no' otherwise
ENABLE_SHARED	?= no   # set 'yes' to build a shared library instead of a static library (EXPERIMENTAL)
USE_PMODE	?= no	# will be overridden from main Makefile
USE_MCSTL	?= no	# will be overridden from main Makefile
USE_ICPC	?= no	# will be overridden from main Makefile

STXXL_ROOT	?= $(TOPDIR)

ifeq ($(strip $(USE_ICPC)),yes)
COMPILER_ICPC	?= icpc
COMPILER	?= $(COMPILER_ICPC)
#ICPC_GCC	?= gcc-x.y    # override the gcc/g++ used to find headers and libraries
WARNINGS	?= -Wall -w1 -openmp-report0 -vec-report0
endif

ifeq ($(strip $(USE_PMODE)),yes)
COMPILER_GCC	?= g++-4.4.x
MODEBASE	?= pmstxxl
endif

ifeq ($(strip $(USE_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
MODEBASE	?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

ifeq ($(strip $(USE_BOOST)),yes)
#BOOST_ROOT	?= /usr/local/boost-1.34.1
LIBEXTRA	?= _boost
endif

COMPILER_GCC	?= g++
COMPILER	?= $(COMPILER_GCC)
LINKER		?= $(COMPILER)
OPT_LEVEL	?= 3
OPT		?= -O$(OPT_LEVEL) # compiler optimization level
WARNINGS	?= -W -Wall -Woverloaded-virtual -Wundef
DEBUG		?= # put here -g option to include the debug information into the binaries

LIBBASE		?= stxxl
LIBEXTRA	?=
MODEBASE	?= stxxl

LIBNAME		?= $(LIBBASE)$(LIBEXTRA)
MODENAME	?= $(MODEBASE)$(LIBEXTRA)

# Hint: for g++-4.4 with c++0x support, enable the following:
#STXXL_SPECIFIC	+= -std=c++0x

#### TROUBLESHOOTING
#
# For automatical checking of order of the output elements in
# the sorters: stxxl::stream::sort, stxxl::stream::merge_runs,
# stxxl::sort, and stxxl::ksort use
#
#STXXL_SPECIFIC	+= -DSTXXL_CHECK_ORDER_IN_SORTS
#
# If your program aborts with message "read/write: wrong parameter"
# or "Invalid argument"
# this could be that your kernel does not support direct I/O
# then try to set it off recompiling the libs and your code with option
#
#STXXL_SPECIFIC	+= -DSTXXL_DIRECT_IO_OFF
#
# But for the best performance it is strongly recommended
# to reconfigure the kernel for the support of the direct I/O.

#### You usually shouldn't need to change the sections below #####

#### MACOSX CONFIGURATION ########################################

ifeq ($(strip $(USE_MACOSX)),yes)

PTHREAD_FLAG	?=

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### FREEBSD CONFIGURATION #######################################

ifeq ($(strip $(USE_FREEBSD)),yes)

PTHREAD_FLAG	?= -pthread

GET_FILE_ID	?= stat -L -f '%d:%i' $1

endif

##################################################################

#### LINUX (DEFAULT) CONFIGURATION ###############################

PTHREAD_FLAG	?= -pthread

# get a unique identifier for a file or directory,
# e.g. device number + inode number
GET_FILE_ID	?= stat -L -c '%d:%i' $1

##################################################################

#### SHARED LIBRARY ###############################################

ifeq ($(strip $(ENABLE_SHARED)),yes)

LIBEXT	?= so
LIBGEN	?= false  # see lib/GNUmakefile
STXXL_LIBRARY_SPECIFIC	+= -fPIC

endif

###################################################################

#### STXXL CONFIGURATION #########################################

# create make.settings.local in the root directory
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifeq (,$(STXXL_AUTOCONFIG))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
endif
cmt	= \#
$(shell echo '$(cmt)STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '$(cmt)MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.2' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_GCC	 = g++-4.4 -std=c++0x' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)USE_BOOST	 = no' >> $(CURDIR)/make.settings.local)
$(shell echo '$(cmt)BOOST_ROOT	 = ' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell echo 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
ifeq (FreeBSD,$(strip $(shell uname)))
$(shell echo 'USE_FREEBSD	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '$(cmt)USE_FREEBSD	 = no' >> $(CURDIR)/make.settings.local)
endif
include make.settings.local
endif
endif

# check, whether stxxl is configured correctly
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
$(warning *** WARNING: Please check make.settings.local)
$(error ERROR: could not find a STXXL installation in STXXL_ROOT=$(STXXL_ROOT))
endif

# in the top dir, check whether STXXL_ROOT points to ourselves
ifneq (,$(wildcard make.settings))
stat1	 = $(shell $(call GET_FILE_ID, ./))
stat2	 = $(shell $(call GET_FILE_ID, $(STXXL_ROOT)/))

ifneq ($(stat1),$(stat2))
$(error ERROR: STXXL_ROOT=$(STXXL_ROOT) points to a different STXXL installation)
endif
endif

##################################################################

#### STXXL OPTIONS ###############################################

STXXL_SPECIFIC	+= \
	$(PTHREAD_FLAG) \
	$(CPPFLAGS_ARCH) \
	-I$(strip $(STXXL_ROOT))/include \
	-include stxxl/bits/defines.h \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE

STXXL_LIBRARY_SPECIFIC	+= -D_IN_LIBSTXXL

STXXL_LDFLAGS	+= $(PTHREAD_FLAG)
STXXL_LDLIBS	+= -L$(strip $(STXXL_ROOT))/lib -l$(LIBNAME)

STXXL_LIBDEPS	+= $(strip $(STXXL_ROOT))/lib/lib$(LIBNAME).$(LIBEXT)

UNAME_M		:= $(shell uname -m)
CPPFLAGS_ARCH	+= $(CPPFLAGS_$(UNAME_M))
CPPFLAGS_i686	?= -march=i686

##################################################################

#### ICPC OPTIONS ################################################

ifeq ($(strip $(USE_ICPC)),yes)

OPENMPFLAG	?= -openmp

ICPC_CPPFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))
ICPC_LDFLAGS	+= $(if $(ICPC_GCC),-gcc-name=$(strip $(ICPC_GCC)))

STXXL_SPECIFIC	+= -include bits/intel_compatibility.h

endif

##################################################################

#### PARALLEL_MODE OPTIONS ###############################################

ifeq ($(strip $(USE_PMODE)),yes)

OPENMPFLAG			?= -fopenmp

PARALLEL_MODE_CPPFLAGS		+= $(OPENMPFLAG) -D_GLIBCXX_PARALLEL
PARALLEL_MODE_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### MCSTL OPTIONS ###############################################

ifeq ($(strip $(USE_MCSTL)),yes)

OPENMPFLAG	?= -fopenmp

ifeq (,$(strip $(wildcard $(strip $(MCSTL_ROOT))/c++/mcstl.h)))
$(error ERROR: could not find a MCSTL installation in MCSTL_ROOT=$(MCSTL_ROOT))
endif

MCSTL_CPPFLAGS		+= $(OPENMPFLAG) -D__MCSTL__ -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

endif

##################################################################

#### BOOST OPTIONS ###############################################

BOOST_INCLUDE			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/include)
BOOST_COMPILER_OPTIONS		+= $(foreach inc,$(BOOST_INCLUDE),-I$(inc))
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_CONFIG
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_FILESYSTEM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_RANDOM
BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_THREADS
#BOOST_COMPILER_OPTIONS		+= -DSTXXL_BOOST_TIMESTAMP   # probably less efficient than gettimeofday()

BOOST_LIB_PATH			?= $(if $(strip $(BOOST_ROOT)),$(strip $(BOOST_ROOT))/lib)
BOOST_LIB_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	$(foreach lib,$(BOOST_LIB_PATH),-L$(lib)) \
	-lboost_thread$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_date_time$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_iostreams$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_system$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX) \
	-lboost_filesystem$(BOOST_LIB_COMPILER_SUFFIX)$(BOOST_LIB_MT_SUFFIX)

##################################################################

#### CPPUNIT OPTIONS #############################################

CPPUNIT_COMPILER_OPTIONS	+=

CPPUNIT_LINKER_OPTIONS		+= -lcppunit -ldl

##################################################################

#### DEPENDENCIES ################################################

HEADER_FILES_BITS	+= namespace.h noncopyable.h version.h
HEADER_FILES_BITS	+= compat_hash_map.h
HEADER_FILES_BITS	+= compat_unique_ptr.h parallel.h singleton.h defines.h
HEADER_FILES_BITS	+= verbose.h unused.h compat_type_traits.h
HEADER_FILES_BITS	+= msvc_compatibility.h deprecated.h libstxxl.h

HEADER_FILES_COMMON	+= aligned_alloc.h new_alloc.h
HEADER_FILES_COMMON	+= mutex.h rand.h semaphore.h state.h
HEADER_FILES_COMMON	+= timer.h utils.h error_handling.h simple_vector.h
HEADER_FILES_COMMON	+= switch.h tmeta.h log.h exceptions.h tuple.h
HEADER_FILES_COMMON	+= types.h settings.h seed.h is_sorted.h exithandler.h

HEADER_FILES_IO		+= io.h iostats.h completion_handler.h
HEADER_FILES_IO		+= request.h request_waiters_impl_basic.h
HEADER_FILES_IO		+= request_state_impl_basic.h request_impl_basic.h
HEADER_FILES_IO		+= disk_queues.h
HEADER_FILES_IO		+= request_queue.h request_queue_impl_worker.h
HEADER_FILES_IO		+= request_queue_impl_qwqr.h
HEADER_FILES_IO		+= request_queue_impl_1q.h
HEADER_FILES_IO		+= file.h disk_queued_file.h
HEADER_FILES_IO		+= ufs_file_base.h syscall_file.h mmap_file.h simdisk_file.h
HEADER_FILES_IO		+= wfs_file_base.h wincall_file.h
HEADER_FILES_IO		+= boostfd_file.h mem_file.h fileperblock_file.h
HEADER_FILES_IO		+= wbtl_file.h
HEADER_FILES_IO		+= create_file.h

HEADER_FILES_MNG	+= adaptor.h block_prefetcher.h
HEADER_FILES_MNG	+= buf_istream.h buf_ostream.h buf_writer.h mng.h
HEADER_FILES_MNG	+= bid.h typed_block.h diskallocator.h config.h
HEADER_FILES_MNG	+= write_pool.h prefetch_pool.h read_write_pool.h
HEADER_FILES_MNG	+= block_alloc.h block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h
#EADER_FILES_CONTAINERS	+= pq_helpers.h pq_mergers.h pq_ext_merger.h
#EADER_FILES_CONTAINERS	+= pq_losertree.h
HEADER_FILES_CONTAINERS	+= queue.h map.h deque.h

HEADER_FILES_CONTAINERS_BTREE	+= btree.h iterator_map.h leaf.h node_cache.h
HEADER_FILES_CONTAINERS_BTREE	+= root_node.h node.h btree_pager.h iterator.h

HEADER_FILES_ALGO	+= adaptor.h inmemsort.h intksort.h run_cursor.h sort.h
HEADER_FILES_ALGO	+= async_schedule.h ksort.h sort_base.h sort_helper.h
HEADER_FILES_ALGO	+= losertree.h scan.h stable_ksort.h random_shuffle.h

HEADER_FILES_STREAM	+= stream.h sort_stream.h
HEADER_FILES_STREAM	+= choose.h unique.h
HEADER_FILES_STREAM	+= sorted_runs.h

HEADER_FILES_UTILS	+= malloc.h

###################################################################

#### MISC #########################################################

# extension of object files
OBJEXT		?= $(MODENAME).o
# extension of object files for the library
LIBOBJEXT	?= lib$(LIBNAME).o
IIEXT		?= $(MODENAME).ii
# static library file extension
LIBEXT		?= a
# executable file extension
EXEEXT		?= $(MODENAME).bin
# static library generation
LIBGEN		?= ar cr
# output file option for the compiler and linker
OUT		?= -o

o	?= $(strip $(OBJEXT))
lo	?= $(strip $(LIBOBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

###################################################################

#### COMPILE/LINK RULES ###########################################

define COMPILE_STXXL
	@$(RM) $@ $(@:.o=).d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $(@:.o=).dT -c $(OUTPUT_OPTION) $< && mv $(@:.o=).dT $(@:.o=).d
endef

DEPS_MAKEFILES		:= $(wildcard $(TOPDIR)/Makefile.subdir.gnu $(TOPDIR)/make.settings $(TOPDIR)/make.settings.local GNUmakefile Makefile Makefile.common Makefile.local)
EXTRA_DEPS_COMPILE	?= $(DEPS_MAKEFILES)
%.$o: %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(lo): PARALLEL_MODE_CPPFLAGS=
%.$(lo): MCSTL_CPPFLAGS=
%.$(lo): STXXL_COMPILER_OPTIONS += $(STXXL_LIBRARY_SPECIFIC)
%.$(lo): o=$(lo)
%.$(lo): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILE_STXXL)

%.$(ii): %.cpp $(EXTRA_DEPS_COMPILE)
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -E $(OUTPUT_OPTION) $<

# $1=infix $2=additional CPPFLAGS
define COMPILE_VARIANT
%.$1.$$o: CPPFLAGS += $2
%.$1.$$o: %.cpp $$(EXTRA_DEPS_COMPILE)
	$$(COMPILE_STXXL)
endef

LINK_STXXL	 = $(LINKER) $1 $(STXXL_LINKER_OPTIONS) -o $@

%.$(bin): %.$o $(STXXL_LIBDEPS)
	$(call LINK_STXXL, $<)

# last resort rules to ignore header files missing due to renames etc.
$(STXXL_ROOT)/include/%::
	@echo "MISSING HEADER: '$@' (ignored)"

%.h::
	@echo "MISSING HEADER: '$@' (ignored)"

/%::
	@echo "MISSING FILE:   '$@' (ignored)"

###################################################################

STXXL_SPECIFIC		+= $(STXXL_EXTRA)
WARNINGS		+= $(WARNINGS_EXTRA)

ifeq ($(strip $(USE_ICPC)),yes)
STXXL_CPPFLAGS_CXX	+= $(ICPC_CPPFLAGS)
STXXL_LDLIBS_CXX	+= $(ICPC_LDFLAGS)
endif

STXXL_COMPILER_OPTIONS	+= $(STXXL_CPPFLAGS_CXX)
STXXL_COMPILER_OPTIONS	+= $(STXXL_SPECIFIC)
STXXL_COMPILER_OPTIONS	+= $(OPT) $(DEBUG) $(WARNINGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS_CXX)
STXXL_LINKER_OPTIONS	+= $(DEBUG)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDFLAGS)
STXXL_LINKER_OPTIONS	+= $(STXXL_LDLIBS)

ifeq ($(strip $(USE_PMODE)),yes)
STXXL_COMPILER_OPTIONS	+= $(PARALLEL_MODE_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(PARALLEL_MODE_LDFLAGS)
endif

ifeq ($(strip $(USE_MCSTL)),yes)
STXXL_COMPILER_OPTIONS	+= $(MCSTL_CPPFLAGS)
STXXL_LINKER_OPTIONS	+= $(MCSTL_LDFLAGS)
endif

ifeq ($(strip $(USE_BOOST)),yes)
STXXL_COMPILER_OPTIONS	+= $(BOOST_COMPILER_OPTIONS)
STXXL_LINKER_OPTIONS	+= $(BOOST_LINKER_OPTIONS)
endif

STXXL_COMPILER_OPTIONS	+= $(CPPFLAGS)

# vim: syn=make


Added flags

Added flags

  -Wdeclaration-after-statement -Wnested-externs

for developer compiling of runtime sources to catch C++ism and nested
externs.

git-svn-id: 88467cb1fb04b8a755be7e1ee1026be4190196ef@8567 3a8e244f-b0f2-452b-bcba-4c88e055c3ca

#
# settings for gnu-compatible platforms
#

#
# Tools
#
CXX = g++
CC = gcc
MAKEDEPEND = $(CXX) -MM -MG
CMAKEDEPEND = $(CC) -MM -MG

#
# General Flags
#

ifdef CHPL_GCOV
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs
endif

ifdef DEBUG
CFLAGS += -g
endif

ifdef OPTIMIZE
CFLAGS += -O2
endif

ifdef PROFILE
CFLAGS += -pg
LDFLAGS += -pg
endif

ifdef CHPL_DEVELOPER
CFLAGS += -Wall -Werror
endif

#
# Flags for compiler, runtime, and generated code
#

COMP_CFLAGS = $(CFLAGS)
RUNTIME_CFLAGS = $(CFLAGS)
GEN_CFLAGS =

ifdef CHPL_DEVELOPER
RUNTIME_CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wdeclaration-after-statement -Wnested-externs
endif

#
# settings for gnu-compatible platforms
#

#
# Tools
#
CXX = g++
CC = gcc
MAKEDEPEND = $(CXX) -MM -MG
CMAKEDEPEND = $(CC) -MM -MG

#
# General Flags
#

ifdef CHPL_GCOV
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -fprofile-arcs
endif

ifdef DEBUG
CFLAGS += -g
endif

ifdef OPTIMIZE
CFLAGS += -O2
endif

ifdef PROFILE
CFLAGS += -pg
LDFLAGS += -pg
endif

ifdef CHPL_DEVELOPER
CFLAGS += -Wall -Werror
endif

#
# Flags for compiler, runtime, and generated code
#

COMP_CFLAGS = $(CFLAGS)
RUNTIME_CFLAGS = $(CFLAGS)
GEN_CFLAGS =

ifdef CHPL_DEVELOPER
RUNTIME_CFLAGS += -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
endif


stxxl.mk: '=' alignment

stxxl.mk: '=' alignment

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@1557 4e380d45-d1fd-0310-85a7-d18ec86df0ad

# This -*- Makefile -*- is intended for processing with GNU make.

############################################################################
#  Makefile.gnu
#
#  Part of the STXXL. See http://stxxl.sourceforge.net
#
#  Copyright (C) 2002-2007 Roman Dementiev <dementiev@mpi-sb.mpg.de>
#  Copyright (C) 2007-2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
#
#  Distributed under the Boost Software License, Version 1.0.
#  (See accompanying file LICENSE_1_0.txt or copy at
#  http://www.boost.org/LICENSE_1_0.txt)
############################################################################

TOPDIR	?= $(CURDIR)

main: library

include make.settings

SUBDIRS	= common io mng containers algo stream lib utils

SUBDIRS-lib: $(SUBDIRS:%=lib-in-%)
SUBDIRS-tests: $(SUBDIRS:%=tests-in-%)
SUBDIRS-clean: $(SUBDIRS:%=clean-in-%)

# compute STXXL_CPPFLAGS/STXXL_LDLIBS for stxxl.mk
# don't include optimization, warning and debug flags
stxxl_mk_cppflags	+= $(STXXL_CPPFLAGS_CXX)
stxxl_mk_ldlibs		+= $(STXXL_LDLIBS_CXX)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_STXXL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_STXXL)
ifeq ($(strip $(USE_PMODE)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_PARALLEL_MODE)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_PARALLEL_MODE)
endif
ifeq ($(strip $(USE_MCSTL)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_MCSTL)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_MCSTL)
endif
ifeq ($(strip $(USE_BOOST)),yes)
stxxl_mk_cppflags	+= $$(STXXL_CPPFLAGS_BOOST)
stxxl_mk_ldlibs		+= $$(STXXL_LDLIBS_BOOST)
endif

# dummy target for initial creation of make.settings.local
config:

lib-in-lib:
	@# nothing to compile
lib-in-%:
	$(MAKE) -C $* lib

build-lib: SUBDIRS-lib
	$(MAKE) -C lib
	$(MAKE) -C common tools
	$(MAKE) -C utils tools

$(LIBNAME).stamp: build-lib
	$(RM) $@ $(LIBNAME).mk.tmp
	echo 'STXXL_CXX			 = $(COMPILER)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS			 = $(stxxl_mk_cppflags)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS			 = $(stxxl_mk_ldlibs)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_STXXL		 = $(STXXL_SPECIFIC)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_STXXL		 = $(STXXL_LDFLAGS) $(STXXL_LDLIBS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LIBDEPS			 = $(STXXL_LIBDEPS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_PARALLEL_MODE	 = $(PARALLEL_MODE_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_PARALLEL_MODE	 = $(PARALLEL_MODE_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_MCSTL		 = $(MCSTL_CPPFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_MCSTL		 = $(MCSTL_LDFLAGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_CPPFLAGS_BOOST		 = $(BOOST_COMPILER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_LDLIBS_BOOST		 = $(BOOST_LINKER_OPTIONS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_WARNFLAGS			 = $(WARNINGS)'	>> $(LIBNAME).mk.tmp
	echo 'STXXL_DEBUGFLAGS		 = $(DEBUG)'	>> $(LIBNAME).mk.tmp
	cmp -s $(LIBNAME).mk.tmp $(LIBNAME).mk || mv $(LIBNAME).mk.tmp $(LIBNAME).mk
	$(RM) $(LIBNAME).mk.tmp
	touch $@

library: $(LIBNAME).stamp

# skip recompilation of existing library
library-fast:
ifeq (,$(wildcard lib/lib$(LIBNAME).$(LIBEXT)))
library-fast: library
endif

ifneq (,$(wildcard .svn))
lib-in-common: common/version_svn.defs

GET_SVNVERSION		?= LC_ALL=POSIX svnversion $(realpath $1)
GET_SVN_INFO		?= LC_ALL=POSIX svn info $(realpath $1)
GET_SVN_INFO_SED	?= sed
GET_SVN_INFO_DATE	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Date/{' -e 's/.*: //' -e 's/ .*//' -e 's/-//g' -e 'p' -e '}'
GET_SVN_INFO_REV	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/Last Changed Rev/s/.*: //p'
GET_SVN_INFO_BRANCH	?= $(call GET_SVN_INFO, $1) | $(GET_SVN_INFO_SED) -n -e '/URL/{' -e 's/.*\/svnroot\/stxxl//' -e '/branches/s/\/branches\///p' -e '}'

STXXL_SVN_BRANCH	:= $(shell $(call GET_SVN_INFO_BRANCH, .))

ifeq (,$(strip $(shell svnversion . | tr -d 0-9)))
# clean checkout - use svn info
STXXL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, .))
STXXL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, .))
else
# modified, mixed, ... checkout - use svnversion and today
STXXL_VERSION_DATE	:= $(shell date "+%Y%m%d")
STXXL_VERSION_SVN_REV	:= $(shell $(call GET_SVNVERSION, .))
endif

# get the svn revision of the MCSTL, if possible
ifneq (,$(strip $(MCSTL_ROOT)))
ifneq (,$(wildcard $(MCSTL_ROOT)/.svn))
ifeq (,$(strip $(shell $(call GET_SVNVERSION, $(MCSTL_ROOT)) | tr -d 0-9)))
# clean checkout - use svn info
MCSTL_VERSION_DATE	:= $(shell $(call GET_SVN_INFO_DATE, $(MCSTL_ROOT)))
MCSTL_VERSION_SVN_REV	:= $(shell $(call GET_SVN_INFO_REV, $(MCSTL_ROOT)))
else
# modified, mixed, ... checkout - use svnversion and today
MCSTL_VERSION_DATE	:= $(shell date "+%Y%m%d")
MCSTL_VERSION_SVN_REV	:= $(shell $(call GET_SVNVERSION, $(MCSTL_ROOT)))
endif
endif
endif

.PHONY: common/version_svn.defs
common/version_svn.defs:
	$(RM) $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_DATE "$(STXXL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp
	echo '#define STXXL_VERSION_STRING_SVN_REVISION "$(STXXL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp
	$(if $(STXXL_SVN_BRANCH), echo '#define STXXL_VERSION_STRING_SVN_BRANCH "$(STXXL_SVN_BRANCH)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_DATE "$(MCSTL_VERSION_DATE)"' >> $@.$(LIBNAME).tmp)
	$(if $(MCSTL_VERSION_SVN_REV), echo '#define MCSTL_VERSION_STRING_SVN_REVISION "$(MCSTL_VERSION_SVN_REV)"' >> $@.$(LIBNAME).tmp)
	cmp -s $@ $@.$(LIBNAME).tmp || mv $@.$(LIBNAME).tmp $@
	$(RM) $@.$(LIBNAME).tmp
endif

tests-in-%: library-fast
	$(MAKE) -C $* tests

tests: SUBDIRS-tests

clean-in-%:
	$(MAKE) -C $* clean

clean: SUBDIRS-clean
	$(RM) common/version_svn.defs
	$(RM) $(LIBNAME).stamp $(LIBNAME).mk $(LIBNAME).mk.tmp

ifneq (,$(wildcard .svn))
VERSION		?= $(shell grep 'define *STXXL_VERSION_STRING_MA_MI_PL' common/version.cpp | cut -d'"' -f2)
PHASE		?= snapshot
DATE		?= $(shell date "+%Y%m%d")
REL_VERSION	:= $(VERSION)$(if $(strip $(DATE)),-$(DATE))
release:
	$(RM) -r reltmp stxxl-$(REL_VERSION).tar.gz stxxl-$(REL_VERSION).zip
	mkdir reltmp
	svn export . reltmp/stxxl-$(REL_VERSION)
	$(RM) -r reltmp/stxxl-$(REL_VERSION)/homepage
	echo '#define STXXL_VERSION_STRING_PHASE "$(PHASE)"' > reltmp/stxxl-$(REL_VERSION)/common/version.defs
	$(if $(strip $(DATE)),echo '#define STXXL_VERSION_STRING_DATE "$(DATE)"' >> reltmp/stxxl-$(REL_VERSION)/common/version.defs)
	cd reltmp && tar cf - stxxl-$(REL_VERSION) | gzip -9 > ../stxxl-$(REL_VERSION).tar.gz && zip -r ../stxxl-$(REL_VERSION).zip stxxl-$(REL_VERSION)/*
	$(RM) -r reltmp
	@echo
	@echo "Your release has been created in stxxl-$(REL_VERSION).tar.gz and stxxl-$(REL_VERSION).zip"
	@echo "The following files are modified and not committed:"
	@svn status -q
endif

.PHONY: main config library library-fast tests clean release