41 lines
1.1 KiB
Makefile
41 lines
1.1 KiB
Makefile
.PHONY: build/exe
|
|
SDL_FLAGS=`pkg-config sdl2 SDL2_image --cflags --libs`
|
|
FLAGS=-pthread -std=c++11 $(SDL_FLAGS) -Wall -Wextra
|
|
CC=g++ $(FLAGS)
|
|
CC_STATIC=$(CC) -fPIC
|
|
CC_SHARED=g++ -shared
|
|
CUR_DIR=$(shell pwd)
|
|
|
|
# get list of '.o' files to be generated for 'build/include/libxsdl.so' target
|
|
XSDL_O_FILES=$(shell ls -l xSDL/*.cpp | awk '{print $$NF}' | sed 's/^xSDL\/\(.\+\)\.cpp$$/build\/static\/\1.o/g')
|
|
|
|
prepare:
|
|
test -d build/ || mkdir build/
|
|
test -d build/static || mkdir build/static
|
|
test -d build/include || mkdir build/include
|
|
|
|
clean:
|
|
test -d build/ && rm -r build/ || true
|
|
|
|
run:
|
|
LD_LIBRARY_PATH="$(CUR_DIR)/build/include/:$LD_LIBRARY_PATH" ./build/exe;
|
|
|
|
# build executable
|
|
build/exe: build/main.o build/include/libxsdl.so
|
|
$(CC) -L$(CUR_DIR)/build/include/ -o $@ $< -lxsdl
|
|
|
|
# xSDL lib static objects
|
|
build/static/%.o: xSDL/%.cpp
|
|
$(CC_STATIC) -c $^ -o $@
|
|
|
|
# xSDL shared (dynamic) library
|
|
build/include/libxsdl.so: $(XSDL_O_FILES)
|
|
$(CC_SHARED) -Wl,-soname,libxsdl.so -o $@ $^
|
|
|
|
# xMario lib
|
|
build/xMario.o: xMario/*.cpp
|
|
$(CC) -o $@ $^
|
|
|
|
# build main
|
|
build/main.o: main.cpp
|
|
$(CC) -o $@ -c $^
|