###############################################################################
#
# (c) Copyright IBM Corp. 2005 All Rights Reserved
#
# Physical Memory Information Module
#
# 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
#
# Author International Business Machines
# Author Paul Movall <movall@us.ibm.com>
#
# Version Current Version: 1.0
#
# Date Current Date: 01/2005
#
# Version 0.1, 11/2003: File created by Paul Movall <movall@us.ibm.com>
# Version 1.0, 01/2005: Miscellaneous cleanup for publish
#
###############################################################################
.PHONY: clean tests doc

DATE=$(shell date +%m-%d-%Y)

# Comment/uncomment the following line to disable/enable debugging
# DEBUG = y

ifeq ($(DEBUG),y)
  DEBFLAGS = -g -DDEBUG
else
  DEBFLAGS = -g
endif


# Architecture dependent flags
ifeq ($(ARCH),ppc)
  SUFFIX = ppc
  CFLAGS = -Wall -mcpu=403 $(DEBFLAGS)
  CROSS = powerpc-linux-
else
  ifeq ($(ARCH),cygwin)
    SUFFIX = cyg
    CFLAGS = $(DEBFLAGS)
    CROSS = 
  else
    SUFFIX = x86
    CFLAGS = $(DEBFLAGS)
    CROSS = 
  endif
endif


CC = $(CROSS)gcc
LD = $(CROSS)gcc

# version of this application
VERSION = 0.1


SRCS    = main.c lex.yy.c parsers.c base_parser.c phys_parser.c lib_sum_map.c outpost.c

TARGETS = mem_analysis_$(SUFFIX)
OBJS   = $(SRCS:.c=_$(SUFFIX).o)

all: $(TARGETS) .depend lex.yy.c

lex.yy.c: td.flex
	flex td.flex

$(TARGETS): $(OBJS)
	$(LD) -o $@ $^

%_$(SUFFIX).o: %.c
	$(CC) -c $(CFLAGS) $< -o $@

clean:
	$(RM) $(TARGETS) *.o *~ core .depend *.LOG dep depend lex.yy.* *.exe

tgz:
	tar cvfz /tmp/mem_analysis-$(DATE).tgz $(SRCS) *load bugs.txt Makefile

ident: all
	ident $(TARGET).o | awk '{ printf("%-14s %10s %s %s %s %s\n",$$2,$$3,$$4,$$5,$$6,$$7)}'

dep depend .depend:
	$(CC) $(CFLAGS) -M *.c > .depend

ifeq (.depend,$(wildcard .depend))
include .depend
endif
