uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

build.sh (2050B)


      1 #!/bin/sh -e
      2 
      3 format=0
      4 console=0
      5 install=0
      6 debug=0
      7 norun=0
      8 
      9 while [ $# -gt 0 ]; do
     10 	case $1 in
     11 		--format)
     12 			format=1
     13 			shift
     14 			;;
     15 
     16 		--console)
     17 			console=1
     18 			shift
     19 			;;
     20 
     21 		--install)
     22 			install=1
     23 			shift
     24 			;;
     25 
     26 		--debug)
     27 			debug=1
     28 			shift
     29 			;;
     30 
     31 		--no-run)
     32 			norun=1
     33 			shift
     34 			;;
     35 
     36 		*)
     37 			shift
     38 	esac
     39 done
     40 
     41 rm -f bin/*
     42 
     43 # When clang-format is present
     44 
     45 if [ $format = 1 ];
     46 then
     47 	clang-format -i src/uxnasm.c
     48 	clang-format -i src/uxncli.c
     49 	clang-format -i src/uxnemu.c
     50 	clang-format -i src/devices/*
     51 fi
     52 
     53 mkdir -p bin
     54 CC="${CC:-cc}"
     55 CFLAGS="${CFLAGS:--std=c89 -Wall -Wno-unknown-pragmas}"
     56 case "$(uname -s 2>/dev/null)" in
     57 MSYS_NT*|MINGW*) # MSYS2 on Windows
     58 	FILE_LDFLAGS="-liberty"
     59 	if [ $console = 1 ];
     60 	then
     61 		UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs | sed -e 's/ -mwindows//g')"
     62 	else
     63 		UXNEMU_LDFLAGS="-static $(sdl2-config --cflags --static-libs)"
     64 	fi
     65 	;;
     66 Darwin) # macOS
     67 	CFLAGS="${CFLAGS} -Wno-typedef-redefinition -D_C99_SOURCE"
     68 	UXNEMU_LDFLAGS="$(sdl2-config --cflags --static-libs)"
     69 	;;
     70 Linux|*)
     71 	UXNEMU_LDFLAGS="-L/usr/local/lib $(sdl2-config --cflags --libs)"
     72 	;;
     73 esac
     74 
     75 if [ $debug = 1 ];
     76 then
     77 	echo "[debug]"
     78 	CFLAGS="${CFLAGS} -DDEBUG -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined"
     79 else
     80 	CFLAGS="${CFLAGS} -DNDEBUG -O2 -g0 -s"
     81 fi
     82 
     83 ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm
     84 ${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} ${FILE_LDFLAGS} -o bin/uxnemu
     85 ${CC} ${CFLAGS} src/uxn.c src/devices/system.c src/devices/console.c src/devices/file.c src/devices/datetime.c src/uxncli.c ${FILE_LDFLAGS} -o bin/uxncli
     86 
     87 if [ $install = 1 ]
     88 then
     89 	cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/
     90 fi
     91 
     92 if [ $norun = 1 ]; then exit; fi
     93 
     94 # Test version
     95 
     96 bin/uxnasm -v
     97 bin/uxncli -v
     98 bin/uxnemu -v
     99 
    100 # Start potato
    101 
    102 bin/uxnemu -2x