Makefile.draft 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # Copyright (c) 2011-2012 IETF Trust, Skype Limited, Jean-Marc Valin. All rights reserved.
  2. #
  3. # This file is extracted from RFC6716. Please see that RFC for additional
  4. # information.
  5. #
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions
  8. # are met:
  9. #
  10. # - Redistributions of source code must retain the above copyright
  11. # notice, this list of conditions and the following disclaimer.
  12. #
  13. # - Redistributions in binary form must reproduce the above copyright
  14. # notice, this list of conditions and the following disclaimer in the
  15. # documentation and/or other materials provided with the distribution.
  16. #
  17. # - Neither the name of Internet Society, IETF or IETF Trust, nor the
  18. # names of specific contributors, may be used to endorse or promote
  19. # products derived from this software without specific prior written
  20. # permission.
  21. #
  22. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
  26. # OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  27. # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  28. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  29. # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  30. # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  31. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. #################### COMPILE OPTIONS #######################
  34. # Uncomment this for fixed-point build
  35. #FIXED_POINT=1
  36. # It is strongly recommended to uncomment one of these
  37. # VAR_ARRAYS: Use C99 variable-length arrays for stack allocation
  38. # USE_ALLOCA: Use alloca() for stack allocation
  39. # If none is defined, then the fallback is a non-threadsafe global array
  40. CFLAGS := -DUSE_ALLOCA $(CFLAGS)
  41. #CFLAGS := -DVAR_ARRAYS $(CFLAGS)
  42. # These options affect performance
  43. # HAVE_LRINTF: Use C99 intrinsics to speed up float-to-int conversion
  44. # inline: Don't use the 'inline' keyword (for ANSI C compilers)
  45. # restrict: Don't use the 'restrict' keyword (for pre-C99 compilers)
  46. #CFLAGS := -DHAVE_LRINTF $(CFLAGS)
  47. #CFLAGS := -Dinline= $(CFLAGS)
  48. CFLAGS := -Drestrict= $(CFLAGS)
  49. ###################### END OF OPTIONS ######################
  50. CFLAGS += -DOPUS_VERSION='"1.0.0"'
  51. include silk_sources.mk
  52. include celt_sources.mk
  53. include opus_sources.mk
  54. ifdef FIXED_POINT
  55. SILK_SOURCES += $(SILK_SOURCES_FIXED)
  56. else
  57. SILK_SOURCES += $(SILK_SOURCES_FLOAT)
  58. endif
  59. EXESUFFIX =
  60. LIBPREFIX = lib
  61. LIBSUFFIX = .a
  62. OBJSUFFIX = .o
  63. CC = $(TOOLCHAIN_PREFIX)cc$(TOOLCHAIN_SUFFIX)
  64. AR = $(TOOLCHAIN_PREFIX)ar
  65. RANLIB = $(TOOLCHAIN_PREFIX)ranlib
  66. CP = $(TOOLCHAIN_PREFIX)cp
  67. cppflags-from-defines = $(addprefix -D,$(1))
  68. cppflags-from-includes = $(addprefix -I,$(1))
  69. ldflags-from-ldlibdirs = $(addprefix -L,$(1))
  70. ldlibs-from-libs = $(addprefix -l,$(1))
  71. WARNINGS = -Wall -W -Wstrict-prototypes -Wextra -Wcast-align -Wnested-externs -Wshadow
  72. CFLAGS += -O2 -g $(WARNINGS) -DOPUS_BUILD
  73. ifdef FIXED_POINT
  74. CFLAGS += -DFIXED_POINT=1 -DDISABLE_FLOAT_API
  75. endif
  76. CINCLUDES += include/ \
  77. silk/ \
  78. silk/float/ \
  79. silk/fixed/ \
  80. celt/ \
  81. src/
  82. # VPATH e.g. VPATH = src:../headers
  83. VPATH = ./ \
  84. silk/interface \
  85. silk/src_FIX \
  86. silk/src_FLP \
  87. silk/src_SigProc_FIX \
  88. silk/src_SigProc_FLP \
  89. test
  90. LIBS = m
  91. LDLIBDIRS = ./
  92. CFLAGS += $(call cppflags-from-defines,$(CDEFINES))
  93. CFLAGS += $(call cppflags-from-includes,$(CINCLUDES))
  94. LDFLAGS += $(call ldflags-from-ldlibdirs,$(LDLIBDIRS))
  95. LDLIBS += $(call ldlibs-from-libs,$(LIBS))
  96. COMPILE.c.cmdline = $(CC) -c $(CFLAGS) -o $@ $<
  97. LINK.o = $(CC) $(LDPREFLAGS) $(LDFLAGS)
  98. LINK.o.cmdline = $(LINK.o) $^ $(LDLIBS) -o $@$(EXESUFFIX)
  99. ARCHIVE.cmdline = $(AR) $(ARFLAGS) $@ $^ && $(RANLIB) $@
  100. %$(OBJSUFFIX):%.c
  101. $(COMPILE.c.cmdline)
  102. %$(OBJSUFFIX):%.cpp
  103. $(COMPILE.cpp.cmdline)
  104. # Directives
  105. # Variable definitions
  106. LIB_NAME = opus
  107. TARGET = $(LIBPREFIX)$(LIB_NAME)$(LIBSUFFIX)
  108. SRCS_C = $(SILK_SOURCES) $(CELT_SOURCES) $(OPUS_SOURCES)
  109. OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(SRCS_C))
  110. OPUSDEMO_SRCS_C = src/opus_demo.c
  111. OPUSDEMO_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSDEMO_SRCS_C))
  112. OPUSCOMPARE_SRCS_C = src/opus_compare.c
  113. OPUSCOMPARE_OBJS := $(patsubst %.c,%$(OBJSUFFIX),$(OPUSCOMPARE_SRCS_C))
  114. # Rules
  115. default: all
  116. all: $(TARGET) lib opus_demo opus_compare
  117. lib: $(TARGET)
  118. $(TARGET): $(OBJS)
  119. $(ARCHIVE.cmdline)
  120. opus_demo$(EXESUFFIX): $(OPUSDEMO_OBJS) $(TARGET)
  121. $(LINK.o.cmdline)
  122. opus_compare$(EXESUFFIX): $(OPUSCOMPARE_OBJS)
  123. $(LINK.o.cmdline)
  124. clean:
  125. rm -f opus_demo$(EXESUFFIX) opus_compare$(EXESUFFIX) $(TARGET) $(OBJS) $(OPUSDEMO_OBJS)