--- gforth/libcc.fs 2008/11/01 19:21:07 1.57 +++ gforth/libcc.fs 2009/10/17 20:57:33 1.60 @@ -219,24 +219,19 @@ end-struct list% node list-next @ repeat ; -\ linked libraries - -list% - cell% 2* field c-lib-string -end-struct c-lib% - -variable c-libs \ linked list of library names (without "lib") +2variable c-libs \ library names in a string (without "lib") : 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 - c-lib-string 2! - r> c-libs list-insert ; - -: append-l ( c-addr1 u1 node -- c-addr2 u2 ) - \ append " -l" to string1 - >r s" -l" append r> c-lib-string 2@ append ; + \G @i{string} is represented by @i{c-addr u}. + c-libs 2@ d0= IF 0 allocate throw 0 c-libs 2! THEN + c-libs 2@ s" -l" append 2swap append c-libs 2! ; + +: add-libpath ( c-addr u -- ) \ gforth +\G Add path @i{string} to the list of library search pathes, where + \G @i{string} is represented by @i{c-addr u}. + c-libs 2@ d0= IF 0 allocate throw 0 c-libs 2! THEN + c-libs 2@ s" -L" append 2swap append c-libs 2! ; \ C prefix lines @@ -256,6 +251,9 @@ variable c-prefix-lines-end c-prefix-lin : print-c-prefix-lines ( -- ) c-prefix-lines @ ['] print-c-prefix-line list-map ; +: free-c-prefix-lines ( -- ) + c-prefix-lines @ off c-prefix-lines @ c-prefix-lines-end ! ; + : save-c-prefix-line ( c-addr u -- ) c-source-file-id @ ?dup-if >r 2dup r> write-line throw @@ -497,7 +495,7 @@ create gen-wrapped-types lib-filename 2@ s" .c" s+ 2dup w/o create-file throw dup c-source-file-id ! ['] print-c-prefix-lines swap outfile-execute - drop free throw ; + drop free-c-prefix-lines free throw ; : c-named-library-name ( c-addr u -- ) \ set up filenames for a (possibly new) library; c-addr u is the @@ -557,8 +555,8 @@ DEFER compile-wrapper-function ( -- ) c-source-file close-file throw 0 c-source-file-id ! [ libtool-command s" --silent --mode=compile " s+ - libtool-cc append s" -I " append - s" includedir" getenv append ] sliteral + libtool-cc append s" -I '" append + s" includedir" getenv append s" '" append ] sliteral s" -O -c " s+ lib-filename 2@ append s" .c -o " append lib-filename 2@ append s" .lo" append ( c-addr u ) \ 2dup type cr @@ -568,7 +566,7 @@ DEFER compile-wrapper-function ( -- ) 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 ) - c-libs @ ['] append-l list-map + c-libs 2@ append \ 2dup type cr 2dup system drop free throw $? abort" libtool link failed" open-wrappers dup 0= if @@ -622,7 +620,7 @@ DEFER compile-wrapper-function ( -- ) c-source-file-id @ if compile-wrapper-function endif - 0 c-libs ! ; + 0. c-libs 2! ; clear-libs : c-library-incomplete ( -- )