On Dec-03, Leopold Toetsch wrote: > # New Ticket Created by Leopold Toetsch > # Please include the string: [perl #18832] > # in the subject line of all future correspondence about this issue. > # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=18832 > > > > Attached patch tries to append building libnci$(SO) to the test_prep > target. I don't know the status of building (or trying to build) shared > libs on different platforms, so I didn't check it in. > It needs definitely work to integrate libnci.def for msvc.
Here's a messier but somewhat more complete patch which also moves the shared libs to blib/lib. This works for me on both gcc/linux/i386 and gcc/darwin/ppc. It uses perl5's cccdlflags to build the shared library, which might actually work other places. Still no *.def support, though. I hope I didn't mess up this patch. It contains some new files in nonexistent directories, and I don't want to cvs add them because then they'd never go away. So I manually appended a diff with /dev/null instead.
Index: config/gen/makefiles/root.in =================================================================== RCS file: /cvs/public/parrot/config/gen/makefiles/root.in,v retrieving revision 1.62 diff -a -u -r1.62 root.in --- config/gen/makefiles/root.in 12 Dec 2002 11:21:06 -0000 1.62 +++ config/gen/makefiles/root.in 16 Dec 2002 05:14:10 -0000 @@ -133,6 +133,8 @@ C_LIBS = ${libs} CC = ${cc} +CC_SHARED = ${cc} +CC_SHARED_FLAGS = ${cccdlflags} PERL = ${perl} @@ -167,9 +169,14 @@ ${make_set_make} +.SUFFIXES: .c .o .so + .c$(O) : $(CC) $(CFLAGS) ${cc_o_out}$@ -c $< +.c$(SO) : + $(CC_SHARED) $(CFLAGS) $(CC_SHARED_FLAGS) ${cc_o_out}$@ -c $< + all : $(TEST_PROG) docs mops : examples/assembly/mops${exe} examples/mops/mops${exe} @@ -200,7 +207,7 @@ blib/lib : blib -mkdir blib${slash}lib -shared : $(GEN_HEADERS) blib/lib blib/lib/libparrot$(SO) ${blib_lib_libparrot_a} +shared : $(GEN_HEADERS) blib/lib blib/lib/libparrot$(SO) ${parrot_static_lib} # XXX Unix-only for now blib/lib/libparrot$(A) : blib/lib $(O_DIRS) $(O_FILES) @@ -208,11 +215,14 @@ $(RANLIB) $@ blib/lib/libparrot$(SO) : blib/lib $(O_DIRS) $(O_FILES) - $(LD) $(LD_SHARED) $(LD_SHARED_FLAGS) $(LDFLAGS) $(LD_OUT)blib/lib/libparrot$(SO) $(O_FILES) $(C_LIBS) + $(LD) $(LD_SHARED) $(LD_SHARED_FLAGS) $(LDFLAGS) +$(LD_OUT)blib${slash}lib${slash}libparrot$(SO) $(O_FILES) $(C_LIBS) $(TEST_PROG_SO) : test_main$(O) blib/lib/libparrot$(SO) lib/Parrot/OpLib/core.pm $(LINK) $(LINKFLAGS) $(LD_OUT)$(TEST_PROG) test_main$(O) blib/lib/libparrot$(A) $(C_LIBS) +blib/lib/libnci$(SO) : nci_test$(SO) + $(LD) $(LD_SHARED) $(LD_SHARED_FLAGS) $(LDFLAGS) $(LD_OUT)${nci_shared_lib} +nci_test$(SO) $(C_LIBS) + # XXX The dependancies on SO.MAJOR.MINOR and SO.VERSION are removed # because those should be done at "make install" and not "make shared" # It also makes the task of getting this working on win32 much easier. :) @@ -324,7 +334,7 @@ examples/mops/mops${exe} : examples/mops/mops$(O) $(LINK) $(LINKFLAGS) ${ld_out}examples/mops/mops${exe} \ - examples/mops/mops$(O) blib/lib/libparrot$(A) $(C_LIBS) + examples/mops/mops$(O) ${parrot_static_lib} $(C_LIBS) ############################################################################### @@ -511,12 +521,12 @@ $(PERL) t/harness $(EXTRA_TEST_ARGS) -g $(TEST_PROG_ARGS) quick # Common prep for all test targets -test_prep : ${blib_lib_libparrot_a} assemble.pl +test_prep : ${parrot_static_lib} ${nci_shared_lib} assemble.pl test_dummy : $(PERL) t/harness $(EXTRA_TEST_ARGS) $(TEST_PROG_ARGS) -testp : $(TEST_PROG) test_prep blib/lib/libcore_prederef$(SO) blib/lib/libparrot$(SO) $(TEST_PROG_SO) test_dummy_p +testp : $(TEST_PROG) test_prep blib/lib/libcore_prederef$(SO) ${parrot_shared_lib} +$(TEST_PROG_SO) test_dummy_p test_dummy_p : $(PERL) t/harness $(EXTRA_TEST_ARGS) $(TEST_PROG_ARGS) -P Index: config/init/data.pl =================================================================== RCS file: /cvs/public/parrot/config/init/data.pl,v retrieving revision 1.9 diff -a -u -r1.9 data.pl --- config/init/data.pl 13 Dec 2002 15:11:24 -0000 1.9 +++ config/init/data.pl 16 Dec 2002 05:14:10 -0000 @@ -24,6 +24,7 @@ # (Usually cc or cl, or something like that.) cc => $Config{cc}, ccflags => $Config{ccflags}, + cccdlflags => $Config{cccdlflags}, # Linker, used to link object files (plus libraries) into # an executable. It is usually $cc on Unix-ish systems. @@ -61,6 +62,9 @@ # should we have a dependancy upon arc to generate .a's? blib_lib_libparrot_a => 'blib/lib/libparrot$(A)', + parrot_static_lib => 'blib/lib/libparrot$(A)', + parrot_shared_lib => 'blib/lib/libparrot$(SO)', + nci_shared_lib => 'blib/lib/libnci$(SO)', perl => $^X, test_prog => 'parrot', Index: t/pmc/nci.t =================================================================== RCS file: /cvs/public/parrot/t/pmc/nci.t,v retrieving revision 1.5 diff -a -u -r1.5 nci.t --- t/pmc/nci.t 15 Dec 2002 07:05:46 -0000 1.5 +++ t/pmc/nci.t 16 Dec 2002 05:14:10 -0000 @@ -3,11 +3,11 @@ use Parrot::Config; SKIP: { -if ($PConfig{jitcpuarch} eq 'i386' && -e "libnci" . $PConfig{so}) { - $ENV{LD_LIBRARY_PATH} = '.'; +if (-e "blib/lib/libnci" . $PConfig{so}) { + $ENV{LD_LIBRARY_PATH} = 'blib/lib'; } else { - skip('needs jit/i386 and libnci'.$PConfig{so}, + skip('needs blib/lib/libnci'.$PConfig{so}, Test::Builder->expected_tests()); } --- /dev/null Thu Apr 11 07:25:15 2002 +++ config/auto/varargs.pl Sun Dec 15 00:22:50 2002 @@ -0,0 +1,24 @@ +package Configure::Step; + +use strict; +use vars qw($description @args); +use Parrot::Configure::Step ':auto'; + +$description="Determining how to access va_list..."; + +sub runstep { + my $method = "unknown"; + cc_gen('config/auto/varargs/test_c.in'); + cc_build(); + $method = "direct" if (cc_run_capture(1) =~ /yes/); + $method = "address" if (cc_run_capture(2) =~ /yes/); + cc_clean(); + + if ($method eq "unknown") { + die "Can't determine how to get a ptr to a va_list!\n"; + } + + Configure::Data->set(va_list_ptr => $method); +} + +1; --- /dev/null Thu Apr 11 07:25:15 2002 +++ config/auto/varargs/test_c.in Sun Dec 15 00:19:10 2002 @@ -0,0 +1,61 @@ +/* + * testvarargs.c - figure out how to get a pointer to a va_list + */ + +#include <stdio.h> +#include <stdarg.h> + +#define UNKNOWN 0 +#define ADDRESS_OF 1 +#define DIRECT 2 + +int +test_address(int first_arg, ...) +{ + va_list args; + va_list* ptr; + int value; + va_start(args, first_arg); + ptr = (va_list*) &args; + value = va_arg(*ptr, int); + va_end(args); + return (value == 7531); +} + +int +test_direct(int first_arg, ...) +{ + va_list args; + va_list* ptr; + int value; + va_start(args, first_arg); + ptr = (va_list*) args; + value = va_arg(*ptr, int); + va_end(args); + return (value == 7531); +} + +int +main(int argc, char *argv[]) +{ + if (argv[1][0] == '1' && test_direct(0, 7531)) { + printf("yes\n"); + return 0; + } else if (argv[1][0] == '2' && test_address(0, 7531)) { + printf("yes\n"); + return 0; + } else { + printf("unknown\n"); + return 1; + } +} + +/* + * Local variables: + * c-indentation-style: bsd + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + * + * vim: expandtab shiftwidth=4: + */