SlideShare uma empresa Scribd logo
1 de 34
�
foreign import ccall ”math.h sin”
  sin :: CDouble -> CDouble




foreign export ccall ”fact”
  fact :: CInt -> CInt
�
== factorial.hs ==
Module Factorial where
import Foreign.C.Types
foreign export ccall ”factorial”
  factorial :: CInt -> Cint
factorial 0 = 1
factorial x = x * factorial(x-1)
== main.c ==
#include <stdio.h>
#include “factorial_stub.h”
int main(int argc, char* argv[])
{
  hs_init(&argc, &argv);
  printf(“%dn”, fact(5));
  hs_exit();
  return 0;
}
$ ghc -shared -dynamic
...                  (   )
#include <ruby.h>
#include "factorial_stub.h"
static VALUE rb_factorial(VALUE self, VALUE val)
{
  return UINT2NUM(factorial(NUM2UINT(val)));
}
void Init_factorial(void)
{
  hs_init(NULL, NULL);//        Haskell          ..
    rb_define_module_function(rb_mMath, "factorial",
      RUBY_METHOD_FUNC(rb_factorial), 1);
}
(gem install         )

$ irb -r factorial/factorial
irb(main):001:0> Math.factorial 4
=> 24
foreign export ccall ”factorial”
factorial :: CInt -> CInt
CInt   -229   +229-1

  9               362,880
 10              3,628,800
 15            1.30767E+12
$ cd `ghc --print-libdir`




     �
require 'rbconfig'
TARGET = 'factorial'
C_SRC = %w{ main.c }
HS_SRC = %w{ factorial.hs }
HS_LIBS = %w{ base integer-gmp ghc-prim }
CONF = RbConfig::MAKEFILE_CONFIG
VALS = %w{prefix includedir RUBY_BASE_NAME ruby_version
rubyhdrdir arch MKDIR_P INSTALL INSTALL_PROGRAM}.map{|k|
          "#{k}=#{CONF[k]}"
        }.join("n")
GHC_LIBDIR=`ghc --print-libdir`.strip
FLAGS = "FLAGS=-I$(rubyhdrdir) -I$(rubyhdrdir)/$(arch) -
shared -dynamic -no-hs-main -lHSrts -lffin" 
       + "FLAGS+=-no-auto-link-packages -I#{GHC_LIBDIR}/
include -L#{GHC_LIBDIR}n" 
       + HS_LIBS.map{|l|
          'FLAGS+=' + `ghc-pkg describe #{l}|sed -ne 's/
library-dirs: /-L/p;s/hs-libraries: /-l/p;'`.gsub(/n/, ' ')
         }.join("n") 
       + "nFLAGS+=-lgmpn"
File.open("Makefile", "w") {|f|
  f.puts <<__MAKEFILE__
TARGET=#{TARGET}.#{CONF['DLEXT']}
HS_SRC=#{HS_SRC.join(' ')}
C_SRC=#{C_SRC.join(' ')}
#{VALS}
#{FLAGS}
STUB=$(HS_SRC:.hs=_stub.o)

all : $(TARGET)

$(STUB) : $(HS_SRC)
   ghc $<

$(TARGET) : $(C_SRC) $(STUB) $(HS_SRC:.hs=.o)
   ghc -o $@ $^ $(FLAGS)

install:
   $(MKDIR_P) ../lib/#{TARGET}/
   $(INSTALL_PROGRAM) $(TARGET) ../lib/#{TARGET}/

clean:
   rm -f $(TARGET) $(C_SRC:.c=.o) $(HS_SRC:.hs=.hi) $
(HS_SRC:.hs=.o) $(HS_SRC:.hs=_stub.)*
__MAKEFILE__
}
�




�
�
Ruby haskell extension
Ruby haskell extension
Ruby haskell extension
Ruby haskell extension

Mais conteúdo relacionado

Mais procurados (20)

Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Pratik Bakane C++
Pratik Bakane C++Pratik Bakane C++
Pratik Bakane C++
 
Include
IncludeInclude
Include
 
C++ programs
C++ programsC++ programs
C++ programs
 
Bankers Algo Implementation
Bankers Algo ImplementationBankers Algo Implementation
Bankers Algo Implementation
 
