-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·59 lines (48 loc) · 1.21 KB
/
build.sh
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
#!/bin/bash
APP=udpcl
APP_DBG=`printf "%s_dbg" "$APP"`
INST_DIR=/usr/sbin
CONF_DIR=/etc/controller
DEBUG_PARAM="-Wall -pedantic"
MODE_DEBUG=-DMODE_DEBUG
NONE=-DNOTHINGANDNOT
function move_bin {
([ -d $INST_DIR ] || mkdir $INST_DIR) && \
cp $APP $INST_DIR/$APP && \
chmod a+x $INST_DIR/$APP && \
chmod og-w $INST_DIR/$APP && \
echo "Your $APP executable file: $INST_DIR/$APP";
}
function build_lib {
gcc $1 -c app.c -D_REENTRANT $DEBUG_PARAM -lpthread && \
gcc $1 -c crc.c $DEBUG_PARAM && \
gcc $1 -c timef.c $DEBUG_PARAM && \
gcc $1 -c udp.c $DEBUG_PARAM && \
gcc $1 -c util.c $DEBUG_PARAM && \
cd acp && \
gcc $1 -c main.c $DEBUG_PARAM && \
cd ../ && \
echo "library: making archive..." && \
rm -f libpac.a
ar -crv libpac.a app.o crc.o timef.o udp.o util.o acp/main.o && echo "library: done"
echo "library: done"
rm -f *.o acp/*.o
}
# 1 2
#debug_mode bin_name
function build {
cd lib && \
build_lib $1 && \
cd ../
gcc -D_REENTRANT $1 main.c -o $2 $DEBUG_PARAM -lpthread -L./lib -lpac && echo "Application successfully compiled. Launch command: sudo ./"$2
}
function full {
DEBUG_PARAM=$NONE
build $NONE $APP && \
move_bin
}
function part_debug {
build $MODE_DEBUG $APP_DBG
}
f=$1
${f}