-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
54 lines (34 loc) · 890 Bytes
/
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
prefix=/usr/local
bindir=$(prefix)/bin
includedir=$(prefix)/include
libdir=$(prefix)/lib
sysconfdir=$(prefix)/etc
LIBSRC = $(sort $(wildcard src/*.c))
SRCS = $(LIBSRC)
OBJS = $(SRCS:.c=.o)
LIBOBJS = $(LIBSRC:.c=.o)
HEADERS = src/libelf.h src/gelf.h
ALL_INCLUDES = $(HEADERS)
ALL_LIBS=libelf.a
CFLAGS=-O3 -std=gnu99 -D_GNU_SOURCE
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
-include config.mak
BUILDCFLAGS=$(CFLAGS)
all: $(ALL_LIBS)
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:src/%=$(DESTDIR)$(includedir)/%)
clean:
rm -f $(ALL_LIBS)
rm -f $(OBJS)
%.o: %.c
$(CC) $(BUILDCFLAGS) -c -o $@ $<
libelf.a: $(LIBOBJS)
rm -f $@
$(AR) rc $@ $(LIBOBJS)
$(RANLIB) $@
$(DESTDIR)$(libdir)/%.a: %.a
install -D -m 755 $< $@
$(DESTDIR)$(includedir)/%: src/%
install -D -m 644 $< $@
.PHONY: all clean install