diff --git a/Makefile.am b/Makefile.am index 5ce8a2e5..4b3d0ab0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,10 +8,6 @@ endif if DEBUG libledger_la_CXXFLAGS = -DDEBUG_LEVEL=4 libledger_la_SOURCES += debug.cc -else -if STANDALONE -libledger_a_CXXFLAGS = -DSGI_STL_USE_SINGLE_CLIENT_ALLOCATOR=1 -endif endif libledger_la_LDFLAGS = -version-info 2:0 @@ -20,10 +16,6 @@ libledger_la_LDFLAGS = -version-info 2:0 bin_PROGRAMS = ledger if DEBUG ledger_CXXFLAGS = -DDEBUG_LEVEL=4 -else -if STANDALONE -ledger_CXXFLAGS = -DSGI_STL_USE_SINGLE_CLIENT_ALLOCATOR=1 -endif endif ledger_SOURCES = main.cc ledger_LDADD = $(LIBOBJS) libledger.la @@ -73,5 +65,8 @@ bin_PROGRAMS += ledger.so ledger.so: python.cc libledger_bpy.a CFLAGS="$(CPPFLAGS) -L." python setup.py build --build-lib=. +install-exec-hook: + CFLAGS="$(CPPFLAGS) -L." python setup.py install --prefix=$(DESTDIR) + endif endif diff --git a/README b/README index acb74a71..50d7c7a2 100644 --- a/README +++ b/README @@ -3,26 +3,27 @@ Welcome to Ledger, a command-line accounting program. Quick start =========== -To build ledger, you will first need these two libraries installed: +To build Ledger, you will first need these two libraries installed: gmp GNU multi-precision library pcre Perl regular expression library -If you wish to read Gnucash data files, you will also need two XML libraries, -which may or may not be available in a single package (it depends on your -distribution): +If you wish to read Gnucash data files, you will also need two XML +libraries, which may or may not be available in a single package (it +depends on your distribution): xmlparse xmltok Once you have determined where the headers and libraries for the above -packages are installed, run the script "configure", passing those paths. If -you installed everything under /usr/local, you can probably just type -"./configure". Otherwise, do this: +packages are installed, run the script "configure", passing those +paths. If you installed everything under /usr/local, you can probably +just type "./configure". Otherwise, do this: ./configure CPPFLAGS=-I LDFLAGS=-L -If you need to specify multiple include or library paths, then do this: +If you need to specify multiple include or library paths, then do +this: ./configure CPPFLAGS="-I -I" LDFLAGS="-L -L" @@ -30,40 +31,12 @@ Once configure is done running, just type: make install -Building on OS/X -================ +Building Ledger as a Python Module +================================== -If you are building ledger for OS/X, there are a couple of things you can do -to ensure that it runs as quickly as possible. First, you will want to -configure ledger using this command, which you can cut and paste from here: - - ./configure CPPFLAGS="-I/sw/include -I/usr/include/httpd/xml" \ - LDFLAGS=-L/sw/lib \ - CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450" \ - --enable-standalone - -Next, if you are interested, we need to change the system headers so that -command-line ledger can use an STL allocator that is not thread-safe. Being -hread-safe has no benefit for the standalone, command-line version of ledger, -and so is needlessly 10% slower. However, there is no easy way to do this, -other than modifying the system headers. So, sudo over to a root shell, and -edit this file: - - /usr/include/gcc/darwin/3.3/c++/bits/stl_alloc.h - -Around line 617, you will find a typedef declaration that looks like this: - - typedef __default_alloc_template __alloc; - -Replace this line with the following block, which will permit the ledger -sources to select a different default allocator: - - #ifdef SGI_STL_USE_SINGLE_CLIENT_ALLOCATOR - typedef __default_alloc_template __alloc; - #else - typedef __default_alloc_template __alloc; - #endif - -The disadvantage to doing this, in general, is that an app using a different -default will not be able to link to other C++ libraries, which use another -default. But since ledger doesn't use any C++ libraries, this is no problem. +If you have Python 2.2 or higher installed, and Boost.Python, then +Ledger will also be built as a Python module. This means you can +interact with your Ledger data from Python, making it easier to write +very custom reporting code. See the developer documentation for +information on Ledger's interfaces, and for some example reports +written in Python. diff --git a/configure.in b/configure.in index 6fd1cbab..d295b3f8 100644 --- a/configure.in +++ b/configure.in @@ -58,15 +58,6 @@ AC_ARG_ENABLE(debug, esac],[debug=false]) AM_CONDITIONAL(DEBUG, test x$debug = xtrue) -AC_ARG_ENABLE(standalone, - [ --enable-standalone Build standalone on OS/X (see README)], - [case "${enableval}" in - yes) standalone=true ;; - no) standalone=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-standalone) ;; - esac],[standalone=false]) -AM_CONDITIONAL(STANDALONE, test x$standalone = xtrue) - # Checks for header files. AC_STDC_HEADERS AC_HAVE_HEADERS(sys/stat.h) diff --git a/main.py b/main.py new file mode 100644 index 00000000..d1e6cb10 --- /dev/null +++ b/main.py @@ -0,0 +1,11 @@ +import sys + +from ledger import * + +parser = TextualParser () +register_parser (parser) + +journal = Journal () +parse_journal_file (sys.argv[1], journal) + +print journal[-1].payee