summaryrefslogtreecommitdiffstats
path: root/debian/rules.d/binary-rust.mk
blob: dcf4c48b0a39055c6664504db677486f2fa57d4c (plain)
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
ifneq ($(DEB_STAGE),rtlibs)
  ifeq (0,1)
  #ifneq (,$(filter yes, $(biarch64) $(biarch32) $(biarchn32)))
  #  arch_binaries  := $(arch_binaries) grs-multi
  #endif
  endif
  arch_binaries := $(arch_binaries) grs-nat grs-host
  ifeq ($(unprefixed_names),yes)
    arch_binaries := $(arch_binaries) grs
    indep_binaries := $(indep_binaries) grs-build
  endif

  #ifeq ($(with_rsdev),yes)
  #  $(lib_binaries) += libgrs-dev
  #endif
  #ifeq ($(with_libgrs),yes)
  #  $(lib_binaries) += libgrs
  #endif

  #ifneq ($(DEB_CROSS),yes)
  #  indep_binaries := $(indep_binaries) grs-doc
  #endif

  ifeq (0,1)
  ifeq ($(with_lib64grsdev),yes)
    $(lib_binaries)	+= lib64grs-dev
  endif
  ifeq ($(with_lib32grsdev),yes)
    $(lib_binaries)	+= lib32grs-dev
  endif
  ifeq ($(with_libn32grsdev),yes)
    $(lib_binaries)	+= libn32grs-dev
  endif
  ifeq ($(with_libx32grsdev),yes)
    $(lib_binaries)	+= libx32grs-dev
  endif

  ifeq ($(with_lib64grs),yes)
    $(lib_binaries)	+= lib64grs
  endif
  ifeq ($(with_lib32grs),yes)
    $(lib_binaries)	+= lib32grs
  endif
  ifeq ($(with_libn32grs),yes)
    $(lib_binaries)	+= libn32grs
  endif
  ifeq ($(with_libx32grs),yes)
    $(lib_binaries)	+= libx32grs
  endif
  endif
endif

p_grs_n		= gccrs$(pkg_ver)-$(subst _,-,$(TARGET_ALIAS))
p_grs_h		= gccrs$(pkg_ver)-for-host
p_grs_b		= gccrs$(pkg_ver)-for-build
p_grs           = gccrs$(pkg_ver)
p_grs_m		= gccrs$(pkg_ver)-multilib$(cross_bin_arch)
p_libgrs	= libgrs-$(GRS_SONAME)
p_libgrsdev	= libgrs$(pkg_ver)-dev
p_grsd		= grs$(pkg_ver)-doc

d_grs_n		= debian/$(p_grs_n)
d_grs_h		= debian/$(p_grs_h)
d_grs_b		= debian/$(p_grs_b)
d_grs           = debian/$(p_grs)
d_grs_m		= debian/$(p_grs_m)
d_libgrs	= debian/$(p_libgrs)
d_libgrsdev	= debian/$(p_libgrsdev)
d_grsd		= debian/$(p_grsd)

dirs_grs_n = \
	$(PF)/bin \
	$(PF)/share/man/man1 \
	$(gcc_lexec_dir) \
	usr/share/lintian/overrides

dirs_grs = \
	$(PF)/bin \
	$(PF)/share/man/man1
#ifneq ($(DEB_CROSS),yes)
#  dirs_grs += \
#	$(grs_include_dir)
#endif

files_grs_n = \
	$(PF)/bin/$(cmd_prefix)gccrs$(pkg_ver) \
	$(gcc_lexec_dir)/crab1

#    files_grs_n += \
#	$(PF)/share/man/man1/$(cmd_prefix)gccrs$(pkg_ver).1

dirs_libgrs = \
	$(PF)/lib \
	$(grs_include_dir) \
	$(gcc_lib_dir)

$(binary_stamp)-grs-nat: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_grs_n)
	dh_installdirs -p$(p_grs_n) $(dirs_grs_n)

	$(dh_compat2) dh_movefiles -p$(p_grs_n) $(files_grs_n)

	dh_installdirs -p$(p_grs_n)
	debian/dh_doclink -p$(p_grs_n) $(p_xbase)

ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTONS)))
	$(DWZ) \
	  $(d_grs_n)/$(gcc_lexec_dir)/crab1
