-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
112 lines (86 loc) · 2.92 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
104
105
106
107
108
109
110
111
# velox: Makefile
include config.mk
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share
LIBDIR ?= $(PREFIX)/lib
LIBEXECDIR ?= $(PREFIX)/libexec
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
PKG_CONFIG ?= pkg-config
WAYLAND_SCANNER ?= wayland-scanner
VERSION_MAJOR := 0
VERSION_MINOR := 1
VERSION := $(VERSION_MAJOR).$(VERSION_MINOR)
TARGETS := velox.pc velox
SUBDIRS := protocol clients
CLEAN_FILES := $(TARGETS)
VELOX_PACKAGES = swc xkbcommon libinput
VELOX_SOURCES = \
config.c \
layout.c \
screen.c \
tag.c \
util.c \
velox.c \
window.c \
protocol/velox-protocol.c
ifeq ($(if $(V),$(V),0), 0)
define quiet
@echo " $1 $@"
@$(if $2,$2,$($1))
endef
else
quiet = $(if $2,$2,$($1))
endif
VELOX_OBJECTS = $(VELOX_SOURCES:%.c=%.o)
VELOX_PACKAGE_CFLAGS ?= $(call pkgconfig,$(VELOX_PACKAGES),cflags,CFLAGS)
VELOX_PACKAGE_LIBS ?= $(call pkgconfig,$(VELOX_PACKAGES),libs,LIBS)
CLEAN_FILES += $(VELOX_OBJECTS)
FINAL_CFLAGS = $(CFLAGS) -std=c99
FINAL_CPPFLAGS = $(CPPFLAGS) -D_XOPEN_SOURCE=700 \
-DVELOX_LIBEXEC='"$(LIBEXECDIR)/velox"'
# Warning/error flags
FINAL_CFLAGS += -Werror=implicit-function-declaration -Werror=implicit-int \
-Werror=pointer-sign -Werror=pointer-arith \
-Wall -Wno-missing-braces
ifeq ($(ENABLE_DEBUG),1)
FINAL_CPPFLAGS += -DENABLE_DEBUG=1
FINAL_CFLAGS += -g
else
FINAL_CPPFLAGS += -DNDEBUG
endif
compile = $(call quiet,CC) $(FINAL_CPPFLAGS) $(FINAL_CFLAGS) -c -o $@ $< \
-MMD -MP -MF .deps/$(basename $<).d -MT $(basename $@).o
link = $(call quiet,CCLD,$(CC)) $(LDFLAGS) -o $@ $^
pkgconfig = $(foreach pkg,$(1),$(if $($(pkg)_$(3)),$($(pkg)_$(3)), \
$(shell $(PKG_CONFIG) --$(2) $(pkg))))
.PHONY: all
all: build
include $(foreach dir,$(SUBDIRS),$(dir)/local.mk)
.PHONY: build
build: $(SUBDIRS:%=build-%) $(TARGETS)
.deps:
@mkdir $@
%.o: %.c | .deps
$(compile) $(VELOX_PACKAGE_CFLAGS)
# Explicitly state dependencies on generated files
screen.o tag.o: protocol/velox-server-protocol.h
velox: $(VELOX_OBJECTS)
$(link) $(VELOX_PACKAGE_LIBS) -lm
velox.pc: velox.pc.in
$(call quiet,GEN,sed) \
-e "s:@VERSION@:$(VERSION):" \
-e "s:@DATADIR@:$(DATADIR):" \
$< > $@
$(foreach dir,BIN PKGCONFIG,$(DESTDIR)$($(dir)DIR)) \
$(foreach dir,DATA LIBEXEC,$(DESTDIR)$($(dir)DIR)/velox):
mkdir -p $@
.PHONY: install
install: $(SUBDIRS:%=install-%) $(TARGETS) \
| $(DESTDIR)$(BINDIR) $(DESTDIR)$(PKGCONFIGDIR)
install -m 755 velox $(DESTDIR)$(BINDIR)
install -m 644 velox.pc $(DESTDIR)$(PKGCONFIGDIR)
.PHONY: clean
clean:
rm -rf $(CLEAN_FILES)
-include .deps/*.d