Skip to content

Commit

Permalink
Clean the OSX build
Browse files Browse the repository at this point in the history
  • Loading branch information
niess committed Mar 19, 2020
1 parent 8b9315d commit 1e150f3
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Default compilation flags
CFLAGS := -O3 -std=c99 -pedantic -Wall
LIBS := -lm
INCLUDES := -Iinclude -Isrc
CFLAGS = -O3 -std=c99 -pedantic -Wall
LIBS = -lm
INCLUDES = -Iinclude -Isrc

OBJS := build/client.o build/ecef.o build/error.o build/io.o build/list.o \
OBJS = build/client.o build/ecef.o build/error.o build/io.o build/list.o \
build/map.o build/projection.o build/stack.o build/stepper.o \
build/tinydir.o

SOEXT = so
SYS = $(shell uname -s)
ifeq ($(SYS), Darwin)
SOEXT = dylib
endif

# Flag for GEOTIFF files
TURTLE_USE_TIFF := 1
ifeq ($(TURTLE_USE_TIFF), 1)
Expand Down Expand Up @@ -55,11 +61,18 @@ endif


# Rules for building the library
lib: lib/libturtle.so
lib: lib/libturtle.$(SOEXT)

SHARED = -shared
RPATH = '-Wl,-rpath,$$ORIGIN/../lib'
ifeq ($(SYS), Darwin)
SHARED = -dynamiclib -Wl,-install_name,@rpath/libturtle.$(SOEXT)
RPATH = -Wl,-rpath,@loader_path/../lib
endif

lib/libturtle.so: $(OBJS)
lib/libturtle.$(SOEXT): $(OBJS)
@mkdir -p lib
@gcc -o $@ $(LDFLAGS) -shared $(INCLUDES) $(OBJS) $(LIBS)
@gcc -o $@ $(LDFLAGS) $(SHARED) $(INCLUDES) $(OBJS) $(LIBS)

build/%.o: src/turtle/%.c src/turtle/%.h
@mkdir -p build
Expand All @@ -85,14 +98,14 @@ build/%.o: src/deps/%.c src/deps/%.h
examples: bin/example-demo bin/example-projection bin/example-pthread \
bin/example-stepper

bin/example-pthread: examples/example-pthread.c lib/libturtle.so
bin/example-pthread: examples/example-pthread.c lib/libturtle.$(SOEXT)
@mkdir -p bin
@gcc -o $@ $(CFLAGS) -Iinclude $< -Llib -Wl,-rpath $(PWD)/lib -lturtle \
@gcc -o $@ $(CFLAGS) -Iinclude $< -Llib $(RPATH) -lturtle \
-lpthread

bin/example-%: examples/example-%.c lib/libturtle.so
bin/example-%: examples/example-%.c lib/libturtle.$(SOEXT)
@mkdir -p bin
@gcc -o $@ $(CFLAGS) -Iinclude $< -Llib -Wl,-rpath $(PWD)/lib -lturtle
@gcc -o $@ $(CFLAGS) -Iinclude $< -Llib $(RPATH) -lturtle


# Rules for installing `libcheck` locally
Expand Down

0 comments on commit 1e150f3

Please sign in to comment.