Makefile 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. #-------------------------------------------------------------------------------
  2. #- --
  3. #- This software is confidential and proprietary and may be used --
  4. #- only as expressly authorized by a licensing agreement from --
  5. #- --
  6. #- Hantro Products Oy. --
  7. #- --
  8. #- (C) COPYRIGHT 2006 HANTRO PRODUCTS OY --
  9. #- ALL RIGHTS RESERVED --
  10. #- --
  11. #- The entire notice above must be reproduced --
  12. #- on all copies and should not be removed. --
  13. #- --
  14. #-------------------------------------------------------------------------------
  15. #-
  16. #-- Abstract : Makefile for encoder library
  17. #--
  18. #-------------------------------------------------------------------------------
  19. # Comment/uncomment the following lines to define which control codes to
  20. # include in the library build
  21. INCLUDE_H264 = y
  22. INCLUDE_JPEG = y
  23. INCLUDE_VIDSTAB = y
  24. # Include internal testing with testId-parameter
  25. INCLUDE_TESTING = y
  26. ifeq (pci,$(findstring pci, $(MAKECMDGOALS)))
  27. # this is just for DEMO
  28. include Baseaddress
  29. endif
  30. # Comment/uncomment the following line to disable/enable debugging
  31. DEBUG = y
  32. # set this to 'y' for Electric Fence checking
  33. USE_EFENCE = n
  34. # don't use IRQs
  35. #POLLING = y
  36. ifeq ($(USE_EFENCE), y)
  37. EFENCE= -DUSE_EFENCE -I/afs/hantro.com/projects/adder/users/atna/efence_2_4_13
  38. endif
  39. # Add your debugging flags (or not)
  40. ifeq ($(DEBUG),y)
  41. DEBFLAGS = -O1 -g -DDEBUG -D_DEBUG_PRINT -D_ASSERT_USED
  42. DEBFLAGS += -DH8290_HAVE_ENCDEBUG_H
  43. DEBFLAGS += -DH8290_HAVE_ENCTRACE_H
  44. DEBFLAGS += -DH8290_HAVE_VIDSTABDEBUG_H
  45. #DEBFLAGS += -DASIC_WAVE_TRACE_TRIGGER # enable logic analyzer trigger
  46. #DEBFLAGS += -DTRACE_EWL # for wrapper layer trace
  47. #DEBFLAGS += -DTRACE_RC # Rate Control trace
  48. #DEBFLAGS += -DTRACE_REGS # reg.trc register dump
  49. #DEBFLAGS += -DTRACE_RECON # mb.trc
  50. #DEBFLAGS += -DTRACE_STREAM # stream.trc
  51. #DEBFLAGS += -DTRACE_VIDEOSTAB_INTERNAL # prints stabilization info
  52. #DEBFLAGS += -DTRACE_PIC_TIMING # trace SEI picture timing values
  53. #DEBFLAGS += -DH264ENC_TRACE # api.trc
  54. #DEBFLAGS += -DJPEGENC_TRACE # api.trc
  55. #DEBFLAGS += -DVIDEOSTB_TRACE # api.trc
  56. else
  57. DEBFLAGS = -O2 -DNDEBUG
  58. endif
  59. # Architecture flags for gcc
  60. #ARCH=
  61. #CROSS_COMPILE=
  62. # C -compiler name, can be replaced by another compiler(replace gcc)
  63. CC = $(CROSS_COMPILE)gcc
  64. ifeq ($(shell uname -m),x86_64)
  65. ifneq (,$(findstring pclinux,$(MAKECMDGOALS)))
  66. export ARCH = -m32
  67. endif
  68. ifneq (,$(findstring system,$(MAKECMDGOALS)))
  69. export ARCH = -m32
  70. endif
  71. ifneq (,$(findstring testdata,$(MAKECMDGOALS)))
  72. export ARCH = -m32
  73. endif
  74. ifneq (,$(findstring eval,$(MAKECMDGOALS)))
  75. export ARCH = -m32
  76. endif
  77. endif
  78. # System model library
  79. MODELLIB = ../../system/models/enc8290_asic_model.a
  80. # System model library that writes test data traces
  81. TESTDATALIB = ../../system/models/enc8290_asic_model_trace.a
  82. # show the path to compiler, where to find header files
  83. INCLUDE = -I../source/h264 -I../source/jpeg \
  84. -I../inc -I../source/common -Iewl -Idebug_trace \
  85. -I../source/camstab -Ikernel_module -Imemalloc
  86. # compiler switches
  87. CFLAGS = $(ARCH) -Wall -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE \
  88. $(DEBFLAGS) $(INCLUDE) #-DH8290_MEMCPY_CABAC_INIT
  89. # list of used sourcefiles
  90. SRC_ENC_COMMON := encasiccontroller_v2.c \
  91. encasiccontroller.c \
  92. encpreprocess.c
  93. SRC_H264 := H264CodeFrame.c\
  94. H264Init.c\
  95. H264NalUnit.c\
  96. H264PictureParameterSet.c\
  97. H264PutBits.c\
  98. H264RateControl.c\
  99. H264SequenceParameterSet.c\
  100. H264Slice.c\
  101. H264EncApi.c\
  102. H264Cabac.c\
  103. H264Mad.c\
  104. H264Sei.c
  105. SRC_JPEG := EncJpeg.c\
  106. EncJpegInit.c\
  107. EncJpegCodeFrame.c\
  108. EncJpegPutBits.c\
  109. JpegEncApi.c
  110. SRC_VIDSTAB := vidstabcommon.c vidstabalg.c
  111. SRC_VIDSTAB_API := vidstabapi.c vidstabinternal.c
  112. SRC_TRACE = enctrace.c enctracestream.c
  113. # Source files for test case specific test IDs, compiler flag INTERNAL_TEST
  114. # If these are not included some tests will fail
  115. SRC_TESTING = H264TestId.c h264encapi_ext.c
  116. SRC_EWL_PC := ewl_x280_file.c
  117. SRC_EWL_ARM = ewl_x280_common.c ewl_linux_lock.c
  118. ifeq ($(POLLING),y)
  119. SRC_EWL_ARM += ewl_x280_polling.c
  120. CFLAGS += -DENC8290_IRQ_DISABLE=1
  121. else
  122. SRC_EWL_ARM += ewl_x280_irq.c
  123. endif
  124. # common parts only for encoder and not for video stab
  125. INCLUDE_ENC_COMMON=n
  126. # Combine the list of all the source files included in the library build
  127. ifeq ($(INCLUDE_H264),y)
  128. SRCS += $(SRC_H264)
  129. INCLUDE_ENC_COMMON=y
  130. endif
  131. ifeq ($(INCLUDE_JPEG),y)
  132. SRCS += $(SRC_JPEG)
  133. INCLUDE_ENC_COMMON=y
  134. endif
  135. ifeq ($(INCLUDE_VIDSTAB),y)
  136. SRCS += $(SRC_VIDSTAB) $(SRC_VIDSTAB_API)
  137. CFLAGS += -DVIDEOSTAB_ENABLED
  138. endif
  139. ifeq ($(INCLUDE_TESTING),y)
  140. SRCS += $(SRC_TESTING)
  141. CONFFLAGS += -DINTERNAL_TEST
  142. endif
  143. # add common encoder files
  144. ifeq ($(INCLUDE_ENC_COMMON),y)
  145. SRCS += $(SRC_ENC_COMMON)
  146. endif
  147. # if tracing flags are defined we need to compile the tracing functions
  148. ifeq ($(DEBUG),y)
  149. SRCS += $(SRC_TRACE)
  150. endif
  151. # choose EWL source, system model uses its own EWL
  152. ifneq (,$(findstring pclinux, $(MAKECMDGOALS)))
  153. SRCS +=
  154. else
  155. ifneq (,$(findstring system, $(MAKECMDGOALS)))
  156. SRCS +=
  157. else
  158. ifneq (,$(findstring testdata, $(MAKECMDGOALS)))
  159. SRCS +=
  160. else
  161. ifneq (,$(findstring eval, $(MAKECMDGOALS)))
  162. SRCS +=
  163. else
  164. SRCS += $(SRC_EWL_ARM)
  165. endif
  166. endif
  167. endif
  168. endif
  169. #source search path
  170. vpath %.c
  171. vpath %.c ../source/common ../source/h264 ../source/jpeg \
  172. ../source/camstab ./ewl ./debug_trace
  173. # name of the outputfile (library)
  174. ENCLIB = lib8290enc.a
  175. # MACRO for cleaning object -files
  176. RM = rm -f
  177. # MACRO for creating library that includes all the object files
  178. AR = $(CROSS_COMPILE)ar rcsv
  179. # object files will be generated from .c sourcefiles
  180. OBJS = $(SRCS:.c=.o)
  181. #Here are rules for building codes and generating object library.
  182. all: tags
  183. @echo ---------------------------------------
  184. @echo "Usage: make [ system | testdata | versatile | integrator ]"
  185. @echo "system - PC system model (== pclinux)"
  186. @echo "testdata - PC system model for test data creation"
  187. @echo "eval - PC system model for evaluation with frame limit"
  188. @echo "versatile - ARM versatile with FPGA HW"
  189. @echo "integrator - ARM integrator with FPGA HW"
  190. @echo "NOTE! Make sure to do 'make clean'"
  191. @echo "between compiling to different targets!"
  192. @echo ---------------------------------------
  193. .PHONY: pclinux system testdata integrator versatile clean tags depend
  194. evaluation: eval
  195. eval: CFLAGS += -DEVALUATION_LIMIT=1000
  196. eval: system
  197. pclinux: system
  198. system: $(ENCLIB)
  199. testdata: CFLAGS += -DTEST_DATA -DTRACE_STREAM
  200. testdata: $(ENCLIB)
  201. integrator: ENVSET = -DSDRAM_LM_BASE=0x80000000 \
  202. -DENC_MODULE_PATH=\"/dev/hx280\" \
  203. -DMEMALLOC_MODULE_PATH=\"/dev/memalloc\"
  204. integrator: ENVSET += -DEWL_NO_HW_TIMEOUT
  205. integrator: CROSS_COMPILE = arm-linux-
  206. integrator: ARCH = -mcpu=arm9tdmi -mtune=arm9tdmi
  207. integrator: $(ENCLIB)
  208. versatile: ENVSET = -DSDRAM_LM_BASE=0x80000000 \
  209. -DENC_MODULE_PATH=\"/tmp/dev/hx280\" \
  210. -DMEMALLOC_MODULE_PATH=\"/tmp/dev/memalloc\"
  211. #versatile: ENVSET += -DEWL_NO_HW_TIMEOUT
  212. #versatile: CROSS_COMPILE = arm-none-linux-gnueabihf-
  213. #versatile: ARCH = -mcpu=cortex-a5 -mfloat-abi=softfp -mfpu=neon
  214. versatile: ARCH = -mtune=cortex-a5
  215. versatile: $(ENCLIB)
  216. versatile_tb: versatile
  217. $(MAKE) -w -C test/h264 versatile
  218. # $(MAKE) -w -C test/mpeg4 versatile
  219. $(MAKE) -w -C test/camstab versatile
  220. $(MAKE) -w -C test/jpeg versatile
  221. pcdemo: CFLAGS = -O2 -g -Wall -D_GNU_SOURCE -D_REENTRANT -D_THREAD_SAFE \
  222. -DDEBUG -D_ASSERT_USED -DH8290_HAVE_ENCDEBUG_H -DH8290_HAVE_VIDSTABDEBUG_H $(INCLUDE)
  223. pcdemo: $(SRC_H264:.c=.o) $(SRC_ENC_COMMON:.c=.o) $(SRC_VIDSTAB:.c=.o)
  224. $(AR) $(ENCLIB) $+
  225. .PHONY: pci
  226. pci:
  227. pci: CROSS_COMPILE=
  228. pci: ARCH=
  229. pci: ENVSET = -DPC_PCI_FPGA_DEMO \
  230. -DSDRAM_LM_BASE=$(CHW_BASE_ADDRESS) \
  231. -DENC_MODULE_PATH=\"/tmp/dev/hx280\" \
  232. -DMEMALLOC_MODULE_PATH=\"/tmp/dev/memalloc\"
  233. pci: ENVSET += -DEWL_NO_HW_TIMEOUT
  234. pci: ENVSET += -DENC_DEMO
  235. pci: $(ENCLIB)
  236. system_cov: CC = covc --retain -t!debug_trace/enctrace.c,!debug_trace/enctracestream.c g++
  237. system_cov: $(ENCLIB)
  238. $(ENCLIB): depend static_lib
  239. static_lib: $(OBJS)
  240. $(AR) $(ENCLIB) $+
  241. %.o: %.c
  242. $(CC) -c $(CFLAGS) $(ENVSET) $(CONFFLAGS) $(EFENCE) $< -o $@
  243. clean:
  244. $(RM) $(ENCLIB)
  245. $(RM) .depend
  246. $(RM) *.o
  247. tags:
  248. ctags ../inc/*h ../source/common/*[ch] ../source/camstab/*[ch]\
  249. ../source/h264/*[ch] ../source/jpeg/*[ch]
  250. lint: LINT_DEF=-dVIDEOSTAB_ENABLED
  251. lint: $(SRC_H264) $(SRC_JPEG) $(SRC_VIDSTAB) $(SRC_VIDSTAB_API) # take out any not relevant sources
  252. # -e537 removes warnings about multiple include
  253. # -e641 removes warnings about converting enum to int
  254. -lint-nt -w2 -e537 -e641 $(LINT_DEF) $(INCLUDE) $^ > pc-lint-report.txt
  255. depend: CFLAGS = $(INCLUDE)
  256. depend: $(SRCS)
  257. $(CC) $(CFLAGS) $(ENVSET) $(EFENCE) -M $^ > .depend
  258. ifneq (clean, $(findstring clean, $(MAKECMDGOALS)))
  259. ifeq (.depend, $(wildcard .depend))
  260. include .depend
  261. endif
  262. endif