Fix building with MSYS and MinGW(-w64); Improve Makefile.lite build system
[platform/upstream/flac.git] / build / config.mk
1 #  FLAC - Free Lossless Audio Codec
2 #  Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009  Josh Coalson
3 #
4 #  This file is part the FLAC project.  FLAC is comprised of several
5 #  components distributed under difference licenses.  The codec libraries
6 #  are distributed under Xiph.Org's BSD-like license (see the file
7 #  COPYING.Xiph in this distribution).  All other programs, libraries, and
8 #  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
9 #  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
10 #  FLAC distribution contains at the top the terms under which it may be
11 #  distributed.
12 #
13 #  Since this particular file is relevant to all components of FLAC,
14 #  it may be distributed under the Xiph.Org license, which is the least
15 #  restrictive of those mentioned above.  See the file COPYING.Xiph in this
16 #  distribution.
17
18 #
19 # customizable settings from the make invocation
20 #
21
22 USE_OGG     ?= 1
23 USE_ICONV   ?= 1
24
25 #
26 # debug/release selection
27 #
28
29 DEFAULT_BUILD = release
30
31 # returns Linux, Darwin, FreeBSD, etc.
32 ifdef OS_OVERRIDE
33     OS := $(OS_OVERRIDE)
34 else
35     OS := $(shell uname -s)
36 endif
37 # returns i386, x86_64, powerpc, etc.
38 ifdef PROC_OVERRIDE
39     PROC := $(PROC_OVERRIDE)
40 else
41     ifeq ($(findstring MINGW,$(OS)),MINGW)
42         PROC := i386 # failsafe
43         # ifeq (mingw32,$(shell gcc -dumpmachine)) # MinGW (mainline): mingw32
44         ifeq ($(findstring i686,$(shell gcc -dumpmachine)),i686) # MinGW-w64: i686-w64-mingw32
45             USE_ICONV := 0
46         else ifeq ($(findstring x86_64,$(shell gcc -dumpmachine)),x86_64) # MinGW-w64: x86_64-w64-mingw32
47             USE_ICONV := 0
48             PROC := x86_64
49         endif
50     else
51         PROC := $(shell uname -p)
52     endif
53 endif
54 ifeq ($(PROC),powerpc)
55     PROC := ppc
56 endif
57
58 debug    : BUILD = debug
59 valgrind : BUILD = debug
60 release  : BUILD = release
61
62 # override LINKAGE on OS X until we figure out how to get 'cc -static' to work
63 ifeq ($(OS),Darwin)
64 LINKAGE = -arch $(PROC)
65 else
66 debug    : LINKAGE = -static
67 valgrind : LINKAGE = -dynamic
68 release  : LINKAGE = -static
69 endif
70
71 all default: $(DEFAULT_BUILD)
72
73 #
74 # GNU makefile fragment for emulating stuff normally done by configure
75 #
76
77 VERSION=\"1.2.1\"
78
79 CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
80
81 ifeq ($(OS),Darwin)
82     CONFIG_CFLAGS += -DFLAC__SYS_DARWIN -arch $(PROC)
83 else
84     CONFIG_CFLAGS += -DHAVE_SOCKLEN_T
85 endif
86
87 ifeq ($(PROC),ppc)
88     CONFIG_CFLAGS += -DWORDS_BIGENDIAN=1
89 else
90     CONFIG_CFLAGS += -DWORDS_BIGENDIAN=0
91 endif
92
93 ifneq (0,$(USE_ICONV))
94     CONFIG_CFLAGS += -DHAVE_ICONV
95     ICONV_LIBS = -liconv
96 else
97     ICONV_LIBS =
98 endif
99
100 ifneq (0,$(USE_OGG))
101     CONFIG_CFLAGS += -DFLAC__HAS_OGG=1
102     OGG_INCLUDES = -I$(OGG_INCLUDE_DIR)
103     OGG_EXPLICIT_LIBS = $(OGG_LIB_DIR)/libogg.a
104     OGG_LIBS = -L$(OGG_LIB_DIR) -logg
105     OGG_SRCS = $(OGG_SRCS_C)
106 else
107     CONFIG_CFLAGS += -DFLAC__HAS_OGG=0
108     OGG_INCLUDES =
109     OGG_EXPLICIT_LIBS =
110     OGG_LIBS =
111     OGG_SRCS =
112 endif
113
114 OGG_INCLUDE_DIR=$(HOME)/local/include
115 OGG_LIB_DIR=$(HOME)/local/lib