Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #
  2. # Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License version 2 as
  6. # published by the Free Software Foundation.
  7. #
  8. UTS_MACHINE := arc
  9. KBUILD_DEFCONFIG := fpga_defconfig
  10. # For ARC FPGA Platforms
  11. platform-$(CONFIG_ARC_PLAT_FPGA_LEGACY) := arcfpga
  12. #New platform adds here
  13. PLATFORM := $(platform-y)
  14. export PLATFORM
  15. cflags-y += -Iarch/arc/plat-$(PLATFORM)/include
  16. cflags-y += -mA7 -fno-common -pipe -fno-builtin -D__linux__
  17. LINUXINCLUDE += -include ${src}/arch/arc/include/asm/defines.h
  18. ifdef CONFIG_ARC_CURR_IN_REG
  19. # For a global register defintion, make sure it gets passed to every file
  20. # We had a customer reported bug where some code built in kernel was NOT using
  21. # any kernel headers, and missing the r25 global register
  22. # Can't do unconditionally (like above) because of recursive include issues
  23. # due to <linux/thread_info.h>
  24. LINUXINCLUDE += -include ${src}/arch/arc/include/asm/current.h
  25. endif
  26. atleast_gcc44 := $(call cc-ifversion, -gt, 0402, y)
  27. cflags-$(atleast_gcc44) += -fsection-anchors
  28. cflags-$(CONFIG_ARC_HAS_LLSC) += -mlock
  29. cflags-$(CONFIG_ARC_HAS_SWAPE) += -mswape
  30. cflags-$(CONFIG_ARC_HAS_RTSC) += -mrtsc
  31. cflags-$(CONFIG_ARC_DW2_UNWIND) += -fasynchronous-unwind-tables
  32. ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
  33. # Generic build system uses -O2, we want -O3
  34. cflags-y += -O3
  35. endif
  36. # small data is default for elf32 tool-chain. If not usable, disable it
  37. # This also allows repurposing GP as scratch reg to gcc reg allocator
  38. disable_small_data := y
  39. cflags-$(disable_small_data) += -mno-sdata -fcall-used-gp
  40. cflags-$(CONFIG_CPU_BIG_ENDIAN) += -mbig-endian
  41. ldflags-$(CONFIG_CPU_BIG_ENDIAN) += -EB
  42. # STAR 9000518362:
  43. # arc-linux-uclibc-ld (buildroot) or arceb-elf32-ld (EZChip) don't accept
  44. # --build-id w/o "-marclinux".
  45. # Default arc-elf32-ld is OK
  46. ldflags-y += -marclinux
  47. ARC_LIBGCC := -mA7
  48. cflags-$(CONFIG_ARC_HAS_HW_MPY) += -multcost=16
  49. ifndef CONFIG_ARC_HAS_HW_MPY
  50. cflags-y += -mno-mpy
  51. # newlib for ARC700 assumes MPY to be always present, which is generally true
  52. # However, if someone really doesn't want MPY, we need to use the 600 ver
  53. # which coupled with -mno-mpy will use mpy emulation
  54. # With gcc 4.4.7, -mno-mpy is enough to make any other related adjustments,
  55. # e.g. increased cost of MPY. With gcc 4.2.1 this had to be explicitly hinted
  56. ARC_LIBGCC := -marc600
  57. ifneq ($(atleast_gcc44),y)
  58. cflags-y += -multcost=30
  59. endif
  60. endif
  61. LIBGCC := $(shell $(CC) $(ARC_LIBGCC) $(cflags-y) --print-libgcc-file-name)
  62. # Modules with short calls might break for calls into builtin-kernel
  63. KBUILD_CFLAGS_MODULE += -mlong-calls
  64. # Finally dump eveything into kernel build system
  65. KBUILD_CFLAGS += $(cflags-y)
  66. KBUILD_AFLAGS += $(KBUILD_CFLAGS)
  67. LDFLAGS += $(ldflags-y)
  68. # Needed for Linker script preprocessing
  69. KBUILD_CPPFLAGS += -Iarch/arc/plat-$(PLATFORM)/include
  70. head-y := arch/arc/kernel/head.o
  71. # See arch/arc/Kbuild for content of core part of the kernel
  72. core-y += arch/arc/
  73. # w/o this dtb won't embed into kernel binary
  74. core-y += arch/arc/boot/dts/
  75. # w/o this ifneq, make ARCH=arc clean was crapping out
  76. ifneq ($(platform-y),)
  77. core-y += arch/arc/plat-$(PLATFORM)/
  78. endif
  79. drivers-$(CONFIG_OPROFILE) += arch/arc/oprofile/
  80. libs-y += arch/arc/lib/ $(LIBGCC)
  81. #default target for make without any arguements.
  82. KBUILD_IMAGE := bootpImage
  83. all: $(KBUILD_IMAGE)
  84. boot := arch/arc/boot
  85. bootpImage: vmlinux
  86. uImage: vmlinux
  87. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  88. %.dtb %.dtb.S %.dtb.o: scripts
  89. $(Q)$(MAKE) $(build)=$(boot)/dts $(boot)/dts/$@
  90. dtbs: scripts
  91. $(Q)$(MAKE) $(build)=$(boot)/dts dtbs
  92. archclean:
  93. $(Q)$(MAKE) $(clean)=$(boot)
  94. # Hacks to enable final link due to absence of link-time branch relexation
  95. # and gcc choosing optimal(shorter) branches at -O3
  96. #
  97. # vineetg Feb 2010: -mlong-calls switched off for overall kernel build
  98. # However lib/decompress_inflate.o (.init.text) calls
  99. # zlib_inflate_workspacesize (.text) causing relocation errors.
  100. # Thus forcing all exten calls in this file to be long calls
  101. export CFLAGS_decompress_inflate.o = -mmedium-calls
  102. export CFLAGS_initramfs.o = -mmedium-calls
  103. ifdef CONFIG_SMP
  104. export CFLAGS_core.o = -mmedium-calls
  105. endif