-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
175 lines (139 loc) · 4.44 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
PWD := $(shell pwd)
CD := cd
TOUCH := touch
MKDIR := mkdir -p
CP := cp -rf -t
RM := rm -rfv
CURL := curl -fLo
COMPANY_NAME ?= ONLYOFFICE
PRODUCT_NAME ?= DocumentBuilder
COMPANY_NAME_LOW = $(shell echo $(COMPANY_NAME) | tr A-Z a-z)
PRODUCT_NAME_LOW = $(shell echo $(PRODUCT_NAME) | tr A-Z a-z)
PUBLISHER_NAME ?= Ascensio System SIA
PUBLISHER_URL ?= http://onlyoffice.com
SUPPORT_URL ?= http://support.onlyoffice.com
SUPPORT_MAIL ?= [email protected]
PRODUCT_VERSION ?= 0.0.0
BUILD_NUMBER ?= 0
BRANDING_DIR ?= .
PACKAGE_NAME := $(COMPANY_NAME_LOW)-$(PRODUCT_NAME_LOW)
UNAME_M ?= $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
RPM_ARCH := x86_64
DEB_ARCH := amd64
WIN_ARCH := x64
TAR_ARCH := x86_64
ARCHITECTURE := 64
endif
ifneq ($(filter %86,$(UNAME_M)),)
RPM_ARCH := i386
DEB_ARCH := i386
WIN_ARCH := x86
TAR_ARCH := i386
ARCHITECTURE := 32
endif
ifneq ($(filter aarch%,$(UNAME_M)),)
RPM_ARCH := aarch64
DEB_ARCH := arm64
TAR_ARCH := aarch64
ARCHITECTURE := arm64
endif
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
PLATFORM := linux
SRC ?= ../build_tools/out/linux_$(ARCHITECTURE)/$(COMPANY_NAME_LOW)/$(PRODUCT_NAME_LOW)/*
DB_PREFIX := $(COMPANY_NAME_LOW)/$(PRODUCT_NAME_LOW)
PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER)
endif
BUILD_DIR = build
RPM_BUILD_DIR := rpm/build
RPM_PACKAGE_DIR := $(RPM_BUILD_DIR)/RPMS/$(RPM_ARCH)
RPM := $(RPM_PACKAGE_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION)$(RPM_RELEASE_SUFFIX).$(RPM_ARCH).rpm
DEB := deb/$(PACKAGE_NAME)_$(PACKAGE_VERSION)$(DEB_RELEASE_SUFFIX)_$(DEB_ARCH).deb
TAR := tar/$(PACKAGE_NAME)-$(PACKAGE_VERSION)$(TAR_RELEASE_SUFFIX)-$(TAR_ARCH).tar.xz
LINUX_DEPS += $(BUILD_DIR)/usr/bin/$(PACKAGE_NAME)
DEB_DEPS += deb/build/debian/source/format
DEB_DEPS += deb/build/debian/changelog
DEB_DEPS += deb/build/debian/compat
DEB_DEPS += deb/build/debian/control
DEB_DEPS += deb/build/debian/copyright
DEB_DEPS += deb/build/debian/rules
DEB_DEPS += deb/build/debian/$(PACKAGE_NAME).install
DEB_DEPS += deb/build/debian/$(PACKAGE_NAME).links
RPM_DEPS += rpm/$(PACKAGE_NAME).spec
M4_PARAMS += -D M4_COMPANY_NAME=$(COMPANY_NAME)
M4_PARAMS += -D M4_PRODUCT_NAME=$(PRODUCT_NAME)
M4_PARAMS += -D M4_PACKAGE_NAME=$(PACKAGE_NAME)
M4_PARAMS += -D M4_PACKAGE_VERSION=$(PACKAGE_VERSION)$(DEB_RELEASE_SUFFIX)
M4_PARAMS += -D M4_DB_PREFIX=$(DB_PREFIX)
M4_PARAMS += -D M4_DEB_ARCH=$(DEB_ARCH)
M4_PARAMS += -D M4_RPM_ARCH=$(RPM_ARCH)
M4_PARAMS += -D M4_WIN_ARCH=$(WIN_ARCH)
M4_PARAMS += -D M4_PUBLISHER_NAME='$(PUBLISHER_NAME)'
M4_PARAMS += -D M4_PUBLISHER_URL='$(PUBLISHER_URL)'
M4_PARAMS += -D M4_SUPPORT_MAIL='$(SUPPORT_MAIL)'
M4_PARAMS += -D M4_SUPPORT_URL='$(SUPPORT_URL)'
M4_PARAMS += -D M4_BRANDING_DIR='$(abspath $(BRANDING_DIR))'
.PHONY: all clean deb rpm tar exe zip packages
all: deb rpm tar
rpm: $(RPM)
rpm_aarch64 : ARCHITECTURE = arm64
rpm_aarch64 : RPM_ARCH = aarch64
rpm_aarch64 : $(RPM)
deb: $(DEB)
tar: $(TAR)
exe: $(EXE)
zip: $(ZIP)
clean :
rm -rf \
$(BUILD_DIR) \
deb*/build \
deb*/*.buildinfo \
deb*/*.changes \
deb*/*.ddeb \
deb*/*.deb \
rpm*/build \
rpm*/$(PACKAGE_NAME).spec \
tar
$(BUILD_DIR) : $(LINUX_DEPS)
$(MKDIR) $@/opt/$(DB_PREFIX)
$(CP) $@/opt/$(DB_PREFIX) $(SRC)
$(BUILD_DIR)/usr/bin/$(PACKAGE_NAME) : common/documentbuilder.sh.m4
mkdir -p $(@D)
m4 $(M4_PARAMS) $< > $@
chmod +x $@
$(RPM): $(BUILD_DIR) $(RPM_DEPS)
$(CD) rpm && rpmbuild -bb \
--define '_topdir $(PWD)/$(RPM_BUILD_DIR)' \
--define '_package_name $(PACKAGE_NAME)' \
--define '_product_version $(PRODUCT_VERSION)' \
--define '_build_number $(BUILD_NUMBER)$(RPM_RELEASE_SUFFIX)' \
--define '_publisher_name $(PUBLISHER_NAME)' \
--define '_publisher_url $(PUBLISHER_URL)' \
--define '_support_mail $(SUPPORT_MAIL)' \
--define '_db_prefix $(DB_PREFIX)' \
--define '_binary_payload w7.xzdio' \
--target $(RPM_ARCH) \
$(PACKAGE_NAME).spec
deb/build/debian/% : deb/template/%
mkdir -pv $(@D) && cp -fv $< $@
deb/build/debian/% : deb/template/%.m4
mkdir -pv $(@D) && m4 $(M4_PARAMS) $< > $@
deb/build/debian/$(PACKAGE_NAME).% : deb/template/package.%.m4
mkdir -pv $(@D) && m4 $(M4_PARAMS) $< > $@
$(DEB): $(BUILD_DIR) $(DEB_DEPS)
cd deb/build && dpkg-buildpackage -b -uc -us -a$(DEB_ARCH)
$(TAR): $(BUILD_DIR)
mkdir -p $(@D)
tar --owner=0 --group=0 -C $(BUILD_DIR) -cJf $@ \
$(patsubst $(BUILD_DIR)/%,%,$(wildcard $(BUILD_DIR)/*))
% : %.m4
m4 $(M4_PARAMS) $< > $@
rpm/$(PACKAGE_NAME).spec : rpm/package.spec
cp -f $< $@
ifeq ($(PLATFORM),linux)
PACKAGES += deb
PACKAGES += rpm
# PACKAGES += tar
endif
packages: $(PACKAGES)