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