This repository has been archived by the owner on Nov 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
202 lines (151 loc) · 7.11 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
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
-include $(PARAMS_FILE)
APP ?= cam
GO ?= go
GOOS ?= linux
GOARCH ?= amd64
GOENV := GOROOT_FINAL=/test/ GOPATH=$(GOPATH) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM)
FAMILY ?= host
CMOS ?= unknown
CMOS_DRIVER ?= unknown
-include sdk/$(FAMILY)/Makefile.params
FAMILY_UPPERCASE := $(shell echo '$(FAMILY)' | tr '[:lower:]' '[:upper:]')
CHIP_UPPERCASE := $(shell echo '$(CHIP)' | tr '[:lower:]' '[:upper:]')
CGO_CFLAGS := -I$(abspath sdk/$(FAMILY)/include) -D$(FAMILY_UPPERCASE) -DLOGGER_C
#-D$(CHIP_UPPERCASE)
#TODO rework this
ifneq ($(CMOS),unknown)
#ifneq ($(CMOS_DRIVER),)
# CMOS := $(CMOS_DRIVER)
#endif
CMOS_TARGET := ../output/boards/$(BOARD)/cmos/lib_$(CMOS_DRIVER).a
endif
ifeq ($(APP),probe)
CMOS_TARGET :=
endif
CMOS_TAGS := $(CMOS) cmos_data_$(CMOS_DATA) cmos_control_$(CMOS_CONTROL) cmos_bus_$(CMOS_BUS)
GOTAGS_PROBE := gohisiprobe $(FAMILY) netgo nethttpomithttp2
GOTAGS_CAM := gohisicam $(FAMILY) $(CHIP) $(CMOS_TAGS) netgo nethttpomithttp2 openapi debug processing streamerJpeg streamerFile streamerRtsp streamerPipe
GOTAGS := $(GOTAGS_$(shell echo '$(APP)' | tr '[:lower:]' '[:upper:]'))
ifneq ($(wildcard ../hisilicon/$(FAMILY)/Makefile.params),)
LIB_TARGET := ../output/hisilicon/$(FAMILY)/lib$(FAMILY).a
CGO_LDFLAGS := $(abspath $(CMOS_TARGET)) $(abspath ../output/hisilicon/$(FAMILY)/lib$(FAMILY).a)
endif
CGOPARAMS := CGO_CFLAGS='$(CFLAGS) $(CGO_CFLAGS)' CGO_CFLAGS_ALLOW='.*' CGO_ENABLED=1 CGO_LDFLAGS='$(CGO_LDFLAGS) $(FAMILY_LDFLAGS)'
ifneq ($(strip $(shell git status --porcelain 2>/dev/null)),)
GIT_TREE_STATE=(dirty)
endif
GIT := $(shell git branch | grep \* | cut -d " " -f2) $(GIT_TREE_STATE)
SDKV := $(HISDK_ARCHIVE) $(HISDK)
GOCC :=$(shell $(GOENV) $(CGOPARAMS) $(GO) env | grep "CC=" | rev | cut -d '"' -f 2 | rev)
EMBEDDVARS := -X 'application/pkg/buildinfo.BuildDateTime=$(shell date --utc "+%Y-%m-%d %H:%M (UTC)")' \
-X 'application/pkg/buildinfo.GoVersion=$(shell $(GOENV) $(GO) version)' \
-X 'application/pkg/buildinfo.GccVersion=$(shell $(GOCC) --version | head -n 1)' \
-X 'application/pkg/buildinfo.BuildTags=$(GOTAGS)' \
-X 'application/pkg/buildinfo.BuildBranch=$(GIT)' \
-X 'application/pkg/buildinfo.Family=$(FAMILY)' \
-X 'application/pkg/buildinfo.SDK=$(SDKV)' \
-X 'application/pkg/buildinfo.CmosProfile=$(CMOS)'
#NO DEBUG SYMBOLS, COMMENT IF WANT TO TURN ON DEBUG
GODEBUG := -s -w
#-extldflags "-static"
#-linkmode "external"
guard:
@echo "guard"
gover:
$(GOENV) $(GO) version
goenv:
$(GOENV) $(GO) env
strip-ko:
$(STRIP) --strip-debug ./sdk/*/ko/*
LIBS := $(wildcard sdk/$(FAMILY)/lib/*.a)
../output/hisilicon/$(FAMILY)/lib$(FAMILY).a:
$(AR) rcsT ../output/hisilicon/$(FAMILY)/lib$(FAMILY).a $(LIBS)
#CMOS all in one archive
#CMOSES := $(wildcard pkg/mpp/cmos/$(FAMILY)/*/)
#CMOSDIRS := $(patsubst pkg/mpp/cmos/$(FAMILY)/%/, ../output/boards/$(BOARD)/cmos/%/, $(CMOSES))
#
#CMOSSRC := $(wildcard pkg/mpp/cmos/$(FAMILY)/*/*.c)
#CMOSOBJ := $(patsubst pkg/mpp/cmos/$(FAMILY)/%.c, ../output/boards/$(BOARD)/cmos/%.o, $(CMOSSRC))
#
#../output/boards/$(BOARD)/cmos/lib_cmoses.a: $(CMOSDIRS) $(CMOSOBJ)
# $(AR) rcs ../output/boards/$(BOARD)/cmos/lib_cmoses.a $(CMOSOBJ)
#
#../output/boards/$(BOARD)/cmos/%/:
# [ -d $@ ] || mkdir -p $@
#
#../output/boards/$(BOARD)/cmos/%.o: pkg/mpp/cmos/$(FAMILY)/%.c
# $(CC) $(CFLAGS) -I$(abspath sdk/$(FAMILY)/include) -c $< -o $@
#CMOS separate archive for each cmos
CMOSSRC := $(wildcard pkg/mpp/cmos/$(FAMILY)/$(CMOS_DRIVER)/*.c)
CMOSOBJ := $(patsubst pkg/mpp/cmos/$(FAMILY)/$(CMOS_DRIVER)/%.c, ../output/boards/$(BOARD)/cmos/$(CMOS_DRIVER)/%.o, $(CMOSSRC))
../output/boards/$(BOARD)/cmos/%/:
[ -d $@ ] || mkdir -p $@
../output/boards/$(BOARD)/cmos/$(CMOS_DRIVER)/%.o: pkg/mpp/cmos/$(FAMILY)/$(CMOS_DRIVER)/%.c
$(CC) $(CFLAGS) -I$(abspath sdk/$(FAMILY)/include) -c $< -o $@
../output/boards/$(BOARD)/cmos/lib_$(CMOS_DRIVER).a: ../output/boards/$(BOARD)/cmos/$(CMOS_DRIVER)/ $(CMOSOBJ)
$(AR) rcs ../output/boards/$(BOARD)/cmos/lib_$(CMOS_DRIVER).a $(CMOSOBJ)
pkg/ko/kobin_$(APP)_$(FAMILY).go:
GOPATH=$(GOPATH) $(GO) generate -tags "$(GOTAGS)" application/pkg/ko
generate: pkg/ko/kobin_$(APP)_$(FAMILY).go
make -C pkg/utils/regs
distrib:
mkdir distrib
deploy-dir-cam: distrib
rm -rf ./distrib/$(FAMILY)
mkdir -p ./distrib/$(FAMILY)/opt/www
mkdir -p ./distrib/$(FAMILY)/opt/storage
mkdir -p ./distrib/$(FAMILY)/opt/scripts
mkdir -p ./distrib/$(FAMILY)/opt/configs
mkdir -p ./distrib/$(FAMILY)/etc/init.d
cp -r ./www/* ./distrib/$(FAMILY)/opt/www
cp -r ./scripts/* ./distrib/$(FAMILY)/opt/scripts
cp ./init/run.sh ./distrib/$(FAMILY)/opt
cp ./init/S99gohisicam ./distrib/$(FAMILY)/etc/init.d/
if [ -f ../boards/$(BOARD)/config ]; then cp ../boards/$(BOARD)/config ./distrib/$(FAMILY)/opt/board.config; fi
cp ../application/configs/* ./distrib/$(FAMILY)/opt/configs/
cp -r ./init/tools ././distrib/$(FAMILY)/opt/
deploy-dir-probe: distrib
rm -rf ./distrib/$(FAMILY)
mkdir -p ./distrib/$(FAMILY)/etc/init.d
mkdir -p ./distrib/$(FAMILY)/opt
cp ./init/S99gohisiprobe ./distrib/$(FAMILY)/etc/init.d/
if [ -f ../boards/$(BOARD)/config ]; then cp ../boards/$(BOARD)/config ./distrib/$(FAMILY)/opt/board.config; fi
#cp ../application/configs/* ./distrib/$(FAMILY)/opt/configs/
TRIMPATH := $(abspath .)
build-cam: generate $(LIB_TARGET) $(CMOS_TARGET) deploy-dir-cam
$(GOENV) $(CGOPARAMS) $(GO) build -gcflags=all=-trimpath=$(TRIMPATH) -asmflags=all=-trimpath=$(TRIMPATH) -a -tags "$(GOTAGS)" -ldflags "$(GODEBUG) $(EMBEDDVARS)" -o ./distrib/$(FAMILY)/opt/gohisicam application/cmd/gohisicam
build-probe: generate $(LIB_TARGET) deploy-dir-probe
$(GOENV) $(CGOPARAMS) $(GO) build -gcflags=all=-trimpath=$(TRIMPATH) -asmflags=all=-trimpath=$(TRIMPATH) -a -tags "$(GOTAGS)" -ldflags "$(GODEBUG) $(EMBEDDVARS)" -o ./distrib/$(FAMILY)/opt/gohisiprobe application/cmd/gohisiprobe
build: build-$(APP)
test-host: generate
GOPATH=$(GOPATH) $(GO) test -tags "$(GOTAGS)" ./... -v
test-target: generate
rm -rf ./tests
mkdir tests
for i in `GOPATH=$(GOPATH) $(GO) list -tags "$(GOTAGS)" ./...`; do \
echo $$i; \
$(GOENV) $(CGOPARAMS) $(GO) test -tags "$(GOTAGS)" -c $$i -o tests/`echo $$i | rev | cut -d '/' -f 1 | rev`.test; \
done
#build-object:
# $(GOENV) $(CGOPARAMS) $(GO) tool nm ./tests/*
testvideo.h264:
ffmpeg -f lavfi -i testsrc=size=320x340 -t 30 -pix_fmt yuv420p -c:v libx264 -tune zerolatency -profile:v main -g 25 -vbsf h264_mp4toannexb -f h264 testvideo.h264
testvideo.h265:
ffmpeg -f lavfi -i testsrc=size=320x340 -t 30 -pix_fmt yuv420p -c:v libx265 -tune zerolatency -g 25 -f hevc testvideo.h265
testvideo-h264.mp4: testvideo.h264
MP4Box -add testvideo.h264 -fps 25 testvideo-h264.mp4
testvideo-h265.mp4: testvideo.h265
MP4Box -add testvideo.h265 -fps 25 testvideo-h265.mp4
clean:
rm -rf ./pkg/ko/kobin_*.go
rm -rf ./distrib
rm -f ./testvideo.h264
rm -f ./testvideo.h265
rm -f ./testvideo-h264.mp4
rm -f ./testvideo-h265.mp4
freeze-vendors:
GOPATH=$(GOPATH) $(GO) mod vendor
install-deps:
GOPATH=$(GOPATH) $(GO) get -u golang.org/x/tools/cmd/goyacc
GOPATH=$(GOPATH) $(GO) get -u github.com/shuLhan/go-bindata
go get -u github.com/shuLhan/go-bindata