exe.mk 3.2 KB
Newer Older
1
#  FLAC - Free Lossless Audio Codec
Josh Coalson's avatar
Josh Coalson committed
2
#  Copyright (C) 2001,2002,2003,2004  Josh Coalson
3
#
Josh Coalson's avatar
Josh Coalson committed
4
5
6
7
8
9
10
11
#  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.
12
#
Josh Coalson's avatar
Josh Coalson committed
13
14
15
16
#  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.
17

Josh Coalson's avatar
Josh Coalson committed
18
19
20
21
#
# GNU makefile fragment for building an executable
#

22
23
include $(topdir)/build/config.mk

Josh Coalson's avatar
Josh Coalson committed
24
25
ifeq ($(DARWIN_BUILD),yes)
CC          = cc
26
CCC         = c++
Josh Coalson's avatar
Josh Coalson committed
27
else
Josh Coalson's avatar
Josh Coalson committed
28
CC          = gcc
29
CCC         = g++
Josh Coalson's avatar
Josh Coalson committed
30
endif
Josh Coalson's avatar
Josh Coalson committed
31
NASM        = nasm
Josh Coalson's avatar
Josh Coalson committed
32
# override to -dynamic on OSX
Josh Coalson's avatar
Josh Coalson committed
33
34
35
36
ifeq ($(DARWIN_BUILD),yes)
LINKAGE     = -dynamic
endif
LINK        = $(CC) $(LINKAGE)
37
38
39
40
41
42
43
44
45
46
OBJPATH     = $(topdir)/obj
BINPATH     = $(OBJPATH)/$(BUILD)/bin
LIBPATH     = $(OBJPATH)/$(BUILD)/lib
DEBUG_BINPATH   = $(OBJPATH)/debug/bin
DEBUG_LIBPATH   = $(OBJPATH)/debug/lib
RELEASE_BINPATH = $(OBJPATH)/release/bin
RELEASE_LIBPATH = $(OBJPATH)/release/lib
PROGRAM         = $(BINPATH)/$(PROGRAM_NAME)
DEBUG_PROGRAM   = $(DEBUG_BINPATH)/$(PROGRAM_NAME)
RELEASE_PROGRAM = $(RELEASE_BINPATH)/$(PROGRAM_NAME)
47

48
49
50
debug   : CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
valgrind: CFLAGS = -g -O0 -DDEBUG $(CONFIG_CFLAGS) $(DEBUG_CFLAGS) -DFLAC__VALGRIND_TESTING -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(CONFIG_CFLAGS) $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
Josh Coalson's avatar
Josh Coalson committed
51
52
53

LFLAGS  = -L$(LIBPATH)

54
55
56
57
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)

debug   : $(ORDINALS_H) $(DEBUG_PROGRAM)
Josh Coalson's avatar
Josh Coalson committed
58
valgrind: $(ORDINALS_H) $(DEBUG_PROGRAM)
59
60
61
62
release : $(ORDINALS_H) $(RELEASE_PROGRAM)

$(DEBUG_PROGRAM) : $(DEBUG_OBJS)
	$(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
Josh Coalson's avatar
Josh Coalson committed
63

64
65
$(RELEASE_PROGRAM) : $(RELEASE_OBJS)
	$(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
Josh Coalson's avatar
Josh Coalson committed
66

67
%.debug.o %.release.o : %.c
Josh Coalson's avatar
Josh Coalson committed
68
	$(CC) $(CFLAGS) -c $< -o $@
69
%.debug.o %.release.o : %.cc
70
	$(CCC) $(CFLAGS) -c $< -o $@
71
%.debug.o %.release.o : %.cpp
Josh Coalson's avatar
Josh Coalson committed
72
	$(CCC) $(CFLAGS) -c $< -o $@
73
%.debug.i %.release.i : %.c
Josh Coalson's avatar
Josh Coalson committed
74
	$(CC) $(CFLAGS) -E $< -o $@
75
%.debug.i %.release.i : %.cc
76
	$(CCC) $(CFLAGS) -E $< -o $@
77
%.debug.i %.release.i : %.cpp
Josh Coalson's avatar
Josh Coalson committed
78
	$(CCC) $(CFLAGS) -E $< -o $@
Josh Coalson's avatar
Josh Coalson committed
79

80
%.debug.o %.release.o : %.nasm
Josh Coalson's avatar
Josh Coalson committed
81
	$(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
Josh Coalson's avatar
Josh Coalson committed
82

Josh Coalson's avatar
Josh Coalson committed
83
84
.PHONY : clean
clean :
Josh Coalson's avatar
Josh Coalson committed
85
	-rm -f $(DEBUG_OBJS) $(RELEASE_OBJS) $(OBJPATH)/*/bin/$(PROGRAM_NAME)
Josh Coalson's avatar
Josh Coalson committed
86
87
88

.PHONY : depend
depend:
Josh Coalson's avatar
Josh Coalson committed
89
	makedepend -fMakefile.lite -- $(CFLAGS) $(INCLUDES) -- *.c *.cc *.cpp