Skip to content

Commit

Permalink
Clean library build commands
Browse files Browse the repository at this point in the history
Rely on the build configuration of MoarVM more when building the
libraries and executables in rakudo instead of hard coding stuff.
  • Loading branch information
PatZim committed Mar 27, 2019
1 parent db5becf commit c1c108f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 29 deletions.
13 changes: 3 additions & 10 deletions Configure.pl
Expand Up @@ -337,29 +337,22 @@ ($$)
if ($nqp_config{'moar::os'} eq 'mingw32') {
$config{'mingw_unicode'} = '-municode';
}
push @c_runner_libs, 'Shlwapi';
push @c_runner_libs, sprintf($nqp_config{'moar::ldusr'}, 'Shlwapi');
} 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"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-lldb-m "lldb" "" "" ""' . "\n"
. "\t" . '$(M_RUN_PERL6) tools/build/create-moar-runner.p6 perl6 $(M_RUNNER) $(DESTDIR)$(PREFIX)/bin/perl6-valgrind-m "valgrind" "" "" ""';
}
$config{'c_runner_libs'} = join ' ',
(map { sprintf $nqp_config{'moar::ldusr'}, $_; } @c_runner_libs),
sprintf(defined_or($nqp_config{'moar::ldimp'}, $nqp_config{'moar::ldusr'}), $nqp_config{'moar::name'});
$config{'c_runner_libs'} = join ' ', @c_runner_libs;
$config{'moar_lib'} = sprintf(defined_or($nqp_config{'moar::ldimp'}, $nqp_config{'moar::ldusr'}), $nqp_config{'moar::name'});

unless (@errors) {
print "Using $config{'m_nqp'} (version $nqp_config{'nqp::version'} / MoarVM $nqp_config{'moar::version'}).\n";

$config{'perl6_ops_dll'} = sprintf($nqp_config{'moar::dll'}, 'perl6_ops_moar');

# Add moar library to link command
# TODO: Get this from Moar somehow
$config{'moarimplib'} = $win || $^O eq 'darwin'
? $nqp_config{'moar::libdir'} . '/' . $nqp_config{'moar::sharedlib'}
: '';

fill_template_file('tools/build/Makefile-Moar.in', $MAKEFILE, %config, %nqp_config);
}
}
Expand Down
38 changes: 19 additions & 19 deletions tools/build/Makefile-Moar.in
Expand Up @@ -17,8 +17,18 @@ M_NQP = @m_nqp@
M_LIBDEFPATH = $(PREFIX)@slash@share@slash@nqp@slash@lib
M_LIBPATH = $(LIBDIR)@slash@nqp@slash@lib
M_INCPATH = $(MOAR_PREFIX)@slash@include

M_RUN_PERL6 = $(MOAR) --libpath="blib" --libpath="$(M_LIBPATH)" perl6.moarvm --nqp-lib=blib
M_MOAR_INC_PATHS = \
$(M_CCINC)"$(M_INCPATH)" \
$(M_CCINC)"$(M_INCPATH)/moar" \
$(M_CCINC)"$(M_INCPATH)/libatomic_ops" \
$(M_CCINC)"$(M_INCPATH)/dyncall" \
$(M_CCINC)"$(M_INCPATH)/moar" \
$(M_CCINC)"$(M_INCPATH)/sha1" \
$(M_CCINC)"$(M_INCPATH)/tinymt" \
$(M_CCINC)"$(M_INCPATH)/libtommath" \
$(M_CCINC)"$(M_INCPATH)/libuv"

M_RUN_PERL6 = "$(MOAR)" --libpath="blib" --libpath="$(M_LIBPATH)" perl6.moarvm --nqp-lib=blib

M_BAT = @runner_suffix@
M_BAT_RUNNER = perl6-m@runner_suffix@
Expand Down Expand Up @@ -115,15 +125,9 @@ check_nqp_version: tools/build/check-nqp-version.pl
$(PERL5) tools/build/check-nqp-version.pl $(M_NQP)

