diff --git a/linux/Makefile b/linux/Makefile new file mode 100644 index 0000000..7acaa98 --- /dev/null +++ b/linux/Makefile @@ -0,0 +1,59 @@ +# Makefile to compile the examples on linux +# make will generate temporary linux compatible cpp files and build them into executables +# +# Tested on Ubuntu 18.04 with: +# sudo apt install libsdl2-dev +# make +# +# (C) 2019 Giampiero Salvi +# LICENSE: GPL 3 + +MAKEFLAGS += --no-builtin-rules +# most programs work with c++11, but OneLoneCoder_Mazes requires 14 for the period definition +CPPFLAGS=-DUNICODE -I/usr/include/SDL2 -I.. -std=c++14 +LDFLAGS= +LDLIBS=-lSDL2 -lpthread + +# Not working yet: +# OneLoneCoder_AR_OpticFlow (missing escapi.h) +# OneLoneCoder_Balls2 (missing function max) +# OneLoneCoder_CaveDiver (imports Windows.h) +# OneLoneCoder_CommandLineFPS (imports Windows.h) +# OneLoneCoder_FlappyBird (imports Windows.h) +# OneLoneCoder_LogitechG13Twitch (winsock2.h) +# OneLoneCoder_LudumDare42 (missing function max) +# OneLoneCoder_olcEngine3D_Part1-4 strange errors, haven't checked +# OneLoneCoder_PanAndZoom (missing to_wstring) +# OneLoneCoder_RacingLines (missing FillTriangle) +# OneLoneCoder_Snake (imports Windows.h) +# OneLoneCoder_Tetris (imports Windows.h) +# OneLoneCoder_Webcam (missing escapi.h) +# worms/OneLoneCoder_Worms1-3 (missing escapi.h) + +# these are working +EXAMPLES= \ + OneLoneCoder_Asteroids \ + OneLoneCoder_Balls1 \ + OneLoneCoder_ComandLineFPS_2 \ + OneLoneCoder_Frogger \ + OneLoneCoder_GameOfLife \ + OneLoneCoder_Matrix \ + OneLoneCoder_Mazes \ + OneLoneCoder_OverEngineered \ + OneLoneCoder_PathFinding_AStar \ + OneLoneCoder_PerlinNoise \ + OneLoneCoder_PlatformGame1 \ + OneLoneCoder_Pseudo3DPlanesMode7 \ + OneLoneCoder_RetroArcadeRacer \ + OneLoneCoder_Splines1 \ + OneLoneCoder_Splines2 \ + OneLoneCoder_SpriteEditor + +all: $(EXAMPLES) + +%_linux.cpp: ../%.cpp + cat $< | sed 's/olcConsoleGameEngine.h/olcConsoleGameEngineSDL.h/g' | sed 's/VK_SHIFT/VK_LSHIFT/g' | sed 's/VK_CONTROL/VK_LCONTROL/g' > $@ + +%: %_linux.cpp + g++ $< $(CPPFLAGS) -o $@ $(LDLIBS) + diff --git a/linux/README.md b/linux/README.md new file mode 100644 index 0000000..e9f7f19 --- /dev/null +++ b/linux/README.md @@ -0,0 +1,19 @@ +# Linux Makefile +This is a Makefile to build the examples in this repository on GNU Linux. It has been tested on Ubuntu 18.04. Running make will create temporary cpp files from the original files, that have been modified to work with Linux. Main differences are using `olcConsoleGameEngineSDL.h` instead of `olcConsoleGameEngine.h` and substituting the `VK_SHIFT` and `VK_CONTROL` flags. Look at the Makefile to know which programs will not build, yet, and why. + +## Dependencies +Install the development files for the SDL library: +``` +sudo apt install libsdl2-dev +``` + +## Build +``` +make +``` +## Run +You need to run the programs from the top directory of the repository in order to find the additional files, such as sprites, for example: +``` +cd .. +linux/OneLoneCoder_Asteroids +```