Skip to content

Commit

Permalink
perl-compatible extensions lists in config.sh
Browse files Browse the repository at this point in the history
There are tests that read config.sh and expect module lists
in the Configure format.

To work around this, there are two copies for some of the lists
now: one (dynamic_ext) perl-compatible for configpm and test and
whatever else may need it, and another one (fullpath_dynamic_ext)
with proper directory names for use in Makefiles.

Since we're back to the perl format now, configpm patch can be
dropped for all perl versions.
  • Loading branch information
arsv committed Jan 10, 2020
1 parent 294a2b0 commit f280b9e
Show file tree
Hide file tree
Showing 30 changed files with 97 additions and 275 deletions.
72 changes: 43 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,18 @@ src += $(mallocsrc)

obj = $(patsubst %.c,%$o,$(wildcard $(src)))

static_tgt = $(patsubst %,%/pm_to_blib,$(static_ext))
dynamic_tgt = $(patsubst %,%/pm_to_blib,$(dynamic_ext))
nonxs_tgt = $(patsubst %,%/pm_to_blib,$(nonxs_ext))
disabled_dynamic_tgt = $(patsubst %,%/pm_to_blib,$(disabled_dynamic_ext))
disabled_nonxs_tgt = $(patsubst %,%/pm_to_blib,$(disabled_nonxs_ext))
static_modules = $(patsubst %,%/pm_to_blib,$(fullpath_static_ext))
dynamic_modules = $(patsubst %,%/pm_to_blib,$(fullpath_dynamic_ext))
nonxs_modules = $(patsubst %,%/pm_to_blib,$(fullpath_nonxs_ext))
disabled_dynamic = $(patsubst %,%/pm_to_blib,$(disabled_dynamic_ext))
disabled_nonxs = $(patsubst %,%/pm_to_blib,$(disabled_nonxs_ext))
# perl module names for static mods
static_pmn = $(shell for e in $(static_ext) ; do grep '^NAME =' $$e/Makefile | cut -d' ' -f3 ; done)
static_pmn = $(shell for e in $(fullpath_static_ext) ; do grep '^NAME =' $$e/Makefile | cut -d' ' -f3 ; done)

dynaloader_o = $(patsubst %,%$o,$(dynaloader))

ext = $(nonxs_ext) $(dynamic_ext) $(static_ext)
tgt = $(nonxs_tgt) $(dynamic_tgt) $(static_tgt)
disabled_ext = $(disabled_nonxs_ext) $(disabled_dynamic_ext)

ext_makefiles = $(patsubst %,%/Makefile,$(ext))
disabled_ext_makefiles = $(pathsubst %,%/Makefile,$(disabled_ext))
modules = $(fullpath_nonxs_ext) $(fullpath_dynamic_ext) $(fullpath_static_ext)
disabled = $(disabled_nonxs_ext) $(disabled_dynamic_ext)

# ---[ perl-cross patches ]-----------------------------------------------------
# Note: the files are patched in-place, and so do not make valid make-rules
Expand All @@ -54,6 +50,8 @@ disabled_ext_makefiles = $(pathsubst %,%/Makefile,$(disabled_ext))
CROSSPATCHES = $(shell find cnf/diffs/$(patchset) -name '*.patch')
CROSSPATCHED = $(patsubst %.patch,%.applied,$(CROSSPATCHES))

.PHONY: crosspatch

crosspatch: $(CROSSPATCHED)

# A minor fix for buildroot, force crosspatching when running "make perl modules"
Expand Down Expand Up @@ -218,7 +216,7 @@ lib/buildcustomize.pl: write_buildcustomize.pl | miniperl$X
# The rules below replace make_ext script used in the original
# perl build chain. Some host-specific functionality is lost.
# Check miniperl_top to see how it works.
$(nonxs_tgt) $(disabled_nonxs_tgt): %/pm_to_blib: | %/Makefile
$(nonxs_modules) $(disabled_nonxs): %/pm_to_blib: | %/Makefile
$(MAKE) -C $(dir $@) all PERL_CORE=1 LIBPERL=$(LIBPERL)

