74 lines
2.1 KiB
Makefile
74 lines
2.1 KiB
Makefile
BUILD := $(shell date -u +%Y%m%d-%H%M%S)
|
|
OS := $(shell uname -s)
|
|
|
|
PREFIX = $(DESTDIR)/opt/TellusAgent
|
|
|
|
ifeq ($(CI_PIPELINE_CREATED_AT), )
|
|
VERSION := $(shell date -u +%Y%m%d-%H%M%S)
|
|
else
|
|
VERSION := $(shell date -u -d "$(CI_PIPELINE_CREATED_AT)" +%Y%m%d-%H%M%S)
|
|
endif
|
|
|
|
ifeq ($(OS), Linux)
|
|
ARCHITECTURE ?= $(shell $(CC) -dumpmachine | grep -o -E '^[^-]+')
|
|
ifeq ($(ARCHITECTURE), aarch64)
|
|
FLAGS += -march=armv8-a
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(OS), Darwin)
|
|
FLAGS += -Wno-deprecated-declarations
|
|
endif
|
|
|
|
OBJECTS = \
|
|
TellusAgent.o
|
|
|
|
FLAGS += -g -fno-omit-frame-pointer -O3 -MMD \
|
|
-DVERSION=\"$(VERSION)\" \
|
|
$(foreach directory, $(DIRECTORIES), -I$(directory)) -DBUILD=\"$(VERSION)\"
|
|
|
|
LIBS += $(foreach library, $(LIBRARIES), -l$(library))
|
|
|
|
CC ?= gcc
|
|
CFLAGS += $(FLAGS) -std=gnu99
|
|
|
|
ifneq ($(strip $(DEPENDENCIES)),)
|
|
FLAGS += $(shell pkg-config --cflags $(DEPENDENCIES))
|
|
LIBS += $(shell pkg-config --libs $(DEPENDENCIES))
|
|
endif
|
|
|
|
all: build
|
|
|
|
build: $(PREREQUISITES) $(OBJECTS)
|
|
$(CC) $(OBJECTS) $(FLAGS) $(LIBS) -o tellusagent
|
|
|
|
install:
|
|
install -D -d $(PREFIX)
|
|
install -o root -g root tellusagent $(PREFIX)
|
|
install -o root -g root tellusagent.sh $(PREFIX)
|
|
install -o root -g root tellusagent.conf $(PREFIX)
|
|
install -D -d $(DESTDIR)/lib/systemd/system/
|
|
ifeq ($(OS), Linux)
|
|
install -o root -g root systemd/tellusagent.service $(DESTDIR)/lib/systemd/system/
|
|
install -o root -g root systemd/tellusagent\@.service $(DESTDIR)/lib/systemd/system/
|
|
install -D -d $(DESTDIR)/lib/systemd/system-generators/
|
|
install -o root -g root systemd/tellusagent-generator $(DESTDIR)/lib/systemd/system-generators/
|
|
endif
|
|
ifeq ($(OS), Darwin)
|
|
# install -m 644 -o root -g root tellusagent.plist $(DESTDIR)/Library/LaunchDaemons
|
|
endif
|
|
|
|
clean:
|
|
rm -f $(PREREQUISITES) $(OBJECTS) tellusagent
|
|
|
|
debian-package:
|
|
./UpdateLog.sh tellusagent "Artem Prilutskiy <cyanide.burnout@gmail.com>" $(VERSION) > debian/changelog
|
|
dpkg-buildpackage --post-clean --no-sign -i -I -b
|
|
|
|
docker-image:
|
|
docker buildx build -t tellusagent:$(VERSION) -o type=tar,dest=tellusagent-docker.tar .
|
|
|
|
macos-archive: build
|
|
zip ../TellusAgent-macOS.zip tellusagent tellusagent.sh tellusagent.conf tellusagent.plist
|
|
|
|
.PHONY: all build clean install
|