File: Makefile

package info (click to toggle)
golang-github-segmentio-asm 1.2.0%2Bgit20231107.1cfacc8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: asm: 6,093; makefile: 32
file content (34 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download
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
SHELL = /bin/bash

dstdir := $(CURDIR)
srcdir := $(CURDIR)/build

sources := $(wildcard \
	$(srcdir)/*_asm.go \
	$(srcdir)/*/*_asm.go \
)

targets := \
	$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$(sources)) \
	$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$(sources))

internal := $(wildcard $(srcdir)/internal/*/*.go)

build: $(targets)

count ?= 5
bench ?= .
pkg ?= ...
benchcmp:
	go test -v -run _ -count $(count) -bench $(bench) ./$(pkg) -tags purego > /tmp/bench-$(subst .,dot,$(pkg))-purego.txt
	go test -v -run _ -count $(count) -bench $(bench) ./$(pkg)              > /tmp/bench-$(subst .,dot,$(pkg))-asm.txt
	benchstat /tmp/bench-$(subst .,dot,$(pkg))-{purego,asm}.txt

$(dstdir)/%_amd64.s $(dstdir)/%_amd64.go: $(srcdir)/%_asm.go $(internal)
	cd build && go run $(patsubst $(CURDIR)/build/%,%,$<) \
		-pkg   $(notdir $(realpath $(dir $<))) \
		-out   ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.s,$<)) \
		-stubs ../$(patsubst $(CURDIR)/%,%,$(patsubst $(srcdir)/%_asm.go,$(dstdir)/%_amd64.go,$<))
	go fmt $(dstdir)/$(*)_amd64.go

.PHONY: build benchmp