summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
authorHendricks266 <Hendricks266@gmail.com>2012-12-29 04:22:59 -0600
committerErik de Castro Lopo <erikd@mega-nerd.com>2013-01-02 21:35:47 +1100
commit96d081c1c9b96743631f3a90d4798150ead43d47 (patch)
tree9a5f9a46f2826352fe2577301ec690d429fc8f3c /build
parent0da96d3cfd13931439324785ca1b89bb788a4a49 (diff)
downloadflac-96d081c1c9b96743631f3a90d4798150ead43d47.tar.gz
Fix building with MSYS and MinGW(-w64); Improve Makefile.lite build system
This is a patch to allow building of the project using MSYS, MinGW, and MinGW-w64 with the following invocation: make -f Makefile.lite libFLAC libFLAC++ flac metaflac test_libs_common test_libFLAC test_libFLAC++ test_grabbag test_seeking test_streams utils examples This patch addresses eight points: 1. `uname -p` in MSYS returns "unknown" so we must use `gcc -dumpmachine` to gain information about the target, 32-bit or 64-bit. 2. MinGW-w64 does not ship with a working iconv.h, so we must disable it under this specific compiler. 3. The code requires <inttypes.h> in a handful of C files, but config.mk did not contain -DHAVE_INTTYPES_H, which under the full build process (I assume) is added by autoconf. 4. The compiler complained when lround() in lpc.c was static, so it is no longer static. 5. Additional scattered linking directives (and reordering) (particularly FLAC, grabbag, and replaygain_analysis) were necessary to build some of the components. 6. The Makefile.lite build system benefited from some cleanup, particularly by rigorously defining all entries, factoring redundancy, and establishing dependencies. (Some typos were fixed too.) 7. Shared objects on Windows use .dll, not .so. (Added *.dll, *.dylib, and *.exe to .gitignore.) 8. To allow more freedom using Makefile.lite without configure, I added the variables USE_OGG and USE_ICONV which can toggle these two components in the build process. ex: make -f Makefile.lite examples USE_OGG=0 USE_ICONV=0 These improvements make use of some use-time Makefile variable expansion. Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Diffstat (limited to 'build')
-rw-r--r--build/compile.mk8
-rw-r--r--build/config.mk70
-rw-r--r--build/exe.mk8
-rw-r--r--build/lib.mk23
4 files changed, 85 insertions, 24 deletions
diff --git a/build/compile.mk b/build/compile.mk
index a22dd637..42c84f25 100644
--- a/build/compile.mk
+++ b/build/compile.mk
@@ -40,15 +40,15 @@
%.debug.o %.release.o : %.s
ifeq ($(OS),Darwin)
- #$(CC) -c -arch ppc -Wall -force_cpusubtype_ALL $< -o $@
- $(AS) -arch ppc -force_cpusubtype_ALL $< -o $@
+ #$(CC) -c -arch $(PROC) -Wall -force_cpusubtype_ALL $< -o $@
+ $(AS) -arch $(PROC) -force_cpusubtype_ALL $< -o $@
else
$(AS) $< -o $@
endif
%.debug.pic.o %.release.pic.o : %.s
ifeq ($(OS),Darwin)
- #$(CC) -c -arch ppc -Wall -force_cpusubtype_ALL $< -o $@
- $(AS) -arch ppc -force_cpusubtype_ALL $< -o $@
+ #$(CC) -c -arch $(PROC) -Wall -force_cpusubtype_ALL $< -o $@
+ $(AS) -arch $(PROC) -force_cpusubtype_ALL $< -o $@
else
$(AS) $< -o $@
endif
diff --git a/build/config.mk b/build/config.mk
index 3bd6637e..76cdc514 100644
--- a/build/config.mk
+++ b/build/config.mk
@@ -16,15 +16,44 @@
# distribution.
#
+# customizable settings from the make invocation
+#
+
+USE_OGG ?= 1
+USE_ICONV ?= 1
+
+#
# debug/release selection
#
DEFAULT_BUILD = release
-# returns i386, x86_64, powerpc, etc.
-PROC := $(shell uname -p)
# returns Linux, Darwin, FreeBSD, etc.
-OS := $(shell uname -s)
+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
debug : BUILD = debug
valgrind : BUILD = debug
@@ -32,7 +61,7 @@ release : BUILD = release
# override LINKAGE on OS X until we figure out how to get 'cc -static' to work
ifeq ($(OS),Darwin)
-LINKAGE =
+LINKAGE = -arch $(PROC)
else
debug : LINKAGE = -static
valgrind : LINKAGE = -dynamic
@@ -47,10 +76,39 @@ all default: $(DEFAULT_BUILD)
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=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DFLAC__SYS_DARWIN -DWORDS_BIGENDIAN
+ 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
+
+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)
else
-CONFIG_CFLAGS=-DHAVE_STDINT_H -DHAVE_ICONV -DHAVE_CXX_VARARRAYS -DHAVE_LANGINFO_CODESET -DHAVE_SOCKLEN_T -DFLAC__HAS_OGG -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
+ CONFIG_CFLAGS += -DFLAC__HAS_OGG=0
+ OGG_INCLUDES =
+ OGG_EXPLICIT_LIBS =
+ OGG_LIBS =
+ OGG_SRCS =
endif
OGG_INCLUDE_DIR=$(HOME)/local/include
diff --git a/build/exe.mk b/build/exe.mk
index 938dee43..b283d1a7 100644
--- a/build/exe.mk
+++ b/build/exe.mk
@@ -22,11 +22,11 @@
include $(topdir)/build/config.mk
ifeq ($(OS),Darwin)
-CC = cc
-CCC = c++
+ CC = cc
+ CCC = c++
else
-CC = gcc
-CCC = g++
+ CC = gcc
+ CCC = g++
endif
NASM = nasm
LINK = $(CC) $(LINKAGE)
diff --git a/build/lib.mk b/build/lib.mk
index 32f9a220..cce311eb 100644
--- a/build/lib.mk
+++ b/build/lib.mk
@@ -22,11 +22,11 @@
include $(topdir)/build/config.mk
ifeq ($(OS),Darwin)
-CC = cc
-CCC = c++
+ CC = cc
+ CCC = c++
else
-CC = gcc
-CCC = g++
+ CC = gcc
+ CCC = g++
endif
AS = as
NASM = nasm
@@ -36,11 +36,14 @@ LIBPATH = $(OBJPATH)/$(BUILD)/lib
DEBUG_LIBPATH = $(OBJPATH)/debug/lib
RELEASE_LIBPATH = $(OBJPATH)/release/lib
ifeq ($(OS),Darwin)
-STATIC_LIB_SUFFIX = a
-DYNAMIC_LIB_SUFFIX = dylib
+ STATIC_LIB_SUFFIX = a
+ DYNAMIC_LIB_SUFFIX = dylib
+else ifeq ($(findstring MINGW,$(OS)),MINGW)
+ STATIC_LIB_SUFFIX = a
+ DYNAMIC_LIB_SUFFIX = dll
else
-STATIC_LIB_SUFFIX = a
-DYNAMIC_LIB_SUFFIX = so
+ STATIC_LIB_SUFFIX = a
+ DYNAMIC_LIB_SUFFIX = so
endif
STATIC_LIB_NAME = $(LIB_NAME).$(STATIC_LIB_SUFFIX)
DYNAMIC_LIB_NAME = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
@@ -51,9 +54,9 @@ DEBUG_DYNAMIC_LIB = $(DEBUG_LIBPATH)/$(DYNAMIC_LIB_NAME)
RELEASE_STATIC_LIB = $(RELEASE_LIBPATH)/$(STATIC_LIB_NAME)
RELEASE_DYNAMIC_LIB = $(RELEASE_LIBPATH)/$(DYNAMIC_LIB_NAME)
ifeq ($(OS),Darwin)
-LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
+ LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
else
-LINKD = $(CC) -shared
+ LINKD = $(CC) -shared
endif
debug : CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -W -Wall -Wmissing-prototypes -Wstrict-prototypes -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)