diff --git a/configure.ac b/configure.ac index 31a9f1ce3..ee43d1092 100644 --- a/configure.ac +++ b/configure.ac @@ -275,6 +275,12 @@ fi fi fi +# hack to define a short filename also for out-of-tree build +if test `dirname $0` = `pwd`; then + HWLIB_CFLAGS="$HWLIB_CFLAGS "'-D__file__=__FILE__' +else + HWLIB_CFLAGS="$HWLIB_CFLAGS "'-D__file__="\"$(subst $(srcdir)/,,$(abspath $<))\""' +fi # # Check for libtdservicedb - the new one - for testing only # diff --git a/src/driver/scanepg.cpp b/src/driver/scanepg.cpp index d13ad599c..efd61a213 100644 --- a/src/driver/scanepg.cpp +++ b/src/driver/scanepg.cpp @@ -17,7 +17,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#define __NFILE__ 1 #ifdef HAVE_CONFIG_H #include #endif diff --git a/src/gui/scan_setup.cpp b/src/gui/scan_setup.cpp index d16914c6b..4e6592de0 100644 --- a/src/gui/scan_setup.cpp +++ b/src/gui/scan_setup.cpp @@ -59,7 +59,6 @@ #include #include #include -#define __NFILE__ 1 #include #include diff --git a/src/neutrino.cpp b/src/neutrino.cpp index f54befa8b..1b94f25de 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -29,7 +29,6 @@ #include #endif -#define __NFILE__ 1 #define NEUTRINO_CPP #include diff --git a/src/zapit/include/zapit/debug.h b/src/zapit/include/zapit/debug.h index 6a7ed9e6f..f36d74415 100644 --- a/src/zapit/include/zapit/debug.h +++ b/src/zapit/include/zapit/debug.h @@ -2,7 +2,7 @@ * $Id: debug.h,v 1.7 2003/04/30 04:39:03 obi Exp $ * * (C) 2002-2003 Andreas Oberritter - * (C) 2011,2013 Stefan Seyfried + * (C) 2011,2013,2016 Stefan Seyfried * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,35 +45,18 @@ /* zapit.cpp */ extern int zapit_debug; -#if defined __NFILE__ -/* this is ugly. - * __FILE__ here is /.../zapit/include/debug.h when building outside the - * source tree, but it is ../../src/zapit/include/zapit/debug.h (relative), - * when building inside the source_tree. - * So we cannot find the real filename here. Hack: when including this file - * from src/neutrino.cpp, src/gui/..., __NFILE__ is defined => strip less characters - * Later on, __FILE__ is the real filename, so if it starts with ../ now, the build - * is from within the source tree => __FILE__ is only basename => strip nothing */ -static int __striplen = (strncmp(__FILE__, "../", 3) == 0) ? 0 : - (strstr(__FILE__, "src/zapit") != NULL) ? (strstr(__FILE__, "src/zapit") - __FILE__ + 4) : 0; -#else -static int __striplen = (strncmp(__FILE__, "../", 3) == 0) ? 0 : - (strstr(__FILE__, "src/zapit") != NULL) ? (strstr(__FILE__, "src/zapit") - __FILE__ + 14) : 0; -#endif -#define __SHORTFILE__ (__FILE__ + __striplen) - #define DBG(fmt, args...) \ do { \ if (zapit_debug) \ fprintf(stdout, "[%s:%s:%d] " fmt, \ - __SHORTFILE__, __FUNCTION__, \ + __file__, __func__, \ __LINE__ , ## args); \ } while (0) #define ERROR(str) \ do { \ fprintf(stderr, "[%s:%s:%d] %s: %s\n", \ - __SHORTFILE__, __FUNCTION__, \ + __file__, __func__, \ __LINE__, str, strerror(errno)); \ } while (0) @@ -82,14 +65,14 @@ static int __striplen = (strncmp(__FILE__, "../", 3) == 0) ? 0 : #define INFO(fmt, args...) \ do { \ fprintf(stdout, "[%s:%s:%d] " fmt "\n", \ - __SHORTFILE__, __FUNCTION__, \ + __file__, __func__, \ __LINE__ , ## args); \ } while (0) #define WARN(fmt, args...) \ do { \ fprintf(stderr, "[%s:%s:%d] " fmt "\n", \ - __SHORTFILE__, __FUNCTION__, \ + __file__, __func__, \ __LINE__ , ## args); \ } while (0)