exchange

Base system with REST service to issue digital coins, run by the payment service provider
Log | Files | Refs | Submodules | README | LICENSE

mustach-original-Makefile (8999B)


      1 # version
      2 MAJOR := 1
      3 MINOR := 2
      4 REVIS := 7
      5 
      6 # installation settings
      7 DESTDIR ?=
      8 PREFIX  ?= /usr/local
      9 BINDIR  ?= $(PREFIX)/bin
     10 LIBDIR  ?= $(PREFIX)/lib
     11 INCLUDEDIR ?= $(PREFIX)/include
     12 MANDIR  ?= $(PREFIX)/share/man
     13 PKGDIR  ?= $(LIBDIR)/pkgconfig
     14 
     15 # Tools (sed must be GNU sed)
     16 SED ?= sed
     17 INSTALL ?= install
     18 
     19 # initial settings
     20 VERSION := $(MAJOR).$(MINOR).$(REVIS)
     21 SOVER := .$(MAJOR)
     22 SOVEREV := .$(MAJOR).$(MINOR)
     23 
     24 HEADERS := mustach.h mustach-wrap.h
     25 SPLITLIB := libmustach-core.so$(SOVEREV)
     26 SPLITPC := libmustach-core.pc
     27 COREOBJS := mustach.o mustach-wrap.o
     28 SINGLEOBJS := $(COREOBJS)
     29 SINGLEFLAGS :=
     30 SINGLELIBS :=
     31 TESTSPECS :=
     32 ALL := manuals
     33 
     34 # availability of CJSON
     35 ifneq ($(cjson),no)
     36  cjson_cflags := $(shell pkg-config --silence-errors --cflags libcjson)
     37  cjson_libs := $(shell pkg-config --silence-errors --libs libcjson)
     38  ifdef cjson_libs
     39   cjson := yes
     40   tool ?= cjson
     41   HEADERS += mustach-cjson.h
     42   SPLITLIB += libmustach-cjson.so$(SOVEREV)
     43   SPLITPC += libmustach-cjson.pc
     44   SINGLEOBJS += mustach-cjson.o
     45   SINGLEFLAGS += ${cjson_cflags}
     46   SINGLELIBS += ${cjson_libs}
     47   TESTSPECS += test-specs/test-specs-cjson
     48  else
     49   ifeq ($(cjson),yes)
     50    $(error Can't find required library cjson)
     51   endif
     52   cjson := no
     53  endif
     54 endif
     55 
     56 # availability of JSON-C
     57 ifneq ($(jsonc),no)
     58  jsonc_cflags := $(shell pkg-config --silence-errors --cflags json-c)
     59  jsonc_libs := $(shell pkg-config --silence-errors --libs json-c)
     60  ifdef jsonc_libs
     61   jsonc := yes
     62   tool ?= jsonc
     63   HEADERS += mustach-json-c.h
     64   SPLITLIB += libmustach-json-c.so$(SOVEREV)
     65   SPLITPC += libmustach-json-c.pc
     66   SINGLEOBJS += mustach-json-c.o
     67   SINGLEFLAGS += ${jsonc_cflags}
     68   SINGLELIBS += ${jsonc_libs}
     69   TESTSPECS += test-specs/test-specs-json-c
     70  else
     71   ifeq ($(jsonc),yes)
     72    $(error Can't find required library json-c)
     73   endif
     74   jsonc := no
     75  endif
     76 endif
     77 
     78 # availability of JANSSON
     79 ifneq ($(jansson),no)
     80  jansson_cflags := $(shell pkg-config --silence-errors --cflags jansson)
     81  jansson_libs := $(shell pkg-config --silence-errors --libs jansson)
     82  ifdef jansson_libs
     83   jansson := yes
     84   tool ?= jansson
     85   HEADERS += mustach-jansson.h
     86   SPLITLIB += libmustach-jansson.so$(SOVEREV)
     87   SPLITPC += libmustach-jansson.pc
     88   SINGLEOBJS += mustach-jansson.o
     89   SINGLEFLAGS += ${jansson_cflags}
     90   SINGLELIBS += ${jansson_libs}
     91   TESTSPECS += test-specs/test-specs-jansson
     92  else
     93   ifeq ($(jansson),yes)
     94    $(error Can't find required library jansson)
     95   endif
     96   jansson := no
     97  endif
     98 endif
     99 
    100 # tool
    101 TOOLOBJS = mustach-tool.o $(COREOBJS)
    102 tool ?= none
    103 ifneq ($(tool),none)
    104   ifeq ($(tool),cjson)
    105     TOOLOBJS += mustach-cjson.o
    106     TOOLFLAGS := ${cjson_cflags} -DTOOL=MUSTACH_TOOL_CJSON
    107     TOOLLIBS := ${cjson_libs}
    108     TOOLDEP := mustach-cjson.h
    109   else ifeq ($(tool),jsonc)
    110     TOOLOBJS += mustach-json-c.o
    111     TOOLFLAGS := ${jsonc_cflags} -DTOOL=MUSTACH_TOOL_JSON_C
    112     TOOLLIBS := ${jsonc_libs}
    113     TOOLDEP := mustach-json-c.h
    114   else ifeq ($(tool),jansson)
    115     TOOLOBJS += mustach-jansson.o
    116     TOOLFLAGS := ${jansson_cflags} -DTOOL=MUSTACH_TOOL_JANSSON
    117     TOOLLIBS := ${jansson_libs}
    118     TOOLDEP := mustach-jansson.h
    119   else
    120    $(error Unknown library $(tool) for tool)
    121   endif
    122   ifneq ($($(tool)),yes)
    123     $(error No library found for tool $(tool))
    124   endif
    125   ALL += mustach
    126 endif
    127 
    128 # compute targets
    129 libs ?= all
    130 ifeq (${libs},split)
    131  ALL += ${SPLITLIB} ${SPLITPC}
    132 else ifeq (${libs},single)
    133  ALL += libmustach.so$(SOVEREV) libmustach.pc
    134 else ifeq (${libs},all)
    135  ALL += libmustach.so$(SOVEREV) libmustach.pc ${SPLITLIB} ${SPLITPC}
    136 else ifneq (${libs},none)
    137  $(error Unknown libs $(libs))
    138 endif
    139 
    140 # display target
    141 $(info tool    = ${tool})
    142 $(info libs    = ${libs})
    143 $(info jsonc   = ${jsonc})
    144 $(info jansson = ${jansson})
    145 $(info cjson   = ${cjson})
    146 
    147 # settings
    148 
    149 EFLAGS = -fPIC -Wall -Wextra -DVERSION=${VERSION}
    150 
    151 ifeq ($(shell uname),Darwin)
    152  LDFLAGS_single  += -install_name $(LIBDIR)/libmustach.so$(SOVEREV)
    153  LDFLAGS_core    += -install_name $(LIBDIR)/libmustach-core.so$(SOVEREV)
    154  LDFLAGS_cjson   += -install_name $(LIBDIR)/libmustach-cjson.so$(SOVEREV)
    155  LDFLAGS_jsonc   += -install_name $(LIBDIR)/libmustach-json-c.so$(SOVEREV)
    156  LDFLAGS_jansson += -install_name $(LIBDIR)/libmustach-jansson.so$(SOVEREV)
    157 else
    158  LDFLAGS_single  += -Wl,-soname,libmustach.so$(SOVER)
    159  LDFLAGS_core    += -Wl,-soname,libmustach-core.so$(SOVER)
    160  LDFLAGS_cjson   += -Wl,-soname,libmustach-cjson.so$(SOVER)
    161  LDFLAGS_jsonc   += -Wl,-soname,libmustach-json-c.so$(SOVER)
    162  LDFLAGS_jansson += -Wl,-soname,libmustach-jansson.so$(SOVER)
    163 endif
    164 
    165 # targets
    166 
    167 .PHONY: all
    168 all: ${ALL}
    169 
    170 mustach: $(TOOLOBJS)
    171 	$(CC) $(LDFLAGS) $(TOOLFLAGS) -o mustach $(TOOLOBJS) $(TOOLLIBS)
    172 
    173 libmustach.so$(SOVEREV): $(SINGLEOBJS)
    174 	$(CC) -shared $(LDFLAGS) $(LDFLAGS_single) -o $@ $^ $(SINGLELIBS)
    175 
    176 libmustach-core.so$(SOVEREV): $(COREOBJS)
    177 	$(CC) -shared $(LDFLAGS) $(LDFLAGS_core) -o $@ $(COREOBJS) $(lib_OBJ)
    178 
    179 libmustach-cjson.so$(SOVEREV): $(COREOBJS) mustach-cjson.o
    180 	$(CC) -shared $(LDFLAGS) $(LDFLAGS_cjson) -o $@ $^ $(cjson_libs)
    181 
    182 libmustach-json-c.so$(SOVEREV): $(COREOBJS) mustach-json-c.o
    183 	$(CC) -shared $(LDFLAGS) $(LDFLAGS_jsonc) -o $@ $^ $(jsonc_libs)
    184 
    185 libmustach-jansson.so$(SOVEREV): $(COREOBJS) mustach-jansson.o
    186 	$(CC) -shared $(LDFLAGS) $(LDFLAGS_jansson) -o $@ $^ $(jansson_libs)
    187 
    188 # pkgconfigs
    189 
    190 %.pc: pkgcfgs
    191 	$(SED) -E '/^==.*==$$/{h;d};x;/==$@==/{x;s/VERSION/$(VERSION)/;p;d};x;d' $< > $@
    192 
    193 # objects
    194 
    195 mustach.o: mustach.c mustach.h
    196 	$(CC) -c $(EFLAGS) $(CFLAGS) -o $@ $<
    197 
    198 mustach-wrap.o: mustach-wrap.c mustach.h mustach-wrap.h
    199 	$(CC) -c $(EFLAGS) $(CFLAGS) -o $@ $<
    200 
    201 mustach-tool.o: mustach-tool.c mustach.h mustach-json-c.h $(TOOLDEP)
    202 	$(CC) -c $(EFLAGS) $(CFLAGS) $(TOOLFLAGS) -o $@ $<
    203 
    204 mustach-cjson.o: mustach-cjson.c mustach.h mustach-wrap.h mustach-cjson.h
    205 	$(CC) -c $(EFLAGS) $(CFLAGS) $(cjson_cflags) -o $@ $<
    206 
    207 mustach-json-c.o: mustach-json-c.c mustach.h mustach-wrap.h mustach-json-c.h
    208 	$(CC) -c $(EFLAGS) $(CFLAGS) $(jsonc_cflags) -o $@ $<
    209 
    210 mustach-jansson.o: mustach-jansson.c mustach.h mustach-wrap.h mustach-jansson.h
    211 	$(CC) -c $(EFLAGS) $(CFLAGS) $(jansson_cflags) -o $@ $<
    212 
    213 # installing
    214 .PHONY: install
    215 install: all
    216 	$(INSTALL) -d $(DESTDIR)$(BINDIR)
    217 	if test "${tool}" != "none"; then \
    218 		$(INSTALL) -m0755 mustach $(DESTDIR)$(BINDIR)/; \
    219 	fi
    220 	$(INSTALL) -d $(DESTDIR)$(INCLUDEDIR)/mustach
    221 	$(INSTALL) -m0644 $(HEADERS)    $(DESTDIR)$(INCLUDEDIR)/mustach
    222 	$(INSTALL) -d $(DESTDIR)$(LIBDIR)
    223 	for x in libmustach*.so$(SOVEREV); do \
    224 		$(INSTALL) -m0755 $$x $(DESTDIR)$(LIBDIR)/ ;\
    225 		ln -sf $$x $(DESTDIR)$(LIBDIR)/$${x%.so.*}.so$(SOVER) ;\
    226 		ln -sf $$x $(DESTDIR)$(LIBDIR)/$${x%.so.*}.so ;\
    227 	done
    228 	$(INSTALL) -d $(DESTDIR)/$(PKGDIR)
    229 	$(INSTALL) -m0644 libmustach*.pc $(DESTDIR)/$(PKGDIR)
    230 	$(INSTALL) -d $(DESTDIR)/$(MANDIR)/man1
    231 	$(INSTALL) -m0644 mustach.1.gz $(DESTDIR)/$(MANDIR)/man1
    232 
    233 # deinstalling
    234 .PHONY: uninstall
    235 uninstall:
    236 	rm -f $(DESTDIR)$(BINDIR)/mustach
    237 	rm -f $(DESTDIR)$(LIBDIR)/libmustach*.so*
    238 	rm -rf $(DESTDIR)$(INCLUDEDIR)/mustach
    239 
    240 .PHONY: test test-basic test-specs
    241 test: basic-tests spec-tests
    242 
    243 basic-tests: mustach
    244 	@$(MAKE) -C test1 test
    245 	@$(MAKE) -C test2 test
    246 	@$(MAKE) -C test3 test
    247 	@$(MAKE) -C test4 test
    248 	@$(MAKE) -C test5 test
    249 	@$(MAKE) -C test6 test
    250 	@$(MAKE) -C test7 test
    251 	@$(MAKE) -C test8 test
    252 
    253 spec-tests: $(TESTSPECS)
    254 
    255 test-specs/test-specs-%: test-specs/%-test-specs test-specs/specs
    256 	./$< test-specs/spec/specs/[a-z]*.json > $@.last || true
    257 	diff $@.ref $@.last
    258 
    259 test-specs/cjson-test-specs.o: test-specs/test-specs.c mustach.h mustach-wrap.h mustach-cjson.h
    260 	$(CC) -I. -c $(EFLAGS) $(CFLAGS) $(cjson_cflags) -DTEST=TEST_CJSON -o $@ $<
    261 
    262 test-specs/cjson-test-specs: test-specs/cjson-test-specs.o mustach-cjson.o $(COREOBJS)
    263 	$(CC) $(LDFLAGS) -o $@ $^ $(cjson_libs)
    264 
    265 test-specs/json-c-test-specs.o: test-specs/test-specs.c mustach.h mustach-wrap.h mustach-json-c.h
    266 	$(CC) -I. -c $(EFLAGS) $(CFLAGS) $(jsonc_cflags) -DTEST=TEST_JSON_C -o $@ $<
    267 
    268 test-specs/json-c-test-specs: test-specs/json-c-test-specs.o mustach-json-c.o $(COREOBJS)
    269 	$(CC) $(LDFLAGS) -o $@ $^ $(jsonc_libs)
    270 
    271 test-specs/jansson-test-specs.o: test-specs/test-specs.c mustach.h mustach-wrap.h mustach-jansson.h
    272 	$(CC) -I. -c $(EFLAGS) $(CFLAGS) $(jansson_cflags) -DTEST=TEST_JANSSON -o $@ $<
    273 
    274 test-specs/jansson-test-specs: test-specs/jansson-test-specs.o mustach-jansson.o $(COREOBJS)
    275 	$(CC) $(LDFLAGS) -o $@ $^ $(jansson_libs)
    276 
    277 .PHONY: test-specs/specs
    278 test-specs/specs:
    279 	if test -d test-specs/spec; then \
    280 		git -C test-specs/spec pull; \
    281 	else \
    282 		git -C test-specs clone https://github.com/mustache/spec.git; \
    283 	fi
    284 
    285 #cleaning
    286 .PHONY: clean
    287 clean:
    288 	rm -f mustach libmustach*.so* *.o *.pc
    289 	rm -f test-specs/*-test-specs test-specs/test-specs-*.last
    290 	rm -rf *.gcno *.gcda coverage.info gcov-latest
    291 	@$(MAKE) -C test1 clean
    292 	@$(MAKE) -C test2 clean
    293 	@$(MAKE) -C test3 clean
    294 	@$(MAKE) -C test4 clean
    295 	@$(MAKE) -C test5 clean
    296 	@$(MAKE) -C test6 clean
    297 	@$(MAKE) -C test7 clean
    298 	@$(MAKE) -C test8 clean
    299 
    300 # manpage
    301 .PHONY: manuals
    302 manuals: mustach.1.gz
    303 
    304 mustach.1.gz: mustach.1.scd
    305 	if which scdoc >/dev/null 2>&1; then scdoc < mustach.1.scd | gzip > mustach.1.gz; fi