Browse Source

Add build tool option for static linking

master
cancel 7 years ago
parent
commit
f123920b53
  1. 13
      tool

13
tool

@ -21,7 +21,9 @@ Options:
-d Enable compiler safeguards like -fstack-protector. -d Enable compiler safeguards like -fstack-protector.
You should probably do this if you plan to give the You should probably do this if you plan to give the
compiled binary to other people. compiled binary to other people.
-p Enable PIE (ASLR) --static Build static binary.
--pie Enable PIE (ASLR).
Note: --pie and --static cannot be mixed.
-s Print statistics about compile time and binary size. -s Print statistics about compile time and binary size.
-h or --help Print this message and exit. -h or --help Print this message and exit.
EOF EOF
@ -42,12 +44,15 @@ verbose=0
protections_enabled=0 protections_enabled=0
stats_enabled=0 stats_enabled=0
pie_enabled=0 pie_enabled=0
static_enabled=0
while getopts c:dhpsv-: opt_val; do while getopts c:dhsv-: opt_val; do
case "$opt_val" in case "$opt_val" in
-) -)
case "$OPTARG" in case "$OPTARG" in
help) print_usage; exit 0;; help) print_usage; exit 0;;
static) static_enabled=1;;
pie) pie_enabled=1;;
*) *)
echo "Unknown long option --$OPTARG" >&2 echo "Unknown long option --$OPTARG" >&2
print_usage >&2 print_usage >&2
@ -58,7 +63,6 @@ while getopts c:dhpsv-: opt_val; do
c) cc_exe="$OPTARG";; c) cc_exe="$OPTARG";;
d) protections_enabled=1;; d) protections_enabled=1;;
h) print_usage; exit 0;; h) print_usage; exit 0;;
p) pie_enabled=1;;
s) stats_enabled=1;; s) stats_enabled=1;;
v) verbose=1;; v) verbose=1;;
\?) print_usage >&2; exit 1;; \?) print_usage >&2; exit 1;;
@ -177,6 +181,9 @@ build_target() {
elif [[ $os != mac ]]; then elif [[ $os != mac ]]; then
add cc_flags -no-pie -fno-pie add cc_flags -no-pie -fno-pie
fi fi
if [[ $static_enabled = 1 ]]; then
add cc_flags -static
fi
case "$1" in case "$1" in
debug) debug)
build_subdir=debug build_subdir=debug

Loading…
Cancel
Save