Skip to content
Snippets Groups Projects
Commit 936c2478 authored by Benedict Gaster's avatar Benedict Gaster
Browse files

Linux support

parent a85e8e9e
No related branches found
No related tags found
No related merge requests found
CC = clang++
LD = clang++
CPPFLAGS = -std=c++17 -I./include -I/usr/include/ -I/usr/include/SDL2 -D_THREAD_SAFE
CFLAGS = -I./include -I/usr/include/ -D_THREAD_SAFE -I/usr/include/SDL2
LDFLAGS = -L/usr/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL
ROOTDIR = ./
CP = cp
ECHO = echo
BUILD_DIR = build
C_SOURCES = src/SDL_FontCache.c
CPP_SOURCES = src/app.cpp src/context.cpp
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o)))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
vpath %.cpp examples
vpath %.cpp assignment
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
$(ECHO) compiling $<
$(CC) -c $(CPPFLAGS) $< -o $@
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
$(ECHO) compiling $<
clang -c $(CFLAGS) $< -o $@
all: $(BUILD_DIR)/splat $(BUILD_DIR)/shapes $(BUILD_DIR)/sprite $(BUILD_DIR)/assignment
$(BUILD_DIR)/splat: $(OBJECTS) $(BUILD_DIR)/splat.o Makefile
$(ECHO) linking $<
$(CC) -L/usr/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -ltiff -ljpeg -lbz2 -lz -o $@ $(OBJECTS) build/splat.o
$(ECHO) success
$(BUILD_DIR)/shapes: $(OBJECTS) $(BUILD_DIR)/shapes.o Makefile
$(ECHO) linking $<
$(CC) -L/usr/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -ltiff -ljpeg -lbz2 -lz -o $@ $(OBJECTS) build/shapes.o
$(ECHO) success
$(BUILD_DIR)/sprite: $(OBJECTS) $(BUILD_DIR)/sprite.o Makefile
$(ECHO) linking $<
$(CC) -L/usr/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -ltiff -ljpeg -lbz2 -lz -o $@ $(OBJECTS) build/sprite.o
$(ECHO) success
$(BUILD_DIR)/assignment: $(OBJECTS) $(BUILD_DIR)/assignment.o Makefile
$(ECHO) linking $<
$(CC) -L/usr/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -ltiff -ljpeg -lbz2 -lz -o $@ $(OBJECTS) build/assignment.o
$(ECHO) success
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)/assignment $(BUILD_DIR)/sprite $(BUILD_DIR)/shapes $(BUILD_DIR)/splat $(BUILD_DIR)/*.o
#######################################
# dependencies
#######################################
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
.PHONY: clean all
...@@ -127,6 +127,45 @@ To run an example or the assigment, simply run the command, e.g. **./shapes.exe* ...@@ -127,6 +127,45 @@ To run an example or the assigment, simply run the command, e.g. **./shapes.exe*
in the same directory. (Note: it is important that you run the executables in the in the same directory. (Note: it is important that you run the executables in the
**window_build** directory.) **window_build** directory.)
## Linux
For Linux you need to first install the packages
> sudo apt install libsdl2-dev
> sudo apt install libsdl2-image-dev
> sudo apt install libsdl2-ttf-dev
> sudo apt install libfreetype6-dev
> sudo apt install libtiff-dev
> sudo apt install libbz2-dev
To make it slightly easier to build both the examples and the assigment itself a Makefile is provided:
- **Makefile_linux**
To build run the command:
```bash
make -f Makefile_linux
```
in the root directory. This will build the resulting
executables in the directory **build**. **build** will
contain the example executables:
```bash
./build/shapes
./build/splat
./build/sprite
```
and for the assigment:
```bash
./build/assignment
```
To run an example or the assigment, simply run the executable from the root directory, e.g. **./build/shapes**.
## OS X ## OS X
> Note: ARM based Macs (M1 or M2) > Note: ARM based Macs (M1 or M2)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment