# f-cpu/configuration/Makefile
# Copyright (C) 2001 Michael Riepe <michael@stud.uni-hannover.de>
# created aug. 23, 2001 by MR
# update  Mon Aug 27 07:31:04 2001 by YG
# version Fri Sep  7 03:08:20 2001 by YG: changed PACKAGEDIR = ../vhdl/configuration
#
# ------------------------BEGIN-SH-LICENCE---------------------------------
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
# ---------------------------END-SH-LICENCE--------------------------------

#
# This file replaces the ../configure.sh script which is now deprecated.
# There are 3 steps usually :
#  - 1) create the "frozen state"
#  - 2) update f-cpu/include/
#  - 3) update f-cpu/vhdl/
# Now, the Makefile is called from within f-cpu/configuration
# so some paths are changed.
#

# how to call m4...
M4 = m4 --prefix-builtins -I.

# where C headers and VHDL packages go
INCLUDEDIR = ../include
PACKAGEDIR = ../vhdl/configuration

# which C headers and VHDL packages to create
INCLUDES = f-cpu_memory.h f-cpu_opcodes.h f-cpu_features.h
PACKAGES = f-cpu_config.vhdl f-cpu_opcodes.vhdl

# full names of files to create
TARGETS = \
	$(patsubst %,$(INCLUDEDIR)/%,$(INCLUDES)) \
	$(patsubst %,$(PACKAGEDIR)/%,$(PACKAGES))

# config source files
M4CONFIG = \
	f-cpu_user.m4 \
	f-cpu_features.m4 \
	f-cpu_opcodes.m4 \
	f-cpu_memory.m4 \
	f-cpu_sr.m4

# how to "freeze" m4 files
%.m4f: %.m4 $(M4CONFIG)
	$(M4) -F $@ $< $(M4CONFIG) > /dev/null

# how to create C headers
$(INCLUDEDIR)/%.h: %.h.in langage_c.m4f
	rm -f $@
	$(M4) -R langage_c.m4f $< > $@

# how to create VHDL packages
$(PACKAGEDIR)/%.vhdl: %.vhdl.in langage_vhdl.m4f
	rm -f $@
	$(M4) -R langage_vhdl.m4f $< > $@

config: $(TARGETS)

all clean install:	# nothing to do

distclean:
	rm -f *.m4f
	rm -f $(TARGETS)
