Skip to content

Commit

Permalink
For issue#92, flip the sense of the "USE_INSTALLED_TRE_H" flag and re…
Browse files Browse the repository at this point in the history
…name it to "USE_LOCAL_TRE_H", then add definitions in all local builds.
  • Loading branch information
trushworth committed Jul 17, 2023
1 parent 896ed7e commit 07e66d0
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 17 deletions.
3 changes: 3 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ dnl Checks for headers, functions, types, and macros
AC_DEFINE(_GNU_SOURCE, 1, [ Define to enable GNU extensions in glibc ])
AC_HEADER_STDC

dnl Make sure locally configured headers are used (this adds the #define to config.h).
AC_DEFINE(USE_LOCAL_TRE_H, 1, [ Define to ensure locally configured headers are used ])

AC_ARG_WITH(alloca,
AC_HELP_STRING(
[--without-alloca],
Expand Down
12 changes: 6 additions & 6 deletions local_includes/regex.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
#ifndef TRE_REXEX_H
#define TRE_REGEX_H 1

#ifdef USE_INSTALLED_TRE_H
/* Use the header(s) from an installed version of the TRE package
(so that this application matches the installed libtre),
not the one(s) in the local_includes directory. */
#include <tre/tre.h>
#else
#ifdef USE_LOCAL_TRE_H
/* Use the header(s) from the TRE package that this file is part of.
(Yes, this file is in local_include too, but the explict path
means there is no way to get a system tre.h by accident.) */
#include "../local_includes/tre.h"
#else
/* Use the header(s) from an installed version of the TRE package
(so that this application matches the installed libtre),
not the one(s) in the local_includes directory. */
#include <tre/tre.h>
#endif

#ifndef TRE_USE_SYSTEM_REGEX_H
Expand Down
8 changes: 4 additions & 4 deletions local_includes/tre.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#ifndef TRE_H
#define TRE_H 1

#ifdef USE_INSTALLED_TRE_H
/* Use the header in the same directory as this file if there is one. */
#include "tre-config.h"
#else
#ifdef USE_LOCAL_TRE_H
/* Make certain to use the header(s) from the TRE package that this
file is part of by giving the full path to the header from this directory. */
#include "../local_includes/tre-config.h"
#else
/* Use the header in the same directory as this file if there is one. */
#include "tre-config.h"
#endif

#ifdef HAVE_SYS_TYPES_H
Expand Down
3 changes: 2 additions & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
data_files = data_files,
ext_modules = [Extension("tre",
sources = ["tre-python.c"],
define_macros = [("HAVE_CONFIG_H", None)],
define_macros = [("HAVE_CONFIG_H", None),
("USE_LOCAL_TRE_H",1)],
include_dirs = include_dirs,
library_dirs = library_dirs,
libraries = libraries
Expand Down
3 changes: 2 additions & 1 deletion python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ setup(name = "tre",
data_files = data_files,
ext_modules = [Extension("tre",
sources = ["tre-python.c"],
define_macros = [("HAVE_CONFIG_H", None)],
define_macros = [("HAVE_CONFIG_H", None),
("USE_LOCAL_TRE_H",1)],
include_dirs = include_dirs,
library_dirs = library_dirs,
libraries = libraries
Expand Down
10 changes: 5 additions & 5 deletions python/tre-python.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
#include "Python.h"
#include "structmember.h"

#ifdef USE_INSTALLED_TRE_H
#ifdef USE_LOCAL_TRE_H
/* Make certain to use the header(s) from the TRE package that this
file is part of by giving the full path to the header from this directory. */
#include "../local_includes/tre.h"
#else
/* Use the header(s) from an installed version of the TRE package
(so that this extension matches the installed libtre),
not the one(s) in the local_includes directory. */
#include <tre/tre.h>
#else
/* Make certain to use the header(s) from the TRE package that this
file is part of by giving the full path to the header from this directory. */
#include "../local_includes/tre.h"
#endif

/* Define this if you want to release the GIL during compilation or searching.
Expand Down
1 change: 1 addition & 0 deletions wscript
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ def configure(cfg):
# file will remove the named defines from the DEFINES list, leaving only the ones meant
# for the compiler command line.
cfg.env.append_unique("DEFINES","HAVE_CONFIG_H=1") # no entry in the list of names, so this ends up on the compiler command line.
cfg.env.append_unique("DEFINES","USE_LOCAL_TRE_H=1") # no entry in the list of names, so this ends up on the compiler command line.
# ================= Platform specific feature availability
# Get a platform specific env for discovering what the platform has available.
# It is derived from the original, so it has all the values set up above.
Expand Down

0 comments on commit 07e66d0

Please sign in to comment.