#  Makefile for LinCity   (c)  I J Peters 1995,1996.

#       This is where the binaries for LinCity will be placed.
LC_BINDIR = /usr/local/bin/
#          for solaris you might choose...
#          LC_BINDIR = /opt/lcity/bin

#       This is where the library/data files will be placed.
LC_LIBDIR = /usr/local/lib/lincity/
#          for solaris you might choose...
#          LC_LIBDIR = /opt/lcity/lib
export LC_LIBDIR

CFLAGS = -O2 -DLIBDIR=\"$(LC_LIBDIR)\"
# -fno-strength-reduce
#PROFF = -pg
#PROFL = -lc
#PROFD = -DCS_PROFILE

LC_XFLAGS = $(CFLAGS) -DLC_X11 
LC_XLIBS = -lXExExt -lXext -lX11

XOBJS = xmain.o xmouse.o xscreen.o xmps.o xtypeinit.o xengine.o\
 xtransport.o xmarket.o xhelp.o lcx11.o

#SOLARIS_XHOME = /usr/openwin

#  /usr/X11R6/lib/X11/config/ is where Imake.tmpl lives, change the following
# line if yours is somewhere else.
LC_IMAKE_ARGS = -DUseInstalled -I/usr/X11R6/lib/X11/config

dummy:
	@echo
	@echo '            LinCity  ----------------------  LinCity'
	@echo
	@echo '      'Please use one of the following commands:
#	@echo
	@echo make install '    ' installs the binaries and lib/data files
	@echo '     ' If you do not have the binaries, you will have
	@echo '     ' to use one of the following commands first.
	@echo make lincity '    ' compiles the svga version
	@echo make xlincity '   ' compiles the X version for Linux
	@echo make hpux '       ' compiles the X version for HP-UX 9.05
	@echo make solaris '    ' compiles the X version for Solaris
	@echo '    ' picedit is used to draw the icons, it is not part of the game.
	@echo make picedit '    ' compiles and installs SVGA picedit
	@echo make xpicedit '   ' compiles and installs xpicedit
	@echo
	@echo make clean '      ' deletes the \'*.o\' files and binaries
	@echo make uninstall '  ' uninstalls everything
	@echo
	@echo The current install paths are:
#	@echo
	@echo '          ' Binaries  '    ' $(LC_BINDIR)
	@echo '         ' Libs/Data  '    ' $(LC_LIBDIR)
	@echo
	@echo To change them edit the Makefile and change LC_BINDIR and LC_LIBDIR.
#	@echo LC_BINDIR and LC_LIBDIR.
	@echo

all : lincity xlincity
	@echo All done.

lc : lincity install
	@echo Installed

lincity : main.o mouse.o screen.o mps.o typeinit.o engine.o transport.o\
		market.o help.o
	g++ $(PROFL) main.o mouse.o screen.o mps.o typeinit.o engine.o\
                transport.o market.o help.o -lm -lvgagl -lvga\
                -o lincity $(PROFF)
	chmod +s lincity

# I only call the Makefile generated by imake for linking
# all the objects and libraries. 
xlincity : $(XOBJS)
	imake -s XMakefile $(LC_IMAKE_ARGS)
	make -f XMakefile

solaris :
	make -f sunosMakefile

hpux : 
	make -f hpuxMakefile

install :
	-cp lincity $(LC_BINDIR)
	-chmod +s $(LC_BINDIR)/lincity
	-cp xlincity $(LC_BINDIR)
	-mkdir -p $(LC_LIBDIR)
	cp -R icons/ $(LC_LIBDIR)
	cp -R help/ $(LC_LIBDIR)
	cp -R messages/ $(LC_LIBDIR)
	cp -R opening/ $(LC_LIBDIR)
	cp open.tga.gz $(LC_LIBDIR)/opening
	cp colour.pal $(LC_LIBDIR)

