-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
56 lines (47 loc) · 1.68 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
.DEFAULT_GOAL := build
BIN := $(shell pwd)/bin/tdlib-server
SRC := ./cmd/tdlib-server/tdlib-server.go
BIN_PREFIX ?= /usr/local/bin
SYMLINK := $(BIN_PREFIX)/tdlib-server
TDLIB_DIR ?= /usr/local
TD_INC ?= $(TDLIB_DIR)/include
TD_LIB ?= $(TDLIB_DIR)/lib
.PHONY: build
build: check_tdlib
CGO_LDFLAGS="-L$(TD_LIB) -Wl,-rpath=$(TD_LIB) -ltdjson" \
CGO_CFLAGS=-I$(TD_INC) \
go build -o $(BIN) $(SRC)
@echo "\ntdlib-server installed at $(BIN)"
.PHONY: clean
clean:
rm -rf ./bin
.PHONY: install
install:
ln -sf $(BIN) $(SYMLINK)
@echo "\ntdlib-server installed at $(SYMLINK)"
.PHONY: uninstall
uninstall:
rm -f $(SYMLINK)
@echo "\ntdlib-server uninstalled from $(SYMLINK)"
.PHONY: check_tdlib
check_tdlib:
@if [ ! -d "$(TD_INC)" ]; then \
echo "Error: TDLib include directory not found at $(TD_INC)."; \
echo "Please ensure that TDLIB_DIR environment variable is set correctly."; \
echo "Alternatively, you can set the TD_INC environment variable manually for include directory."; \
exit 1; \
fi
@if [ ! -d "$(TD_LIB)" ]; then \
echo "Error: TDLib library directory not found at $(TD_LIB)."; \
echo "Please ensure that TDLIB_DIR environment variable is set correctly."; \
echo "Alternatively, you can set the TD_LIB environment variable manually for library directory."; \
exit 1; \
fi
.PHONY: help
help:
@echo "Available commands:"
@echo " make build - Build the tdlib-server binary"
@echo " make clean - Remove the built binary and clean up"
@echo " make install - Install tdlib-server system-wide"
@echo " make uninstall - Uninstall tdlib-server system-wide"
@echo " make help - Display this help message"