Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…80b4-e980-4839-00ea3ed24e77
  • Loading branch information
valery.isaev@gmail.com committed May 30, 2011
1 parent 95968c2 commit 55f7bad
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
23 changes: 15 additions & 8 deletions trunk/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
bin_PROGRAMS = pn

FILE_CONF = file.conf
pkgdata_DATA = $(FILE_CONF)

if DISABLE_IMAGES
else
images_pn_sources = src/file_types/img.cpp src/file_types/img.h
images_pn_cxxflags = -I/usr/include/ImageMagick
images_pn_ldadd = -lMagick++
endif

pn_SOURCES = \
src/logger.cpp \
src/file_types/img.cpp \
src/file_types/base.cpp \
src/file_types/text.cpp \
src/program_options.cpp \
Expand All @@ -13,7 +22,6 @@ pn_SOURCES = \
src/file_typer.cpp \
src/clusterization.cpp \
src/logger.h \
src/file_types/img.h \
src/file_types/text.h \
src/file_types/base.h \
src/kleisli.h \
Expand All @@ -24,14 +32,13 @@ pn_SOURCES = \
src/file_types.h \
src/clusterization.h \
src/file_typer.h \
src/filesystem.h
src/filesystem.h \
$(images_pn_sources) \
$(FILE_CONF)

file_conf = file.conf
pkgdata_DATA = $(file_conf)
pn_CXXFLAGS = $(images_pn_cxxflags) -DDATA_DIR='"$(pkgdatadir)"'
pn_LDADD = $(images_pn_ldadd) -lboost_program_options -lboost_filesystem -lboost_system

uninstall: uninstall-am
@echo " ( rmdir '$(pkgdatadir)' )"
-@rmdir '$(pkgdatadir)'

pn_CXXFLAGS = -I/usr/include/ImageMagick -DDATA_DIR='"$(pkgdatadir)"' -DFILE_CONF='"$(file_conf)"'
pn_LDADD = -lMagick++ -lboost_program_options -lboost_filesystem -lboost_system
33 changes: 30 additions & 3 deletions trunk/configure.in
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
AC_PREREQ([2.68])
AC_INIT([pn], [0.1], [valery.isaev@gmail.com])
AC_INIT([pn], [0.1], [valery.isaev(at)gmail.com])

AC_CONFIG_SRCDIR([src/main.cpp])
AC_CONFIG_HEADER(config.h)

AM_INIT_AUTOMAKE([1.9 foreign])
AM_INIT_AUTOMAKE

AC_PROG_CXX

AC_CHECK_HEADERS([magic.h])
AC_CHECK_LIB(magic, magic_file)

AC_MSG_CHECKING([if image support enabled])
AC_ARG_WITH([images],
[ --with-images enable image support],
[ if test "x$with_images" = "xyes"; then
AC_MSG_RESULT([yes])
else
AC_DEFINE(DISABLE_IMAGES, [], [Disable image support])
AC_MSG_RESULT([no])
fi
], [AC_MSG_RESULT([yes])])
AM_CONDITIONAL(DISABLE_IMAGES, test "x$with_images" = "xno")

if test "x$with_images" != "xno"; then
AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, yes, no)
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test "x$HAVE_PKGCONFIG" = "xyes"; then
PKG_CHECK_MODULES(ImageMagick, Magick++, [], [
if test "x$with_images" = "xyes"; then
AC_MSG_ERROR($ImageMagick_PKG_ERRORS)
else
AC_MSG_WARN($ImageMagick_PKG_ERRORS)
fi
])
fi
fi

AC_DEFINE_UNQUOTED(FILE_CONF, "file.conf", [Configuration file name])

AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
Expand Down
14 changes: 12 additions & 2 deletions trunk/src/file_types.h
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#ifndef _FILE_TYPES_H_
#define _FILE_TYPES_H_

#include "../config.h"
#include "type_list.h"

#include "file_types/text.h"
#include "file_types/img.h"
#include "file_types/base.h"

#ifndef DISABLE_IMAGES
#include "file_types/img.h"
#endif

typedef
cons< file_type::base,
cons< file_type::text,
#ifndef DISABLE_IMAGES
cons< file_type::img,
nil > > > unsorted_file_types_list;
#endif
nil
#ifndef DISABLE_IMAGES
>
#endif
> > unsorted_file_types_list;

typedef type_sort<unsorted_file_types_list>::result file_types_list;

Expand Down
4 changes: 3 additions & 1 deletion trunk/src/program_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "program_options.h"
#include "filesystem.h"
#include "../config.h"
#include <stdio.h>

namespace po = boost::program_options;

Expand Down Expand Up @@ -64,7 +65,7 @@ static void parse_config_file(po::options_description config_file_options, po::v
#ifndef DATA_DIR
return;
#endif
file_name = fs::path(DATA_DIR) / FILE_CONF;
file_name = fs::path(DATA_DIR) / PACKAGE / FILE_CONF;
if (!exists(file_name)) {
return;
}
Expand Down Expand Up @@ -167,6 +168,7 @@ void program_options::initialize(int argc, char* argv[]) {
} else {
_text_threshold = text_threshold;
}
printf("%d\n", _text_threshold);
} catch(std::exception const& e) {
logger::std(e.what());
exit(1);
Expand Down

0 comments on commit 55f7bad

Please sign in to comment.