Oops in c++
Oops in c++Oops in c++
Oops in c++
 
One dimensional operation of Array in C- language
One dimensional operation of Array in C- language One dimensional operation of Array in C- language
One dimensional operation of Array in C- language
 
Code
CodeCode
Code
 
A Shiny Example-- R
A Shiny Example-- RA Shiny Example-- R
A Shiny Example-- R
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Oprerator overloading
Oprerator overloadingOprerator overloading
Oprerator overloading
 
Modificacion del programa
Modificacion del programaModificacion del programa
Modificacion del programa
 
PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY PROGRAM FOR INSERTION SORTING IN ARRAY
PROGRAM FOR INSERTION SORTING IN ARRAY
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
ECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScriptECMAScript 5: Новое в JavaScript
ECMAScript 5: Новое в JavaScript
 
Introduction to cron queue
Introduction to cron queueIntroduction to cron queue
Introduction to cron queue
 
week-5x
week-5xweek-5x
week-5x
 
Document
DocumentDocument
Document
 
cosc 281 hw2
cosc 281 hw2cosc 281 hw2
cosc 281 hw2
 

Destaque (11)

Frank-afcproxy
Frank-afcproxyFrank-afcproxy
Frank-afcproxy
 
Amazon aws 20110611
Amazon aws 20110611Amazon aws 20110611
Amazon aws 20110611
 
Castoro sequense
Castoro sequenseCastoro sequense
Castoro sequense
 
Apache mod authまわりとか
Apache mod authまわりとかApache mod authまわりとか
Apache mod authまわりとか
 
Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回Ruby2.0 - refinements - 鳥取Ruby会 第11回
Ruby2.0 - refinements - 鳥取Ruby会 第11回
 
とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料とっとるびー(2回目)発表資料
とっとるびー(2回目)発表資料
 
Castoro / RubyKaigi2010
Castoro / RubyKaigi2010Castoro / RubyKaigi2010
Castoro / RubyKaigi2010
 
Apache2.3 探訪
Apache2.3 探訪Apache2.3 探訪
Apache2.3 探訪
 
Tottoruby 20130119
Tottoruby 20130119Tottoruby 20130119
Tottoruby 20130119
 
Bazaar
BazaarBazaar
Bazaar
 
Web Server - Internet Applications
Web Server - Internet ApplicationsWeb Server - Internet Applications
Web Server - Internet Applications
 

Semelhante a Ruby haskell extension

C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2Koshy Geoji
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfRahulRoy130127
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたAkira Maruoka
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationDinesh Manajipet
 
