-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
44 lines (36 loc) · 1.11 KB
/
Makefile
File metadata and controls
44 lines (36 loc) · 1.11 KB
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
BINS = mathfairy
PKGS = gtkmm-4.0
SRCS += $(wildcard src/*.cpp)
OBJS = $(patsubst src/%,$(BUILDDIR)/%,$(SRCS:.cpp=.o))
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share
BUILDDIR = build
CXXFLAGS += -Oz -s -Wall -flto
CXXFLAGS += $(shell pkg-config --cflags $(PKGS))
LDFLAGS += $(shell pkg-config --libs $(PKGS)) -Wl,--gc-sections
$(shell mkdir -p $(BUILDDIR))
JOB_COUNT := $(BINS) $(OBJS)
JOBS_DONE := $(shell ls -l $(JOB_COUNT) 2> /dev/null | wc -l)
define progress
$(eval JOBS_DONE := $(shell echo $$(($(JOBS_DONE) + 1))))
@printf "[$(JOBS_DONE)/$(shell echo $(JOB_COUNT) | wc -w)] %s %s\n" $(1) $(2)
endef
$(BINS): $(OBJS)
$(call progress, Linking $@)
@$(CXX) -o \
$(BUILDDIR)/$(BINS) \
$(OBJS) \
$(LDFLAGS) \
$(CXXFLAGS)
$(BUILDDIR)/%.o: src/%.cpp
$(call progress, Compiling $@)
@$(CXX) -c $< -o $@ $(CXXFLAGS)
install: $(BINS)
@echo "Installing..."
@install -D -t $(DESTDIR)$(BINDIR) $(BUILDDIR)/$(BINS)
@install -D -t $(DESTDIR)$(DATADIR)/applications data/mathfairy.desktop
@install -D -t $(DESTDIR)$(DATADIR)/pixmaps data/mathfairy.svg
clean:
@echo "Cleaning up"
@rm -r $(BUILDDIR)