Makefile.inc 2.1 KB

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