Skip to content

Commit

Permalink
Get mingw compiling.
Browse files Browse the repository at this point in the history
  • Loading branch information
PatZim committed Mar 20, 2019
1 parent e00c9ea commit 4ec400b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
11 changes: 10 additions & 1 deletion Configure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,16 @@

$errors{moar}{'no gen-nqp'} = @errors && !defined $options{'gen-nqp'};

unless ($win) {
if ($win) {
if ($prefix . $slash . 'bin' ne $nqp_config{'moar::libdir'}) {
$config{'m_install'} = "\t" . '$(CP) ' . $nqp_config{'moar::libdir'} . $slash . $nqp_config{'moar::moar'} . ' $(PREFIX)' . $slash . 'bin';
}
$config{'mingw_unicode'} = '';
if ($nqp_config{'moar::os'} eq 'mingw32') {
$config{'mingw_unicode'} = '-municode';
}
$config{'c_runner_libs'} = '-lShlwapi';
} else {
$config{'m_cleanups'} = " \$(M_GDB_RUNNER) \\\n \$(M_LLDB_RUNNER) \\\n \$(M_VALGRIND_RUNNER)";
$config{'m_all'} = '$(M_GDB_RUNNER) $(M_LLDB_RUNNER) $(M_VALGRIND_RUNNER)';
$config{'m_install'} = "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-gdb-m "gdb" "" "" ""' . "\n"
Expand Down
2 changes: 2 additions & 0 deletions src/vm/moar/runner/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#ifndef _WIN32
# include <libgen.h>
#else
# include <shlwapi.h>
#endif

#ifndef _WIN32
Expand Down
21 changes: 12 additions & 9 deletions tools/build/Makefile-Moar.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ M_CC = @moar::cc@
M_LD = @moar::ld@
M_CFLAGS = @moar::cflags@ @moar::ccmiscflags@ @moar::ccoptiflags@ @moar::ccwarnflags@
M_LDFLAGS = @moar::ldflags@ @moar::ldmiscflags@ @moar::ldoptiflags@ @moar::ldlibs@
M_LDRPATH = @moar::ldrpath@
M_C_RUNNER_LIBS = @c_runner_libs@
M_MINGW_UNICODE = @mingw_unicode@

M_GEN_CAT = tools/build/gen-cat.nqp moar

M_BUILD_DIR = gen/moar

MOAR_PREFIX = @moar::prefix@
MOAR = @moar::bindir@@slash@moar@exe@
MOAR = @moar::bindir@@slash@moar@moar::exe@
M_NQP = @m_nqp@
M_LIBDEFPATH = $(PREFIX)@slash@share@slash@nqp@slash@lib
M_LIBPATH = $(LIBDIR)@slash@nqp@slash@lib
Expand All @@ -19,10 +22,10 @@ M_RUN_PERL6 = $(MOAR) --libpath="blib" --libpath="$(M_LIBPATH)" perl6.moarvm --n
M_BAT = @runner_suffix@
M_BAT_RUNNER = perl6-m@runner_suffix@

M_RUNNER = perl6-m@exe@
M_DEBUG_RUNNER = perl6-debug-m@exe@
M_C_RUNNER = perl6-mc@exe@
M_C_DEBUG_RUNNER = perl6-debug-mc@exe@
M_RUNNER = perl6-m@moar::exe@
M_DEBUG_RUNNER = perl6-debug-m@moar::exe@
M_C_RUNNER = perl6-mc@moar::exe@
M_C_DEBUG_RUNNER = perl6-debug-mc@moar::exe@

# files we create
PERL6_MOAR = perl6.moarvm
Expand Down Expand Up @@ -225,15 +228,15 @@ $(M_C_RUNNER): src/vm/moar/runner/main.c
$(RM_F) $(M_C_RUNNER)
# Using only the pkgconfig moar includes does not work, because moar.h assumes all the specific includes below.
$(M_CC) @moar::ccshared@ $(M_CFLAGS) $(M_LDFLAGS) -I$(M_INCPATH) -I$(M_INCPATH)/moar \
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/moar -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ -Wl,-z,origin,-rpath,'$$ORIGIN/../lib' -lmoar @moar::ccout@$@ src/vm/moar/runner/main.c
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ $(M_LDRPATH) $(M_MINGW_UNICODE) @moar::ccout@$@ src/vm/moar/runner/main.c -lmoar $(M_C_RUNNER_LIBS)

$(M_C_DEBUG_RUNNER): src/vm/moar/runner/main.c
$(RM_F) $(M_C_RUNNER)
# Using only the pkgconfig moar includes does not work, because moar.h assumes all the specific includes below.
$(M_CC) @moar::ccshared@ -DMOAR_PERL6_RUNNER_DEBUG $(M_CFLAGS) $(M_LDFLAGS) -I$(M_INCPATH) -I$(M_INCPATH)/moar \
-I$(M_INCPATH)/libatomic_ops -I$(M_INCPATH)/dyncall -I$(M_INCPATH)/moar -I$(M_INCPATH)/sha1 -I$(M_INCPATH)/tinymt -I$(M_INCPATH)/libtommath -I$(M_INCPATH)/libuv \
-L@moar::libdir@ -Wl,-z,origin,-rpath,'$$ORIGIN/../lib' -lmoar @moar::ccout@$@ src/vm/moar/runner/main.c
-L@moar::libdir@ $(M_LDRPATH) $(M_MINGW_UNICODE) @moar::ccout@$@ src/vm/moar/runner/main.c -lmoar $(M_C_RUNNER_LIBS)


## testing targets
Expand Down Expand Up @@ -332,7 +335,7 @@ m-install: m-all tools/build/create-moar-runner.p6 tools/build/install-core-dist
@m_install@

m-runner-default-install: m-install
$(CP) $(DESTDIR)$(PREFIX)/bin/perl6-m@exe@ $(DESTDIR)$(PREFIX)/bin/perl6@exe@
$(CP) $(DESTDIR)$(PREFIX)/bin/perl6-m@moar::exe@ $(DESTDIR)$(PREFIX)/bin/perl6@moar::exe@

manifest:
echo MANIFEST >MANIFEST
Expand Down
6 changes: 4 additions & 2 deletions tools/build/create-moar-runner.p6
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@ multi sub MAIN("perl6", $perl6, $install-to, $toolchain, $ld-lib-path, $perl6-ho
chmod(0o755, $install-to) if $*DISTRO ne 'mswin32';
}

multi sub MAIN("moar", $moar, $install-to, $mbc, $p6-mbc-path, $toolchain, $perl6-home is copy, $nqp-home is copy, $blib is copy, *@libpaths) {
multi sub MAIN("moar", $moar, $install-to is copy, $mbc, $p6-mbc-path, $toolchain, $perl6-home is copy, $nqp-home is copy, $blib is copy, *@libpaths) {
$perl6-home = "PERL6_HOME=$perl6-home" if $perl6-home;
$nqp-home = "NQP_HOME=$nqp-home" if $nqp-home;
my $env-vars = join(' ', $nqp-home, $perl6-home).trim;

$blib = ' ' ~ $blib if $blib;
my $libpaths = '--libpath="%s"'.sprintf: @libpaths.join('" --libpath="');
my $libpath-line = '%s %s/%s%s'.sprintf: $libpaths, $p6-mbc-path, $mbc, $blib;

$install-to ~= '.bat' if $*DISTRO eq 'mswin32';

my $fh = open $install-to, :w;

if $*DISTRO eq 'mswin32' {
$fh.print(get-moar-win-runner($moar, $libpaths, $blib));
$fh.print(get-moar-win-runner($moar, $libpaths, $p6-mbc-path, $mbc, $blib));
}
elsif $toolchain eq any('gdb','lldb') {
$fh.print(get-moar-debug-runner($toolchain, $moar, $libpath-line));
Expand Down

0 comments on commit 4ec400b

Please sign in to comment.