#
# 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.
#

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

#CC = gcc

ALC_INC = -I$(ALLIANCE_INCLUDE) \
          -DGFP_H='<$(GFP_H)>' \
          -DMGN_H='<$(MGN_H)>' \
          -DMLU_H='<$(MLU_H)>' \
          -DMPU_H='<$(MPU_H)>' \
          -DMLO_H='<$(MLO_H)>' \
          -DMPH_H='<$(MPH_H)>' \
          -DBHL_H='<$(BHG_H)>' \
          -DBVL_H='<$(BVL_H)>' \
          -DBEH_H='<$(BEH_H)>' \
          -DPAT_H='<$(PAT_H)>' \
          -DLOG_H='<$(LOG_H)>' \
          -DMUT_H='<$(MUT_H)>' \
          -DAPR_H='<$(APR_H)>'

ALC_LIB = -L$(ALLIANCE_LIB) \
          $(GFP_L) \
          $(APR_L) \
          $(MGN_L) \
          $(MLU_L) \
          $(MPU_L) \
          $(MCP_L) \
          $(MAP_L) \
          $(MMG_L) \
          $(MCL_L) \
          $(MGL_L) \
          $(MAL_L) \
          $(MVL_L) \
          $(MEL_L) \
          $(MSL_L) \
          $(MHL_L) \
          $(MLO_L) \
          $(RCN_L) \
          $(MPH_L) \
          $(BVL_L) \
          $(BHL_L) \
          $(BEH_L) \
          $(PAT_L) \
          $(MUT_L)

DPR_VERSION   =  6.2
LOCAL_CFLAGS  =  $(CFLAGS)                              \
                 $(ALC_INC)                             \
                 -DDPR_VERSION='"$(DPR_VERSION)"'       \
                 -DALLIANCE_VERSION=$(ALLIANCE_VERSION) \
                 -D$(MACHINE)                           \
                 -O

EXE          = $(TARGET_BIN)/dpr

MAIN_OBJ     = dpr.o
PLACER_OBJ   = placer_main.o        \
               placer_structure.o   \
               placer_decoup.o      \
               placer_utils.o       \
               placer_create_grid.o \
               placer_create_con.o  \
               placer_dprfile.o     \
               scp_scp2mbk.o        \
               y.tab.o              \
               lex.yy.o
ROUTER_OBJ   = router_acces.o       \
               router_init_router.o \
               router_optiplace.o   \
               router_save.o        \
               router_dpr.o         \
               router_phwork.o      \
               router_sig.o         \
               router_chanrout.o    \
               router_load.o        \
               router_util.o        \
               router_debug.o       \
               router_dprlin.o      \
               router_router.o
STRECHER_OBJ = strecher_allowed.o   \
	           strecher_intv.o      \
		       strecher_strech.o    \
               strecher_bics.o      \
		       strecher_phcma.o     \
	           strecher_supply.o    \
               strecher_dtdupl.o    \
	           strecher_phcut.o     \
	           strecher_support.o   \
               strecher_hierarch.o  \
	           strecher_phtalu.o    \
	           strecher_upper.o
OBJ          = $(MAIN_OBJ)          \
               $(STRECHER_OBJ)      \
               $(PLACER_OBJ)        \
               $(ROUTER_OBJ)

%.o: %.c
	$(CC) $(LOCAL_CFLAGS) -c $<

all: $(EXE)

$(EXE) : $(OBJ)
	$(CC) $(CFLAGS) $(OBJ) $(ALC_LIB) -lm -o $(EXE)
	$(STRIP) $(EXE)

clean:
	-$(RM) -f *.o

realclean: clean
	-$(RM) -f $(EXE)

depends:
	@if [ "$(CC)" = "gcc" ] ;\
	 then \
	   echo "Creating file : Makefile.depends" ;\
	   $(CC) -MM $(LOCAL_CFLAGS) *.c > Makefile.depends ;\
	 else \
	   echo "Option invalide avec $(CC)" ;\
	 fi

y.tab.c : placer_scr.yac
	$(YACC) $(YACCFLAGS) -d placer_scr.yac

lex.yy.c : placer_scr.lex
	$(LEX) placer_scr.lex

lex.yy.o : lex.yy.c
y.tab.o : y.tab.c

#include Makefile.depends
