-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
45 lines (37 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
BINS = frog
PKGS = gtkmm-4.0 gtk4-layer-shell-0 blkid libudev gstreamer-1.0 gstreamer-video-1.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 -std=c++20
CXXFLAGS += $(shell pkg-config --cflags $(PKGS)) -I "include"
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)/sys64/frog config.conf style.css
@install -D -t $(DESTDIR)$(DATADIR)/applications data/frog.desktop
@install -D -t $(DESTDIR)$(DATADIR)/pixmaps data/frog.png
clean:
@echo "Cleaning up"
@rm -r $(BUILDDIR)