bundled-jansson: On OpenSuse Leap libjansson.a was placed in lib64
[asterisk/asterisk.git] / third-party / jansson / Makefile
1 .PHONY: all install clean distclean configure
2
3 .NOTPARALLEL:
4
5 include ../versions.mak
6 export JANSSON_DIR := $(shell pwd -P)
7
8 SPECIAL_TARGETS :=
9
10 ifneq ($(findstring configure,$(MAKECMDGOALS)),)
11 # Run from $(ASTTOPDIR)/configure
12     SPECIAL_TARGETS += configure
13 endif
14
15 ifeq ($(findstring clean,$(MAKECMDGOALS)),clean)
16 # clean or distclean
17     SPECIAL_TARGETS += clean
18 endif
19
20 ifeq ($(findstring uninstall,$(MAKECMDGOALS)),uninstall)
21     SPECIAL_TARGETS += uninstall
22 endif
23
24
25 ifneq ($(wildcard ../../makeopts),)
26     include ../../makeopts
27 endif
28
29 ifeq ($(SPECIAL_TARGETS),)
30 # Run locally or from $(ASTTOPDIR)/Makefile.  All include files should be present
31     ifeq ($(wildcard ../../makeopts),)
32         $(error ASTTOPDIR/configure hasn't been run)
33     endif
34
35     ifeq ($(JANSSON_BUNDLED),yes)
36         ifneq ($(wildcard ../../menuselect.makeopts),)
37             include ../../menuselect.makeopts
38         else
39             $(warning ASTTOPDIR/menuselect hasn't been run yet.  Can't find debug options.)
40         endif
41
42         all: dest/include/jansson.h
43     else
44         all:
45     endif
46 endif
47
48 include ../../Makefile.rules
49 include ../Makefile.rules
50 include Makefile.rules
51
52 ECHO_PREFIX := $(ECHO_PREFIX) echo '[jansson] '
53 SHELL_ECHO_PREFIX := echo '[jansson] '
54
55 dest/include/jansson.h: source/config.status
56         $(ECHO_PREFIX) Building bundled jansson.
57         $(CMD_PREFIX) (cd source; make $(REALLY_QUIET))
58         $(CMD_PREFIX) (cd source; make install DESTDIR= $(REALLY_QUIET))
59
60 .DELETE_ON_ERROR:
61
62 $(DOWNLOAD_DIR)/$(TARBALL_FILE): ../versions.mak
63         $(CMD_PREFIX) ($(TARBALL_EXISTS) && $(TARBALL_VERIFY) && touch $@) || (rm -rf $@ ;\
64         $(TARBALL_DOWNLOAD)) || (rm -rf $@ ;\
65         $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))
66
67 source/.unpacked: $(DOWNLOAD_DIR)/$(TARBALL_FILE)
68         $(CMD_PREFIX) $(TARBALL_VERIFY) || (rm -rf $@ ;\
69         $(SHELL_ECHO_PREFIX) Retrying download ; $(TARBALL_DOWNLOAD))
70         $(ECHO_PREFIX) Unpacking $<
71         -@rm -rf source jansson-*/ >/dev/null 2>&1
72         $(CMD_PREFIX) $(TAR) -xjf $<
73         @mv jansson-$(JANSSON_VERSION) source
74         $(ECHO_PREFIX) Applying patches "$(realpath patches)" "$(realpath .)/source"
75         $(CMD_PREFIX) ../apply_patches $(QUIET_CONFIGURE) "$(realpath patches)" "$(realpath .)/source"
76         -@touch source/.unpacked
77
78 .rebuild_needed: $(wildcard ../../.lastclean)
79         $(ECHO_PREFIX) Rebuilding
80         $(CMD_PREFIX) $(MAKE) clean $(REALLY_QUIET)
81
82 source/config.status: source/.unpacked Makefile.rules .rebuild_needed
83         $(ECHO_PREFIX) Configuring
84         $(CMD_PREFIX) (cd source ; ./configure $(QUIET_CONFIGURE) $(JANSSON_CONFIG_OPTS) --disable-shared \
85                 --enable-static --prefix=$(JANSSON_DIR)/dest --libdir=$(JANSSON_DIR)/dest/lib)
86
87 configure: source/config.status
88
89 install:
90 uninstall:
91
92 clean:
93         $(ECHO_PREFIX) Cleaning
94         +-$(CMD_PREFIX) test -d source dest && $(SUBMAKE) -C source clean || :
95
96 distclean:
97         $(ECHO_PREFIX) Distcleaning
98         -$(CMD_PREFIX) rm -rf source jansson-*.tar.bz2 .rebuild_needed