colourpicker

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

build.sh (2238B)


      1 #!/bin/sh
      2 
      3 version=1.0
      4 
      5 cflags=${CFLAGS:-"-march=native -O3"}
      6 cflags="${cflags} -std=c11 "
      7 ldflags="${LDFLAGS} -flto -lm"
      8 
      9 output="colourpicker"
     10 
     11 cc=${CC:-cc}
     12 
     13 for arg; do
     14 	case ${arg} in
     15 	debug) debug=1
     16 	esac
     17 done
     18 
     19 mkdir -p out
     20 
     21 case $(uname -s) in
     22 MINGW64*)
     23 	w32=1
     24 	output="Colour Picker"
     25 	windres assets/colourpicker.rc out/colourpicker.rc.o
     26 	ldflags="out/colourpicker.rc.o ${ldflags} -mwindows -lgdi32 -lwinmm"
     27 	;;
     28 esac
     29 
     30 build_raylib()
     31 {
     32 	cp external/raylib/src/raylib.h external/raylib/src/rlgl.h out/
     33 	src=external/raylib/src
     34 	srcs="rcore rglfw rshapes rtext rtextures utils"
     35 
     36 	raylib_cmd="${cflags} -I./external/raylib/src -Iexternal/raylib/src/external/glfw/include"
     37 	raylib_cmd="${raylib_cmd} -DPLATFORM_DESKTOP_GLFW"
     38 	raylib_cmd="${raylib_cmd} -Wno-unused-but-set-variable -Wno-unused-parameter"
     39 	[ ! ${w32} ] && raylib_cmd="${raylib_cmd} -D_GLFW_X11"
     40 
     41 	if [ ${debug} ]; then
     42 		files=""
     43 		for n in ${srcs}; do
     44 			files="${files} ${src}/${n}.c"
     45 		done
     46 		raylib_cmd="${raylib_cmd} -DBUILD_LIBTYPE_SHARED -D_GLFW_BUILD_DLL"
     47 		raylib_cmd="${raylib_cmd} -fPIC -shared"
     48 		raylib_cmd="${raylib_cmd} ${files} -o ${raylib}"
     49 		[ ${w32} ] && raylib_cmd="${raylib_command} -L. -lgdi32 -lwinmm"
     50 		${cc} ${raylib_cmd}
     51 	else
     52 		outs=""
     53 		for n in ${srcs}; do
     54 			${cc} ${raylib_cmd} -c "${src}/${n}.c" -o "out/${n}.o"
     55 			outs="${outs} out/${n}.o"
     56 		done
     57 
     58 		ar rc "${raylib}" ${outs}
     59 	fi
     60 }
     61 
     62 if [ $(git diff-index --quiet HEAD -- external/raylib) ]; then
     63 	git submodule update --init --checkout --depth=1 external/raylib
     64 fi
     65 
     66 [ ! -s "config.h" ] && cp config.def.h config.h
     67 
     68 raylib=out/libraylib.a
     69 [ ${debug} ] && raylib="libraylib.so"
     70 [ "./build.sh" -nt ${raylib} ] || [ ! -f ${raylib} ] && build_raylib
     71 
     72 cflags="${cflags} -Wall -Wextra -Iout"
     73 
     74 if [ ! -s "out/lora_sb_0_inc.h" ] || [ "gen_incs.c" -nt "out/lora_sb_0_inc.h" ]; then
     75 	${cc} ${cflags} -o gen_incs gen_incs.c ${raylib} ${ldflags} && ./gen_incs
     76 fi
     77 
     78 if [ "$debug" ]; then
     79 	# Hot Reloading/Debugging
     80 	cflags="${cflags} -O0 -ggdb -D_DEBUG -Wno-unused-function"
     81 
     82 	${cc} ${cflags} -fPIC -shared colourpicker.c -o colourpicker.so
     83 	ldflags="${ldflags} -Wl,-rpath,. ${raylib}"
     84 else
     85 	ldflags="${raylib} ${ldflags}"
     86 fi
     87 
     88 ${cc} ${cflags} -DVERSION="\"${version}\"" main.c -o "${output}" ${ldflags}