Commit 6e144900 authored by Josh Coalson's avatar Josh Coalson
Browse files

add support for Darwin builds

parent 04180bef
......@@ -19,11 +19,19 @@
# 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)
......
......@@ -19,13 +19,27 @@
# 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 $@
......
......@@ -20,10 +20,14 @@
#
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 \
......
......@@ -21,11 +21,23 @@
#
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
......
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