-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
81 lines (65 loc) · 1.96 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
69
70
71
72
73
74
75
76
77
78
79
80
81
TOPDIR := ./src
IVAR := -I. -I$(TOPDIR)/include/ -I/usr/local/include
DESTDIR =
PREFIX = /usr
BINDIR = $(PREFIX)/bin
DATADIR = $(PREFIX)/share
MANDIR = $(DATADIR)/man
MAN1DIR = $(MANDIR)/man1
INSTALL = install
INSTALL_DIR = install -d
INSTALL_DATA = install -m644
INSTALL_PROGRAM = install
rm = rm -rf
OBJDIR = obj
OUTDIR = bin
# Target and Version
TARGET = fetchme
VERSION = 1.4.9
include config_backend.mk
# These variables depend on values from config_backend.mk
INCLUDES:= $(wildcard $(SRCDIR)/modules/include/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
include cc_and_flags.mk
.PHONY: all clean remove install install-strip uninstall format pgo
all:
$(MAKE) remove
$(MAKE) $(TARGET)
$(TARGET): $(OBJECTS) | $(OUTDIR)
$(CC) -o $(OUTDIR)/$@ $(F_CFLAGS) $(LFLAGS) $(INCLUDE) $^
$(OBJDIR)/%.o : $(SRCDIR)/%.c | $(OBJDIR)/modules
$(CC) -o $@ $(F_CFLAGS) $^ -c
$(PROFDIR) $(OUTDIR) $(OBJDIR)/modules:
mkdir -p $@
clean:
$(rm) $(OBJECTS)
@echo "Cleanup complete!"
remove: clean
$(rm) $(OUTDIR)/$(TARGET)
@echo "Executable removed!"
install: | $(TARGET)
$(INSTALL_DIR) $(DESTDIR)$(BINDIR)
$(INSTALL_PROGRAM) $(OUTDIR)/$(TARGET) $(DESTDIR)$(BINDIR)
@echo "Executable installed!"
$(INSTALL_DIR) $(DESTDIR)$(MAN1DIR)
$(INSTALL_DATA) docs/fetchme.1 $(DESTDIR)$(MAN1DIR)
@echo "Man page installed!"
install-strip:
$(MAKE) INSTALL_PROGRAM="install -s" install
uninstall:
$(rm) $(DESTDIR)$(BINDIR)/$(TARGET)
@echo "Exectuable removed!"
$(rm) $(DESTDIR)$(MAN1DIR)/fetchme.1
@echo "Man page uninstalled!"
format:
@find . -iname *.h -o -iname *.c | xargs clang-format -style=file:.clang-format -i
pgo:
@# only clang is supported for this PGO
if [[ -f fetchme.profdata ]]; then \
make CC=clang PGO=use && $(rm) fetchme.prof*; \
else \
make CC=clang PGO=gen CFLAGS="-DPGO_LOOP $(CFLAGS)" \
M_TERMINAL=n M_SHELL=n && \
LLVM_PROFILE_FILE=fetchme.profraw ./bin/fetchme > /dev/null; \
llvm-profdata merge -output=fetchme.profdata fetchme.profraw; \
fi