#
# This file is part of the Alliance CAD System
# Copyright (C) Laboratoire LIP6 - Dpartement ASIM
# Universite Pierre et Marie Curie
# 
# Home page          : http://www-asim.lip6.fr/alliance/
# E-mail support     : mailto:alliance-support@asim.lip6.fr
# 
# This progam 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.
# 
# Alliance VLSI  CAD System  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 the GNU C Library; see the  file COPYING. If not, write to the Free
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

# makefile for mbk2mg : leaf cells to idps standard modgen
#                       written by Frederic Petrot

include $(TOP)/etc/$(MACHINE).mk
include $(TOP)/etc/libraries.mk

ALC_INC          = -I$(ALLIANCE_INCLUDE) \
                   -DMPU_H='"$(MPU_H)"' \
                   -DMPH_H='"$(MPH_H)"' \
                   -DMUT_H='"$(MUT_H)"'

VERSION = 4.0
RCSSOURCES = Makefile mbk2mg.c mg2mbk.lex mg2mbk.yac
MMG_LIB = libMmg402.a

OBJ       = mbk2mg.o mgyac.o mglex.o

all: $(TARGET_LIB)/$(MMG_LIB)

$(TARGET_LIB)/$(MMG_LIB) : $(OBJ)
	$(AR) $(ARFLAGS) $(TARGET_LIB)/$(MMG_LIB) $(OBJ)
	$(RANLIB) $(TARGET_LIB)/$(MMG_LIB)


mbk2mg.o : mbk2mg.c
	$(CC) $(CFLAGS) $(ALC_INC) -c mbk2mg.c

mglex.o : mg2mbk.lex
	$(LEX) $(LEXFLAGS) mg2mbk.lex
	$(SED) -e "s/yy/mg/g" -e "s/YY/MG/g" lex.yy.c > mglex.c
	$(RM) lex.yy.c
	$(CC) $(CFLAGS) $(ALC_INC) -c mglex.c

mgyac.o : mg2mbk.yac
	$(YACC) $(YACCFLAGS) -d mg2mbk.yac
	$(SED) -e "s/yy/mg/g" -e "s/YY/MG/g" y.tab.c > mgyac.c; \
	$(RM) y.tab.c
	$(SED) -e "s/yy/mg/g" -e "s/YY/MG/g" y.tab.h > 1; \
	$(MV) 1 y.tab.h
	$(CC) $(CFLAGS) $(ALC_INC) -c mgyac.c

checkin : 
	echo "y" > 1
	for i in $(RCSSOURCES); do \
		ci -l$(VERSION) -f -m"rcs version number consistency" $$i < 1 ; \
	done
	head -15 Makefile > ./RCS/rcs$(VERSION)
	$(RM) 1

clean :
	$(RM) -f $(OBJ) lex.yy.c y.tab.c y.tab.h

realclean: clean
	$(RM) -f $(TARGET_LIB)/$(MMG_LIB)