DynaLoader$o: | ext/DynaLoader/pm_to_blib
Expand All @@ -230,17 +228,19 @@ ext/DynaLoader/pm_to_blib: %/pm_to_blib: | %/Makefile

ext/DynaLoader/Makefile: config.h | dist/lib/pm_to_blib

$(static_tgt): %/pm_to_blib: | %/Makefile $(nonxs_tgt)
$(static_modules): %/pm_to_blib: | %/Makefile $(nonxs_tgt)
$(MAKE) -C $(dir $@) all PERL_CORE=1 LIBPERL=$(LIBPERL) LINKTYPE=static static

$(dynamic_tgt) $(disabled_dynamic_tgt): %/pm_to_blib: | %/Makefile
$(dynamic_modules) $(disabled_dynamic): %/pm_to_blib: | %/Makefile
$(MAKE) -C $(dir $@) all PERL_CORE=1 LIBPERL=$(LIBPERL) LINKTYPE=dynamic

lib/re.pm: ext/re/re.pm
cp -f ext/re/re.pm lib/re.pm

lib/lib.pm: dist/lib/pm_to_blib

.PHONY: preplibrary

preplibrary: $(CONFIGPM) | miniperl$X lib/re.pm lib/lib.pm

dist/lib/Makefile: dist/lib/Makefile.PL cflags config.h $(CONFIGPM) | miniperl$X
Expand All @@ -255,12 +255,15 @@ dist/lib/Makefile: dist/lib/Makefile.PL cflags config.h $(CONFIGPM) | miniperl$X
PERL_CORE=1 LIBPERL_A=$(LIBPERL) PERL="$(top)miniperl_top"

# Allow building modules by typing "make cpan/Module-Name"
$(static_ext) $(dynamic_ext) $(nonxs_ext) $(disabled_dynamic_ext) $(disabled_nonxs_ext): %: %/pm_to_blib
.PHONY: $(modules) $(disabled)
$(modules) $(disabled): %: %/pm_to_blib

.PHONY: nonxs_ext dynamic_ext static_ext extensions modules

nonxs_ext: $(nonxs_tgt)
dynamic_ext: $(dynamic_tgt)
static_ext: $(static_tgt)
extensions: cflags $(nonxs_tgt) $(dynamic_tgt) $(static_tgt)
nonxs_ext: $(nonxs_modules)
dynamic_ext: $(dynamic_modules)
static_ext: $(static_modules)
extensions: cflags nonxs_ext dynamic_ext static_ext
modules: extensions

# Some things needed to make modules
Expand All @@ -270,10 +273,12 @@ modules: extensions
cflags: cflags.SH
sh $<

.PHONY: makeppport

makeppport: $(CONFIGPM) | miniperl$X
./miniper_top mkppport

makefiles: $(ext:pm_to_blib=Makefile)
makefiles: $(patsubst %,%/Makefile,$(modules))

dynaloader: $(dynaloader_o)

Expand Down Expand Up @@ -322,25 +327,29 @@ ext/Pod-Functions/pm_to_blib: | cpan/Pod-Simple/pm_to_blib

cpan/Pod-Simple/pm_to_blib: | cpan/Pod-Escapes/pm_to_blib

$(dynamic_tgt): | dist/ExtUtils-CBuilder/pm_to_blib
$(dynamic_modules): | dist/ExtUtils-CBuilder/pm_to_blib

dist/ExtUtils-CBuilder/pm_to_blib: | cpan/Perl-OSType/pm_to_blib cpan/Text-ParseWords/pm_to_blib

# ---[ modules cleanup & rebuilding ] ------------------------------------------

.PHONY: modules-reset modules-makefiles modules-clean

modules-reset:
$(if $(nonxs_ext), rm -f $(patsubst %,%/pm_to_blib,$(nonxs_ext)))
$(if $(static_ext), rm -f $(patsubst %,%/pm_to_blib,$(static_ext)))
$(if $(dynamic_ext), rm -f $(patsubst %,%/pm_to_blib,$(dynamic_ext)))
$(if $(disabled_nonxs_ext), rm -f $(patsubst %,%/pm_to_blib,$(disabled_nonxs_ext)))
$(if $(disabled_dynamic_ext), rm -f $(patsubst %,%/pm_to_blib,$(disabled_dynamic_ext)))
$(if $(nonxs_modules), rm -f $(nonxs_modules))
$(if $(static_modules), rm -f $(static_modules))
$(if $(dynamic_modules), rm -f $(dynamic_modules))
$(if $(disabled_nonxs), rm -f $(disabled_nonxs))
$(if $(disabled_dynamic), rm -f $(disabled_dynamic))

