add unit test for same_or_descendant

add unit test for same_or_descendant

:- use_module(u(internal/objects_i)).
:- use_module(u(v)).
:- use_module(library(aggregate)).

:- begin_tests(objects_i, [setup(objects_i_test_v)]).

test(class_fields) :-

   class_id(Id, citizen_v), !,

   class_fields(_:_, Id, false, false, F1),
   assertion(F1 = [height:_, name:_, sex:_, surname:_, weight:_]),

   class_fields(_:_, Id, false, true, F2),
   assertion(F2 = [class:_, functor:_]),

   class_fields(_:_, Id, true, false, F3),
   assertion(F3 = [birthday:_, country:_, id:_]),

   class_fields(_:_, Id, true, true, F4),
   assertion(F4 = [age:_]),

   class_fields(_:_, Id, false, _, F5),
   assertion(F5 = [class:_, functor:_, height:_, name:_, sex:_,
                   surname:_, weight:_]),

   class_fields(_:_, Id, true, _, F6),
   assertion(F6 = [age:_, birthday:_, country:_, id:_]),

   class_fields(_:_, Id, _, false, F7),
   assertion(F7 = [birthday:_, country:_, height:_, id:_, name:_,
                   sex:_, surname:_, weight:_]),

   class_fields(_:_, Id, _, true, F8),
   assertion(F8 = [age:_, class:_, functor:_]),

   class_fields(_:_, Id, _, _, F9),
   assertion(F9 = [age:_, birthday:_, class:_, country:_,
                   functor:_, height:_, id:_, name:_, sex:_,
                   surname:_,weight:_]).

test(list_inheritance_names1) :-

   class_primary_id(callup_v, Id),
   list_inheritance_names(Id, List),
   assertion(List == [object_base_v, object_v, man_v, citizen_v,
                      callup_v]).

test(list_inheritance_names2) :-

   class_primary_id(object_base_v, Id),
   list_inheritance_names(Id, List),
   assertion(List == [object_base_v]).

test(list_inheritance_names3) :-

   class_primary_id(man_v, Id1),
   class_primary_id(citizen_v, Id2),
   list_inheritance_names(Id1, Id2, List),
   assertion(List == [man_v, citizen_v]).

test(obj_unify_int_with_evals) :-

   class_primary_id(citizen_v, Class_Id),
   obj_construct(citizen_v, [], [], O),
   obj_unify_int(Class_Id,
                 [functor, class, birthday], throw,
                 O,
                 [citizen_v, citizen_v, 1994], _),
   obj_field(O, class, Class1),
   assertion(Class1 == citizen_v),

   obj_unify_int(Class_Id,
                 [functor, class, sex], throw,
                 O,
                 [citizen_v, callup_v, man], _),
   obj_field(O, class, Class4),
   assertion(Class4 == callup_v),

   obj_unify_int(Class_Id,
                 [functor, class, birthday, sex], throw,
                 O,
                 [X, Y, 1994, man], _),
   obj_field(O, class, Class5),
   assertion(Class5 == callup_v),
   assertion(X = citizen_v),
   assertion(Y = callup_v).

