Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make libpe compile and link on Mac OS X.

  • Loading branch information...
commit eaaaec60fc801d80cf5603df9f9d0aaaa80cc0c4 1 parent 318e379
Jardel Weyrich jweyrich authored

Showing 2 changed files with 30 additions and 6 deletions. Show diff stats Hide diff stats

  1. +1 1  configure
  2. +29 5 lib/libpe/Makefile
2  configure
@@ -76,7 +76,7 @@ check which
76 76 check sed make ld test mkdir rmdir install strip rm mv mktemp uname cut mktemp
77 77
78 78 # get os type
79   -os=$(uname -a | cut -d' ' -f1)
  79 +os=$(uname)
80 80 echo -n "Getting OS type... "
81 81 [ -n $os ] && echo "$os" || (echo "unable to retrieve OS type" && exit 1)
82 82
34 lib/libpe/Makefile
... ... @@ -1,3 +1,9 @@
  1 +####### Platform specifics
  2 +
  3 +PLATFORM_OS := $(shell uname)
  4 +
  5 +####### Compiler, tools and options
  6 +
1 7 PREFIX=/usr
2 8 DEST=$(DESTDIR)/$(PREFIX)/lib
3 9 VERSION=1.0
@@ -5,24 +11,42 @@ CFLAGS=-W -Wall -Wextra -pedantic -std=c99
5 11 SRC=pe.c
6 12 RM=rm -f
7 13 CC=gcc
8   -LN=ln -sf
  14 +SYMLINK=ln -sf
9 15 STRIP=strip --strip-unneeded
10 16 LIBNAME=libpe
11 17 INSTALL=install -m 0644
12 18
  19 +####### Build rules
  20 +
13 21 all: pe.c pe.h
14 22 $(CC) -o $(LIBNAME).o -c $(CFLAGS) -fPIC $(SRC)
  23 +ifeq ($(PLATFORM_OS), Linux)
15 24 $(CC) -shared -Wl,-soname,$(LIBNAME).so.1 -o $(LIBNAME).so $(LIBNAME).o
  25 +else ifeq ($(PLATFORM_OS), Darwin)
  26 + $(CC) -headerpad_max_install_names -dynamiclib \
  27 + -flat_namespace -install_name $(TARGET).$(TARGET_VERSION).dylib \
  28 + -current_version $(VERSION) -compatibility_version $(VERSION) \
  29 + -o $(LIBNAME).dylib $(LIBNAME).o
  30 +endif
16 31
17 32 install:
18 33 $(STRIP) $(LIBNAME).so
19 34 test -d $(DEST) || mkdir -p $(DEST)
  35 +ifeq ($(PLATFORM_OS), Linux)
20 36 $(INSTALL) $(LIBNAME).so $(DEST)/$(LIBNAME).so.$(VERSION)
21   - cd $(DEST); $(LN) $(LIBNAME).so.$(VERSION) $(LIBNAME).so
22   - cd $(DEST); $(LN) $(LIBNAME).so.$(VERSION) $(LIBNAME).so.1
  37 + cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so
  38 + cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so.1
  39 +else ifeq ($(PLATFORM_OS), Darwin)
  40 + $(INSTALL) $(LIBNAME).dylib $(DEST)/$(LIBNAME).$(VERSION).dylib
  41 + cd $(DEST); $(SYMLINK) $(LIBNAME).$(VERSION).dylib $(LIBNAME).dylib
  42 + cd $(DEST); $(SYMLINK) $(LIBNAME).$(VERSION).dylib $(LIBNAME).1.dylib
  43 +endif
23 44
24 45 uninstall:
25   - $(RM) $(DEST)/$(LIBNAME).so*
  46 + $(RM) $(DEST)/$(LIBNAME).so* \
  47 + $(DEST)/$(LIBNAME)*.dylib
26 48
27 49 clean:
28   - $(RM) $(LIBNAME).*o*
  50 + $(RM) $(LIBNAME).*o* \
  51 + $(LIBNAME).so* \
  52 + $(LIBNAME)*.dylib

0 comments on commit eaaaec6

Please sign in to comment.
Something went wrong with that request. Please try again.