1
0
Fork 0
mirror of https://github.com/alice-lg/birdwatcher.git synced 2025-03-09 00:00:05 +01:00
birdwatcher/Makefile

134 lines
2.7 KiB
Makefile
Raw Permalink Normal View History

#
2018-07-20 15:08:34 +02:00
# Birdseye Makefile
#
PROG=birdwatcher
ARCH=amd64
APP_VERSION=$(shell cat VERSION)
VERSION=$(APP_VERSION)_$(shell git rev-parse --short HEAD)
2016-11-24 15:56:59 +01:00
BUILD_SERVER=''
SYSTEM_INIT=systemd
DIST=DIST/
REMOTE_DIST=$(PROG)-$(DIST)
RPM=$(PROG)-$(VERSION)-1.x86_64.rpm
LOCAL_RPMS=RPMS
# OS Detection
UNAME=$(shell uname)
ifeq ($(UNAME), Darwin)
TARGET=osx
2021-03-20 11:46:00 +01:00
endif
ifeq ($(UNAME), FreeBSD)
TARGET=freebsd
endif
ifeq ($(UNAME), Linux)
TARGET=linux
endif
2021-03-20 11:46:00 +01:00
ifneq ($(UNAME),$(filter $(UNAME),Darwin FreeBSD Linux))
$(error error: Unkown OS )
endif
2023-04-21 14:04:21 +02:00
LDFLAGS_STATIC=-ldflags="-extldflags '-static'"
all: $(TARGET)
@echo "Built $(VERSION) @ $(TARGET)"
osx:
2019-07-18 13:45:19 +02:00
GO111MODULE=on GOARCH=$(ARCH) GOOS=darwin go build -o $(PROG)-osx-$(ARCH)
linux:
2019-07-18 13:45:19 +02:00
GO111MODULE=on GOARCH=$(ARCH) GOOS=linux go build -o $(PROG)-linux-$(ARCH)
2021-03-20 11:46:00 +01:00
freebsd:
GO111MODULE=on GOARCH=$(ARCH) GOOS=freebsd go build -o $(PROG)-freebsd-$(ARCH)
2023-04-21 14:04:21 +02:00
linux_static:
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) \
go build $(CFLAGS) \
-a $(LDFLAGS_STATIC) \
-o $(PROG)-linux-$(ARCH)
2016-11-24 15:56:59 +01:00
build_server:
ifeq ($(BUILD_SERVER), '')
$(error BUILD_SERVER not configured)
endif
dist: clean linux
2018-07-20 15:08:34 +02:00
mkdir -p $(DIST)opt/birdwatcher/birdwatcher/bin
mkdir -p $(DIST)etc/birdwatcher
2016-11-30 13:43:39 +01:00
ifeq ($(SYSTEM_INIT), systemd)
# Installing systemd services
mkdir -p $(DIST)usr/lib/systemd/system/
cp install/systemd/* $(DIST)usr/lib/systemd/system/.
else
# Installing upstart configuration
mkdir -p $(DIST)/etc/init/
cp install/upstart/init/* $(DIST)etc/init/.
endif
# Copy config and startup script
2018-07-20 15:08:34 +02:00
cp etc/birdwatcher/* DIST/etc/birdwatcher/.
rm -f DIST/etc/birdwatcher/*.local.*
# Copy bin
2018-07-20 15:08:34 +02:00
cp $(PROG)-linux-$(ARCH) DIST/opt/birdwatcher/birdwatcher/bin/.
2017-04-11 10:22:06 +02:00
release: linux
mkdir -p ../birdseye-static/birdwatcher-builds/$(APP_VERSION)/
cp birdwatcher-linux-amd64 ../birdseye-static/birdwatcher-builds/$(APP_VERSION)/
rm -f ../birdseye-static/birdwatcher-builds/latest
2018-07-20 15:08:34 +02:00
cd ../birdseye-static/birdwatcher-builds && ln -s $(APP_VERSION) latest
2017-04-11 10:22:06 +02:00
rpm: dist
# Clear tmp failed build (if any)
2016-12-06 17:46:52 +01:00
mkdir -p $(LOCAL_RPMS)
# Create RPM from dist
fpm -s dir -t rpm -n $(PROG) -v $(VERSION) -C $(DIST) \
2018-07-20 15:08:34 +02:00
--config-files /etc/birdwatcher/birdwatcher.conf \
opt/ etc/
mv $(RPM) $(LOCAL_RPMS)
2016-11-24 15:56:59 +01:00
remote_rpm: build_server dist
2016-11-30 13:16:39 +01:00
mkdir -p $(LOCAL_RPMS)
# Copy distribution to build server
ssh $(BUILD_SERVER) -- rm -rf $(REMOTE_DIST)
scp -r $(DIST) $(BUILD_SERVER):$(REMOTE_DIST)
ssh $(BUILD_SERVER) -- fpm -s dir -t rpm -n $(PROG) -v $(VERSION) -C $(REMOTE_DIST) \
2018-07-20 15:08:34 +02:00
--config-files /etc/birdwatcher/birdwatcher.conf \
opt/ etc/
# Get rpm from server
scp $(BUILD_SERVER):$(RPM) $(LOCAL_RPMS)/.
2019-03-20 11:23:02 +01:00
.PHONY: test clean
test:
go test -v
cd endpoints/ && go test -v
cd bird/ && go test -v
clean:
rm -f $(PROG)-osx-$(ARCH)
rm -f $(PROG)-linux-$(ARCH)
rm -rf $(DIST)
2019-03-20 11:23:02 +01:00