-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
86 lines (74 loc) · 2.19 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
INSTALL?=install
USE_SOLINK:=
OBJECTS=sfklCoding.o sfklDiff.o sfklLPC.o sfklZip.o sfklCrunch.o sfklFile.o sfklString.o
CXXFLAGS+=-fPIC -Wall -Wextra -ffloat-store
OS := $(shell uname)
ifneq (,$(filter Linux GNU/kFreeBSD GNU,${OS}))
CPPFLAGS+=-DUSE_ENDIAN_H
else ifneq (,$(findstring BSD,${OS}))
CPPFLAGS+=-DUSE_SYS_ENDIAN_H
else
ENDIANNESS=LITTLE_ENDIAN
CPPFLAGS+=-DUSE_MANUAL_ENDIANNESS -DMANUAL_${ENDIANNESS}
endif
ifeq ($(OS),Darwin)
LDFLAGS += -flat_namespace -undefined suppress -dynamiclib
SO = dylib
else
LDFLAGS += -shared
SHLIB_MAJOR:=1
SHLIB_MINOR:=0
SHLIB_PATCHLEVEL:=0
ifneq (,$(filter Linux GNU/kFreeBSD GNU,${OS}))
INSTALL += -D
USE_SOLINK:=so.${SHLIB_MAJOR} so
SO = so.${SHLIB_MAJOR}.${SHLIB_MINOR}.${SHLIB_PATCHLEVEL}
LDFLAGS += -Wl,-soname,libsfark.so.${SHLIB_MAJOR}
else ifneq (,$(findstring BSD,${OS}))
# OpenBSD/MirBSD, might apply to NetBSD, FreeBSD/MidnightBSD might differ
SO = so.${SHLIB_MAJOR}.${SHLIB_MINOR}
else
SO = so
endif
endif
PREFIX ?= /usr/local
ifdef DEB_HOST_MULTIARCH
LIBDIR = ${PREFIX}/lib/${DEB_HOST_MULTIARCH}
else
LIBDIR = ${PREFIX}/lib
endif
INCDIR = ${PREFIX}/include
all: libsfark.$(SO)
ifneq (,$(strip ${USE_SOLINK}))
set -ex; for solink in ${USE_SOLINK}; do \
rm -f libsfark.$$solink; \
ln -s libsfark.$(SO) libsfark.$$solink; \
done
endif
.PHONY: clean
clean:
-rm *.o libsfark.$(SO)
ifneq (,$(strip ${USE_SOLINK}))
set -ex; for solink in ${USE_SOLINK}; do \
rm -f libsfark.$$solink; \
done
endif
test: libsfark.$(SO)
-rm -rf sfarkxtc
git clone https://github.com/raboof/sfarkxtc
CXXFLAGS="-I.. -L.." make -C sfarkxtc
rm -rf sfarkxtc
libsfark.$(SO): $(OBJECTS)
$(CXX) -shared $(LDFLAGS) $(OBJECTS) -o libsfark.$(SO) -lz
# It is unclear to me whether /usr/local/* is the proper location on
# OSX, as reportedly it's not on the clang path by default there. Let
# me know if you know how this should be done there :).
install: libsfark.$(SO) sfArkLib.h
$(INSTALL) libsfark.$(SO) ${DESTDIR}${LIBDIR}/libsfark.$(SO)
$(INSTALL) sfArkLib.h ${DESTDIR}${INCDIR}/sfArkLib.h
ifneq (,$(strip ${USE_SOLINK}))
set -ex; for solink in ${USE_SOLINK}; do \
rm -f ${DESTDIR}${LIBDIR}/libsfark.$$solink; \
ln -s libsfark.$(SO) ${DESTDIR}${LIBDIR}/libsfark.$$solink; \
done
endif