diff --git a/Makefile.in b/Makefile.in index d5f79a199..6c92581be 100644 --- a/Makefile.in +++ b/Makefile.in @@ -70,7 +70,8 @@ dllib=@DLLIB@ HOSTCC = @CC@ HOSTCFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@ -CC = @CC@ +BUILDCC = @CC_FOR_BUILD@ +BUILDEXT = @BUILD_EXEEXT@ CXX = @CXX@ DLLTOOL = @DLLTOOL@ INSTALL = @INSTALL@ @@ -127,9 +128,9 @@ all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vp # In the windows world, the installer will need a dosify program to # dosify text files. ifeq (@MINGW32@,yes) -all: dosify.exe -dosify.exe: $(srcdir)/dosify.c - $(HOSTCC) $(HOSTCFLAGS) -o dosify.exe $(srcdir)/dosify.c +all: dosify$(BUILDEXT) +dosify$(BUILDEXT): $(srcdir)/dosify.c + $(BUILDCC) $(CFLAGS) -o dosify$(BUILDEXT) $(srcdir)/dosify.c endif # This rule rules the compiler in the trivial hello.vl program to make @@ -156,7 +157,7 @@ clean: $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true rm -f *.o parse.cc parse.h lexor.cc rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps - rm -f parse.output syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp + rm -f parse.output syn-rules.output dosify$(BUILDEXT) ivl@EXEEXT@ check.vvp rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc rm -rf dep rm -f version.exe @@ -239,7 +240,7 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile endif version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h - $(HOSTCC) $(HOSTCFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c + $(BUILDCC) $(CFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c %.o: %.cc config.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o diff --git a/README.txt b/README.txt index 62f2b92bd..d44a106e5 100644 --- a/README.txt +++ b/README.txt @@ -26,7 +26,7 @@ system and C/C++ compilation should be able to build the source distribution with little effort. Some actual programming skills are not required, but helpful in case of problems. -If you are building for Windows, see the mingw.txt file. +If you are building on Windows, see the mingw.txt file. 2.1 Compile Time Prerequisites @@ -112,6 +112,12 @@ configure script that modify its behavior: with the same prefix but different suffix are guaranteed to not interfere with each other. + --host= + Compile iverilog for a different platform. You can use: + x64_64-w64-mingw32 for building 64-bit Windows executables + i686-w64-mingw32 for building 32-bit Windows executables + Both options require installing the required mingw-w64 packages. + 2.3 (Optional) Testing To run a simple test before installation, execute diff --git a/aclocal.m4 b/aclocal.m4 index 7a113bf44..a47eba42c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -225,7 +225,9 @@ AC_DEFUN([AX_C99_STRTOD], [# On MinGW we need to jump through hoops to get a C99 compliant strtod(). # mingw-w64 doesn't need this, and the 64-bit version doesn't support it. case "${host}" in - *-pc-mingw32) + x86_64-w64-mingw32) + ;; + *-*-mingw32) LDFLAGS+=" -Wl,--undefined=___strtod,--wrap,strtod,--defsym,___wrap_strtod=___strtod" ;; esac @@ -244,3 +246,130 @@ _config_header=$1 _stamp_name=stamp-`expr //$_config_header : '.*/\([[^./]]*\)\.[[^./]]*$'`-h echo "timestamp for $_config_header" > `AS_DIRNAME(["$_config_header"])`/[]$_stamp_name ]) #_AC_AM_CONFIG_HEADER_HOOK + +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_cc_for_build.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_CC_FOR_BUILD +# +# DESCRIPTION +# +# This macro searches for a C compiler that generates native executables, +# that is a C compiler that surely is not a cross-compiler. This can be +# useful if you have to generate source code at compile-time like for +# example GCC does. +# +# The macro sets the CC_FOR_BUILD and CPP_FOR_BUILD macros to anything +# needed to compile or link (CC_FOR_BUILD) and preprocess (CPP_FOR_BUILD). +# The value of these variables can be overridden by the user by specifying +# a compiler with an environment variable (like you do for standard CC). +# +# It also sets BUILD_EXEEXT and BUILD_OBJEXT to the executable and object +# file extensions for the build platform, and GCC_FOR_BUILD to `yes' if +# the compiler we found is GCC. All these variables but GCC_FOR_BUILD are +# substituted in the Makefile. +# +# LICENSE +# +# Copyright (c) 2008 Paolo Bonzini +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 8 + +AU_ALIAS([AC_PROG_CC_FOR_BUILD], [AX_PROG_CC_FOR_BUILD]) +AC_DEFUN([AX_PROG_CC_FOR_BUILD], [dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_EXEEXT])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl + +dnl Use the standard macros, but make them use other variable names +dnl +pushdef([ac_cv_prog_CPP], ac_cv_build_prog_CPP)dnl +pushdef([ac_cv_prog_gcc], ac_cv_build_prog_gcc)dnl +pushdef([ac_cv_prog_cc_works], ac_cv_build_prog_cc_works)dnl +pushdef([ac_cv_prog_cc_cross], ac_cv_build_prog_cc_cross)dnl +pushdef([ac_cv_prog_cc_g], ac_cv_build_prog_cc_g)dnl +pushdef([ac_cv_exeext], ac_cv_build_exeext)dnl +pushdef([ac_cv_objext], ac_cv_build_objext)dnl +pushdef([ac_exeext], ac_build_exeext)dnl +pushdef([ac_objext], ac_build_objext)dnl +pushdef([CC], CC_FOR_BUILD)dnl +pushdef([CPP], CPP_FOR_BUILD)dnl +pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl +pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl +pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl +pushdef([host], build)dnl +pushdef([host_alias], build_alias)dnl +pushdef([host_cpu], build_cpu)dnl +pushdef([host_vendor], build_vendor)dnl +pushdef([host_os], build_os)dnl +pushdef([ac_cv_host], ac_cv_build)dnl +pushdef([ac_cv_host_alias], ac_cv_build_alias)dnl +pushdef([ac_cv_host_cpu], ac_cv_build_cpu)dnl +pushdef([ac_cv_host_vendor], ac_cv_build_vendor)dnl +pushdef([ac_cv_host_os], ac_cv_build_os)dnl +pushdef([ac_cpp], ac_build_cpp)dnl +pushdef([ac_compile], ac_build_compile)dnl +pushdef([ac_link], ac_build_link)dnl + +save_cross_compiling=$cross_compiling +save_ac_tool_prefix=$ac_tool_prefix +cross_compiling=no +ac_tool_prefix= + +AC_PROG_CC +AC_PROG_CPP +AC_EXEEXT + +ac_tool_prefix=$save_ac_tool_prefix +cross_compiling=$save_cross_compiling + +dnl Restore the old definitions +dnl +popdef([ac_link])dnl +popdef([ac_compile])dnl +popdef([ac_cpp])dnl +popdef([ac_cv_host_os])dnl +popdef([ac_cv_host_vendor])dnl +popdef([ac_cv_host_cpu])dnl +popdef([ac_cv_host_alias])dnl +popdef([ac_cv_host])dnl +popdef([host_os])dnl +popdef([host_vendor])dnl +popdef([host_cpu])dnl +popdef([host_alias])dnl +popdef([host])dnl +popdef([LDFLAGS])dnl +popdef([CPPFLAGS])dnl +popdef([CFLAGS])dnl +popdef([CPP])dnl +popdef([CC])dnl +popdef([ac_objext])dnl +popdef([ac_exeext])dnl +popdef([ac_cv_objext])dnl +popdef([ac_cv_exeext])dnl +popdef([ac_cv_prog_cc_g])dnl +popdef([ac_cv_prog_cc_cross])dnl +popdef([ac_cv_prog_cc_works])dnl +popdef([ac_cv_prog_gcc])dnl +popdef([ac_cv_prog_CPP])dnl + +dnl Finally, set Makefile variables +dnl +BUILD_EXEEXT=$ac_build_exeext +BUILD_OBJEXT=$ac_build_objext +AC_SUBST(BUILD_EXEEXT)dnl +AC_SUBST(BUILD_OBJEXT)dnl +AC_SUBST([CFLAGS_FOR_BUILD])dnl +AC_SUBST([CPPFLAGS_FOR_BUILD])dnl +AC_SUBST([LDFLAGS_FOR_BUILD])dnl +]) + diff --git a/configure.in b/configure.in index fb93c3674..2bae77b3f 100644 --- a/configure.in +++ b/configure.in @@ -224,8 +224,8 @@ case "${host}" in CFLAGS="-mieee $CFLAGS" ;; *-*-mingw*) - CXXFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CXXFLAGS" - CFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CFLAGS" + CXXFLAGS="-Wno-deprecated-declarations -Wno-sign-compare -D__USE_MINGW_ANSI_STDIO=1 $CXXFLAGS" + CFLAGS="-Wno-sign-compare -D__USE_MINGW_ANSI_STDIO=1 $CFLAGS" ;; esac @@ -325,5 +325,5 @@ then AC_MSG_ERROR(cannot configure white space in libdir: $libdir) fi AC_MSG_RESULT(ok) - +AX_PROG_CC_FOR_BUILD AC_OUTPUT(Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile tgt-blif/Makefile tgt-sizer/Makefile) diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index f4cc6b167..cc99468cf 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -36,6 +36,7 @@ mandir = @mandir@ dllib=@DLLIB@ CC = @CC@ +HOSTCC := @CC@ WINDRES = @WINDRES@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ @@ -97,6 +98,11 @@ install: all installdirs $(bindir)/iverilog-vpi$(suffix)@EXEEXT@ $(bindir)/iverilog-vpi$(suffix)@EXEEXT@: ./iverilog-vpi@EXEEXT@ $(INSTALL_PROGRAM) ./iverilog-vpi@EXEEXT@ "$(bindir)/iverilog-vpi$(suffix)@EXEEXT@" +ifeq (@WIN32@,yes) + $(INSTALL_PROGRAM) $(shell $(HOSTCC) --print-file-name=libwinpthread-1.dll) "$(DESTDIR)$(bindir)" + $(INSTALL_PROGRAM) $(shell $(HOSTCC) --print-file-name=libgcc_s_sjlj-1.dll) "$(DESTDIR)$(bindir)" + $(INSTALL_PROGRAM) $(shell $(HOSTCC) --print-file-name=libstdc++-6.dll) "$(DESTDIR)$(bindir)" +endif installdirs: $(srcdir)/../mkinstalldirs $(srcdir)/../mkinstalldirs "$(bindir)" diff --git a/vvp/Makefile.in b/vvp/Makefile.in index d5a1c7f92..998e38969 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -35,7 +35,8 @@ includedir = @includedir@ HOSTCC = @CC@ HOSTCFLAGS = @WARNING_FLAGS@ @WARNING_FLAGS_CC@ @CFLAGS@ -CC = @CC@ +BUILDCC = @CC_FOR_BUILD@ +BUILDEXT = @BUILD_EXEEXT@ CXX = @CXX@ DLLTOOL = @DLLTOOL@ AR = @AR@ @@ -153,9 +154,9 @@ endif mv $*.d dep/$*.d tables.cc: $(srcdir)/draw_tt.c - $(HOSTCC) $(HOSTCFLAGS) -o draw_tt.exe $(srcdir)/draw_tt.c - ./draw_tt.exe > tables.cc - rm draw_tt.exe + $(CC) $(CFLAGS) -o draw_tt$(BUILDEXT) $(srcdir)/draw_tt.c + ./draw_tt$(BUILDEXT) > tables.cc + rm draw_tt$(BUILDEXT) lexor.o: lexor.cc parse.h