-host_phantglobs.o: ${.CURDIR}/phantglobs.c
- ${HOST_COMPILE.c} -o host_phantglobs.o ${.CURDIR}/phantglobs.c
-
-setup.o: ${.CURDIR}/setup.c
- ${HOST_COMPILE.c} ${.CURDIR}/setup.c
-
-afterinstall:
- ./setup -m ${.CURDIR}/monsters.asc
- chown games:games ${DESTDIR}/var/games/phantasia/*
+FILESDIR=/var/games/phantasia
+FILESOWN=games
+FILESGRP=games
+FILESMODE=0660
+ALLFILES=gold lastdead mess monsters void motd characs scoreboard
+FILES=gold lastdead mess monsters void motd
+# don't overwrite existing characters or scorefile
+.for file in characs scoreboard
+.if !exists(${DESTDIR}${FILESDIR}/${file})
+FILES+=${file}
+.endif
+.endfor
+
+CLEANFILES+=map mkdata setup.lo host_phantglobs.lo ${ALLFILES} files.stamp
+
+realall: ${FILES}
+
+${FILES}: files.stamp
+files.stamp: mkdata monsters.asc
+ ${_MKMSG_CREATE} ${FILES}
+ rm -f ${.TARGET}
+ ./mkdata -m ${.CURDIR}/monsters.asc
+ touch ${.TARGET}
+
+mkdata: host_phantglobs.lo setup.lo ${LIBM}
+ ${_MKTARGET_LINK}
+ ${HOST_LINK.c} -o ${.TARGET} ${.ALLSRC:M*.lo} -lm
+
+BUILDSYMLINKS+= phantglobs.c host_phantglobs.c
+HOST_CPPFLAGS+= -I${.CURDIR}