-# $NetBSD: Makefile,v 1.10 1996/10/18 02:43:36 thorpej Exp $
+# $NetBSD: Makefile,v 1.30 2011/08/16 10:14:40 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= atc
-CFLAGS+=-DBSD -I${.CURDIR} -I.
-SRCS= extern.c grammar.c graphics.c input.c lex.c list.c log.c \
+SRCS= extern.c graphics.c input.c list.c log.c \
main.c tunable.c update.c
MAN= atc.6
-LDADD= -ll -lm -lcurses -ltermcap
-DPADD= ${LIBL} ${LIBM} ${LIBTERM} ${LIBCURSES}
-GAMES= ATC_scores Game_List Killer crossover default easy game_2 \
- Atlantis OHare Tic-Tac-Toe airports box crosshatch game_3 \
- game_4 novice two-corners
-CLEANFILES=grammar.c y.tab.h lex.c
-HIDEGAME=hidegame
+FILES=${GAMES:S@^@${.CURDIR}/games/@g}
+FILESDIR=$(PREFIX)/share/games/atc
+FILESMODE=644
-beforeinstall:
- @if [ ! -d ${DESTDIR}/usr/share/games/atc ]; then \
- /bin/rm -f ${DESTDIR}/usr/share/games/atc ; \
- mkdir -p ${DESTDIR}/usr/share/games/atc ; \
- chown root.wheel ${DESTDIR}/usr/share/games/atc ; \
- chmod 755 ${DESTDIR}/usr/share/games/atc ; \
- else \
- true ; \
- fi
- (cd ${.CURDIR}/games; ${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 400 \
- ${GAMES} ${DESTDIR}/usr/share/games/atc)
+all: $(PROG)
-.include <bsd.prog.mk>
+$(PROG): $(SRCS) grammar.y lex.l
+ yacc -d grammar.y -o grammar.c
+ lex lex.l
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $(PROG) $(SRCS) grammar.c lex.yy.c -lncursesw $(LIBFLA) -I$(ROOT)
+ $(STRIP) $(PROG)
+
+install: $(PROG) $(MAN)
+ $(GINSTALL) -Dm2755 $(PROG) $(DESTDIR)/$(PREFIX)/games/$(PROG)
+ $(GINSTALL) -Dm644 $(MAN) $(DESTDIR)/$(PREFIX)/share/man/man6/$(MAN)
+ mkdir -p $(DESTDIR)/$(PREFIX)/share/games
+ cp -r games $(DESTDIR)/$(PREFIX)/share/games/atc
+ chmod -R 644 $(DESTDIR)/$(PREFIX)/share/games/atc/*
+ mkdir -p $(DESTDIR)/$(LOCALSTATEDIR)/games/
+
+
+clean:
+ rm -f $(CLEANFILES) $(PROG) grammar.c grammar.h lex.yy.c
+
+.PHONY: all clean install