+# $NetBSD: Makefile,v 1.37 2014/06/14 20:49:37 mrg Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= phantasia
-SRCS= main.c fight.c io.c interplayer.c gamesupport.c misc.c phantglobs.c
-DPADD= ${LIBM} ${LIBCURSES} ${LIBTERM} ${LIBCOMPAT}
-LDADD= -lm -lcurses -ltermlib -lcompat
-HIDEGAME=hidegame
+SRCS= fight.c gamesupport.c interplayer.c io.c main.c misc.c phantglobs.c
MAN= phantasia.6
-CLEANFILES+=map setup setup.o
-all: setup phantasia
+FILESDIR=/var/games/phantasia
+FILESMODE=0660
+ALLFILES=gold lastdead mess monsters void motd characs scoreboard
+FILES=gold lastdead mess monsters void motd
-setup: phantglobs.o setup.o monsters.asc ${LIBM}
- ${CC} phantglobs.o setup.o -o ${.TARGET} -lm
+CLEANFILES+=map mkdata $(ALLFILES) files.stamp
-beforeinstall:
- ./setup -m ${.CURDIR}/monsters.asc
- chown games.bin ${DESTDIR}/var/games/phantasia/*
+all: $(PROG) $(FILES)
+
+$(FILES): files.stamp
+files.stamp: mkdata monsters.asc
+ rm -f files.stamp
+ ./mkdata -m monsters.asc
+ touch files.stamp
+
+mkdata: phantglobs.c setup.c
+ clang -o mkdata phantglobs.c setup.c
# Make Phantasia map. Change the map commands reflect your installation.
# PLOTDEVICE is used for plotting the map. Change as appropriate.
map: map.c
- ${CC} -O ${.CURDIR}/map.c -lplot -o ${.TARGET}
+ clang -o map map.c -lplot
./map | plot > /dev/tty
-# XXX this rule shouldn't be here.
-phantasia.cat6: phantasia.6
- tbl ${.CURDIR}/phantasia.6 | nroff -man > ${.TARGET}
+$(PROG): $(SRCS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG) $(SRCS) -lncursesw
+ $(STRIP) $(PROG)
+
+$(ALLFILES): $(FILES)
+
+install: $(PROG) $(MAN) $(ALLFILES)
+ $(GINSTALL) -Dm2755 $(PROG) $(DESTDIR)/usr/games/$(PROG)
+ $(GINSTALL) -Dm644 $(MAN) $(DESTDIR)/usr/share/man/man6/$(MAN)
+ $(GINSTALL) -d $(DESTDIR)$(FILESDIR)
+ $(GINSTALL) -Dm$(FILESMODE) $(ALLFILES) $(DESTDIR)$(FILESDIR)
+
+clean:
+ rm -f $(CLEANFILES) $(PROG)
-.include <bsd.prog.mk>
+.PHONY: all clean install