git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 10/14] Makefile: introduce CROSS_COMPILE variable

From
Marat Radchenko <marat@slonopotamus.org>
Date
Sep 30, 2014, 07:02 UTC
Message-ID
<1412060563-22041-11-git-send-email-marat@slonopotamus.org>
In-Reply-To
<1412060563-22041-1-git-send-email-marat@slonopotamus.org>

To ease cross-compilation process, introduce a single variable with the prefix to all compiler-related executables.

Define CROSS_COMPILE=foo- if your compiler and binary utilities are foo-cc, foo-ar, foo-strip, etc. More specific variables override this, so if you set CC=gcc CROSS_COMPILE=ia64-linux-gnu- then the compiler will be 'gcc', not 'ia64-linux-gnu-gcc'.

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
---
 Makefile         | 19 +++++++++++++------
 config.mak.uname |  2 +-
 2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index f34a2d4..c412996 100644
--- a/Makefile
+++ b/Makefile
@@ -339,6 +339,11 @@ all::
 # return NULL when it receives a bogus time_t.
 #
 # Define HAVE_CLOCK_GETTIME if your platform has clock_gettime in librt.
+#
+# Define CROSS_COMPILE=foo- if your compiler and binary utilities
+# are foo-cc, foo-ar, foo-strip, etc.  More specific variables
+# override this, so if you set CC=gcc CROSS_COMPILE=ia64-linux-gnu-
+# then the compiler will be 'gcc', not 'ia64-linux-gnu-gcc'.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -350,7 +355,6 @@ CFLAGS = -g -O2 -Wall
 LDFLAGS =
 ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
-STRIP ?= strip
 
 # Among the variables below, these:
 #   gitexecdir
@@ -390,8 +394,12 @@ htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
 
 export prefix bindir sharedir sysconfdir gitwebdir localedir
 
-CC = cc
-AR = ar
+AR = $(CROSS_COMPILE)ar
+CC = $(CROSS_COMPILE)cc
+GCOV = $(CROSS_COMPILE)gcov
+RC = $(CROSS_COMPILE)windres
+STRIP = $(CROSS_COMPILE)strip
+
 RM = rm -f
 DIFF = diff
 TAR = tar
@@ -404,13 +412,12 @@ XGETTEXT = xgettext
 MSGFMT = msgfmt
 PTHREAD_LIBS = -lpthread
 PTHREAD_CFLAGS =
-GCOV = gcov
 
 export TCL_PATH TCLTK_PATH
 
 SPARSE_FLAGS =
 
-
+RCFLAGS =
 
 ### --- END CONFIGURATION SECTION ---
 
@@ -1669,7 +1676,7 @@ $(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES
 	mv $@+ $@
 
 git.res: git.rc GIT-VERSION-FILE
-	$(QUIET_RC)$(RC) \
+	$(QUIET_RC)$(RC) $(RCFLAGS) \
 	  $(join -DMAJOR= -DMINOR=, $(wordlist 1,2,$(subst -, ,$(subst ., ,$(GIT_VERSION))))) \
 	  -DGIT_VERSION="\\\"$(GIT_VERSION)\\\"" $< -o $@
 
diff --git a/config.mak.uname b/config.mak.uname
index f79c0e0..9f7037e 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -523,7 +523,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))
 	EXTLIBS += -lws2_32
 	GITLIBS += git.res
 	PTHREAD_LIBS =
-	RC = windres -O coff
+	RCFLAGS += -O coff
 	NATIVE_CRLF = YesPlease
 	X = .exe
 	SPARSE_FLAGS = -Wno-one-bit-signed-bitfield
-- 
2.1.1

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "Git for Windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Previous: Marat RadchenkoNext: Marat Radchenko
Message 11 of 30 in “MinGW(-W64) compilation”
  1. MinGW(-W64) compilationMarat Radchenko, Sep 30, 2014
  2. 01/14 MINGW: compat/mingw.h: do not attempt to redefine lseek on mingw-w64Marat Radchenko, Sep 30, 2014
  3. 02/14 MSVC: config.mak.uname: drop -D__USE_MINGW_ACCESS from CFLAGSMarat Radchenko, Sep 30, 2014
  4. 03/14 MINGW: compat/mingw.h: drop fork() definitionMarat Radchenko, Sep 30, 2014
  5. 04/14 MINGW: do not fail at redefining pid_t on MinGW-W64Marat Radchenko, Sep 30, 2014
  6. 05/14 MINGW: config.mak.uname: allow using cURL for non-msysGit buildsMarat Radchenko, Sep 30, 2014
  7. 06/14 MINGW: compat/winansi.c: do not redefine CONSOLE_FONT_INFOEXMarat Radchenko, Sep 30, 2014
  8. 07/14 Fix BASIC_LDFLAGS and COMPAT_CFLAGS for 64bit MinGW-w64Marat Radchenko, Sep 30, 2014
  9. 08/14 MINGW: git-compat-util.h: use inttypes.h for printf macrosMarat Radchenko, Sep 30, 2014
  10. 09/14 MINGW: config.mak.uname: reorganize MinGW settingsMarat Radchenko, Sep 30, 2014
  11. 10/14 Makefile: introduce CROSS_COMPILE variableMarat Radchenko, Sep 30, 2014
  12. 11/14 compat/nedmalloc/malloc.c.h: fix compilation under MinGW-W64Marat Radchenko, Sep 30, 2014
  13. 12/14 Fix pointer -> integer casts on IL32P64 systemsMarat Radchenko, Sep 30, 2014
  14. 13/14 git-compat-util.h: fix integer overflow on IL32P64 systemsMarat Radchenko, Sep 30, 2014
  15. 14/14 MINGW: config.mak.uname: auto-detect MinGW build from compilerMarat Radchenko, Sep 30, 2014
  16. Duy NguyenSep 30, 2014
  17. Marat RadchenkoOct 6, 2014
  18. Johannes SixtOct 6, 2014
  19. Junio C HamanoOct 7, 2014
  20. Johannes SixtOct 7, 2014
  21. Thomas BraunOct 7, 2014
  22. Marat RadchenkoOct 8, 2014
  23. Johannes SchindelinOct 8, 2014
  24. Marat RadchenkoOct 8, 2014
  25. Johannes SchindelinOct 8, 2014
  26. Thomas BraunOct 8, 2014
  27. Johannes SchindelinOct 8, 2014
  28. Johannes SchindelinOct 8, 2014
  29. Marat RadchenkoOct 8, 2014
  30. Johannes SchindelinOct 8, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.