Re: [AD] Patch for makefile issue when compiling MSVC with Cygwin

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Milan Mimica wrote:
On 19/12/06, Andrei Ellman <ae-a-alleg@xxxxxxxxxx> wrote:
+ifdef ALLEGRO_USE_CYGWIN
+
+# Note: Using ':=' instead of '=' to improve performance of parsing makefile.
+# ?: Is there a more elegant way of setting MSVCDIR_S? MSVCDIR_S := $(shell cygpath $(MSVCDIR_MSVCDIR)) does not seem to work.
+ifdef MSVCDIR
+   MSVCDIR_S := $(shell cygpath $$MSVCDIR)
+else
+ifdef MSVCDir
+   MSVCDIR_S := $(shell cygpath $$MSVCDir)
+endif
+endif
+
+   MSVCDIR_U = $(subst \,/,$(MSVCDIR_S))
+   MSVCDIR_D = $(subst /,\,$(MSVCDIR_S))
+else
+  MSVCDIR_U = $(subst \,/,$(MSVCDIR_MSVCDIR))
+   MSVCDIR_D = $(subst /,\,$(MSVCDIR_MSVCDIR))
+endif  # ALLEGRO_USE_CYGWIN

First, there is also VCINSTALLDIR to check.
Second, this isn't working for me. The following works, can you also try it out?

ifdef ALLEGRO_USE_CYGWIN

# Note: Using ':=' instead of '=' to improve performance of parsing
makefile.
# ?: Is there a more elegant way of setting MSVCDIR_S? MSVCDIR_S :=
$(shell cygpath $(MSVCDIR_MSVCDIR)) does not seem to work.
ifdef MSVCDIR
   MSVCDIR_S := $(shell cygpath -s -w "$(MSVCDIR)")
endif
ifdef MSVCDir
   MSVCDIR_S := $(shell cygpath -s -w "$(MSVCDir)")
endif
ifdef VCINSTALLDIR
   MSVCDIR_S := $(shell cygpath -s -w "$(VCINSTALLDIR)")
endif
   MSVCDIR_U = $(subst \,/,$(MSVCDIR_S))
   MSVCDIR_D = $(subst /,\,$(MSVCDIR_D))
else
   MSVCDIR_U = $(subst \,/,$(MSVCDIR_MSVCDIR))
   MSVCDIR_D = $(subst /,\,$(MSVCDIR_MSVCDIR))
endif  # ALLEGRO_USE_CYGWIN


But it would be really nice if we could pass a makefile variable there.


I tried out your suggestion, and it did not work with me. I then changed a few things round and it did.

Included is a patch against 4.2.1's makefile.vc that combines my previous patch and your suggestions. I suspect the reason that you could not get it to work was because the spaces weren't being removed from the environment variables. Most notably, instead of using
   MSVCDIR_S := $(shell cygpath -s -w $"$(MSVCDIR)")
I used
   MSVCDIR_S := $(shell cygpath `cygpath -d "$(MSVCDIR)"`)
This converts the path to DOS 8.3 format, and then converts the result to Cygwin format.

Also, the patched makefile contains a few comments and questions that might be worth looking in to.


AE.

--- makefile.vc.old	2006-11-26 12:13:58.000000000 +0100
+++ makefile.vc	2006-12-22 12:26:45.835766400 +0100
@@ -103,6 +103,14 @@
 
 .PHONY: badwin badmsvc badspaces
 
+ifdef ALLEGRO_USE_CYGWIN
+
+WINDIR_S = $(shell cygpath -S)
+WINDIR_U = $(subst \,/,$(WINDIR_S))
+WINDIR_D = $(subst /,\,$(WINDIR_S))
+
+else
+
 ifeq ($(OS),Windows_NT)
    WINSYSDIR = $(SYSTEMROOT)
    ifeq ($(WINSYSDIR),)
@@ -125,19 +133,51 @@
 	@echo Your SYSTEMROOT or windir environment variable is not set!
 endif
 
+endif # ALLEGRO_USE_CYGWIN
+
+
 ifdef MSVCDIR
