JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
Refactored Makefile
[vor.git] / Makefile
1 #   Rock Dodger! Avoid the rocks as long as you can!
2 #   Copyright (C) 2001  Paul Holt <pad@pcholt.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 debug := $(if $(DEBUG),1,0)
19 ldflags := $(shell sdl-config --libs) -lSDL_image -lSDL_mixer
20 cflags := $(shell sdl-config --cflags) -Wall -DDEBUG=$(debug) $(CFLAGS)
21
22 my_objects := file.o rocks.o score.o shape.o sound.o main.o $(if $(DEBUG),debug.o)
23 libs := SFont.o
24 objects := $(libs) $(my_objects)
25
26 rocks := 00 01 02 03 04 05 06 07 08 09
27 rocks += 10 11 12 13 14 15 16 17 18 19
28 rocks += 20 21 22 23 24 25 26 27 28 29
29 rocks += 30 31 32 33 34 35 36 37 38 39
30 rocks += 40 41 42 43 44 45 46 47 48 49
31
32 graphics := data/sprites/ship.png data/indicators/life.png $(rocks:%=data/sprites/rock%.png)
33
34 INSTALL = install
35 INSTALL_PROGRAM = $(INSTALL) -o games -g games
36 INSTALL_DATA = $(INSTALL) -m 644
37
38 DATA_PREFIX = /usr/share/vor
39 PROGRAM_PREFIX = /usr/games/bin
40
41
42
43 .PHONY: all clean graphics maintainer-clean install uninstall
44
45 all: graphics vor
46
47 graphics: $(graphics)
48
49 %.o: %.c
50         $(CC) $(cflags) -c -o $@ $<
51
52 $(my_objects): config.h
53
54 main.o file.o: file.h
55
56 vor: $(objects)
57         $(CC) $(ldflags) -o $@ $^ $(LIBRARIES)
58
59 include gfx.mk
60
61 clean:
62         rm -f *.o vor
63
64 maintainer-clean: clean
65         rm -f $(graphics)
66
67 install:        all
68         if [ ! -d $(DATA_PREFIX) ]; then mkdir $(DATA_PREFIX); fi
69         if [ ! -d $(DATA_PREFIX)/banners ]; then mkdir $(DATA_PREFIX)/banners; fi
70         if [ ! -d $(DATA_PREFIX)/fonts ]; then mkdir $(DATA_PREFIX)/fonts; fi
71         if [ ! -d $(DATA_PREFIX)/icons ]; then mkdir $(DATA_PREFIX)/icons; fi
72         if [ ! -d $(DATA_PREFIX)/indicators ]; then mkdir $(DATA_PREFIX)/indicators; fi
73         if [ ! -d $(DATA_PREFIX)/music ]; then mkdir $(DATA_PREFIX)/music; fi
74         if [ ! -d $(DATA_PREFIX)/sounds ]; then mkdir $(DATA_PREFIX)/sounds; fi
75         if [ ! -d $(DATA_PREFIX)/sprites ]; then mkdir $(DATA_PREFIX)/sprites; fi
76
77         $(INSTALL_PROGRAM) ./vor $(PROGRAM_PREFIX)
78         $(INSTALL_DATA) ./data/banners/* $(DATA_PREFIX)/banners/
79         $(INSTALL_DATA) ./data/fonts/* $(DATA_PREFIX)/fonts/
80         $(INSTALL_DATA) ./data/icons/* $(DATA_PREFIX)/icons/
81         $(INSTALL_DATA) ./data/indicators/* $(DATA_PREFIX)/indicators/
82         $(INSTALL_DATA) ./data/music/* $(DATA_PREFIX)/music/
83         $(INSTALL_DATA) ./data/sounds/* $(DATA_PREFIX)/sounds/
84         $(INSTALL_DATA) ./data/sprites/* $(DATA_PREFIX)/sprites/
85         touch $(DATA_PREFIX)/scores
86         chmod a+rw $(DATA_PREFIX)/scores
87
88 uninstall:
89         rm -f $(PROGRAM_PREFIX)/vor
90         rm -f $(DATA_PREFIX)/banners/*
91         rm -f $(DATA_PREFIX)/fonts/*
92         rm -f $(DATA_PREFIX)/icons/*
93         rm -f $(DATA_PREFIX)/indicators/*
94         rm -f $(DATA_PREFIX)/music/*
95         rm -f $(DATA_PREFIX)/sounds/*
96         rm -f $(DATA_PREFIX)/sprites/*
97         rm -f $(DATA_PREFIX)/scores $(DATA_PREFIX)/.highscore
98
99         if [ -d $(DATA_PREFIX)/banners ]; then rmdir $(DATA_PREFIX)/banners; fi
100         if [ -d $(DATA_PREFIX)/fonts ]; then rmdir $(DATA_PREFIX)/fonts; fi
101         if [ -d $(DATA_PREFIX)/icons ]; then rmdir $(DATA_PREFIX)/icons; fi
102         if [ -d $(DATA_PREFIX)/indicators ]; then rmdir $(DATA_PREFIX)/indicators; fi
103         if [ -d $(DATA_PREFIX)/music ]; then rmdir $(DATA_PREFIX)/music; fi
104         if [ -d $(DATA_PREFIX)/sounds ]; then rmdir $(DATA_PREFIX)/sounds; fi
105         if [ -d $(DATA_PREFIX)/sprites ]; then rmdir $(DATA_PREFIX)/sprites; fi
106         if [ -d $(DATA_PREFIX) ]; then rmdir $(DATA_PREFIX); fi