Commit b74fc98b authored by Josh Coalson's avatar Josh Coalson
Browse files

revamp Makefile.lite system, use separate dirs and names for debug and release...

revamp Makefile.lite system, use separate dirs and names for debug and release targets and object files
parent 6c53ffea
......@@ -15,6 +15,17 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# debug/release selection
#
DEFAULT_BUILD = release
debug : BUILD = debug
release : BUILD = release
all default: $(DEFAULT_BUILD)
#
# GNU makefile fragment for emulating stuff normally done by configure
#
......
......@@ -19,6 +19,8 @@
# GNU makefile fragment for building an executable
#
include $(topdir)/build/config.mk
ifeq ($(DARWIN_BUILD),yes)
CC = cc
CCC = c++
......@@ -34,44 +36,55 @@ else
LINKAGE = -static
endif
LINK = $(CC) $(LINKAGE)
BINPATH = $(topdir)/obj/bin
LIBPATH = $(topdir)/obj/lib
PROGRAM = $(BINPATH)/$(PROGRAM_NAME)
all : release
include $(topdir)/build/config.mk
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)
debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
LFLAGS = -L$(LIBPATH)
debug : $(ORDINALS_H) $(PROGRAM)
release : $(ORDINALS_H) $(PROGRAM)
#@@@ OBJS = $(SRCS_C:%.c=%.o) $(SRCS_CC:%.cc=%.o) $(SRCS_CPP:%.cpp=%.o) $(SRCS_NASM:%.nasm=%.o)
#@@@ OBJS = $(SRCS_C:%.c=%.$(BUILD).o) $(SRCS_CC:%.cc=%.$(BUILD).o) $(SRCS_CPP:%.cpp=%.$(BUILD).o) $(SRCS_NASM:%.nasm=%.$(BUILD).o)
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)
release : $(ORDINALS_H) $(RELEASE_PROGRAM)
$(DEBUG_PROGRAM) : $(DEBUG_OBJS)
$(LINK) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
$(PROGRAM) : $(OBJS)
$(LINK) -o $@ $(OBJS) $(LFLAGS) $(LIBS)
$(RELEASE_PROGRAM) : $(RELEASE_OBJS)
$(LINK) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
%.o : %.c
%.debug.o %.release.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o : %.cc
%.debug.o %.release.o : %.cc
$(CCC) $(CFLAGS) -c $< -o $@
%.o : %.cpp
%.debug.o %.release.o : %.cpp
$(CCC) $(CFLAGS) -c $< -o $@
%.i : %.c
%.debug.i %.release.i : %.c
$(CC) $(CFLAGS) -E $< -o $@
%.i : %.cc
%.debug.i %.release.i : %.cc
$(CCC) $(CFLAGS) -E $< -o $@
%.i : %.cpp
%.debug.i %.release.i : %.cpp
$(CCC) $(CFLAGS) -E $< -o $@
%.o : %.nasm
%.debug.o %.release.o : %.nasm
$(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
.PHONY : clean
clean :
-rm -f $(OBJS) $(PROGRAM)
-rm -f *.o $(OBJPATH)/*/bin/$(PROGRAM_NAME)
.PHONY : depend
depend:
......
......@@ -19,6 +19,8 @@
# GNU makefile fragment for building a library
#
include $(topdir)/build/config.mk
ifeq ($(DARWIN_BUILD),yes)
CC = cc
CCC = c++
......@@ -28,7 +30,10 @@ CCC = g++
endif
NASM = nasm
LINK = ar cru
LIBPATH = $(topdir)/obj/lib
OBJPATH = $(topdir)/obj
LIBPATH = $(OBJPATH)/$(BUILD)/lib
DEBUG_LIBPATH = $(OBJPATH)/debug/lib
RELEASE_LIBPATH = $(OBJPATH)/release/lib
ifeq ($(DARWIN_BUILD),yes)
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = dylib
......@@ -36,55 +41,72 @@ else
STATIC_LIB_SUFFIX = a
DYNAMIC_LIB_SUFFIX = so
endif
STATIC_LIB = $(LIBPATH)/$(LIB_NAME).$(STATIC_LIB_SUFFIX)
DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).$(DYNAMIC_LIB_SUFFIX)
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 ($(DARWIN_BUILD),yes)
LINKD = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name $(DYNAMIC_LIB)
else
LINKD = $(CC) -shared
endif
all : release
include $(topdir)/build/config.mk
debug : CFLAGS = -g -O0 -DDEBUG $(DEBUG_CFLAGS) -Wall -W -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
release : CFLAGS = -O3 -fomit-frame-pointer -funroll-loops -finline-functions -DNDEBUG $(RELEASE_CFLAGS) -Wall -W -Winline -DFLaC__INLINE=__inline__ -DVERSION=$(VERSION) $(DEFINES) $(INCLUDES)
LFLAGS = -L$(LIBPATH)
debug : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
release : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
#@@@ OBJS = $(SRCS_C:%.c=%.o) $(SRCS_CC:%.cc=%.o) $(SRCS_CPP:%.cpp=%.o) $(SRCS_NASM:%.nasm=%.o)
#@@@ OBJS = $(SRCS_C:%.c=%.$(BUILD).o) $(SRCS_CC:%.cc=%.$(BUILD).o) $(SRCS_CPP:%.cpp=%.$(BUILD).o) $(SRCS_NASM:%.nasm=%.$(BUILD).o)
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_STATIC_LIB) $(DEBUG_DYNAMIC_LIB)
release : $(ORDINALS_H) $(RELEASE_STATIC_LIB) $(RELEASE_DYNAMIC_LIB)
$(STATIC_LIB) : $(OBJS)
$(LINK) $@ $(OBJS) && ranlib $@
$(DEBUG_STATIC_LIB): $(DEBUG_OBJS)
$(LINK) $@ $(DEBUG_OBJS) && ranlib $@
$(RELEASE_STATIC_LIB): $(RELEASE_OBJS)
$(LINK) $@ $(RELEASE_OBJS) && ranlib $@
$(DEBUG_DYNAMIC_LIB) : $(DEBUG_OBJS)
ifeq ($(DARWIN_BUILD),yes)
$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS) -lc
else
$(LINKD) -o $@ $(DEBUG_OBJS) $(LFLAGS) $(LIBS)
endif
$(DYNAMIC_LIB) : $(OBJS)
$(RELEASE_DYNAMIC_LIB) : $(RELEASE_OBJS)
ifeq ($(DARWIN_BUILD),yes)
$(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS) -lc
$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS) -lc
else
$(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS)
$(LINKD) -o $@ $(RELEASE_OBJS) $(LFLAGS) $(LIBS)
endif
%.o : %.c
%.debug.o %.release.o : %.c
$(CC) $(CFLAGS) -c $< -o $@
%.o : %.cc
%.debug.o %.release.o : %.cc
$(CCC) $(CFLAGS) -c $< -o $@
%.o : %.cpp
%.debug.o %.release.o : %.cpp
$(CCC) $(CFLAGS) -c $< -o $@
%.i : %.c
%.debug.i %.release.i : %.c
$(CC) $(CFLAGS) -E $< -o $@
%.i : %.cc
%.debug.i %.release.i : %.cc
$(CCC) $(CFLAGS) -E $< -o $@
%.i : %.cpp
%.debug.i %.release.i : %.cpp
$(CCC) $(CFLAGS) -E $< -o $@
%.o : %.nasm
%.debug.o %.release.o : %.nasm
$(NASM) -f elf -d OBJ_FORMAT_elf -i ia32/ $< -o $@
.PHONY : clean
clean :
-rm -f $(OBJS) $(STATIC_LIB) $(DYNAMIC_LIB) $(ORDINALS_H)
-rm -f *.o $(OBJPATH)/*/lib/$(STATIC_LIB_NAME) $(OBJPATH)/*/lib/$(DYNAMIC_LIB_NAME) $(ORDINALS_H)
.PHONY : depend
depend:
......
......@@ -408,8 +408,12 @@ AC_OUTPUT( \
man/Makefile \
test/Makefile \
build/Makefile \
obj/bin/Makefile \
obj/lib/Makefile \
obj/debug/bin/Makefile \
obj/debug/lib/Makefile \
obj/debug/Makefile \
obj/release/bin/Makefile \
obj/release/lib/Makefile \
obj/release/Makefile \
obj/Makefile \
flac.pbproj/Makefile \
)
......@@ -37,12 +37,12 @@ LIBS = -lgrabbag -lOggFLAC -lFLAC -lgain_analysis -lgetopt -lutf8 -lm -L
endif
endif
OBJS = \
analyze.o \
decode.o \
encode.o \
main.o \
vorbiscomment.o
SRCS_C = \
analyze.c \
decode.c \
encode.c \
main.c \
vorbiscomment.c
include $(topdir)/build/exe.mk
......
......@@ -25,14 +25,14 @@ topdir = ../..
LIB_NAME = libFLAC++
INCLUDES = -I$(topdir)/include
OBJS = \
file_decoder.o \
file_encoder.o \
metadata.o \
seekable_stream_decoder.o \
seekable_stream_encoder.o \
stream_decoder.o \
stream_encoder.o
SRCS_CPP = \
file_decoder.cpp \
file_encoder.cpp \
metadata.cpp \
seekable_stream_decoder.cpp \
seekable_stream_encoder.cpp \
stream_decoder.cpp \
stream_encoder.cpp
include $(topdir)/build/lib.mk
......
......@@ -39,32 +39,32 @@ ifeq ($(DARWIN_BUILD),yes)
else
ifeq ($(SOLARIS_BUILD),yes)
else
ASM_OBJS = \
ia32/cpu_asm.o \
ia32/fixed_asm.o \
ia32/lpc_asm.o
SRCS_NASM = \
ia32/cpu_asm.nasm \
ia32/fixed_asm.nasm \
ia32/lpc_asm.nasm
endif
endif
OBJS = $(ASM_OBJS) \
bitbuffer.o \
bitmath.o \
cpu.o \
crc.o \
file_decoder.o \
file_encoder.o \
fixed.o \
format.o \
lpc.o \
md5.o \
memory.o \
metadata_iterators.o \
metadata_object.o \
seekable_stream_decoder.o \
seekable_stream_encoder.o \
stream_decoder.o \
stream_encoder.o \
stream_encoder_framing.o
SRCS_C = \
bitbuffer.c \
bitmath.c \
cpu.c \
crc.c \
file_decoder.c \
file_encoder.c \
fixed.c \
format.c \
lpc.c \
md5.c \
memory.c \
metadata_iterators.c \
metadata_object.c \
seekable_stream_decoder.c \
seekable_stream_encoder.c \
stream_decoder.c \
stream_encoder.c \
stream_encoder_framing.c
include $(topdir)/build/lib.mk
......
......@@ -25,9 +25,9 @@ topdir = ../..
LIB_NAME = libOggFLAC++
INCLUDES = -I$(topdir)/include
OBJS = \
stream_decoder.o \
stream_encoder.o
SRCS_CPP = \
stream_decoder.cpp \
stream_encoder.cpp
include $(topdir)/build/lib.mk
......
......@@ -35,9 +35,9 @@ endif
INCLUDES = -I./include -I$(topdir)/include -I$(HOME)/local/include
DEBUG_CFLAGS =
OBJS = \
stream_decoder.o \
stream_encoder.o
SRCS_C = \
stream_decoder.c \
stream_encoder.c
include $(topdir)/build/lib.mk
......
......@@ -25,15 +25,15 @@ PROGRAM_NAME = metaflac
INCLUDES = -I./include -I$(topdir)/include
LIBS = -lgrabbag -lFLAC -lgain_analysis -lgetopt -lutf8 -lm
OBJS = \
main.o \
operations.o \
operations_shorthand_seektable.o \
operations_shorthand_streaminfo.o \
operations_shorthand_vorbiscomment.o \
options.o \
usage.o \
utils.o
SRCS_C = \
main.c \
operations.c \
operations_shorthand_seektable.c \
operations_shorthand_streaminfo.c \
operations_shorthand_vorbiscomment.c \
options.c \
usage.c \
utils.c
include $(topdir)/build/exe.mk
......
......@@ -8,14 +8,14 @@ LIB_NAME = libplugin_common
INCLUDES = -I./include -I$(topdir)/include -I$(HOME)/local/include
DEFINES = -DFLAC__HAS_ID3LIB -DID3LIB_MAJOR=3 -DID3LIB_MINOR=8 -DID3LIB_PATCH=0
OBJS = \
canonical_tag.o \
charset.o \
dither.o \
id3v1.o \
id3v2.o \
replaygain_synthesis.o \
vorbiscomment.o
SRCS_C = \
canonical_tag.c \
charset.c \
dither.c \
id3v1.c \
id3v2.c \
replaygain_synthesis.c \
vorbiscomment.c
include $(topdir)/build/lib.mk
......
......@@ -23,14 +23,15 @@ topdir = ../..
LIB_NAME = libxmms-flac
INCLUDES = $(shell xmms-config --cflags) -I./include -I$(topdir)/include -I..
LIBS = $(topdir)/obj/lib/libFLAC.a $(topdir)/obj/lib/libplugin_common.a $(topdir)/obj/lib/libgrabbag.a $(topdir)/obj/lib/libgain_analysis.a $(HOME)/local/lib/libid3.a -lstdc++ -lz
# refer to the static libs explicitly
LIBS = $(topdir)/obj/$(BUILD)/lib/libFLAC.a $(topdir)/obj/$(BUILD)/lib/libplugin_common.a $(topdir)/obj/$(BUILD)/lib/libgrabbag.a $(topdir)/obj/$(BUILD)/lib/libgain_analysis.a $(HOME)/local/lib/libid3.a -lstdc++ -lz
OBJS = \
charset.o \
configure.o \
plugin.o \
fileinfo.o \
wrap_id3.o
SRCS_C = \
charset.c \
configure.c \
plugin.c \
fileinfo.c \
wrap_id3.c
include $(topdir)/build/lib.mk
......
......@@ -7,8 +7,8 @@ topdir = ../../..
LIB_NAME = libgain_analysis
INCLUDES = -I$(topdir)/include/share
OBJS = \
gain_analysis.o
SRCS_C = \
gain_analysis.c
include $(topdir)/build/lib.mk
......
......@@ -7,9 +7,9 @@ topdir = ../../..
LIB_NAME = libgetopt
INCLUDES = -I$(topdir)/include -I$(topdir)/include/share
OBJS = \
getopt.o \
getopt1.o
SRCS_C = \
getopt.c \
getopt1.c
include $(topdir)/build/lib.mk
......
......@@ -7,11 +7,11 @@ topdir = ../../..
LIB_NAME = libgrabbag
INCLUDES = -I$(topdir)/include
OBJS = \
cuesheet.o \
file.o \
replaygain.o \
seektable.o
SRCS_C = \
cuesheet.c \
file.c \
replaygain.c \
seektable.c
include $(topdir)/build/lib.mk
......
......@@ -7,10 +7,10 @@ topdir = ../../..
LIB_NAME = libutf8
INCLUDES = -I$(topdir)/include -I$(topdir)/include/share
OBJS = \
charset.o \
iconvert.o \
utf8.o
SRCS_C = \
charset.c \
iconvert.c \
utf8.c
include $(topdir)/build/lib.mk
......
......@@ -24,14 +24,14 @@ topdir = ../..
PROGRAM_NAME = test_libFLAC++
INCLUDES = -I$(topdir)/include
LIBS = -lgrabbag -lFLAC++ -lFLAC -lm
OBJS = \
decoders.o \
encoders.o \
file_utils.o \
main.o \
metadata.o \
metadata_manip.o \
metadata_object.o
SRCS_CPP = \
decoders.cpp \
encoders.cpp \
file_utils.cpp \
main.cpp \
metadata.cpp \
metadata_manip.cpp \
metadata_object.cpp
include $(topdir)/build/exe.mk
......
......@@ -24,16 +24,16 @@ topdir = ../..
PROGRAM_NAME = test_libFLAC
INCLUDES = -I../libFLAC/include -I$(topdir)/include
LIBS = -lgrabbag -lFLAC -lm
OBJS = \
bitbuffer.o \
decoders.o \
encoders.o \
file_utils.o \
main.o \
metadata.o \
metadata_manip.o \
metadata_object.o \
metadata_utils.o
SRCS_C = \
bitbuffer.c \
decoders.c \
encoders.c \
file_utils.c \
main.c \
metadata.c \
metadata_manip.c \
metadata_object.c \
metadata_utils.c
include $(topdir)/build/exe.mk
......
......@@ -25,11 +25,11 @@ PROGRAM_NAME = test_libOggFLAC++
#@@@ TODO: conditionalize ogg lib path and -logg
INCLUDES = -I$(topdir)/include
LIBS = -lgrabbag -lOggFLAC++ -lOggFLAC -lFLAC -L$(HOME)/local/lib -logg -lm
OBJS = \
decoders.o \
encoders.o \
file_utils.o \
main.o
SRCS_CPP = \
decoders.cpp \
encoders.cpp \
file_utils.cpp \
main.cpp
include $(topdir)/build/exe.mk
......
......@@ -25,12 +25,12 @@ PROGRAM_NAME = test_libOggFLAC
#@@@ TODO: conditionalize ogg lib path and -logg
INCLUDES = -I$(topdir)/include
LIBS = -lgrabbag -lOggFLAC -lFLAC -L$(HOME)/local/lib -logg -lm
OBJS = \
decoders.o \
encoders.o \
file_utils.o \
main.o \
metadata_utils.o
SRCS_C = \
decoders.c \
encoders.c \
file_utils.c \
main.c \
metadata_utils.c
include $(topdir)/build/exe.mk
......
......@@ -24,8 +24,8 @@ topdir = ../..
PROGRAM_NAME = test_streams
INCLUDES = -I./include -I$(topdir)/include
LIBS = -lm
OBJS = \
main.o
SRCS_C = \
main.c
include $(topdir)/build/exe.mk
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment