Blame build/lib.mk

Packit 8f7830
#  FLAC - Free Lossless Audio Codec
Packit 8f7830
#  Copyright (C) 2001-2009  Josh Coalson
Packit 8f7830
#  Copyright (C) 2011-2016  Xiph.Org Foundation
Packit 8f7830
#
Packit 8f7830
#  This file is part the FLAC project.  FLAC is comprised of several
Packit 8f7830
#  components distributed under different licenses.  The codec libraries
Packit 8f7830
#  are distributed under Xiph.Org's BSD-like license (see the file
Packit 8f7830
#  COPYING.Xiph in this distribution).  All other programs, libraries, and
Packit 8f7830
#  plugins are distributed under the GPL (see COPYING.GPL).  The documentation
Packit 8f7830
#  is distributed under the Gnu FDL (see COPYING.FDL).  Each file in the
Packit 8f7830
#  FLAC distribution contains at the top the terms under which it may be
Packit 8f7830
#  distributed.
Packit 8f7830
#
Packit 8f7830
#  Since this particular file is relevant to all components of FLAC,
Packit 8f7830
#  it may be distributed under the Xiph.Org license, which is the least
Packit 8f7830
#  restrictive of those mentioned above.  See the file COPYING.Xiph in this
Packit 8f7830
#  distribution.
Packit 8f7830
Packit 8f7830
#
Packit 8f7830
# GNU makefile fragment for building a library
Packit 8f7830
#
Packit 8f7830
Packit 8f7830
include $(topdir)/build/config.mk
Packit 8f7830
Packit 8f7830
ifeq ($(OS),Darwin)
Packit 8f7830
    CC          = cc
Packit 8f7830
    CCC         = c++
Packit 8f7830
else
Packit 8f7830
ifeq ($(OS),FreeBSD)
Packit 8f7830
    CC          = cc
Packit 8f7830
    CCC         = c++
Packit 8f7830
else
Packit 8f7830
    CC          = gcc
Packit 8f7830
    CCC         = g++
Packit 8f7830
endif
Packit 8f7830
endif
Packit 8f7830
NASM        = nasm
Packit 8f7830
LINK        = ar cru
Packit 8f7830
OBJPATH     = $(topdir)/objs
Packit 8f7830
LIBPATH     = $(OBJPATH)/$(BUILD)/lib
Packit 8f7830
DEBUG_LIBPATH     = $(OBJPATH)/debug/lib
Packit 8f7830
RELEASE_LIBPATH   = $(OBJPATH)/release/lib
Packit 8f7830
ifeq ($(OS),Darwin)
Packit 8f7830
    STATIC_LIB_SUFFIX = a
Packit 8f7830
    DYNAMIC_LIB_SUFFIX = dylib
Packit 8f7830
else
Packit 8f7830
ifeq ($(findstring Windows,$(OS)),Windows)
Packit 8f7830
    STATIC_LIB_SUFFIX = a
Packit 8f7830
    DYNAMIC_LIB_SUFFIX = dll
Packit 8f7830
else
Packit 8f7830
    STATIC_LIB_SUFFIX = a
Packit 8f7830
    DYNAMIC_LIB_SUFFIX = so
Packit 8f7830
endif
Packit 8f7830
endif
Packit 8f7830
STATIC_LIB_NAME     = $(LIB_NAME).$(STATIC_LIB_SUFFIX)
Packit 8f7830
DYNAMIC_LIB_NAME    = $(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
Packit 8f7830
STATIC_LIB          = $(LIBPATH)/$(STATIC_LIB_NAME)
Packit 8f7830
DYNAMIC_LIB         = $(LIBPATH)/$(DYNAMIC_LIB_NAME)
Packit 8f7830
DEBUG_STATIC_LIB    = $(DEBUG_LIBPATH)/$(STATIC_LIB_NAME)
Packit 8f7830
DEBUG_DYNAMIC_LIB   = $(DEBUG_LIBPATH)/$(DYNAMIC_LIB_NAME)
Packit 8f7830
RELEASE_STATIC_LIB  = $(RELEASE_LIBPATH)/$(STATIC_LIB_NAME)
Packit 8f7830
RELEASE_DYNAMIC_LIB = $(RELEASE_LIBPATH)/$(DYNAMIC_LIB_NAME)
Packit 8f7830
ifeq ($(OS),Darwin)
Packit 8f7830
    LINKD       = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
Packit 8f7830
else
Packit 8f7830
    LINKD       = $(CC) -shared
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
BASE_CFLAGS = -Wall -Wextra $(CONFIG_CFLAGS) -DVERSION=$(VERSION) -DPACKAGE_VERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Packit 8f7830
Packit 8f7830
ifeq ($(DEFAULT_BUILD),debug)
Packit 8f7830
CFLAGS   := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
Packit 8f7830
CXXFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS)
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
ifeq ($(DEFAULT_BUILD),valgrind)
Packit 8f7830
CFLAGS   := -g -O0 -DDEBUG  -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
Packit 8f7830
CXXFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS)
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
ifeq ($(DEFAULT_BUILD),release)
Packit 8f7830
CFLAGS   := -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
Packit 8f7830
CXXFLAGS := -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS)
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
LFLAGS   = -L$(LIBPATH)
Packit 8f7830
Packit 8f7830
DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
Packit 8f7830
RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
Packit 8f7830
ifeq ($(PROC),x86_64)
Packit 8f7830
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)
Packit 8f7830
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)
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
debug   : $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
Packit 8f7830
valgrind: $(DEBUG_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
Packit 8f7830
release : $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB)
Packit 8f7830
Packit 8f7830
$(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
Packit 8f7830
	$(LINK) $@ $(DEBUG_OBJS) && ranlib $@
Packit 8f7830
Packit 8f7830
$(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
Packit 8f7830
	$(LINK) $@ $(RELEASE_OBJS) && ranlib $@
Packit 8f7830
Packit 8f7830
$(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS)
Packit 8f7830
ifeq ($(OS),Darwin)
Packit 8f7830
	echo Not building dynamic lib, command is: $(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc
Packit 8f7830
else
Packit 8f7830
ifeq ($(PROC),x86_64)
Packit 8f7830
	$(LINKD) -o $@ $(DEBUG_PIC_OBJS) $(LFLAGS) $(LIBS)
Packit 8f7830
else
Packit 8f7830
	$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
Packit 8f7830
endif
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
$(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS)
Packit 8f7830
ifeq ($(OS),Darwin)
Packit 8f7830
	echo Not building dynamic lib, command is: $(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc
Packit 8f7830
else
Packit 8f7830
ifeq ($(PROC),x86_64)
Packit 8f7830
	$(LINKD) -o $@ $(RELEASE_PIC_OBJS) $(LFLAGS) $(LIBS)
Packit 8f7830
else
Packit 8f7830
	$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
Packit 8f7830
endif
Packit 8f7830
endif
Packit 8f7830
Packit 8f7830
include $(topdir)/build/compile.mk
Packit 8f7830
Packit 8f7830
.PHONY : clean
Packit 8f7830
clean :
Packit 8f7830
	-rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME)
Packit 8f7830
Packit 8f7830
.PHONY : depend
Packit 8f7830
depend:
Packit 8f7830
	makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp