# =============================================================================
# xIncode - Makefile
#
# Copyright (C) 2000-2005 by Karim Kaschani
#
# This file is part of the software xIncode developed to support the design
# of interconnects in semiconductor technologies.
#
# xIncode 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.
#
# xIncode 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
# =============================================================================

# ............................................................... general items

# the directory, where the binary goes
BINDIR      = /usr/local/bin

# the directory, where the man page should be installed
MANDIR	    = /usr/local/man

# the directory, where you keep your pixmaps
PIXMAPDIR   = /usr/local/include/X11/pixmaps

# the directory of your systems application defaults
APPDEFDIR   = /usr/X11R6/lib/X11/app-defaults

# the directory, where the database file can be found
DATABASEDIR = '"./examples"'

# .......................................................... XPM specific items

# if your system lacks XPM comment the following 3 items
XPM         = -DHAVE_XPM

# the directory, where the xpm.h can be found
XPM_INCDIR  = -I/usr/X11R6/include/X11

# the directory, where the XPM libraries can be found
XPM_LIBDIR  = -L/usr/X11R6/lib -lXpm

# ----------------------------------------------------------------------- Linux

INSTALL  = /usr/bin/install
CC       = gcc
CFLAGS   = -c
COPTIONS = -g
DEFINES  = -DDBDIR=$(DATABASEDIR) $(XPM)
INCLUDES = -I/usr/X11R6/include -I/usr/local/include $(XPM_INCDIR)
LEX      = lex
LFLAGS   =
YACC     = yacc
YFLAGS   = -d
LDFLAGS  = -L/usr/X11R6/lib -L/usr/local/lib $(XPM_LIBDIR) \
           -lXm -lXt -lXext -lX11 -lfl -lm

# --------------------------------------------------------------- Solaris 2.5.x

#INSTALL  = /usr/ucb/install
#CC       = cc
#CFLAGS   = -c
#COPTIONS = -O
#DEFINES  = -DDBDIR=$(DATABASEDIR) $(XPM)
#INCLUDES = -I/usr/openwin/include -I/usr/dt/include $(XPM_INCDIR)
#LEX      = flex
#LFLAGS   =
#YACC     = yacc
#YFLAGS   = -d
#LDFLAGS  = -L/usr/openwin/lib -L/usr/dt/lib $(XPM_LIBDIR) \
#           -lXm -lXt -lXext -lX11 -lnsl -lsocket -lfl -lm \
#           -R /usr/dt/lib

# -------------------------------------------------------------------- HPUX 9.0

#INSTALL  = /usr/local/bin/install
#CC       = cc
#CFLAGS   = -c
#COPTIONS = -Aa -O
#DEFINES  = -D_HPUX_SOURCE -DDBDIR=$(DATABASEDIR) $(XPM)
#INCLUDES = -I/usr/include/X11R5 -I/usr/include/Motif1.2 $(XPM_INCDIR)
#LEX      = lex
#LFLAGS   =
#YACC     = yacc
#YFLAGS   = -d
#LDFLAGS  = -L/usr/lib/X11R5 -L/usr/lib/Motif1.2 $(XPM_LIBDIR) \
#           -lXm -lXt -lXext -lX11 -lm

# ------------------------------------------------------------------- AIX 4.1.4

#INSTALL  = installbsd
#CC       = cc
#CFLAGS   = -c
#COPTIONS = -O
#DEFINES  = -DAIX -DSYSV -DDBDIR=$(DATABASEDIR) $(XPM)
#INCLUDES = $(XPM_INCDIR)
#LEX      = lex
#LFLAGS   =
#YACC     = yacc
#YFLAGS   = -d
#LDFLAGS  = $(XPM_LIBDIR) -lXm -lXt -lXext -lX11 -lm

# --------------------------------------------------------------- general stuff

XSRC = lex.yy.c y.tab.c calc.c misc.c xutils.c xincode.c
XOBJ = lex.yy.o y.tab.o calc.o misc.o xutils.o xincode.o
PSRC = lex.yy.c y.tab.c calc.c misc.c xutils.c
POBJ = lex.yy.o y.tab.o calc.o misc.o xutils.o

all: xincode

xincode: $(XOBJ)
	$(CC) -o xincode $(XOBJ) $(LDFLAGS)

y.tab.c y.tab.h: parse.y
	$(YACC) $(YFLAGS) parse.y

lex.yy.c: parse.l
	$(LEX) $(LFLAGS) parse.l

.c.o: $(XSRC) $(PSRC)
	$(CC) $(CFLAGS) $(COPTIONS) $(DEFINES) $(INCLUDES) $<

xincode.o: xincode.h help.h error.h calc.h misc.h xutils.h y.tab.h xincode.xbm xincode.xpm
xutils.o: xincode.h misc.h
lex.yy.o: y.tab.h lex.yy.c
lex.yy.c: xincode.h misc.h
y.tab.c: xincode.h
misc.o: calc.h xincode.h
calc.o: xincode.h xutils.h

install: xincode xincode.xbm xincode.xpm xincode.1 xincode.5 xincode.7
	mkdir -p $(BINDIR)
	mkdir -p $(PIXMAPDIR)
	mkdir -p $(APPDEFDIR)
	mkdir -p $(MANDIR)/man1
	mkdir -p $(MANDIR)/man5
	mkdir -p $(MANDIR)/man7
	$(INSTALL) -s -m 755 xincode $(BINDIR)
	$(INSTALL)    -m 644 xincode.xbm $(PIXMAPDIR)
	$(INSTALL)    -m 644 xincode.xpm $(PIXMAPDIR)
	$(INSTALL)    -m 644 xIncode $(APPDEFDIR)
	$(INSTALL)    -m 644 xincode.1 $(MANDIR)/man1
	$(INSTALL)    -m 644 xincode.5 $(MANDIR)/man5
	$(INSTALL)    -m 644 xincode.7 $(MANDIR)/man7

uninstall: xincode xincode.xbm xincode.xpm xincode.1 xincode.5 xincode.7
	rm -f $(BINDIR)/xincode
	rm -f $(PIXMAPDIR)/xincode.xbm
	rm -f $(PIXMAPDIR)/xincode.xpm
	rm -f $(APPDEFDIR)/xIncode
	rm -f $(MANDIR)/man1/xincode.1
	rm -f $(MANDIR)/man5/xincode.5
	rm -f $(MANDIR)/man5/xincode.7

clean:
	rm -f $(XOBJ) $(POBJ) lex.yy.c y.tab.c y.tab.h xincode
