develooper Front page | perl.perl5.porters | Postings from April 2007

VMS and Win32 Makefiles in change 31059

Thread Next
From:
Nicholas Clark
Date:
April 25, 2007 03:11
Subject:
VMS and Win32 Makefiles in change 31059
Message ID:
20070424231737.GA52697@plum.flirble.org
Originally the unpack code 'u' was implemented with character arithmetic.
Change 1697 replaced it with a table based algorithm, and some code to generate
the table at run time, which avoided character set issues (Think EBCDIC)

http://public.activestate.com/cgi-bin/perlbrowse/p/1697 and search for uudmap

Unfortunately, assigning to

  static char uudmap[256];

at run time isn't a great idea, so it was moved into the interpreter structure
at the time of ithreads.

This means that currently, every perl thread has 256 bytes to hold a
duplicate of the uudecode table. Hmmm. Not very frugal.

Plus there's a small amount of run time code to check whether the table needs
building, and if so do it, which means a slight size and speed hit.

So I've changed things to generate the table at build time from that C code,
which should still keep the character set independence, but saves
256 * ($threads - 1) bytes of memory. However, it requires doing funky things
in the Makefile, as I'm generating a header, uudmap.h, to contain the
definition for the intialiser to PL_uudmap (which has become a constant
global). I have *nix working (which I can test - hopefully it will
work on Cygwin and OS/2). The Makefile generated looks like this:

globals$(OBJ_EXT): uudmap.h

uudmap.h: generate_uudmap$(EXE_EXT)
	./generate_uudmap$(EXE_EXT) >uudmap.h

generate_uudmap$(EXE_EXT): generate_uudmap$(OBJ_EXT)
	$(CC) -o generate_uudmap $(LDFLAGS) generate_uudmap$(OBJ_EXT) $(libs)


which ensures that the header uudmap.h is generated before globals.o is
built, as that's the only source file which needs the definition.
There are also lines to remove generate_uudmap generate_uudmap.o and uudmap.h
at make clean time.

However, I can't test Win32 or VMS. I've tried to write the makefile sections
based on cut&paste from the rules for miniperl and x2p, but I suspect I have
bugs:

rm/Log [.ext.DynaLoader]dl_vms.c

==== //depot/perl/win32/Makefile#331 (text) ====

@@ -957,6 +957,15 @@
 <<
 	$(EMBED_EXE_MANI)
 
+globals$(o) : uudmap.h
+
+uudmap.h: generate_uudmap.exe
+	generate_uudmap >uudmap.h
+
+generate_uudmap.exe : generate_uudmap$(o)
+	$(LINK32) -subsystem:console -out:$@ @<<
+		$(LINK_FLAGS) $(LIBFILES) generate_uudmap$(o)
+
 perlmain.c : runperl.c
 	copy runperl.c perlmain.c
 
@@ -1274,6 +1283,7 @@
 	-@$(DEL) $(PERLSTATICLIB)
 	-@$(DEL) $(PERLDLL)
 	-@$(DEL) $(CORE_OBJ)
+	-@$(DEL) generate_uudmap.exe generate_uudmap$(o) uudmap.h
 	-if exist $(MINIDIR) rmdir /s /q $(MINIDIR)
 	-if exist $(UNIDATADIR1) rmdir /s /q $(UNIDATADIR1)
 	-if exist $(UNIDATADIR2) rmdir /s /q $(UNIDATADIR2)

==== //depot/perl/win32/makefile.mk#368 (text) ====

@@ -1266,6 +1266,23 @@
 	$(EMBED_EXE_MANI)
 .ENDIF
 
+globals$(o) : uudmap.h
+
+uudmap.h: generate_uudmap.exe
+	generate_uudmap >uudmap.h
+
+generate_uudmap.exe : generate_uudmap$(o)
+.IF "$(CCTYPE)" == "BORLAND"
+	$(LINK32) -Tpe -ap $(BLINK_FLAGS) \
+	    @$(mktmp c0x32$(o) generate_uudmap$(o),$(@:s,\,$B,),,$(LIBFILES),)
+.ELIF "$(CCTYPE)" == "GCC"
+	$(LINK32) -v -o $@ $(BLINK_FLAGS) \
+	    $(mktmp $(LKPRE) generate_uudmap$(o) $(LIBFILES) $(LKPOST))
+.ELSE
+	$(LINK32) -subsystem:console -out:$@ $(BLINK_FLAGS) \
+	    @$(mktmp $(LIBFILES) generate_uudmap$(o))
+.ENDIF
+
 perlmain.c : runperl.c
 	copy runperl.c perlmain.c
 
@@ -1605,6 +1622,7 @@
 	-@erase $(PERLSTATICLIB)
 	-@erase $(PERLDLL)
 	-@erase $(CORE_OBJ)
+	-@erase generate_uudmap.exe generate_uudmap$(o) uudmap.h
 	-if exist $(MINIDIR) rmdir /s /q $(MINIDIR)
 	-if exist $(UNIDATADIR1) rmdir /s /q $(UNIDATADIR1)
 	-if exist $(UNIDATADIR2) rmdir /s /q $(UNIDATADIR2)


I'm hoping that people can fix these for me. Sorry to make work for others.

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About