0

My problem: in a Makefile which I use in both the MSYS and the MSYS2 environment I know a path, PYTHON_ROOT_DIR, which shall be used at compilation time in a C++ program. Problem is PYTHON_ROOT_DIR is in the Makefile known as posix style path such as /mingw64/bin, where in the C++ program it shall have a form like "C:\\prog64\\msys64\\mingw64\\bin". Additional challenge is that depending on a configuration variable PYTHONMAJOR the path shall be wide characters or normal characters.

My question: how do I solve this in the Makefile without a need to install additional programs/scripts in the msys or msys2 environments?

Klamer Schutte
  • 1,063
  • 9
  • 18

1 Answers1

0

Part of the question is addressed in msys path conversion (or cygpath for msys?), namely how to convert a msys style path to a windows style path. My full solution in the Makefile is:

ifeq ($(PYTHONMAJOR),3)
    L=L
endif
DEFINES += -DPYTHON_ROOT_DIR=$(L)'"'$(shell (cmd //c echo $(PYTHON_ROOT_DIR)) | sed 's|/|\\\\\\\\|g')'"'

which defines the preprocessor symbol PYTHON_ROOT_DIR with the proper path.

Community
  • 1
  • 1
Klamer Schutte
  • 1,063
  • 9
  • 18
  • I thought this might be an issue with my Cygwin environment or any customizations, but I am finding this in libtool causing build issues for me causing sed to wait for input because this provides none. Executing this in a plain `cmd` prompt opens a new process that does not quit. Changing it to `cmd /c echo ...` may yield better results. – Pysis Sep 14 '21 at 20:10
  • 1
    I guess cygwin is again different from msys... – Klamer Schutte Nov 10 '21 at 15:11