-   MSVCDIR_U = $(subst \,/,$(MSVCDIR))
-   MSVCDIR_D = $(subst /,\,$(MSVCDIR))
+   MSVCDIR_MSVCDIR = $(MSVCDIR)
 else
 ifdef MSVCDir
-   MSVCDIR_U = $(subst \,/,$(MSVCDir))
-   MSVCDIR_D = $(subst /,\,$(MSVCDir))
+   MSVCDIR_MSVCDIR = $(MSVCDir)
+else
+ifdef VCINSTALLDIR
+   # The :msvccommon label of fix.bat includes the following line:
+   # if "%MSVCDir%" == "" set MSVCDir=%VCINSTALLDIR%
+   # Which would make 'ifdef VCINSTALLDIR MSVCDIR_MSVCDIR = $(VCINSTALLDIR)' redundant
+   # However, fix.sh currently does not include this functionality.
+   MSVCDIR_MSVCDIR = $(VCINSTALLDIR)
 else
 badmsvc:
-	@echo Your MSVCDIR environment variable is not set!
+	@echo Your MSVCDIR or MSVCDir or VCINSTALLDIR environment variable is not set!
 	@echo See the docs/build/msvc.txt file!
 endif
 endif
+endif
+
+ifdef ALLEGRO_USE_CYGWIN
+
+# Note: Using ':=' instead of '=' to improve performance of parsing makefile.
+# Note: In order to get the Cygwin-style path without spaces, we must first convert the path to DOS 8.3 format, and then convert the result to Cygwin format.
+# ?: By using the above technique, is it possible to make the msvchelp.exe utility redundant?
+# ?: Is there a more elegant way of setting MSVCDIR_S? MSVCDIR_S := $(shell cygpath `cygpath -d "$(MSVCDIR_MSVCDIR)"`) does not seem to work.
+ifdef MSVCDIR
+   MSVCDIR_S := $(shell cygpath `cygpath -d "$(MSVCDIR)"`)
+endif
+ifdef MSVCDir
+   MSVCDIR_S := $(shell cygpath `cygpath -d "$(MSVCDir)"`)
+endif
+ifdef VCINSTALLDIR
+   MSVCDIR_S := $(shell cygpath `cygpath -d "$(VCINSTALLDIR)"`)
+endif
+   MSVCDIR_U = $(subst \,/,$(MSVCDIR_S))
+   MSVCDIR_D = $(subst /,\,$(MSVCDIR_S))
+else
+   MSVCDIR_U = $(subst \,/,$(MSVCDIR_MSVCDIR))
+   MSVCDIR_D = $(subst /,\,$(MSVCDIR_MSVCDIR))
+endif  # ALLEGRO_USE_CYGWIN
+
 
 NULLSTRING :=
 SPACE := $(NULLSTRING) # special magic to get an isolated space character
@@ -160,13 +200,22 @@
 
 # -------- Work out the absolute pathnames for some MSVC tools to avoid confusion --------
 
+ifdef ALLEGRO_USE_CYGWIN
+   # The runner.exe tool does not like paths in the /cygdrive/ format.
+   # ?: Is this because if an app was compiled with -mno-cygwin, it means that paths in the /cygdrive format do not make sense?
+   MSVCDIR_TOOLSDIR_U = $(subst \,/,$(MSVCDIR_MSVCDIR))
+else
+   MSVCDIR_TOOLSDIR_U = $(MSVCDIR_U)
+endif
+
+
 ifdef COMPILER_ICL
    MSVC_CL = icl
 else
-   MSVC_CL = $(MSVCDIR_U)/bin/cl
+   MSVC_CL = $(MSVCDIR_TOOLSDIR_U)/bin/cl
 endif
-MSVC_LINK = $(MSVCDIR_U)/bin/link
-MSVC_LIB = $(MSVCDIR_U)/bin/link -lib
+MSVC_LINK = $(MSVCDIR_TOOLSDIR_U)/bin/link
+MSVC_LIB = $(MSVCDIR_TOOLSDIR_U)/bin/link -lib
 MSVC_RC = rc
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/