Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Cygwin path to Windows path in a makefile

How can I convert a Cygwin style path ( /cygdrive/c/foo/bar ) to Windows style ( C:/foo/bar ) (yes, with / going forward) in a GNU makefile? I have the situation of using Cygwin's make with a GCC that does not understand Cygwin style paths, so paths relative to the makefiles location that are produced by make are not accepted by the compiler.

like image 532
grrussel Avatar asked Dec 09 '10 16:12

grrussel


People also ask

How do I change the PATH in Cygwin?

Update the PATH environment variable: From the Start menu, select Parameters > Control Panel > System. Select the Advanced tab and click Environment variables. Edit the PATH environment variable to add the Cygwin installation directory, for example c:\cygwin\bin; and click OK.

Where does Cygwin store files windows?

The Cygwin DLL supports user specific fstab files. These are stored in the directory /etc/fstab. d and the name of the file is the Cygwin username of the user, as it's created from the Windows account database or stored in the /etc/passwd file (see the section called “Mapping Windows accounts to POSIX accounts”).

What is Cygpath EXE?

Description. The cygpath program is a utility that converts Windows native filenames to Cygwin POSIX-style pathnames and vice versa. It can be used when a Cygwin program needs to pass a file name to a native Windows program, or expects to get a file name from a native Windows program.

Where is Cygdrive on Windows?

Using Cygwin As noted, Cygwin provides a Unix-like environment under Windows. The installation directory (by default, c:\cygwin) is the root of the Unix-like file system, which contains bin, etc, home, tmp, and usr directories as would be found on a GNU/Linux or other Unix system.


1 Answers

Use the shell function to execute the cygpath utility with the -w flag.

Example:

BAR := /cygdrive/c/foo/bar
WIN_BAR := $(shell cygpath -w ${BAR})

cygpath accepts a lot of additional options. See the man page for details.

like image 199
Dan Moulding Avatar answered Oct 17 '22 22:10

Dan Moulding