JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
* Makefile: add DESTDIR and use GNU install dir names.
[vor.git] / Makefile
1 #   Variations on Rockdodger
2 #   Copyright (C) 2004  Joshua Grams <josh@qualdan.com>
3
4 #   This program is free software; you can redistribute it and/or modify
5 #   it under the terms of the GNU General Public License as published by
6 #   the Free Software Foundation; either version 2 of the License, or
7 #   (at your option) any later version.
8
9 #   This program is distributed in the hope that it will be useful,
10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 #   GNU General Public License for more details.
13
14 #   You should have received a copy of the GNU General Public License
15 #   along with this program; if not, write to the Free Software
16 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17
18 prefix = /usr
19 exec_prefix = $(prefix)
20
21 datadir = $(prefix)/share/games
22 pkgdatadir = $(datadir)/vor
23 bindir = $(exec_prefix)/games
24
25 CFLAGS := -Wall -O3
26 LDFLAGS := 
27
28 paths := -DDATA_PREFIX=\"$(pkgdatadir)\"
29 sdl-cflags := $(shell sdl-config --cflags)
30 sdl-ldflags := $(shell sdl-config --libs)
31
32 ldflags := $(sdl-ldflags) -lSDL_image -lSDL_mixer $(LDFLAGS)
33 cflags := $(sdl-cflags) $(paths) $(CFLAGS)
34
35 my_objects := args.o dust.o file.o mt.o rocks.o score.o sprite.o sound.o autopilot.o
36 my_objects += main.o
37 libs := font.o
38 objects := $(libs) $(my_objects)
39
40 rocks := 00 01 02 03 04 05 06 07 08 09
41 rocks += 10 11 12 13 14 15 16 17 18 19
42 rocks += 20 21 22 23 24 25 26 27 28 29
43 rocks += 30 31 32 33 34 35 36 37 38 39
44 rocks += 40 41 42 43 44 45 46 47 48 49
45 rocks := $(rocks:%=data/rock%.png)
46 graphics := data/ship.png data/icon.png data/life.png data/font.png $(rocks)
47
48 INSTALL := install
49 INSTALL_PROGRAM := $(INSTALL) $(shell sh -c 'test "$$UID" "=" "0" && echo "-o games -g games"')
50 INSTALL_DATA := $(INSTALL) -m 644
51
52
53 .PHONY: all clean maintainer-clean install uninstall
54 .PHONY: mkinstalldirs rminstalldirs
55 .PHONY: program program-clean install-program uninstall-program
56 .PHONY: data data-clean install-data uninstall-data
57
58 .INTERMEDIATE: font_guts font_guts.pov
59
60 all: program data
61
62 data: $(graphics)
63
64 program: vor
65
66 %.o: %.c
67         @echo compiling $@ from $<
68         @$(CC) $(cflags) -c -o $@ $<
69
70 $(my_objects): config.h
71
72 font.o: font.h
73
74 args.o: args.h
75
76 dust.o: globals.h dust.h float.h mt.h
77
78 file.o: file.h common.h
79
80 main.o: args.h common.h dust.h file.h float.h globals.h mt.h rocks.h score.h sprite.h sound.h autopilot.h
81
82 mt.o: mt.h
83
84 rocks.o: rocks.h common.h file.h globals.h mt.h sprite.h
85
86 score.o: score.h common.h file.h
87
88 sound.o: sound.h args.h common.h
89
90 sprite.o: sprite.h common.h
91
92 vor: $(objects)
93         @echo linking $@ from $^
94         @$(CC) $^ $(ldflags) -o $@
95
96 include gfx.mk
97
98 tags: *.c *.h
99         exuberant-ctags *.c *.h /usr/include/SDL/*
100
101 clean: program-clean
102         rm -f tags
103
104 maintainer-clean: program-clean data-clean
105
106 program-clean:
107         rm -f *.o vor
108
109 data-clean:
110         rm -f $(graphics) font_guts font_guts.pov
111
112 mkinstalldirs:
113         if [ ! -d $(DESTDIR)$(pkgdatadir) ]; then mkdir $(DESTDIR)$(pkgdatadir); fi
114
115 rminstalldirs:
116         if [ -d $(DESTDIR)$(pkgdatadir) ]; then rmdir $(DESTDIR)$(pkgdatadir); fi
117
118 install: all mkinstalldirs install-program install-data
119
120 install-program: program
121         $(INSTALL_PROGRAM) ./vor $(DESTDIR)$(bindir)
122
123 install-data: data
124         $(INSTALL_DATA) ./data/*.png $(DESTDIR)$(pkgdatadir)/
125         $(INSTALL_DATA) ./data/*.wav $(DESTDIR)$(pkgdatadir)/
126         $(INSTALL_DATA) ./data/*.xm $(DESTDIR)$(pkgdatadir)/
127         @echo
128         @echo "$(pkgdatadir)/icon.png (48x48) or ship.png (32x32) make good icons."
129         @echo
130
131 uninstall: uninstall-program uninstall-data rminstalldirs
132
133 uninstall-program:
134         rm -f $(DESTDIR)$(bindir)/vor
135
136 uninstall-data:
137         rm -f $(DESTDIR)$(pkgdatadir)/*.png
138         rm -f $(DESTDIR)$(pkgdatadir)/*.wav
139         rm -f $(DESTDIR)$(pkgdatadir)/*.xm