-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
103 lines (75 loc) · 2.12 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# -*- Makefile -*- for fmt
.SECONDEXPANSION:
.SUFFIXES:
ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
QUIET = @
QUIET_CXX = @echo ' ' CXX $<;
QUIET_AR = @echo ' ' AR $@;
QUIET_RANLIB = @echo ' ' RANLIB $@;
QUIET_INSTALL = @echo ' ' INSTALL $<;
export V
endif
endif
LIB = libfmt.a
AR ?= ar
ARFLAGS ?= rc
CXX ?= g++
RANLIB ?= ranlib
RM ?= rm -f
BUILD_DIR := build
BUILD_ID ?= default-build-id
OBJ_DIR := $(BUILD_DIR)/$(BUILD_ID)
ifeq (,$(BUILD_ID))
$(error BUILD_ID cannot be an empty string)
endif
prefix ?= /usr/local
libdir := $(prefix)/lib
includedir := $(prefix)/include
CXXFLAGS ?= -O2
CXXFLAGS += -std=c++2a -fno-rtti -fno-exceptions -Iinclude -I$(includedir)
HEADERS = \
include/fmt/*.h \
SOURCES = \
src/format.cc \
src/os.cc \
SOURCES := $(wildcard $(SOURCES))
HEADERS := $(wildcard $(HEADERS))
HEADERS_INST := $(patsubst include/%,$(includedir)/%,$(HEADERS))
OBJECTS := $(patsubst %.cc,$(OBJ_DIR)/%.o,$(SOURCES))
.PHONY: install
all: $(OBJ_DIR)/$(LIB)
$(includedir)/%.h: include/%.h | $$(@D)/.
$(QUIET_INSTALL)cp $< $@
@chmod 0644 $@
$(libdir)/%.a: $(OBJ_DIR)/%.a
-@if [ ! -d $(libdir) ]; then mkdir -p $(libdir); fi
$(QUIET_INSTALL)cp $< $@
@chmod 0644 $@
install: $(HEADERS_INST) $(libdir)/$(LIB)
clean:
$(RM) -r $(OBJ_DIR)
distclean: clean
$(RM) -r $(BUILD_DIR)
$(OBJ_DIR)/$(LIB): $(OBJECTS)
$(QUIET_AR)$(AR) $(ARFLAGS) $@ $^
$(QUIET_RANLIB)$(RANLIB) $@
$(OBJ_DIR)/%.o: %.cc $(OBJ_DIR)/.cflags | $$(@D)/.
$(QUIET_CXX)$(CXX) $(CXXFLAGS) -o $@ -c $<
.PRECIOUS: $(includedir)/. $(includedir)%/. $(OBJ_DIR)/. $(OBJ_DIR)%/.
$(includedir)/.:
$(QUIET)mkdir -p $@
$(includedir)%/.:
$(QUIET)mkdir -p $@
$(OBJ_DIR)/.:
$(QUIET)mkdir -p $@
$(OBJ_DIR)%/.:
$(QUIET)mkdir -p $@
TRACK_CFLAGS = $(subst ','\'',$(CXX) $(CXXFLAGS))
$(OBJ_DIR)/.cflags: .force-cflags | $$(@D)/.
@FLAGS='$(TRACK_CFLAGS)'; \
if test x"$$FLAGS" != x"`cat $(OBJ_DIR)/.cflags 2>/dev/null`" ; then \
echo " * rebuilding fmt: new build flags or prefix"; \
echo "$$FLAGS" > $(OBJ_DIR)/.cflags; \
fi
.PHONY: .force-cflags