-
Notifications
You must be signed in to change notification settings - Fork 113
build on Dos #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guberathome
wants to merge
3
commits into
philburk:master
Choose a base branch
from
guberathome:dos
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
build on Dos #201
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| y* | ||
| src/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # run with wmake from OpenWatcomC | ||
|
|
||
| coreObjFiles = PFCOMPIL.OBJ PF_CGLUE.OBJ PF_CLIB.OBJ PF_CORE.OBJ PF_INNER.OBJ PF_IO.OBJ PF_MAIN.OBJ PF_MEM.OBJ PF_SAVE.OBJ PF_TEXT.OBJ PF_WORDS.OBJ | ||
| ioObjFiles = | ||
| customObjFiles = PFCUSTOM.OBJ | ||
| allObjFiles = $(coreObjFiles) $(ioObjFiles) $(customObjFiles) missing.obj | ||
|
|
||
| .c.obj | ||
| wcc386 -fp3 -fpi87 -I. -DPF_SUPPORT_FP $< | ||
|
|
||
| pforth.dic: pforth.exe | ||
| cd ..\fth | ||
| ..\csrc\pforth -i system.fth | ||
| cd ..\csrc | ||
| move ..\fth\pforth.dic . | ||
|
|
||
| pforth.exe: $(allObjFiles) | ||
| %write pforth.lnk NAME $@ | ||
| %write pforth.lnk SYSTEM DOS4G | ||
| %write pforth.lnk FILE {$(allObjFiles)} | ||
| wlink @pforth.lnk | ||
|
|
||
| clean: .symbolic | ||
| del *.dic *.exe *.lnk *.obj *.err | ||
|
|
||
| test: pforth.dic .symbolic | ||
| copy pforth.dic ..\fth\ | ||
| cd ..\fth | ||
| ..\csrc\pforth -q t_corex.fth | ||
| ..\csrc\pforth -q tstrings.fth | ||
| ..\csrc\pforth -q t_locals.fth | ||
| ..\csrc\pforth -q t_alloc.fth | ||
| ..\csrc\pforth -q t_floats.fth | ||
| # this will not succeed: ..\csrc\pforth -q t_file.fth | ||
| del pforth.dic | ||
| cd ..\csrc\ | ||
| echo | ||
| echo "all tests PASSED" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| Build environment | ||
| ----------------- | ||
| PForth has been build (and run) under both FreeDos and DosBox. | ||
| Others (DR-DOS, MS-DOS...) might work as well. | ||
|
|
||
|
|
||
| Preparation steps | ||
| ----------------- | ||
| DOS limits file names to 8+3 characters. | ||
| Currently 19 relevant files in the PForth source tree violate this rule (see rename.txt for details). | ||
| It is recommended to perform the following steps on a POSIX system (tested under MSYS2/Cygwin): | ||
| 1) run ./step-1-prepare-sourceTree.sh to rename all files to 8+3 characters convention. | ||
| It will check that no new files violate the convention and abort if so. | ||
| In that case extend rename.txt. | ||
| 2) Select OS-specific routine and run appropriate script, e.g.: | ||
| ./step-2a-select-stdio.sh | ||
| For now only stdio is tested. | ||
| 3) Create an archive and transfer it to the build environment. | ||
| Both FreeDos and Linux-hosts for DosBox provide tar, so you can: | ||
| tar cf pf-dos.tar src/ | ||
| FreeDos also provides unzip.exe if you want to create a ZIP file instead. | ||
|
|
||
|
|
||
| Compiler | ||
| -------- | ||
| FreeDos developers seem to prefer OpenWatcomC (install it via fdimples on FreeDos). | ||
| It has been used to compile PForth successfully under both FreeDos and DosBox. | ||
| (The latter does not provide a "move" command, so the build needs a bit of help at 1 point after pforth.dic has been created). | ||
| This build targets 386 hardware and and a DOS extender (DOS4GW) since the standard 16-bit build (via owcc) failed. | ||
| OpenWatcomC does not implement two required functions for floating point operation, missing.c fixes that. | ||
| The test suite runs fine except for unimplemtented stuff in t_file.fth. | ||
|
|
||
| Potentially you could build pforth using DJGPP (gcc and gnu-make). | ||
| Unfortunately I found it unusable (it crashed way too often). | ||
|
|
||
| PForth assumes 32bit several times in the source code. | ||
| Thus not 16 bit compilers (like Turbo C) were tried. | ||
|
|
||
|
|
||
| where / how to build? | ||
| --------------------- | ||
| Extract the prepared sources to a drive with sufficient free space and execute: | ||
| cd .\src\csrc | ||
| wmake | ||
|
|
||
| If that worked fine, try this next: | ||
| wmake test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #include "missing.h" | ||
|
|
||
| double round(double x) { | ||
| double i, s; | ||
| if( x>=0 ) { | ||
| i = floor(x); | ||
| s = 1.0; | ||
| } else { | ||
| i = ceil(x); | ||
| s = -1.0; | ||
| } | ||
| if( fabs(x - i) < 0.5 ) | ||
| return i; /* round down */ | ||
| else | ||
| return i + s; /* round up */ | ||
| } | ||
|
|
||
| double log1p(double x) { | ||
| if( -1.0 < x && x <= 1.0 ) | ||
| return x - 0.5*x*x + 1.0/3.0*x*x*x - 0.25*x*x*x*x + 0.20*x*x*x*x*x; | ||
| else | ||
| return log( 1.0 + x ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* include this in pf_inner.c !! */ | ||
|
|
||
| #ifndef PF_MISSING_H | ||
| #define PF_MISSING_H | ||
|
|
||
| #include <math.h> | ||
| double round(double x); | ||
| double log1p(double x); | ||
|
|
||
| #endif /* PF_MISSING_H */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| src/csrc/pf_io_none.c src/csrc/ionone.c | ||
| src/csrc/posix/pf_io_posix.c src/csrc/posix/ioposix.c | ||
| src/csrc/stdio/pf_fileio_stdio.c src/csrc/stdio/fiostdio.c | ||
| src/csrc/stdio/pf_io_stdio.c src/csrc/stdio/iostdio.c | ||
| src/csrc/win32/pf_io_win32.c src/csrc/win32/iowin32.c | ||
| src/csrc/win32csl/pf_io_win32_console.c src/csrc/win32csl/iowin32c.c | ||
| src/fth/save-input.fth src/fth/savinput.fth | ||
| src/fth/structure.fth src/fth/structur.fth | ||
| src/fth/t_include.fth src/fth/tinclude.fth | ||
| src/fth/t_load_defer.fth src/fth/tlddefer.fth | ||
| src/fth/t_load_pairs.fth src/fth/tldpairs.fth | ||
| src/fth/t_load_semi.fth src/fth/tldsemi.fth | ||
| src/fth/t_load_undef.fth src/fth/tldundef.fth | ||
| src/fth/t_required_helper1.fth src/fth/treqhlp1.fth | ||
| src/fth/t_required_helper2.fth src/fth/treqhlp2.fth | ||
| src/fth/t_strings.fth src/fth/tstrings.fth | ||
| src/fth/utils/dump_struct.fth src/fth/utils/dumpstru.fth | ||
| src/fth/utils/load_file.fth src/fth/utils/loadfile.fth | ||
| src/fth/utils/make_all256.fth src/fth/utils/make_all.fth | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| #!/bin/sh | ||
|
|
||
| echo | ||
| echo "0) clean previous build folder" | ||
| echo "------------------------------" | ||
| rm -rf ./src/ | ||
|
|
||
| echo | ||
| echo "1) copy sources here" | ||
| echo "--------------------" | ||
| mkdir src | ||
| mkdir src/csrc | ||
| mkdir src/fth | ||
| cp -r ../../csrc/ ./src/ | ||
| cp -r ../../fth/ ./src/ | ||
| cp missing.* ./src/csrc/ | ||
| cp Makefile.mk ./src/csrc/ | ||
| find . | grep -i cmake | xargs rm # Nobody likes CMake!!! | ||
| mv ./src/csrc/win32_console/ ./src/csrc/win32csl/ | ||
|
|
||
| echo | ||
| echo "2a) rename files to 8+3 filename convention" | ||
| echo "-------------------------------------------" | ||
| cat rename.txt | awk '{if( NF==2 ) print "mv " $1 " " $2}' | sh | ||
| echo "2b) verify that 8+3 filename convention is kept." | ||
| echo "-----------------------------------------------" | ||
| find src/ -type f | awk -f too-long-filenames.awk | tee yMissingRenames | ||
| echo "-----------------------------------------------" | ||
| if test -s yMissingRenames | ||
| then | ||
| echo "ABORT: more files need to be renamed!" | ||
| else # yMissingRenames | ||
|
|
||
| echo | ||
| echo "3) extract list of filenames to substitute from 'rename.txt'" | ||
| echo "-------------------------------------------------------------" | ||
| cat rename.txt | awk '{if( NF==2 ) print "echo s#`basename " $1 "`#`basename " $2 "`#g" }' | sh | sed -e 's#\.#\\\.#g' > yFileNames | ||
|
|
||
| echo | ||
| echo "4) patch file contents" | ||
| echo "----------------------" | ||
| for curFile in `find src/ -type f` | ||
| do | ||
| sed -f yFileNames -i $curFile | ||
| done | ||
| rm yFileNames | ||
|
|
||
| echo | ||
| echo "4) include missing.h in pf_inner.c" | ||
| echo "----------------------------------" | ||
| mv ./src/csrc/pf_inner.c tmp.c | ||
| cat - tmp.c > ./src/csrc/pf_inner.c << EOF | ||
| #include "missing.h" | ||
| EOF | ||
| rm tmp.c | ||
|
|
||
| echo | ||
| echo "99) done" | ||
| echo "--------" | ||
| rm yMissingRenames | ||
|
|
||
| fi # yMissingRenames |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/bin/sh | ||
|
|
||
| ioSources="fiostdio.c iostdio.c" | ||
|
|
||
| cd ./src/csrc/ | ||
|
|
||
| # 1) copy ioSources to parent dir (so all sources are in 1 folder) and patch the include statements accordingly | ||
| for srcFile in $ioSources | ||
| do | ||
| cat "./stdio/$srcFile" | sed -e 's#\.\./##g' > $srcFile | ||
| done | ||
|
|
||
| # 2) include ioSources in Makefile | ||
| objFiles=`echo $ioSources | sed -e 's#\.c#\\\.obj#g' ` | ||
| cat Makefile.mk | sed -e "s/ioObjFiles =/ioObjFiles = $objFiles/g" > Makefile | ||
| rm Makefile.mk | ||
|
|
||
| cd ../../ | ||
| echo "done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # call via: | ||
| # find csrc/ fth/ -type f | awk -f too-long-filenames.awk | ||
|
|
||
|
|
||
| BEGIN { | ||
| FS="/" # separate by directory | ||
| } | ||
|
|
||
|
|
||
| { | ||
| noParts = split( $NF, parts, "." ) | ||
| if ( noParts!=2 ) | ||
| { | ||
| if ( noParts>2 ) | ||
| print "----> invalid noParts=" noParts " for file='" $0 "'" | ||
| } | ||
| else | ||
| { | ||
| if( length(parts[1]) > 8 || length(parts[2]) > 3 ) | ||
| print $0; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should rename all these files to 8.3 format in the main code.
I thought 8.3 files were no longer important on Windows.
But I guess they are still a requirement.