colourpicker

Simple Colour Picker written in C
git clone anongit@rnpnr.xyz:colourpicker.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

build.sh (1757B)


      1 #!/bin/sh
      2 
      3 version=1.0
      4 
      5 cflags=${CFLAGS:-"-march=native -O3 -Wall -Wextra"}
      6 cflags="${cflags} -std=c11 -I./external/include -DVERSION=\"$version\""
      7 ldflags=${LDFLAGS:-"-flto"}
      8 ldflags="$ldflags -lraylib -lm"
      9 
     10 output="colourpicker"
     11 
     12 debug=${DEBUG}
     13 
     14 cc=${CC:-cc}
     15 system_raylib=${USE_SYSTEM_RAYLIB:-$debug}
     16 
     17 case $(uname -s) in
     18 MINGW64*)
     19 	output="Colour Picker"
     20 	windres assets/colourpicker.rc assets/colourpicker.rc.o
     21 	ldflags="assets/colourpicker.rc.o $ldflags -mwindows -lgdi32 -lwinmm"
     22 	;;
     23 esac
     24 
     25 # NOTE: clones and builds a static raylib if system lib is not requested
     26 # NOTE: this requires cmake
     27 if [ "$system_raylib" ]; then
     28 	ldflags="-L/usr/local/lib $ldflags"
     29 else
     30 	if  [ ! -f external/lib/libraylib.a ]; then
     31 		git submodule update --init --checkout --depth=1 external/raylib
     32 		cmake --install-prefix="${PWD}/external" \
     33 		      -G "Ninja" -B external/raylib/build -S external/raylib \
     34 		      -D CMAKE_INSTALL_LIBDIR=lib -D CMAKE_BUILD_TYPE="Release" \
     35 		      -D CUSTOMIZE_BUILD=ON -D WITH_PIC=ON -D BUILD_EXAMPLES=OFF
     36 		cmake --build   external/raylib/build
     37 		cmake --install external/raylib/build
     38 	fi
     39 	ldflags="-L./external/lib $ldflags"
     40 fi
     41 
     42 [ ! -s "config.h" ] && cp config.def.h config.h
     43 
     44 if [ ! -e "external/include/shader_inc.h" ] || [ "slider_lerp.glsl" -nt "external/include/shader_inc.h" ]; then
     45 	${cc} $cflags -o gen_incs gen_incs.c $ldflags
     46 	./gen_incs
     47 	mv lora_sb*.h external/include/
     48 fi
     49 
     50 if [ "$debug" ]; then
     51 	# Hot Reloading/Debugging
     52 	cflags="$cflags -O0 -ggdb -D_DEBUG -Wno-unused-function"
     53 	# NOTE: needed for sync(3p)
     54 	cflags="$cflags -D_XOPEN_SOURCE=700"
     55 
     56 	libcflags="$cflags -fPIC"
     57 	libldflags="$ldflags -shared"
     58 
     59 	${cc} $libcflags colourpicker.c -o libcolourpicker.so $libldflags
     60 fi
     61 
     62 ${cc} $cflags -o "$output" main.c $ldflags