uninstall:
	-rm $(LC_BINDIR)/lincity
	-rm $(LC_BINDIR)/xlincity
	-rm $(LC_BINDIR)/picedit
	-rm $(LC_BINDIR)/xpicedit
	-rm -r $(LC_LIBDIR)


main.o : main.cxx main.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c main.cxx -o main.o $(CFLAGS)

xmain.o : main.cxx main.h lin-city.h lctypes.h lcx11.h
	gcc $(PROFF) $(PROFD) -c main.cxx -o xmain.o $(LC_XFLAGS)

mouse.o : mouse.cxx mouse.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c mouse.cxx -o mouse.o $(CFLAGS)

xmouse.o : mouse.cxx mouse.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c mouse.cxx -o xmouse.o $(LC_XFLAGS)

screen.o : screen.cxx screen.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c screen.cxx -o screen.o $(CFLAGS)

xscreen.o : screen.cxx screen.h lin-city.h lctypes.h lcx11.h
	gcc $(PROFF) $(PROFD) -c screen.cxx -o xscreen.o $(LC_XFLAGS)

mps.o : mps.cxx mps.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c mps.cxx -o mps.o $(CFLAGS)

xmps.o : mps.cxx mps.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c mps.cxx -o xmps.o $(LC_XFLAGS)

typeinit.o : typeinit.cxx typeinit.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c typeinit.cxx -o typeinit.o $(CFLAGS)

xtypeinit.o : typeinit.cxx typeinit.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c typeinit.cxx -o xtypeinit.o $(LC_XFLAGS)

engine.o : engine.cxx engine.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c engine.cxx -o engine.o $(CFLAGS)

xengine.o : engine.cxx engine.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c engine.cxx -o xengine.o $(LC_XFLAGS)

transport.o : transport.cxx transport.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c transport.cxx -o transport.o $(CFLAGS)
 
xtransport.o : transport.cxx transport.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c transport.cxx -o xtransport.o $(LC_XFLAGS)

market.o    : market.cxx market.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c market.cxx -o market.o $(CFLAGS)

xmarket.o    : market.cxx market.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c market.cxx -o xmarket.o $(LC_XFLAGS)

help.o      : help.cxx help.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c help.cxx -o help.o $(CFLAGS)

xhelp.o      : help.cxx help.h lin-city.h lctypes.h
	gcc $(PROFF) $(PROFD) -c help.cxx -o xhelp.o $(LC_XFLAGS)

lcx11.o    : lcx11.cxx lcx11.h lin-city.h
	gcc -c lcx11.cxx -o lcx11.o $(LC_XFLAGS)


clean :
	-rm lincity
	-rm xlincity
	-rm picedit
	-rm xpicedit
	-rm *.o
	-rm XMakefile
	-rm XPMakefile

distclean:
	-rm help/*~
	-rm help/*.bak
	-rm opening/*~
	-rm messages/*~
	-rm messages/*.bak
	-rm picedit
	-rm *.bak
	-rm *~
	-rm XMakefile
	-rm XPMakefile

picedit : picedit.cxx 
	gcc picedit.cxx -o picedit -lvgagl -lvga $(CFLAGS)
	cp picedit $(LC_BINDIR)
	chmod +s $(LC_BINDIR)/picedit
	-mkdir -p $(LC_LIBDIR)/opening
	cp opening/alt-8x8 $(LC_LIBDIR)/opening
	cp colour.pal $(LC_LIBDIR)

# I only call the Makefile generated by imake for linking.
xpicedit : picedit.cxx picedit.h
	gcc -c picedit.cxx -o xpicedit.o $(CFLAGS) -DP_X
	imake -f XPImakefile -s XPMakefile $(LC_IMAKE_ARGS)
	make -f XPMakefile
	cp xpicedit /usr/local/bin
	-mkdir -p $(LC_LIBDIR)/opening
	cp opening/alt-8x8 $(LC_LIBDIR)/opening
	cp colour.pal $(LC_LIBDIR)

#    --------  End of Makefile for LinCity  -----------
