# Author: Andreas Abel, 2018-01-01, 2020-12-22

.PHONY : default all

default: lbnf
all: lbnf license

# bnfc's own parser
###################

# BNFC-generated files
gen = BNFC/Abs.hs BNFC/Doc.txt ErrM.hs BNFC/Lex.x BNFC/Par.y BNFC/Print.hs BNFC/Skel.hs BNFC/Test.hs

.PHONY: lbnf

lbnf : BNFC/Abs.hs BNFC/Lex.hs BNFC/Par.hs BNFC/Print.hs

%/Abs.hs %/Doc.txt %/Lex.x %/Par.y %/Print.hs %/Skel.hs %/Test.hs : %.cf
	bnfc --haskell -d $<

%.hs : %.x
	alex -g $<

%.hs : %.y
	happy -gcai $<

# Generate License.hs
#####################

.PHONY: license

license: BNFC/License.hs

BNFC/License.hs : ../LICENSE Makefile
	echo "\
-- This file was autogenerated from LICENSE, do not edit!!\n\n\
{-# LANGUAGE QuasiQuotes #-}\n\n\
module BNFC.License where\n\n\
import Data.String.QQ\n\n\
license :: String\n\
license = [s|" > $@
	cat $< >> $@
	echo "\n|]" >> $@

# Emacs Tags
############

.PHONY : tags

tags :
	hasktags -e .

# Fake cabal file for old version of haskell-mode (emacs)
#########################################################

.PHONY: fake-cabal rm-fake-cabal

fake-cabal :
	touch inferior-haskell-find-project-root.cabal

# Remove this this file confuses tools like cabal and stack.
rm-fake-cabal :
	rm inferior-haskell-find-project-root.cabal

#EOF
