--- gforth/libcc.fs 2008/07/27 10:34:06 1.51 +++ gforth/libcc.fs 2008/11/01 19:21:07 1.57 @@ -135,6 +135,7 @@ \ : delete-file 2drop 0 ; require struct.fs +require mkdir.fs \ c-function-ft word body: struct @@ -226,7 +227,7 @@ end-struct c-lib% variable c-libs \ linked list of library names (without "lib") -: add-lib ( c-addr u -- ) +: add-lib ( c-addr u -- ) \ gforth \G Add library lib@i{string} to the list of libraries, where \G @i{string} is represented by @i{c-addr u}. c-lib% %size allocate throw dup >r @@ -284,7 +285,6 @@ const+ d \ double const+ r \ float const+ func \ C function pointer const+ void -const+ file \ C file pointer drop set-current @@ -301,7 +301,7 @@ set-current parse-libcc-type dup 0< -32 and throw swap c! ; : type-letter ( n -- c ) - chars s" nadrfvF" drop + c@ ; + chars s" nadrfv" drop + c@ ; \ count-stacks @@ -330,7 +330,6 @@ create count-stacks-types ' count-stacks-r , ' count-stacks-func , ' count-stacks-void , -' count-stacks-a , : count-stacks ( pars -- fp-change sp-change ) \ pars is an addr u pair @@ -358,9 +357,6 @@ create count-stacks-types : gen-par-void ( fp-depth1 sp-depth1 -- fp-depth2 sp-depth2 ) -32 throw ; -: gen-par-file ( fp-depth1 sp-depth1 -- fp-depth2 sp-depth2 ) - ." (FILE *)(" gen-par-n ." )" ; - create gen-par-types ' gen-par-n , ' gen-par-a , @@ -368,7 +364,6 @@ create gen-par-types ' gen-par-r , ' gen-par-func , ' gen-par-void , -' gen-par-file , : gen-par ( fp-depth1 sp-depth1 partype -- fp-depth2 sp-depth2 ) cells gen-par-types + @ execute ; @@ -413,7 +408,6 @@ create gen-wrapped-types ' gen-wrapped-r , ' gen-wrapped-func , ' gen-wrapped-void , -' gen-wrapped-a , : gen-wrapped-stmt ( pars c-name fp-change1 sp-change1 ret -- fp-change sp-change ) cells gen-wrapped-types + @ execute ; @@ -438,7 +432,7 @@ create gen-wrapped-types dup { descriptor } count { ret } count 2dup { d: pars } chars + count { d: c-name } ." void " lib-modulename 2@ type ." _LTX_" descriptor wrapper-function-name 2dup type drop free throw - .\" (void)\n" + .\" (GFORTH_ARGS)\n" .\" {\n Cell MAYBE_UNUSED *sp = gforth_SP;\n Float MAYBE_UNUSED *fp = gforth_FP;\n " pars c-name 2over count-stacks ret gen-wrapped-stmt .\" ;\n" ?dup-if @@ -512,13 +506,15 @@ create gen-wrapped-types open-wrappers dup if lib-handle-addr @ ! else + libcc-named-dir $1ff mkdir-parents drop drop c-library-name-create endif ; : c-tmp-library-name ( c-addr u -- ) \ set up filenames for a new library; c-addr u is the basename of \ the library - libcc-tmp-dir prepend-dirname c-library-name-setup c-library-name-create ; + libcc-tmp-dir 2dup $1ff mkdir-parents drop + prepend-dirname c-library-name-setup c-library-name-create ; : lib-handle ( -- addr ) lib-handle-addr @ @ ; @@ -560,15 +556,15 @@ DEFER compile-wrapper-function ( -- ) lib-handle 0= if c-source-file close-file throw 0 c-source-file-id ! - [ libtool-command s" --silent --mode=compile --tag=CC " s+ + [ libtool-command s" --silent --mode=compile " s+ libtool-cc append s" -I " append s" includedir" getenv append ] sliteral s" -O -c " s+ lib-filename 2@ append s" .c -o " append lib-filename 2@ append s" .lo" append ( c-addr u ) - \ cr 2dup type + \ 2dup type cr 2dup system drop free throw $? abort" libtool compile failed" - [ libtool-command s" --silent --mode=link --tag=CC " s+ - libtool-cc append s" -module -rpath " s+ ] sliteral + [ libtool-command s" --silent --mode=link " s+ + libtool-cc append libtool-flags append s" -module -rpath " s+ ] sliteral lib-filename 2@ dirname replace-rpath s+ s" " append lib-filename 2@ append s" .lo -o " append lib-filename 2@ append s" .la" append ( c-addr u ) @@ -621,7 +617,7 @@ DEFER compile-wrapper-function ( -- ) defer lastxt dup c-function-rt lastxt c-function-ft lastxt swap defer! ; -: clear-libs ( -- ) +: clear-libs ( -- ) \ gforth \G Clear the list of libs c-source-file-id @ if compile-wrapper-function