Commits

Richard Goedeken  committed d6d2007

imported patch OSX_build

  • Participants
  • Parent commits 85ec855

Comments (0)

Files changed (1)

File projects/unix/Makefile

 UNAME = $(shell uname -s)
 ifeq ("$(UNAME)","Linux")
   OS = LINUX
+  SO_EXTENSION = so
+  SHARED = -shared
 endif
 ifeq ("$(UNAME)","linux")
   OS = LINUX
+  SO_EXTENSION = so
+  SHARED = -shared
 endif
 ifeq ("$(UNAME)","Darwin")
   OS = OSX
   LDFLAGS += -liconv -lpng
+  SO_EXTENSION = dylib
+  SHARED = -bundle
 endif
 ifeq ("$(UNAME)","FreeBSD")
   OS = FREEBSD
+  SO_EXTENSION = so
+  SHARED = -shared
 endif
 
 # detect system architecture
 ifeq ($(OS),FREEBSD)
     CFLAGS  += `${SDL_CONFIG} --cflags`
     LDFLAGS += `${SDL_CONFIG} --libs`
+else ifeq ("$(UNAME)","Darwin")
+    CFLAGS  += $(shell sdl-config --cflags)
+    # sdl-config on mac screws up when we're trying to build a library and not an executable
+    # SDL 1.3 is supposed to fix that, if it's ever released
+    LDFLAGS += -L/usr/local/lib -lSDL -Wl,-framework,Cocoa
 else
     CFLAGS  += $(shell sdl-config --cflags)
     LDFLAGS += $(shell sdl-config --libs)
 $(shell mkdir -p $(OBJDIRS))
 
 # build targets
-all: mupen64plus-input-sdl.so
+all: mupen64plus-input-sdl.$(SO_EXTENSION)
 
 clean:
-	rm -rf ./_obj mupen64plus-input-sdl.so
+	rm -rf ./_obj mupen64plus-input-sdl.$(SO_EXTENSION)
 
 # build rules
-mupen64plus-input-sdl.so: $(OBJECTS)
-	$(LD) -shared $^ $(LDFLAGS) -o $@
+mupen64plus-input-sdl.$(SO_EXTENSION): $(OBJECTS)
+	$(LD) $(SHARED) $^ $(LDFLAGS) -o $@
 	$(STRIP) $@
 
 $(OBJDIR)/%.o: $(SRCDIR)/%.c