-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
155 lines (139 loc) · 4.26 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
# ---------------------------------------------------------------------
# OS parsing
ifeq ($(OS),Windows_NT)
OSFLAGS = -shared
# GCC = x86_64-w64-mingw32-g++.exe
GCC = g++.exe
OUT = parquet_windows.plugin
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSFLAGS = -shared -fPIC -DSYSTEM=OPUNIX
OUT = parquet_unix.plugin
endif
ifeq ($(UNAME_S),Darwin)
OSFLAGS = -bundle -DSYSTEM=APPLEMAC
OUT = parquet_macosx.plugin
endif
GCC = g++
endif
# ---------------------------------------------------------------------
# Flags
SPI = 2.0
UFLAGS =
CFLAGS = -Wall -O3 $(OSFLAGS) $(UFLAGS)
INCLUDE = /usr/local/include
LIBS = /usr/local/lib64
PARQUET = -I$(INCLUDE) -L$(LIBS) -larrow -lparquet
STATA = ${HOME}/.local/stata13/stata
STATARUN = LD_LIBRARY_PATH=$(LIBS) ${STATA}
# ---------------------------------------------------------------------
# Rules
## Build plugin
all: clean links parquet copy
## Symlinks to plugin libraries
links:
rm -f src/plugin/lib
rm -f src/plugin/spi
ln -sf ../../lib src/plugin/lib
ln -sf lib/spi-$(SPI) src/plugin/spi
## Build parquet plugin
parquet: src/plugin/parquet.cpp src/plugin/spi/stplugin.cpp
mkdir -p ./build
$(GCC) $(CFLAGS) -o build/$(OUT) src/plugin/spi/stplugin.cpp src/plugin/parquet.cpp $(PARQUET)
mkdir -p lib/plugin/
cp build/*plugin lib/plugin/
## Copy Stata package files to ./build
copy:
cp src/parquet.pkg ./build/
cp src/stata.toc ./build/
cp src/ado/parquet.ado ./build/
cp docs/parquet.sthlp ./build/
cp ./src/test/parquet_tests.do ./build/
sed -i.bak 's/parquet_os.plugin/$(OUT)/' build/parquet.pkg
## Install the Stata package (replace if necessary)
replace:
sed -i.bak 's/parquet_os.plugin/$(OUT)/' build/parquet.pkg
cd build/ && $(STATARUN) -b "cap noi net uninstall parquet"
cd build/ && $(STATARUN) -b "net install parquet, from(\`\"${PWD}/build\"')"
## Run tests
test:
cp ./src/test/parquet_tests.do ./build/
cd build/ && $(STATARUN) -b do parquet_tests.do
# TODO: Bump version?
# README.md
# docs/parquet.sthlp
# src/ado/parquet.ado
# src/parquet.pkg
# src/plugin/parquet.cpp
# src/plugin/parquet.h
# src/stata.toc
# changelog.md
# NOTE: Debug conda installation
#
# _GCC=g++
# _GCC=${HOME}/Desktop/GCC-9.2/g++
# _PREFIX=${HOME}/Desktop/stata-parquet/lib
#
# _PREFIX=${HOME}/bulk/programs/miniconda3/envs/stata-parquet
# _GCC=${PREFIX}/bin/x86_64-conda_cos6-linux-gnu-g++
#
# make GCC=${_GCC} UFLAGS=-std=c++11 INCLUDE=${_PREFIX}/include LIBS=${_PREFIX}/lib all replace test
# make GCC=${_GCC} UFLAGS=-std=c++11 INCLUDE=${_PREFIX}/include LIBS=${_PREFIX}/lib all
#
# ${HOME}/.local/stata/stata -b "net install parquet, from(${PWD}/build) replace"
# LD_LIBRARY_PATH=${_PREFIX}/lib:$LD_LIBRARY_PATH ${HOME}/.local/stata/stata
#
# ${HOME}/.local/stata15/stata-mp -b "net install parquet, from(${PWD}/build) replace"
# LD_LIBRARY_PATH=${_PREFIX}/lib:$LD_LIBRARY_PATH ${HOME}/.local/stata15/stata-mp
#
# NOTE: Be sure to type `which conda` and `which parquet` to check you
# are using the latest versions.
.PHONY: clean
clean:
rm -rf build
#######################################################################
# #
# Self-Documenting Foo (Ignore) #
# #
#######################################################################
.DEFAULT_GOAL := show-help
.PHONY: show-help
show-help:
@echo "$$(tput bold)Available rules:$$(tput sgr0)"
@echo
@sed -n -e "/^## / { \
h; \
s/.*//; \
:doc" \
-e "H; \
n; \
s/^## //; \
t doc" \
-e "s/:.*//; \
G; \
s/\\n## /---/; \
s/\\n/ /g; \
p; \
}" ${MAKEFILE_LIST} \
| LC_ALL='C' sort --ignore-case \
| awk -F '---' \
-v ncol=$$(tput cols) \
-v indent=19 \
-v col_on="$$(tput setaf 6)" \
-v col_off="$$(tput sgr0)" \
'{ \
printf "%s%*s%s ", col_on, -indent, $$1, col_off; \
n = split($$2, words, " "); \
line_length = ncol - indent; \
for (i = 1; i <= n; i++) { \
line_length -= length(words[i]) + 1; \
if (line_length <= 0) { \
line_length = ncol - indent - length(words[i]) - 1; \
printf "\n%*s ", -indent, " "; \
} \
printf "%s ", words[i]; \
} \
printf "\n"; \
}' \
| more $(shell test $(shell uname) = Darwin && echo '--no-init --raw-control-chars')