forked from nyaosorg/nyagos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (79 loc) · 2.66 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
PROMPT=$$$$$$S
ifeq ($(OS),Windows_NT)
SHELL=CMD.EXE
NUL=NUL
DEL=del
DELTREE=rmdir /s
SET=set
TYPE=type
GITDIR=$(or $(GIT_INSTALL_ROOT),$(shell for %%I in (git.exe) do echo %%~dp$$PATH:I..))
AWK="$(GITDIR)\usr\bin\gawk.exe"
D=$\\
else
NUL=/dev/null
SET=export
DEL=rm
DELTREE=rm -r
TYPE=cat
AWK=gawk
D=/
endif
snapshot: fmt nyagos.syso
$(SET) "CGO_ENABLED=0" && go build -ldflags "-s -w -X main.version=$(shell git.exe describe --tags)"
debug:
$(SET) "CGO_ENABLED=0" && go build -ldflags "-s -w -X main.version=$(shell git.exe describe --tags)" -tags=debug
test: tstlua
cd alias && go test
cd commands && go test
cd history && go test
cd mains && go test
cd nodos && go test
cd shell && go test
cd texts && go test
tstlua:
$(foreach I,$(wildcard luatst/*.lua),echo $(I) && nyagos --norc -f "$(I)" && ) :
release: fmt nyagos.syso
cd bin 2>$(NUL) || mkdir bin
cd bin$(D)386 2>$(NUL) || mkdir bin$(D)386
cd bin$(D)amd64 2>$(NUL) || mkdir bin$(D)amd64
$(SET) "GOOS=windows" && $(SET) "GOARCH=386" && go build -o bin/386/nyagos.exe -ldflags "-s -w"
$(SET) "GOOS=windows" && $(SET) "GOARCH=amd64" && go build -o bin/amd64/nyagos.exe -ldflags "-s -w"
$(SET) "CGO_ENABLED=0" && $(SET) "GOOS=linux" && $(SET) "GOARCH=amd64" && go build -ldflags "-s -w"
clean:
-$(DELTREE) bin 2>$(NUL)
-$(DEL) nyagos.exe nyagos nyagos.syso 2>$(NUL)
fmt:
git status -s | $(AWK) "/^.M.*\.go/{ system(\"go fmt \" $$NF) }"
nyagos.syso:
cd Etc && go generate
get:
go get -u
# go get -u github.com/zetamatta/go-readline-ny@master
go mod tidy
VERSION=$(shell $(TYPE) Etc$(D)version.txt)
_zip:
zip -9j "nyagos-$(VERSION)-windows-$(GOARCH).zip" \
"bin$(D)$(GOARCH)$(D)nyagos.exe" .nyagos _nyagos makeicon.cmd LICENSE \
"Etc$(D)*.ico"
zip -9 "nyagos-$(VERSION)-windows-$(GOARCH).zip" \
nyagos.d$(D)*.lua nyagos.d$(D)catalog$(D)*.lua
package:
make _zip GOARCH=386
make _zip GOARCH=amd64
tar zcvf "nyagos-$(VERSION)-linux-amd64.tar.gz" -C .. \
nyagos/nyagos nyagos/.nyagos nyagos/_nyagos nyagos/nyagos.d
ifeq ($(OS),Windows_NT)
install:
ifeq ($(INSTALLDIR),)
@echo Please do $(MAKE) INSTALLDIR=...
@echo or set INSTALLDIR=...
else
copy /-Y _nyagos "$(INSTALLDIR)$(D)."
xcopy "nyagos.d$(D)*" "$(INSTALLDIR)$(D)nyagos.d" /E /I /Y
copy /-Y nyagos.exe "$(INSTALLDIR)$(D)." || ( \
move "$(INSTALLDIR)$(D)nyagos.exe" "$(INSTALLDIR)$(D)nyagos.exe-%RANDOM%" && \
copy nyagos.exe "$(INSTALLDIR)$(D)." )
endif
update:
for /F "skip=1" %%I in ('where nyagos.exe') do $(MAKE) install INSTALLDIR=%%~dpI
endif