Skip to content

Commit

Permalink
more config/makefile etc changes for mingw64 compilation w sheet and …
Browse files Browse the repository at this point in the history
…ncurses
  • Loading branch information
liquidaty committed Oct 3, 2024
1 parent 0af2f2e commit 316fbd2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,13 @@ ifeq ($(WIN),0)
CFLAGS_EXE+= -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 -s PTHREAD_POOL_SIZE=8
endif
endif
CFLAGS_SETENV=
else
BUILD_SUBDIR=win/${DBG_SUBDIR}
EXE=.exe
CFLAGS+= -D__USE_MINGW_ANSI_STDIO -D_ISOC99_SOURCE
CFLAGS+= -D__USE_MINGW_ANSI_STDIO -D_ISOC99_SOURCE -D_GNU_SOURCE
CFLAGS+= -Wl,--strip-all
CONFIGURE_HOST=x86_64-w64-mingw32
CFLAGS_SETENV=-Dsetenv\(a,b,c\)=_putenv_s\(a,b\)
CFLAGS+=-Dsetenv\(a,b,c\)=_putenv_s\(a,b\)
endif

JQ_CONFIGURE_HOST=
Expand Down Expand Up @@ -191,6 +190,7 @@ CLI_SOURCES=echo select desc count paste 2tsv pretty sql flatten 2json serialize
ifeq ($(ZSV_BUILD_SHEET),1)
SOURCES+=sheet
CLI_SOURCES+=sheet
CFLAGS+=-DZSV_BUILD_SHEET
CFLAGS+=${CFLAGS_NCURSES}
LDFLAGS+=${LDFLAGS_NCURSES}
endif
Expand Down Expand Up @@ -405,7 +405,7 @@ lib-jq: ${JQ_LIB}

${JQ_BUNDLE_LIB}: ${JQ_SRC} # -D_REENTRANT needed for clang to not break
cd ${JQ_SRC} \
&& CC="${CC}" CFLAGS="${CFLAGS} -D_REENTRANT ${CFLAGS_SETENV}" ./configure \
&& CC="${CC}" CFLAGS="${CFLAGS} -D_REENTRANT" ./configure \
--prefix="${JQ_PREFIX}" \
--disable-maintainer-mode \
--without-oniguruma \
Expand Down
6 changes: 5 additions & 1 deletion app/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ ZSV_MAIN_DECL(desc);
ZSV_MAIN_DECL(sql);
ZSV_MAIN_DECL(2db);
ZSV_MAIN_DECL(compare);
#ifdef ZSV_BUILD_SHEET
ZSV_MAIN_DECL(sheet);
#endif
ZSV_MAIN_DECL(echo);
ZSV_MAIN_NO_OPTIONS_DECL(prop);
ZSV_MAIN_NO_OPTIONS_DECL(rm);
Expand Down Expand Up @@ -109,7 +111,9 @@ struct builtin_cmd builtin_cmds[] = {
CLI_BUILTIN_COMMAND(sql),
CLI_BUILTIN_COMMAND(2db),
CLI_BUILTIN_COMMAND(compare),
CLI_BUILTIN_COMMAND(sheet),
#ifdef ZSV_BUILD_SHEET
CLI_BUILTIN_COMMAND(sheet),
#endif
CLI_BUILTIN_COMMAND(echo),
CLI_BUILTIN_NO_OPTIONS_COMMAND(prop),
CLI_BUILTIN_NO_OPTIONS_COMMAND(rm),
Expand Down
1 change: 0 additions & 1 deletion app/cli_ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* This file is part of zsv/lib, distributed under the license defined at
* https://opensource.org/licenses/MIT
*/

#include <zsv/utils/string.h>
#include <zsv/utils/os.h>
#include <zsv/utils/dirs.h>
Expand Down
19 changes: 15 additions & 4 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Optional features:
--force-avx force compile with (no CPU check) or without -mavx [auto]
--force-sse2 force compile with (no CPU check) or without -msse2 [auto]
--enable-sheet compile with 'sheet' feature (requires ncurses) [yes]
--ncurses-dynamic compile without NCURSES_STATIC or NCURSESW_STATIC defines
--enable-lto compile with LTO (works with some but not all platforms/compilers) [no]
--enable-whole-program compile without -fwhole-program even if no -flto [yes]
--enable-pie build with position independent executables [auto]
Expand Down Expand Up @@ -222,7 +223,7 @@ tryflag () {
}

tryldflag () { # var, flag, other_arguments (optional)
printf "checking whether linker accepts %s... " "$2"
printf "checking whether linker accepts %s %s... " "$2" "$3"
echo "int main(){return 0;}" > "$tmpc"
if $CC $LDFLAGS "$2" $3 -o "$tmpo" "$tmpc" >/dev/null 2>&1 ; then
printf "yes\n"
Expand Down Expand Up @@ -306,6 +307,7 @@ usepie=auto
usepic=auto
usetermcap=auto

NCURSES_DYNAMIC=
for arg ; do
case "$arg" in
--help|-h) usage ;;
Expand Down Expand Up @@ -336,6 +338,8 @@ for arg ; do
--force-sse2|--force-sse2=yes) FORCE_SSE2=yes;;
--force-sse2=no) FORCE_SSE2=no;;

--ncurses-dynamic) NCURSES_DYNAMIC=1;;

--enable-sheet|--enable-sheet=yes) TRY_SHEET=yes;;
--enable-sheet=auto) TRY_SHEET=auto;;
--disable-sheet|--enable-sheet=no) TRY_SHEET=no;;
Expand Down Expand Up @@ -479,7 +483,6 @@ tryldflag LDFLAGS_TRY -Werror=unused-command-line-argument
tryldflag LDFLAGS_TRY -Werror=ignored-optimization-argument

CFLAGS_STD="-std=gnu11 -D_POSIX_C_SOURCE=200809L -U_XOPEN_SOURCE -D_XOPEN_SOURCE=700"
# CFLAGS_OPT="-DNDEBUG"
MINGW=0
case "$host" in
*-*freebsd*) CFLAGS_STD="$CFLAGS_STD -D_BSD_SOURCE -D__BSD_VISIBLE=1" ;;
Expand Down Expand Up @@ -513,13 +516,21 @@ tryflag CFLAGS_OPENMP -fopenmp
if [ "$TRY_SHEET" != "no" ]; then
if tryldflag LDFLAGS_NCURSES -lncurses -L${PREFIX}/lib ; then
NCLIB=ncurses
CFLAGS_NCURSES=-DHAVE_NCURSES
if [ "NCURSES_DYNAMIC" != "" ] ; then
CFLAGS_NCURSES="-DHAVE_NCURSES -DNCURSES_STATIC"
else
CFLAGS_NCURSES=-DHAVE_NCURSES
fi
fi
if tryldflag LDFLAGS_NCURSESW -lncursesw -L${PREFIX}/lib ; then
LDFLAGS_NCURSES="$LDFLAGS_NCURSES -lncursesw"
NCLIB="$NCLIB ncursesw"
if [ "$CFLAGS_NCURSES" = "" ]; then
CFLAGS_NCURSES=-DHAVE_NCURSESW
if [ "NCURSES_DYNAMIC" != "" ] ; then
CFLAGS_NCURSES="-DHAVE_NCURSESW -DNCURSESW_STATIC"
else
CFLAGS_NCURSES="-DHAVE_NCURSESW"
fi
fi
fi
ZSV_BUILD_SHEET=1
Expand Down

0 comments on commit 316fbd2

Please sign in to comment.