How do I define a path from an MSYS Makefile for a C++ program?
Asked Answered
Q

1

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?

Quinquennial answered 26/10, 2016 at 8:46 Comment(0)
Q
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.

Quinquennial answered 26/10, 2016 at 8:46 Comment(2)
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.Slipknot
I guess cygwin is again different from msys...Quinquennial

© 2022 - 2024 — McMap. All rights reserved.