Makefile.unix 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #################### COMPILE OPTIONS #######################
  2. # Uncomment this for fixed-point build
  3. #FIXED_POINT=1
  4. # It is strongly recommended to uncomment one of these
  5. # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
  6. # USE_ALLOCA: Use alloca() for stack allocation
  7. # If none is defined, then the fallback is a non-threadsafe global array
  8. CFLAGS := -DUSE_ALLOCA $(CFLAGS)
  9. #CFLAGS := -DVAR_ARRAYS $(CFLAGS)
  10. # These options affect performance
  11. # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
  12. # inline: Don't use the 'inline' keyword (for ANSI C compilers)
  13. # restrict: Don't use the 'restrict' keyword (for pre-C99 compilers)
  14. #CFLAGS := -DHAVE_LRINTF $(CFLAGS)
  15. #CFLAGS := -Dinline= $(CFLAGS)
  16. CFLAGS := -Drestrict= $(CFLAGS)
  17. ###################### END OF OPTIONS ######################
  18. -include package_version
  19. include silk_sources.mk
  20. include celt_sources.mk
  21. include opus_sources.mk
  22. ifdef FIXED_POINT
  23. SILK_SOURCES += $(SILK_SOURCES_FIXED)
  24. else
  25. SILK_SOURCES += $(SILK_SOURCES_FLOAT)
  26. OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
  27. endif
  28. EXESUFFIX =
  29. LIBPREFIX = lib
  30. LIBSUFFIX = .a
  31. OBJSUFFIX = .o
  32. CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
  33. AR = $(TOOLCHAIN_PREFIX)ar
  34. RANLIB = $(TOOLCHAIN_PREFIX)ranlib
  35. CP = $(TOOLCHAIN_PREFIX)cp
  36. cppflags-from-defines = $(addprefix -D,$(1))
  37. cppflags-from-includes = $(addprefix -I,$(1))
  38. ldflags-from-ldlibdirs = $(addprefix -L,$(1))
  39. ldlibs-from-libs = $(addprefix -l,$(1))
  40. WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
  41. CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
  42. CINCLUDES = include silk celt
  43. ifdef FIXED_POINT
  44. CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
  45. CINCLUDES += silk/fixed
  46. else
  47. CINCLUDES += silk/float
  48. endif
  49. LIBS = m
  50. LDLIBDIRS = ./
  51. CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
  52. CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
  53. LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
  54. LDLIBS += $(call ldlibs-from-libs,$(LIBS))
  55. COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
  56. LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
  57. LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
  58. ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
  59. %$(OBJSUFFIX):%.c
  60. $(COMPILE.c.cmdline)
  61. %$(OBJSUFFIX):%.cpp
  62. $(COMPILE.cpp.cmdline)
  63. # Directives
  64. # Variable definitions
  65. LIB_NAME = opus
  66. TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
  67. SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
  68. OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
  69. OPUSDEMO_SRCS_C = src/opus_demo.c
  70. OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
  71. OPUSCOMPARE_SRCS_C = src/opus_compare.c
  72. OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
  73. # Rules
  74. all: lib opus_demo opus_compare
  75. lib: $(TARGET)
  76. $(TARGET): $(OBJS)
  77. $(ARCHIVE.cmdline)
  78. opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
  79. $(LINK.o.cmdline)
  80. opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
  81. $(LINK.o.cmdline)
  82. celt/celt.o: CFLAGS += -DPACKAGE_VERSION='$(PACKAGE_VERSION)'
  83. celt/celt.o: package_version
  84. package_version: force
  85. @if [ -x ./update_version ]; then \
  86. ./update_version || true; \
  87. elif [ ! -e ./package_version ]; then \
  88. echo 'PACKAGE_VERSION="unknown"' > ./package_version; \
  89. fi
  90. force:
  91. clean:
  92. rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) \
  93. $(OBJS) $(OPUSDEMO_OBJS) $(OPUSCOMPARE_OBJS)
  94. .PHONY: all lib clean