diff --git a/.gitignore b/.gitignore index 1aaf59c6765446226bd247bb02966a4993720fd6..0d333f684c33d9f4916cefd3730b9ad482ee9489 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 0000000000000000000000000000000000000000..b2992bcd27b4b8d4665b1604502a5317cf460693 --- /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 c079fbb7d3d3fc59f2320628cf38db89df783994..eeb1c4c82b99d93a80ccaf21dcde91b45ad60d03 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 62a0e338d7dcac82956d9e201a6c08b296d83a95..6462cd3e2bb99a19677405ef6c3287c1a40676fb 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) {