2015-01-30 17:06:14 +03:00
|
|
|
OBJ = cJSON.o
|
|
|
|
LIBNAME = libcjson
|
|
|
|
TESTS = test
|
|
|
|
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
INCLUDE_PATH ?= include/cjson
|
|
|
|
LIBRARY_PATH ?= lib
|
|
|
|
|
|
|
|
INSTALL_INCLUDE_PATH = $(DESTDIR)$(PREFIX)/$(INCLUDE_PATH)
|
|
|
|
INSTALL_LIBRARY_PATH = $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH)
|
|
|
|
|
|
|
|
INSTALL ?= cp -a
|
|
|
|
|
2015-10-05 20:46:14 +03:00
|
|
|
R_CFLAGS = -fpic $(CFLAGS) -Wall -Werror -Wstrict-prototypes -Wwrite-strings -D_POSIX_C_SOURCE=200112L
|
2015-01-30 17:06:14 +03:00
|
|
|
|
|
|
|
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo false')
|
|
|
|
|
|
|
|
## shared lib
|
|
|
|
DYLIBNAME = $(LIBNAME).so
|
|
|
|
DYLIBCMD = $(CC) -shared -o $(DYLIBNAME)
|
|
|
|
|
|
|
|
## create dynamic (shared) library on Darwin (base OS for MacOSX and IOS)
|
|
|
|
ifeq (Darwin, $(uname_S))
|
|
|
|
DYLIBNAME = $(LIBNAME).dylib
|
|
|
|
## create dyanmic (shared) library on SunOS
|
2016-02-11 15:56:54 +03:00
|
|
|
else ifeq (SunOS, $(uname_S))
|
2015-01-30 17:06:14 +03:00
|
|
|
DYLIBCMD = $(CC) -G -o $(DYLIBNAME)
|
|
|
|
INSTALL = cp -r
|
|
|
|
endif
|
|
|
|
|
|
|
|
## static lib
|
|
|
|
STLIBNAME = $(LIBNAME).a
|
|
|
|
|
|
|
|
.PHONY: all clean install
|
|
|
|
|
|
|
|
all: $(DYLIBNAME) $(STLIBNAME) $(TESTS)
|
|
|
|
|
|
|
|
$(DYLIBNAME): $(OBJ)
|
|
|
|
$(DYLIBCMD) $< $(LDFLAGS)
|
|
|
|
|
|
|
|
$(STLIBNAME): $(OBJ)
|
2016-10-06 23:05:37 +03:00
|
|
|
$(AR) rcs $@ $<
|
2015-01-30 17:06:14 +03:00
|
|
|
|
|
|
|
$(OBJ): cJSON.c cJSON.h
|
|
|
|
|
|
|
|
.c.o:
|
|
|
|
$(CC) -ansi -pedantic -c $(R_CFLAGS) $<
|
|
|
|
|
|
|
|
$(TESTS): cJSON.c cJSON.h test.c
|
|
|
|
$(CC) cJSON.c test.c -o test -lm -I.
|
|
|
|
|
|
|
|
install: $(DYLIBNAME) $(STLIBNAME)
|
|
|
|
mkdir -p $(INSTALL_LIBRARY_PATH) $(INSTALL_INCLUDE_PATH)
|
|
|
|
$(INSTALL) cJSON.h $(INSTALL_INCLUDE_PATH)
|
|
|
|
$(INSTALL) $(DYLIBNAME) $(INSTALL_LIBRARY_PATH)
|
|
|
|
$(INSTALL) $(STLIBNAME) $(INSTALL_LIBRARY_PATH)
|
|
|
|
|
2016-02-11 15:56:54 +03:00
|
|
|
uninstall:
|
|
|
|
rm -rf $(INSTALL_LIBRARY_PATH)/$(DYLIBNAME)
|
|
|
|
rm -rf $(INSTALL_LIBRARY_PATH)/$(STLIBNAME)
|
|
|
|
rm -rf $(INSTALL_INCLUDE_PATH)/cJSON.h
|
|
|
|
|
2015-01-30 17:06:14 +03:00
|
|
|
clean:
|
|
|
|
rm -rf $(DYLIBNAME) $(STLIBNAME) $(TESTS) *.o
|