Makefile 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #############################################################################
  2. #
  3. # The MIT License (MIT)
  4. #
  5. # Copyright (c) 2014 - 2021 VERISILICON
  6. #
  7. # Permission is hereby granted, free of charge, to any person obtaining a
  8. # copy of this software and associated documentation files (the "Software"),
  9. # to deal in the Software without restriction, including without limitation
  10. # the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. # and/or sell copies of the Software, and to permit persons to whom the
  12. # Software is furnished to do so, subject to the following conditions:
  13. #
  14. # The above copyright notice and this permission notice shall be included in
  15. # all copies or substantial portions of the Software.
  16. #
  17. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. # DEALINGS IN THE SOFTWARE.
  24. #
  25. #############################################################################
  26. #
  27. # The GPL License (GPL)
  28. #
  29. # Copyright (C) 2014 - 2021 VERISILICON
  30. #
  31. # This program is free software; you can redistribute it and/or
  32. # modify it under the terms of the GNU General Public License
  33. # as published by the Free Software Foundation; either version 2
  34. # of the License, or (at your option) any later version.
  35. #
  36. # This program is distributed in the hope that it will be useful,
  37. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. # GNU General Public License for more details.
  40. #
  41. # You should have received a copy of the GNU General Public License
  42. # along with this program; if not, write to the Free Software Foundation,
  43. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  44. #
  45. #############################################################################
  46. #
  47. # Note: This software is released under dual MIT and GPL licenses. A
  48. # recipient may use this file under the terms of either the MIT license or
  49. # GPL License. If you wish to use only one license not the other, you can
  50. # indicate your decision by deleting one of the above license notices in your
  51. # version of this file.
  52. #
  53. ##############################################################################
  54. ARM_CROSS_COMPILE ?= n
  55. ifeq ($(ARM_CROSS_COMPILE),y)
  56. export ARCH=arm64
  57. export CROSS_COMPILE=/opt/kmb/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/bin/aarch64-linux-gnu-
  58. KDIR := /home/vsi/kmb-evm/kernel/mainline-tracking
  59. endif
  60. SUPPORT_MMU = y
  61. SUPPORT_AXIFE = n
  62. SUPPORT_VCMD_ENABLE_IP = n
  63. ifeq ($(obj),)
  64. obj = .
  65. endif
  66. #################################################
  67. # configuration
  68. MDIR := hantro
  69. # drivers objects
  70. # list-multi := hantro_mmu.o
  71. # # what to build
  72. vc8000-objs := vc8000_driver.o vc8000_vcmd_driver.o bidirect_list.o vcmdswhwregisters.o vc8000_normal_driver.o
  73. obj-m += vc8000.o
  74. ifeq ($(strip $(SUPPORT_MMU)),y)
  75. vc8000-objs += hantro_mmu.o
  76. endif
  77. ifeq ($(strip $(SUPPORT_AXIFE)),y)
  78. vc8000-objs += vc8000_axife.o
  79. endif
  80. tardest := .
  81. #################################################
  82. # compile modules
  83. ifneq ($(KERNELRELEASE),)
  84. # recursive call from kernel build system
  85. dummy := $(shell echo $(KERNELRELEASE) > $(obj)/.version)
  86. ifeq ($(VERSION).$(PATCHLEVEL),2.6)
  87. export-objs :=
  88. list-multi :=
  89. else
  90. multi-m := $(filter $(list-multi), $(obj-m))
  91. int-m := $(sort $(foreach m, $(multi-m), $($(basename $(m))-objs)))
  92. export-objs := $(filter $(int-m) $(obj-m),$(export-objs))
  93. endif
  94. CC += -I$(obj)
  95. EXTRA_CFLAGS += -g
  96. # Print debugging messages from the device
  97. #EXTRA_CFLAGS += -DHANTRO_DRIVER_DEBUG
  98. #EXTRA_CFLAGS += -DHANTROMMU_DEBUG
  99. #EXTRA_CFLAGS += -DDYNAMIC_MALLOC_VCMDNODE
  100. snapshot := $(wildcard $(obj)/.snapshot)
  101. ifneq ($(snapshot),)
  102. SNAPSHOT_CFLAGS := -DSNAPSHOT='$(shell cat $(snapshot))'
  103. EXTRA_CFLAGS += $(SNAPSHOT_CFLAGS)
  104. endif
  105. ifeq ($(strip $(SUPPORT_MMU)),y)
  106. EXTRA_CFLAGS += -DHANTROMMU_SUPPORT
  107. endif
  108. ifeq ($(strip $(SUPPORT_AXIFE)),y)
  109. EXTRA_CFLAGS += -DHANTROAXIFE_SUPPORT
  110. endif
  111. ifeq ($(strip $(SUPPORT_VCMD_ENABLE_IP)),y)
  112. EXTRA_CFLAGS += -DHANTROVCMD_ENABLE_IP_SUPPORT
  113. endif
  114. -include $(TOPDIR)/Rules.make
  115. else
  116. # take version info from last module build if available
  117. KERNELRELEASE := $(shell cat $(obj)/.version 2>/dev/null || uname -r)
  118. endif
  119. ifneq ($(ARM_CROSS_COMPILE),y)
  120. KDIR_BASE := /afs/hantro.com/projects/Testing/Board_Version_Control
  121. #KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/v0_0/linux-2.6.19-arm2
  122. #KDIR := $(KDIR_BASE)/Realview_EB/SW/Linux/linux-2.6.21-arm1/v0_0/linux-2.6.21-arm1
  123. #KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.24-arm2-spnlck/v0_1/linux-2.6.24-arm2-spnlck
  124. #KDIR := $(KDIR_BASE)/Realview_PB/PB926EJS/SW/Linux/linux-2.6.28-arm1/v0_1/linux-2.6.28-arm1
  125. #KDIR := $(KDIR_BASE)/SW_Common/ARM_realview_v6/2.6.28-arm1/v0_1-v6/linux-2.6.28-arm1
  126. KVER := $(shell uname -r)
  127. KDIR := /lib/modules/$(KVER)/build
  128. endif
  129. PWD := $(shell pwd)
  130. DEST := /lib/modules/$(KERNELRELEASE)/$(MDIR)
  131. # which files to install?
  132. inst-m := $(wildcard *.ko)
  133. ifeq ($(inst-m),)
  134. inst-m := $(obj-m)
  135. endif
  136. # locales seem to cause trouble sometimes.
  137. LC_ALL = POSIX
  138. export LC_ALL
  139. default::
  140. $(MAKE) -C $(KDIR) M=$(PWD) modules
  141. install::
  142. strip --strip-debug $(inst-m)
  143. -su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); depmod -a"
  144. clean::
  145. $(MAKE) -C $(KDIR) M=$(PWD) clean
  146. -rm -f .version
  147. #################################################
  148. # build tarballs
  149. thisdir := $(notdir $(PWD))
  150. name := $(shell echo $(thisdir) | sed 's/-.*//')
  151. ver := $(shell echo $(thisdir) | sed 's/.*-//')
  152. date := $(shell date +%Y%m%d)
  153. tardest ?= .
  154. snapdir := $(HOME)/snapshot
  155. snap ?= $(name)
  156. release: clean
  157. rm -f .snapshot
  158. (cd ..; tar cvzf $(tardest)/$(name)-$(ver).tar.gz $(thisdir))
  159. snapshot snap tarball: clean
  160. echo $(date) > .snapshot
  161. (cd ..; tar czf $(snapdir)/$(snap)-$(date).tar.gz $(thisdir))
  162. $(MAKE) -C $(snapdir)
  163. #################################################
  164. # other stuff
  165. %.asm: %.o
  166. objdump -S $< > $@