forked from displaylink-rpm/displaylink-rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
138 lines (105 loc) · 4.03 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# Versions
#
DAEMON_VERSION := 5.3.1.34
DOWNLOAD_ID := 1576 # This id number comes off the link on the displaylink website
VERSION := 1.7.2
RELEASE := 2
#
# Dependencies
#
DAEMON_PKG := DisplayLink\ USB\ Graphics\ Software\ for\ Ubuntu\ $(DAEMON_VERSION).zip
EVDI_PKG := v$(VERSION).tar.gz
SPEC_FILE := displaylink.spec
# The following is a little clunky, but we need to ensure the resulting
# tarball expands the same way as the upstream tarball
EVDI_DEVEL_BRANCH := v1.7.x
EVDI_DEVEL_REPO := https://github.com/DisplayLink/evdi.git
EVDI_DEVEL_BASE_DIR := /var/tmp
EVDI_DEVEL := $(EVDI_DEVEL_BASE_DIR)/evdi-$(VERSION)
BUILD_DEPS := $(DAEMON_PKG) $(EVDI_PKG) $(SPEC_FILE)
#
# Targets
#
i386_RPM := i386/displaylink-$(VERSION)-$(RELEASE).i386.rpm
x86_64_RPM := x86_64/displaylink-$(VERSION)-$(RELEASE).x86_64.rpm
SRPM := displaylink-$(VERSION)-$(RELEASE).src.rpm
TARGETS := $(i386_RPM) $(x86_64_RPM) $(SRPM)
#
# Upstream checks
#
EVDI_GITHUB := https://api.github.com/repos/DisplayLink/evdi
define get_latest_prerelease
curl -s $(EVDI_GITHUB)/releases?per_page=1 \
-H "Accept: application/vnd.github.full+json" |\
grep tag_name | sed s/[^0-9\.]//g
endef
define get_release_version
echo -e "$(RELEASE)" | tr -d '[:space:]'
endef
define get_devel_date
curl -s $(EVDI_GITHUB)/branches/devel \
-H "Accept: application/vnd.github.full+json" |\
grep date | head -1 | cut -d: -f 2- |\
sed s/[^0-9TZ]//g
endef
#
# PHONY targets
#
.PHONY: all rpm srpm devel rawhide clean clean-rawhide clean-mainline clean-all versions
all: $(TARGETS)
rpm: $(i386_RPM) $(x86_64_RPM)
srpm: $(SRPM)
devel: $(EVDI_DEVEL)
cd $(EVDI_DEVEL) && git pull
tar -z -c -f $(EVDI_PKG) -C $(EVDI_DEVEL_BASE_DIR) evdi-$(VERSION)
rawhide:
@echo Checking last upstream commit date...
$(MAKE) RELEASE="`$(get_release_version)`.rawhide.`$(get_devel_date)`" devel all
clean-rawhide:
@echo Checking last upstream commit date...
$(MAKE) RELEASE="`$(get_release_version)`.rawhide.`$(get_devel_date)`" clean-mainline
clean-mainline:
rm -rf $(TARGETS) $(EVDI_DEVEL) $(EVDI_PKG)
clean: clean-mainline clean-rawhide
clean-all:
rm -rf i386/*.rpm x86_64/*.rpm displaylink*.src.rpm $(EVDI_PKG) $(EVDI_DEVEL)
# for testing our version construction
versions:
@echo VERSION: $(VERSION)
@echo Checking upstream version...
@version=`$(get_latest_prerelease)` && echo UPSTREAM: $$version
@echo Checking upstream version...done
@echo
@echo Checking last upstream commit date...
@devel_date=`$(get_devel_date)` && echo DEVEL_DATE: $$devel_date
@echo Checking last upstream commit date...done
#
# Real targets
#
$(EVDI_DEVEL):
git clone --depth 1 -b $(EVDI_DEVEL_BRANCH) $(EVDI_DEVEL_REPO) $(EVDI_DEVEL)
$(DAEMON_PKG):
wget --post-data="fileId=$(DOWNLOAD_ID)&accept_submit=Accept" -O $(DAEMON_PKG) \
https://www.displaylink.com/downloads/file?id=$(DOWNLOAD_ID)
$(EVDI_PKG):
wget -O v$(VERSION).tar.gz \
https://github.com/DisplayLink/evdi/archive/v$(VERSION).tar.gz
BUILD_DEFINES = \
--define "_topdir `pwd`" \
--define "_sourcedir `pwd`" \
--define "_rpmdir `pwd`" \
--define "_specdir `pwd`" \
--define "_srcrpmdir `pwd`" \
--define "_buildrootdir `mktemp -d /var/tmp/displayportXXXXXX`" \
--define "_builddir `mktemp -d /var/tmp/displayportXXXXXX`" \
--define "_release $(RELEASE)" \
--define "_daemon_version $(DAEMON_VERSION)" \
--define "_version $(VERSION)" \
--define "_tmppath `mktemp -d /var/tmp/displayportXXXXXX`" \
$(i386_RPM): $(BUILD_DEPS)
rpmbuild -bb $(BUILD_DEFINES) displaylink.spec --target=i386
$(x86_64_RPM): $(BUILD_DEPS)
rpmbuild -bb $(BUILD_DEFINES) displaylink.spec --target=x86_64
$(SRPM): $(BUILD_DEPS)
rpmbuild -bs $(BUILD_DEFINES) displaylink.spec