Makefile.unix 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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 version.mk
  19. CFLAGS += -DOPUS_VERSION='$(OPUS_VERSION)'
  20. include silk_sources.mk
  21. include celt_sources.mk
  22. include opus_sources.mk
  23. ifdef FIXED_POINT
  24. SILK_SOURCES += $(SILK_SOURCES_FIXED)
  25. else
  26. SILK_SOURCES += $(SILK_SOURCES_FLOAT)
  27. OPUS_SOURCES += $(OPUS_SOURCES_FLOAT)
  28. endif
  29. EXESUFFIX =
  30. LIBPREFIX = lib
  31. LIBSUFFIX = .a
  32. OBJSUFFIX = .o
  33. CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
  34. AR = $(TOOLCHAIN_PREFIX)ar
  35. RANLIB = $(TOOLCHAIN_PREFIX)ranlib
  36. CP = $(TOOLCHAIN_PREFIX)cp
  37. cppflags-from-defines = $(addprefix -D,$(1))
  38. cppflags-from-includes = $(addprefix -I,$(1))
  39. ldflags-from-ldlibdirs = $(addprefix -L,$(1))
  40. ldlibs-from-libs = $(addprefix -l,$(1))
  41. WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
  42. CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
  43. ifdef FIXED_POINT
  44. CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
  45. endif
  46. CINCLUDES += include/ \
  47. silk/ \
  48. silk/float/ \
  49. silk/fixed/ \
  50. celt/ \
  51. src/
  52. # VPATH e.g. VPATH = src:../headers
  53. VPATH = ./ \
  54. silk/interface \
  55. silk/src_FIX \
  56. silk/src_FLP \
  57. silk/src_SigProc_FIX \
  58. silk/src_SigProc_FLP \
  59. test
  60. LIBS = m
  61. LDLIBDIRS = ./
  62. CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
  63. CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
  64. LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
  65. LDLIBS += $(call ldlibs-from-libs,$(LIBS))
  66. COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
  67. LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
  68. LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
  69. ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
  70. %$(OBJSUFFIX):%.c
  71. $(COMPILE.c.cmdline)
  72. %$(OBJSUFFIX):%.cpp
  73. $(COMPILE.cpp.cmdline)
  74. # Directives
  75. # Variable definitions
  76. LIB_NAME = opus
  77. TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
  78. SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
  79. OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
  80. OPUSDEMO_SRCS_C = src/opus_demo.c
  81. OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
  82. OPUSCOMPARE_SRCS_C = src/opus_compare.c
  83. OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
  84. # Rules
  85. default: all
  86. all: $(TARGET) lib opus_demo opus_compare
  87. lib: $(TARGET)
  88. $(TARGET): $(OBJS)
  89. $(ARCHIVE.cmdline)
  90. opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
  91. $(LINK.o.cmdline)
  92. opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
  93. $(LINK.o.cmdline)
  94. clean:
  95. rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) $(OBJS) $(OPUSDEMO_OBJS)