Makefile 3.7 KB

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