-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
60 lines (60 loc) · 2.23 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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
# Uplink-c
GIT_REPO=https://github.com/storj/uplink-c
UPLINKC_NAME=uplink-c
UPLINKC_VERSION=v1.2.2
#Library Name
LIBRARY_NAME_LINUX=libuplinkcv1.2.4.so
LIBRARY_NAME_DARWIN=libuplinkcv1.2.4.dylib
LIBRARY_NAME_WIN=libuplinkcv1.2.4.dll
LIBRARY_UPLINK=*.h
DELETE_LIBRARY_HEADER=libuplinkcv1.2.4.h
#Library Path
MACOS_DYLIB_DEFAULT_PAYH=/usr/local/lib
#JSFOLDER
JSFOLDER=dist
JSFOLDERLIB=libuplinkcv1.2.4.*
#Color
RED_COLOR=\033[31m
GREEN_COLOR=\033[32m
RESET_COLOR=\033[0m
#
build:
ifdef OS
git clone -b ${UPLINKC_VERSION} ${GIT_REPO}
(cd ${UPLINKC_NAME}) && (${GOBUILD} -o ../${LIBRARY_NAME_WIN} -buildmode=c-shared) && (move ${LIBRARY_UPLINK} ../)
rmdir /s ${UPLINKC_NAME}
else
echo "$(shell uname)";\
if [ ! -d $(UPLINKC_NAME) ]; then\
git clone -b $(UPLINKC_VERSION) $(GIT_REPO);\
fi;\
if [ $(shell uname) = Darwin ]; then\
cd $(UPLINKC_NAME);$(GOBUILD) -o ../$(LIBRARY_NAME_DARWIN) -buildmode=c-shared;mv $(LIBRARY_UPLINK) ../;cd ../;cp ./$(JSFOLDERLIB) ./$(JSFOLDER)/;\
fi;\
if [ $(shell uname) = Linux ]; then\
cd $(UPLINKC_NAME);$(GOBUILD) -o ../$(LIBRARY_NAME_LINUX) -buildmode=c-shared;mv $(LIBRARY_UPLINK) ../;cd ../;cp ./$(JSFOLDERLIB) ./$(JSFOLDER)/;\
fi;\
if test -d ./$(UPLINKC_NAME); then rm -rf ./$(UPLINKC_NAME); fi;\
echo ' $(GREEN_COLOR) \n Successfully build $(RESET_COLOR)';
endif
clean:
ifdef OS
(IF EXIST ${LIBRARY_UPLINK}; (del "${LIBRARY_UPLINK}")) && (IF EXIST ${DELETE_LIBRARY_HEADER}; (del "${DELETE_LIBRARY_HEADER}")) && (IF EXIST ${LIBRARY_NAME_WIN}; (del "${LIBRARY_NAME_WIN}")) && (IF EXIST ${UPLINKC_NAME}; (rmdir /s "${UPLINKC_NAME}"))
else
if test -d $(UPLINKC_NAME); then rm -rf $(UPLINKC_NAME); fi
if test -f ./$(LIBRARY_UPLINK); then rm ./$(LIBRARY_UPLINK); fi;\
if test -f ./$(DELETE_LIBRARY_HEADER); then rm ./$(DELETE_LIBRARY_HEADER); fi;\
if [ $(shell uname) = Darwin ]; then\
if test -f ./$(LIBRARY_NAME_DARWIN); then rm ./$(LIBRARY_NAME_DARWIN); fi;\
fi;\
if [ $(shell uname) = Linux ]; then\
if test -f $(LIBRARY_NAME_LINUX); then rm $(LIBRARY_NAME_LINUX); fi;\
fi;
endif
@echo ' $(GREEN_COLOR) \n Successfully cleaned $(RESET_COLOR)';