add support for Darwin builds
authorJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 7 Dec 2001 19:28:25 +0000 (19:28 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 7 Dec 2001 19:28:25 +0000 (19:28 +0000)
build/exe.mk
build/lib.mk
src/flac/Makefile.lite
src/libFLAC/Makefile.lite

index ce36e93..507d3b1 100644 (file)
 # GNU makefile fragment for building an executable
 #
 
+ifeq ($(DARWIN_BUILD),yes)
+CC          = cc
+else
 CC          = gcc
+endif
 NASM        = nasm
-# LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static
+# LINKAGE can be forced to -static or -dynamic from invocation if desired, but it defaults to -static except on OSX
+ifeq ($(DARWIN_BUILD),yes)
+LINKAGE     = -dynamic
+else
 LINKAGE     = -static
-LINK        = gcc $(LINKAGE)
+endif
+LINK        = $(CC) $(LINKAGE)
 BINPATH     = ../../obj/bin
 LIBPATH     = ../../obj/lib
 PROGRAM     = $(BINPATH)/$(PROGRAM_NAME)
index bc9ecfb..9a72335 100644 (file)
 # GNU makefile fragment for building a library
 #
 
+ifeq ($(DARWIN_BUILD),yes)
+CC          = cc
+else
 CC          = gcc
+endif
 NASM        = nasm
 LINK        = ar cru
+ifeq ($(DARWIN_BUILD),yes)
+LINKD       = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name ../../obj/lib/libFLAC.dylib
+#LINKD       = $(CC) -dynamiclib -flat_namespace -undefined suppress -install_name ../../obj/lib/libFLAC.1.dylib -compatibility_version 3 -current_version 3.1
+else
 LINKD       = ld -G
+endif
 LIBPATH     = ../../obj/lib
 STATIC_LIB  = $(LIBPATH)/$(LIB_NAME).a
+ifeq ($(DARWIN_BUILD),yes)
+DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).dylib
+#DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).1.1.1.dylib
+else
 DYNAMIC_LIB = $(LIBPATH)/$(LIB_NAME).so
+endif
 
 all : release
 
@@ -40,10 +54,14 @@ debug   : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
 release : $(ORDINALS_H) $(STATIC_LIB) $(DYNAMIC_LIB)
 
 $(STATIC_LIB) : $(OBJS)
-       $(LINK) $@ $(OBJS)
+       $(LINK) $@ $(OBJS) && ranlib $@
 
 $(DYNAMIC_LIB) : $(OBJS)
+ifeq ($(DARWIN_BUILD),yes)
+       $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS) -lc
+else
        $(LINKD) -o $@ $(OBJS) $(LFLAGS) $(LIBS)
+endif
 
 %.o : %.c
        $(CC) $(CFLAGS) -c $< -o $@
index aab13cb..e99cd76 100644 (file)
 #
 
 PROGRAM_NAME = flac
-#@@@OGG
+ifeq ($(DARWIN_BUILD),yes)
+INCLUDES     = -I./include -I../../include
+LIBS         = -lFLAC -lc -lm
+else
+#@@@ TODO: conditionalize ogg includes, defines, and -logg
 INCLUDES     = -I./include -I../../include -I$(HOME)/local/include -DFLAC__HAS_OGG
-#@@@OGG conditionalize -logg
 LIBS         = -lFLAC -lm -L$(HOME)/local/lib -logg
+endif
 
 OBJS = \
        analyze.o \
index a684df6..3de4cfa 100644 (file)
 #
 
 LIB_NAME  = libFLAC
+ifeq ($(DARWIN_BUILD),yes)
+DEFINES = -DFLAC__NO_NASM -DFLAC__ALIGN_MALLOC_DATA
+else
 DEFINES = -DFLAC__CPU_IA32 -DFLAC__HAS_NASM -DFLAC__ALIGN_MALLOC_DATA
+endif
 INCLUDES  = -I./include -I../../include
 DEBUG_CFLAGS = -DFLAC__OVERFLOW_DETECT
 
-OBJS = \
+ifeq ($(DARWIN_BUILD),yes)
+else
+ASM_OBJS = \
+       ia32/cpu_asm.o \
+       ia32/fixed_asm.o \
+       ia32/lpc_asm.o
+endif
+
+OBJS = $(ASM_OBJS) \
        bitbuffer.o \
        bitmath.o \
        cpu.o \
@@ -41,10 +53,7 @@ OBJS = \
        stream_decoder.o \
        stream_encoder.o \
        stream_encoder_framing.o \
-       utility.o \
-       ia32/cpu_asm.o \
-       ia32/fixed_asm.o \
-       ia32/lpc_asm.o
+       utility.o
 
 include ../../build/lib.mk