-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
64 lines (50 loc) · 1.67 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
BINS = sysshell
PKGS = gtkmm-4.0 gtk4-layer-shell-0
SRCS = $(wildcard src/*.cpp src/libs/*.cpp src/extras/*.cpp)
OBJS = $(SRCS:.cpp=.o)
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share
CXXFLAGS += -Os -s -Wall -flto=auto -fno-exceptions
LDFLAGS += -Wl,-O1,--no-as-needed,-z,now,-z,pack-relative-relocs
CXXFLAGS += $(shell pkg-config --cflags $(PKGS))
LDFLAGS += $(shell pkg-config --libs $(PKGS))
PROTOS = $(wildcard proto/*.xml)
PROTO_HDRS = $(patsubst proto/%.xml, src/%.h, $(PROTOS))
PROTO_SRCS = $(patsubst proto/%.xml, src/%.c, $(PROTOS))
PROTO_OBJS = $(PROTO_SRCS:.c=.o)
JOB_COUNT := $(BINS) $(OBJS) $(PROTO_HDRS) $(PROTO_SRCS) $(PROTO_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
all: $(BINS)
install: $(BINS)
@echo "Installing..."
@install -D -t $(DESTDIR)$(BINDIR) $(BINS)
@install -D -t $(DESTDIR)$(DATADIR)/sys64/shell config.conf
clean:
@echo "Cleaning up"
@rm $(BINS) $(OBJS) $(PROTO_OBJS) $(PROTO_HDRS) $(PROTO_SRCS)
$(BINS): $(PROTO_HDRS) $(PROTO_SRCS) $(PROTO_OBJS) $(OBJS)
$(call progress, Linking $@)
@$(CXX) -o $(BINS) \
$(OBJS) \
$(PROTO_OBJS) \
$(CXXFLAGS) \
$(LDFLAGS) -lwayland-client
%.o: %.cpp
$(call progress, Compiling $@)
@$(CXX) -c $< -o $@ \
$(CXXFLAGS) \
-I include
%.o: %.c
$(call progress, Compiling $@)
@$(CC) -c $< -o $@ $(CFLAGS)
$(PROTO_HDRS): src/%.h : proto/%.xml
$(call progress, Creating $@)
@wayland-scanner client-header $< $@
$(PROTO_SRCS): src/%.c : proto/%.xml
$(call progress, Creating $@)
@wayland-scanner public-code $< $@