-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
46 lines (34 loc) · 1.28 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
CFLAGS = -Wall -Wextra -Werror -O2 -I./lib
OS = $(shell uname)
BUILD_DIR = build
ALL_TARGETS = dreamscreen-cli dreamscreend
ifdef DEBUG
CFLAGS := $(CFLAGS) -DDEBUG
endif
ifeq ($(OS),Linux)
CC = gcc
endif
ifeq ($(OS),FreeBSD)
CC = clang
ALL_TARGETS = dreamscreen-cli
endif
.PHONY: all clean install uninstall cli daemon
all: build $(addprefix $(BUILD_DIR)/,$(ALL_TARGETS))
cli: build $(BUILD_DIR)/dreamscreen-cli
daemon: build $(BUILD_DIR)/dreamscreend
build:
@mkdir -p $(BUILD_DIR)
$(BUILD_DIR)/%: dreamscreen-cli/%.c
$(CC) $(CFLAGS) $< -o $@
$(BUILD_DIR)/%: dreamscreend/%.c
$(CC) $(CFLAGS) $< -o $@
clean:
$(RM) -r $(BUILD_DIR)
install:
install -m 755 $(BUILD_DIR)/dreamscreen-cli /usr/local/bin/
if test -f $(BUILD_DIR)/dreamscreend ; then install -m 755 $(BUILD_DIR)/dreamscreend /usr/local/bin/ ; fi
if test -f $(BUILD_DIR)/dreamscreend ; then install -m 744 $(BUILD_DIR)/dreamscreend.service /usr/lib/systemd/system/ ; fi
if test -f $(BUILD_DIR)/dreamscreend ; then systemctl daemon-reload ; fi
uninstall:
if test -f /usr/lib/systemd/system/dreamscreend.service ; then systemctl stop dreamscreend && systemctl disable dreamscreend && $(RM) /usr/lib/systemd/system/dreamscreend.service && systemctl daemon-reload ; fi
$(RM) /usr/local/bin/dreamscreen-cli /usr/local/bin/dreamscreend