Makefile.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Basic OS detection
  2. #
  3. UNAME=$(shell uname)
  4. CP=cp
  5. ifeq "$(UNAME)" "Linux"
  6. OPENAIS_COMPAT=LINUX
  7. endif
  8. ifeq "$(UNAME)" "Darwin"
  9. OPENAIS_COMPAT=DARWIN
  10. CP=rsync
  11. endif
  12. ifneq "" "$(findstring BSD,$(UNAME))"
  13. OPENAIS_COMPAT=BSD
  14. endif
  15. ifeq "$(UNAME)" "SunOS"
  16. OPENAIS_COMPAT=SOLARIS
  17. # Note that CC must be set to gcc compiled to link with gnu-ld
  18. endif
  19. ifndef OPENAIS_COMPAT
  20. $(error "OPENAIS_COMPAT cannot be detected, it must be manually defined")
  21. endif
  22. # BUILD_DYNAMIC can be defined to 1 to build for dynamic loading of service
  23. # handler modules. If the developer intends to debug, building without
  24. # dynamic modules should provide an easier route.
  25. ifndef BUILD_DYNAMIC
  26. BUILD_DYNAMIC=1
  27. endif
  28. # OPENAIS_BUILD can be defined as RELEASE or DEBUG
  29. #
  30. ifndef OPENAIS_BUILD
  31. OPENAIS_BUILD=RELEASE
  32. endif
  33. # OPENAIS_PROFILE
  34. # default CFLAGS, LDFLAGS
  35. #
  36. CFLAGS =
  37. LDFLAGS =
  38. DYFLAGS =
  39. # Adding the TS_CLASS flag enables not being scheduled RR
  40. #CFLAGS += -DTS_CLASS
  41. # build CFLAGS, LDFLAGS
  42. #
  43. ifeq (${OPENAIS_BUILD}, RELEASE)
  44. CFLAGS += -O3 -Wall
  45. # -Wstrict-aliasing=2 TODO sameday fix all of these
  46. ifndef OPENAIS_PROFILE
  47. CFLAGS += -fomit-frame-pointer
  48. endif
  49. LDFLAGS +=
  50. endif
  51. ifeq (${OPENAIS_BUILD}, DEBUG)
  52. CFLAGS += -O0 -g -Wall -DDEBUG
  53. LDFLAGS += -g
  54. ifeq (${OPENAIS_COMPAT}, SOLARIS)
  55. CFLAGS += -Werror -DTS_CLASS
  56. endif
  57. endif
  58. ifeq (${OPENAIS_BUILD}, COVERAGE)
  59. CFLAGS += -O0 -g -ftest-coverage -fprofile-arcs
  60. LDFLAGS += -g -ftest-coverage -fprofile-arcs
  61. BUILD_DYNAMIC=0
  62. endif
  63. ifdef OPENAIS_PROFILE
  64. CFLAGS += -pg
  65. LDFLAGS += -pg
  66. endif
  67. # platform specific CFLAGS, LDFLAGS
  68. #
  69. ifeq (${OPENAIS_COMPAT}, LINUX)
  70. override CFLAGS += -DOPENAIS_LINUX
  71. override LDFLAGS += -ldl -lpthread
  72. override DYFLAGS += -rdynamic
  73. endif
  74. ifeq (${OPENAIS_COMPAT}, BSD)
  75. override CFLAGS += -DOPENAIS_BSD
  76. override LDFLAGS += -pthread
  77. override DYFLAGS += -export-dynamic
  78. endif
  79. ifeq (${OPENAIS_COMPAT}, DARWIN)
  80. override CFLAGS += -DOPENAIS_DARWIN
  81. override LDFLAGS += -lpthread
  82. endif
  83. ifeq (${OPENAIS_COMPAT}, SOLARIS)
  84. override CFLAGS += -DOPENAIS_SOLARIS -D_REENTRANT
  85. override LDFLAGS += -lpthread
  86. # See http://sources.redhat.com/ml/bug-gnu-utils/2000-07/msg00168.html
  87. override LDFLAGS += -Wl,--export-dynamic -Wl,-rpath-link=/usr/lib
  88. ifeq ($(shell uname -r), 5.10)
  89. override CFLAGS += -DHAVE_GETPEERUCRED -DHAVE_SCANDIR -DHAVE_ALPHASORT
  90. endif
  91. ifeq ($(shell uname -r), 5.11)
  92. override CFLAGS += -DHAVE_GETPEERUCRED -DHAVE_SCANDIR -DHAVE_ALPHASORT
  93. endif
  94. endif