You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 1 година
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ##
  2. ## This file is part of the libopencm3 project.
  3. ##
  4. ## Copyright (C) 2014 Frantisek Burian <BuFran@seznam.cz>
  5. ##
  6. ## This library is free software: you can redistribute it and/or modify
  7. ## it under the terms of the GNU Lesser General Public License as published by
  8. ## the Free Software Foundation, either version 3 of the License, or
  9. ## (at your option) any later version.
  10. ##
  11. ## This library is distributed in the hope that it will be useful,
  12. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ## GNU Lesser General Public License for more details.
  15. ##
  16. ## You should have received a copy of the GNU Lesser General Public License
  17. ## along with this library. If not, see <http://www.gnu.org/licenses/>.
  18. ##
  19. ifeq ($(DEVICE),)
  20. $(warning no DEVICE specified for linker script generator)
  21. endif
  22. LDSCRIPT = generated.$(DEVICE).ld
  23. DEVICES_DATA = $(OPENCM3_DIR)/ld/devices.data
  24. genlink_family :=$(shell $(OPENCM3_DIR)/scripts/genlink.py $(DEVICES_DATA) $(DEVICE) FAMILY)
  25. genlink_subfamily :=$(shell $(OPENCM3_DIR)/scripts/genlink.py $(DEVICES_DATA) $(DEVICE) SUBFAMILY)
  26. genlink_cpu :=$(shell $(OPENCM3_DIR)/scripts/genlink.py $(DEVICES_DATA) $(DEVICE) CPU)
  27. genlink_fpu :=$(shell $(OPENCM3_DIR)/scripts/genlink.py $(DEVICES_DATA) $(DEVICE) FPU)
  28. genlink_cppflags :=$(shell $(OPENCM3_DIR)/scripts/genlink.py $(DEVICES_DATA) $(DEVICE) CPPFLAGS)
  29. CPPFLAGS += $(genlink_cppflags)
  30. ARCH_FLAGS :=-mcpu=$(genlink_cpu)
  31. ifeq ($(genlink_cpu),$(filter $(genlink_cpu),cortex-m0 cortex-m0plus cortex-m3 cortex-m4 cortex-m7))
  32. ARCH_FLAGS +=-mthumb
  33. endif
  34. ifeq ($(genlink_fpu),soft)
  35. ARCH_FLAGS += -msoft-float
  36. else ifeq ($(genlink_fpu),hard-fpv4-sp-d16)
  37. ARCH_FLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
  38. else ifeq ($(genlink_fpu),hard-fpv5-sp-d16)
  39. ARCH_FLAGS += -mfloat-abi=hard -mfpu=fpv5-sp-d16
  40. else
  41. $(warning No match for the FPU flags)
  42. endif
  43. ifeq ($(genlink_family),)
  44. $(warning $(DEVICE) not found in $(DEVICES_DATA))
  45. endif
  46. # only append to LDFLAGS if the library file exists to not break builds
  47. # where those are provided by different means
  48. ifneq (,$(wildcard $(OPENCM3_DIR)/lib/libopencm3_$(genlink_family).a))
  49. LIBNAME = opencm3_$(genlink_family)
  50. else
  51. ifneq (,$(wildcard $(OPENCM3_DIR)/lib/libopencm3_$(genlink_subfamily).a))
  52. LIBNAME = opencm3_$(genlink_subfamily)
  53. else
  54. $(warning $(OPENCM3_DIR)/lib/libopencm3_$(genlink_family).a library variant for the selected device does not exist.)
  55. endif
  56. endif
  57. LDLIBS += -l$(LIBNAME)
  58. LIBDEPS += $(OPENCM3_DIR)/lib/lib$(LIBNAME).a
  59. # only append to LDLIBS if the directory exists
  60. ifneq (,$(wildcard $(OPENCM3_DIR)/lib))
  61. LDFLAGS += -L$(OPENCM3_DIR)/lib
  62. else
  63. $(warning $(OPENCM3_DIR)/lib as given be OPENCM3_DIR does not exist.)
  64. endif
  65. # only append include path to CPPFLAGS if the directory exists
  66. ifneq (,$(wildcard $(OPENCM3_DIR)/include))
  67. CPPFLAGS += -I$(OPENCM3_DIR)/include
  68. else
  69. $(warning $(OPENCM3_DIR)/include as given be OPENCM3_DIR does not exist.)
  70. endif