makefrag 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #
  2. # on windows we have to link with the ws2_32 (winsock2) library as it is no longer added
  3. # to the omnetpp system libraries by default (as of OMNeT++ 5.1)
  4. #
  5. ifeq ($(PLATFORM),win32.x86_64)
  6. LIBS += -lws2_32
  7. DEFINES += -DINET_EXPORT
  8. ENABLE_AUTO_IMPORT=-Wl,--enable-auto-import
  9. LDFLAGS := $(filter-out $(ENABLE_AUTO_IMPORT), $(LDFLAGS))
  10. endif
  11. #
  12. # TCP implementaion using the Network Simulation Cradle (TCP_NSC feature)
  13. #
  14. WITH_TCP_NSC := $(shell (cd .. && ./inet_featuretool -q isenabled TCP_NSC && echo enabled) )
  15. ifeq ($(WITH_TCP_NSC), enabled)
  16. NSC_VERSION= $(shell ls -d ../3rdparty/nsc* 2>/dev/null | sed 's/^.*-//')
  17. ifneq ($(NSC_VERSION),)
  18. INCLUDE_PATH += -I../3rdparty/nsc-$(NSC_VERSION)/sim
  19. LIBS += -Wl,-rpath,$(abspath ../3rdparty/nsc-$(NSC_VERSION))
  20. else
  21. $(error Please install NSC or disable 'TCP_NSC' feature)
  22. endif
  23. endif
  24. #
  25. # TCP implementation using the lwIP stack
  26. #
  27. WITH_TCP_LWIP := $(shell (cd .. && ./inet_featuretool -q isenabled TCP_lwIP && echo enabled) )
  28. ifeq ($(WITH_TCP_LWIP), enabled)
  29. INCLUDE_PATH += -Iinet/transportlayer/tcp_lwip/lwip/include -Iinet/transportlayer/tcp_lwip/lwip/include/ipv4 -Iinet/transportlayer/tcp_lwip/lwip/include/ipv6
  30. endif
  31. #
  32. # pkg-config:
  33. #
  34. HAVE_PKGCFG := $(shell pkg-config --version 2>/dev/null)
  35. ifeq ($(strip $(HAVE_PKGCFG)),)
  36. HAVE_PKGCFG := no
  37. else
  38. HAVE_PKGCFG := yes
  39. PKGCFG := $(shell which pkg-config)
  40. endif
  41. #
  42. # VoipStream feature:
  43. #
  44. WITH_VOIPSTREAM := $(shell (cd .. && ./inet_featuretool -q isenabled VoIPStream && echo enabled) )
  45. ifeq ($(WITH_VOIPSTREAM), enabled)
  46. ifeq ($(HAVE_PKGCFG), yes)
  47. HAVE_FFMPEG := $(shell $(PKGCFG) --exists libavcodec libavformat libavutil && echo yes || echo no)
  48. ifeq ($(HAVE_FFMPEG), yes)
  49. LIBS += $(shell $(PKGCFG) --libs libavcodec libavformat libavutil)
  50. CFLAGS += $(shell $(PKGCFG) --cflags libavcodec libavformat libavutil) -DHAVE_FFMPEG
  51. endif
  52. HAVE_FFMPEG_AVRESAMPLE := $(shell $(PKGCFG) --exists libavresample && echo yes || echo no)
  53. ifeq ($(HAVE_FFMPEG_AVRESAMPLE), yes)
  54. LIBS += $(shell $(PKGCFG) --libs libavresample)
  55. CFLAGS += $(shell $(PKGCFG) --cflags libavresample) -DHAVE_FFMPEG_AVRESAMPLE
  56. endif
  57. endif
  58. endif
  59. #
  60. # visualization feature requires (optionally) some extra osg and osgEarth libraries
  61. #
  62. WITH_VISUALIZERS := $(shell (cd .. && ./inet_featuretool -q isenabled visualization && echo enabled) )
  63. ifeq ($(WITH_VISUALIZERS), enabled)
  64. ifeq ($(WITH_OSGEARTH), yes)
  65. OMNETPP_LIBS += -lOpenThreads -losg -losgText -losgDB -losgEarth -losgEarthUtil
  66. endif
  67. endif
  68. # uncomment this if you want to run the NS3 vs INET 802.11 cross validation tests in the 'tests/misc/ns3' folder.
  69. # CFLAGS += -DNS3_VALIDATION
  70. # disable anoying "... hides overloaded virtual function" warning
  71. CFLAGS += -Wno-overloaded-virtual
  72. #########################################################################
  73. # precompiled header support for GCC and CLANG
  74. ifeq ($(CC),gcc)
  75. PRECOMPILED_EXT=gch
  76. else ifeq ($(CC),clang)
  77. PRECOMPILED_EXT=pch
  78. else
  79. PRECOMPILED_EXT=
  80. endif
  81. PRECOMPILED_HEADER=inet/common/precompiled_$(MODE).h
  82. PRECOMPILED_HEADER_PCH=$(PRECOMPILED_HEADER).$(PRECOMPILED_EXT)
  83. PRECOMPILED_HEADER_D=$(PRECOMPILED_HEADER_PCH:%.$(PRECOMPILED_EXT)=%.d)
  84. CFLAGS += -include $(PRECOMPILED_HEADER)
  85. # Main target
  86. all-pch: | pch msgheaders all
  87. .PHONY: pch clean-pch
  88. pch : $(PRECOMPILED_HEADER_PCH)
  89. $(PRECOMPILED_HEADER_PCH): $(PRECOMPILED_HEADER)
  90. ifneq ("$(PRECOMPILED_EXT)","")
  91. @echo Creating precompiled header for $(CC)...
  92. $(Q)$(CXX) -x c++-header $(CXXFLAGS) $(filter-out -MMD -include $(PRECOMPILED_HEADER),$(COPTS)) -MD -o $@ $<
  93. endif
  94. clean: clean-pch clean-defines
  95. clean-pch:
  96. $(Q)-rm -f $(PRECOMPILED_HEADER_D) $(PRECOMPILED_HEADER).pch $(PRECOMPILED_HEADER).gch
  97. -include $(PRECOMPILED_HEADER_D)
  98. # Create opp_defines.h so important WITH_* macros from OMNeT++ can be included as macros from a header file
  99. # This helps the IDE to properly enable/disable conditional code in the editor
  100. DEFINES_FILE=inet/opp_defines.h
  101. msgheaders: $(DEFINES_FILE)
  102. clean-defines:
  103. $(Q)-rm -f $(DEFINES_FILE)
  104. $(DEFINES_FILE) : $(COPTS_FILE)
  105. @echo "// Generated file, do not edit" >$(DEFINES_FILE)
  106. ifeq ($(WITH_OSG),yes)
  107. @echo "#ifndef WITH_OSG" >>$(DEFINES_FILE)
  108. @echo "#define WITH_OSG" >>$(DEFINES_FILE)
  109. @echo "#endif" >>$(DEFINES_FILE)
  110. endif
  111. ifeq ($(WITH_OSGEARTH),yes)
  112. @echo "#ifndef WITH_OSGEARTH" >>$(DEFINES_FILE)
  113. @echo "#define WITH_OSGEARTH" >>$(DEFINES_FILE)
  114. @echo "#endif" >>$(DEFINES_FILE)
  115. endif
  116. # dump out the actual compiler and linker command line for easier debugging
  117. ifneq ($(MAKECMDGOALS),clean)
  118. $(info *** COMPILING with:)
  119. $(info $(CXX) -c $(CXXFLAGS) $(COPTS))
  120. $(info *** LINKING with:)
  121. $(info $(SHLIB_LD) -o $O/$(TARGET) $(AS_NEEDED_OFF) $(WHOLE_ARCHIVE_ON) $(LIBS) $(WHOLE_ARCHIVE_OFF) $(OMNETPP_LIBS) $(LDFLAGS))
  122. $(info Building...)
  123. endif