Skip to content

Instantly share code, notes, and snippets.

@rday
Last active November 11, 2015 22:26
Show Gist options
  • Save rday/621bb8dccb18f1d27fc2 to your computer and use it in GitHub Desktop.
Save rday/621bb8dccb18f1d27fc2 to your computer and use it in GitHub Desktop.
Proposed patch for makesetup
--- a/Modules/makesetup 2015-02-25 06:27:46.000000000 -0500
+++ b/Modules/makesetup 2015-11-11 16:18:44.831994585 -0500
@@ -128,7 +128,7 @@
# Output DEFS in reverse order so first definition overrides
case $line in
- *=*) DEFS="$line$NL$DEFS"; continue;;
+ [A-Za-z]*=*) DEFS="$line$NL$DEFS"; continue;;
'include '*) DEFS="$line$NL$DEFS"; continue;;
'*noobjects*')
case $noobjects in
Context:
I'm cross compiling Python 3.4.3 to the Rumpkernel NetBSD platform. This requires a static Python
build. I've got Python compiling just fine. I'm compiling several static modules as well. Python
runs, and I can run applications written in Python.
I'm trying to statically build the _sqlite3 extension. The extension must link with my static
cross compiled sqlite3 library, not the host library. The easiest way (I think) to do this is by
adding _sqlite3 files, includes, and libraries to the Setup.local file under Modules/.
_sqlite3 \
-DMODULE_NAME='"sqlite3"' \
_sqlite/cache.c _sqlite/microprotocols.c _sqlite/row.c \
_sqlite/connection.c _sqlite/module.c _sqlite/statement.c \
_sqlite/cursor.c _sqlite/prepare_protocol.c _sqlite/util.c \
-IModules/_sqlite \
-I../../sqlite -L../../sqlite/.libs -lsqlite3
This will include my sqlite headers, and my cross compiled sqlite library.
The problem is that -DMODULE_NAME='"sqlite3"' is required to build the extension. But the
"makesetup" script doesn't like the '=' sign. "makesetup" treats the entire line as a
variable definition and doesn't build the extension.
This patch makes "makesetup" only recognize definitions of variables that are uppercase or
lowercase letters. This will let any -DX=Y work because the spaces in the line won't be matched.
The patch works for my specific use case. I'm wondering if there is some obvious problem
I'm missing, or some better way of doing this that I'm not thinking about.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment