Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve build system, respect CC, CFLAGS, DESTDIR, PREFIX
  • Loading branch information
AMDmi3 committed Apr 9, 2015
1 parent 5dc958f commit 157ff57
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 73 deletions.
56 changes: 37 additions & 19 deletions makefile
@@ -1,27 +1,45 @@
all: griel
PREFIX?= /usr

griel: ./src/main.c ./src/history.c ./src/intro.c ./src/game.c ./src/hud.c ./src/hero.c ./src/loading.c ./src/ending.c
gcc -finline-functions -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize ./src/main.c src/history.c ./src/intro.c ./src/game.c ./src/hud.c ./src/hero.c ./src/loading.c ./src/ending.c -o griels `sdl-config --cflags --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_gfx -lm
CC?= gcc
CFLAGS?= -O2 -finline-functions -funswitch-loops -fpredictive-commoning -fgcse-after-reload -ftree-vectorize

CFLAGS+= `sdl-config --cflags` -DDATADIR="\"$(PREFIX)/share/griels\""
LIBS= `sdl-config --libs` -lSDL_image -lSDL_ttf -lSDL_mixer -lSDL_gfx -lm

PROG= griels
SRCS= src/ending.c \
src/game.c \
src/hero.c \
src/history.c \
src/hud.c \
src/intro.c \
src/loading.c \
src/main.c

all: $(PROG)

$(PROG): $(SRCS)
$(CC) $(CFLAGS) $(SRCS) -o $(PROG) $(LIBS)

clean:
rm -f griels
rm -f $(PROG)

# Installation
install:
cp griels /usr/bin/
cp griels.desktop /usr/share/applications
mkdir -p /usr/share/griels/music
cp ./music/* /usr/share/griels/music
mkdir -p /usr/share/griels/fx
cp ./fx/* /usr/share/griels/fx
mkdir -p /usr/share/griels/data
cp ./data/* /usr/share/griels/data
mkdir -p /usr/share/griels/png
cp ./png/* /usr/share/griels/png
cp ./png/icon.png /usr/share/pixmaps/griels.png
cp $(PROG) $(DESTDIR)$(PREFIX)/bin/
cp griels.desktop $(DESTDIR)$(PREFIX)/share/applications
mkdir -p $(DESTDIR)$(PREFIX)/share/griels/music
cp ./music/* $(DESTDIR)$(PREFIX)/share/griels/music
mkdir -p $(DESTDIR)$(PREFIX)/share/griels/fx
cp ./fx/* $(DESTDIR)$(PREFIX)/share/griels/fx
mkdir -p $(DESTDIR)$(PREFIX)/share/griels/data
cp ./data/* $(DESTDIR)$(PREFIX)/share/griels/data
mkdir -p $(DESTDIR)$(PREFIX)/share/griels/png
cp ./png/* $(DESTDIR)$(PREFIX)/share/griels/png
cp ./png/icon.png $(DESTDIR)$(PREFIX)/share/pixmaps/griels.png

uninstall:
rm /usr/bin/griels
rm /usr/share/applications/griels.desktop
rm /usr/share/pixmaps/griels.png
rm -rf /usr/share/griels
rm $(DESTDIR)$(PREFIX)/bin/$(PROG)
rm $(DESTDIR)$(PREFIX)/share/applications/griels.desktop
rm $(DESTDIR)$(PREFIX)/share/pixmaps/griels.png
rm -rf $(DESTDIR)$(PREFIX)/share/griels
14 changes: 7 additions & 7 deletions src/ending.c
Expand Up @@ -21,23 +21,23 @@ void ending (SDL_Surface *screen, uint *state) {
int framerate = 0;

/* Loading files */
temp = IMG_Load("/usr/share/griels/png/blackbox2.png");
temp = IMG_Load(DATADIR "/png/blackbox2.png");
blackbox = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/ending1.png");
temp = IMG_Load(DATADIR "/png/ending1.png");
ending1 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/ending2.png");
temp = IMG_Load(DATADIR "/png/ending2.png");
ending2 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/ending3.png");
temp = IMG_Load(DATADIR "/png/ending3.png");
ending3 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/theend.png");
temp = IMG_Load(DATADIR "/png/theend.png");
ending4 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
argh = Mix_LoadWAV("/usr/share/griels/fx/fx_uaaah.ogg");
bso = Mix_LoadMUS("/usr/share/griels/music/ending.ogg");
argh = Mix_LoadWAV(DATADIR "/fx/fx_uaaah.ogg");
bso = Mix_LoadMUS(DATADIR "/music/ending.ogg");

SDL_Rect srcending = {0,0,512,448};
SDL_Rect destending = {0,0,512,448};
Expand Down
42 changes: 21 additions & 21 deletions src/game.c
Expand Up @@ -52,60 +52,60 @@ void game (SDL_Surface *screen, uint *state, uint *level) {
uint fullscreench = 0;

/* load files */
temp = IMG_Load("/usr/share/griels/png/round.png");
temp = IMG_Load(DATADIR "/png/round.png");
roundscreen = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/blocks.png");
temp = IMG_Load(DATADIR "/png/blocks.png");
blocks = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/gamehead.png");
temp = IMG_Load(DATADIR "/png/gamehead.png");
headgame = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/fonts.png");
temp = IMG_Load(DATADIR "/png/fonts.png");
fonts = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/blackbox.png");
temp = IMG_Load(DATADIR "/png/blackbox.png");
blackbox = SDL_DisplayFormat(temp);
window = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/gameover.png");
temp = IMG_Load(DATADIR "/png/gameover.png");
gameoverscreen = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw1.png");
temp = IMG_Load(DATADIR "/png/passw1.png");
passscreen01 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw2.png");
temp = IMG_Load(DATADIR "/png/passw2.png");
passscreen02 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw3.png");
temp = IMG_Load(DATADIR "/png/passw3.png");
passscreen03 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw4.png");
temp = IMG_Load(DATADIR "/png/passw4.png");
passscreen04 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw5.png");
temp = IMG_Load(DATADIR "/png/passw5.png");
passscreen05 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw6.png");
temp = IMG_Load(DATADIR "/png/passw6.png");
passscreen06 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw7.png");
temp = IMG_Load(DATADIR "/png/passw7.png");
passscreen07 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw8.png");
temp = IMG_Load(DATADIR "/png/passw8.png");
passscreen08 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw9.png");
temp = IMG_Load(DATADIR "/png/passw9.png");
passscreen09 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/passw10.png");
temp = IMG_Load(DATADIR "/png/passw10.png");
passscreen10 = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
stageclear = Mix_LoadWAV("/usr/share/griels/music/stageclear.ogg");
gameover = Mix_LoadMUS("/usr/share/griels/music/gameover.ogg");
giveup = Mix_LoadWAV("/usr/share/griels/fx/fx_giveup.ogg");
key = Mix_LoadWAV("/usr/share/griels/fx/fx_key.ogg");
kill = Mix_LoadWAV("/usr/share/griels/fx/fx_kill.ogg");
stageclear = Mix_LoadWAV(DATADIR "/music/stageclear.ogg");
gameover = Mix_LoadMUS(DATADIR "/music/gameover.ogg");
giveup = Mix_LoadWAV(DATADIR "/fx/fx_giveup.ogg");
key = Mix_LoadWAV(DATADIR "/fx/fx_key.ogg");
kill = Mix_LoadWAV(DATADIR "/fx/fx_kill.ogg");

/* load map data */
loaddata(map);
Expand Down
12 changes: 6 additions & 6 deletions src/history.c
Expand Up @@ -38,20 +38,20 @@ void history (SDL_Surface *screen, uint *state) {
SDL_Rect destsent4 = {28,168,200,8};

/* Loading files */
temp = IMG_Load("/usr/share/griels/png/blackbox.png");
temp = IMG_Load(DATADIR "/png/blackbox.png");
blackbox = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/blackbox.png");
temp = IMG_Load(DATADIR "/png/blackbox.png");
window = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/howtoplay.png");
temp = IMG_Load(DATADIR "/png/howtoplay.png");
pictures = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/texts.png");
temp = IMG_Load(DATADIR "/png/texts.png");
texts = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
bso = Mix_LoadMUS("/usr/share/griels/music/history.ogg");
lol = Mix_LoadWAV("/usr/share/griels/fx/fx_hahaha.ogg");
bso = Mix_LoadMUS(DATADIR "/music/history.ogg");
lol = Mix_LoadWAV(DATADIR "/fx/fx_hahaha.ogg");

/* Loop */
while (*state == 1) {
Expand Down
28 changes: 14 additions & 14 deletions src/intro.c
Expand Up @@ -24,40 +24,40 @@ void game_intro (SDL_Surface *screen, uint *state, uint *level) {
SDL_Event keystroke;

/* Load files */
temp = IMG_Load("/usr/share/griels/png/blackbox.png");
temp = IMG_Load(DATADIR "/png/blackbox.png");
blackbox = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/karoshi.png");
temp = IMG_Load(DATADIR "/png/karoshi.png");
karoshi = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/blackbox.png");
temp = IMG_Load(DATADIR "/png/blackbox.png");
window = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/startscreen.png");
temp = IMG_Load(DATADIR "/png/startscreen.png");
startscreen = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/startinfo.png");
temp = IMG_Load(DATADIR "/png/startinfo.png");
startinfo = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/blocks.png");
temp = IMG_Load(DATADIR "/png/blocks.png");
blocks = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/menu.png");
temp = IMG_Load(DATADIR "/png/menu.png");
menu = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/fonts.png");
temp = IMG_Load(DATADIR "/png/fonts.png");
arrow = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/password.png");
temp = IMG_Load(DATADIR "/png/password.png");
passwords = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
temp = IMG_Load("/usr/share/griels/png/fonts.png");
temp = IMG_Load(DATADIR "/png/fonts.png");
fonts = SDL_DisplayFormatAlpha(temp);
SDL_FreeSurface(temp);
start = Mix_LoadWAV("/usr/share/griels/fx/fx_start.ogg");
poff = Mix_LoadWAV("/usr/share/griels/fx/fx_poff.ogg");
error = Mix_LoadWAV("/usr/share/griels/fx/fx_error.ogg");
ding = Mix_LoadWAV("/usr/share/griels/fx/fx_ding.ogg");
start = Mix_LoadWAV(DATADIR "/fx/fx_start.ogg");
poff = Mix_LoadWAV(DATADIR "/fx/fx_poff.ogg");
error = Mix_LoadWAV(DATADIR "/fx/fx_error.ogg");
ding = Mix_LoadWAV(DATADIR "/fx/fx_ding.ogg");

SDL_Rect srcscreen = {0,0,256,224};
SDL_Rect destscreen = {0,0,256,224};
Expand Down
12 changes: 6 additions & 6 deletions src/loading.c
Expand Up @@ -7,7 +7,7 @@ void loaddata (int map[][11][16]) {
uint i = 0;
uint j = 0;
uint k = 0;
FILE *datafile = fopen("/usr/share/griels/data/rounds.txt", "r");
FILE *datafile = fopen(DATADIR "/data/rounds.txt", "r");
char line[49];
char temp[3];
temp[2] = 0;
Expand All @@ -33,15 +33,15 @@ void loaddata (int map[][11][16]) {
void load_music(Mix_Music *bsogame, int round) {

if ((round == 0) || (round == 5) || (round == 10) || (round == 15) || (round == 20) || (round == 25) || (round == 30) || (round == 35) || (round == 40) || (round == 45) || (round == 50) || (round == 55))
bsogame = Mix_LoadMUS("/usr/share/griels/music/stage1.ogg");
bsogame = Mix_LoadMUS(DATADIR "/music/stage1.ogg");
if ((round == 1) || (round == 6) || (round == 11) || (round == 16) || (round == 21) || (round == 26) || (round == 31) || (round == 36) || (round == 41) || (round == 46) || (round == 51) || (round == 56))
bsogame = Mix_LoadMUS("/usr/share/griels/music/stage2.ogg");
bsogame = Mix_LoadMUS(DATADIR "/music/stage2.ogg");
if ((round == 2) || (round == 7) || (round == 12) || (round == 17) || (round == 22) || (round == 27) || (round == 32) || (round == 37) || (round == 42) || (round == 47) || (round == 52) || (round == 57))
bsogame = Mix_LoadMUS("/usr/share/griels/music/stage3.ogg");
bsogame = Mix_LoadMUS(DATADIR "/music/stage3.ogg");
if ((round == 3) || (round == 8) || (round == 13) || (round == 18) || (round == 23) || (round == 28) || (round == 33) || (round == 38) || (round == 43) || (round == 48) || (round == 53))
bsogame = Mix_LoadMUS("/usr/share/griels/music/stage4.ogg");
bsogame = Mix_LoadMUS(DATADIR "/music/stage4.ogg");
if ((round == 4) || (round == 9) || (round == 14) || (round == 19) || (round == 24) || (round == 29) || (round == 34) || (round == 39) || (round == 44) || (round == 49) || (round == 54))
bsogame = Mix_LoadMUS("/usr/share/griels/music/stage5.ogg");
bsogame = Mix_LoadMUS(DATADIR "/music/stage5.ogg");

Mix_PlayMusic(bsogame, -1);

Expand Down

0 comments on commit 157ff57

Please sign in to comment.