From 07c577b8990c5f9627ef21204f90e84006596ae9 Mon Sep 17 00:00:00 2001 From: Jarkko Hietaniemi Date: Sun, 1 Aug 1999 22:41:41 +0000 Subject: Integrate with Sarathy. perl.h and util.c required manual resolving. p4raw-id: //depot/cfgperl@3864 --- cygwin/Makefile.SHs | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++++ cygwin/ld2.in | 20 ++++++ cygwin/perlld.in | 89 +++++++++++++++++++++++++ 3 files changed, 298 insertions(+) create mode 100644 cygwin/Makefile.SHs create mode 100644 cygwin/ld2.in create mode 100644 cygwin/perlld.in (limited to 'cygwin') diff --git a/cygwin/Makefile.SHs b/cygwin/Makefile.SHs new file mode 100644 index 0000000000..e6a604db87 --- /dev/null +++ b/cygwin/Makefile.SHs @@ -0,0 +1,189 @@ +# This file is read by Makefile.SH to produce rules for $(LIBPERL) (and +# some additional rules as well). + +# Rerun `sh Makefile.SH; make depend' after making any change. + +# Additional rules supported: libperls.a (for static linking), +# ld2, perlld (dynamic linking tools) +# + +#! /bin/sh +case $CONFIG in +'') + if test -f config.sh; then TOP=.; + elif test -f ../config.sh; then TOP=..; + elif test -f ../../config.sh; then TOP=../..; + elif test -f ../../../config.sh; then TOP=../../..; + elif test -f ../../../../config.sh; then TOP=../../../..; + else + echo "Can't find config.sh."; exit 1 + fi + . $TOP/config.sh + ;; +esac + +addtopath=`pwd` +$spitshell >>Makefile <ld2 + @echo "installing ld2 into $installbin" +# install is included in Cygwin distributions, and we make a note of th +# requirement in the README.cygwin file. However, let's give them +# a warning. + @if test -n "`type $1 2>&1 | sed -n -e '/'$1'$/p'`" ; then \ + install -c -m 755 ld2 ${installbin}/ld2 ; \ + else \ + echo "*************************************************" ; \ + echo "Oh, no! You didn't read the README.cygwin" ; \ + echo "file, which stated that \"install\" was required." ; \ + echo "Make will probably fail in a few more steps." ; \ + echo "When it does, copy \"ld2\" to a directory in" ; \ + echo "your path, other than \".\"." ; \ + echo "\"/usr/local/bin\" or something similar will do." ; \ + echo "Then restart make." ; \ + echo "*************************************************" ; \ + fi + +!GROK!THIS! + +$spitshell >>Makefile <perlld + +!GROK!THIS! + +# make sure that all library names are not malformed +libperl=`echo $libperl|sed -e s,\\\..*,,` + +# it would be nice to allow dll to have any name, +# but for now i insist on 'lib.dll' +if ( ! ( echo $libperl | grep '^lib' >/dev/null ) ) +then + libperl=lib$libperl +fi +linklibperl=-l`echo $libperl|sed -e s,^lib,,` + +$spitshell >>Makefile <>Makefile <<'!NO!SUBS!' +cwobj = $(obj) + +# override default rule (NB: make croaks!) to force dll usage +perlmain$(OBJ_EXT): perlmain.c + $(CCCMD) $(PLDLFLAGS) -DUSEIMPORTLIB $*.c + +# library used to make statically linked executables +# miniperl is linked against it to avoid libperl.dll locking +$(LIBPERL)s$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) + $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj) + +# dll and import library +$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) ld2 + $(LDLIBPTH) ld2 $(SHRPLDFLAGS) -o $(LIBPERL)$(DLSUFFIX) \ + perl$(OBJ_EXT) $(cwobj) $(libs) + +# How to build executables. + +# The miniperl -w -MExporter line is a basic cheap test to catch errors +# before make goes on to run preplibrary and then MakeMaker on extensions. +# This is very handy because later errors are often caused by miniperl +# build problems but that's not obvious to the novice. +# The Module used here must not depend on Config or any extensions. + +miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)s$(LIB_EXT) + $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL)s $(libs) + $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest + +!NO!SUBS! + ;; +*) +$spitshell >>Makefile <<'!NO!SUBS!' + +# perl library +$(LIBPERL)$(LIB_EXT): $& perl$(OBJ_EXT) $(cwobj) + $(AR) rcu $@ perl$(OBJ_EXT) $(cwobj) + +# How to build executables. + +# The miniperl -w -MExporter line is a basic cheap test to catch errors +# before make goes on to run preplibrary and then MakeMaker on extensions. +# This is very handy because later errors are often caused by miniperl +# build problems but that's not obvious to the novice. +# The Module used here must not depend on Config or any extensions. + +miniperl: $& miniperlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) + $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) -o miniperl miniperlmain$(OBJ_EXT) $(LLIBPERL) $(libs) + $(LDLIBPTH) ./miniperl -w -Ilib -MExporter -e 0 || $(MAKE) minitest + +!NO!SUBS! + ;; +esac + +# libperl.a is _the_ library both in dll and static cases +# $(LIBPERL)$(LIB_EXT) expands to this name dependless of build model +# +$spitshell >>Makefile <<'!NO!SUBS!' + +perl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs + $(SHRPENV) $(LDLIBPTH) $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o perl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs) + +pureperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs + $(SHRPENV) $(LDLIBPTH) purify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o pureperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs) + +purecovperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs + $(SHRPENV) $(LDLIBPTH) purecov $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o purecovperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs) + +quantperl: $& perlmain$(OBJ_EXT) $(LIBPERL)$(LIB_EXT) $(DYNALOADER) $(static_ext) ext.libs + $(SHRPENV) $(LDLIBPTH) quantify $(CC) $(LARGE) $(CLDFLAGS) $(CCDLFLAGS) -o quantperl perlmain$(OBJ_EXT) $(DYNALOADER) $(static_ext) $(LLIBPERL) `cat ext.libs` $(libs) + +!NO!SUBS! + +# suid perl is removed - i've never seen suid scripts for win32 + +############################################## +# additional targets + +$spitshell >>Makefile <<'!NO!SUBS!' + +DIST_DIRECTORY = .dist + +distdir: miniperl + -mkdir $(DIST_DIRECTORY) + ./miniperl '-MExtUtils::Manifest' \ + -e "ExtUtils::Manifest::manicopy(ExtUtils::Manifest::maniread(),'$(DIST_DIRECTORY)')" + +!NO!SUBS! diff --git a/cygwin/ld2.in b/cygwin/ld2.in new file mode 100644 index 0000000000..3776c71f87 --- /dev/null +++ b/cygwin/ld2.in @@ -0,0 +1,20 @@ +#!/bin/sh +# +# ld wrapper for building dynamic lib version of perl; +# passes all args to perlld +# + +# own miniperl is first candidate 'cause it doesn not lock libperl.dll +for trythis in @buildpath@/miniperl @buildpath@/perl perl +do + if [ -x $trythis ] + then + $trythis @buildpath@/perlld "$@" + exit $? + fi +done +# hard luck! +echo i see no perl executable around there +echo perl is required to build dynamic libraries +echo go fetch one or build this one static +exit 1 diff --git a/cygwin/perlld.in b/cygwin/perlld.in new file mode 100644 index 0000000000..19a1a2f7b9 --- /dev/null +++ b/cygwin/perlld.in @@ -0,0 +1,89 @@ +# +# Perl script being a wrapper around the gnu ld. When a dll is specified to +# to be built, special processing is done, else the standard ld is called. +# + +# theese are pretty mandatory +my $CC = '@CC@'; +my $DLLWRAP = '@DLLWRAP@'; + +# following are optional. +my $WRAPDRIVER = '@WRAPDRIVER@'; +my $AS = '@AS@'; +my $DLLTOOL = '@DLLTOOL@'; +my $EXPORT_ALL = @EXPORT_ALL@; +# if some of extensions are undefined, +# no corresponding output will be done. +# most probably, you'd like to have an export library +my $DEF_EXT = '@DEF_EXT@'; +# my $EXP_EXT = '@EXP_EXT@'; +my $LIB_EXT = '@LIB_EXT@'; + +#my $DEBUG ="perlld.out"; +my $DEBUG =undef; + +my $args = join(" ",@ARGV); # get args +my $verbose =grep(/^\-(v|\-verbose)$/, @ARGV); + +sub shellexec; + +if ($DEBUG) { + open DEBUGFILE, ">>$DEBUG"; + print DEBUGFILE "\n--- " .localtime() ."\nargs:\n$args\n\nenvironment:\n"; + foreach (keys(%ENV)) { print DEBUGFILE $_, "=", $ENV{$_}, "\n"; }; +} + +if ($args !~ /\-o (\S+)/) { + print DEBUGFILE "+ no dll output -- passing to gcc\n\n" if $DEBUG; + shellexec("$CC $args\n"); +} else { + my ($path, $command, $dllname, $libname) =''; + + $dllname =$1; + print DEBUGFILE "output file: $dllname\n" if $DEBUG; + # remove -o from args + $args =~ s/(^| )\-o \S+/$1/; + + # Check for path: + if( $dllname =~ /.*[\/\\]/){ + $dllname = $'; + $path = $&; + $path =~ s,[/\\](\.[/\\])*,/,g; + } + if ($dllname =~ /\./) { $libname =$`; } else { $libname =$dllname; }; + $dllname ="$libname.dll"; + $libname ="lib$libname" unless ($libname =~ /^lib/); + print DEBUGFILE "dll name: $dllname\nimport library: $libname\npath: $path\n" if $DEBUG; + + $command ="$DLLWRAP --dllname $dllname"; + $command .=" --driver-name $WRAPDRIVER" if $WRAPDRIVER; + $command .=" --dlltool $DLLTOOL" if $DLLTOOL; + $command .=" --export-all-symbols" if $EXPORT_ALL; + $command .=" --as $AS" if $AS; + $command .=" --verbose" if $verbose; + + $command .=" --output-def $libname$DEF_EXT" if $DEF_EXT; + $command .=" --output-exp $libname$EXP_EXT" if $EXP_EXT; + $command .=" --output-lib $libname$LIB_EXT" if $LIB_EXT; + + # other args are passed through + shellexec("$command \\\n$args\n"); + + if ($path) { + $command ="mv $dllname"; + $command .=" $libname$LIB_EXT" if $LIB_EXT; + shellexec("$command $path\n"); + }; +}; +close DEBUGFILE if $DEBUG; + +#--------------------------------------------------------------------------- +sub shellexec{ + my $command =shift; + print $command; + print DEBUGFILE $command if $DEBUG; + system($command) == 0 + or die "perlld: *** system() failed to execute\n$command\n"; +}; + +1; -- cgit v1.2.1