Commit 6ada0c4e authored by Yann Jacquelet's avatar Yann Jacquelet Committed by Guillaume Lazzara
Browse files

Import annotating sources from milena green's sandbox.

	* README.green: New.
	* demo/annotating/bic/Makefile.am: New.
	* demo/annotating/bic/bic.cc: New.
	* demo/annotating/hsv/Makefile.am: New.
	* demo/annotating/hsv/hsv.cc: New.
	* demo/annotating/lep/Makefile.am: New.
	* demo/annotating/lep/lep.cc: New.
	* demo/annotating/nb_color/Makefile.am: New.
	* demo/annotating/nb_color/nb_color.cc: New.
	* demo/annotating/project/Makefile.am: New.
	* demo/annotating/project/project.cc: New.
	* demo/annotating/rgb_64/Makefile.am: New.
	* demo/annotating/rgb_64/rgb_64.cc: New.
	* demo/annotating/rgb_64_9/Makefile.am: New.
	* demo/annotating/rgb_64_9/rgb_64_9.cc: New.
	* demo/annotating/stddev_color/Makefile.am: New.
	* demo/annotating/stddev_color/stddev_color.cc: New.
	* demo/annotating/stddev_color_16/Makefile.am: New.
	* demo/annotating/stddev_color_16/stddev_color_16.cc: New.
	* exp/annotating/achromastism/Makefile.am: New.
	* exp/annotating/achromastism/achromastism.cc: New.
	* exp/annotating/achromastism/text-color.txt: New.
	* exp/annotating/achromastism/text-img.txt: New.
	* exp/annotating/achromastism/text-only.txt: New.
	* exp/annotating/bench/Makefile.am: New.
	* exp/annotating/bench/bench.cc: New.
	* exp/annotating/error/Makefile.am: New.
	* exp/annotating/error/error.cc: New.
	* exp/annotating/histo/Makefile.am: New.
	* exp/annotating/histo/histo.cc: New.
	* exp/annotating/hsv/Makefile.am: New.
	* exp/annotating/hsv/hsv.cc: New.
	* exp/annotating/hue/Makefile.am: New.
	* exp/annotating/hue/hue.cc: New.
	* exp/annotating/hue/text-color.txt: New.
	* exp/annotating/hue/text-img.txt: New.
	* exp/annotating/hue/text-only.txt: New.
	* exp/annotating/nb_color/Makefile.am: New.
	* exp/annotating/nb_color/nb_color.cc: New.
	* exp/annotating/saturation/Makefile.am: New.
	* exp/annotating/saturation/saturation.cc: New.
	* exp/annotating/saturation/text-color.txt: New.
	* exp/annotating/saturation/text-img.txt: New.
	* exp/annotating/saturation/text-only.txt: New.
	* exp/annotating/stddev_color/Makefile.am: New.
	* exp/annotating/stddev_color/stddev_color.cc: New.
	* exp/annotating/stddev_color_16/Makefile.am: New.
	* exp/annotating/stddev_color_16/stddev_color_16.cc: New.
	* exp/annotating/value/Makefile.am: New.
	* exp/annotating/value/text-color.txt: New.
	* exp/annotating/value/text-img.txt: New.
	* exp/annotating/value/text-only.txt: New.
	* exp/annotating/value/value.cc: New.
	* mln/clustering/kmean2d.hh: New.
	* mln/fun/p2b/achromatic.hh: New.
	* mln/fun/v2v/hue_concentration.hh: New.
	* mln/fun/v2v/rgb_to_achromatism_map.hh: New.
	* mln/fun/v2v/rgb_to_hsv.hh: New.
