diff --git a/Makefile_linux b/Makefile_linux new file mode 100644 index 0000000000000000000000000000000000000000..aba995c56267550797957f84f876b8ca4a8aced6 --- /dev/null +++ b/Makefile_linux @@ -0,0 +1,66 @@ +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 diff --git a/README.md b/README.md index 13bd379aeea903e24059235cf1f7d6f2e070b491..c8a862cf1b709951181785111709af3fe53185fb 100644 --- a/README.md +++ b/README.md @@ -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 **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 > Note: ARM based Macs (M1 or M2)