test(obj_unify_int_with_evals_rebased) :-

   obj_construct(citizen_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   obj_unify_int(Class_Id,
                 [functor, class, birthday], throw,
                 O,
                 [citizen_v, citizen_v, 1994], _),
   obj_field(O, class, Class1),
   assertion(Class1 == citizen_v),

   obj_unify_int(Class_Id,
                 [functor, class, sex], throw,
                 O,
                 [citizen_v, callup_v, man], _),
   obj_field(O, class, Class4),
   assertion(Class4 == callup_v),

   obj_unify_int(Class_Id,
                 [functor, class, birthday, sex], throw,
                 O,
                 [X, Y, 1994, man], _),
   obj_field(O, class, Class5),
   assertion(Class5 == callup_v),
   assertion(X = citizen_v),
   assertion(Y = callup_v).

test(obj_unify_int_combinatoric_feature1,
     [N =:= N_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, false, Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N).

test(obj_unify_int_combinatoric_feature1_rebased,
     [N =:= N_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, false, Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N).

test(obj_unify_int_combinatoric_feature2,
     [N =:= N_Noneval_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, _, Flds),
   class_fields(_, Class_Id, _, false, Noneval_Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N),
   length(Noneval_Flds, N_Noneval_Flds).

test(obj_unify_int_combinatoric_feature2_rebased,
     [N =:= N_Noneval_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, _, Flds),
   class_fields(_, Class_Id, _, false, Noneval_Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N),
   length(Noneval_Flds, N_Noneval_Flds).

test(same_class) :-

   obj_construct(man_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj2, Id2),
   arg(1, Obj3, Id3),
   same_class(Id1, true, man_v),
   same_class(Id1, true, Class1),
   assertion(Class1 == man_v),
   \+ same_class(Id1, false, man_v),
   \+ same_class(Id1, false, _),
   same_class(Id2, false, man_v),
   same_class(Id2, false, Class2),
   assertion(Class2 == man_v),
   \+ same_class(Id2, true, man_v),
   \+ same_class(Id2, true, _),

   findall([NR, Class], same_class(Id1, NR, Class), L1),
   findall([NR, Class], same_class(Id3, NR, Class), L3),

   assertion(L1 == [[true, man_v]]),
   assertion(L3 == [[false, man_v]]).

test(descendant_class1) :-

   obj_construct(callup_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj3, Id3),
   descendant_class(Id1, true, man_v),
   findall(Class, descendant_class(Id1, true, Class), L1U),
   msort(L1U, L1),
   assertion(L1 = [citizen_v, man_v, object_base_v, object_v]),

   \+ descendant_class(Id1, false, man_v),
   \+ descendant_class(Id1, false, _),

   descendant_class(Id3, false, man_v),
   findall(Class, descendant_class(Id3, false, Class), L2U),
   msort(L2U, L2),
   assertion(L2 = [citizen_v, db_object_v, man_v,
                   object_base_v, object_v, tarjan_vertex_v]),

   \+ descendant_class(Id3, true, man_v),
   \+ descendant_class(Id3, true, _),

   findall(p(NR, Class), descendant_class(Id1, NR, Class), PL4),
   findall(p(NR, Class), descendant_class(Id3, NR, Class), PL5),

   maplist(arg(1), PL4, BL4U), sort(BL4U, B4),
   maplist(arg(2), PL4, L4U), msort(L4U, L4),
   maplist(arg(1), PL5, BL5U), sort(BL5U, B5),
   maplist(arg(2), PL5, L5U), msort(L5U, L5),

   assertion(B4 == [true]),
   assertion(L4 == L1),
   assertion(B5 == [false]),
   assertion(L5 == L2).

test(descendant_class2_1) :-
   class_primary_id(man_v, Man_Id),
   findall(Desc,
           (  descendant_class(Desc_Id, Man_Id),
              class_id(Desc_Id, Desc)
           ),
           Descendants),
   assertion(Descendants = [citizen_v, callup_v]).

test(descendant_class2_2) :-
   class_primary_id(man_v, Man_Id),
   findall(Anc,
           (  descendant_class(Man_Id, Anc_Id),
              class_id(Anc_Id, Anc)
           ),
           Ancestors),
   assertion(Ancestors = [object_v, object_base_v]).

test(same_or_descendant1) :-

   obj_construct(callup_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj3, Id3),
   same_or_descendant(Id1, true, man_v),
   same_or_descendant(Id1, true, callup_v),
   \+ same_or_descendant(Id1, true, db_object_v),
   findall(Class, same_or_descendant(Id1, true, Class), L1U),
   msort(L1U, L1),
   assertion(L1 = [callup_v, citizen_v, man_v, object_base_v, object_v]),

   \+ same_or_descendant(Id1, false, object_base_v),
   \+ same_or_descendant(Id1, false, callup_v),
   \+ same_or_descendant(Id1, false, _),

   same_or_descendant(Id3, false, object_base_v),
   same_or_descendant(Id3, false, db_object_v),
   same_or_descendant(Id3, false, tarjan_vertex_v),
   same_or_descendant(Id3, false, callup_v),
   findall(Class, same_or_descendant(Id3, false, Class), L2U),
   msort(L2U, L2),
   assertion(L2 = [callup_v, citizen_v, db_object_v, man_v,
                   object_base_v, object_v, tarjan_vertex_v]),

   \+ same_or_descendant(Id3, true, callup_v),
   \+ same_or_descendant(Id3, true, man_v),
   \+ same_or_descendant(Id3, true, _),

   findall(p(NR, Class), same_or_descendant(Id1, NR, Class), PL4),
   findall(p(NR, Class), same_or_descendant(Id3, NR, Class), PL5),

   maplist(arg(1), PL4, BL4U), sort(BL4U, B4),
   maplist(arg(2), PL4, L4U), msort(L4U, L4),
   maplist(arg(1), PL5, BL5U), sort(BL5U, B5),
   maplist(arg(2), PL5, L5U), msort(L5U, L5),

   assertion(B4 == [true]),
   assertion(L4 == L1),
   assertion(B5 == [false]),
   assertion(L5 == L2).

test(same_or_descendant2_1) :-
   class_primary_id(man_v, Man_Id),
   findall(Desc,
           (  same_or_descendant(Desc_Id, Man_Id),
              class_id(Desc_Id, Desc)
           ),
           Descendants),
   assertion(Descendants = [man_v, citizen_v, callup_v]).

test(same_or_descendant2_2) :-
   class_primary_id(man_v, Man_Id),
   findall(Anc,
           (  same_or_descendant(Man_Id, Anc_Id),
              class_id(Anc_Id, Anc)
           ),
           Ancestors),
   assertion(Ancestors = [object_v, object_base_v, man_v]).

test(same_or_descendant2_3) :-
   Class_id = 1,
   same_or_descendant(Class_id, Class_id).

objects_i_test_v :-

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(objects_i_test_v, object_v, [a, b, c]).

:- end_tests(objects_i).

:- use_module(u(internal/objects_i)).
:- use_module(u(v)).
:- use_module(library(aggregate)).

:- begin_tests(objects_i, [setup(objects_i_test_v)]).

test(class_fields) :-

   class_id(Id, citizen_v), !,

   class_fields(_:_, Id, false, false, F1),
   assertion(F1 = [height:_, name:_, sex:_, surname:_, weight:_]),

   class_fields(_:_, Id, false, true, F2),
   assertion(F2 = [class:_, functor:_]),

   class_fields(_:_, Id, true, false, F3),
   assertion(F3 = [birthday:_, country:_, id:_]),

   class_fields(_:_, Id, true, true, F4),
   assertion(F4 = [age:_]),

   class_fields(_:_, Id, false, _, F5),
   assertion(F5 = [class:_, functor:_, height:_, name:_, sex:_,
                   surname:_, weight:_]),

   class_fields(_:_, Id, true, _, F6),
   assertion(F6 = [age:_, birthday:_, country:_, id:_]),

   class_fields(_:_, Id, _, false, F7),
   assertion(F7 = [birthday:_, country:_, height:_, id:_, name:_,
                   sex:_, surname:_, weight:_]),

   class_fields(_:_, Id, _, true, F8),
   assertion(F8 = [age:_, class:_, functor:_]),

   class_fields(_:_, Id, _, _, F9),
   assertion(F9 = [age:_, birthday:_, class:_, country:_,
                   functor:_, height:_, id:_, name:_, sex:_,
                   surname:_,weight:_]).

test(list_inheritance_names1) :-

   class_primary_id(callup_v, Id),
   list_inheritance_names(Id, List),
   assertion(List == [object_base_v, object_v, man_v, citizen_v,
                      callup_v]).

test(list_inheritance_names2) :-

   class_primary_id(object_base_v, Id),
   list_inheritance_names(Id, List),
   assertion(List == [object_base_v]).

test(list_inheritance_names3) :-

   class_primary_id(man_v, Id1),
   class_primary_id(citizen_v, Id2),
   list_inheritance_names(Id1, Id2, List),
   assertion(List == [man_v, citizen_v]).

test(obj_unify_int_with_evals) :-

   class_primary_id(citizen_v, Class_Id),
   obj_construct(citizen_v, [], [], O),
   obj_unify_int(Class_Id,
                 [functor, class, birthday], throw,
                 O,
                 [citizen_v, citizen_v, 1994], _),
   obj_field(O, class, Class1),
   assertion(Class1 == citizen_v),

   obj_unify_int(Class_Id,
                 [functor, class, sex], throw,
                 O,
                 [citizen_v, callup_v, man], _),
   obj_field(O, class, Class4),
   assertion(Class4 == callup_v),

   obj_unify_int(Class_Id,
                 [functor, class, birthday, sex], throw,
                 O,
                 [X, Y, 1994, man], _),
   obj_field(O, class, Class5),
   assertion(Class5 == callup_v),
   assertion(X = citizen_v),
   assertion(Y = callup_v).

test(obj_unify_int_with_evals_rebased) :-

   obj_construct(citizen_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   obj_unify_int(Class_Id,
                 [functor, class, birthday], throw,
                 O,
                 [citizen_v, citizen_v, 1994], _),
   obj_field(O, class, Class1),
   assertion(Class1 == citizen_v),

   obj_unify_int(Class_Id,
                 [functor, class, sex], throw,
                 O,
                 [citizen_v, callup_v, man], _),
   obj_field(O, class, Class4),
   assertion(Class4 == callup_v),

   obj_unify_int(Class_Id,
                 [functor, class, birthday, sex], throw,
                 O,
                 [X, Y, 1994, man], _),
   obj_field(O, class, Class5),
   assertion(Class5 == callup_v),
   assertion(X = citizen_v),
   assertion(Y = callup_v).

test(obj_unify_int_combinatoric_feature1,
     [N =:= N_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, false, Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N).

test(obj_unify_int_combinatoric_feature1_rebased,
     [N =:= N_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, false, Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N).

test(obj_unify_int_combinatoric_feature2,
     [N =:= N_Noneval_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, _, Flds),
   class_fields(_, Class_Id, _, false, Noneval_Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N),
   length(Noneval_Flds, N_Noneval_Flds).

test(obj_unify_int_combinatoric_feature2_rebased,
     [N =:= N_Noneval_Flds ** N_Flds]) :-

   obj_construct(objects_i_test_v, [], [], O0),
   obj_rebase((object_v -> db_object_v), O0, O),
   arg(1, O, Class_Id),
   class_fields(_, Class_Id, _, _, Flds),
   class_fields(_, Class_Id, _, false, Noneval_Flds),
   length(Flds, N_Flds),
   length(U_Flds, N_Flds),
   aggregate_all(count,
                 obj_unify_int(Class_Id, U_Flds, throw, O, U_Flds,
                               _),
                 N),
   length(Noneval_Flds, N_Noneval_Flds).

test(same_class) :-

   obj_construct(man_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj2, Id2),
   arg(1, Obj3, Id3),
   same_class(Id1, true, man_v),
   same_class(Id1, true, Class1),
   assertion(Class1 == man_v),
   \+ same_class(Id1, false, man_v),
   \+ same_class(Id1, false, _),
   same_class(Id2, false, man_v),
   same_class(Id2, false, Class2),
   assertion(Class2 == man_v),
   \+ same_class(Id2, true, man_v),
   \+ same_class(Id2, true, _),

   findall([NR, Class], same_class(Id1, NR, Class), L1),
   findall([NR, Class], same_class(Id3, NR, Class), L3),

   assertion(L1 == [[true, man_v]]),
   assertion(L3 == [[false, man_v]]).

test(descendant_class1) :-

   obj_construct(callup_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj3, Id3),
   descendant_class(Id1, true, man_v),
   findall(Class, descendant_class(Id1, true, Class), L1U),
   msort(L1U, L1),
   assertion(L1 = [citizen_v, man_v, object_base_v, object_v]),

   \+ descendant_class(Id1, false, man_v),
   \+ descendant_class(Id1, false, _),

   descendant_class(Id3, false, man_v),
   findall(Class, descendant_class(Id3, false, Class), L2U),
   msort(L2U, L2),
   assertion(L2 = [citizen_v, db_object_v, man_v,
                   object_base_v, object_v, tarjan_vertex_v]),

   \+ descendant_class(Id3, true, man_v),
   \+ descendant_class(Id3, true, _),

   findall(p(NR, Class), descendant_class(Id1, NR, Class), PL4),
   findall(p(NR, Class), descendant_class(Id3, NR, Class), PL5),

   maplist(arg(1), PL4, BL4U), sort(BL4U, B4),
   maplist(arg(2), PL4, L4U), msort(L4U, L4),
   maplist(arg(1), PL5, BL5U), sort(BL5U, B5),
   maplist(arg(2), PL5, L5U), msort(L5U, L5),

   assertion(B4 == [true]),
   assertion(L4 == L1),
   assertion(B5 == [false]),
   assertion(L5 == L2).

test(descendant_class2_1) :-
   class_primary_id(man_v, Man_Id),
   findall(Desc,
           (  descendant_class(Desc_Id, Man_Id),
              class_id(Desc_Id, Desc)
           ),
           Descendants),
   assertion(Descendants = [citizen_v, callup_v]).

test(descendant_class2_2) :-
   class_primary_id(man_v, Man_Id),
   findall(Anc,
           (  descendant_class(Man_Id, Anc_Id),
              class_id(Anc_Id, Anc)
           ),
           Ancestors),
   assertion(Ancestors = [object_v, object_base_v]).

test(same_or_descendant1) :-

   obj_construct(callup_v, [], [], Obj1),
   obj_rebase((object_v -> db_object_v), Obj1, Obj2),
   obj_rebase((object_v -> tarjan_vertex_v), Obj2, Obj3),
   arg(1, Obj1, Id1),
   arg(1, Obj3, Id3),
   same_or_descendant(Id1, true, man_v),
   same_or_descendant(Id1, true, callup_v),
   \+ same_or_descendant(Id1, true, db_object_v),
   findall(Class, same_or_descendant(Id1, true, Class), L1U),
   msort(L1U, L1),
   assertion(L1 = [callup_v, citizen_v, man_v, object_base_v, object_v]),

   \+ same_or_descendant(Id1, false, object_base_v),
   \+ same_or_descendant(Id1, false, callup_v),
   \+ same_or_descendant(Id1, false, _),

   same_or_descendant(Id3, false, object_base_v),
   same_or_descendant(Id3, false, db_object_v),
   same_or_descendant(Id3, false, tarjan_vertex_v),
   same_or_descendant(Id3, false, callup_v),
   findall(Class, same_or_descendant(Id3, false, Class), L2U),
   msort(L2U, L2),
   assertion(L2 = [callup_v, citizen_v, db_object_v, man_v,
                   object_base_v, object_v, tarjan_vertex_v]),

   \+ same_or_descendant(Id3, true, callup_v),
   \+ same_or_descendant(Id3, true, man_v),
   \+ same_or_descendant(Id3, true, _),

   findall(p(NR, Class), same_or_descendant(Id1, NR, Class), PL4),
   findall(p(NR, Class), same_or_descendant(Id3, NR, Class), PL5),

   maplist(arg(1), PL4, BL4U), sort(BL4U, B4),
   maplist(arg(2), PL4, L4U), msort(L4U, L4),
   maplist(arg(1), PL5, BL5U), sort(BL5U, B5),
   maplist(arg(2), PL5, L5U), msort(L5U, L5),

   assertion(B4 == [true]),
   assertion(L4 == L1),
   assertion(B5 == [false]),
   assertion(L5 == L2).

test(same_or_descendant2_1) :-
   class_primary_id(man_v, Man_Id),
   findall(Desc,
           (  same_or_descendant(Desc_Id, Man_Id),
              class_id(Desc_Id, Desc)
           ),
           Descendants),
   assertion(Descendants = [man_v, citizen_v, callup_v]).

test(same_or_descendant2_2) :-
   class_primary_id(man_v, Man_Id),
   findall(Anc,
           (  same_or_descendant(Man_Id, Anc_Id),
              class_id(Anc_Id, Anc)
           ),
           Ancestors),
   assertion(Ancestors = [object_v, object_base_v, man_v]).

objects_i_test_v :-

   current_prolog_flag(verbose, Old_Verbose),
   set_prolog_flag(verbose, silent),
   reload_all_classes,
   set_prolog_flag(verbose, Old_Verbose),

   class_create(objects_i_test_v, object_v, [a, b, c]).

:- end_tests(objects_i).


Y-scaling fix

Y-scaling fix

#!/usr/bin/env gnuplot

# graph of battery charge level

# datafiles
ifnameh = "/tmp/upsdiagd/mysql/upsh.csv"
ifnamed = "/tmp/upsdiagd/mysql/upsd.csv"
ifnamew = "/tmp/upsdiagd/mysql/upsw.csv"
set output "/tmp/upsdiagd/site/img/ups15.png"

# ******************************************************* General settings *****
set terminal png 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.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* 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 - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnameh using 5 name "Yh" nooutput

# ********************************************************* 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 - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnamed using 5 name "Yd" nooutput

# ********************************************************* 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 - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# stats for Y-axis
stats ifnamew using 5 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max) + 1.0
Ymin = min(min(Yd_min, Yh_min), Yw_min) - 1.0

set multiplot layout 1, 3 title "Batterij lading ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Lading [%]"
set yrange [ Ymin : Ymax ]

# ***************************************************************** 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 lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):5 title " Lading [%]" with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ Ymin : Ymax ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):5 with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

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

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

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):5 with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

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

unset multiplot

#!/usr/bin/env gnuplot

# graph of battery charge level

# datafiles
ifnameh = "/tmp/upsdiagd/mysql/upsh.csv"
ifnamed = "/tmp/upsdiagd/mysql/upsd.csv"
ifnamew = "/tmp/upsdiagd/mysql/upsw.csv"
set output "/tmp/upsdiagd/site/img/ups15.png"

# ******************************************************* General settings *****
set terminal png 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.
if (GPVAL_VERSION == 4.6) {epoch_compensate = 946684800} else {if (GPVAL_VERSION == 5.0) {epoch_compensate = 0}}
# Positions of split between graphs
LMARG = 0.06
LMPOS = 0.40
MRPOS = 0.73
RMARG = 0.94

min(x,y) = (x < y) ? x : y
max(x,y) = (x > y) ? x : y

# ********************************************************* 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 - epoch_compensate
Xh_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnameh using 5 name "Yh" nooutput

# ********************************************************* 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 - epoch_compensate
Xd_max = X_max + utc_offset - epoch_compensate

# stats to be calculated here for Y-axes
stats ifnamed using 5 name "Yd" nooutput

# ********************************************************* 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 - epoch_compensate
Xw_max = X_max + utc_offset - epoch_compensate

# stats for Y-axis
stats ifnamew using 5 name "Yw" nooutput

Ymax = max(max(Yd_max, Yh_max), Yw_max)
Ymin = min(min(Yd_min, Yh_min), Yw_min)
R10 = (Ymax - Ymin) * 0.1
Ymax = Ymax + R10
Ymin = Ymin - R10

set multiplot layout 1, 3 title "Batterij lading ".strftime("( %Y-%m-%dT%H:%M:%S )", time(0)+utc_offset)

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                       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 "Lading [%]"
set yrange [ Ymin : Ymax ]

# ***************************************************************** 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 lmargin at screen LMARG
set rmargin at screen LMPOS

# ***** PLOT *****
plot ifnamew \
      using ($2+utc_offset):5 title " Lading [%]" with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                     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 [ Ymin : Ymax ]

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

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

# ***** PLOT *****
plot ifnamed \
      using ($2+utc_offset):5 with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#                                                      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 ]
set xtics textcolor rgb "red"

# ***************************************************************** Y-axis *****
set ylabel " "
set ytics format " "
set yrange [ Ymin : Ymax ]

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

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

# ***** PLOT *****
plot ifnameh \
      using ($2+utc_offset):5 with lines lw 0.1 fc rgb "#ccbb0000"
      # with points pt 5 ps 0.2 fc rgb "#ccbb0000" \

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

unset multiplot


fixing a minor issue in naming files for daily monitoring

# today=system("date +%F")
today='2019-04-30'
iFileName='submitAll_'.today.'.dat'
iFileNameAssimilated='assimilateAll_'.today.'.dat'
oFileName='submitAll_'.today.'.ps'

set terminal postscript enhanced 'Times-Roman, 16'
set output oFileName

tStep=3600
set xdata time
set timefmt '%Y-%m-%dT%H:%M:%S'
set format x '%H:%M:%S'
set xlabel 'time'
set xtics rotate by 90 tStep

set grid

set key outside horizontal
set ylabel 'submitted WUs [10^3]'
set title 'date: '.today
print "< awk '{if ($6==\"fvanderv\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName
plot \
     "< awk '{if ($6==\"mcrouch\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'black'       title 'mcrouch',\
     "< awk '{if ($6==\"ynosochk\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-green'  title 'ynosochk',\
     "< awk '{if ($6==\"emaclean\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'green'       title 'emaclean',\
     "< awk '{if ($6==\"fvanderv\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'blue'        title 'fvanderv',\
     "< awk '{if ($6==\"kaltchev\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'magenta'     title 'kaltchev',\
     "< awk '{if ($6==\"phermes\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'cyan'        title 'phermes',\
     "< awk '{if ($6==\"nkarast\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'orange'      title 'nkarast',\
     "< awk '{if ($6==\"dpellegr\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'pink'        title 'dpellegr',\
     "< awk '{if ($6==\"ecruzala\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'navy'        title 'ecruzala',\
     "< awk '{if ($6==\"amereghe\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'purple'      title 'amereghe',\
     "< awk '{if ($6==\"rdemaria\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'yellow'      title 'rdemaria',\
     "< awk '{if ($6==\"jbarranc\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-blue'   title 'jbarranc',\
     "< awk '{if ($6==\"giovanno\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'gold'        title 'giovanno',\
     "< awk '{if ($6==\"mcintosh\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'violet'      title 'mcintosh',\
     "< awk '{if ($6==\"skostogl\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-red'    title 'skostogl',\
     "< awk '{if ($6==\"lcoyle\") {tot+=$4; print ($1,$3,tot)}}'   ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'salmon'      title 'lcoyle',\
     "< awk '{if ($6==\"mihofer\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'turquoise'   title 'mihofer',\
     "< awk '{if ($6==\"xiaohan\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'skyblue'     title 'xiaohan',\
     "< awk '{if ($6==\"-\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName        index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'red'         title '-'

set ylabel 'WUs [10^3]'
plot \
     "< awk '{tot+=$4; print ($1,tot)}'  ".iFileName index 0 using 1:($2/1000) with steps lt 1 lw 3 lc rgb 'red' title 'submitted',\
     "< awk '{tot+=$4; print ($1\"T\"$2,tot)}'  ".iFileNameAssimilated index 0 using 1:($2/1000) with steps lt 1 lw 3 lc rgb 'blue' title 'assimilated'

# today=system("date +%F")
today='2019-04-29'
iFileName='submitAll_'.today.'.dat'
iFileNameAssimilated='assimilateAll_'.today.'.dat'

set terminal postscript enhanced 'Times-Roman, 16'
set output iFileName.'.ps'

tStep=3600
set xdata time
set timefmt '%Y-%m-%dT%H:%M:%S'
set format x '%H:%M:%S'
set xlabel 'time'
set xtics rotate by 90 tStep

set grid

set key outside horizontal
set ylabel 'submitted WUs [10^3]'
set title 'date: '.today
print "< awk '{if ($6==\"fvanderv\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName
plot \
     "< awk '{if ($6==\"mcrouch\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'black'       title 'mcrouch',\
     "< awk '{if ($6==\"ynosochk\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-green'  title 'ynosochk',\
     "< awk '{if ($6==\"emaclean\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'green'       title 'emaclean',\
     "< awk '{if ($6==\"fvanderv\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'blue'        title 'fvanderv',\
     "< awk '{if ($6==\"kaltchev\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'magenta'     title 'kaltchev',\
     "< awk '{if ($6==\"phermes\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'cyan'        title 'phermes',\
     "< awk '{if ($6==\"nkarast\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'orange'      title 'nkarast',\
     "< awk '{if ($6==\"dpellegr\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'pink'        title 'dpellegr',\
     "< awk '{if ($6==\"ecruzala\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'navy'        title 'ecruzala',\
     "< awk '{if ($6==\"amereghe\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'purple'      title 'amereghe',\
     "< awk '{if ($6==\"rdemaria\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'yellow'      title 'rdemaria',\
     "< awk '{if ($6==\"jbarranc\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-blue'   title 'jbarranc',\
     "< awk '{if ($6==\"giovanno\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'gold'        title 'giovanno',\
     "< awk '{if ($6==\"mcintosh\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'violet'      title 'mcintosh',\
     "< awk '{if ($6==\"skostogl\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'dark-red'    title 'skostogl',\
     "< awk '{if ($6==\"lcoyle\") {tot+=$4; print ($1,$3,tot)}}'   ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'salmon'      title 'lcoyle',\
     "< awk '{if ($6==\"mihofer\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'turquoise'   title 'mihofer',\
     "< awk '{if ($6==\"xiaohan\") {tot+=$4; print ($1,$3,tot)}}'  ".iFileName index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'skyblue'     title 'xiaohan',\
     "< awk '{if ($6==\"-\") {tot+=$4; print ($1,$3,tot)}}' ".iFileName        index 0 using 1:($3/1E6) with steps lt 1 lw 3 lc rgb 'red'         title '-'

set ylabel 'WUs [10^3]'
plot \
     "< awk '{tot+=$4; print ($1,tot)}'  ".iFileName index 0 using 1:($2/1000) with steps lt 1 lw 3 lc rgb 'red' title 'submitted',\
     "< awk '{tot+=$4; print ($1\"T\"$2,tot)}'  ".iFileNameAssimilated index 0 using 1:($2/1000) with steps lt 1 lw 3 lc rgb 'blue' title 'assimilated'


trying clustered histogram

trying clustered histogram


Delete command.gp

Delete command.gp


secs since the UINX epoch. other updates.

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

set xlabel "Time"
set ylabel "Primary key" offset 1.5,0

set border (1 + 2) lc rgb "#808080"
set ytics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,10
set xtics nomirror scale 0.5,0 tc rgb "#808080" format "%Y" rotate by -30

set xdata time
# seconds since the UNIX epoch
set timefmt "%s"

#set key box lc rgb "#808080" opaque
set nokey

# Plot reads first so that writes are on top
plot \
FN_IN u 3:((strcol(2) eq "R") ? $1 : 1/0) w points pt 7 ps 0.15 lc rgb "#0000FF" t "Read", \
FN_IN u 3:((strcol(2) eq "W") ? $1 : 1/0) w points pt 7 ps 0.2  lc rgb "#FF0000" t "Write"

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

set xlabel "Time"
set ylabel "Primary key"

# TODO: get R times right
# TODO: dep file doesn't have to be built everytime. compare with .jar file!

set border (1 + 2) lc rgb "#808080"
set ytics nomirror scale 0.5,0 tc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080"
#set xtics nomirror scale 0.5,0 tc rgb "#808080" ( \
#		"1h" 3600 \
#		, "1d" 24*3600 \
#		, "1m" 365.0/12*24*3600 \
#		, "1y" 365.0*24*3600 \
#		, "XX" 30*365.0*24*3600 \
#		)

set pointsize 0.2

set key box lc rgb "#808080" opaque

plot \
FN_IN u 3:((strcol(2) eq "W") ? $1 : 1/0) w points pt 7 lc rgb "#FF0000" t "Write", \
FN_IN u 3:((strcol(2) eq "R") ? $1 : 1/0) w points pt 7 lc rgb "#0000FF" t "Read"


update

update

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get min and max values
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

plot FN_IN u 1:($2/1000000) w fsteps, \
FN_IN u 1:($4+$5) w lines axes x1y2

X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX
Y2_MIN=GPVAL_DATA_Y2_MIN
Y2_MAX=GPVAL_DATA_Y2_MAX

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

#set tmargin at screen 0.975
#set bmargin at screen 0.152
#set lmargin at screen 0.185
#set rmargin at screen 0.940

set xlabel "Time" offset 0,0.3
set ylabel "Storage size (MB)" offset 1.3,0
set y2label "Storage cost ($)"

set border (1 + 2 + 8) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,(365.25*24*3600)

# Not sure if this is what I wanted. Not important.
x1(a)=(10**floor(log10(a)))
x2(a)=floor(a/x1(a))*x1(a)
x3(a)=floor(a/x1(a)/2)*x1(a)*2
startsWith1(a)=(a == x1(a))
yTicsStep(a, b)=(startsWith1(x2(a/b)) ? x2(a/b) : x3(a/b))

set print "-"
print (sprintf("Y_MAX: %f", Y_MAX))
print (sprintf("Y2_MAX: %f", Y2_MAX))
print (sprintf("yTicsStep(Y_MAX, 2)=%f", yTicsStep(Y_MAX, 2)))
print (sprintf("yTicsStep(Y2_MAX, 2)=%f", yTicsStep(Y2_MAX, 2)))

# TODO: disabled for "generates increment must be positive"
#   160226-140338
set ytics  nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,yTicsStep(Y_MAX, 2)
set y2tics nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,yTicsStep(Y2_MAX, 2)
set tics front

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]
set y2range [Y2_MIN:Y2_MAX]

set key top left

set pointsize 0.1

plot \
FN_IN u 1:($2/1000000) w steps lc rgb "red" t "Hot", \
FN_IN u 1:($3/1000000) w steps lc rgb "blue" t "Cold", \
FN_IN u 1:4 w linespoints axes x1y2 pt 7 lc rgb "red" not, \
FN_IN u 1:5 w linespoints axes x1y2 pt 7 lc rgb "blue" not, \
FN_IN u 1:($4+$5) w linespoints axes x1y2 pt 7 lc rgb "black" not

#FN_IN u 1:($2/1000000) w fillsteps fs solid 0.15 noborder not, \

# Tested with gnuplot 4.6 patchlevel 6

FN_IN = system("echo $FN_IN")
FN_OUT = system("echo $FN_OUT")

# Get min and max values
set terminal unknown
set xdata time
set timefmt "%y%m%d-%H%M%S"
set format x "'%y"

plot FN_IN u 1:($2/1000000) w fsteps, \
FN_IN u 1:($4+$5) w lines axes x1y2

X_MIN=GPVAL_DATA_X_MIN
X_MAX=GPVAL_DATA_X_MAX
Y_MIN=GPVAL_DATA_Y_MIN
Y_MAX=GPVAL_DATA_Y_MAX
Y2_MIN=GPVAL_DATA_Y2_MIN
Y2_MAX=GPVAL_DATA_Y2_MAX

set terminal pdfcairo enhanced size 3in, 2in
set output FN_OUT

#set tmargin at screen 0.975
#set bmargin at screen 0.152
#set lmargin at screen 0.185
#set rmargin at screen 0.940

set xlabel "Time" offset 0,0.3
set ylabel "Storage size (MB)" offset 1.3,0
set y2label "Storage cost ($)"

set border (1 + 2 + 8) back lc rgb "#808080"
set xtics nomirror scale 0.5,0 tc rgb "#808080" #autofreq 0,(365.25*24*3600)

# Not sure if this is what I wanted. Not important.
x1(a)=(10**floor(log10(a)))
x2(a)=floor(a/x1(a))*x1(a)
x3(a)=floor(a/x1(a)/2)*x1(a)*2
startsWith1(a)=(a == x1(a))
yTicsStep(a, b)=(startsWith1(x2(a/b)) ? x2(a/b) : x3(a/b))

set print "-"
print (sprintf("Y_MAX: %f", Y_MAX))
print (sprintf("Y2_MAX: %f", Y2_MAX))
print (sprintf("yTicsStep(Y_MAX, 2)=%f", yTicsStep(Y_MAX, 2)))
print (sprintf("yTicsStep(Y2_MAX, 2)=%f", yTicsStep(Y2_MAX, 2)))
set ytics  nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y_MAX, 2)
set y2tics nomirror scale 0.5,0 tc rgb "#808080" autofreq 0,yTicsStep(Y2_MAX, 2)
set tics front

set xrange [X_MIN:X_MAX]
set yrange [Y_MIN:Y_MAX]
set y2range [Y2_MIN:Y2_MAX]

set key top left

set pointsize 0.1

plot \
FN_IN u 1:($2/1000000) w steps lc rgb "red" t "Hot", \
FN_IN u 1:($3/1000000) w steps lc rgb "blue" t "Cold", \
FN_IN u 1:4 w linespoints axes x1y2 pt 7 lc rgb "red" not, \
FN_IN u 1:5 w linespoints axes x1y2 pt 7 lc rgb "blue" not, \
FN_IN u 1:($4+$5) w linespoints axes x1y2 pt 7 lc rgb "black" not

#FN_IN u 1:($2/1000000) w fillsteps fs solid 0.15 noborder not, \


Update plot.

Update plot.

# 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,9" linewidth 2 rounded fontscale 1.0

# Line style for axes
set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 lt 0  # dashed
set style line 81 lt rgb "#808080"  # grey

set grid back linestyle 81
set border 3 back linestyle 80 # Remove border on top and right.  These
             # borders are useless and make it harder
             # to see plotted lines near the border.
    # Also, put it in grey; no need for so much emphasis on a border.
# set xtics nomirror
# set ytics nomirror

#set log x
#set mxtics 10    # Makes logscale look good.

# Line styles: try to pick pleasing colors, rather
# than strictly primary colors or hard-to-see colors
# like gnuplot's default yellow.  Make the lines thick
# so they're easy to see in small plots in papers.
set style line 1 lt rgb "#A00000" lw 2 pt 1
# set style line 2 lt rgb "#00A000" lw 2 pt 6
# set style line 3 lt rgb "#5060D0" lw 2 pt 2
# set style line 4 lt rgb "#F25900" lw 2 pt 9

set output outputname
set xlabel "Time in Seconds"
set ylabel "MB/client Transmitted"

set key top left

set datafile missing '0'

# log scale on the y axis
# set logscale y 2
# set format y ""
# set ytics 1e-6, 10, 1
# set ytics add ("1" 1, ".1" 0.1, ".01" 0.01, "10^-3" 0.001, \
#                "10^-4" 0.0001)
# set mytics 10

# set xrange [0:60]
# set yrange [0.5:64]

# Input file contains comma-separated values fields
set datafile separator ","

plot inputfile1 using 1:3 title "Client-to-Server" with linespoints #, \
#     inputfile2 using 1:3 title "Server-to-Server" with linespoints

# Note you need gnuplot 4.4 for the pdfcairo terminal.

set terminal pdfcairo font "Gill Sans,9" linewidth 4 rounded fontscale 1.0

# Line style for axes
set style line 80 lt rgb "#808080"

# Line style for grid
set style line 81 lt 0  # dashed
set style line 81 lt rgb "#808080"  # grey

set grid back linestyle 81
set border 3 back linestyle 80 # Remove border on top and right.  These
             # borders are useless and make it harder
             # to see plotted lines near the border.
    # Also, put it in grey; no need for so much emphasis on a border.
set xtics nomirror
set ytics nomirror

#set log x
#set mxtics 10    # Makes logscale look good.

# Line styles: try to pick pleasing colors, rather
# than strictly primary colors or hard-to-see colors
# like gnuplot's default yellow.  Make the lines thick
# so they're easy to see in small plots in papers.
set style line 1 lt rgb "#A00000" lw 2 pt 1
set style line 2 lt rgb "#00A000" lw 2 pt 6
set style line 3 lt rgb "#5060D0" lw 2 pt 2
set style line 4 lt rgb "#F25900" lw 2 pt 9

set output outputname
set xlabel "Time in Seconds"
set ylabel "MB/client Transmitted"

set key top left

set datafile missing '0'

# log scale on the y axis
# set logscale y 2
# set format y ""
# set ytics 1e-6, 10, 1
# set ytics add ("1" 1, ".1" 0.1, ".01" 0.01, "10^-3" 0.001, \
#                "10^-4" 0.0001)
set mytics 10

# set xrange [0:60]
# set yrange [0.5:64]

# Input file contains comma-separated values fields
set datafile separator ","

plot inputfile1 using 1:3 title "Client-to-Server" with linespoints, \
     inputfile2 using 1:3 title "Server-to-Server" with linespoints


turning graph upside-down puts more emphasis on higer priorites (<)

#!/usr/bin/env gnuplot

# graph of count of loglines

# datafile
ifname = "/tmp/sql15.csv"
ofname = "/tmp/lnxdiagd/site/img/day15.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom font "Vera,6"

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD <= 0 ? NaN : xD)
old_x = NaN

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

X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "Logging"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # 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 xtics rotate by 40 right
set xrange [ X_min : X_max ]

# ***************************************************************** Y-axis *****
set ylabel "Lines []"
set autoscale y
set format y "%4.1s %c"
set logscale y 10

# **************************************************************** Y2-axis *****
# set y2label "Load"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
set key outside bottom center horizontal box
set key samplen .2
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 output ofname

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifname \
      using ($2+utc_offset):(delta($4+$5+$6+$7+$8)) title "p4" fc "gold"   \
  ,'' using ($2+utc_offset):(delta($4+$5+$6+$7))    title "p3" fc "orange" \
  ,'' using ($2+utc_offset):(delta($4+$5+$6))       title "p2" fc "red"    \
  ,'' using ($2+utc_offset):(delta($4+$5))          title "p1" fc "blue"   \
  ,'' using ($2+utc_offset):(delta($4))             title "p0" fc "black"  \
  #    using ($2+utc_offset):(delta($4+$5+$6+$7+$8+$9+$10+$11)) title "p0" fc "black"\
  #,'' using ($2+utc_offset):(delta($5+$6+$7+$8+$9+$10+$11)) title "p1" fc "blue"\
  #,'' using ($2+utc_offset):(delta($6+$7+$8+$9+$10+$11)) title "p2" fc "red"\
  #,'' using ($2+utc_offset):(delta($7+$8+$9+$10+$11)) title "p3" fc "orange"\
  #,'' using ($2+utc_offset):(delta($8+$9+$10+$11)) title "p4" fc "gold"\
  #,'' using ($2+utc_offset):(delta($9+$10+$11)) title "p5" fc "yellow"\
  #,'' using ($2+utc_offset):(delta($10+$11)) title "p6" fc "green" \
  #,'' using ($2+utc_offset):(delta($11)) title "p7" fc "grey" \

#!/usr/bin/env gnuplot

# graph of count of loglines

# datafile
ifname = "/tmp/sql15.csv"
ofname = "/tmp/lnxdiagd/site/img/day15.png"

# ******************************************************* General settings *****
set terminal png truecolor enhanced font "Vera,9" size 640,304
set datafile separator ';'
set datafile missing "NaN"    # Ignore missing values
set grid front
tz_offset = utc_offset / 3600 # GNUplot only works with UTC. Need to compensate
                              # for timezone ourselves.
set timestamp 'created: %Y-%m-%d %H:%M' bottom font "Vera,6"

# ************************************************************* Functions ******
# determine delta data
delta(x) = ( xD = x - old_x, old_x = x, xD <= 0 ? NaN : xD)
old_x = NaN

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

X_min = X_min + utc_offset - 946684800
X_max = X_max + utc_offset - 946684800

# ****************************************************************** Title *****
set title "Logging"

# ***************************************************************** X-axis *****
set xlabel "Date/Time"       # 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 xtics rotate by 40 right
set xrange [ X_min : X_max ]

# ***************************************************************** Y-axis *****
set ylabel "Lines []"
set autoscale y
set format y "%4.1s %c"
set logscale y 10

# **************************************************************** Y2-axis *****
# set y2label "Load"
# set autoscale y2
# set y2tics border

# ***************************************************************** Legend *****
set key outside bottom center horizontal box
set key samplen .2
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 output ofname

# ***** PLOT *****
set style data boxes
set style fill solid noborder

plot ifname \
      using ($2+utc_offset):(delta($4+$5+$6+$7+$8+$9+$10+$11)) title "p0" fc "black"\
  ,'' using ($2+utc_offset):(delta($5+$6+$7+$8+$9+$10+$11)) title "p1" fc "blue"\
  ,'' using ($2+utc_offset):(delta($6+$7+$8+$9+$10+$11)) title "p2" fc "red"\
  ,'' using ($2+utc_offset):(delta($7+$8+$9+$10+$11)) title "p3" fc "orange"\
  ,'' using ($2+utc_offset):(delta($8+$9+$10+$11)) title "p4" fc "gold"\
  #,'' using ($2+utc_offset):(delta($9+$10+$11)) title "p5" fc "yellow"\
  #,'' using ($2+utc_offset):(delta($10+$11)) title "p6" fc "green" \
  #,'' using ($2+utc_offset):(delta($11)) title "p7" fc "grey" \


gnuplot

gnuplot

set term post eps
set output "2-curves.eps"
set title "Comparison between two reverse-count functions"
set xlabel "List length"
set ylabel "Time"
plot '2-curves.dat' using 1:2 with lines linecolor rgb "blue", \
      '2-curves.dat' using 1:3 with lines linecolor rgb "red"

set term post eps
set output "coloring.eps"
set title "Coloring on rectangular grids 6 x N"
set xlabel "N"
set ylabel "Time"
plot 'coloring.dat' using 1:2 with lines linecolor rgb "red"


don't embed '#' in strings, some make versions treat it as a begin-of-comment causing syntax errors, use echo -e and the octal escape instead

git-svn-id: 4e7379b20b57f8e3dde5a0b7363f233184647162@957 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-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	?= $(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_MCSTL	?= no	# will be overriden from main Makefile
USE_ICPC	?= no	# will be overriden from main Makefile

STXXL_ROOT	?= $(HOME)/work/stxxl

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_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
LIBNAME		?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

#BOOST_ROOT	?= /usr/local/boost-1.34.1

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

LIBNAME		?= stxxl

# Hint: for g++-4.3 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

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

#### 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

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

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

# check, whether stxxl has been configured
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
$(warning *** WARNING: trying autoconfiguration for STXXL_ROOT=$(CURDIR:$(HOME)%=$$(HOME)%))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
$(shell echo 'STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo -e '\043MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo -e '\043COMPILER_GCC	 = g++-4.2.3' >> $(CURDIR)/make.settings.local)
$(shell echo -e '\043COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell echo -e 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo -e '\043USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
$(error ERROR: Please check make.settings.local and try again)
endif
else
$(warning *** WARNING: Please check make.settings.local)
endif
$(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) \
	-DSORT_OPTIMAL_PREFETCHING \
	-DUSE_MALLOC_LOCK \
	-DCOUNT_WAIT_TIME \
	-I$(strip $(STXXL_ROOT))/include \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
	$(POSIX_MEMALIGN) $(XOPEN_SOURCE)

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

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

#### 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__ $(MCSTL_INCLUDES_PREPEND) -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

MCSTL_INCLUDES_PREPEND	+= $(if $(findstring 4.3,$(COMPILER)),-I$(MCSTL_ROOT)/c++/mod_stl/gcc-4.3)

endif

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

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

BOOST_COMPILER_OPTIONS		+= $(if $(strip $(BOOST_ROOT)),-I$(strip $(BOOST_ROOT)))
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_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	-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_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 compat_hash_set.h
HEADER_FILES_BITS	+= compat_auto_ptr.h

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

HEADER_FILES_IO		+= completion_handler.h io.h iobase.h iostats.h
HEADER_FILES_IO		+= mmap_file.h simdisk_file.h syscall_file.h
HEADER_FILES_IO		+= ufs_file.h wincall_file.h wfs_file.h boostfd_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	+= write_pool.h prefetch_pool.h
HEADER_FILES_MNG	+= block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h queue.h
HEADER_FILES_CONTAINERS	+= 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
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 #########################################################

DEPEXT	 = $(LIBNAME).d # extension of dependency files
OBJEXT	 = $(LIBNAME).o	# extension of object files
IIEXT	 = $(LIBNAME).ii
LIBEXT	 = a		# static library file extension
EXEEXT	 = $(LIBNAME).bin # executable file extension
RM	 = rm -f	# remove file command
LIBGEN	 = ar cr	# library generation
OUT	 = -o		# output file option for the compiler and linker

d	?= $(strip $(DEPEXT))
o	?= $(strip $(OBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

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

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

DEPS_MAKEFILES	:= $(wildcard ../Makefile.subdir.gnu ../make.settings ../make.settings.local GNUmakefile Makefile.local)
%.$o: %.cpp $(DEPS_MAKEFILES)
	@$(RM) $@ $*.$d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $*.$dT -c $(OUTPUT_OPTION) $< && mv $*.$dT $*.$d

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

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

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

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

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_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-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	?= $(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_MCSTL	?= no	# will be overriden from main Makefile
USE_ICPC	?= no	# will be overriden from main Makefile

STXXL_ROOT	?= $(HOME)/work/stxxl

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_MCSTL)),yes)
COMPILER_GCC	?= g++-4.2.3
LIBNAME		?= mcstxxl
# the root directory of your MCSTL installation
MCSTL_ROOT	?= $(HOME)/work/mcstl
endif

#BOOST_ROOT	?= /usr/local/boost-1.34.1

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

LIBNAME		?= stxxl

# Hint: for g++-4.3 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

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

#### 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

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

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

# check, whether stxxl has been configured
ifeq (,$(strip $(wildcard $(STXXL_ROOT)/include/stxxl.h)))
$(warning *** WARNING: STXXL has not been configured correctly)
ifeq (,$(strip $(wildcard $(CURDIR)/make.settings.local)))
ifneq (,$(strip $(wildcard $(CURDIR)/include/stxxl.h)))
$(warning *** WARNING: trying autoconfiguration for STXXL_ROOT=$(CURDIR:$(HOME)%=$$(HOME)%))
$(warning *** WARNING: you did not have a make.settings.local file -- creating ...)
$(shell echo 'STXXL_ROOT	 = $(CURDIR:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
MCSTL_ROOT	?= $(HOME)/work/mcstl
$(shell echo '#MCSTL_ROOT	 = $(MCSTL_ROOT:$(HOME)%=$$(HOME)%)' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_GCC	 = g++-4.2.3' >> $(CURDIR)/make.settings.local)
$(shell echo '#COMPILER_ICPC	 = icpc' >> $(CURDIR)/make.settings.local)
ifeq (Darwin,$(strip $(shell uname)))
$(shell echo 'USE_MACOSX	 = yes' >> $(CURDIR)/make.settings.local)
else
$(shell echo '#USE_MACOSX	 = no' >> $(CURDIR)/make.settings.local)
endif
$(error ERROR: Please check make.settings.local and try again)
endif
else
$(warning *** WARNING: Please check make.settings.local)
endif
$(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) \
	-DSORT_OPTIMAL_PREFETCHING \
	-DUSE_MALLOC_LOCK \
	-DCOUNT_WAIT_TIME \
	-I$(strip $(STXXL_ROOT))/include \
	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
	$(POSIX_MEMALIGN) $(XOPEN_SOURCE)

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

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

#### 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__ $(MCSTL_INCLUDES_PREPEND) -I$(MCSTL_ROOT)/c++
MCSTL_LDFLAGS		+= $(OPENMPFLAG)

MCSTL_INCLUDES_PREPEND	+= $(if $(findstring 4.3,$(COMPILER)),-I$(MCSTL_ROOT)/c++/mod_stl/gcc-4.3)

endif

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

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

BOOST_COMPILER_OPTIONS		+= $(if $(strip $(BOOST_ROOT)),-I$(strip $(BOOST_ROOT)))
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_COMPILER_SUFFIX	?=
BOOST_LIB_MT_SUFFIX		?= -mt
BOOST_LINKER_OPTIONS		 = \
	-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_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 compat_hash_set.h
HEADER_FILES_BITS	+= compat_auto_ptr.h

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

HEADER_FILES_IO		+= completion_handler.h io.h iobase.h iostats.h
HEADER_FILES_IO		+= mmap_file.h simdisk_file.h syscall_file.h
HEADER_FILES_IO		+= ufs_file.h wincall_file.h wfs_file.h boostfd_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	+= write_pool.h prefetch_pool.h
HEADER_FILES_MNG	+= block_alloc_interleaved.h

HEADER_FILES_CONTAINERS	+= pager.h stack.h vector.h priority_queue.h queue.h
HEADER_FILES_CONTAINERS	+= 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
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 #########################################################

DEPEXT	 = $(LIBNAME).d # extension of dependency files
OBJEXT	 = $(LIBNAME).o	# extension of object files
IIEXT	 = $(LIBNAME).ii
LIBEXT	 = a		# static library file extension
EXEEXT	 = $(LIBNAME).bin # executable file extension
RM	 = rm -f	# remove file command
LIBGEN	 = ar cr	# library generation
OUT	 = -o		# output file option for the compiler and linker

d	?= $(strip $(DEPEXT))
o	?= $(strip $(OBJEXT))
ii	?= $(strip $(IIEXT))
bin	?= $(strip $(EXEEXT))

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

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

DEPS_MAKEFILES	:= $(wildcard ../Makefile.subdir.gnu ../make.settings ../make.settings.local GNUmakefile Makefile.local)
%.$o: %.cpp $(DEPS_MAKEFILES)
	@$(RM) $@ $*.$d
	$(COMPILER) $(STXXL_COMPILER_OPTIONS) -MD -MF $*.$dT -c $(OUTPUT_OPTION) $< && mv $*.$dT $*.$d

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

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

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

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

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_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