Makefile.common 4.57 KB
Newer Older
1 2
# -*- makefile -*-

3 4
CFLAGS_PLATFORM=

5 6 7
export LC_COLLATE := C
unexport LC_ALL

8 9
# Platform specific options
if COND_sparc64_ieee1275
10
  LDFLAGS_PLATFORM = -Wl,-melf64_sparc
11
endif
12
if COND_arm
13
if !COND_emu
14 15
  LDFLAGS_PLATFORM = -Wl,--wrap=__clear_cache
endif
16
endif
17 18 19
if COND_arm64
  CFLAGS_PLATFORM += -mcmodel=large
endif
20 21 22
if COND_powerpc_ieee1275
  CFLAGS_PLATFORM += -mcpu=powerpc
endif
23 24 25

# Other options

26
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
27 28 29 30 31 32
CPPFLAGS_DEFAULT += -I$(builddir)
CPPFLAGS_DEFAULT += -I$(srcdir)
CPPFLAGS_DEFAULT += -I$(top_builddir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)
CPPFLAGS_DEFAULT += -I$(top_srcdir)/include
CPPFLAGS_DEFAULT += -I$(top_builddir)/include
33
CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/
34
CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1
35
BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT)
36

37
CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
38
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
39
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
40
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)
Vladimir Serbinenko's avatar
Vladimir Serbinenko committed
41
STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx
42

43 44
CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
45 46 47
CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)

48 49
CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin
LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S
50 51 52 53 54 55 56 57
CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM)
CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM)

CFLAGS_PROGRAM =
LDFLAGS_PROGRAM =
CPPFLAGS_PROGRAM =
CCASFLAGS_PROGRAM =

BVK Chaitanya's avatar
BVK Chaitanya committed
58 59 60
CFLAGS_LIBRARY =
CPPFLAGS_LIBRARY =
CCASFLAGS_LIBRARY =
61 62 63 64

# Other variables

grubconfdir = $(sysconfdir)/grub.d
65
platformdir = $(pkglibdir)/$(target_cpu)-$(platform)
Dalet Omega's avatar
Dalet Omega committed
66
starfielddir = $(pkgdatadir)/themes/starfield
67

68
CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion
69
CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib
70 71 72 73

CFLAGS_POSIX = -fno-builtin
CPPFLAGS_POSIX = -I$(top_srcdir)/grub-core/lib/posix_wrap

74
CFLAGS_GCRY = -Wno-error -Wno-missing-field-initializers -Wno-redundant-decls -Wno-undef $(CFLAGS_POSIX)
75 76
CPPFLAGS_GCRY = -I$(top_srcdir)/grub-core/lib/libgcrypt_wrap $(CPPFLAGS_POSIX) -D_GCRYPT_IN_LIBGCRYPT=1 -I$(top_srcdir)/include/grub/gcrypt

77 78
CPPFLAGS_EFIEMU = -I$(top_srcdir)/grub-core/efiemu/runtime

79 80 81 82 83 84 85 86 87 88 89 90 91 92
# List file macros for recognizing /interesting/ modules
CPPFLAGS_FS_LIST = -Dgrub_fs_register=FS_LIST_MARKER
CPPFLAGS_VIDEO_LIST= -Dgrub_video_register=VIDEO_LIST_MARKER
CPPFLAGS_PARTMAP_LIST = -Dgrub_partition_map_register=PARTMAP_LIST_MARKER
CPPFLAGS_PARTTOOL_LIST = -Dgrub_parttool_register=PARTTOOL_LIST_MARKER
CPPFLAGS_TERMINAL_LIST = '-Dgrub_term_register_input(...)=INPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
CPPFLAGS_TERMINAL_LIST += '-Dgrub_term_register_output(...)=OUTPUT_TERMINAL_LIST_MARKER(__VA_ARGS__)'
CPPFLAGS_COMMAND_LIST = '-Dgrub_register_command(...)=COMMAND_LIST_MARKER(__VA_ARGS__)'
CPPFLAGS_COMMAND_LIST += '-Dgrub_register_extcmd(...)=EXTCOMMAND_LIST_MARKER(__VA_ARGS__)'
CPPFLAGS_COMMAND_LIST += '-Dgrub_register_command_p1(...)=P1COMMAND_LIST_MARKER(__VA_ARGS__)'
CPPFLAGS_MARKER = $(CPPFLAGS_FS_LIST) $(CPPFLAGS_VIDEO_LIST) \
	$(CPPFLAGS_PARTTOOL_LIST) $(CPPFLAGS_PARTMAP_LIST) \
	$(CPPFLAGS_TERMINAL_LIST) $(CPPFLAGS_COMMAND_LIST)

93 94 95 96 97
# Define these variables to calm down automake

IMG_FILES =
MOD_FILES =
MODULE_FILES =
98
MARKER_FILES =
99 100 101 102
KERNEL_HEADER_FILES =

man_MANS =
noinst_DATA =
103
pkgdata_DATA =
104 105 106 107 108 109
bin_SCRIPTS =
sbin_SCRIPTS =
bin_PROGRAMS =
platform_DATA =
sbin_PROGRAMS =
check_SCRIPTS =
110
dist_grubconf_DATA =
111
check_PROGRAMS =
BVK Chaitanya's avatar
BVK Chaitanya committed
112
noinst_SCRIPTS =
113 114 115
noinst_PROGRAMS =
grubconf_SCRIPTS =
noinst_LIBRARIES =
116
dist_noinst_DATA =
117 118
platform_SCRIPTS =
platform_PROGRAMS =
119 120 121 122 123

TESTS =
EXTRA_DIST =
CLEANFILES =
BUILT_SOURCES =
124

125
# Rules for Automake input
126 127

.PRECIOUS: $(top_srcdir)/Makefile.util.am
128 129
$(top_srcdir)/Makefile.util.am: $(top_srcdir)/gentpl.py $(top_srcdir)/Makefile.util.def $(top_srcdir)/Makefile.utilgcry.def
	python $^ > $@.new || (rm -f $@.new; exit 1)
130 131 132
	mv $@.new $@

.PRECIOUS: $(top_srcdir)/grub-core/Makefile.core.am
133
$(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
Colin Watson's avatar
Colin Watson committed
134
	if [ "x$$GRUB_CONTRIB" != x ]; then echo "You need to run ./autogen.sh manually." >&2; exit 1; fi
135
	python $^ > $@.new || (rm -f $@.new; exit 1)
136
	mv $@.new $@