code duplication
[netris.git] / Makefile
1 # Netris Makefile
2
3 include config.mak
4
5 VERSION = ?
6
7 PROG = netris
8 SPROG = netrisserver
9 HEADERS = netris.h
10
11 SRCS = client.c curses.c board.c util.c inet.c
12 SSRCS = server.c util.c
13
14 OBJS = $(SRCS:.c=.o)
15 SOBJS = $(SSRCS:.c=.o)
16
17 DISTFILES = README FAQ INSTALL COPYING TODO CHANGES \
18         configure Makefile netris.h \
19         $(SRCS) server.c \
20
21 all: config.h $(PROG) $(SPROG)
22
23 msg.h: msg.en.h $(MSG_FILE)
24         @echo "Linking $(MSG_FILE) to msg.h"
25         @echo '// WARNING! This is a generated file. Do NOT edit.' > msg.h
26         @echo '// See msg.*.h for the editable files.' >> msg.h
27         @echo '#include "$(MSG_FILE)"' >> msg.h
28
29 ifneq ($(MSG_FILE),msg.en.h)
30         @echo "Adding untranslated messages to msg.h"
31         @echo '// untranslated messages from the English master file:' >> msg.h
32         @./msg_diff.sh $(MSG_FILE) < msg.en.h >> msg.h
33 endif
34
35 $(PROG): msg.h $(OBJS)
36         $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
37
38 $(SPROG): msg.h $(SOBJS)
39         $(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS)
40
41 .c.o:
42         $(CC) $(CFLAGS) -c $<
43
44 config.h: configure
45         @echo "Makefile and/or config.h is out of date"
46         @echo "Run ./configure now"
47         @false
48
49 dist: $(DISTFILES)
50         @dir="netris-$(VERSION)"; \
51         echo "Creating $$dir directory"; \
52         rm -rf $$dir; \
53         mkdir $$dir; \
54         cp $(DISTFILES) $$dir; \
55         chmod 755 $$dir; \
56         chmod 644 $$dir/*; \
57         chmod 755 $$dir/configure; \
58         echo "Creating $$dir.tar.gz"; \
59         tar -cvzof $$dir.tar.gz $$dir
60
61 clean:
62         rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) msg.h a.out
63
64 cleandir: clean
65         rm -f config.mak config.h
66