Makefile 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #
  2. # Asterisk -- A telephony toolkit for Linux.
  3. #
  4. # Makefile for CDR backends (dynamically loaded)
  5. #
  6. # Copyright (C) 1999-2005, Digium
  7. #
  8. # Mark Spencer <markster@digium.com>
  9. #
  10. # This program is free software, distributed under the terms of
  11. # the GNU General Public License
  12. #
  13. MODS=cdr_csv.so cdr_manager.so cdr_custom.so
  14. ifeq (${OSARCH},CYGWIN)
  15. CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
  16. CYGSOLIB=-L.. -L. -lasterisk.dll
  17. else
  18. CFLAGS+=-fPIC
  19. endif
  20. ifeq ($(findstring BSD,${OSARCH}),BSD)
  21. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include
  22. SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
  23. endif
  24. #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
  25. #This works for even old (2.96) versions of gcc and provides a small boost either way.
  26. #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
  27. #So we go lowest common available by gcc and go a step down, still a step up from
  28. #the default as we now have a better instruction set to work with. - Belgarath
  29. ifeq ($(PROC),sparc64)
  30. PROC=ultrasparc
  31. CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
  32. endif
  33. #
  34. # unixODBC stuff...
  35. #
  36. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
  37. MODS+=cdr_odbc.so
  38. endif
  39. #
  40. # FreeTDS stuff...
  41. #
  42. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/tds.h),)
  43. ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/local/include/tdsver.h | grep -c 0.63),1)
  44. CFLAGS += -DFREETDS_0_63
  45. else
  46. ifeq ($(shell grep -s TDS_VERSION_NO $(CROSS_COMPILE_TARGET)/usr/include/tdsver.h $(CROSS_COMPILE_TARGET)/usr/local/include/tdsver.h | grep -c 0.62),1)
  47. CFLAGS += -DFREETDS_0_62
  48. else
  49. CFLAGS += -DFREETDS_PRE_0_62
  50. endif
  51. endif
  52. MODS+=cdr_tds.so
  53. endif
  54. #
  55. # PGSQL stuff... Autoconf anyone??
  56. #
  57. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),)
  58. MODS+=cdr_pgsql.so
  59. endif
  60. MLFLAGS=
  61. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
  62. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
  63. MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/postgresql
  64. endif
  65. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include),)
  66. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include
  67. MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib
  68. endif
  69. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql),)
  70. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/pgsql
  71. MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql
  72. endif
  73. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql),)
  74. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql
  75. MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql
  76. endif
  77. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include),)
  78. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/opt/pgsql/include
  79. MLFLAGS+=-L$(CROSS_COMPILE_TARGET) /opt/pgsql/lib
  80. endif
  81. ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
  82. CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
  83. endif
  84. ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/lib/libpq.so),)
  85. MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib
  86. endif
  87. #
  88. # SQLite stuff...
  89. #
  90. ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sqlite.h),)
  91. MODS+=cdr_sqlite.so
  92. endif
  93. all: depend $(MODS)
  94. install: all
  95. for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
  96. clean:
  97. rm -f *.so *.o .depend
  98. %.so : %.o
  99. $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
  100. ifneq ($(wildcard .depend),)
  101. include .depend
  102. endif
  103. cdr_odbc.so: cdr_odbc.o
  104. $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc $(MLFLAGS)
  105. cdr_tds.so: cdr_tds.o
  106. $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -ltds $(MLFLAGS)
  107. cdr_pgsql.so: cdr_pgsql.o
  108. $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lpq -lz $(MLFLAGS)
  109. cdr_sqlite.so: cdr_sqlite.o
  110. $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lsqlite $(MLFLAGS)
  111. depend: .depend
  112. .depend:
  113. ../build_tools/mkdep $(CFLAGS) `ls *.c`