modules-makefiles: $(ext_makefiles)
modules-makefiles: makefiles

modules-clean: clean-modules

# ---[ Misc ]-------------------------------------------------------------------

.PHONY: utilities

utilities: miniperl$X $(CONFIGPM)
$(MAKE) -C utils all

Expand Down Expand Up @@ -449,7 +458,12 @@ clean-subdirs:

# assuming modules w/o Makefiles were never built and need no cleaning
clean-modules: config.h
@for i in $(ext) $(disabled_ext); do test -f $$i/Makefile && touch $$i/Makefile && $(MAKE) -C $$i clean || true; done
@for i in $(modules disabled); do \
test -f $$i/Makefile && \
touch $$i/Makefile && \
$(MAKE) -C $$i clean \
|| true; \
done

clean-generated-files:
-rm -f uudmap.h opmini.c generate_uudmap$X bitcount.h $(CONFIGPM)
Expand Down
13 changes: 4 additions & 9 deletions Makefile.config.SH
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ if [ ! -f config.sh ]; then
exit -1
fi

disabledmods=''

. ./config.sh
true > Makefile.config
if [ "$usecrosscompile" = 'define' ]; then
Expand Down Expand Up @@ -138,17 +136,14 @@ LNS = $lns
archlib = $archlib
dynamic_ext = $dynamic_ext
static_ext = $static_ext
nonxs_ext = $nonxs_ext
END
fullpath_dynamic_ext = $fullpath_dynamic_ext
fullpath_static_ext = $fullpath_static_ext
fullpath_nonxs_ext = $fullpath_nonxs_ext
if [ "$disabledmods" = 'define' ]; then
cat >> Makefile.config << END
disabled_dynamic_ext=$disabled_dynamic_ext
disabled_nonxs_ext=$disabled_nonxs_ext
END
fi


vertag=$PERL_REVISION$PERL_VERSION$PERL_SUBVERSION
echo >> Makefile.config
Expand Down
86 changes: 50 additions & 36 deletions cnf/configure_mods.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
# In-tree perl modules discovery.

# Some of the tests use $Config{'extensions'} to decide whether to do their
# thing or not. The original Configure uses weird old format for module names,
# "File/Glob" for what should have been either File::Glob or ext/File-Glob.
#
# We have to keep those for compatibility, but we also need directory names
# to use in makefiles. The code below builds both kinds of module lists at
# once, the perl-compatible set (extensions, known_extensions, static_ext etc)
# and the set the Makefiles will use (fullpath_*_ext and disabled_*_ext).

test "$mode" = 'buildmini' && return

# See also: modsymname in configure__f.sh

modvarname() {
echo "$1" | sed -r -e 's!^(ext|cpan|dist|lib)/!!' -e 's!-!/!g'
}

