summaryrefslogtreecommitdiff
path: root/debian/rules.d/binary-go.mk
blob: 88d767c910ddbb44a97c1d57c82e6787e4e767a4 (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
335
ifeq ($(with_libgo),yes)
  $(lib_binaries) += libgo
endif
ifeq ($(with_lib64go),yes)
  $(lib_binaries) += lib64go
endif
ifeq ($(with_lib32go),yes)
  $(lib_binaries) += lib32go
endif
ifeq ($(with_libn32go),yes)
  $(lib_binaries) += libn32go
endif
ifeq ($(with_libx32go),yes)
  $(lib_binaries) += libx32go
endif

arch_binaries  := $(arch_binaries) gccgo
ifneq (,$(filter yes, $(biarch64) $(biarch32) $(biarchn32) $(biarchx32)))
  arch_binaries  := $(arch_binaries) gccgo-multi
endif
ifneq ($(DEB_CROSS),yes)
  ifneq ($(GFDL_INVARIANT_FREE),yes)
    indep_binaries := $(indep_binaries) go-doc
  endif
endif

p_go	= gccgo$(pkg_ver)$(cross_bin_arch)
p_go_m	= gccgo$(pkg_ver)-multilib$(cross_bin_arch)
p_god	= gccgo$(pkg_ver)-doc
p_golib	= libgo$(GO_SONAME)$(cross_lib_arch)

d_go	= debian/$(p_go)
d_go_m	= debian/$(p_go_m)
d_god	= debian/$(p_god)
d_golib	= debian/$(p_golib)

dirs_go = \
	$(docdir)/$(p_xbase)/go \
	$(PF)/bin \
	$(gcc_lexec_dir) \
	$(gcc_lib_dir) \
	$(PF)/include \
	$(PF)/share/man/man1
files_go = \
	$(PF)/bin/$(cmd_prefix)gccgo$(pkg_ver) \
	$(gcc_lexec_dir)/{cgo,go1} \
	$(PF)/share/man/man1/{go,gofmt}$(pkg_ver).1

ifneq (,$(filter $(build_type), build-native cross-build-native))
  files_go += \
	$(PF)/bin/{go,gofmt}$(pkg_ver)
endif

ifneq ($(GFDL_INVARIANT_FREE),yes)
  files_go += \
	$(PF)/share/man/man1/$(cmd_prefix)gccgo$(pkg_ver).1
endif

ifeq ($(with_standalone_go),yes)

  dirs_go += \
	$(gcc_lib_dir)/include \
	$(PF)/share/man/man1

# XXX: what about triarch mapping?
  files_go += \
	$(PF)/bin/{cpp,gcc,gcov}$(pkg_ver) \
	$(PF)/bin/$(cmd_prefix)gcc-{ar,ranlib,nm}$(pkg_ver) \
	$(PF)/share/man/man1/$(cmd_prefix)gcc-{ar,nm,ranlib}$(pkg_ver).1 \
	$(gcc_lexec_dir)/{cc1,collect2,lto1,lto-wrapper} \
	$(gcc_lexec_dir)/liblto_plugin.so{,.0,.0.0.0} \
	$(gcc_lib_dir)/{libgcc*,libgcov.a,*.o} \
	$(header_files) \
	$(shell test -e $(d)/$(gcc_lib_dir)/SYSCALLS.c.X \
		&& echo $(gcc_lib_dir)/SYSCALLS.c.X)

  ifeq ($(with_cc1),yes)
    files_go += \
	$(gcc_lib_dir)/plugin/libcc1plugin.so{,.0,.0.0.0}
  endif

  ifneq ($(GFDL_INVARIANT_FREE),yes)
    files_go += \
	$(PF)/share/man/man1/{cpp,gcc,gcov}$(pkg_ver).1
  endif

  ifeq ($(biarch64),yes)
    files_go += $(gcc_lib_dir)/$(biarch64subdir)/{libgcc*,libgcov.a,*.o}
  endif
  ifeq ($(biarch32),yes)
    files_go += $(gcc_lib_dir)/$(biarch32subdir)/{libgcc*,*.o}
  endif
  ifeq ($(biarchn32),yes)
    files_go += $(gcc_lib_dir)/$(biarchn32subdir)/{libgcc*,libgcov.a,*.o}
  endif
  ifeq ($(biarchx32),yes)
    files_go += $(gcc_lib_dir)/$(biarchx32subdir)/{libgcc*,libgcov.a,*.o}
  endif
endif

# ----------------------------------------------------------------------
define __do_gccgo
	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_COMPAT=2 dh_movefiles -p$(p_l) \
		$(usr_lib$(2))/libgo.so.* $(usr_lib$(2))/go

	debian/dh_doclink -p$(p_l) $(p_base)
	debian/dh_doclink -p$(p_d) $(p_base)

	: # don't strip: https://gcc.gnu.org/ml/gcc-patches/2015-02/msg01722.html
	: # dh_strip -p$(p_l) --dbg-package=$(p_d)
	dh_compress -p$(p_l) -p$(p_d)
	dh_fixperms -p$(p_l) -p$(p_d)
	$(cross_makeshlibs) dh_makeshlibs -p$(p_l)
	$(call cross_mangle_shlibs,$(p_l))
	$(ignshld)DIRNAME=$(subst n,,$(2)) $(cross_shlibdeps) dh_shlibdeps -p$(p_l) \
		$(call shlibdirs_to_search, \
			$(subst go$(GO_SONAME),gcc$(GCC_SONAME),$(p_l)) \
			$(subst go$(GO_SONAME),atomic$(ATOMIC_SONAME),$(p_l)) \
		,$(2))
	$(call cross_mangle_substvars,$(p_l))
	$(cross_gencontrol) dh_gencontrol -p$(p_l) -p$(p_d) \
		-- -v$(DEB_VERSION) $(common_substvars)
	$(call cross_mangle_control,$(p_l))
	dh_installdeb -p$(p_l) -p$(p_d)
	dh_md5sums -p$(p_l) -p$(p_d)
	dh_builddeb -p$(p_l) -p$(p_d)

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

do_gccgo = $(call __do_gccgo,lib$(1)go$(GO_SONAME),$(1))

define install_gccgo_lib
	mv $(d)/$(usr_lib$(3))/$(1).a debian/$(4)/$(gcc_lib_dir$(3))/
	rm -f $(d)/$(usr_lib$(3))/$(1)*.{la,so}
	dh_link -p$(4) \
	  /$(usr_lib$(3))/$(1).so.$(2) /$(gcc_lib_dir$(3))/$(1).so
endef

# __do_gccgo_libgcc(flavour,package,todir,fromdir)
define __do_gccgo_libgcc
	$(if $(findstring gccgo,$(PKGSOURCE)),
		: # libgcc_s.so may be a linker script on some architectures
		set -e; \
		if [ -h $(4)/libgcc_s.so ]; then \
		  rm -f $(4)/libgcc_s.so; \
		  dh_link -p$(2) /$(libgcc_dir$(1))/libgcc_s.so.$(GCC_SONAME) \
		    $(3)/libgcc_s.so; \
		else \
		  mv $(4)/libgcc_s.so $(d)/$(3)/libgcc_s.so; \
		  dh_link -p$(2) /$(libgcc_dir$(1))/libgcc_s.so.$(GCC_SONAME) \
		    $(3)/libgcc_s.so.$(GCC_SONAME); \
		fi; \
		$(if $(1), dh_link -p$(2) /$(3)/libgcc_s.so \
		    $(gcc_lib_dir)/libgcc_s_$(1).so;)
	)
endef

define do_go_dev
	dh_installdirs -p$(2) $(gcc_lib_dir$(1))
	DH_COMPAT=2 dh_movefiles -p$(2) \
		$(gcc_lib_dir$(1))/{libgobegin,libnetgo}.a
	$(if $(filter yes, $(with_standalone_go)), \
	  $(call install_gccgo_lib,libgomp,$(GOMP_SONAME),$(1),$(2)))
	$(call install_gccgo_lib,libgo,$(GO_SONAME),$(1),$(2))
	$(call __do_gccgo_libgcc,$(1),$(2),$(gcc_lib_dir$(1)),$(d)/$(usr_lib$(1)))
endef
# ----------------------------------------------------------------------
$(binary_stamp)-libgo: $(install_stamp)
	$(call do_gccgo,)

$(binary_stamp)-lib64go: $(install_stamp)
	$(call do_gccgo,64)

$(binary_stamp)-lib32go: $(install_stamp)
	$(call do_gccgo,32)

$(binary_stamp)-libn32go: $(install_stamp)
	$(call do_gccgo,n32)

$(binary_stamp)-libx32go: $(install_stamp)
	$(call do_gccgo,x32)

# ----------------------------------------------------------------------
$(binary_stamp)-gccgo: $(install_stamp)
	dh_testdir
	dh_testroot
	mv $(install_stamp) $(install_stamp)-tmp

	rm -rf $(d_go)
	dh_installdirs -p$(p_go) $(dirs_go)

	mv $(d)/$(usr_lib)/{libgobegin,libnetgo}.a \
		$(d)/$(gcc_lib_dir)/
	if [ -f $(d)/$(usr_lib64)/libgobegin.a ]; then \
	    mv $(d)/$(usr_lib64)/{libgobegin,libnetgo}.a \
		$(d)/$(gcc_lib_dir)/64/; \
	fi
	if [ -f $(d)/$(usr_lib32)/libgobegin.a ]; then \
	    mv $(d)/$(usr_lib32)/{libgobegin,libnetgo}.a \
		$(d)/$(gcc_lib_dir)/32/; \
	fi
	if [ -f $(d)/$(usr_libn32)/libgobegin.a ]; then \
	    mv $(d)/$(usr_libn32)/{libgobegin,libnetgo}.a \
		$(d)/$(gcc_lib_dir)/n32/; \
	fi
	if [ -f $(d)/$(usr_libx32)/libgobegin.a ]; then \
	    mv $(d)/$(usr_libx32)/{libgobegin,libnetgo}.a \
		$(d)/$(gcc_lib_dir)/x32/; \
	fi

	$(call do_go_dev,,$(p_go))

	DH_COMPAT=2 dh_movefiles -p$(p_go) $(files_go)

ifneq (,$(findstring gccgo,$(PKGSOURCE)))
	rm -rf $(d_go)/$(gcc_lib_dir)/include/cilk
	rm -rf $(d_go)/$(gcc_lib_dir)/include/openacc.h
endif

ifneq ($(DEB_CROSS),yes)
	ln -sf gccgo$(pkg_ver) \
	    $(d_go)/$(PF)/bin/$(DEB_TARGET_GNU_TYPE)-gccgo$(pkg_ver)
	ln -sf gccgo$(pkg_ver) \
	    $(d_go)/$(PF)/bin/$(TARGET_ALIAS)-gccgo$(pkg_ver)
ifneq ($(GFDL_INVARIANT_FREE),yes)
	ln -sf gccgo$(pkg_ver).1 \
	    $(d_go)/$(PF)/share/man/man1/$(DEB_TARGET_GNU_TYPE)-gccgo$(pkg_ver).1
	ln -sf gccgo$(pkg_ver).1 \
	    $(d_go)/$(PF)/share/man/man1/$(TARGET_ALIAS)-gccgo$(pkg_ver).1
endif
endif

ifeq ($(with_standalone_go),yes)
  ifneq ($(DEB_CROSS),yes)
	for i in gcc gcov gcc-ar gcc-nm gcc-ranlib; do \
	  ln -sf $$i$(pkg_ver) \
	    $(d_go)/$(PF)/bin/$(DEB_TARGET_GNU_TYPE)-$$i$(pkg_ver); \
	  ln -sf $$i$(pkg_ver) \
	    $(d_go)/$(PF)/bin/$(TARGET_ALIAS)-$$i$(pkg_ver); \
	done
    ifneq ($(GFDL_INVARIANT_FREE),yes)
	for i in gcc gcov gcc-ar gcc-nm gcc-ranlib; do \
	  ln -sf gcc$(pkg_ver).1 \
	    $(d_go)/$(PF)/share/man/man1/$(DEB_TARGET_GNU_TYPE)-$$i$(pkg_ver).1; \
	  ln -sf $$i$(pkg_ver).1 \
	    $(d_go)/$(PF)/share/man/man1/$(TARGET_ALIAS)-$$i$(pkg_ver).1; \
	done
    endif
  endif
  ifeq ($(with_gomp),yes)
	mv $(d)/$(usr_lib)/libgomp*.spec $(d_go)/$(gcc_lib_dir)/
  endif
  ifeq ($(with_cc1),yes)
	rm -f $(d)/$(usr_lib)/libcc1.so
	dh_link -p$(p_go) \
		/$(usr_lib)/libcc1.so.$(CC1_SONAME) /$(gcc_lib_dir)/libcc1.so
  endif
endif

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

#	cp -p $(srcdir)/gcc/go/ChangeLog \
#		$(d_go)/$(docdir)/$(p_base)/go/changelog
	debian/dh_rmemptydirs -p$(p_go)

	dh_strip -p$(p_go) -X/cgo -Xgo$(pkg_ver) -Xgofmt$(pkg_ver) \
	  $(if $(unstripped_exe),-X/go1)
	dh_compress -p$(p_go)
	dh_fixperms -p$(p_go)
	dh_shlibdeps -p$(p_go)
	dh_gencontrol -p$(p_go) -- -v$(DEB_VERSION) $(common_substvars)
	dh_installdeb -p$(p_go)
	dh_md5sums -p$(p_go)
	dh_builddeb -p$(p_go)

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

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

	rm -rf $(d_go_m)
	dh_installdirs -p$(p_go_m) $(docdir)

	$(foreach flavour,$(flavours), \
		$(call do_go_dev,$(flavour),$(p_go_m)))

	debian/dh_doclink -p$(p_go_m) $(p_xbase)
	debian/dh_rmemptydirs -p$(p_go_m)
	dh_strip -p$(p_go_m)
	dh_compress -p$(p_go_m)
	dh_fixperms -p$(p_go_m)
	dh_shlibdeps -p$(p_go_m)
	dh_gencontrol -p$(p_go_m) -- -v$(DEB_VERSION) $(common_substvars)
	dh_installdeb -p$(p_go_m)
	dh_md5sums -p$(p_go_m)
	dh_builddeb -p$(p_go_m)

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

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

	rm -rf $(d_god)
	dh_installdirs -p$(p_god) \
		$(docdir)/$(p_xbase)/go \
		$(PF)/share/info
	DH_COMPAT=2 dh_movefiles -p$(p_god) \
		$(PF)/share/info/gccgo*

	debian/dh_doclink -p$(p_god) $(p_xbase)
	dh_installdocs -p$(p_god)
	rm -f $(d_god)/$(docdir)/$(p_xbase)/copyright
	cp -p html/gccgo.html $(d_god)/$(docdir)/$(p_xbase)/go/

	dh_compress -p$(p_god)
	dh_fixperms -p$(p_god)
	dh_installdeb -p$(p_god)
	dh_gencontrol -p$(p_god) -- -v$(DEB_VERSION) $(common_substvars)
	dh_md5sums -p$(p_god)
	dh_builddeb -p$(p_god)

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