Skip to content

Instantly share code, notes, and snippets.

@aymanosman
Created April 2, 2017 02:48
Show Gist options
  • Save aymanosman/5827b842244ac07904c6884522f5a63a to your computer and use it in GitHub Desktop.
Save aymanosman/5827b842244ac07904c6884522f5a63a to your computer and use it in GitHub Desktop.
Haskell Makefile
HC = ghc
HC_OPTS = -cpp $(EXTRA_HC_OPTS)
SRCS = Main.lhs Foo.lhs Bar.lhs
OBJS = Main.o Foo.o Bar.o
.SUFFIXES : .o .hs .hi .lhs .hc .s
cool_pgm : $(OBJS)
rm -f $@
$(HC) -o $@ $(HC_OPTS) $(OBJS)
# Standard suffix rules
.o.hi:
@:
.lhs.o:
$(HC) -c $< $(HC_OPTS)
.hs.o:
$(HC) -c $< $(HC_OPTS)
.o-boot.hi-boot:
@:
.lhs-boot.o-boot:
$(HC) -c $< $(HC_OPTS)
.hs-boot.o-boot:
$(HC) -c $< $(HC_OPTS)
# Inter-module dependencies
Foo.o Foo.hc Foo.s : Baz.hi # Foo imports Baz
Main.o Main.hc Main.s : Foo.hi Baz.hi # Main imports Foo and Baz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment