Make.defaults 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # -*- makefile -*-
  2. # Copyright (c) 1999-2007 Hewlett-Packard Development Company, L.P.
  3. # Contributed by David Mosberger <[email protected]>
  4. # Contributed by Stephane Eranian <[email protected]>
  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. LIBDIR := $(PREFIX)/lib
  48. INSTALL := install
  49. # Compilation tools
  50. HOSTCC := $(prefix)gcc
  51. CC := $(prefix)$(CROSS_COMPILE)gcc
  52. AS := $(prefix)$(CROSS_COMPILE)as
  53. LD := $(prefix)$(CROSS_COMPILE)ld
  54. AR := $(prefix)$(CROSS_COMPILE)ar
  55. RANLIB := $(prefix)$(CROSS_COMPILE)ranlib
  56. OBJCOPY := $(prefix)$(CROSS_COMPILE)objcopy
  57. # Host/target identification
  58. OS := $(shell uname -s)
  59. HOSTARCH := $(shell $(HOSTCC) -dumpmachine | cut -f1 -d- | sed s,i[3456789]86,ia32,)
  60. ARCH := $(HOSTARCH)
  61. # Get ARCH from the compiler if cross compiling
  62. ifneq ($(CROSS_COMPILE),)
  63. override ARCH := $(shell $(CC) -dumpmachine | cut -f1 -d-| sed s,i[3456789]86,ia32,)
  64. endif
  65. # FreeBSD (and possibly others) reports amd64 instead of x86_64
  66. ifeq ($(ARCH),amd64)
  67. override ARCH := x86_64
  68. endif
  69. #
  70. # Where to build the package
  71. #
  72. OBJDIR := $(TOPDIR)/$(ARCH)
  73. #
  74. # Variables below derived from variables above
  75. #
  76. # Arch-specific compilation flags
  77. CPPFLAGS += -DCONFIG_$(ARCH)
  78. ifeq ($(ARCH),ia64)
  79. CFLAGS += -mfixed-range=f32-f127
  80. endif
  81. ifeq ($(ARCH),ia32)
  82. CFLAGS += -mno-mmx -mno-sse
  83. ifeq ($(HOSTARCH),x86_64)
  84. ARCH3264 = -m32
  85. endif
  86. endif
  87. ifeq ($(ARCH),x86_64)
  88. GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.)
  89. GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.)
  90. # Rely on GCC MS ABI support?
  91. GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
  92. || ( [ $(GCCVERSION) -eq "4" ] \
  93. && [ $(GCCMINOR) -ge "7" ] ) ) \
  94. && echo 1)
  95. ifeq ($(GCCNEWENOUGH),1)
  96. CPPFLAGS += -DGNU_EFI_USE_MS_ABI -maccumulate-outgoing-args --std=c11
  97. endif
  98. CFLAGS += -mno-red-zone -mno-mmx -mno-sse
  99. ifeq ($(HOSTARCH),ia32)
  100. ARCH3264 = -m64
  101. endif
  102. endif
  103. #
  104. # Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv],
  105. # otherwise we need to compose the PE/COFF header using the assembler
  106. #
  107. ifneq ($(ARCH),aarch64)
  108. ifneq ($(ARCH),arm)
  109. export HAVE_EFI_OBJCOPY=y
  110. endif
  111. endif
  112. ifneq ($(ARCH),arm)
  113. export LIBGCC=$(shell $(CC) $(ARCH3264) -print-libgcc-file-name)
  114. endif
  115. ifeq ($(ARCH),arm)
  116. CFLAGS += -marm
  117. endif
  118. # Generic compilation flags
  119. INCDIR += -I$(SRCDIR) -I$(TOPDIR)/inc -I$(TOPDIR)/inc/$(ARCH) \
  120. -I$(TOPDIR)/inc/protocol
  121. ifeq (FreeBSD, $(findstring FreeBSD, $(OS)))
  122. CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
  123. -ffreestanding -fno-stack-protector
  124. else
  125. CFLAGS += $(ARCH3264) -g -O2 -fpic -Wall -fshort-wchar -fno-strict-aliasing \
  126. -fno-merge-constants -ffreestanding -fno-stack-protector \
  127. -fno-stack-check
  128. endif
  129. ASFLAGS += $(ARCH3264)
  130. LDFLAGS += -nostdlib --warn-common --no-undefined --fatal-warnings \
  131. --build-id=sha1