Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makefile for Linux #26

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions linux/Makefile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
# 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)

19 changes: 19 additions & 0 deletions linux/README.md
Original file line number Diff line number Diff line change
@@ -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
```