flac/build/lib.mk
NotTsunami 1640e10e43 lib.mk: Remove incorrect u flag from ar
We work in deterministic mode by default, so timestamps are zeroed,
thus it is impossible to check timestamps and insert only newer
members. Silences the following autotools warning:

ar: `u' modifier ignored since `D' is the default (see `U')

https://sourceware.org/binutils/docs/binutils/ar-cmdline.html
2019-11-20 14:04:42 +11:00

139 lines
4.9 KiB
Makefile

# FLAC - Free Lossless Audio Codec
# Copyright (C) 2001-2009 Josh Coalson
# Copyright (C) 2011-2016 Xiph.Org Foundation
#
# This file is part the FLAC project. FLAC is comprised of several
# components distributed under different 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.
#
# 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.
#
# GNU makefile fragment for building a library
#
include $(topdir)/build/config.mk
ifeq ($(OS),Darwin)
CC = cc
CCC = c++
else
ifeq ($(OS),FreeBSD)
CC = cc
CCC = c++
else
CC = gcc
CCC = g++
endif
endif
ifeq ($(CC),gcc)
GCC_INLINE = -finline-functions
endif
NASM = nasm
LINK = ar cr
OBJPATH = $(topdir)/objs
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
else
ifeq ($(findstring Windows,$(OS)),Windows)
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = dll
else
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = so
endif
endif
STATIC_LIB_NAME = $(LIB_NAME).$(STATIC_LIB_SUFFIX)
DYNAMIC_LIB_NAME = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
STATIC_LIB = $(LIBPATH)/$(STATIC_LIB_NAME)
DYNAMIC_LIB = $(LIBPATH)/$(DYNAMIC_LIB_NAME)
DEBUG_STATIC_LIB = $(DEBUG_LIBPATH)/$(STATIC_LIB_NAME)
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)
else
LINKD = $(CC) -shared
endif
BASE_CFLAGS = -Wall -Wextra $(CONFIG_CFLAGS) -DVERSION=$(VERSION) -DPACKAGE_VERSION=$(VERSION) $(DEFINES) $(INCLUDES)
ifeq ($(DEFAULT_BUILD),debug)
CFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS)
endif
ifeq ($(DEFAULT_BUILD),valgrind)
CFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS)
endif
ifeq ($(DEFAULT_BUILD),release)
CFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
CXXFLAGS := -O3 -fomit-frame-pointer -funroll-loops $(GCC_INLINE) -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS)
endif
LFLAGS = -L$(LIBPATH)
DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
ifeq ($(PROC),x86_64)
DEBUG_PIC_OBJS = $(SRCS_C:%.c=%.debug.pic.o) $(SRCS_CC:%.cc=%.debug.pic.o) $(SRCS_CPP:%.cpp=%.debug.pic.o) $(SRCS_NASM:%.nasm=%.debug.pic.o)
RELEASE_PIC_OBJS = $(SRCS_C:%.c=%.release.pic.o) $(SRCS_CC:%.cc=%.release.pic.o) $(SRCS_CPP:%.cpp=%.release.pic.o) $(SRCS_NASM:%.nasm=%.release.pic.o)
endif
debug : $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
valgrind: $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
release : $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB)
$(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
$(LINK) $@ $(DEBUG_OBJS) && ranlib $@
$(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
$(LINK) $@ $(RELEASE_OBJS) && ranlib $@
$(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS)
ifeq ($(OS),Darwin)
echo Not building dynamic lib, command is: $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc
else
ifeq ($(PROC),x86_64)
$(LINKD) -o $@ $(DEBUG_PIC_OBJS) $(LFLAGS) $(LIBS)
else
$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
endif
endif
$(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS)
ifeq ($(OS),Darwin)
echo Not building dynamic lib, command is: $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc
else
ifeq ($(PROC),x86_64)
$(LINKD) -o $@ $(RELEASE_PIC_OBJS) $(LFLAGS) $(LIBS)
else
$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
endif
endif
include $(topdir)/build/compile.mk
.PHONY : clean
clean :
-rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME)
.PHONY : depend
depend:
makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp