Make.defaults 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. # -*- makefile -*-
  2. # Copyright (c) 1999-2007 Hewlett-Packard Development Company, L.P.
  3. # Contributed by David Mosberger <davidm@hpl.hp.com>
  4. # Contributed by Stephane Eranian <eranian@hpl.hp.com>
  5. #
  6. # All rights reserved.
  7. #
  8. # Redistribution and use in source and binary forms, with or without
  9. # modification, are permitted provided that the following conditions
  10. # are met:
  11. #
  12. # * Redistributions of source code must retain the above copyright
  13. # notice, this list of conditions and the following disclaimer.
  14. # * Redistributions in binary form must reproduce the above
  15. # copyright notice, this list of conditions and the following
  16. # disclaimer in the documentation and/or other materials
  17. # provided with the distribution.
  18. # * Neither the name of Hewlett-Packard Co. nor the names of its
  19. # contributors may be used to endorse or promote products derived
  20. # from this software without specific prior written permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  23. # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  24. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  25. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
  27. # BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
  28. # OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  29. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  30. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  32. # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  33. # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. #
  36. TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
  37. #
  38. # Variables below overridable from command-line:
  39. # make VARNAME=value ...
  40. #
  41. #
  42. # Where to install the package. GNU-EFI will create and access
  43. # lib and include under the root
  44. #
  45. INSTALLROOT := /
  46. PREFIX := /usr/local
  47. EXEC_PREFIX := $(PREFIX)
  48. LIBDIR := $(EXEC_PREFIX)/lib
  49. INCLUDEDIR := $(PREFIX)/include
  50. INSTALL := install
  51. # Compilation tools
  52. HOSTCC := $(prefix)gcc
  53. CC := $(prefix)$(CROSS_COMPILE)gcc
  54. AS := $(prefix)$(CROSS_COMPILE)as
  55. LD := $(prefix)$(CROSS_COMPILE)ld
  56. AR := $(prefix)$(CROSS_COMPILE)ar
  57. RANLIB := $(prefix)$(CROSS_COMPILE)ranlib
  58. OBJCOPY := $(prefix)$(CROSS_COMPILE)objcopy
  59. # Host/target identification
  60. OS := $(shell uname -s)
  61. HOSTARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
  62. ARCH ?= $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
  63. # Get ARCH from the compiler if cross compiling
  64. ifneq ($(CROSS_COMPILE),)
  65. override ARCH := $(shell $(CC) -dumpmachine | cut -f1 -d-| sed -e s,i[3456789]86,ia32, -e 's,armv[67].*,arm,' )
  66. endif
  67. # FreeBSD (and possibly others) reports amd64 instead of x86_64
  68. ifeq ($(ARCH),amd64)
  69. override ARCH := x86_64
  70. endif
  71. #
  72. # Where to build the package
  73. #
  74. OBJDIR := $(TOPDIR)/$(ARCH)
  75. #
  76. # Variables below derived from variables above
  77. #
  78. # Arch-specific compilation flags
  79. CPPFLAGS += -DCONFIG_$(ARCH)
  80. CFLAGS += -Wno-error=pragmas
  81. ifeq ($(ARCH),ia64)
  82. CFLAGS += -mfixed-range=f32-f127
  83. endif
  84. ifeq ($(ARCH),ia32)
  85. CFLAGS += -mno-mmx -mno-sse
  86. ifeq ($(HOSTARCH),x86_64)
  87. ARCH3264 = -m32
  88. endif
  89. endif
  90. ifeq ($(ARCH),x86_64)
  91. GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.)
  92. GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.)
  93. USING_CLANG := $(shell $(CC) -v 2>&1 | grep -q 'clang version' && echo clang)
  94. # Rely on GCC MS ABI support?
  95. GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
  96. || ( [ $(GCCVERSION) -eq "4" ] \
  97. && [ $(GCCMINOR) -ge "7" ] ) ) \
  98. && echo 1)
  99. ifeq ($(GCCNEWENOUGH),1)
  100. CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
  101. else ifeq ($(USING_CLANG),clang)
  102. CPPFLAGS += -DGNU_EFI_USE_MS_ABI --std=c11
  103. endif
  104. CFLAGS += -mno-red-zone
  105. ifeq ($(HOSTARCH),ia32)
  106. ARCH3264 = -m64
  107. endif
  108. endif
  109. ifneq (,$(filter $(ARCH),ia32 x86_64))
  110. # Disable AVX, if the compiler supports that.
  111. CC_CAN_DISABLE_AVX=$(shell $(CC) -Werror -c -o /dev/null -xc -mno-avx - </dev/null >/dev/null 2>&1 && echo 1)
  112. ifeq ($(CC_CAN_DISABLE_AVX), 1)
  113. CFLAGS += -mno-avx
  114. endif
  115. endif
  116. ifeq ($(ARCH),mips64el)
  117. CFLAGS += -march=mips64r2
  118. ARCH3264 = -mabi=64
  119. endif
  120. #
  121. # Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv],
  122. # otherwise we need to compose the PE/COFF header using the assembler
  123. #
  124. ifneq ($(ARCH),arm)
  125. ifneq ($(ARCH),mips64el)
  126. ifneq ($(ARCH),riscv64)
  127. ifneq ($(ARCH),loongarch64)
  128. export HAVE_EFI_OBJCOPY=y
  129. endif
  130. endif
  131. endif
  132. endif
  133. ifneq ($(ARCH),arm)
  134. export LIBGCC=$(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
  135. endif
  136. ifeq ($(ARCH),arm)
  137. CFLAGS += -marm
  138. endif
  139. ifeq ($(ARCH),aarch64)
  140. LDFLAGS += -z common-page-size=4096
  141. LDFLAGS += -z max-page-size=4096
  142. endif
  143. # Generic compilation flags
  144. INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
  145. -I$(TOPDIR)/inc/protocol
  146. # Only enable -fPIE for non MinGW compilers (unneeded on MinGW)
  147. GCCMACHINE := $(shell $(CC) -dumpmachine)
  148. ifneq (mingw32,$(findstring mingw32, $(GCCMACHINE)))
  149. CFLAGS += -fPIE
  150. endif
  151. ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
  152. CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Werror \
  153. -fshort-wchar -fno-strict-aliasing \
  154. -ffreestanding -fno-stack-protector
  155. else
  156. CFLAGS += $(ARCH3264) -g -O2 -Wall -Wextra -Wno-pointer-sign -Werror \
  157. -fshort-wchar -fno-strict-aliasing \
  158. -ffreestanding -fno-stack-protector -fno-stack-check \
  159. -fno-stack-check \
  160. $(if $(findstring gcc,$(CC)),-fno-merge-all-constants,)
  161. endif
  162. ARFLAGS := rDv
  163. ASFLAGS += $(ARCH3264)
  164. LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \
  165. --build-id=sha1