parent 175ec2f5
2010-09-08 Yann Jacquelet <jacquelet@lrde.epita.fr>
Import annotating sources from milena green's sandbox.
* README.green: New.
* demo/annotating/bic/Makefile.am: New.
* demo/annotating/bic/bic.cc: New.
* demo/annotating/hsv/Makefile.am: New.
* demo/annotating/hsv/hsv.cc: New.
* demo/annotating/lep/Makefile.am: New.
* demo/annotating/lep/lep.cc: New.
* demo/annotating/nb_color/Makefile.am: New.
* demo/annotating/nb_color/nb_color.cc: New.
* demo/annotating/project/Makefile.am: New.
* demo/annotating/project/project.cc: New.
* demo/annotating/rgb_64/Makefile.am: New.
* demo/annotating/rgb_64/rgb_64.cc: New.
* demo/annotating/rgb_64_9/Makefile.am: New.
* demo/annotating/rgb_64_9/rgb_64_9.cc: New.
* demo/annotating/stddev_color/Makefile.am: New.
* demo/annotating/stddev_color/stddev_color.cc: New.
* demo/annotating/stddev_color_16/Makefile.am: New.
* demo/annotating/stddev_color_16/stddev_color_16.cc: New.
* exp/annotating/achromastism/Makefile.am: New.
* exp/annotating/achromastism/achromastism.cc: New.
* exp/annotating/achromastism/text-color.txt: New.
* exp/annotating/achromastism/text-img.txt: New.
* exp/annotating/achromastism/text-only.txt: New.
* exp/annotating/bench/Makefile.am: New.
* exp/annotating/bench/bench.cc: New.
* exp/annotating/error/Makefile.am: New.
* exp/annotating/error/error.cc: New.
* exp/annotating/histo/Makefile.am: New.
* exp/annotating/histo/histo.cc: New.
* exp/annotating/hsv/Makefile.am: New.
* exp/annotating/hsv/hsv.cc: New.
* exp/annotating/hue/Makefile.am: New.
* exp/annotating/hue/hue.cc: New.
* exp/annotating/hue/text-color.txt: New.
* exp/annotating/hue/text-img.txt: New.
* exp/annotating/hue/text-only.txt: New.
* exp/annotating/nb_color/Makefile.am: New.
* exp/annotating/nb_color/nb_color.cc: New.
* exp/annotating/saturation/Makefile.am: New.
* exp/annotating/saturation/saturation.cc: New.
* exp/annotating/saturation/text-color.txt: New.
* exp/annotating/saturation/text-img.txt: New.
* exp/annotating/saturation/text-only.txt: New.
* exp/annotating/stddev_color/Makefile.am: New.
* exp/annotating/stddev_color/stddev_color.cc: New.
* exp/annotating/stddev_color_16/Makefile.am: New.
* exp/annotating/stddev_color_16/stddev_color_16.cc: New.
* exp/annotating/value/Makefile.am: New.
* exp/annotating/value/text-color.txt: New.
* exp/annotating/value/text-img.txt: New.
* exp/annotating/value/text-only.txt: New.
* exp/annotating/value/value.cc: New.
* mln/clustering/kmean2d.hh: New.
* mln/fun/p2b/achromatic.hh: New.
* mln/fun/v2v/hue_concentration.hh: New.
* mln/fun/v2v/rgb_to_achromatism_map.hh: New.
* mln/fun/v2v/rgb_to_hsv.hh: New.
2010-07-07 Yann Jacquelet <jacquelet@lrde.epita.fr>
Import regional maxima sources from milena green's sandbox.
......
This diff is collapsed.
#
# Generic Makefile
#
#########
# TOOLS #
#########
#LOADLIBES= -lboost_filesystem
INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
INCLUDES2= -I$(HOME)/git/olena/milena
INCLUDES= $(INCLUDES1) $(INCLUDES2)
CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
ECHO= echo
RM= rm
MKDIR= mkdir -p
CP= cp
SOURCE_PATTERN= green/demo
BUILD__PATTERN= green/build/demo
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
# Case where make is done from build directory.
SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
BUILD__DIR= $(PWD)/
else
# Case where make is done from source directory.
SOURCE_DIR= $(PWD)/
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
OBJ= $(patsubst %.cc,%.o,$(SRC))
SOURCE_MAKEFILE=Makefile.am
BUILD__MAKEFILE=Makefile
TARGET_FILE= $(notdir $(PWD))
SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
#############
# BOOTSTRAP #
#############
bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
# Create, if nessary, the destination directory
$(BUILD__DIR):
$(MKDIR) $(BUILD__DIR)
# Copy, if nessary, all the files, except the Makefile.am
$(BUILD__F_PATH): $(SOURCE_F_PATH)
$(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
# Copy if nessary, the Makefile.am into Makefile
$(BUILD__M_PATH): $(SOURCE_M_PATH)
$(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
#######
# ALL #
#######
# We assume that the call is done from the build directory.
# With the directive vpath, hidden files are found in the source directory.
all: $(TARGET_F_PATH)
$(TARGET_F_PATH): $(OBJ_F_PATH)
$(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
$(OBJ_F_PATH):$(SRC_F_PATH)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
#########
# CLEAN #
#########
# Force every time the deletion
clean: clean_target clean_obj clean_dst clean_old #clean_make
clean_target:
-@$(RM) $(TARGET_F_PATH) &> /dev/null
clean_obj:
-@$(RM) $(OBJ_F_PATH) &> /dev/null
clean_dst:
-@$(RM) $(BUILD_F_PATH) &> /dev/null
clean_make:
-@$(RM) $(BUILD_M_PATH) &> /dev/null
clean_old:
-@$(RM) $(OLD_F_PATH) &> /dev/null
#########
# PRINT #
#########
print: print_tools print_bootstrap
print_tools:
@$(ECHO) "HOME = $(HOME)"
@$(ECHO) "INCLUDES = $(INCLUDES)"
@$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
@$(ECHO) "ECHO = $(ECHO)"
@$(ECHO) "RM = $(RM)"
@$(ECHO) "MKDIR = $(MKDIR)"
@$(ECHO) "CP = $(CP)"
@$(ECHO)
print_bootstrap:
@$(ECHO) "PWD = $(PWD)"
@$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
@$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
@$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
@$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
@$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
@$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
@$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
@$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
@$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
@$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
@$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
@$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
@$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
@$(ECHO) "SRC = $(SRC)"
@$(ECHO) "OBJ = $(OBJ)"
@$(ECHO) "OLD = $(OLD)"
@$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
@$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
@$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
@$(ECHO)
// Copyright (C) 2007, 2008, 2009, 2010 EPITA LRDE
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to produce
// an executable, this file does not by itself cause the resulting
// executable to be covered by the GNU General Public License. This
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
/// \file
///
/// \brief Implement the Millet BIC descriptor [millet.phd.2008.pdf]
///
/// This is an image descriptor. It quantifies the three channels on 3
/// bits, then builds two histograms with the interior pixels and the
/// exterior ones. The interior pixels are those where color value is
/// the same as their 4 neighbouring pixels. The descriptor is the
/// fusion of the two histograms.
#include <iostream>
#include <mln/accu/stat/histo3d_rgb.hh>
#include <mln/core/image/image2d.hh>
#include <mln/core/alias/neighb2d.hh>
#include <mln/core/routine/initialize.hh>
#include <mln/core/var.hh>
#include <mln/data/compute.hh>
#include <mln/data/convert.hh>
#include <mln/data/transform.hh>
#include <mln/data/fill.hh>
#include <mln/debug/println.hh>
#include <mln/fun/v2v/rgb8_to_rgbn.hh>
#include <mln/img_path.hh>
#include <mln/io/ppm/load.hh>
#include <mln/io/ppm/save.hh>
#include <mln/io/plot/save_image_sh.hh>
#include <mln/literal/colors.hh>
#include <mln/value/rgb.hh>
#include <mln/value/rgb8.hh>
/// \brief Main entry.
///
/// Load the images, compute the interior and the exterior with the
/// predicate, then compute the two histograms separately.
int main()
{
typedef mln::value::rgb<3> t_rgb3;
typedef mln::value::rgb8 t_rgb8;
typedef mln::neighb2d t_neighb2d;
typedef mln::image2d<t_rgb3> t_image2d_rgb3;
typedef mln::image2d<t_rgb8> t_image2d_rgb8;
typedef mln::image3d<unsigned> t_histo3d;
typedef mln::fun::v2v::rgb8_to_rgbn<3> t_rgb8_to_rgb3;
typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
t_image2d_rgb8 input_rgb8;
t_image2d_rgb3 input_rgb3;
t_image2d_rgb3 interior_rgb3;
t_image2d_rgb3 exterior_rgb3;
t_histo3d histo_exterior;
t_histo3d histo_interior;
// IMAGE LOADING PHASE
std::cout << "Image loading phase ..." << std::endl;
mln::io::ppm::load(input_rgb8, ICDAR_50P_PPM_IMG_PATH"/mp00082c_50p.ppm");
input_rgb3 = mln::data::transform(input_rgb8, t_rgb8_to_rgb3());
mln::initialize(interior_rgb3, input_rgb3);
mln::initialize(exterior_rgb3, input_rgb3);
mln::data::fill(interior_rgb3, mln::literal::black);
mln::data::fill(exterior_rgb3, mln::literal::black);
mln_piter_(t_image2d_rgb3) p(input_rgb3.domain());
mln_niter_(t_neighb2d) n(mln::c4(), p);
for_all(p)
{
bool is_interior = true;
for_all(n)
is_interior = is_interior && (input_rgb3(p) == input_rgb3(n));
if (is_interior)
interior_rgb3(p) = input_rgb3(p);
else
exterior_rgb3(p) = input_rgb3(p);
}
histo_interior = mln::data::compute(t_histo3d_fun(), interior_rgb3);
histo_exterior = mln::data::compute(t_histo3d_fun(), exterior_rgb3);
//mln::io::plot::save_image_sh(histo, "histo.sh");
// PRINTING PHASE
mln::debug::println(histo_interior);
mln::debug::println(histo_exterior);
}
#
# Generic Makefile
#
#########
# TOOLS #
#########
#LOADLIBES= -lboost_filesystem
INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
INCLUDES2= -I$(HOME)/git/olena/milena
INCLUDES= $(INCLUDES1) $(INCLUDES2)
CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
ECHO= echo
RM= rm
MKDIR= mkdir -p
CP= cp
SOURCE_PATTERN= green/demo
BUILD__PATTERN= green/build/demo
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
# Case where make is done from build directory.
SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
BUILD__DIR= $(PWD)/
else
# Case where make is done from source directory.
SOURCE_DIR= $(PWD)/
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
OBJ= $(patsubst %.cc,%.o,$(SRC))
SOURCE_MAKEFILE=Makefile.am
BUILD__MAKEFILE=Makefile
TARGET_FILE= $(notdir $(PWD))
SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
#############
# BOOTSTRAP #
#############
bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
# Create, if nessary, the destination directory
$(BUILD__DIR):
$(MKDIR) $(BUILD__DIR)
# Copy, if nessary, all the files, except the Makefile.am
$(BUILD__F_PATH): $(SOURCE_F_PATH)
$(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
# Copy if nessary, the Makefile.am into Makefile
$(BUILD__M_PATH): $(SOURCE_M_PATH)
$(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
#######
# ALL #
#######
# We assume that the call is done from the build directory.
# With the directive vpath, hidden files are found in the source directory.
all: $(TARGET_F_PATH)
$(TARGET_F_PATH): $(OBJ_F_PATH)
$(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
$(OBJ_F_PATH):$(SRC_F_PATH)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
#########
# CLEAN #
#########
# Force every time the deletion
clean: clean_target clean_obj clean_dst clean_old #clean_make
clean_target:
-@$(RM) $(TARGET_F_PATH) &> /dev/null
clean_obj:
-@$(RM) $(OBJ_F_PATH) &> /dev/null
clean_dst:
-@$(RM) $(BUILD_F_PATH) &> /dev/null
clean_make:
-@$(RM) $(BUILD_M_PATH) &> /dev/null
clean_old:
-@$(RM) $(OLD_F_PATH) &> /dev/null
#########
# PRINT #
#########
print: print_tools print_bootstrap
print_tools:
@$(ECHO) "HOME = $(HOME)"
@$(ECHO) "INCLUDES = $(INCLUDES)"
@$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
@$(ECHO) "ECHO = $(ECHO)"
@$(ECHO) "RM = $(RM)"
@$(ECHO) "MKDIR = $(MKDIR)"
@$(ECHO) "CP = $(CP)"
@$(ECHO)
print_bootstrap:
@$(ECHO) "PWD = $(PWD)"
@$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
@$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
@$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
@$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
@$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
@$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
@$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
@$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
@$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
@$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
@$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
@$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
@$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
@$(ECHO) "SRC = $(SRC)"
@$(ECHO) "OBJ = $(OBJ)"
@$(ECHO) "OLD = $(OLD)"
@$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
@$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
@$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
@$(ECHO)
This diff is collapsed.
#
# Generic Makefile
#
#########
# TOOLS #
#########
#LOADLIBES= -lboost_filesystem
INCLUDES1= -I$(HOME)/git/olena/scribo/sandbox/green
INCLUDES2= -I$(HOME)/git/olena/milena
INCLUDES= $(INCLUDES1) $(INCLUDES2)
CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O3 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
ECHO= echo
RM= rm
MKDIR= mkdir -p
CP= cp
SOURCE_PATTERN= green/demo
BUILD__PATTERN= green/build/demo
ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
# Case where make is done from build directory.
SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
BUILD__DIR= $(PWD)/
else
# Case where make is done from source directory.
SOURCE_DIR= $(PWD)/
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
OBJ= $(patsubst %.cc,%.o,$(SRC))
SOURCE_MAKEFILE=Makefile.am
BUILD__MAKEFILE=Makefile
TARGET_FILE= $(notdir $(PWD))
SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
#############
# BOOTSTRAP #
#############
bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
# Create, if nessary, the destination directory
$(BUILD__DIR):
$(MKDIR) $(BUILD__DIR)
# Copy, if nessary, all the files, except the Makefile.am
$(BUILD__F_PATH): $(SOURCE_F_PATH)
$(CP) $(addprefix $(SOURCE_DIR),$(@F)) $@
# Copy if nessary, the Makefile.am into Makefile
$(BUILD__M_PATH): $(SOURCE_M_PATH)
$(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
#######
# ALL #
#######
# We assume that the call is done from the build directory.
# With the directive vpath, hidden files are found in the source directory.
all: $(TARGET_F_PATH)
$(TARGET_F_PATH): $(OBJ_F_PATH)
$(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
$(OBJ_F_PATH):$(SRC_F_PATH)
$(COMPILE.cc) $(OUTPUT_OPTION) $<
#########
# CLEAN #
#########
# Force every time the deletion
clean: clean_target clean_obj clean_dst clean_old #clean_make
clean_target:
-@$(RM) $(TARGET_F_PATH) &> /dev/null
clean_obj:
-@$(RM) $(OBJ_F_PATH) &> /dev/null