From 6e05673770ecd83ffc037e41580dbc9cd5ae347e Mon Sep 17 00:00:00 2001 From: Benedict Gaster <benedict.gaster@gmail.com> Date: Mon, 30 Nov 2020 16:23:24 +0000 Subject: [PATCH] Added a rough makefile for OSX --- .gitignore | 3 ++- Makefile | 60 +++++++++++++++++++++++++++++++++++++++++++++ README.md | 16 ++++++++++++ examples/shapes.cpp | 2 -- 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 Makefile diff --git a/.gitignore b/.gitignore index 1aaf59c..0d333f6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ a.out html latex -*.o \ No newline at end of file +*.o +build \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b2992bc --- /dev/null +++ b/Makefile @@ -0,0 +1,60 @@ +CC = clang++ +LD = clang++ +CPPFLAGS = -std=c++17 -I./osx/include/ -I./osx/include/SDL2/ -I./include +CFLAGS = -I./osx/include/ -I./osx/include/SDL2/ -I./include +LDFLAGS = -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL + +ROOTDIR = ./ + +LIBDIR=S(ROOTDIR)/osx/lib + +CP = cp +ECHO = echo + +BUILD_DIR = build + +C_SOURCES = src/SDL_FontCache.c +CPP_SOURCES = src/app.cpp src.cpp/context.cpp + +OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(CPP_SOURCES:.cpp=.o))) +vpath %.cpp $(sort $(dir $(CPP_SOURCES))) +vpath %.cpp examples + +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)/splat: $(OBJECTS) $(BUILD_DIR)/splat.o Makefile + $(ECHO) linking $< + $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/splat.o + # $(CC)Â $(LDFLAGS) -o $@ $(OBJECTS) $(BUILD_DIR)/splat.o + $(ECHO) success + +$(BUILD_DIR)/shapes: $(OBJECTS) $(BUILD_DIR)/shapes.o Makefile + $(ECHO) linking $< + $(CC) -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -framework OpenGL -o $@ $(OBJECTS) build/shapes.o + # $(CC)Â $(LDFLAGS) -o $@ $(OBJECTS) $(BUILD_DIR)/splat.o + $(ECHO) success + +####################################### +# clean up +####################################### +clean: + -rm -fR .dep $(BUILD_DIR) + +####################################### +# dependencies +####################################### +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +.PHONY: clean all \ No newline at end of file diff --git a/README.md b/README.md index c079fbb..eeb1c4c 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,21 @@ # OSX +To build the examples simple run: + +``` +make +``` + +Then you can run: + +``` +build/shapes +``` + +``` +build/splat +``` + clang++ -std=c++17 -L./osx/lib/ -lSDL2 -lSDL2_ttf -lSDL2_image -lfreetype -lpng -lwebp -ltiff -ljpeg -lbz2 -lz -I./osx/include/ -I./osx/include/SDL2/ -I./include ./SDL_FontCache.o src/context.cpp src/app.cpp examples/splat.cpp -framework OpenGL We need to build font cache diff --git a/examples/shapes.cpp b/examples/shapes.cpp index 62a0e33..6462cd3 100644 --- a/examples/shapes.cpp +++ b/examples/shapes.cpp @@ -84,8 +84,6 @@ void MyApp::draw() { int height; get_image_size(some_text_, &width, &height); draw_image(some_text_, uwe::make_rect(0,0, width, height), uwe::make_rect(150,30, width, height) ); - - } uwe::Image MyApp::render_text(std::string msg) { -- GitLab