Link to multiple modules during compilation

This commit is contained in:
Justin Ethier 2015-05-13 22:29:29 -04:00
parent e87aee8ed1
commit d5982c0671

View file

@ -233,19 +233,23 @@
(create-c-file program)))) ;; TODO: no, don't do same work twice. real answer is linking (create-c-file program)))) ;; TODO: no, don't do same work twice. real answer is linking
;; Compile the generated C file ;; Compile the generated C file
;; TODO: -I is a hack, real answer is to use 'make install' to place .h file
(if cc? (if cc?
(cond (cond
(program? (program?
; TODO: if there is an (import)
; (write `(DEBUG ,(lib:imports->objs (cdar in-prog) ".")))
(let ((objs-str (let ((objs-str
(if (tagged-list? 'import (car in-prog)) (if (tagged-list? 'import (car in-prog))
TODO: lib:imports->objs;; TODO: populate using above (if prog) and link to objs below (will need to run 2 gcc commands) (apply string-append
(map
(lambda (str)
(string-append " " str " "))
(lib:imports->objs (cdar in-prog) ".")))
""))) "")))
(system (if (equal? 0
;; -I is a hack, real answer is to use 'make install' to place .h file (system
;TODO: need to link to object files from lib:import->obj-file (string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o")))
(string-append "gcc " src-file " -L" (cyc:get-clib-dir) " -lcyclone -lm -I" (cyc:get-include-dir) " -g -o " exec-file)))) (system
(string-append "gcc " exec-file ".o " objs-str " -L" (cyc:get-clib-dir) " -lcyclone -lm -I" (cyc:get-include-dir) " -g -o " exec-file)))))
(else (else
(system (system
(string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o"))))))) (string-append "gcc " src-file " -I" (cyc:get-include-dir) " -g -c -o " exec-file ".o")))))))