jdict

command line tool for looking up terms in yomidict dictionaries
git clone anongit@rnpnr.xyz:jdict.git
Log | Files | Refs | Feed | README | LICENSE

build.sh (1253B)


      1 #!/bin/sh
      2 cflags="-march=native -std=c99 -Wall -Wextra -fno-builtin -static"
      3 #cflags="${cflags} -fproc-stat-report"
      4 #cflags="${cflags} -Rpass-missed=.*"
      5 #cflags="${cflags} -fsanitize=address,undefined"
      6 
      7 cc=${CC:-cc}
      8 build=release
      9 
     10 for arg in "$@"; do
     11 	case "$arg" in
     12 	clang)   cc=clang      ;;
     13 	gcc)     cc=gcc        ;;
     14 	debug)   build=debug   ;;
     15 	release) build=release ;;
     16 	*) echo "usage: $0 [debug|release] [gcc|clang]" ;;
     17 	esac
     18 done
     19 
     20 case "${build}" in
     21 debug)   cflags="${cflags} -O0 -ggdb -D_DEBUG" ;;
     22 release) cflags="${cflags} -O3 -s" ;;
     23 esac
     24 
     25 src=platform_posix.c
     26 
     27 case $(uname -sm) in
     28 "Linux aarch64")
     29 	src=platform_linux_aarch64.c
     30 	cflags="${cflags} -nostdlib -ffreestanding -fno-stack-protector -Wl,--gc-sections"
     31 	;;
     32 "Linux x86_64")
     33 	src=platform_linux_amd64.c
     34 	cflags="${cflags} -nostdinc -nostdlib -ffreestanding -fno-stack-protector -Wl,--gc-sections"
     35 	;;
     36 esac
     37 
     38 ${cc} ${cflags} ${ldflags} $src -o jdict
     39 
     40 # NOTE(rnp): cross compile tests
     41 clang --target=x86_64-unknown-linux-musl  -O3 -nostdlib -ffreestanding -fno-stack-protector \
     42 	-Wl,--gc-sections platform_linux_amd64.c -o /dev/null
     43 clang --target=aarch64-unknown-linux-musl -O3 -nostdlib -ffreestanding -fno-stack-protector \
     44 	-Wl,--gc-sections platform_linux_aarch64.c -o /dev/null