# Makefile for traindir by Campiero Caprini
# http://www.backerstreet.com/traindir/
# http://xtsl.free.fr
# Created by Marani Claude
#
# for Linux and Freebsd

VERSION=1.19c

BINDIR=/usr/local/bin
SAMPLEDIR=/usr/local/share

INSTALL = install

GTKINC=`gtk-config --cflags`
GTKLIB=`gtk-config --libs`
GLIBINC=`glib-config --cflags`
GLIBLIB=`glib-config --libs`

CFLAGS += -g $(GLIBINC) $(GTKINC) #-static

CC ?= cc

LIBS = $(GLIBLIB) $(GTKLIB)

SRCS = gtkmain.c button.c clist.c gdialog.c gtkask.c gtkopen.c \
       html.c .c loadsave.c field.c menu.c run.c table.c tgraph.c \
       runai.c track.c trsim.c
       
SRCS2 = wmatch.c

OBJS = gtkmain.o button.o clist.o gdialog.o gtkask.o gtkopen.o \
       html.o loadsave.o field.c menu.o run.o table.o tgraph.o \
       runai.o track.o trsim.o 

OBJS2 = wmatch.o

DEPENDS = ask.h color.h gtkask.h gtkopen.h gtktrain.h gtkui.h html.h resource.h \
          trsim.h trsimres.h ui.h wclist.h

TARGETS = traindir gentt

all:	$(TARGETS)

static: $(OBJS) $(OBJS2)
	$(CC) $(CFLAGS) -static -o traindir $(OBJS) $(LIBS)
	$(CC) $(CFLAGS) -static -o gentt $(OBJS2) $(LIBS)

traindir: $(OBJS)
	$(CC) $(CFLAGS) -o traindir $(OBJS) $(LIBS)

gentt:	$(OBJS2)
	$(CC) $(CFLAGS) -o gentt $(OBJS2) $(LIBS)

install:
	$(INSTALL) -d $(SAMPLEDIR)/traindir
	$(INSTALL) -d $(SAMPLEDIR)/traindir/tdicons
	$(INSTALL) -d $(SAMPLEDIR)/traindir/locales
	$(INSTALL) -m 755 setup_trdir.sh $(BINDIR)
	$(INSTALL) -m 755 traindir $(BINDIR)
	$(INSTALL) -m 755 gentt $(BINDIR)
	$(INSTALL) -m 644 sample/bridgeup.xpm $(SAMPLEDIR)/traindir/tdicons
	$(INSTALL) -m 644 sample/bridgedn.xpm $(SAMPLEDIR)/traindir/tdicons
	$(INSTALL) -m 644 sample/default.sch $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/default.trk $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/demoitin.trk $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/southst.trk $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/triangl.xpm $(SAMPLEDIR)/traindir/tdicons
	$(INSTALL) -m 644 sample/tdirico1.ico $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/tdirico2.ico $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 sample/train.ico $(SAMPLEDIR)/traindir/
	$(INSTALL) -m 644 locales/.traindir.it $(SAMPLEDIR)/traindir/locales
	$(INSTALL) -m 644 locales/.traindir.fr $(SAMPLEDIR)/traindir/locales
	$(INSTALL) -m 644 locales/README $(SAMPLEDIR)/traindir/locales  
clean:
	rm -f $(TARGETS) *.o  

dist:
	rm -f *.o
	rm -f $(TARGETS)
	tar -cvf traindir-$(VERSION)-src.tar *
	gzip traindir-$(VERSION)-src.tar

uninstall:
	rm -fr $(SAMPLEDIR)/traindir
	rm -f $(BINDIR)/traindir
	rm -f $(BINDIR)/gentt
	rm -f $(BINDIR)/setup_traindir.sh
