diff --git a/configure.ac b/configure.ac index f29068e..7c91496 100644 --- a/configure.ac +++ b/configure.ac @@ -26,4 +26,37 @@ AC_CONFIG_FILES([ src/Makefile ]) +# geonames.org support +AC_ARG_ENABLE( + [geonames], + [AS_HELP_STRING([--enable-geonames], [enable support geonames.org geocoding (def=yes)])], + [enable_geonames=$enableval], + [enable_geonames=yes] +) + +AM_CONDITIONAL([GEONAMES_SUPPORT], [test x"$enable_geonames" = x"yes"]) +if test x"$enable_geonames" = x"yes"; then + AC_DEFINE([GEONAMES_SUPPORT], [], [Geonames geocoding]) + PKG_CHECK_MODULES([DEPS_GEONAMES], [libcurl >= 7.21, json >= 0.9]) +fi + + +AC_DEFINE([GEONAMES_SUPPORT], [1], [compile with geonames.org lookup capabilities]) + + +# debug compilation support +AC_ARG_ENABLE( + [debug], + [AS_HELP_STRING([--enable-debug], [enable debug data generation (def=no)])], + [debug=$enableval], + [debug=no] +) + +if test x"$debug" = x"yes"; then + AC_DEFINE([DEBUG], [], [enable debugging]) + AM_CXXFLAGS="$AM_CXXFLAGS -g -Wall -Werror -Wno-uninitialized -O0 -fno-omit-frame-pointer -Woverloaded-virtual -Wno-system-headers" +else + AM_CXXFLAGS="$AM_CXXFLAGS -O3" +fi + AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 03eb786..568af56 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,16 @@ -bin_PROGRAMS = sun geonames +bin_PROGRAMS = sun -sun_SOURCES = sun_main.c sun.c geonames.c -sun_LDADD = -lm -lcurl -ljson +sun_SOURCES = sun_main.c sun.c +sun_LDADD = -lm -geonames_SOURCES = geonames_main.c geonames.c -geonames_LDADD = -lcurl -ljson +if GEONAMES_SUPPORT + bin_PROGRAMS += geonames + + geonames_SOURCES = geonames_main.c geonames.c + geonames_LDADD = $(DEPS_GEONAMES_LIBS) + + sun_SOURCES += geonames.c + sun_LDADD += $(DEPS_GEONAMES_LIBS) + + AM_CFLAGS = $(DEPS_GEONAMES_CFLAGS) +endif diff --git a/src/sun.c b/src/sun.c index 5876b26..a2746a3 100644 --- a/src/sun.c +++ b/src/sun.c @@ -26,6 +26,7 @@ #include #include +#include "../config.h" #include "sun.h" double deg2rad(double deg) { diff --git a/src/sun.h b/src/sun.h index 36132dd..4140ef7 100644 --- a/src/sun.h +++ b/src/sun.h @@ -34,8 +34,6 @@ struct coords { double lat, lon; }; struct sun_coords { double dk, ra; }; -//#define DEBUG 1 -#define GEONAMES_SUPPORT 1 #define M_2PI (M_PI * 2) enum mode { RISE, SET, NOON, DAYTIME, NIGHTTIME };