At 6:51 pm +0200 04/05/02, Martin Buchmann wrote: I note your message was specifically to Chris, but perhaps these thoughts might be some help nevertheless.
>Maybe i should wait until i finished my diplomathesis in one week >and then start over again :-) Maybe the answer to that is yes? >Where and how should i begin? I thought trying the example in your >book would be a goog idea but maybe i should read some more docs >before about the usage of the MPW. You really should get hold of: a) Introduction to MPW b) Building and Managing Programs in MPW Both books are available (free) in PDF from the Apple Developer Site. For building XS libraries I find it much easier to split the process up into three separate operations. When things go wrong, which they usually do for one reason or another, that way it is easier to see what and where the problem is. You can always link the steps together in a makefile later if you want to. Step 1: Save the following as a file named "Convert_XS.sh". ------- Set name {1} perl "{MacPerl_Src}"perl:lib:ExtUtils:xsubpp -noprototypes -typemap "{MacPerl_Src}"perl:macos:ext:Mac:typemap -typemap "{MacPerl_Src}"perl:macos:ext:Mac:QuickDraw:typemap -typemap "{MacPerl_Src}"perl:macos:ext:Mac:"Files":typemap -typemap "{MacPerl_Src}"perl:lib:ExtUtils:typemap {name}.xs > xstmp.c Rename -y xstmp.c {name}.c Its function is to convert the .XS file to a '.c' file. You will have to add to the list of 'typemaps' from time to time. If you see a 'typemap' in the folder containing the XS file -- add it to the list. You may not always need "QuickDraw" and "Files" either. Step 2: Save the following as a file named "Compile.sh" ------- Set name {1} MrC -includes unix -d MACOS_TRADITIONAL -sym on -w off -traceback -t -fatext -i "{MacPerl_Src}"perl:macos: -i "{MacPerl_Src}"perl: -i "{MacPerl_Src}"Sfio_04Aug99:include: -i "{MacPerl_Src}"GUSI_221:include: -i {MPW}:Interfaces&Libraries:Interfaces:CIncludes: -i : -shared_lib_export on -export_list {name}.exp {name}.c It does what you expect i.e. compiles the '.c' file you have just made. You will have to be aware you may need to add to the list of 'includes' depending on the nature of the file. MrC will give you plenty of warnings if something is missing. Step 3: Save the following as a file named "Link.sh" ------- Set name {1} PPCLink -w -xm sharedlibrary -sym on -@export {name}.exp "{name}".c.PPC.o {SharedLibraries}InterfaceLib #{SharedLibraries}StdCLib #{SharedLibraries}MathLib #{PPCLibraries}PPCCRuntime.o "{MacPerl_Src}"perl:macos:PerlStub -c cfmg -fragname {name}.shlb.PPC -o {name} Again this script does what you would expect and links the various bits and pieces together. Also again you will have to add to the list of library files from time to time depending on the nature of the XS file. (Note the 'PerlStub' here: 'printf' is missing in MacPerl 5.6.1r1 which is why the link step in building XPlusX fails.) Note: The symbol at the end of each line is Opt-D -- that may get mangled by the mail agents along the way. Make sure BTW that there is no space after the 'delta' and before the CR. Anything after the 'delta' scrambles the file and there is no coherent error message to tell you what has gone wrong. Running the scripts. -------------------- To run each of these scripts do the following. Put the XS and the three '.sh' files in a folder somewhere handy. The desktop is fine. Then: a) Set MPW's current directory to that folder. You can do this various ways including typing in the WorkSheet: directory 'path:to:my:myFile_folder:' and hitting "Enter" (Note "Enter", the key by the keypad, *not* CR, BTW"). You can also just drag the folder onto the WorkSheet: MPW is often pure magic. b) In the work sheet type: Convert_XS.sh myFile and hit "Enter". c) Repeat for the other '.sh' files. At the end of all this you will find in your myFile.XS folder the following files: MyFile.c MyFile.c.ppc.o myFile.exp MyFile.xcoff myFile (the XS library file you've built) You can, if you want to, examine the 'c.ppc.o' and the binary library files by typing in the WorkSheet: DumpPEF MyFile.c.ppc.o or DumpPEF MyFile and, as always, hitting "Enter". Finally as a small economy, you can remove all but the very last line in the '.exp' file (which will read something like 'boot_myFile') before you 'link'. It's not particularly important but it makes the binary a tad smaller. Oh -- I forgot to mention this. Things in curly brackets e.g. {MacPerl_Src} are simply paths you have defined for your system in MPW. You put these definitions in a file in MPW's 'Startup Items' folder.You can check it works by typing "echo {MacPerl_Src}" and hitting "Enter". It just saves having to type the full path every time. HTH, Alan Fry