Skip to content

Commit

Permalink
Enable static library linking for MinGW builds (#152)
Browse files Browse the repository at this point in the history
This change allows to build Windows binaries without dependencies on
toolchain-specific libraries (like `libc++.dll`).
It allows to perform version updates by copying of single `bochs.exe`,
without the need for searching and distribution of linked DLLs.

---------

Co-authored-by: Volker Ruppert <[email protected]>
  • Loading branch information
Vort and vruppert authored Dec 3, 2023
1 parent d9bee7d commit 5147c20
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 28 deletions.
1 change: 1 addition & 0 deletions bochs/.conf.win32-cygwin
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export CXXFLAGS
./configure --enable-sb16 \
--enable-ne2000 \
--enable-all-optimizations \
--enable-static-link \
--enable-cpu-level=6 \
--enable-x86-64 \
--enable-vmx=2 \
Expand Down
1 change: 1 addition & 0 deletions bochs/.conf.win64-cross-mingw32
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export DLLTOOL
--enable-sb16 \
--enable-ne2000 \
--enable-all-optimizations \
--enable-static-link \
--enable-cpu-level=6 \
--enable-x86-64 \
--enable-vmx=2 \
Expand Down
71 changes: 43 additions & 28 deletions bochs/configure
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,7 @@ SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_static_link
enable_static
enable_shared
enable_fast_install
Expand Down Expand Up @@ -1751,6 +1752,7 @@ Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-static-link link libraries statically [default=disabled]
--enable-static[=PKGS] build static libraries [default=no]
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-fast-install[=PKGS]
Expand Down Expand Up @@ -3937,6 +3939,16 @@ printf "%s\n" "no" >&6; }
cross_configure=0
fi

# Check whether --enable-static-link was given.
if test ${enable_static_link+y}
then :
enableval=$enable_static_link; enable_static_link="$enableval"
else $as_nop
enable_static_link=no

fi


# this case statement defines the compile flags which are needed to
# compile bochs on a platform. Don't put things like optimization settings
# into the configure.in file, since people will want to be able to change
Expand All @@ -3963,6 +3975,9 @@ case "$target" in
;;
*-cygwin* | *-mingw32* | *-msys)
NO_LT=1 # do not use libtool at all
if test "$enable_static_link" = yes; then
EXTRA_LINK_OPTS="${EXTRA_LINK_OPTS} -static"
fi
if test "$with_term" = yes; then
# ncurses won't compile with -DWIN32
# also, I can't get it to link without this -DBROKEN_LINKER=1 hack.
Expand Down Expand Up @@ -6146,7 +6161,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 6149 "configure"' > conftest.$ac_ext
echo '#line 6164 "configure"' > conftest.$ac_ext
if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
(eval $ac_compile) 2>&5
ac_status=$?
Expand Down Expand Up @@ -7643,11 +7658,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7646: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7661: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7650: \$? = $ac_status" >&5
echo "$as_me:7665: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -7877,11 +7892,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7880: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7895: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7884: \$? = $ac_status" >&5
echo "$as_me:7899: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -7945,11 +7960,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7948: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7963: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:7952: \$? = $ac_status" >&5
echo "$as_me:7967: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -9770,7 +9785,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 9773 "configure"
#line 9788 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -9865,7 +9880,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 9868 "configure"
#line 9883 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -11983,11 +11998,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:11986: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12001: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:11990: \$? = $ac_status" >&5
echo "$as_me:12005: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -12051,11 +12066,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:12054: $lt_compile\"" >&5)
(eval echo "\"\$as_me:12069: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:12058: \$? = $ac_status" >&5
echo "$as_me:12073: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -13074,7 +13089,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13077 "configure"
#line 13092 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -13169,7 +13184,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 13172 "configure"
#line 13187 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -13989,11 +14004,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:13992: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14007: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:13996: \$? = $ac_status" >&5
echo "$as_me:14011: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -14057,11 +14072,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:14060: $lt_compile\"" >&5)
(eval echo "\"\$as_me:14075: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:14064: \$? = $ac_status" >&5
echo "$as_me:14079: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -16025,11 +16040,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16028: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16043: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16032: \$? = $ac_status" >&5
echo "$as_me:16047: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -16259,11 +16274,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16262: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16277: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:16266: \$? = $ac_status" >&5
echo "$as_me:16281: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings
Expand Down Expand Up @@ -16327,11 +16342,11 @@ else $as_nop
-e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:16330: $lt_compile\"" >&5)
(eval echo "\"\$as_me:16345: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:16334: \$? = $ac_status" >&5
echo "$as_me:16349: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
Expand Down Expand Up @@ -18152,7 +18167,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 18155 "configure"
#line 18170 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -18247,7 +18262,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 18250 "configure"
#line 18265 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down Expand Up @@ -20053,7 +20068,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<EOF
#line 20056 "configure"
#line 20071 "configure"
#include "confdefs.h"

#if HAVE_DLFCN_H
Expand Down
10 changes: 10 additions & 0 deletions bochs/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ else
cross_configure=0
fi

AC_ARG_ENABLE([static-link],
[AS_HELP_STRING([--enable-static-link],
[link libraries statically @<:@default=disabled@:>@])],
[enable_static_link="$enableval"],
[enable_static_link=no]
)

# this case statement defines the compile flags which are needed to
# compile bochs on a platform. Don't put things like optimization settings
# into the configure.in file, since people will want to be able to change
Expand All @@ -59,6 +66,9 @@ case "$target" in
;;
*-cygwin* | *-mingw32* | *-msys)
NO_LT=1 # do not use libtool at all
if test "$enable_static_link" = yes; then
EXTRA_LINK_OPTS="${EXTRA_LINK_OPTS} -static"
fi
if test "$with_term" = yes; then
# ncurses won't compile with -DWIN32
# also, I can't get it to link without this -DBROKEN_LINKER=1 hack.
Expand Down

0 comments on commit 5147c20

Please sign in to comment.