Advertisement
Guest User

Makefile.common

a guest
Mar 3rd, 2014
355
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.76 KB | None | 0 0
  1. ###############################################################################
  2. # Ensure this Makefile is invoked with the right variable set
  3. ###############################################################################
  4. ifeq ($(ARCH), )
  5. all:
  6. @echo "***************************************************************"
  7. @echo "You cannot use this Makefile directly, instead use the"
  8. @echo "architecture-specific Makefile. For example:"
  9. @echo " gmake -f make/Makefile.i86Linux2.6gcc4.4.5"
  10. @echo "***************************************************************"
  11. @false
  12. else
  13. ###############################################################################
  14. # Ensure $NDDSHOME is defined
  15. ###############################################################################
  16. ifeq ($(NDDSHOME), )
  17. all:
  18. @echo "***************************************************************"
  19. @echo "The environment variable 'NDDSHOME' is not set!"
  20. @echo "To use this makefile you need to set NDDSHOME to the directory"
  21. @echo "where you have RTI Connext installed."
  22. @echo "***************************************************************"
  23. @false
  24. endif
  25. endif
  26.  
  27. # Define the sources and NDDS search path
  28. INCLUDES = -Isrc/CommonInfrastructure -Isrc/Generated -I$(NDDSHOME)/include \
  29. -I$(NDDSHOME)/include/ndds -I/usr/include/libxml2
  30.  
  31.  
  32. ###############################################################################
  33. # Modify build flags for debug/release
  34. ###############################################################################
  35. ifeq ($(DEBUG),1)
  36. CXXFLAGS += -g -O0 -D__STDC_CONSTANT_MACROS
  37. ifeq ($(SHAREDLIB),1)
  38. NDDSLIBS = -lnddscppd -lnddscd -lnddscored
  39. else
  40. NDDSLIBS = -lnddscppzd -lnddsczd -lnddscorezd
  41. endif
  42. else
  43. CXXFLAGS += -O2 -D__STDC_CONSTANT_MACROS
  44. ifeq ($(SHAREDLIB),1)
  45. NDDSLIBS = -lnddscpp -lnddsc -lnddscore
  46. else
  47. NDDSLIBS = -lnddscppz -lnddscz -lnddscorez
  48. endif
  49. endif
  50.  
  51. CXXFLAGS += $(shell pkg-config --cflags glib-2.0)
  52. CXXFLAGS += $(shell pkg-config --cflags gstreamer-0.10)
  53.  
  54. LIBS = -L$(NDDSHOME)/lib/$(ARCH) -L/usr/lib $(NDDSLIBS) $(SYSLIBS)
  55. LIBS += $(shell pkg-config --libs glib-2.0)
  56. LIBS += $(shell pkg-config --libs gstreamer-0.10)
  57. LIBS += -lgstapp-0.10
  58.  
  59. COMMONSRC = src/CommonInfrastructure/DDSCommunicator.cxx \
  60. src/CommonInfrastructure/OSAPI.cxx \
  61. src/CommonInfrastructure/VideoBuffer.cxx \
  62. src/CommonInfrastructure/VideoSource.cxx \
  63. src/CommonInfrastructure/VideoOutput.cxx \
  64. src/CommonInfrastructure/SimCList.cxx
  65.  
  66. COMMON_H = src/CommonInfrastructure/DDSCommunicator.h \
  67. src/CommonInfrastructure/OSAPI.h \
  68. src/CommonInfrastructure/DDSTypeWrapper.h \
  69. src/CommonInfrastructure/VideoBuffer.h \
  70. src/CommonInfrastructure/VideoSource.h
  71.  
  72. SOURCES_IDL = src/Generated/VideoData.cxx \
  73. src/Generated/VideoDataPlugin.cxx \
  74. src/Generated/VideoDataSupport.cxx
  75.  
  76. VIDEOPUB_H = src/VideoPublisher/VideoPublisher.h
  77.  
  78. VIDEOPUBSRC = src/VideoPublisher/VideoPublisher.cxx \
  79. src/VideoPublisher/VideoPublisherInterface.cxx
  80.  
  81. VIDEOSUB_H = src/VideoSubscriber/VideoSubscriber.h
  82.  
  83. VIDEOSUBSRC = src/VideoSubscriber/VideoSubscriber.cxx \
  84. src/VideoSubscriber/VideoSubscriberInterface.cxx
  85.  
  86. HEADERS_IDL = src/Generated/VideoData.h \
  87. src/Generated/VideoDataPlugin.h \
  88. src/Generated/VideoDataSupport.h
  89.  
  90. DIRECTORIES = objs.dir objs/$(ARCH).dir objs/$(ARCH)/VideoPublisher.dir \
  91. objs/$(ARCH)/Common.dir objs/$(ARCH)/VideoSubscriber.dir
  92. SOURCES_NODIR = $(notdir $(COMMONSRC)) $(notdir $(SOURCES_IDL))
  93. VIDEOPUBSRC_NODIR = $(notdir $(VIDEOPUBSRC))
  94. VIDEOSUBSRC_NODIR = $(notdir $(VIDEOSUBSRC))
  95.  
  96. COMMONOBJS = $(SOURCES_NODIR:%.cxx=objs/$(ARCH)/Common/%.o)
  97. VIDEOPUBOBJS = $(VIDEOPUBSRC_NODIR:%.cxx=objs/$(ARCH)/VideoPublisher/%.o) $(COMMONOBJS)
  98. VIDEOSUBOBJS = $(VIDEOSUBSRC_NODIR:%.cxx=objs/$(ARCH)/VideoSubscriber/%.o) $(COMMONOBJS)
  99. EXEC = VideoPublisher
  100. SUBEXEC = VideoSubscriber
  101.  
  102. ###############################################################################
  103. # Build Rules
  104. ###############################################################################
  105. $(ARCH): VideoPublisher VideoSubscriber
  106.  
  107. VideoPublisher: $(DIRECTORIES) $(VIDEOPUBOBJS) $(EXEC:%=objs/$(ARCH)/VideoPublisher/%.o) \
  108. $(EXEC:%=objs/$(ARCH)/VideoPublisher/%.out)
  109.  
  110. VideoSubscriber: $(DIRECTORIES) $(VIDEOSUBOBJS) $(@:%=objs/$(ARCH)/VideoSubscriber/%.o) \
  111. $(SUBEXEC:%=objs/$(ARCH)/VideoSubscriber/%.out)
  112.  
  113.  
  114. # Building the video publisher application
  115. objs/$(ARCH)/VideoPublisher/%.out: objs/$(ARCH)/VideoPublisher/%.o
  116. $(CXXLD) $(CXXLDFLAGS) -o $(@:%.out=%) $(VIDEOPUBOBJS) $(LIBS)
  117.  
  118. # Building the video subscriber application
  119. objs/$(ARCH)/VideoSubscriber/%.out: objs/$(ARCH)/VideoSubscriber/%.o
  120. $(CXXLD) $(CXXLDFLAGS) -o $(@:%.out=%) $(VIDEOSUBOBJS) $(LIBS)
  121.  
  122. objs/$(ARCH)/Common/%.o: src/CommonInfrastructure/%.cxx $(COMMON_H)
  123. $(CXX) $(CXXFLAGS) -o $@ $(DEFINES) $(INCLUDES) -c $<
  124.  
  125. objs/$(ARCH)/Common/%.o: src/Generated/%.cxx $(COMMON_H)
  126. $(CXX) $(CXXFLAGS) -o $@ $(DEFINES) $(INCLUDES) -c $<
  127.  
  128. objs/$(ARCH)/VideoPublisher/%.o: src/VideoPublisher/%.cxx $(COMMON_H) $(HEADERS_IDL)
  129. $(CXX) $(CXXFLAGS) -o $@ $(DEFINES) $(INCLUDES) -c $<
  130.  
  131. objs/$(ARCH)/VideoSubscriber/%.o: src/VideoSubscriber/%.cxx $(COMMON_H) $(HEADERS_IDL)
  132. $(CXX) $(CXXFLAGS) -o $@ $(DEFINES) $(INCLUDES) -c $<
  133.  
  134.  
  135. # Rule to rebuild the generated files when the .idl file change
  136. $(SOURCES_IDL) $(HEADERS_IDL): src/Idl/VideoData.idl
  137. @mkdir -p src/Generated
  138. ifeq ($(OS_ARCH), i86Win32)
  139. call $(NDDSHOME)/scripts/rtiddsgen.bat -d src/idl src/VideoData.idl -replace -language C++
  140. else
  141. $(NDDSHOME)/scripts/rtiddsgen -namespace -d src/Generated src/Idl/VideoData.idl -replace -language C++
  142. endif
  143.  
  144. generate: $(SOURCES_IDL) $(HEADERS_IDL)
  145.  
  146. # Here is how we create those subdirectories automatically.
  147. %.dir :
  148. @echo "Checking directory $*"
  149. @if [ ! -d $* ]; then \
  150. echo "Making directory $*"; \
  151. mkdir -p $* ; \
  152. fi;
  153.  
  154. ###############################################################################
  155. # Clean target: removes the objs dir
  156. ###############################################################################
  157. clean:
  158. @rm -Rf objs/$(ARCH)
  159. @echo "Successfully deleted object and executable files for architecture $(ARCH)"
  160. @echo "To delete ALL the architectures and any generated file use target 'veryclean'"
  161.  
  162. veryclean:
  163. @rm -Rf objs
  164. @rm -Rf src/idl
  165. @rm -Rf src/generated
  166. @echo "Deleted all executables, objects and generated files"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement