view rogue3/Makefile.in @ 224:4d0f53998e8a

Makefile fixes related to installation. 'make install' and 'make uninstall' should now work correctly, placing the documentation in the proper places. Any directories needed will be created.
author John "Elwin" Edwards
date Fri, 26 Feb 2016 17:30:30 -0500
parents 0e99eade579c
children 455464db5800
line wrap: on
line source

#
# Makefile for rogue
# %W% (Berkeley) %G%
#
# Rogue: Exploring the Dungeons of Doom
# Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
# All rights reserved.
#
# See the file LICENSE.TXT for full copyright and licensing information.
#

DISTNAME=@PACKAGE_TARNAME@@PACKAGE_VERSION@
PACKAGE_TARNAME=@PACKAGE_TARNAME@-@PACKAGE_VERSION@
PROGRAM=@PROGRAM@

SCOREFILE=@SCOREFILE@
LOGFILE=@LOGFILE@
SAVEDIR=@SAVEDIR@
GROUPOWNER=@GROUPOWNER@

DESTDIR=
prefix=@prefix@
exec_prefix=@exec_prefix@
datarootdir=@datarootdir@
bindir=@bindir@
mandir=@mandir@
man6dir=$(mandir)/man6
docdir=@docdir@


O=o

HDRS= 	rogue.h machdep.h config.h

OBJS1 = vers.$(O) armor.$(O) chase.$(O) command.$(O) daemon.$(O) daemons.$(O) \
        fight.$(O) init.$(O) io.$(O) list.$(O) main.$(O) mdport.$(O) \
	misc.$(O) monsters.$(O) move.$(O) newlevel.$(O) options.$(O) 
OBJS2 =	pack.$(O) passages.$(O) potions.$(O) rings.$(O) rip.$(O) rooms.$(O) \
	save.$(O) scrolls.$(O) state.$(O) sticks.$(O) things.$(O) \
	weapons.$(O) wizard.$(O) xcrypt.$(O)
OBJS  = $(OBJS1) $(OBJS2)

CFILES= vers.c armor.c chase.c command.c daemon.c daemons.c fight.c \
	init.c io.c list.c main.c mdport.c misc.c monsters.c move.c newlevel.c \
	options.c pack.c passages.c potions.c rings.c rip.c rooms.c \
	save.c scrolls.c state.c sticks.c things.c weapons.c wizard.c xcrypt.c


MISC_C=
DOCSRC= rogue.6 rogue.r
DOCS  = $(PROGRAM).doc $(PROGRAM).cat
RAWDOCS = LICENSE.TXT rogue36.html readme36.html
MISC  =	Makefile $(MISC_C) $(PROGRAM).sln $(PROGRAM).vcproj $(RAWDOCS) $(DOCS)\
	$(DOCSRC)

CC    = gcc
CPPFLAGS =@DEFS@
ROPTS =
COPTS =
CFLAGS= $(COPTS) $(ROPTS)
LIBS  = @LIBS@
RM    = rm -f
LD    = $(CC)
LDOUT = -o 
INSTALL=@INSTALL@
GROFF=@GROFF@
NROFF=@NROFF@
COLCRT=@COLCRT@
TBL=@TBL@

.SUFFIXES: .obj

.c.obj:
	$(CC) $(CFLAGS) /c $*.c

all: $(PROGRAM)$(EXE) docs

