# This software is a part of NOODLYBOX.
# This software is distributed under the terms of the new BSD License.
# Copyright (c) 2008, molelord
# All rights reserved.

CC=gcc
CXX=g++
CFLAGS=-Wall -W -Wformat=2 -pipe
CXXFLAGS=-Wall -W -Wformat=2 -pipe

.PHONY : all clean depend

ifeq ($(shell uname -o), Msys)
    DOTEXE=.exe
    # Replace /?/ by ?:/
    COLON_NOODLYBOX_HOME:=$(shell echo $(NOODLYBOX_HOME) | sed -e 's,^/\(.\)/,\1:/,')
else
    DOTEXE=
    COLON_NOODLYBOX_HOME:=$(NOODLYBOX_HOME)
endif

# if current directory's name ends with 'v', ...
ifneq ($(subst v/,//,$(notdir $(shell pwd))/),$(notdir $(shell pwd))/)
    HDL=verilog
    HDLEXT=v
    PACKAGE_VHDL=
    FUSEFLAGS=-lib unisims_ver
else
    HDL=vhdl
    HDLEXT=vhd
    PACKAGE_VHDL=package-vhdl
    FUSEFLAGS=
endif


%_PKG.vhd : %.vhd
	compo.rb $< > $@

%.vhd : %.xaw
	xaw2vhdl $< -intstyle silent $@
	rm -f $*_arwz.ucf xaw2vhdl.log
	mimic.rb $@

%.v : %.xaw
	xaw2verilog $< -intstyle silent $@
	rm -f $*_arwz.ucf xaw2vhdl.log
	mimic.rb $@

%.c : %.csv
	accessor.rb -c $< > $@

%.h : %.csv
	accessor.rb -h $< > $@

%$(DOTEXE) : %.prj
	fuse $(FUSEFLAGS) -intstyle xflow -nodebug -incremental \
        -prj $< -top $* -o $@
	touch $@

# vim: set ft=make:
