-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
50 lines (36 loc) · 898 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
prefix=/usr/local
bindir=$(prefix)/bin
includedir=$(prefix)/include
libdir=$(prefix)/lib
SRC = $(sort $(wildcard *.c))
OBJS = $(SRC:.c=.o)
SHLIB_EXT=.so
ALL_INCLUDES=argp.h
ALL_LIBS=libargp$(SHLIB_EXT) libargp.a
CFLAGS=-O0 -fPIC -Wall
BUILDCFLAGS=$(CFLAGS) -I.
LDFLAGS=
AR ?= $(CROSS_COMPILE)ar
RANLIB ?= $(CROSS_COMPILE)ranlib
CC ?= $(CROSS_COMPILE)cc
INSTALL ?= ./install.sh
all: $(ALL_LIBS)
install: $(ALL_LIBS:lib%=$(DESTDIR)$(libdir)/lib%) $(ALL_INCLUDES:%=$(DESTDIR)$(includedir)/%)
clean:
rm -f $(ALL_LIBS)
rm -f $(OBJS)
rm -f *.o *.so
%.o: %.c
$(CC) $(BUILDCFLAGS) -c -o $@ $<
libargp.a: $(OBJS)
rm -f $@
$(AR) rc $@ $(OBJS)
$(RANLIB) $@
libargp$(SHLIB_EXT): $(OBJS)
rm -f $@
$(CC) $(LDFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS)
$(DESTDIR)$(libdir)/%: %
$(INSTALL) -D -m 755 $< $@
$(DESTDIR)$(includedir)/%.h: %.h
$(INSTALL) -D -m 644 $< $@
.PHONY: all clean install