Skip to content

Commit

Permalink
Simplify the dependencies and clean the README
Browse files Browse the repository at this point in the history
  • Loading branch information
niess committed Aug 20, 2018
1 parent 67bbb8b commit bb2223c
Show file tree
Hide file tree
Showing 13 changed files with 1,247 additions and 60 deletions.
12 changes: 3 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Ignore any library object.
lib
*.so

# Ignore any binaries.
*.o
# Ignore library and binaries
bin

# Ignore examples output.
*.png
build
lib

# Ignore shared data
share
Expand Down
6 changes: 0 additions & 6 deletions .gitmodules

This file was deleted.

42 changes: 22 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
# Default compilation flags
DEPS_DIR := deps

CFLAGS := -O2 -std=c99 -pedantic -Wall -fPIC -Wfatal-errors
CFLAGS := -O3 -std=c99 -pedantic -Wall -fPIC
LIBS := -lm
OBJS := client.o ecef.o error.o io.o map.o projection.o stack.o stepper.o \
turtle.o
INCLUDES := -Iinclude -Isrc -I$(DEPS_DIR)/tinydir
INCLUDES := -Iinclude -Isrc

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

# Flag for GEOTIFF files
TURTLE_USE_TIFF := 1
ifeq ($(TURTLE_USE_TIFF), 1)
LIBS += -ltiff
OBJS += geotiff16.o
OBJS += build/geotiff16.o
else
CFLAGS += -DTURTLE_NO_TIFF
endif

# Flag for GRD files
TURTLE_USE_GRD := 1
ifeq ($(TURTLE_USE_GRD), 1)
OBJS += grd.o
OBJS += build/grd.o
else
CFLAGS += -DTURTLE_NO_GRD
endif

# Flag for HGT files
TURTLE_USE_HGT := 1
ifeq ($(TURTLE_USE_HGT), 1)
OBJS += hgt.o
OBJS += build/hgt.o
else
CFLAGS += -DTURTLE_NO_HGT
endif
Expand All @@ -38,36 +37,39 @@ ifeq ($(TURTLE_USE_PNG), 1)
PACKAGE := libpng
CFLAGS += $(shell pkg-config --cflags $(PACKAGE))
LIBS += $(shell pkg-config --libs $(PACKAGE))
OBJS += jsmn.o png16.o
INCLUDES += -I$(DEPS_DIR)/jsmn
OBJS += build/jsmn.o build/png16.o
else
CFLAGS += -DTURTLE_NO_PNG
endif

# Available builds.
# Available builds
.PHONY: lib clean examples

# Rules for building the library.
# Rules for building the library
lib: lib/libturtle.so
@rm -f *.o

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

%.o: src/turtle/%.c src/turtle/%.h
build/%.o: src/turtle/%.c src/turtle/%.h
@mkdir -p build
@gcc $(CFLAGS) $(INCLUDES) -o $@ -c $<

%.o: src/turtle/%.c
build/%.o: src/turtle/%.c
@mkdir -p build
@gcc $(CFLAGS) $(INCLUDES) -o $@ -c $<

%.o: src/turtle/io/%.c
build/%.o: src/turtle/io/%.c
@mkdir -p build
@gcc $(CFLAGS) $(INCLUDES) -o $@ -c $<

%.o: src/%.c include/%.h
build/%.o: src/%.c include/%.h
@mkdir -p build
@gcc $(CFLAGS) $(INCLUDES) -o $@ -c $<

%.o: $(DEPS_DIR)/jsmn/%.c $(DEPS_DIR)/jsmn/%.h
build/%.o: src/deps/%.c src/deps/%.h
@mkdir -p build
@gcc $(CFLAGS) -o $@ -c $<

# Rules for building the examples
Expand All @@ -85,4 +87,4 @@ bin/example-%: examples/example-%.c

# Clean-up rule
clean:
@rm -rf bin lib *.o
@rm -rf bin lib build
35 changes: 18 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ and dumped in **PNG**, enriched with a custom header (as a `tEXt` chunk).

## Installation

Currently there is no automatic build procedure. If on a Linux box you might
try and adapt the provided `Makefile`. The source code conforms to C99. For
loading or dumping **DEM**s, you will need the following libraries and packages:
Currently the TURTLE library only supports Linux systems. An example of
[`Makefile`](Makefile) is shipped with the sources. The following should
build TURTLE (as a shared library: `libturtle.so`) and the examples:
```bash
make && make examples
```

* **libpng** and [JSMN][JSMN] for local maps.
* **libtiff** for geotiff data, e.g. [ASTER-GDEM2](https://asterweb.jpl.nasa.gov/gdem.asp)
or [GEBCO](http://www.gebco.net/).
* [TinyDir][TinyDir] for OS independent directories management.
Note that the TURTLE source code conforms to C99 and has little dependencies
except on the C89 standard library. Note however that for loading or dumping
**DEM**s, you might also need the following external libraries:

Note that build options allow to disable either or both of PNG or TIFF formats,
and their dependencies, if not needed.
* **libpng** for custom TURTLE dumps.
* **libtiff** for loading GEOTIFF data, e.g.
[ASTER-GDEM2](https://asterweb.jpl.nasa.gov/gdem.asp) or
[GEBCO](http://www.gebco.net/).

Note also that while **libpng** and **libtiff** are expected to be installed
on your system, you can directly get [JSMN][JSMN] and [TinyDir][TinyDir] as
submodules, e.g. using `git clone --recursive`.

[JSMN]: https://github.com/zserge/jsmn
[TinyDIr]: https://github.com/cxong/tinydir
Build options in the Makefile allow to disable either or both of PNG or TIFF
formats, and their dependencies, if not needed.

## Documentation

Expand All @@ -54,5 +54,6 @@ You might directly check the [examples](examples) as well.
## License

The TURTLE library is under the **GNU LGPLv3** license. See the provided
`LICENSE` and `COPYING.LESSER` files. The [examples](examples) however have a
separate public domain license allowing them to be copied without restrictions.
[`LICENSE`](LICENSE) and [`COPYING.LESSER`](COPYING.LESSER) files. The
[examples](examples) however have a separate public domain license allowing
them to be copied without restrictions.
1 change: 0 additions & 1 deletion deps/jsmn
Submodule jsmn deleted from 350865
1 change: 0 additions & 1 deletion deps/tinydir
Submodule tinydir deleted from 9c6c5d
Loading

0 comments on commit bb2223c

Please sign in to comment.