Skip to content

Commit fa7fbeb

Browse files
committed
Windows: Add workaround for MSYS' path conversion
MSYS' automatic path conversion causes problems when passing paths as defines ('-D' arguments to the compiler). MSYS tries to be smart and converts absolute paths to native Windows paths, e.g. if MSYS sees "/bin" it converts it to "c:/msysgit/bin". But we want completely unmodified paths; e.g. if we set bindir in the Makefile to "/bin", the define BINDIR shall expand to "/bin". Conversion to absolute Windows path will takes place later, during runtime. This commit adds a workaround by replacing "/" with its octal representation "\057", effectively hiding the path from MSYS' path conversion mechanism. MSYS does no longer see the absolute path and therefore leaves it alone.
1 parent cc185a6 commit fa7fbeb

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,12 @@ template_dir_SQ = $(subst ','\'',$(template_dir))
10491049
htmldir_SQ = $(subst ','\'',$(htmldir))
10501050
prefix_SQ = $(subst ','\'',$(prefix))
10511051

1052+
ETC_GITCONFIG_SQ_C = $(subst /,\057,$(ETC_GITCONFIG_SQ))
1053+
bindir_SQ_C = $(subst /,\057,$(bindir_SQ))
1054+
gitexecdir_SQ_C = $(subst /,\057,$(gitexecdir_SQ))
1055+
htmldir_SQ_C = $(subst /,\057,$(htmldir_SQ))
1056+
template_dir_SQ_C = $(subst /,\057,$(template_dir_SQ))
1057+
10521058
SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
10531059
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
10541060
TCLTK_PATH_SQ = $(subst ','\'',$(TCLTK_PATH))
@@ -1100,7 +1106,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
11001106

11011107
help.o: help.c common-cmds.h GIT-CFLAGS
11021108
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
1103-
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
1109+
'-DGIT_HTML_PATH="$(htmldir_SQ_C)"' \
11041110
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
11051111
'-DGIT_INFO_PATH="$(infodir_SQ)"' $<
11061112

@@ -1207,12 +1213,12 @@ git.o git.spec \
12071213
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
12081214

12091215
exec_cmd.o: exec_cmd.c GIT-CFLAGS
1210-
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
1216+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ_C)"' -DBINDIR='"$(bindir_SQ_C)"' $<
12111217
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
1212-
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
1218+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ_C)"' $<
12131219

12141220
config.o: config.c GIT-CFLAGS
1215-
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' $<
1221+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ_C)"' $<
12161222

12171223
http.o: http.c GIT-CFLAGS
12181224
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<

0 commit comments

Comments
 (0)