Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. ##############################################################################
  2. # File: Generic makefile for arm c/c++ Program
  3. # Author: athina
  4. # Date: 2020-06-20 (v1.0, original version)
  5. # Usage:
  6. # Make the Yolov3 Demo
  7. ##############################################################################
  8. # gcc compiler
  9. CC = aarch64-himix100-linux-gcc
  10. # g++ compiler
  11. CXX = aarch64-himix100-linux-g++
  12. # program name
  13. PROGRAM =bird
  14. # source directory
  15. SRCDIRS =./src
  16. # header directory
  17. HDRDIRS =./inc ./inc/include ./third ./inc/rapidjson ./inc/dataType ./inc/device
  18. # binary directory
  19. BINDIRS =./bin
  20. # library directory
  21. LIBDIRS =./lib ./third/libopencv
  22. ##############################################################################
  23. # empty character
  24. EMPTY =
  25. # gcc option
  26. CFLAGS =-g -rdynamic -Wall -O0
  27. CFLAGS +=$(addprefix -I,$(HDRDIRS))
  28. # g++ option
  29. CXXFLAGS=$(CFLAGS)
  30. # Link flags
  31. LDFLAGS = $(addprefix -L,$(LIBDIRS)) -Wl,-z,relro,-z,noexecstack,--disable-new-dtags,-rpath,/lib/:/usr/lib/:/usr/app/lib
  32. LDFLAGS += -lrt -lm -lsecurec -lpthread -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio
  33. # dependence flag
  34. DEPFLAGS=-MM -MP
  35. # source extended
  36. SRCEXTS =.c .cpp
  37. # header extended
  38. HDREXTS =.h
  39. # source files
  40. SOURCE =$(foreach d, $(SRCDIRS),$(wildcard $(addprefix $(d)/*,$(SRCEXTS))))
  41. # head files
  42. HEADER =$(foreach d, $(HDRDIRS),$(wildcard $(addprefix $(d)/*,$(HDREXTS))))
  43. # object files
  44. OBJECT =$(foreach d, $(basename $(notdir $(SOURCE))),$(BINDIRS)/$(d).o)
  45. # dependance files
  46. DEPEND =$(patsubst %.o,%.d, $(OBJECT))
  47. ##############################################################################
  48. # Stable, don't change
  49. ifeq ($(PROGRAM), $(EMPTY))
  50. PROGRAM:=$(BINDIRS)/program
  51. else
  52. PROGRAM:=$(BINDIRS)/$(PROGRAM)
  53. endif
  54. .PHONY: all object depend clean vclean show help
  55. # target file
  56. all:$(PROGRAM)
  57. $(PROGRAM): $(OBJECT)
  58. ifeq ($(filter-out %.c, $(SOURCE)), $(EMPTY))
  59. ifneq ($(SOURCE), $(EMPTY))
  60. $(CC) -o $@ $(DBGFLAGS) $^ $(LDFLAGS)
  61. endif
  62. else
  63. ifneq ($(SOURCE), $(EMPTY))
  64. $(CXX) -o $@ $(DBGFLAGS) $^ $(LDFLAGS)
  65. endif
  66. endif
  67. ifndef NODEP
  68. sinclude $(DEPEND)
  69. endif
  70. # object files
  71. object:$(OBJECT)
  72. $(BINDIRS)/%.o: $(SRCDIRS)/%.c
  73. $(CC) $(OPTFLAGS) $(CFLAGS) -o $@ -c $<
  74. $(BINDIRS)/%.o: $(SRCDIRS)/%.cpp
  75. $(CXX) $(OPTFLAGS) $(CXXFLAGS) -o $@ -c $<
  76. # dependance files
  77. depend:$(DEPEND)
  78. $(DEPEND): $(SOURCE)
  79. $(BINDIRS)/%.d: $(SRCDIRS)/%.c
  80. @$(CC) $(CFLAGS) $(DEPFLAGS) $< | sed 's,\($*\).o[ :]*,$(BINDIRS)/\1.o $@ :,g' >$@
  81. $(BINDIRS)/%.d: $(SRCDIRS)/%.cpp
  82. @$(CXX) $(CXXFLAGS) $(DEPFLAGS) $< | sed 's,\($*\).o[ :]*,$(BINDIRS)/\1.o $@ :,g' >$@
  83. # clean the temporary files
  84. clean:
  85. rm -rf ./bin/*.*
  86. vclean:
  87. $(RM) $(OBJECT) $(DEPEND) $(PROGRAM)
  88. show:
  89. @echo '[File list]:'
  90. @echo ' PROGRAM NAME :$(PROGRAM)'
  91. @echo ' SOURCE FILES :$(SOURCE)'
  92. @echo ' HEADER FILES :$(HEADER)'
  93. @echo ' OBJECT FILES :$(OBJECT)'
  94. @echo ' DEPEND FILES :$(DEPEND)'
  95. help:
  96. @echo 'Generic Makefile for C/C++ Programs (gcmakefile) version 2.1'
  97. @echo '[Usage]: make[TARGET]'
  98. @echo ' all :(=make)compile and link'
  99. @echo ' object :compile only (not linking)'
  100. @echo ' depend :(NODEP=yes)[do|donot] generate the dependencies(not compiling)'
  101. @echo ' clean :clean up the object files and the dependence files'
  102. @echo ' vclean :clean up all of the generated files(including executable file)'
  103. @echo ' show :show the hierarchical of the files list'
  104. @echo ' help :print how to use the makefile manual'