# Since 5.10.1 the module dirs are flat, so there's no need
# for recursive search etc.
extdir() {
Expand All @@ -20,54 +35,65 @@ extdir() {
done
}

extadddisabled() {
if [ "$1" = "xs" ]; then
disabled_dynamic_ext="$disabled_dynamic_ext$2 "
else
disabled_nonxs_ext="$disabled_nonxs_ext$2 "
fi
}

extadd() {
s=`modsymname "$2"`
n=`modvarname "$2"`

if [ "$s" = "dynaloader" ]; then
msg " skipping $2"
return
fi
known_extensions="$known_extensions$2 "

known_extensions="$known_extensions$n "

getenv o "only_$s"
if [ -n "$onlyext" -a -z "$o" ]; then
msg " skipping $2"
extadddisabled "$1" "$2"
return
fi

getenv d "disable_$s"
if [ -n "$d" -a "$d" != "0" ]; then
msg " disabled $2"
extadddisabled "$1" "$2"
return
fi

extensions="$extensions$n "

getenv t "static_$s"
if [ "$1" = "xs" -a -n "$t" -a "$t" != "0" ]; then
msg " static $2"
static_ext="$static_ext$2 "
static_ext="$static_ext$n "
fullpath_static_ext="$fullpath_static_ext$2 "
elif [ "$1" = "xs" -a -n "$allstatic" ]; then
msg " static $2"
static_ext="$static_ext$2 "
static_ext="$static_ext$n "
fullpath_static_ext="$fullpath_static_ext$2 "
elif [ "$1" = "xs" ]; then
msg " dynamic $2"
dynamic_ext="$dynamic_ext$2 "
dynamic_ext="$dynamic_ext$n "
fullpath_dynamic_ext="$fullpath_dynamic_ext$2 "
else
msg " non-xs $2"
nonxs_ext="$nonxs_ext$2 "
nonxs_ext="$nonxs_ext$n "
fullpath_nonxs_ext="$fullpath_nonxs_ext$2 "
fi
# See also: findext.patch
if [ "$2" = "cpan/Scalar-List-Utils" ]; then
shadow_ext="${shadow_ext}cpan/List-Util "
fi
}

extadddisabled() {
s=`modsymname "$2"`
if [ "$1" = "xs" ]; then
disabled_dynamic_ext="$disabled_dynamic_ext$2 "
else
disabled_nonxs_ext="$disabled_nonxs_ext$2 "
fi
}

extonlyif() {
m="$1"; shift
s=`modsymname "$m"`
Expand Down Expand Up @@ -117,11 +143,10 @@ extonlyif Win32CORE "$osname" = 'win32'

extonlyif Thread "$usethreads" = 'define'

known_extensions=
dynamic_ext=
static_ext=
nonxs_ext=
shadow_ext=
unset extensions known_extensions
unset nonxs_ext static_ext dynamic_ext shadow_ext
unset fullpath_nonxs_ext fullpath_dynamic_ext fullpath_static_ext
unset disabled_nonxs_ext disabled_dynamic_ext

for d in ext cpan dist; do
msg "Looking for extensions recursively under $d/"
Expand All @@ -138,22 +163,11 @@ definetrimspaces nonxs_ext "$nonxs_ext"
definetrimspaces dynamic_ext "$dynamic_ext"
definetrimspaces known_extensions "$known_extensions"

# Unless the user explictily asks us not to do it,
# allow building disabled mods with "make cpan/Some-Module"
# This only affects perl-cross Makefile via Makefile.config

if [ "$disabledmods" != 'define' ]; then
define disabledmods 'define'
definetrimspaces disabled_dynamic_ext "$disabled_dynamic_ext"
definetrimspaces disabled_nonxs_ext "$disabled_nonxs_ext"
fi
definetrimspaces fullpath_static_ext "$fullpath_static_ext"
definetrimspaces fullpath_nonxs_ext "$fullpath_nonxs_ext"
definetrimspaces fullpath_dynamic_ext "$fullpath_dynamic_ext"

# Some of the tests use $Config{'extensions'} to decide whether to do their
# thing or not. The original Configure uses weird old format for module names,
# "File/Glob" for what should have been either File::Glob or ext/File-Glob.
#
# perl-cross keeps full directory names in ${...}_ext and $extensions,
# and does the conversion in configpm. This keeps things simple when writing
# Makefiles, and does not break tests later.
definetrimspaces disabled_dynamic_ext "$disabled_dynamic_ext"
definetrimspaces disabled_nonxs_ext "$disabled_nonxs_ext"

definetrimspaces extensions "$static_ext $dynamic_ext $nonxs_ext $shadow_ext"
definetrimspaces extensions "$extensions"
30 changes: 0 additions & 30 deletions cnf/diffs/cperl-5.24.0/configpm.patch

This file was deleted.

30 changes: 0 additions & 30 deletions cnf/diffs/cperl-5.24.1/configpm.patch

This file was deleted.

Loading

0 comments on commit f280b9e

Please sign in to comment.