config.mk 3.88 KB
Newer Older
1
#  FLAC - Free Lossless Audio Codec
2
#  Copyright (C) 2001-2009  Josh Coalson
3
#  Copyright (C) 2011-2016  Xiph.Org Foundation
4
#
Josh Coalson's avatar
Josh Coalson committed
5
#  This file is part the FLAC project.  FLAC is comprised of several
6
#  components distributed under different licenses.  The codec libraries
Josh Coalson's avatar
Josh Coalson committed
7 8 9 10 11 12
#  are distributed under Xiph.Org's BSD-like license (see the file
#  COPYING.Xiph in this distribution).  All other programs, libraries, and
#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
#  FLAC distribution contains at the top the terms under which it may be
#  distributed.
13
#
Josh Coalson's avatar
Josh Coalson committed
14 15 16 17
#  Since this particular file is relevant to all components of FLAC,
#  it may be distributed under the Xiph.Org license, which is the least
#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
#  distribution.
18

19 20 21 22 23 24
#
# customizable settings from the make invocation
#

USE_OGG     ?= 1
USE_ICONV   ?= 1
25 26
USE_LROUND  ?= 1
USE_FSEEKO  ?= 1
27
USE_LANGINFO_CODESET ?= 1
28

29 30 31 32 33 34
#
# debug/release selection
#

DEFAULT_BUILD = release

35 36
F_PIC := -fPIC

37
# returns Linux, Darwin, FreeBSD, etc.
38
ifndef OS
39 40 41
    OS := $(shell uname -s)
endif
# returns i386, x86_64, powerpc, etc.
42 43
ifndef PROC
    ifeq ($(findstring Windows,$(OS)),Windows)
44
        PROC := i386 # failsafe
45 46
        # ifeq ($(findstring i686,$(shell gcc -dumpmachine)),i686) # MinGW-w64: i686-w64-mingw32
        ifeq ($(findstring x86_64,$(shell gcc -dumpmachine)),x86_64) # MinGW-w64: x86_64-w64-mingw32
47 48 49
            PROC := x86_64
        endif
    else
50 51 52 53 54
        ifeq ($(shell uname -p),amd64)
            PROC := x86_64
        else
            PROC := $(shell uname -p)
        endif
55 56 57 58 59
    endif
endif
ifeq ($(PROC),powerpc)
    PROC := ppc
endif
60 61 62 63 64 65
# x64_64 Mac OS outputs 'i386' in uname -p; use uname -m instead
ifeq ($(PROC),i386)
    ifeq ($(OS),Darwin)
        PROC := $(shell uname -m)
    endif
endif
66

67 68 69 70 71
ifeq ($(OS),Linux)
    PROC := $(shell uname -m)
    USE_ICONV := 0
endif

Erik de Castro Lopo's avatar
Erik de Castro Lopo committed
72 73 74 75 76 77 78 79 80
ifeq ($(findstring Windows,$(OS)),Windows)
    F_PIC :=
    USE_ICONV := 0
    USE_LANGINFO_CODESET := 0
    ifeq (mingw32,$(shell gcc -dumpmachine)) # MinGW (mainline): mingw32
        USE_FSEEKO := 0
    endif
endif

Josh Coalson's avatar
Josh Coalson committed
81 82 83 84
debug    : BUILD = debug
valgrind : BUILD = debug
release  : BUILD = release

85
# override LINKAGE on OS X until we figure out how to get 'cc -static' to work
86
ifeq ($(OS),Darwin)
87
LINKAGE = -arch $(PROC)
88
else
Josh Coalson's avatar
Josh Coalson committed
89 90 91
debug    : LINKAGE = -static
valgrind : LINKAGE = -dynamic
release  : LINKAGE = -static
92
endif
93 94 95

all default: $(DEFAULT_BUILD)

96 97 98 99
#
# GNU makefile fragment for emulating stuff normally done by configure
#

Erik de Castro Lopo's avatar
Erik de Castro Lopo committed
100
VERSION=\"1.3.2\"
101

102
CONFIG_CFLAGS=$(CUSTOM_CFLAGS) -DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_CXX_VARARRAYS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
103

104
ifeq ($(OS),Darwin)
105
    CONFIG_CFLAGS += -DFLAC__SYS_DARWIN -DHAVE_SYS_PARAM_H -arch $(PROC)
106 107 108 109 110
else
    CONFIG_CFLAGS += -DHAVE_SOCKLEN_T
endif

ifeq ($(PROC),ppc)
111
    CONFIG_CFLAGS += -DWORDS_BIGENDIAN=1 -DCPU_IS_LITTLE_ENDIAN=0
112
else
113
    CONFIG_CFLAGS += -DWORDS_BIGENDIAN=0 -DCPU_IS_LITTLE_ENDIAN=1
114 115
endif

116 117 118 119 120
ifeq ($(OS),Linux)
	ifeq ($(PROC),x86_64)
        CONFIG_CFLAGS += -fPIC
	endif
endif
121 122 123
ifeq ($(OS),FreeBSD)
    CONFIG_CFLAGS += -DHAVE_SYS_PARAM_H
endif
124

125 126 127 128 129 130 131 132 133 134 135 136 137
ifneq (0,$(USE_ICONV))
    CONFIG_CFLAGS += -DHAVE_ICONV
    ICONV_LIBS = -liconv
else
    ICONV_LIBS =
endif

ifneq (0,$(USE_OGG))
    CONFIG_CFLAGS += -DFLAC__HAS_OGG=1
    OGG_INCLUDES = -I$(OGG_INCLUDE_DIR)
    OGG_EXPLICIT_LIBS = $(OGG_LIB_DIR)/libogg.a
    OGG_LIBS = -L$(OGG_LIB_DIR) -logg
    OGG_SRCS = $(OGG_SRCS_C)
Josh Coalson's avatar
Josh Coalson committed
138
else
139 140 141 142 143
    CONFIG_CFLAGS += -DFLAC__HAS_OGG=0
    OGG_INCLUDES =
    OGG_EXPLICIT_LIBS =
    OGG_LIBS =
    OGG_SRCS =
Josh Coalson's avatar
Josh Coalson committed
144
endif
145

Josh Coalson's avatar
Josh Coalson committed
146 147
OGG_INCLUDE_DIR=$(HOME)/local/include
OGG_LIB_DIR=$(HOME)/local/lib
148 149 150 151 152 153 154 155

ifneq (0,$(USE_LROUND))
    CONFIG_CFLAGS += -DHAVE_LROUND
endif

ifneq (0,$(USE_FSEEKO))
    CONFIG_CFLAGS += -DHAVE_FSEEKO
endif
156 157 158 159

ifneq (0,$(USE_LANGINFO_CODESET))
    CONFIG_CFLAGS += -DHAVE_LANGINFO_CODESET
endif