endif
	dh_strip -p$(p_grs_n) \
	  $(if $(unstripped_exe),-X/crab1)
	dh_shlibdeps -p$(p_grs_n)

	echo '$(p_grs_n) binary: hardening-no-pie' \
	  > $(d_grs_n)/usr/share/lintian/overrides/$(p_grs_n)

	echo $(p_grs_n) >> debian/arch_binaries

	find $(d_grs_n) -type d -empty -delete

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)

$(binary_stamp)-grs-host: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp
	rm -rf $(d_grs_h)
	debian/dh_doclink -p$(p_grs_h) $(p_xbase)
	echo $(p_grs_h) >> debian/arch_binaries
	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)

$(binary_stamp)-grs-build: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp
	rm -rf $(d_grs_b)
	debian/dh_doclink -p$(p_grs_b) $(p_cpp_b)
	echo $(p_grs_b) >> debian/indep_binaries
	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)

$(binary_stamp)-grs: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_grs)
	dh_installdirs -p$(p_grs) $(dirs_grs)

	dh_installdocs -p$(p_grs)
	dh_installchangelogs -p$(p_grs) #src/gcc/rs/ChangeLog

	$(dh_compat2) dh_movefiles -p$(p_grs) $(files_grs)

	ln -sf $(cmd_prefix)gccrs$(pkg_ver) \
	    $(d_grs)/$(PF)/bin/gccrs$(pkg_ver)
#	ln -sf $(cmd_prefix)gccrs$(pkg_ver).1 \
#	    $(d_grs)/$(PF)/share/man/man1/gccrs$(pkg_ver).1
	dh_installdirs -p$(p_grs)
	debian/dh_doclink -p$(p_grs) $(p_xbase)

	echo $(p_grs) >> debian/arch_binaries

	find $(d_grs) -type d -empty -delete

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)

$(binary_stamp)-grs-multi: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_grs_m)
	dh_installdirs -p$(p_grs_m) $(docdir)

	debian/dh_doclink -p$(p_grs_m) $(p_xbase)

	dh_strip -p$(p_grs_m)
	dh_shlibdeps -p$(p_grs_m)
	echo $(p_grs_m) >> debian/arch_binaries

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)

define __do_libgrs
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_l) $(d_d)
	dh_installdirs -p$(p_l) \
		$(usr_lib$(2))
	$(dh_compat2) dh_movefiles -p$(p_l) \
		$(usr_lib$(2))/librspim.so.* \
		$(usr_lib$(2))/librscor.so.* \
		$(usr_lib$(2))/librsiso.so.* \
		$(usr_lib$(2))/librslog.so.* \
		$(usr_lib$(2))/librsmin.so.*

	debian/dh_doclink -p$(p_l) $(p_lbase)
	$(if $(with_dbg),debian/dh_doclink -p$(p_d) $(p_lbase))

	$(call do_strip_lib_dbg, $(p_l), $(p_d), $(v_dbg),,)
	: ln -sf libgrs.symbols debian/$(p_l).symbols
	$(cross_makeshlibs) dh_makeshlibs $(ldconfig_arg) -p$(p_l) \
		-- -a$(call mlib_to_arch,$(2)) || echo XXXXXXXXXXX ERROR $(p_l)
	rm -f debian/$(p_l).symbols
	$(call cross_mangle_shlibs,$(p_l))
	$(ignshld)DIRNAME=$(subst n,,$(2)) $(cross_shlibdeps) dh_shlibdeps -p$(p_l) \
		$(call shlibdirs_to_search, \
			$(subst grs-$(GRS_SONAME),gcc-s$(GCC_SONAME),$(p_l)) \
		,$(2)) \
		$(if $(filter yes, $(with_common_libs)),,-- -Ldebian/shlibs.common$(2))
	$(call cross_mangle_substvars,$(p_l))

	mkdir -p $(d_l)/usr/share/lintian/overrides; \
	( \
	  echo "$(p_l) binary: dev-pkg-without-shlib-symlink"; \
	  echo "$(p_l) binary: shared-lib-without-dependency-information"; \
	  echo "$(p_l) binary: package-name-doesnt-match-sonames"; \
	  echo "$(p_l) binary: library-not-linked-against-libc"; \
	) >> $(d_l)/usr/share/lintian/overrides/$(p_l)

	dh_lintian -p$(p_l)
	echo $(p_l) $(if $(with_dbg), $(p_d)) >> debian/$(lib_binaries)

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)
endef

