packages feed

webidl-0.1: cbits/Makefile

LEX = flex
SED = sed
CPP = gcc -E -dD
GHC = ghc
HSFFIG = hsffig
FFIPKG = ffipkg
HSC2HS = hsc2hs -t /dev/null
GHCLIB = `$(GHC) --print-libdir`

LEX_OPT = --header-file=../include/lex.yy.h -8 --nounistd -I

INCLUDE = ../include

LEX_C = lex.yy.c
LEX_H = $(INCLUDE)/lex.yy.h

LEXER_H = $(INCLUDE)/lexer.h
PARSER_H = $(INCLUDE)/parser.h

LEXER_HS = lexer-tmp/HS_LEXER_H.hs

all:
	@echo "Do not run make directly: run cabal configure"
	@exit -1

# remove some c++isms

$(LEX_C) $(LEX_H): lexer.ll $(LEXER_H)
	$(LEX) $(LEX_OPT) $<
	$(SED) -i 's/extern *\"C\"/extern /g' $(LEX_C)
	$(SED) -i 's/for *(char\* s/char *s; for (s/g' $(LEX_C)
	$(SED) -i 's/yyinput/input/g' $(LEX_C)
	$(SED) -i 's/Node::getBaseObjectName()/\"Object\"/g' $(LEX_C)

# Using ffipkg, build and install the LEXER package.

lexer-pkg: $(LEX_C) $(LEX_H) $(LEXER_HS)

$(LEXER_HS): $(LEX_C) $(LEX_H) $(LEXER_H) $(PARSER_H)
	rm -rf lexer-tmp
	mkdir lexer-tmp
	cd lexer-tmp; $(FFIPKG) -I ../$(INCLUDE) -I $(GHCLIB)/include lexer.h && cabal install