common.target 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ##############################################################################
  2. #
  3. # Copyright 2012 - 2021 Vivante Corporation, Santa Clara, California.
  4. # All Rights Reserved.
  5. #
  6. # Permission is hereby granted, free of charge, to any person obtaining
  7. # a copy of this software and associated documentation files (the
  8. # 'Software'), to deal in the Software without restriction, including
  9. # without limitation the rights to use, copy, modify, merge, publish,
  10. # distribute, sub license, and/or sell copies of the Software, and to
  11. # permit persons to whom the Software is furnished to do so, subject
  12. # to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice (including the
  15. # next paragraph) shall be included in all copies or substantial
  16. # portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  19. # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. # IN NO EVENT SHALL VIVANTE AND/OR ITS SUPPLIERS BE LIABLE FOR ANY
  22. # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. #
  26. ##############################################################################
  27. ################################################################################
  28. # Define a shortcut for the main target.
  29. TARGET_OUTPUT = $(OBJ_DIR)/$(TARGET_NAME)
  30. ifeq ($(TARGET_SONAME),)
  31. TARGET_SONAME := $(TARGET_NAME)
  32. endif
  33. ifeq ($(OBJ_DIR),)
  34. ifeq ($(DEBUG), 1)
  35. OBJ_DIR ?= bin_d
  36. else
  37. OBJ_DIR ?= bin_r
  38. endif
  39. endif
  40. ################################################################################
  41. # Specify targets.
  42. all: $(TARGET_OUTPUT)
  43. clean:
  44. @rm -rf $(OBJ_DIR)/* $(OBJ_DIR)
  45. @rm -rf $(CLEAN_EXTRA)
  46. install: $(TARGET_OUTPUT)
  47. ifneq ($(INSTALL_DIR),)
  48. @mkdir -p $(INSTALL_DIR)
  49. @-cp $(TARGET_OUTPUT) $(INSTALL_DIR)
  50. endif
  51. MAKEFILE_NAME = makefile.linux
  52. ifeq ($(gcdSTATIC_LINK),1)
  53. ifneq ($(USE_ARMCC), 1)
  54. PFLAGS += -static
  55. else
  56. PFLAGS += -L--no_search_dynamic_libraries
  57. endif
  58. else
  59. ifneq ($(QNX), 1)
  60. LIBS += -lrt
  61. endif
  62. PFLAGS += -Wl,-rpath-link $(VIVANTE_SDK_DIR)/drivers
  63. endif
  64. ifeq ($(PROGRAM), 1)
  65. $(TARGET_OUTPUT): $(OBJECTS)
  66. ifeq ($(SRC_CXX),)
  67. @echo " LINK \033[1m$(notdir $@)\033[0m"
  68. @$(CC) $(PFLAGS) $(OBJECTS) -o $(TARGET_OUTPUT) $(LIBS)
  69. else
  70. @echo " LINK \033[1m$(notdir $@)\033[0m"
  71. @$(CXX) $(PFLAGS) $(OBJECTS) -o $(TARGET_OUTPUT) $(LIBS)
  72. endif
  73. ifneq ($(USE_ARMCC), 1)
  74. ifneq ($(DEBUG), 1)
  75. @$(STRIP) $(TARGET_OUTPUT)
  76. endif
  77. endif
  78. endif
  79. ifeq ($(DYNAMIC), 1)
  80. ifeq ($(USE_ARMCC), 1)
  81. LDFLAGS += --shared -L--soname=,$(TARGET_NAME)
  82. else
  83. LDFLAGS += -Wall -shared -Wl,-soname,$(TARGET_NAME) -Wl,-z,defs
  84. endif
  85. $(TARGET_OUTPUT): $(OBJECTS)
  86. @echo " LINK \033[1m$(notdir $@)\033[0m"
  87. @$(CC) $(LDFLAGS) $(OBJECTS) -o $(TARGET_OUTPUT) $(LIBS)
  88. endif
  89. ifeq ($(STATIC), 1)
  90. $(TARGET_OUTPUT): $(OBJECTS)
  91. @echo " ARCHIVE \033[1m$(notdir $@)\033[0m"
  92. @$(AR) -r -c $(TARGET_OUTPUT) $(OBJECTS)
  93. ifneq ($(USE_ARMCC), 1)
  94. $(RANLIB) $(TARGET_OUTPUT)
  95. endif
  96. endif
  97. $(OBJ_DIR)/%.o: %.c
  98. @echo " COMPILE $(abspath $<)"
  99. @mkdir -p $(OBJ_DIR)
  100. @$(CC) -c $(CFLAGS) -o $@ $<
  101. $(OBJ_DIR)/%.o: %.cpp
  102. @echo " COMPILE $(abspath $<)"
  103. @mkdir -p $(OBJ_DIR)
  104. @$(CXX) -c $(CFLAGS) -o $@ $<
  105. $(OBJ_DIR)/%.o: %.cc
  106. @echo " COMPILE $(abspath $<)"
  107. @mkdir -p $(OBJ_DIR)
  108. @$(CXX) -c $(CFLAGS) -o $@ $<