From: Felix Fietkau Date: Fri, 3 Dec 2010 18:16:10 +0000 (+0100) Subject: compile a subset on darwin X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=56086cf6974cb9aeda74158d9a4c1eccc5ad9ece;p=project%2Flibubox.git compile a subset on darwin --- diff --git a/.gitignore b/.gitignore index 140f8cf..9784b6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.so +*.dylib diff --git a/Makefile b/Makefile index 8af237d..3c0399a 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,23 @@ INCLUDE_DIR=$(PREFIX)/include/libubox LIBDIR=$(PREFIX)/lib CPPFLAGS= -all: libubox.so +OS=$(shell uname) +FILES=blob.c blobmsg.c hash.c uhtbl.c +ifeq ($(OS),Linux) + FILES += ucix.c usock.c uloop.c unl.c + LIBS += -luci $(LIBNL) + LDFLAGS_SHARED=-shared -Wl,-soname,$@ + SHLIB_EXT=so +endif +ifeq ($(OS),Darwin) + LDFLAGS_SHARED=-dynamiclib + SHLIB_EXT=dylib +endif -libubox.so: ucix.c blob.c blobmsg.c hash.c uhtbl.c usock.c uloop.c unl.c - $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -shared -Wl,-soname,libubox.so $^ $(LDFLAGS) -luci $(LIBNL) +all: libubox.$(SHLIB_EXT) + +libubox.$(SHLIB_EXT): $(FILES) + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $^ $(LDFLAGS) $(LIBS) $(LDFLAGS_SHARED) install-headers: mkdir -p $(INCLUDE_DIR) @@ -19,10 +32,10 @@ install-headers: install-lib: mkdir -p $(LIBDIR) - cp libubox.so $(LIBDIR)/ + cp libubox.$(SHLIB_EXT) $(LIBDIR)/ install: install-lib install-headers clean: - rm -f *.so + rm -f *.$(SHLIB_EXT)