Merge pull request #17 from flederwiesel/master

Add support for cross-compile and debug build
This commit is contained in:
Bertold Van den Bergh 2019-11-11 11:51:37 +01:00 committed by GitHub
commit a214a3bd13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 5 deletions

3
library/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
libzonedetect.dll
libzonedetect.so
zonedetect.o

View file

@ -27,7 +27,7 @@
CC?=$(CCARCH)gcc
STRIP?=$(CCARCH)strip
CFLAGS=-fPIC -O3 -std=gnu99 -pedantic -Wall -Wextra -Wconversion -Werror -c -fmessage-length=0 -ffunction-sections -fdata-sections
CFLAGS=-fPIC $(if $(DEBUG),-O0 -g,-O3) -std=gnu99 -pedantic -Wall -Wextra -Wconversion -Werror -c -fmessage-length=0 -ffunction-sections -fdata-sections
LDFLAGS=-shared
ifeq ($(OS),Windows_NT)
@ -36,6 +36,10 @@ else
EXT=so
endif
prefix ?= /usr
libdir ?= $(prefix)/lib
includedir ?= $(prefix)/include
EXECUTABLE=libzonedetect.$(EXT)
INCLUDES_SRC=zonedetect.h
SOURCES_SRC=zonedetect.c
@ -43,11 +47,13 @@ SOURCES_SRC=zonedetect.c
OBJECTS_OBJ=$(SOURCES_SRC:.c=.o)
.PHONY: all install clean nice
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS_OBJ)
$(CC) $(LDFLAGS) $(OBJECTS_OBJ) -o $@
$(STRIP) $@
$(if $(DEBUG),,$(STRIP) $@)
obj/%.o: src/%.c $(INCLUDES_SRC)
@ -57,9 +63,12 @@ clean:
rm -rf $(OBJECTS_OBJ) $(EXECUTABLE)
install:
cp zonedetect.h /usr/include/
cp $(EXECUTABLE) /usr/lib/
ldconfig
install -m 0755 -d $(DESTDIR)$(includedir) $(DESTDIR)$(libdir)
install -m 0644 -t $(DESTDIR)$(includedir) zonedetect.h
install -m 0644 -t $(DESTDIR)$(libdir) $(EXECUTABLE)
# Assuming DESTDIR is set for cross-installing only, we don't need
# (and probably do not have) ldconfig
$(if $(DESTDIR),,ldconfig)
nice:
mkdir -p bak/