# install_grs_lib(lib,soname,flavour,package,subdir)
#define install_grs_lib
#	mkdir -p debian/$(4)/$(gcc_lib_dir$(3))/$(5)
#	mv $(d)/$(usr_lib$(3))/$(1)*.a debian/$(4)/$(gcc_lib_dir$(3))/$(5)/.
#	rm -f $(d)/$(usr_lib$(3))/$(1)*.{la,so}
#	dh_link -p$(4) \
#	  /$(usr_lib$(3))/$(1).so.$(2) /$(gcc_lib_dir$(3))/$(5)/$(1).so
#endef
define install_grs_lib
	dh_link -p$(4) \
	  /$(usr_lib$(3))/$(1).so.$(2) /$(gcc_lib_dir$(3))/$(5)/$(1).so
	rm -f $(d)/$(usr_lib$(3))/$(1).so
	rm -f $(d)/$(usr_lib$(3))/$(1).a
endef

define __do_libgrs_dev
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_l)
	dh_installdirs -p$(p_l) \
		$(gcc_lib_dir$(2))

	: # install_grs_lib calls needed?

	$(if $(2),,
	$(dh_compat2) dh_movefiles -p$(p_l) \
		$(gcc_lexec_dir)/rs
	)

	$(call install_grs_lib,librspim,$(GRS_SONAME),$(2),$(p_l),rs/rspim)
	$(call install_grs_lib,librscor,$(GRS_SONAME),$(2),$(p_l),rs/rscor)
	$(call install_grs_lib,librsiso,$(GRS_SONAME),$(2),$(p_l),rs/rsiso)
	$(call install_grs_lib,librslog,$(GRS_SONAME),$(2),$(p_l),rs/rslog)
	$(call install_grs_lib,librsmin,$(GRS_SONAME),$(2),$(p_l),rs/rsmin)

	: # included in grs package
	rm -f $(d_l)/$(grs_include_dir)/__entrypoint.di

	debian/dh_doclink -p$(p_l) $(p_lbase)
	echo $(p_l) >> debian/$(lib_binaries)

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)
endef

do_libgrs = $(call __do_libgrs,lib$(1)grs-$(GRS_SONAME),$(1))
do_libgrs_dev = $(call __do_libgrs_dev,lib$(1)grs-$(BASE_VERSION)-dev,$(1))

# ----------------------------------------------------------------------
$(binary_stamp)-grs-doc: $(build_html_stamp) $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_grsd)
	dh_installdirs -p$(p_grsd) \
		$(docdir)/$(p_grs) \
		$(docdir)/$(p_xbase)/rs \
		$(PF)/share/info
	cp -p $(builddir)/gcc/doc/rs.info $(d_grsd)/$(PF)/share/info/grs.info
	cp -p html/grs.html $(d_grsd)/$(docdir)/$(p_xbase)/rs/
	ln -sf ../$(p_xbase)/rs/grs.html $(d_grsd)/$(docdir)/$(p_grs)/grs.html

	debian/dh_doclink -p$(p_grsd) $(p_xbase)
	dh_installdocs -p$(p_grsd)
	rm -f $(d_grsd)/$(docdir)/$(p_xbase)/copyright

	echo $(p_grsd) >> debian/indep_binaries

	trap '' 1 2 3 15; touch $@; mv $(install_stamp)-tmp $(install_stamp)


$(binary_stamp)-libgrs: $(install_stamp)
	$(call do_libgrs,)

$(binary_stamp)-lib64grs: $(install_stamp)
	$(call do_libgrs,64)

$(binary_stamp)-lib32grs: $(install_stamp)
	$(call do_libgrs,32)

$(binary_stamp)-libn32grs: $(install_stamp)
	$(call do_libgrs,n32)

$(binary_stamp)-libx32grs: $(install_stamp)
	$(call do_libgrs,x32)


$(binary_stamp)-libgrs-dev: $(install_stamp)
	$(call do_libgrs_dev,)

$(binary_stamp)-lib64grs-dev: $(install_stamp)
	$(call do_libgrs_dev,64)

$(binary_stamp)-lib32grs-dev: $(install_stamp)
	$(call do_libgrs_dev,32)

$(binary_stamp)-libx32grs-dev: $(install_stamp)
	$(call do_libgrs_dev,x32)

$(binary_stamp)-libn32grs-dev: $(install_stamp)
	$(call do_libgrs_dev,n32)