$(PROGRAM)$(EXE): $(HDRS) $(OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(LIBS) $(LDOUT)$@

clean:
	$(RM) $(OBJS1)
	$(RM) $(OBJS2)
	$(RM) core $(PROGRAM) $(PROGRAM).exe $(DOCS) $(DISTNAME).tar $(DISTNAME).tar.gz 
	$(RM) $(DISTNAME).zip

docs: $(DOCS)

$(PROGRAM).doc: rogue.r
	if test "x$(GROFF)" != "x" ; then \
	$(GROFF) -P-c -P-b -P-u -t -ms -Tutf8 rogue.r > $(PROGRAM).doc ;\
	elif test "x$(NROFF)" != "x" && test "x$(TBL)" != "x" && test "x$(COLCRT)" != "x" ; then \
	$(TBL) rogue.r | $(NROFF) -ms | $(COLCRT) - > $(PROGRAM).doc ;\
	fi

$(PROGRAM).cat: rogue.6
	if test "x$(GROFF)" != "x" ; then \
	$(GROFF) -P-c -P-b -P-u -Tascii -man rogue.6 > $(PROGRAM).cat ;\
	elif test "x$(NROFF)" != "x" && test "x$(COLCRT)" != "x" ; then \
	$(NROFF) -man rogue.6 | $(COLCRT) - > $(PROGRAM).cat ;\
	fi

install: all
	touch test
	if test ! -f $(DESTDIR)$(SCOREFILE) ; then \
	    mkdir -p `dirname $(DESTDIR)$(SCOREFILE)` ; \
	    $(INSTALL) -m 0664 test $(DESTDIR)$(SCOREFILE) ; fi
	if test "x$(LOGFILE)" != "x" && test ! -f $(DESTDIR)$(LOGFILE) ; then \
	    mkdir -p `dirname $(DESTDIR)$(LOGFILE)` ; \
	    $(INSTALL) -m 0664 test $(DESTDIR)$(LOGFILE) ; fi
	if test "x$(SAVEDIR)" != "x" && test ! -d $(DESTDIR)$(SAVEDIR) ; then \
	    mkdir -p $(DESTDIR)$(SAVEDIR) ; fi
	mkdir -p $(DESTDIR)$(bindir)
	$(INSTALL) -m 0755 $(PROGRAM) $(DESTDIR)$(bindir)/$(PROGRAM)
	-if test "x$(GROUPOWNER)" != "x" ; then \
	    chgrp $(GROUPOWNER) $(DESTDIR)$(SCOREFILE) ; \
	    chgrp $(GROUPOWNER) $(DESTDIR)$(LOGFILE) ; \
	    chgrp $(GROUPOWNER) $(DESTDIR)$(bindir)/$(PROGRAM) ; \
	    chgrp $(GROUPOWNER) $(DESTDIR)$(SAVEDIR) ; \
	    chmod 02755 $(DESTDIR)$(bindir)/$(PROGRAM) ; \
	    chmod 0464 $(DESTDIR)$(SCOREFILE) ; \
	    chmod 0464 $(DESTDIR)$(LOGFILE) ; \
	    chmod 0775 $(DESTDIR)$(SAVEDIR) ; \
        fi
	if test ! -d $(DESTDIR)$(man6dir) && test -d $(DESTDIR)$(mandir) ; \
	    then $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(mandir)/$(PROGRAM).6 ; \
	    else mkdir -p $(DESTDIR)$(man6dir) ; \
	    $(INSTALL) -m 0644 rogue.6 $(DESTDIR)$(man6dir)/$(PROGRAM).6 ; fi
	if test ! -d $(DESTDIR)$(docdir) ; \
	    then mkdir -p $(DESTDIR)$(docdir) ; fi
	$(INSTALL) -m 0644 rogue.r $(DESTDIR)$(docdir)/$(PROGRAM).r
	$(INSTALL) -m 0644 $(DOCS) $(RAWDOCS) $(DESTDIR)$(docdir)
	$(RM) test

uninstall:	
	$(RM) $(DESTDIR)$(bindir)/$(PROGRAM)
	$(RM) $(DESTDIR)$(man6dir)/$(PROGRAM).6
	$(RM) $(DESTDIR)$(mandir)/$(PROGRAM).6
	$(RM) -r $(DESTDIR)$(docdir)
    
reinstall: uninstall install

dist.src:
	make clean
	tar cf $(DISTNAME)-src.tar $(CFILES) $(HDRS) $(MISC) $(DOCS)
	gzip -f $(DISTNAME)-src.tar

dist.irix:
	@$(MAKE) clean
	@$(MAKE) CC=cc CFLAGS="-woff 1116 -O3" $(PROGRAM)
#	tbl rogue.r | nroff -ms | colcrt - > $(PROGRAM).doc
#	nroff -man rogue.6 | colcrt - > $(PROGRAM).cat
	tar cf $(DISTNAME)-irix.tar $(PROGRAM) LICENSE.TXT $(DOCS)
	gzip -f $(DISTNAME)-irix.tar

dist.aix:
	@$(MAKE) clean
	@$(MAKE) CC=xlc CFLAGS="-qmaxmem=16768 -O3 -qstrict" $(PROGRAM)
#	tbl rogue.r | nroff -ms | colcrt - > $(ROGUE).doc
#	nroff -man rogue.6 | colcrt - > $(ROGUE).cat
	tar cf $(DISTNAME)-aix.tar $(PROGRAM) LICENSE.TXT $(DOCS)
	gzip -f $(DISTNAME)-aix.tar

dist.linux:
	@$(MAKE) clean
	@$(MAKE) $(PROGRAM)
#	groff -P-c -t -ms -Tascii rogue.r | sed -e 's/.\x08//g' > $(PROGRAM).doc
#	groff -man rogue.6 | sed -e 's/.\x08//g' > $(PROGRAM).cat
	tar cf $(DISTNAME)-linux.tar $(PROGRAM) LICENSE.TXT $(DOCS)
	gzip -f $(DISTNAME)-linux.tar
	
debug.linux:
	@$(MAKE) clean
	@$(MAKE) COPTS="-g" $(PROGRAM)
#	groff -P-c -t -ms -Tascii rogue.r | sed -e 's/.\x08//g' > $(PROGRAM).doc
#	groff -man rogue.6 | sed -e 's/.\x08//g' > $(PROGRAM).cat
	
dist.interix: 
	@$(MAKE) clean
	@$(MAKE) COPTS="-ansi" $(PROGRAM)
#	groff -P-b -P-u -t -ms -Tascii rogue.r > $(PROGRAM).doc
#	groff -P-b -P-u -man -Tascii rogue.6 > $(PROGRAM).cat
	tar cf $(DISTNAME)-interix.tar $(PROGRAM) LICENSE.TXT $(DOCS)
	gzip -f $(DISTNAME)-interix.tar	

dist.cygwin:
	@$(MAKE) --no-print-directory clean
	@$(MAKE) COPTS="-I/usr/include/ncurses" --no-print-directory $(PROGRAM)
#	groff -P-c -t -ms -Tascii rogue.r | sed -e 's/.\x08//g' > $(PROGRAM).doc
#	groff -P-c -man -Tascii rogue.6 | sed -e 's/.\x08//g' > $(PROGRAM).cat
	tar cf $(DISTNAME)-cygwin.tar $(PROGRAM).exe LICENSE.TXT $(DOCS)
	gzip -f $(DISTNAME)-cygwin.tar

#
# Use MINGW32-MAKE to build this target
#
dist.mingw32:
	@$(MAKE) --no-print-directory RM="cmd /c del" clean
	@$(MAKE) --no-print-directory COPTS="-I../pdcurses" LIBS="../pdcurses/pdcurses.a" $(PROGRAM)
	cmd /c del $(DISTNAME)-mingw32.zip
	zip $(DISTNAME)-mingw32.zip $(PROGRAM).exe LICENSE.TXT $(DOCS)
	
#
# Seperate doc targets for DJGPP prevent strange SIGSEGV in groff
# in that environment.
#
doc.djgpp:
	groff -t -ms -Tascii rogue.r | sed -e 's/.\x08//g' > $(PROGRAM).doc

cat.djgpp:
	groff -man -Tascii rogue.6 | sed -e 's/.\x08//g' > $(PROGRAM).cat

dist.djgpp: 
	@$(MAKE) --no-print-directory clean
	@$(MAKE) --no-print-directory LDFLAGS="-L$(DJDIR)/LIB" \
		LIBS="-lpdcur" $(PROGRAM)
#	@$(MAKE) --no-print-directory doc.djgpp
#	@$(MAKE) --no-print-directory cat.djgpp
	rm -f $(DISTNAME)-djgpp.zip
	zip $(DISTNAME)-djgpp.zip $(PROGRAM) LICENSE.TXT $(DOCS)

#
# Use NMAKE to build this target
#
dist.win32:
	@$(MAKE) /NOLOGO O="obj" RM="-del" clean
	@$(MAKE) /NOLOGO O="obj" CC="@CL" LD="link" LDOUT="/OUT:" EXE=".exe"\
	    LIBS="/NODEFAULTLIB:LIBC ..\pdcurses\pdcurses.lib shell32.lib user32.lib Advapi32.lib" \
	    COPTS="-nologo -D_CRT_SECURE_NO_DEPRECATE -I..\pdcurses \
	    -Ox -wd4033 -wd4716" $(PROGRAM).exe
	-del $(DISTNAME)-win32.zip
	zip $(DISTNAME)-win32.zip $(PROGRAM).exe LICENSE.TXT $(DOCS)