aboutsummaryrefslogblamecommitdiffstats
path: root/src/Makefile
blob: 21ccda9cd0e8a9e1709a3e1ce79e5eb8cdef8684 (plain) (tree)
1
2
3
4
5
6
7
 
                                                

                                     
 
 
                                                       












                                                           

                                                                               












                              
                                            

      
                              


                                



                                                                     

          

                                        

                                   
#
# Copyright (c) 2019-2022, yzrh <yzrh@noema.org>
#
# SPDX-License-Identifier: Apache-2.0
#

src = snake-sdl.c collision.c game.c input.c renderer.c
inc = extern.h game.h input.h renderer.h screen.h version.h

.ifdef GPIO

src += gpio.c
inc += gpio.h

.endif

obj = ${src:.c=.o}

PREFIX = /usr/local

CFLAGS = -O2 -pipe -flto -Wall -Wextra -Wno-unused-result -Wno-unused-parameter
LDFLAGS = -Wl,-O2 -lpthread -lSDL2 -lSDL2_ttf

.ifdef SOUND

LDFLAGS += -lSDL2_mixer

.endif

LDFLAGS += -Wl,--as-needed

CFLAGS += -I/usr/local/include
LDFLAGS += -L/usr/local/lib

all: ${obj} ${inc}
	${CC} ${LDFLAGS} -o snake-sdl ${obj}

clean:
	rm -f snake-sdl ${obj}

install:
	install -d ${PREFIX}/bin
	install -d ${PREFIX}/share/snake-sdl
	install snake-sdl ${PREFIX}/bin
	install -m644 ../contrib/font.ttf ${PREFIX}/share/snake-sdl
	install -m644 ../contrib/music.flac ${PREFIX}/share/snake-sdl

deinstall:
	rm -f ${PREFIX}/bin/snake-sdl
	rm -rf ${PREFIX}/share/snake-sdl

.PHONY: all clean install deinstall