-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
139 lines (118 loc) · 4.12 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
BIN=@ArmA3URLFetch
PREFIX=a3uf
BUILD_PATH=.build
BUILDS_PATH=.builds
GIT_HASH=$(shell git describe --tag | sed "s/-.*-/-/")
ARMAKE_FLAGS=-w unquoted-string -w redefinition-wo-undef
CPPFLAGS=-Wall -fPIC -pthread -std=c++11
INCLUDES_x32=-I/usr/local/include -Iinclude/jsoncpp
OBJS=include/jsoncpp.o src/common.o src/arguments.o src/requests.o src/clients.o src/output.o src/handler.o src/main.o
LIBS_x32=/usr/local/lib/libcurl.a /usr/local/lib/libssl.a /usr/local/lib/libcrypto.a
LIBS_x64=/usr/local/lib/libcurl.a /usr/local/lib/libssl.a /usr/local/lib/libcrypto.a
LDFLAGS=-shared -fPIC -pthread
OUTPUT=""
OPENSSLSRC=https://www.openssl.org/source/openssl-1.1.0f.tar.gz
CURLSRC=https://github.com/curl/curl/releases/download/curl-7_59_0/curl-7.59.0.zip
TAG=$(shell git describe --tag | sed "s/-.*-/-/")
OUTPUTPATH=".build/@ArmA3URLFetch/"
ARMAKE=armake
ifeq ($(OS), Windows_NT)
ARMAKE = ./tools/armake_w64.exe
endif
all: linux32 build_mod deploy_mod
linux32: prepare clean build_obj_linux_x32 link
linux64: prepare clean build_obj_linux_x64 link
prepare:
@mkdir -p .build/
@mkdir -p .build/@ArmA3URLFetch/addons
@mkdir -p .build/@ArmA3URLFetch/keys
@mkdir -p .build/keys
@mkdir -p .build/bin
build_obj_linux_x32: $(OBJS)
@$(eval CPPFLAGS = -m32 $(CPPFLAGS))
@$(eval LDFLAGS = -m32 $(LDFLAGS))
$(eval LIBS=$(LIBS_x32))
$(eval OUTPUT=$(OUTPUTPATH)/arma3urlfetch.so)
build_obj_linux_x64: $(OBJS)
@$(eval CPPFLAGS = -m64 $(CPPFLAGS))
@$(eval LDFLAGS = -m64 $(LDFLAGS))
$(eval LIBS=$(LIBS_x64))
$(eval OUTPUT=$(OUTPUTPATH)/arma3urlfetch_x64.so)
%.o: %.cpp
@echo "\tCXX\t\t$@"
@$(CXX) $(INCLUDES_x32) $(CPPFLAGS) -ldl -c $< -o $@
link:
@echo "\tLD\t\t$(OUTPUT)"
@$(CXX) $(OBJS) $(LIBS) $(LDFLAGS) -ldl -o $(OUTPUT)
clean:
@echo "\tCLEANUP"
@rm -f src/*.o
@rm -f include/*.o
test: prepare testLinux32
testLinux32: cleanTest
@$(eval CPPFLAGS = -m32 $(CPPFLAGS))
@$(eval LDFLAGS = -m32 $(LDFLAGS))
@echo "\tTEST\t\tLinux (x86/x32)"
@$(CXX) -m32 -pthread -fPIC -I.build/usr/local/include/ \
-Isrc/ \
-Iinclude/jsoncpp \
-std=c++11 \
include/jsoncpp.cpp \
src/common.cpp \
src/arguments.cpp \
src/requests.cpp \
src/clients.cpp \
src/output.cpp \
src/handler.cpp \
test/main.cpp \
$(LIBS_x32) \
-ldl \
-o .build/test.a
@echo "\tTEST\t\ttest.a (x86/x32)"
@.build/test.a
testLinux64: cleanTest
@$(eval CPPFLAGS = -m64 $(CPPFLAGS))
@$(eval LDFLAGS = -m64 $(LDFLAGS))
@echo "\tTEST\t\tLinux (x86/x64)"
@$(CXX) -m64 -pthread -fPIC -I.build/usr/local/include/ \
-Isrc/ \
-Iinclude/jsoncpp \
-std=c++11 \
include/jsoncpp.cpp \
src/common.cpp \
src/arguments.cpp \
src/requests.cpp \
src/clients.cpp \
src/output.cpp \
src/handler.cpp \
test/main.cpp \
$(LIBS_x64) \
-ldl \
-o .build/test.a
@echo "\tTEST\t\ttest.a (x86/x64)"
@.build/test.a
cleanTest:
@echo "\tRM\t\tCleaning up tests"
@rm -f .build/test.a
build: $(patsubst addons/%, $(BUILD_PATH)/$(BIN)/addons/$(PREFIX)_%.pbo, $(wildcard addons/*))
$(BUILD_PATH)/$(BIN)/addons/$(PREFIX)_%.pbo: addons/%
@mkdir -p $(BUILD_PATH)/$(BIN)/addons
@echo " PBO $@"
@${ARMAKE} build $(FLAGS) -p -f -e "version=$(GIT_HASH)" $< $@
$(BUILD_PATH)/keys/%.biprivatekey:
@mkdir -p $(BUILD_PATH)/keys
@echo " KEY $@"
@${ARMAKE} keygen -f $(patsubst $(BUILD_PATH)/keys/%.biprivatekey, $(BUILD_PATH)/keys/%, $@)
$(BUILD_PATH)/$(BIN)/addons/$(PREFIX)_%.pbo.a3uf_$(GIT_HASH).bisign: $(BUILD_PATH)/$(BIN)/addons/$(PREFIX)_%.pbo $(BUILD_PATH)/keys/a3uf_$(GIT_HASH).biprivatekey
@echo " SIG $@"
@${ARMAKE} sign -f -s $@ $(BUILD_PATH)/keys/a3uf_$(GIT_HASH).biprivatekey $<
signatures: $(patsubst addons/%, $(BUILD_PATH)/$(BIN)/addons/$(PREFIX)_%.pbo.a3uf_$(GIT_HASH).bisign, $(wildcard addons/*))
mod_clean:
@rm -Rf $(BUILD_PATH)/$(BIN) $(BUILD_PATH)/keys $(BUILDS_PATH)/$(GIT_HASH)
release: mod_clean
@"$(MAKE)" $(MAKEFLAGS) signatures
@mkdir -p $(BUILDS_PATH)/$(GIT_HASH)
@echo " CP $(BUILD_PATH)/* to $(BUILDS_PATH)/$(GIT_HASH)"
@cp -Rf $(BUILD_PATH)/$(BIN) $(BUILD_PATH)/keys $(BUILDS_PATH)/$(GIT_HASH)/
@mkdir -p $(BUILDS_PATH)/$(GIT_HASH)/$(BIN)/keys/
@cp -f $(BUILDS_PATH)/$(GIT_HASH)/keys/a3uf_$(GIT_HASH).bikey $(BUILDS_PATH)/$(GIT_HASH)/$(BIN)/keys/