-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (50 loc) · 1.56 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
#!/usr/bin/make
#
# libsara - S.A.R.A.'s helper library
# Copyright (C) 2017 Salvatore Mesoraca <s.mesoraca16@gmail.com>
#
# This program is released under CC0 1.0 Universal license
#
DESTDIR ?= /
LIBDIR ?= usr/lib/
STATICLIBDIR ?= usr/lib/
INCLUDEDIR ?= usr/include/
CC ?= $(CROSS_COMPILE)gcc
LD ?= $(CROSS_COMPILE)ld
CFLAGS := -O2 -fstack-protector -fPIC $(CFLAGS)
LDFLAGS := -Wl,-z,relro -Wl,-z,now -Wl,-Bsymbolic-functions -shared $(LDFLAGS)
SRCDIR= ./
all: libsara.so libsara.a
$(SOURCE)%.o: $(SRCDIR)/$(SOURCE)%.c
$(CC) -c -o $@ $< $(CFLAGS)
libsara.so: libsara.o
$(CC) -o $@ $^ -Wl,-soname,$@.0 $(LDFLAGS)
libsara.a: libsara.o
ar rcs $@ $^
install: all
mkdir -p $(DESTDIR)/$(LIBDIR)
mkdir -p $(DESTDIR)/$(STATICLIBDIR)
mkdir -p $(DESTDIR)/$(INCLUDEDIR)
mkdir -p $(DESTDIR)/$(LIBDIR)/pkgconfig/
mkdir -p $(DESTDIR)/usr/share/man/man3/
cp $(SRCDIR)/sara.h $(DESTDIR)/$(INCLUDEDIR)
cp libsara.so $(DESTDIR)/$(LIBDIR)
cp libsara.a $(DESTDIR)/$(STATICLIBDIR)
cp libsara.pc $(DESTDIR)/$(LIBDIR)/pkgconfig/
gzip -c man/sara.h.3 > $(DESTDIR)/usr/share/man/man3/sara.h.3.gz
uninstall:
-rm $(DESTDIR)/$(INCLUDEDIR)/sara.h
-rm $(DESTDIR)/$(LIBDIR)/libsara.so
-rm $(DESTDIR)/$(STATICLIBDIR)/libsara.a
-rm $(DESTDIR)/$(LIBDIR)/pkgconfig/libsara.pc
-rm $(DESTDIR)/usr/share/man/man3/sara.h.3.gz
-rmdir $(DESTDIR)/$(INCLUDEDIR)
-rmdir $(DESTDIR)/$(LIBDIR)
-rmdir $(DESTDIR)/$(STATICLIBDIR)
-rmdir $(DESTDIR)/$(LIBDIR)/pkgconfig/
clean:
-rm -f *.o *~
-rm -f $(SRCDIR)/*~
distclean:
-rm -f libsara.so* libsara.a
.PHONY: all install uninstall clean distclean