GET_FILES = ../hsrc/get_files
HBCXMAKE = ../bin/hbcxmake -cpp
NHC13XMAKE = ../bin/nhc13xmake #old
NHCXMAKE = ../bin/nhcxmake
#GHCXMAKE = ../bin/ghcxmake -package-name fudgetscontrib -cpp $(OPT)
#GHCXMAKE = ../bin/ghuxmake -batch -cpp $(OPT)
GHCXMAKE = ../bin/ghcxhmake -cpp $(OPT)
GHCFUDGETS = ../GhcFudgets
HBCFLAGS = -fexist-type -O
# -fno-overload-restr

### hbc ########################################################################
#

contrib: lib.a
contrib_p: lib_p.a
contrib_ph: lib_ph.a

###

lib.a::
	$(GET_FILES) hi hbc
	$(GET_FILES) o hbc
	$(HBCXMAKE) ContribFudgets.hs
	rm -f lib.a
	ar cr lib.a *.o
	ranlib lib.a

lib_p.a::
	$(GET_FILES) hi hbc
	$(GET_FILES) o hbc_p
	$(HBCXMAKE) -p ContribFudgets.hs
	rm -f lib_p.a
	ar cr lib_p.a *.o
	ranlib lib_p.a

lib_ph.a::
	$(GET_FILES) hi hbc
	$(GET_FILES) o hbc_ph
	$(HBCXMAKE) -ph ContribFudgets.hs
	rm -f lib_ph.a
	ar cr lib_ph.a *.o
	ranlib lib_ph.a


### nhc13 ######################################################################
#

nhc-contrib: lib0.a
nhc-contrib_ph: lib1.a

###

lib0.a::
	$(GET_FILES) hi nhc
	$(GET_FILES) o nhc0
	$(NHCXMAKE) -i../hsrc/hbc_library -P../hsrc/dialogue -P../hsrc/nhc ContribFudgets.hs
	rm -f lib0.a
	ar cr lib0.a *.o
	ranlib lib0.a

lib1.a::
	$(GET_FILES) hi nhc
	$(GET_FILES) o nhc1
	$(NHCXMAKE) -p -i../hsrc/hbc_library -P../hsrc/dialogue ContribFudgets.hs
	rm -f lib1.a
	ar cr lib1.a *.o
	ranlib lib1.a


### ghc ########################################################################
#

ghc-contrib: ghc-lib.a
ghc-contrib_prof: ghc-lib_p.a

###

ghc-lib.a::
	$(GET_FILES) hi ghc
	$(GET_FILES) o ghc0
	env GHCFUDGETS=$(GHCFUDGETS) $(GHCXMAKE) ContribFudgets.hs
	rm -f ghc-lib.a
	ar cr ghc-lib.a *.o
	ranlib ghc-lib.a

ghc-lib_p.a::
	$(GET_FILES) hi ghc
	$(GET_FILES) o ghc1
	env GHCFUDGETS=$(GHCFUDGETS) $(GHCXMAKE) -prof -auto-all ContribFudgets.hs
	rm -f ghc-lib_p.a
	ar cr ghc-lib_p.a *.o
	ranlib ghc-lib_p.a


### clean ######################################################################
#

clean:
	rm -rf objs *.o *.hi *.a *.version
