Branch
Hash :
752330a5
Author :
Thomas de Grivel
Date :
2024-08-08T17:20:11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
#!/bin/sh
## kc3
## Copyright 2022-2024 kmx.io <contact@kmx.io>
##
## Permission is hereby granted to use this software granted the above
## copyright notice and this permission paragraph are included in all
## copies and substantial portions of this software.
##
## THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
## PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
## AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
## THIS SOFTWARE.
set -e
echo "$PWD/configure"
export SRC_TOP="$(dirname "$PWD")"
. ../../../../config.subr
PROG=kc3_window_cairo_quartz_demo
PROG_ASAN=kc3_window_cairo_quartz_demo_asan
PROG_COV=kc3_window_cairo_quartz_demo_cov
PROG_DEBUG=kc3_window_cairo_quartz_demo_debug
echo "PROG = $PROG" >> ${CONFIG_MK}
echo "PROG_ASAN = $PROG_ASAN" >> ${CONFIG_MK}
echo "PROG_COV = $PROG_COV" >> ${CONFIG_MK}
echo "PROG_DEBUG = $PROG_DEBUG" >> ${CONFIG_MK}
APP=kc3_window_cairo_quartz_demo.app
APP_ASAN=kc3_window_cairo_quartz_demo_asan.app
APP_COV=kc3_window_cairo_quartz_demo_cov.app
APP_DEBUG=kc3_window_cairo_quartz_demo_debug.app
echo "APP = $APP" >> ${CONFIG_MK}
echo "APP_ASAN = ${APP_ASAN}" >> ${CONFIG_MK}
echo "APP_COV = ${APP_COV}" >> ${CONFIG_MK}
echo "APP_DEBUG = ${APP_DEBUG}" >> ${CONFIG_MK}
APP_PROG=${APP}/Contents/MacOS/${PROG}
APP_PROG_ASAN=${APP_ASAN}/Contents/MacOS/${PROG_ASAN}
APP_PROG_COV=${APP_COV}/Contents/MacOS/${PROG_COV}
APP_PROG_DEBUG=${APP_DEBUG}/Contents/MacOS/${PROG_DEBUG}
echo "APP_PROG = $APP_PROG" >> ${CONFIG_MK}
echo "APP_PROG_ASAN = $APP_PROG_ASAN" >> ${CONFIG_MK}
echo "APP_PROG_COV = $APP_PROG_COV" >> ${CONFIG_MK}
echo "APP_PROG_DEBUG = $APP_PROG_DEBUG" >> ${CONFIG_MK}
. ./sources.sh
OBJECTS="$(c2ext .main.lo "$SOURCES")"
echo "OBJECTS = $OBJECTS" >> ${CONFIG_MK}
OBJECTS_ASAN="$(c2ext .asan.lo "$SOURCES")"
echo "OBJECTS_ASAN = $OBJECTS_ASAN" >> ${CONFIG_MK}
if $HAVE_GCOV; then
OBJECTS_COV="$(c2ext .cov.lo "$SOURCES")"
echo "OBJECTS_COV = $OBJECTS_COV" >> ${CONFIG_MK}
fi
OBJECTS_DEBUG="$(c2ext .debug.lo "$SOURCES")"
echo "OBJECTS_DEBUG = $OBJECTS_DEBUG" >> ${CONFIG_MK}
# Common config for all targets
CPPFLAGS="$CPPFLAGS -I../../../.."
CFLAGS="$CFLAGS -W -Wall -Werror -std=c11 -pedantic -pipe"
OBJCFLAGS="$CFLAGS -W -Wall -Werror"
LDFLAGS="$LDFLAGS -framework Cocoa"
LIBS="$LIBS"
config_asan
config_gnu
config_i386
pkg_config cairo
pkg_config cairo-ft
pkg_config libffi
pkg_config libmd
pkg_config xkbcommon
# Asan config
CPPFLAGS_ASAN="$CPPFLAGS"
CFLAGS_ASAN="$CFLAGS -DDEBUG -O1 -g"
CFLAGS_ASAN="$CFLAGS_ASAN -fsanitize=address -fno-omit-frame-pointer"
LDFLAGS_ASAN="$LDFLAGS"
LOCAL_LIBS_ASAN="../../demo/libkc3_window_cairo_demo_asan.la"
LOCAL_LIBS_ASAN="$LOCAL_LIBS_ASAN ../libkc3_window_cairo_quartz_asan.la"
LIBS_ASAN="$LOCAL_LIBS_ASAN $LIBS"
# Coverage config
CPPFLAGS_COV="$CPPFLAGS"
CFLAGS_COV="$CFLAGS -DDEBUG --coverage"
LDFLAGS_COV="$LDFLAGS"
LOCAL_LIBS_COV="../../demo/libkc3_window_cairo_demo_cov.la"
LOCAL_LIBS_COV="$LOCAL_LIBS_COV ../libkc3_window_cairo_quartz_cov.la"
LIBS_COV="$LOCAL_LIBS_COV $LIBS"
# Debug config
CPPFLAGS_DEBUG="$CPPFLAGS"
CFLAGS_DEBUG="$CFLAGS -DDEBUG -O0 -g"
LDFLAGS_DEBUG="$LDFLAGS"
LOCAL_LIBS_DEBUG="../../demo/libkc3_window_cairo_demo_debug.la"
LOCAL_LIBS_DEBUG="$LOCAL_LIBS_DEBUG ../libkc3_window_cairo_quartz_debug.la"
LIBS_DEBUG="$LOCAL_LIBS_DEBUG $LIBS"
# Main config
DEFAULT_CFLAGS="-O2 -fPIC"
if [ "x$ENV_CFLAGS" = "x" ]; then
CFLAGS="$CFLAGS $DEFAULT_CFLAGS"
fi
CFLAGS="$CFLAGS -DNDEBUG"
LIBKC3=../libkc3/libkc3.la
LOCAL_LIBS="../../demo/libkc3_window_cairo_demo.la"
LOCAL_LIBS="$LOCAL_LIBS ../libkc3_window_cairo_quartz.la"
LIBS="$LOCAL_LIBS $LIBS"
echo "HAVE_ASAN = $HAVE_ASAN" >> ${CONFIG_MK}
echo "CPPFLAGS = $CPPFLAGS" >> ${CONFIG_MK}
echo "CFLAGS = $CFLAGS" >> ${CONFIG_MK}
echo "LDFLAGS = $LDFLAGS" >> ${CONFIG_MK}
echo "LIBS = $LIBS" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "CFLAGS_ASAN = $CFLAGS_ASAN" >> ${CONFIG_MK}
echo "LDFLAGS_ASAN = $LDFLAGS_ASAN" >> ${CONFIG_MK}
echo "LIBS_ASAN = $LIBS_ASAN" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "CFLAGS_COV = $CFLAGS_COV" >> ${CONFIG_MK}
echo "LDFLAGS_COV = $LDFLAGS_COV" >> ${CONFIG_MK}
echo "LIBS_COV = $LIBS_COV" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "CFLAGS_DEBUG = $CFLAGS_DEBUG" >> ${CONFIG_MK}
echo "LDFLAGS_DEBUG = $LDFLAGS_DEBUG" >> ${CONFIG_MK}
echo "LIBS_DEBUG = $LIBS_DEBUG" >> ${CONFIG_MK}
update_build
update_build_prog
build_lo
build_prog
echo >> ${CONFIG_MK}
echo "${APP_PROG}: ${PROG}" >> ${CONFIG_MK}
echo " mkdir -p $(dirname $APP_PROG)" >> ${CONFIG_MK}
echo " cp .libs/${PROG} ${APP_PROG}" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "${APP_PROG_ASAN}: ${PROG_ASAN}" >> ${CONFIG_MK}
echo " mkdir -p $(dirname $APP_PROG_ASAN)" >> ${CONFIG_MK}
echo " cp .libs/${PROG_ASAN} ${APP_PROG_ASAN}" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "${APP_PROG_COV}: ${PROG_COV}" >> ${CONFIG_MK}
echo " mkdir -p $(dirname $APP_PROG_COV)" >> ${CONFIG_MK}
echo " cp .libs/${PROG_COV} ${APP_PROG_COV}" >> ${CONFIG_MK}
echo >> ${CONFIG_MK}
echo "${APP_PROG_DEBUG}: ${PROG_DEBUG}" >> ${CONFIG_MK}
echo " mkdir -p $(dirname $APP_PROG_DEBUG)" >> ${CONFIG_MK}
echo " cp .libs/${PROG_DEBUG} ${APP_PROG_DEBUG}" >> ${CONFIG_MK}
BUNDLE_LIBS="../../../../libkc3/.libs/libkc3.0.dylib ../../../.libs/libkc3_window.0.dylib ../../.libs/libkc3_window_cairo.0.dylib ../../demo/.libs/libkc3_window_cairo_demo.0.dylib ../.libs/libkc3_window_cairo_quartz.0.dylib"
echo >> ${CONFIG_MK}
echo "${APP}/Contents/Frameworks: ${BUNDLE_LIBS}" >> ${CONFIG_MK}
echo " mkdir -p ${APP}/Contents/Frameworks" >> ${CONFIG_MK}
echo " cp ${BUNDLE_LIBS} ${APP}/Contents/Frameworks/" >> ${CONFIG_MK}
for BUNDLE_LIB in ${BUNDLE_LIBS}; do
L=$(basename $BUNDLE_LIB)
echo " install_name_tool -id @executable_path/../Frameworks/ ${APP}/Contents/Frameworks/$L" >> ${CONFIG_MK}
echo " install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP}/Contents/MacOS/${PROG}" >> ${CONFIG_MK}
echo " DEPS=\$\$(otool -L '${BUNDLE_LIB}' | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print \$\$1 }'); for DEP in \$\${DEPS}; do D=\$\$(basename \"\$\${DEP}\"); if [ -f ${APP}/Contents/Frameworks/\$\$D ]; then install_name_tool -change \$\${DEP} @executable_path/../Frameworks/\$\$D ${APP}/Contents/Frameworks/$L; fi; done" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo ".PHONY: \\" >> ${CONFIG_MK}
echo " ${APP}/Contents/Frameworks \\" >> ${CONFIG_MK}
echo " ${APP_PROG}" >> ${CONFIG_MK}
BUNDLE_LIBS_ASAN="../../../../libkc3/.libs/libkc3_asan.0.dylib ../../../.libs/libkc3_window_asan.0.dylib ../../.libs/libkc3_window_cairo_asan.0.dylib ../../demo/.libs/libkc3_window_cairo_demo_asan.0.dylib ../.libs/libkc3_window_cairo_quartz_asan.0.dylib"
echo >> ${CONFIG_MK}
echo "${APP_ASAN}/Contents/Frameworks: ${BUNDLE_LIBS_ASAN}" >> ${CONFIG_MK}
echo " mkdir -p ${APP_ASAN}/Contents/Frameworks" >> ${CONFIG_MK}
echo " cp ${BUNDLE_LIBS_ASAN} ${APP_ASAN}/Contents/Frameworks/" >> ${CONFIG_MK}
for BUNDLE_LIB in ${BUNDLE_LIBS_ASAN}; do
L=$(basename $BUNDLE_LIB)
echo " install_name_tool -id @executable_path/../Frameworks/ ${APP_ASAN}/Contents/Frameworks/$L" >> ${CONFIG_MK}
echo " install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_ASAN}/Contents/MacOS/${PROG_ASAN}" >> ${CONFIG_MK}
echo " DEPS=\$\$(otool -L '${BUNDLE_LIB}' | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print \$\$1 }'); for DEP in \$\${DEPS}; do D=\$\$(basename \"\$\${DEP}\"); if [ -f ${APP_ASAN}/Contents/Frameworks/\$\$D ]; then install_name_tool -change \$\${DEP} @executable_path/../Frameworks/\$\$D ${APP_ASAN}/Contents/Frameworks/$L; fi; done" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo ".PHONY: \\" >> ${CONFIG_MK}
echo " ${APP_ASAN}/Contents/Frameworks \\" >> ${CONFIG_MK}
echo " ${APP_PROG_ASAN}" >> ${CONFIG_MK}
BUNDLE_LIBS_COV="../../../../libkc3/.libs/libkc3_cov.0.dylib ../../../.libs/libkc3_window_cov.0.dylib ../../.libs/libkc3_window_cairo_cov.0.dylib ../../demo/.libs/libkc3_window_cairo_demo_cov.0.dylib ../.libs/libkc3_window_cairo_quartz_cov.0.dylib"
echo >> ${CONFIG_MK}
echo "${APP_COV}/Contents/Frameworks: ${BUNDLE_LIBS_COV}" >> ${CONFIG_MK}
echo " mkdir -p ${APP_COV}/Contents/Frameworks" >> ${CONFIG_MK}
echo " cp ${BUNDLE_LIBS_COV} ${APP_COV}/Contents/Frameworks/" >> ${CONFIG_MK}
for BUNDLE_LIB in ${BUNDLE_LIBS_COV}; do
L=$(basename $BUNDLE_LIB)
echo " install_name_tool -id @executable_path/../Frameworks/ ${APP_COV}/Contents/Frameworks/$L" >> ${CONFIG_MK}
echo " install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_COV}/Contents/MacOS/${PROG}" >> ${CONFIG_MK}
echo " DEPS=\$\$(otool -L '${BUNDLE_LIB}' | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print \$\$1 }'); for DEP in \$\${DEPS}; do D=\$\$(basename \"\$\${DEP}\"); if [ -f ${APP_COV}/Contents/Frameworks/\$\$D ]; then install_name_tool -change \$\${DEP} @executable_path/../Frameworks/\$\$D ${APP_COV}/Contents/Frameworks/$L; fi; done" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo ".PHONY: \\" >> ${CONFIG_MK}
echo " ${APP_COV}/Contents/Frameworks \\" >> ${CONFIG_MK}
echo " ${APP_PROG}" >> ${CONFIG_MK}
BUNDLE_LIBS_DEBUG="../../../../libkc3/.libs/libkc3_debug.0.dylib ../../../.libs/libkc3_window_debug.0.dylib ../../.libs/libkc3_window_cairo_debug.0.dylib ../../demo/.libs/libkc3_window_cairo_demo_debug.0.dylib ../.libs/libkc3_window_cairo_quartz_debug.0.dylib"
echo >> ${CONFIG_MK}
echo "${APP_DEBUG}/Contents/Frameworks: ${BUNDLE_LIBS_DEBUG}" >> ${CONFIG_MK}
echo " mkdir -p ${APP_DEBUG}/Contents/Frameworks" >> ${CONFIG_MK}
echo " cp ${BUNDLE_LIBS_DEBUG} ${APP_DEBUG}/Contents/Frameworks/" >> ${CONFIG_MK}
for BUNDLE_LIB in ${BUNDLE_LIBS_DEBUG}; do
L=$(basename $BUNDLE_LIB)
echo " install_name_tool -id @executable_path/../Frameworks/ ${APP_DEBUG}/Contents/Frameworks/$L" >> ${CONFIG_MK}
echo " install_name_tool -change ${LIBDIR}/$L @executable_path/../Frameworks/$L ${APP_DEBUG}/Contents/MacOS/${PROG_DEBUG}" >> ${CONFIG_MK}
echo " DEPS=\$\$(otool -L '${BUNDLE_LIB}' | awk '/^\t.+(\/usr\/lib|\/System)/ { next } /^\t/ { print \$\$1 }'); for DEP in \$\${DEPS}; do D=\$\$(basename \"\$\${DEP}\"); if [ -f ${APP_DEBUG}/Contents/Frameworks/\$\$D ]; then install_name_tool -change \$\${DEP} @executable_path/../Frameworks/\$\$D ${APP_DEBUG}/Contents/Frameworks/$L; fi; done" >> ${CONFIG_MK}
done
echo >> ${CONFIG_MK}
echo ".PHONY: \\" >> ${CONFIG_MK}
echo " ${APP_DEBUG}/Contents/Frameworks \\" >> ${CONFIG_MK}
echo " ${APP_PROG_DEBUG}" >> ${CONFIG_MK}
update_config_mk