fix new battery plugin to work better with multiple batteries present
[wmiirc-lua.git] / Makefile.ext
blobcc173948882224519aee91c1a983464b0a62e250
1 # ------------------------------------------------------------------------
2 # local variable overrides
4 EXT_DIR = ext
6 PWD     = $(shell pwd)
8 CCPIC   = cc -c -fPIC
10 # ------------------------------------------------------------------------
11 # help
13 .PHONY: ext-help
14 ext-help:
15         @echo " extra packages"
16         @echo "   ext              - build all extra packages"
17         @echo "   ext-install      - install extra packages in system dir"
18         @echo "   ext-install-user - install extra packages in user home dir"
19         @echo "   ext-check        - check if sources are uptodate"
20         @echo "   ext-update       - update everything from git submodules"
22 # ------------------------------------------------------------------------
23 # git submodules
25 EXT_SM_NAMES  = libixp wmii
26 EXT_SM_DIRS   = ${EXT_SM_NAMES:%=${EXT_DIR}/%}
27 EXT_SM_REGEXP = submodule\.($(shell echo ${EXT_SM_DIRS} | tr ' ' '|'))\.url
28 EXT_SM_COUNT  = $(shell echo ${EXT_SM_NAMES} | wc -w)
30 .PHONY: ext-check ext-update
32 ext-check:
33         @echo "Checking git submodules..."
34         ${Q} if ! test ${EXT_SM_COUNT} = $$(git config --get-regexp "${EXT_SM_REGEXP}" | wc -l) ; then \
35                 echo "ERROR: submodules not initialized, run:" >&2 ; \
36                 echo "       make update"                      >&2 ; \
37                 $(if ${NOCHECK},true,false) ; \
38          fi
39         ${Q} if (git submodule status | grep '^[+-]' 2>/dev/null) ; then \
40                 echo "ERROR: submodules out of date, run:"     >&2 ; \
41                 echo "       make update"                      >&2 ; \
42                 $(if ${NOCHECK},true,false) ; \
43          fi
44         @echo "CHECK OK"
46 update:
47 ext-update:
48         @echo "Updating git submodules..."
49         ${Q} if ! test ${EXT_SM_COUNT} = $$(git config --get-regexp "${EXT_SM_REGEXP}" | wc -l) ; then \
50                 git submodule init ; \
51          fi
52         ${Q} if (git submodule status | grep '^[+-]' 2>/dev/null) ; then \
53                 git submodule update ; \
54          fi
55         @echo "UPDATE OK"
57 # ------------------------------------------------------------------------
58 # where is libixp ?
60 .PHONY: ext-libixp-check
62 # NOTE: by default we assume that libixp is available in ext directory
63 EXT_IXP_PREFIX      = ${PWD}/${EXT_DIR}/libixp
64 EXT_IXP_LIB_DIR     = ${EXT_IXP_PREFIX}/lib
65 EXT_IXP_INC_DIR     = ${EXT_IXP_PREFIX}/include
67 EXT_IXP_A           = ${EXT_IXP_LIB_DIR}/libixp.a
68 EXT_IXP_H           = ${EXT_IXP_INC_DIR}/ixp.h
70 ext-libixp-check:
71         @echo "Checking for libixp..."
72         $(if $(wildcard ${EXT_IXP_A}),,$(error could not find libixp.a in ${EXT_IXP_PREFIX}; set EXT_IXP_PREFIX appropriately))
73         $(if $(wildcard ${EXT_IXP_H}),,$(error could not find ixp.h in ${EXT_IXP_PREFIX}; set EXT_IXP_PREFIX appropriately))
74         @echo "LIBIXP OK"
76 # ------------------------------------------------------------------------
77 # building & installing
79 .PHONY: ext
80 ext: ext-all
82 .PHONY: ext-all ext-clean ext-install ext-install-user ext-user
84 ext-all ext-user:               BUILD_STR="BUILD"
85 ext-install ext-install-user:   BUILD_STR="INSTALL"
87 ext-all ext-user:               BUILD_BASE_RULE=all
88 ext-all ext-user:               BUILD_WMIIRCLUA_RULE=all
90 ext-install ext-install-user:   BUILD_BASE_RULE=install
91 ext-install:                    BUILD_WMIIRCLUA_RULE=install
92 ext-install-user:               BUILD_WMIIRCLUA_RULE=install-user
94 ext-all ext-install:            BUILD_RULE=all
95 ext-all ext-install:            BUILD_PREFIX=${PREFIX}
96 ext-all:                        ext-build-helper
97 ext-install:                    ext-build-helper
98 ext-install:                    install-variable-check
100 ext-user ext-install-user:      BUILD_RULE=all
101 ext-user ext-install-user:      BUILD_PREFIX=${HOME_PREFIX}
102 ext-user:                       ext-build-helper
103 ext-install-user:               ext-build-helper
104 ext-install-user:               install-user-variable-check
106 ext-clean:                      BUILD_RULE=clean
107 ext-clean:                      BUILD_PREFIX=
108 ext-clean:                      ext-build-helper
110 .PHONY: ext-build-helper
111 ext-build-helper: ext-check
112         $(if ${BUILD_RULE},,$(error $@ is an internal rule))
113         #
114         @echo ${BUILD_STR} libixp
115         ${Q} ${MAKE} -C ${EXT_DIR}/libixp ${BUILD_RULE} \
116                 "CC=${CCPIC}" \
117                 "PREFIX=${BUILD_PREFIX}" \
118                 ${BUILD_BASE_RULE}
119         #
120 ifeq (${BUILD_RULE},clean)
121         ${MAKE} ext-libixp-check
122 endif
123         #
124         @echo ${BUILD_STR} wmii
125         ${Q} ${MAKE} -C ${EXT_DIR}/wmii ${BUILD_RULE} \
126                 "INCLUDE=${EXT_IXP_INC_DIR}:${INCLUDE}" \
127                 "LIBIXP=${EXT_IXP_A}" "CC=${CCPIC}" \
128                 "PREFIX=${BUILD_PREFIX}" \
129                 "CONFVERSION=lua" \
130                 ${BUILD_BASE_RULE}
131         #
132         @echo ${BUILD_STR} OK
135 # ------------------------------------------------------------------------
136 # more cleaning
138 .PHONY: lcl-gitclean
139 gitclean: lcl-gitclean
140 lcl-gitclean:
141         @echo GITCLEAN libixp
142         -${Q} cd ${EXT_DIR}/libixp && git clean -d -x -f
143         #
144         @echo GITCLEAN wmii
145         -${Q} cd ${EXT_DIR}/wmii && git clean -d -x -f