-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·209 lines (175 loc) · 4.38 KB
/
configure
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
203
204
205
206
207
208
209
#!/bin/sh
# Created by: WestleyR
# email: [email protected]
# Date: Feb 23, 2019
# https://github.com/WestleyR/print-line
# Version-1.0.1
#
# The Clear BSD License
#
# Copyright (c) 2019 WestleyR
# All rights reserved.
#
# This software is licensed under a Clear BSD License.
#
set -e
MAKEFILE="Makefile"
MAKEFRAG="makefile-parts"
ALL_MAKE="all.makefile"
STATIC_MAKE="static.makefile"
INSTALL_MAKE="install.makefile"
CLEAN_MAKE="clean.makefile"
UNINSTALL_MAKE="uninstall.makefile"
SRCDIR="src"
FILES_NEEDED="${SRCDIR}/main-print-line.c ${MAKEFRAG}/${ALL_MAKE} \
${MAKEFRAG}/${STATIC_MAKE} ${MAKEFRAG}/${INSTALL_MAKE} \
${MAKEFRAG}/${CLEAN_MAKE} ${MAKEFRAG}/${UNINSTALL_MAKE}"
PREFIX="/usr/bin"
COMPILER="gcc"
help_menu() {
echo "USAGE:
$0 [option]
OPTIONS:
--prefix=string : set install prefix.
--compiler=string : set the compiler, eg. gcc, tcc...
"
exit 0
}
for arg in "$@"; do
if [ "$arg" = "-h" ] || [ "$arg" = "--help" ]; then
help_menu
elif [ $(echo "$arg" | strcomp -s="--prefix=") -eq 0 ]; then
PREFIX=`echo "$arg" | sed 's/--prefix=//'`
elif [ $(echo "$arg" | strcomp -s="--compiler=") -eq 0 ]; then
COMPILER=`echo "$arg" | sed 's/--compiler=//'`
else
echo "ERROR: Option not found: ${arg}"
exit 1
fi
done
echo "Starting configure..."
echo " Checking dependcies:"
echo -n " Checking for: strcomp... "
if ! [ -x "$(command -v strcomp)" ]; then
echo "missing"
echo "ERROR: Need 'strcomp'"
echo
echo "Please download/install strcomp from:"
echo "https://github.com/WestleyR/strcomp"
exit 1
fi
echo "yes"
echo -n " Checking for: make... "
if ! [ -x "$(command -v make)" ]; then
echo "missing"
echo "ERROR: Need 'make'"
echo
echo "Please download/install it by:"
echo ">> $ sudo apt-get install make # or"
echo ">> $ sudo apt-get install build-essential"
exit 1
fi
echo "yes"
echo -n " Checking for: ${COMPILER}... "
if ! [ -x "$(command -v ${COMPILER})" ]; then
echo "no"
COMPILER_B="tcc"
echo -n " Now looking for backup compiler: ${COMPILER_B}... "
if ! [ -x "$(command -v ${COMPILER_B})" ]; then
echo "no"
echo "ERROR: No compiler found."
echo "ERROR: Need 'gcc', or 'tcc'"
echo
echo "Please download/install it by:"
echo ">> $ sudo apt-get install build-essential"
exit 1
else
echo "yes"
echo
echo "ERROR: The compiler (${COMPILER}), is not found..."
echo "But, you do have ${COMPILER_B}. Try:"
echo
echo "./configure --compiler=tcc"
echo
exit 1
fi
fi
echo "yes"
echo " Setting prefix : ${PREFIX}"
echo " Setting compiler : ${COMPILER}"
echo " Checking for existing files..."
for file in $FILES_NEEDED; do
echo -n " Checking for file : ${file}... "
if [ ! -e "$file" ]; then
echo "no"
echo "ERROR: File missing : ${file}"
echo
echo "Try redownloading print-line from https://github.com/WestleyR/print-line"
echo
exit 100
else
echo "yes"
fi
done
echo " Building makefile..."
cat << EOF > "$MAKEFILE"
# Created by: WestleyR
# email: [email protected]
# Date: Feb 7, 2018
# https://github.com/WestleyR/print-line
# Version-1.0.3
#
# The Clear BSD License
#
# Copyright (c) 2019 WestleyR
# All rights reserved.
#
# This software is licensed under a Clear BSD License.
#
# This Makefile was generated by: configure, and was:
# generated in : $(pwd)
# generated by : $(whoami)
# generated on : $(date "+%B %d, %Y, %I:%M:%S %p")
# generated on arch : $(uname -m)
#
#
# DO NOT EDIT!
#
EOF
if [ "$COMPILER" = "gcc" ]; then
cat << EOF >> "$MAKEFILE"
PREFIX = ${PREFIX}
CODE_NAME = src/main-print-line.c
SCRIPT_NAME = pl
COMPILER = ${COMPILER}
CFLAG = -Wall
STATIC_BUILD_FLAG = -static
FLAG =
EOF
else
cat << EOF >> "$MAKEFILE"
PREFIX = ${PREFIX}
CODE_NAME = src/main-print-line.c
SCRIPT_NAME = pl
COMPILER = ${COMPILER}
CFLAG = -Wall
FLAG =
EOF
fi
cat "${MAKEFRAG}/${ALL_MAKE}" >> "$MAKEFILE"
if [ "$COMPILER" != "tcc" ]; then
cat "${MAKEFRAG}/${STATIC_MAKE}" >> "$MAKEFILE"
fi
cat "${MAKEFRAG}/${INSTALL_MAKE}" >> "$MAKEFILE"
cat "${MAKEFRAG}/${CLEAN_MAKE}" >> "$MAKEFILE"
cat "${MAKEFRAG}/${UNINSTALL_MAKE}" >> "$MAKEFILE"
echo "DONE."
echo
echo "Makefile ready; do:"
echo
echo " $ make [make_option]"
echo " $ sudo make install"
echo
#
# End configure
#