C basics
C basicsC basics
C basicsMSc CST
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)Ashishchinu
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
JVM code reading -- C2
JVM code reading -- C2JVM code reading -- C2
JVM code reading -- C2ytoshima
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - CompilationsHSA Foundation
 
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support SystemR (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support SystemMaithreya Chakravarthula
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++varun arora
 

Semelhante a Ruby haskell extension (20)

C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Bijender (1)
Bijender (1)Bijender (1)
Bijender (1)
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
IR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdfIR Journal (itscholar.codegency.co.in).pdf
IR Journal (itscholar.codegency.co.in).pdf
 
Chainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみたChainer-Compiler 動かしてみた
Chainer-Compiler 動かしてみた
 
C Programming
C ProgrammingC Programming
C Programming
 
Basicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt applicationBasicsof c make and git for a hello qt application
Basicsof c make and git for a hello qt application
 
C basics
C basicsC basics
C basics
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
CppTutorial.ppt
CppTutorial.pptCppTutorial.ppt
CppTutorial.ppt
 
Final DAA_prints.pdf
Final DAA_prints.pdfFinal DAA_prints.pdf
Final DAA_prints.pdf
 
7720
77207720
7720
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
JVM code reading -- C2
JVM code reading -- C2JVM code reading -- C2
JVM code reading -- C2
 
C++ manual Report Full
C++ manual Report FullC++ manual Report Full
C++ manual Report Full
 
ISCA Final Presentaiton - Compilations
ISCA Final Presentaiton -  CompilationsISCA Final Presentaiton -  Compilations
ISCA Final Presentaiton - Compilations
 
R (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support SystemR (Shiny Package) - Server Side Code for Decision Support System
R (Shiny Package) - Server Side Code for Decision Support System
 
Billing in a supermarket c++
Billing in a supermarket c++Billing in a supermarket c++
Billing in a supermarket c++
 
C lab programs
C lab programsC lab programs
C lab programs
 
C lab programs
C lab programsC lab programs
C lab programs
 

Último

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 

Último (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 

Ruby haskell extension

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. foreign import ccall ”math.h sin” sin :: CDouble -> CDouble foreign export ccall ”fact” fact :: CInt -> CInt
  • 10.
  • 11. == factorial.hs == Module Factorial where import Foreign.C.Types foreign export ccall ”factorial” factorial :: CInt -> Cint factorial 0 = 1 factorial x = x * factorial(x-1)
  • 12.
  • 13. == main.c == #include <stdio.h> #include “factorial_stub.h” int main(int argc, char* argv[]) { hs_init(&argc, &argv); printf(“%dn”, fact(5)); hs_exit(); return 0; }
  • 14. $ ghc -shared -dynamic ... ( )
  • 15. #include <ruby.h> #include "factorial_stub.h" static VALUE rb_factorial(VALUE self, VALUE val) { return UINT2NUM(factorial(NUM2UINT(val))); } void Init_factorial(void) { hs_init(NULL, NULL);// Haskell .. rb_define_module_function(rb_mMath, "factorial", RUBY_METHOD_FUNC(rb_factorial), 1); }
  • 16. (gem install ) $ irb -r factorial/factorial irb(main):001:0> Math.factorial 4 => 24
  • 17. foreign export ccall ”factorial” factorial :: CInt -> CInt CInt -229 +229-1 9 362,880 10 3,628,800 15 1.30767E+12
  • 18.
  • 19.
  • 20.
  • 21. $ cd `ghc --print-libdir` �
  • 22.
  • 23.
  • 24. require 'rbconfig' TARGET = 'factorial' C_SRC = %w{ main.c } HS_SRC = %w{ factorial.hs } HS_LIBS = %w{ base integer-gmp ghc-prim } CONF = RbConfig::MAKEFILE_CONFIG VALS = %w{prefix includedir RUBY_BASE_NAME ruby_version rubyhdrdir arch MKDIR_P INSTALL INSTALL_PROGRAM}.map{|k| "#{k}=#{CONF[k]}" }.join("n") GHC_LIBDIR=`ghc --print-libdir`.strip FLAGS = "FLAGS=-I$(rubyhdrdir) -I$(rubyhdrdir)/$(arch) - shared -dynamic -no-hs-main -lHSrts -lffin" + "FLAGS+=-no-auto-link-packages -I#{GHC_LIBDIR}/ include -L#{GHC_LIBDIR}n" + HS_LIBS.map{|l| 'FLAGS+=' + `ghc-pkg describe #{l}|sed -ne 's/ library-dirs: /-L/p;s/hs-libraries: /-l/p;'`.gsub(/n/, ' ') }.join("n") + "nFLAGS+=-lgmpn"
  • 25. File.open("Makefile", "w") {|f| f.puts <<__MAKEFILE__ TARGET=#{TARGET}.#{CONF['DLEXT']} HS_SRC=#{HS_SRC.join(' ')} C_SRC=#{C_SRC.join(' ')} #{VALS} #{FLAGS} STUB=$(HS_SRC:.hs=_stub.o) all : $(TARGET) $(STUB) : $(HS_SRC) ghc $< $(TARGET) : $(C_SRC) $(STUB) $(HS_SRC:.hs=.o) ghc -o $@ $^ $(FLAGS) install: $(MKDIR_P) ../lib/#{TARGET}/ $(INSTALL_PROGRAM) $(TARGET) ../lib/#{TARGET}/ clean: rm -f $(TARGET) $(C_SRC:.c=.o) $(HS_SRC:.hs=.hi) $ (HS_SRC:.hs=.o) $(HS_SRC:.hs=_stub.)* __MAKEFILE__ }
  • 26.
  • 27.
  • 28.
  • 30.

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n