Makefile.common 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. # -*- makefile -*-
  2. CFLAGS_PLATFORM=
  3. export LC_COLLATE := C
  4. unexport LC_ALL
  5. # Platform specific options
  6. if COND_sparc64_ieee1275
  7. LDFLAGS_PLATFORM = -Wl,-melf64_sparc
  8. endif
  9. if COND_arm
  10. if !COND_emu
  11. LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
  12. endif
  13. endif
  14. if COND_arm64
  15. CFLAGS_PLATFORM += -mcmodel=large
  16. endif
  17. if COND_powerpc_ieee1275
  18. CFLAGS_PLATFORM += -mcpu=powerpc
  19. endif
  20. if COND_HAVE_PCI
  21. CFLAGS_PLATFORM += -DGRUB_HAS_PCI
  22. endif
  23. # Other options
  24. CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
  25. CPPFLAGS_DEFAULT += -I$(builddir)
  26. CPPFLAGS_DEFAULT += -I$(srcdir)
  27. CPPFLAGS_DEFAULT += -I$(top_builddir)
  28. CPPFLAGS_DEFAULT += -I$(top_srcdir)
  29. CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
  30. CPPFLAGS_DEFAULT += -I$(top_builddir)/include
  31. CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
  32. CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
  33. BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
  34. CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
  35. LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
  36. CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
  37. CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
  38. STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
  39. if !COND_emu
  40. if COND_HAVE_ASM_USCORE
  41. LDFLAGS_KERNEL += -Wl,--defsym=_malloc=_grub_malloc -Wl,--defsym=_free=_grub_free
  42. else
  43. LDFLAGS_KERNEL += -Wl,--defsym=malloc=grub_malloc -Wl,--defsym=free=grub_free
  44. endif
  45. endif
  46. CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
  47. LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r
  48. CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
  49. CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
  50. CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
  51. LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
  52. CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
  53. CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
  54. CFLAGS_PROGRAM =
  55. LDFLAGS_PROGRAM =
  56. CPPFLAGS_PROGRAM =
  57. CCASFLAGS_PROGRAM =
  58. CFLAGS_LIBRARY =
  59. CPPFLAGS_LIBRARY =
  60. CCASFLAGS_LIBRARY =
  61. # Other variables
  62. grubconfdir = $(sysconfdir)/grub.d
  63. platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
  64. starfielddir = $(pkgdatadir)/themes/starfield
  65. CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-error=attributes
  66. CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/lib/gnulib -I$(top_srcdir)/grub-core/lib/gnulib
  67. CFLAGS_POSIX = -fno-builtin
  68. CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap
  69. CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX)
  70. CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap $(CPPFLAGS_POSIX) -D_GCRYPT_IN_LIBGCRYPT=1 -I$(top_srcdir)/include/grub/gcrypt
  71. CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime
  72. # List file macros for recognizing /interesting/ modules
  73. CPPFLAGS_FS_LIST = -Dgrub_fs_register=FS_LIST_MARKER
  74. CPPFLAGS_VIDEO_LIST= -Dgrub_video_register=VIDEO_LIST_MARKER
  75. CPPFLAGS_PARTMAP_LIST = -Dgrub_partition_map_register=PARTMAP_LIST_MARKER
  76. CPPFLAGS_PARTTOOL_LIST = -Dgrub_parttool_register=PARTTOOL_LIST_MARKER
  77. CPPFLAGS_TERMINAL_LIST = '-Dgrub_term_register_input(...)=INPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
  78. CPPFLAGS_TERMINAL_LIST += '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
  79. CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)'
  80. CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_lockdown(...)=COMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)'
  81. CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)'
  82. CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd_lockdown(...)=EXTCOMMAND_LOCKDOWN_LIST_MARKER(__VA_ARGS__)'
  83. CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)'
  84. CPPFLAGS_FDT_LIST := '-Dgrub_fdtbus_register(...)=FDT_DRIVER_LIST_MARKER(__VA_ARGS__)'
  85. CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \
  86. $(CPPFLAGS_PARTTOOL_LIST) $(CPPFLAGS_PARTMAP_LIST) \
  87. $(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST) \
  88. $(CPPFLAGS_FDT_LIST)
  89. # Define these variables to calm down automake
  90. IMG_FILES =
  91. MOD_FILES =
  92. MODULE_FILES =
  93. MARKER_FILES =
  94. KERNEL_HEADER_FILES =
  95. bin_SCRIPTS =
  96. bin_PROGRAMS =
  97. check_SCRIPTS_native =
  98. check_SCRIPTS_nonnative =
  99. check_PROGRAMS_native =
  100. check_PROGRAMS_nonnative =
  101. dist_grubconf_DATA =
  102. dist_noinst_DATA =
  103. grubconf_SCRIPTS =
  104. man_MANS =
  105. noinst_DATA =
  106. noinst_SCRIPTS =
  107. noinst_PROGRAMS =
  108. noinst_LIBRARIES =
  109. pkgdata_DATA =
  110. platform_DATA =
  111. platform_SCRIPTS =
  112. platform_PROGRAMS =
  113. sbin_SCRIPTS =
  114. sbin_PROGRAMS =
  115. EXTRA_DIST =
  116. CLEANFILES =
  117. BUILT_SOURCES =
  118. # Rules for Automake input
  119. .PRECIOUS: $(top_srcdir)/Makefile.util.am
  120. $(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
  121. $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1)
  122. mv $@.new $@
  123. .PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
  124. $(top_srcdir)/grub-core/Makefile.core.am: $(top_srcdir)/gentpl.py $(top_srcdir)/grub-core/Makefile.core.def $(top_srcdir)/grub-core/Makefile.gcry.def
  125. if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./bootstrap manually." >&2; exit 1; fi
  126. $(PYTHON) $^ > $@.new || (rm -f $@.new; exit 1)
  127. mv $@.new $@