forked from merces/libpe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (56 loc) · 1.7 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
####### Platform specifics
# cut is necessary for Cygwin
PLATFORM_OS := $(shell uname | cut -d_ -f1)
####### Compiler, tools and options
PREFIX = /usr
DEST = $(DESTDIR)/$(PREFIX)/lib
VERSION = 1.0
override CFLAGS += -W -Wall -Wextra -pedantic -std=c99 -c
ifneq ($(PLATFORM_OS), CYGWIN)
override CFLAGS += -fPIC
endif
SRC = pe.c
RM = rm -f
CC ?= gcc
SYMLINK = ln -sf
ifeq ($(PLATFORM_OS), Darwin)
STRIP = strip -x
else
STRIP = strip --strip-unneeded
endif
LIBNAME = libpe
INSTALL = install -m 0644
####### Build rules
all: pe.c pe.h
$(CC) -o $(LIBNAME).o $(CFLAGS) $(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 $(LIBNAME).$(VERSION).dylib \
-current_version $(VERSION) -compatibility_version $(VERSION) \
-o $(LIBNAME).dylib $(LIBNAME).o
else ifeq ($(PLATFORM_OS), CYGWIN)
$(CC) -shared -o $(LIBNAME).dll $(LIBNAME).o
endif
install:
test -d $(DEST) || mkdir -p $(DEST)
ifeq ($(PLATFORM_OS), Linux)
$(STRIP) $(LIBNAME).so
$(INSTALL) $(LIBNAME).so $(DEST)/$(LIBNAME).so.$(VERSION)
cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so
cd $(DEST); $(SYMLINK) $(LIBNAME).so.$(VERSION) $(LIBNAME).so.1
else ifeq ($(PLATFORM_OS), Darwin)
$(STRIP) $(LIBNAME).dylib
$(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* \
$(DEST)/$(LIBNAME)*.dylib
clean:
$(RM) $(LIBNAME)*.o \
$(LIBNAME)*.so \
$(LIBNAME)*.dylib \
$(LIBNAME)*.dll