#
# Rudimentary makefile for "gwave" analog waveform viewer
# This makefile requires gmake.
#
# 

# a few configuration items
# someday real soon we'll use autoconf

# If you have a working POSIX regcomp/regexec(3), define HAVE_POSIX_REGEXP
# and comment out REGEXP_OBJS
DFLAGS=-DHAVE_POSIX_REGEXP
#REGEXP_OBJS=regexp.o regerror.o

HW_OS=$(shell hw_os)
INSTDIR=/usr/msl/vlsi/bin/bin-$(HW_OS)

NAME=gwave-0.0.4

#############################################################################
GTKLIBS = $(shell gtk-config --libs)
GTKCFLAGS = $(shell gtk-config --cflags)
THISDIR=$(notdir $(shell pwd))

CFLAGS	= -g -Wall $(GTKCFLAGS) $(DFLAGS)
LDLIBS	= $(GTKLIBS)

CC=gcc
LDCC=gcc

all: gwave test_read

GWAVE_OBJS=gwave.o wavelist.o pixmaps.o cmd.o draw.o event.o wavewin.o \
	reader.o rd_cazm.o rd_hspice.o gtkmisc.o $(REGEXP_OBJS)

gwave: $(GWAVE_OBJS)
	$(LDCC) -o $@ $(GWAVE_OBJS) $(LDLIBS)

test_read: test_read.o reader.o rd_cazm.o rd_hspice.o $(REGEXP_OBJS)
	$(LDCC) -o $@ $^ $(LDLIBS)

regexp.o: regexp.c
	gcc -traditional $(CFLAGS) -c $*.c 

clean:
	rm -f core *.o

distclean: clean
	rm -f gwave test_read *~

dist: distclean
	cd .. ; \
	ln -s $(THISDIR) $(NAME) ; \
	gtar czvf $(NAME).tar.gz --exclude=RCS --dereference $(NAME); \
	rm $(NAME)


install: gwave
	cp gwave $(INSTDIR)


# manual dependencies
gwave.o cmd.o draw.o event.o wavewin.o wavelist.o: gwave.h reader.h
gtkmisc.o: gtkmisc.h
gwave.o: reader.h gwave.h
wavelist.o: gtkmisc.h

reader.o: reader.h
rd_cazm.o: reader.h
rd_hspice.o: reader.h
