Permalink
Browse files

Make libpe compile and link on Mac OS X.

  • Loading branch information...
1 parent 318e379 commit eaaaec60fc801d80cf5603df9f9d0aaaa80cc0c4 @jweyrich jweyrich committed Aug 3, 2012
Showing with 30 additions and 6 deletions.
  1. +1 −1 configure
  2. +29 −5 lib/libpe/Makefile
View
2 configure
@@ -76,7 +76,7 @@ check which
check sed make ld test mkdir rmdir install strip rm mv mktemp uname cut mktemp
# get os type
-os=$(uname -a | cut -d' ' -f1)
+os=$(uname)
echo -n "Getting OS type... "
[ -n $os ] && echo "$os" || (echo "unable to retrieve OS type" && exit 1)
View
34 lib/libpe/Makefile
@@ -1,28 +1,52 @@
+####### Platform specifics
+
+PLATFORM_OS := $(shell uname)
+
+####### Compiler, tools and options
+
PREFIX=/usr
DEST=$(DESTDIR)/$(PREFIX)/lib
VERSION=1.0
CFLAGS=-W -Wall -Wextra -pedantic -std=c99
SRC=pe.c
RM=rm -f
CC=gcc
-LN=ln -sf
+SYMLINK=ln -sf
STRIP=strip --strip-unneeded
LIBNAME=libpe
INSTALL=install -m 0644
+####### Build rules
+
all: pe.c pe.h
$(CC) -o $(LIBNAME).o -c $(CFLAGS) -fPIC $(SRC)
+ifeq ($(PLATFORM_OS), Linux)
$(CC) -shared -Wl,-soname,$(LIBNAME).so.1 -o $(LIBNAME).so $(LIBNAME).o
+else ifeq ($(PLATFORM_OS), Darwin)
+ $(CC) -headerpad_max_install_names -dynamiclib \
+ -flat_namespace -install_name $(TARGET).$(TARGET_VERSION).dylib \
+ -current_version $(VERSION) -compatibility_version $(VERSION) \
+ -o $(LIBNAME).dylib $(LIBNAME).o
+endif
install:
$(STRIP) $(LIBNAME).so
test -d $(DEST) || mkdir -p $(DEST)
+ifeq ($(PLATFORM_OS), Linux)
$(INSTALL) $(LIBNAME).so $(DEST)/$(LIBNAME).so.$(VERSION)
- cd $(DEST); $(LN) $(LIBNAME).so.$(VERSION) $(LIBNAME).so
- cd $(DEST); $(LN) $(LIBNAME).so.$(VERSION) $(LIBNAME).so.1
+ cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so
+ cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so.1
+else ifeq ($(PLATFORM_OS), Darwin)
+ $(INSTALL) $(LIBNAME).dylib $(DEST)/$(LIBNAME).$(VERSION).dylib
+ cd $(DEST); $(SYMLINK) $(LIBNAME).$(VERSION).dylib $(LIBNAME).dylib
+ cd $(DEST); $(SYMLINK) $(LIBNAME).$(VERSION).dylib $(LIBNAME).1.dylib
+endif
uninstall:
- $(RM) $(DEST)/$(LIBNAME).so*
+ $(RM) $(DEST)/$(LIBNAME).so* \
+ $(DEST)/$(LIBNAME)*.dylib
clean:
- $(RM) $(LIBNAME).*o*
+ $(RM) $(LIBNAME).*o* \
+ $(LIBNAME).so* \
+ $(LIBNAME)*.dylib

0 comments on commit eaaaec6

Please sign in to comment.