-
Notifications
You must be signed in to change notification settings - Fork 20
/
Makefile
68 lines (50 loc) · 1.37 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
#
# Makefile for libulz (stolen from musl) (requires GNU make)
#
# Use config.mak to override any of the following variables.
# Do not make changes here.
#
prefix = /usr/local/
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
includedir = $(prefix)/include
libdir = $(prefix)/lib
SRCS = $(sort $(wildcard src/*/*.c))
OBJS = $(SRCS:.c=.o)
LOBJS = $(OBJS:.o=.lo)
CFLAGS += -Os
CFLAGS_REQ=-std=c99
#-ffreestanding -std=c99 -D_XOPEN_SOURCE=700 -pipe
#LDFLAGS = -nostdlib -shared -fPIC -Wl,-e,_start -Wl,-Bsymbolic-functions
INC = -I./include
#PIC = -fPIC -O3
AR = $(CROSS_COMPILE)ar
RANLIB = $(CROSS_COMPILE)ranlib
OBJCOPY = $(CROSS_COMPILE)objcopy
ALL_INCLUDES = $(sort $(wildcard include/*.h include/*/*.h))
ULZ_LIBS = lib/libulz.a
ALL_LIBS = $(ULZ_LIBS)
-include config.mak
CFLAGS += $(CFLAGS_REQ)
all: $(ALL_LIBS)
install: $(ALL_LIBS:lib/%=$(DESTDIR)$(libdir)/%) $(ALL_INCLUDES:include/%=$(DESTDIR)$(includedir)/ulz/%) $(ALL_TOOLS:tools/%=$(DESTDIR)$(bindir)/%)
clean:
rm -f crt/*.o
rm -f $(OBJS)
rm -f $(LOBJS)
rm -f $(ALL_LIBS) lib/*.[ao] lib/*.so
%.o: %.c
$(CC) $(CFLAGS) $(INC) -c -o $@ $<
lib/libulz.a: $(OBJS)
rm -f $@
$(AR) rc $@ $(OBJS)
$(RANLIB) $@
lib/%.o:
cp $< $@
$(DESTDIR)$(includedir)/ulz%: include/%
install -D $< $@
$(DESTDIR)$(bindir)/%: tools/%
install -D $< $@
$(DESTDIR)$(prefix)/%: %
install -D -m 644 $< $@
.PHONY: all clean install