diff --git a/checkrt.c b/checkrt.c index 613108b..bced186 100644 --- a/checkrt.c +++ b/checkrt.c @@ -18,6 +18,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ +#include "debug.h" #include #include @@ -47,7 +48,6 @@ char *optional = NULL; char *optional_ld_preload = NULL; -int debug_flag = 0; void checkrt(char *usr_in_appdir) { @@ -63,8 +63,6 @@ void checkrt(char *usr_in_appdir) char *gcc_bundle_lib = "./" GCCDIR "/libgcc_s.so.1"; const char *format = "tr '\\0' '\\n' < '%s' | grep -e '%s' | tail -n1"; - debug_flag = getenv("APPIMAGE_CHECKRT_DEBUG") ? 1 : 0; - if (access(stdcxx_bundle_lib, F_OK) == 0) { f = popen("ldconfig -p | grep 'libstdc++.so.6 (" LIBC6_ARCH ")' | awk 'NR==1{print $NF}'", "r"); ret = fscanf(f, "%s", stdcxx_sys_lib); (void)ret; diff --git a/checkrt.h b/checkrt.h index 4f8a72a..84f7720 100644 --- a/checkrt.h +++ b/checkrt.h @@ -1,9 +1,8 @@ +#ifndef CHEKRT_H +#define CHECKRT_H + extern char *optional; extern char *optional_ld_preload; extern void checkrt(char *usr_in_appdir); -extern int debug_flag; -#define DEBUG(...) do { \ - if (debug_flag) \ - printf(__VA_ARGS__); \ -} while (0) +#endif diff --git a/debug.h b/debug.h new file mode 100644 index 0000000..c6e6523 --- /dev/null +++ b/debug.h @@ -0,0 +1,11 @@ +#ifndef DEBUG_H +#define DEBUG_H + +#include + +#define DEBUG(...) do { \ + if (getenv("APPIMAGE_CHECKRT_DEBUG")) \ + printf(__VA_ARGS__); \ +} while (0) + +#endif // DEBUG_H diff --git a/exec.c b/exec.c index ccf2bd7..71b74cf 100644 --- a/exec.c +++ b/exec.c @@ -42,7 +42,7 @@ variable (e.g. "PATH"): #define _GNU_SOURCE -#include "checkrt.h" +#include "debug.h" #include #include