$(M_PERL6_OPS_DLL): $(M_PERL6_OPS_SRC) $(M_PERL6_CONT_SRC)
$(M_CC) @moar::ccswitch@ @moar::ccshared@ $(M_CFLAGS) -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 -I$(M_INCPATH) @moar::cincludes@ @moar::ccout@$(M_PERL6_OPS_OBJ) $(M_PERL6_OPS_SRC)
$(M_CC) @moar::ccswitch@ @moar::ccshared@ $(M_CFLAGS) -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 -I$(M_INCPATH) @moar::cincludes@ @moar::ccout@$(M_PERL6_CONT_OBJ) $(M_PERL6_CONT_SRC)
$(M_LD) @moar::ldswitch@ -L@moar::libdir@ @moar::ldshared@ $(M_LDFLAGS) $(M_LDLIBS) @moar::ldout@$(M_PERL6_OPS_DLL) $(M_PERL6_OPS_OBJ) $(M_PERL6_CONT_OBJ) -lmoar @moarimplib@
$(M_CC) @moar::ccswitch@ @moar::ccshared@ $(M_CFLAGS) $(M_MOAR_INC_PATHS) @moar::ccout@$(M_PERL6_OPS_OBJ) $(M_PERL6_OPS_SRC)
$(M_CC) @moar::ccswitch@ @moar::ccshared@ $(M_CFLAGS) $(M_MOAR_INC_PATHS) @moar::ccout@$(M_PERL6_CONT_OBJ) $(M_PERL6_CONT_SRC)
$(M_LD) @moar::ldswitch@ @moar::lddir@"@moar::libdir@" @moar::ldshared@ $(M_LDFLAGS) $(M_LDLIBS) @moar::ldout@$(M_PERL6_OPS_DLL) $(M_PERL6_OPS_OBJ) $(M_PERL6_CONT_OBJ) @moar_lib@

$(PERL6_ML_MOAR): src/Perl6/ModuleLoader.nqp src/vm/moar/ModuleLoaderVMConfig.nqp gen/nqp-version
$(M_NQP) $(M_GEN_CAT) src/vm/moar/ModuleLoaderVMConfig.nqp src/Perl6/ModuleLoader.nqp > $(M_BUILD_DIR)/ModuleLoader.nqp
Expand Down Expand Up @@ -228,18 +232,14 @@ $(M_VALGRIND_RUNNER): tools/build/create-moar-runner.p6 $(M_C_RUNNER) $(PERL6_MO
$(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::ccswitch@ @static_nqp_home_define@ @static_perl6_home_define@ $(M_CFLAGS) $(M_CCINC)$(M_INCPATH) $(M_CCINC)$(M_INCPATH)/moar \
$(M_CCINC)$(M_INCPATH)/libatomic_ops $(M_CCINC)$(M_INCPATH)/dyncall $(M_CCINC)$(M_INCPATH)/moar $(M_CCINC)$(M_INCPATH)/sha1 $(M_CCINC)$(M_INCPATH)/tinymt $(M_CCINC)$(M_INCPATH)/libtommath $(M_CCINC)$(M_INCPATH)/libuv \
@moar::ccout@main@moar::obj@ src/vm/moar/runner/main.c
$(M_LD) @moar::ldout@$@ $(M_LDFLAGS) $(M_MINGW_UNICODE) main@moar::obj@ @moar::lddir@@moar::libdir@ $(M_C_RUNNER_LIBS)
$(M_CC) @moar::ccswitch@ @static_nqp_home_define@ @static_perl6_home_define@ $(M_CFLAGS) $(M_MOAR_INC_PATHS) @moar::ccout@main@moar::obj@ src/vm/moar/runner/main.c
$(M_LD) @moar::ldout@$@ $(M_LDFLAGS) $(M_MINGW_UNICODE) main@moar::obj@ @moar::lddir@"@moar::libdir@" @c_runner_libs@ @moar_lib@

$(M_C_DEBUG_RUNNER): src/vm/moar/runner/main.c
$(RM_F) $(M_C_DEBUG_RUNNER)
# Using only the pkgconfig moar includes does not work, because moar.h assumes all the specific includes below.
$(M_CC) @moar::ccswitch@ @static_nqp_home_define@ @static_perl6_home_define@ -DMOAR_PERL6_RUNNER_DEBUG $(M_CFLAGS) $(M_CCINC)$(M_INCPATH) $(M_CCINC)$(M_INCPATH)/moar \
$(M_CCINC)$(M_INCPATH)/libatomic_ops $(M_CCINC)$(M_INCPATH)/dyncall $(M_CCINC)$(M_INCPATH)/moar $(M_CCINC)$(M_INCPATH)/sha1 $(M_CCINC)$(M_INCPATH)/tinymt $(M_CCINC)$(M_INCPATH)/libtommath $(M_CCINC)$(M_INCPATH)/libuv \
@moar::ccout@main@moar::obj@ src/vm/moar/runner/main.c
$(M_LD) @moar::ldout@$@ $(M_LDFLAGS) $(M_MINGW_UNICODE) main@moar::obj@ @moar::lddir@@moar::libdir@ $(M_C_RUNNER_LIBS)
$(M_CC) @moar::ccswitch@ @static_nqp_home_define@ @static_perl6_home_define@ -DMOAR_PERL6_RUNNER_DEBUG $(M_CFLAGS) $(M_MOAR_INC_PATHS) @moar::ccout@main@moar::obj@ src/vm/moar/runner/main.c
$(M_LD) @moar::ldout@$@ $(M_LDFLAGS) $(M_MINGW_UNICODE) main@moar::obj@ @moar::lddir@"@moar::libdir@" @c_runner_libs@ @moar_lib@


## testing targets
Expand Down

0 comments on commit c1c108f

Please sign in to comment.