exe.mk 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # FLAC - Free Lossless Audio Codec
  2. # Copyright (C) 2001-2009 Josh Coalson
  3. # Copyright (C) 2011-2016 Xiph.Org Foundation
  4. #
  5. # This file is part the FLAC project. FLAC is comprised of several
  6. # components distributed under different licenses. The codec libraries
  7. # are distributed under Xiph.Org's BSD-like license (see the file
  8. # COPYING.Xiph in this distribution). All other programs, libraries, and
  9. # plugins are distributed under the GPL (see COPYING.GPL). The documentation
  10. # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the
  11. # FLAC distribution contains at the top the terms under which it may be
  12. # distributed.
  13. #
  14. # Since this particular file is relevant to all components of FLAC,
  15. # it may be distributed under the Xiph.Org license, which is the least
  16. # restrictive of those mentioned above. See the file COPYING.Xiph in this
  17. # distribution.
  18. #
  19. # GNU makefile fragment for building an executable
  20. #
  21. include $(topdir)/build/config.mk
  22. ifeq ($(OS),Darwin)
  23. CC = cc
  24. CCC = c++
  25. else
  26. ifeq ($(OS),FreeBSD)
  27. CC = cc
  28. CCC = c++
  29. else
  30. CC = gcc
  31. CCC = g++
  32. endif
  33. endif
  34. NASM = nasm
  35. LINK = $(CC) $(LINKAGE)
  36. OBJPATH = $(topdir)/objs
  37. BINPATH = $(OBJPATH)/$(BUILD)/bin
  38. LIBPATH = $(OBJPATH)/$(BUILD)/lib
  39. DEBUG_BINPATH = $(OBJPATH)/debug/bin
  40. DEBUG_LIBPATH = $(OBJPATH)/debug/lib
  41. RELEASE_BINPATH = $(OBJPATH)/release/bin
  42. RELEASE_LIBPATH = $(OBJPATH)/release/lib
  43. PROGRAM = $(BINPATH)/$(PROGRAM_NAME)
  44. DEBUG_PROGRAM = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
  45. RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
  46. BASE_CFLAGS = -Wall -Wextra $(CONFIG_CFLAGS) -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
  47. ifeq ($(DEFAULT_BUILD),debug)
  48. CFLAGS := -g -O0 -DDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
  49. CXXFLAGS := -g -O0 -DDEBUG $(CXXFLAGS) $(BASE_CFLAGS)
  50. endif
  51. ifeq ($(DEFAULT_BUILD),valgrind)
  52. CFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
  53. CXXFLAGS := -g -O0 -DDEBUG -DDEBUG -DFLAC__VALGRIND_TESTING $(CXXFLAGS) $(BASE_CFLAGS)
  54. endif
  55. ifeq ($(DEFAULT_BUILD),release)
  56. CFLAGS := -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DFLaC__INLINE=__inline__ -DNDEBUG $(CFLAGS) $(BASE_CFLAGS) -Wmissing-prototypes -Wstrict-prototypes
  57. CXXFLAGS := -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DFLaC__INLINE=__inline__ -DNDEBUG $(CXXFLAGS) $(BASE_CFLAGS)
  58. endif
  59. LFLAGS = -L$(LIBPATH)
  60. DEBUG_OBJS = $(SRCS_C:%.c=%.debug.o) $(SRCS_CC:%.cc=%.debug.o) $(SRCS_CPP:%.cpp=%.debug.o) $(SRCS_NASM:%.nasm=%.debug.o)
  61. RELEASE_OBJS = $(SRCS_C:%.c=%.release.o) $(SRCS_CC:%.cc=%.release.o) $(SRCS_CPP:%.cpp=%.release.o) $(SRCS_NASM:%.nasm=%.release.o)
  62. ifeq ($(PROC),x86_64)
  63. 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)
  64. 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)
  65. endif
  66. debug : $(DEBUG_PROGRAM)
  67. valgrind: $(DEBUG_PROGRAM)
  68. release : $(RELEASE_PROGRAM)
  69. # by default on OS X we link with static libs as much as possible
  70. $(DEBUG_PROGRAM) : $(DEBUG_OBJS) $(DEBUG_PIC_OBJS)
  71. ifeq ($(OS),Darwin)
  72. $(LINK) -o $@ $(DEBUG_OBJS) $(EXPLICIT_LIBS)
  73. else
  74. $(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
  75. endif
  76. $(RELEASE_PROGRAM) : $(RELEASE_OBJS) $(RELEASE_PIC_OBJS)
  77. ifeq ($(OS),Darwin)
  78. $(LINK) -o $@ $(RELEASE_OBJS) $(EXPLICIT_LIBS)
  79. else
  80. $(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
  81. endif
  82. include $(topdir)/build/compile.mk
  83. .PHONY : clean
  84. clean :
  85. -rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(DEBUG_PIC_OBJS) $(RELEASE_PIC_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME)
  86. .PHONY : depend
  87. depend:
  88. makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp