-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
48 lines (40 loc) · 1.25 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
NAME := solunar
VERSION := 2.0c
LIBS := -lm ${EXTRA_LIBS}
KLIB := klib
KLIB_INC := $(KLIB)/include
KLIB_LIB := $(KLIB)
LIBSOL := libsolunar
LIBSOL_INC := $(LIBSOL)/include
LIBSOL_LIB := $(LIBSOL)
TARGET := $(NAME)
SOURCES := $(shell find src/ -type f -name *.c)
OBJECTS := $(patsubst src/%,build/%,$(SOURCES:.c=.o))
DEPS := $(OBJECTS:.o=.deps)
DESTDIR := /
PREFIX := /usr
BINDIR := $(DESTDIR)/$(PREFIX)/bin
MANDIR := $(DESTDIR)/$(PREFIX)/share/man/man1/
EXTRA_LDFLAGS ?=
EXTRA_CFLAGS ?=
CFLAGS := -g -O3 -Wall -Wno-unused-result -DNAME=\"$(NAME)\" -DVERSION=\"$(VERSION)\" -DPREFIX=\"$(PREFIX)\" -I $(LIBSOL_INC) -I $(KLIB_INC) ${EXTRA_CFLAGS} -ffunction-sections -fdata-sections
LDFLAGS := -s -Wl,--gc-sections ${EXTRA_LDFLAGS}
$(TARGET): $(OBJECTS)
echo $(SOURCES)
make -C klib
make -C libsolunar
$(CC) $(LDFLAGS) -o $(TARGET) $(OBJECTS) $(LIBSOL)/libsolunar.a $(KLIB)/klib.a $(LIBS)
build/%.o: src/%.c
@mkdir -p build/
$(CC) $(CFLAGS) -MD -MF $(@:.o=.deps) -c -o $@ $<
clean:
$(RM) -r build/ $(TARGET)
make -C klib clean
make -C libsolunar clean
install: $(TARGET)
mkdir -p $(BINDIR) $(MANDIR)
strip $(TARGET)
install -m 755 $(TARGET) ${BINDIR}
install -m 644 man1/* $(MANDIR)
-include $(DEPS)
.PHONY: clean