#
# 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 BSG.
# date : 29/02/1996

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

all : $(TARGET_BIN)/bsg $(TARGET_INCLUDE)/gbs201.h $(TARGET_LIB)/libGbs201.a

realclean : clean
	-@$(RM) $(TARGET_BIN)/bsg $(TARGET_BIN)/bsg.old $(TARGET_INCLUDE)/gbs*.h $(TARGET_LIB)/libGbs*.a > /dev/null 2>&1

clean :
	-@$(RM) bsg_*.o > /dev/null 2>&1

##### Barrel shifter generator compilation.

ALC_INC          = -I$(ALLIANCE_INCLUDE)\
                   -DMUT_H='<'$(MUT_H)'>'\
                   -DMLO_H='<'$(MLO_H)'>'\
                   -DMPH_H='<'$(MPH_H)'>'\
                   -DMLU_H='<'$(MLU_H)'>'\
                   -DMPU_H='<'$(MPU_H)'>'\
                   -DMGN_H='<'$(MGN_H)'>'\
                   -DICU_H='<'$(ICU_H)'>'\
                   -DICN_H='<'$(ICN_H)'>'\
                   -DIAC_H='<'$(IAC_H)'>'



ALC_LIB          = -L$(ALLIANCE_LIB)\
                   $(MGN_L)\
                   $(MLU_L)\
                   $(MPU_L)\
                   $(MCP_L)\
                   $(MAP_L)\
                   $(MMG_L)\
                   $(MCL_L)\
                   $(MAL_L)\
                   $(MVL_L)\
                   $(MEL_L)\
                   $(MSL_L)\
                   $(MHL_L)\
                   $(MGL_L)\
                   $(RCN_L)\
                   $(MLO_L)\
                   $(MPH_L)\
                   $(ICU_L)\
                   $(ICC_L)\
                   $(ICA_L)\
                   $(ICN_L)\
                   $(MUT_L)\
                   -lm

distrib : $(TARGET_BIN)/bsg

$(TARGET_BIN)/bsg : bsg_main.o bsg_disp.o
	$(CC) $(CFLAGS) $(ALC_INC) bsg_main.o bsg_disp.o $(ALC_LIB) -o $(TARGET_BIN)/bsg;
	$(STRIP) $(TARGET_BIN)/bsg;
	@ echo ""

bsg_main.o : bsg_main.c bsg_head.h gbs201.h
	$(CC) $(CFLAGS) $(ALC_INC)  -I$(ALLIANCE_INCLUDE) -DALC_VER=$(ALLIANCE_VERSION) bsg_main.c -c;
	@ echo ""

bsg_disp.o : bsg_disp.c bsg_head.h bsg_layo.c bsg_icon.c bsg_vhdl.c bsg_patt.c bsg_netl.c bsg_data.c
	$(CC) $(CFLAGS) $(ALC_INC) bsg_disp.c -c;
	@ echo ""

##### Include file copy.

$(TARGET_INCLUDE)/gbs201.h : gbs201.h
	$(CP) gbs201.h $(TARGET_INCLUDE)/gbs201.h;
	@ echo ""

##### Barrel shifter generator library make.

$(TARGET_LIB)/libGbs201.a : bsg_disp.o
	$(AR) $(ARFLAGS) $(TARGET_LIB)/libGbs201.a bsg_disp.o;
	$(RANLIB) $(TARGET_LIB)/libGbs201.a;
	@ echo ""

