# FLAC - Free Lossless Audio Codec
-# Copyright (C) 2001 Josh Coalson
+# Copyright (C) 2001,2002,2003,2004,2005,2006,2007,2008,2009 Josh Coalson
#
-# This program is part of FLAC; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+# This file is part the FLAC project. FLAC is comprised of several
+# components distributed under difference licenses. The codec libraries
+# 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.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# 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.
+
+#
+# customizable settings from the make invocation
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+USE_OGG ?= 1
+USE_ICONV ?= 1
+
+#
+# debug/release selection
+#
+
+DEFAULT_BUILD = release
+
+# returns Linux, Darwin, FreeBSD, etc.
+ifdef OS_OVERRIDE
+ OS := $(OS_OVERRIDE)
+else
+ OS := $(shell uname -s)
+endif
+# returns i386, x86_64, powerpc, etc.
+ifdef PROC_OVERRIDE
+ PROC := $(PROC_OVERRIDE)
+else
+ ifeq ($(findstring MINGW,$(OS)),MINGW)
+ PROC := i386 # failsafe
+ # ifeq (mingw32,$(shell gcc -dumpmachine)) # MinGW (mainline): mingw32
+ ifeq ($(findstring i686,$(shell gcc -dumpmachine)),i686) # MinGW-w64: i686-w64-mingw32
+ USE_ICONV := 0
+ else ifeq ($(findstring x86_64,$(shell gcc -dumpmachine)),x86_64) # MinGW-w64: x86_64-w64-mingw32
+ USE_ICONV := 0
+ PROC := x86_64
+ endif
+ else
+ PROC := $(shell uname -p)
+ endif
+endif
+ifeq ($(PROC),powerpc)
+ PROC := ppc
+endif
+
+ifeq ($(OS),Linux)
+ PROC := $(shell uname -m)
+ USE_ICONV := 0
+endif
+
+debug : BUILD = debug
+valgrind : BUILD = debug
+release : BUILD = release
+
+# override LINKAGE on OS X until we figure out how to get 'cc -static' to work
+ifeq ($(OS),Darwin)
+LINKAGE = -arch $(PROC)
+else
+debug : LINKAGE = -static
+valgrind : LINKAGE = -dynamic
+release : LINKAGE = -static
+endif
+
+all default: $(DEFAULT_BUILD)
#
# GNU makefile fragment for emulating stuff normally done by configure
#
-VERSION=\"1.0devel\"
+VERSION=\"1.2.1\"
+
+CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_INTTYPES_H -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+
+ifeq ($(OS),Darwin)
+ CONFIG_CFLAGS += -DFLAC__SYS_DARWIN -arch $(PROC)
+else
+ CONFIG_CFLAGS += -DHAVE_SOCKLEN_T
+endif
+
+ifeq ($(PROC),ppc)
+ CONFIG_CFLAGS += -DWORDS_BIGENDIAN=1
+else
+ CONFIG_CFLAGS += -DWORDS_BIGENDIAN=0
+endif
+
+ifeq ($(OS),Linux)
+ ifeq ($(PROC),x86_64)
+ CONFIG_CFLAGS += -fPIC
+ endif
+endif
+
+ifneq (0,$(USE_ICONV))
+ CONFIG_CFLAGS += -DHAVE_ICONV
+ ICONV_LIBS = -liconv
+else
+ ICONV_LIBS =
+endif
-ORDINALS_H = ../../include/FLAC/ordinals.h
+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)
+else
+ CONFIG_CFLAGS += -DFLAC__HAS_OGG=0
+ OGG_INCLUDES =
+ OGG_EXPLICIT_LIBS =
+ OGG_LIBS =
+ OGG_SRCS =
+endif
-$(ORDINALS_H): $(ORDINALS_H).in
- sed \
- -e 's/@FLaC__SIZE16@/short/g' \
- -e 's/@FLaC__SIZE32@/int/g' \
- -e 's/@FLaC__SIZE64@/long long/g' \
- -e 's/@FLaC__USIZE16@/unsigned short/g' \
- -e 's/@FLaC__USIZE32@/unsigned int/g' \
- -e 's/@FLaC__USIZE64@/unsigned long long/g' \
- $< > $@
+OGG_INCLUDE_DIR=$(HOME)/local/include
+OGG_LIB_DIR=$(HOME)/local/lib