| 1 | # $FreeWRT$
|
|---|
| 2 | #-
|
|---|
| 3 | # This file is part of the FreeWRT project. FreeWRT is copyrighted
|
|---|
| 4 | # material, please see the LICENCE file in the top-level directory
|
|---|
| 5 | # or at http://www.freewrt.org/licence for details.
|
|---|
| 6 | #-
|
|---|
| 7 | # Comments:
|
|---|
| 8 | # * pre/do/post-foo are always defined here, but empty. This is so
|
|---|
| 9 | # that we can call it (BSD make has .if target(foo) but GNU not)
|
|---|
| 10 | # and it won't error out.
|
|---|
| 11 | # * ${_foo_COOKIE} are the actual targets
|
|---|
| 12 | # * default is "manual" -> define a do-foo: target in the Makefile
|
|---|
| 13 | # * if you have a style -> define a pre-foo: and post-foo: if they
|
|---|
| 14 | # are required, but the do-foo: magic is done here
|
|---|
| 15 | # * we want to use styles (configure:gnu, build/install:auto), for
|
|---|
| 16 | # making the Makefiles of the packages more clear
|
|---|
| 17 |
|
|---|
| 18 | ifneq ($(filter gnu,${CONFIGURE_STYLE}),)
|
|---|
| 19 | REORDER_DEPENDENCIES+= ${TOPDIR}/scripts/automake.dep
|
|---|
| 20 | endif
|
|---|
| 21 |
|
|---|
| 22 | REORDER_DEPENDENCIES?=
|
|---|
| 23 |
|
|---|
| 24 | #--- configure
|
|---|
| 25 | pre-configure:
|
|---|
| 26 | do-configure:
|
|---|
| 27 | post-configure:
|
|---|
| 28 | ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
|
|---|
| 29 | ifneq ($(strip ${REORDER_DEPENDENCIES}),)
|
|---|
| 30 | @sed -e '/^#/d' ${REORDER_DEPENDENCIES} | \
|
|---|
| 31 | tsort -r | while read f; do \
|
|---|
| 32 | cd ${WRKSRC}; \
|
|---|
| 33 | case $$f in \
|
|---|
| 34 | /*) \
|
|---|
| 35 | find . -name "$${f#/}" -print | while read i; do \
|
|---|
| 36 | echo "Touching $$i"; touch "$$i"; \
|
|---|
| 37 | done;; \
|
|---|
| 38 | *) \
|
|---|
| 39 | if test -e "$$f" ; then \
|
|---|
| 40 | echo "Touching $$f"; touch "$$f"; \
|
|---|
| 41 | fi;; \
|
|---|
| 42 | esac; \
|
|---|
| 43 | done
|
|---|
| 44 | endif
|
|---|
| 45 | mkdir -p ${WRKBUILD}
|
|---|
| 46 | @${MAKE} pre-configure
|
|---|
| 47 | ifneq ($(filter gnu,${CONFIGURE_STYLE}),)
|
|---|
| 48 | cd ${WRKBUILD}; rm -f config.{cache,status}; \
|
|---|
| 49 | env ${CONFIGURE_ENV} \
|
|---|
| 50 | ${MBSH} ${WRKSRC}/configure \
|
|---|
| 51 | --build=${GNU_HOST_NAME} \
|
|---|
| 52 | --host=${GNU_TARGET_NAME} \
|
|---|
| 53 | --target=${GNU_TARGET_NAME} \
|
|---|
| 54 | --program-prefix= \
|
|---|
| 55 | --program-suffix= \
|
|---|
| 56 | --prefix=/usr \
|
|---|
| 57 | --datadir=/usr/share \
|
|---|
| 58 | --mandir=/usr/share/man \
|
|---|
| 59 | --libexecdir=/usr/lib \
|
|---|
| 60 | --localstatedir=/var \
|
|---|
| 61 | --sysconfdir=/etc \
|
|---|
| 62 | --disable-nls \
|
|---|
| 63 | --enable-shared \
|
|---|
| 64 | --disable-static \
|
|---|
| 65 | --disable-dependency-tracking \
|
|---|
| 66 | --disable-libtool-lock \
|
|---|
| 67 | --disable-debug \
|
|---|
| 68 | ${CONFIGURE_ARGS}
|
|---|
| 69 | else ifneq ($(filter bsd,${CONFIGURE_STYLE}),)
|
|---|
| 70 | cd ${WRKBUILD} && env ${MAKE_ENV} ${BSDMAKE} -f ${MAKE_FILE} \
|
|---|
| 71 | ${MAKE_FLAGS} obj
|
|---|
| 72 | cd ${WRKBUILD} && env ${MAKE_ENV} ${BSDMAKE} -f ${MAKE_FILE} \
|
|---|
| 73 | ${MAKE_FLAGS} depend
|
|---|
| 74 | else ifeq ($(filter-out manual,${CONFIGURE_STYLE}),)
|
|---|
| 75 | env ${CONFIGURE_ENV} ${MAKE} do-configure
|
|---|
| 76 | else
|
|---|
| 77 | @echo "Invalid CONFIGURE_STYLE '${CONFIGURE_STYLE}'" >&2
|
|---|
| 78 | @exit 1
|
|---|
| 79 | endif
|
|---|
| 80 | @${MAKE} post-configure
|
|---|
| 81 | touch $@
|
|---|
| 82 |
|
|---|
| 83 | #--- build
|
|---|
| 84 | pre-build:
|
|---|
| 85 | do-build:
|
|---|
| 86 | post-build:
|
|---|
| 87 | ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
|
|---|
| 88 | @env ${MAKE_ENV} ${MAKE} pre-build
|
|---|
| 89 | ifneq ($(filter auto,${BUILD_STYLE}),)
|
|---|
| 90 | cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
|
|---|
| 91 | ${MAKE_FLAGS} ${ALL_TARGET}
|
|---|
| 92 | else ifneq ($(filter bsd,${BUILD_STYLE}),)
|
|---|
| 93 | cd ${WRKBUILD} && env ${MAKE_ENV} ${BSDMAKE} -f ${MAKE_FILE} \
|
|---|
| 94 | ${MAKE_FLAGS} ${ALL_TARGET}
|
|---|
| 95 | else ifeq ($(filter-out manual,${BUILD_STYLE}),)
|
|---|
| 96 | env ${MAKE_ENV} ${MAKE} do-build
|
|---|
| 97 | else
|
|---|
| 98 | @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
|
|---|
| 99 | @exit 1
|
|---|
| 100 | endif
|
|---|
| 101 | @env ${MAKE_ENV} ${MAKE} post-build
|
|---|
| 102 | touch $@
|
|---|
| 103 |
|
|---|
| 104 | #--- fake
|
|---|
| 105 | pre-install:
|
|---|
| 106 | do-install:
|
|---|
| 107 | post-install:
|
|---|
| 108 | ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
|
|---|
| 109 | -rm -f ${_ALL_CONTROLS}
|
|---|
| 110 | @mkdir -p '${STAGING_PARENT}/pkg' ${WRKINST} '${STAGING_DIR}/scripts'
|
|---|
| 111 | @${MAKE} ${_ALL_CONTROLS}
|
|---|
| 112 | @env ${MAKE_ENV} ${MAKE} pre-install
|
|---|
| 113 | ifneq ($(filter auto,${INSTALL_STYLE}),)
|
|---|
| 114 | cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
|
|---|
| 115 | DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET}
|
|---|
| 116 | else ifneq ($(filter bsd,${INSTALL_STYLE}),)
|
|---|
| 117 | @mkdir -p ${WRKINST}/{,usr/}{bin,include,lib,sbin}
|
|---|
| 118 | cd ${WRKBUILD} && env ${MAKE_ENV} ${BSDMAKE} -f ${MAKE_FILE} \
|
|---|
| 119 | DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET}
|
|---|
| 120 | else ifeq ($(filter-out manual,${INSTALL_STYLE}),)
|
|---|
| 121 | env ${MAKE_ENV} ${MAKE} do-install
|
|---|
| 122 | else
|
|---|
| 123 | @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
|
|---|
| 124 | @exit 1
|
|---|
| 125 | endif
|
|---|
| 126 | ifneq ($(filter confprog,${INSTALL_STYLE}),)
|
|---|
| 127 | for a in ${WRKINST}/usr/{bin/*-config,lib/pkgconfig/*.pc}; do \
|
|---|
| 128 | [[ -e $$a ]] || continue; \
|
|---|
| 129 | printf ',g/^prefix=/s,,&${STAGING_DIR},\nwq\n' | ed -s $$a; \
|
|---|
| 130 | done
|
|---|
| 131 | @: # not needed at the moment: ',g/-[IL].{/s,-[IL],&${STAGING_DIR},'
|
|---|
| 132 | endif
|
|---|
| 133 | @env ${MAKE_ENV} ${MAKE} post-install
|
|---|
| 134 | @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
|
|---|
| 135 | cd '${STAGING_DIR}'; \
|
|---|
| 136 | while read fn; do \
|
|---|
| 137 | rm -f "$$fn"; \
|
|---|
| 138 | done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
|
|---|
| 139 | fi
|
|---|
| 140 | @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
|
|---|
| 141 | @cd ${WRKINST}; \
|
|---|
| 142 | find lib \( -name lib\*.so\* -o -name lib\*.a \) \
|
|---|
| 143 | -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
|
|---|
| 144 | ' fix this!' >&2 \; -quit 2>/dev/null; \
|
|---|
| 145 | find usr ! -type d 2>/dev/null | \
|
|---|
| 146 | grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' | \
|
|---|
| 147 | tee '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
|
|---|
| 148 | cpio -apdlmu '${STAGING_DIR}'
|
|---|
| 149 | @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
|
|---|
| 150 | '${STAGING_PARENT}/pkg/${PKG_NAME}' | while read fn; do \
|
|---|
| 151 | chmod u+w $$fn; \
|
|---|
| 152 | printf '%s\nwq\n' '/^libdir='\''*/s##&${STAGING_DIR}#' | \
|
|---|
| 153 | ed -s $$fn; \
|
|---|
| 154 | done; grep 'usr/s*bin/' '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
|
|---|
| 155 | while read fn; do \
|
|---|
| 156 | b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
|
|---|
| 157 | [[ $$b = '#!' ]] || continue; \
|
|---|
| 158 | cp "$$fn" scripts/; \
|
|---|
| 159 | echo "scripts/$$(basename "$$fn")" \
|
|---|
| 160 | >>'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
|
|---|
| 161 | done
|
|---|
| 162 | touch $@
|
|---|
| 163 |
|
|---|
| 164 | #--- package
|
|---|
| 165 | ${_IPKGS_COOKIE}:
|
|---|
| 166 | clean=0; \
|
|---|
| 167 | for f in ${ALL_IPKGS}; do \
|
|---|
| 168 | [[ -e $$f ]] && clean=1; \
|
|---|
| 169 | done; \
|
|---|
| 170 | [[ $$clean = 0 ]] || ${MAKE} clean
|
|---|
| 171 | exec ${MAKE} package
|
|---|
| 172 |
|
|---|
| 173 | package: ${ALL_IPKGS}
|
|---|
| 174 | @cd ${WRKDIR}/fake-${ARCH} || exit 1; \
|
|---|
| 175 | y=; sp=; for x in ${ALL_IDIRS}; do \
|
|---|
| 176 | y="$$y$$sp$${x#$(WRKDIR)/fake-${ARCH}/}"; \
|
|---|
| 177 | sp=' '; \
|
|---|
| 178 | done; ls=; ln=; x=1; [[ -z $$y ]] || \
|
|---|
| 179 | md5sum $$(find $$y -type f) | \
|
|---|
| 180 | while read sum name; do \
|
|---|
| 181 | inode=$$(ls -i "$$name"); \
|
|---|
| 182 | echo "$$sum $${inode%% *} $$name"; \
|
|---|
| 183 | done | sort | while read sum inode name; do \
|
|---|
| 184 | if [[ $$sum = $$ls ]]; then \
|
|---|
| 185 | [[ $$li = $$inode ]] && continue; \
|
|---|
| 186 | case $$x in \
|
|---|
| 187 | 1) echo 'WARNING: duplicate files found in' \
|
|---|
| 188 | 'package "${PKG_NAME}"! Fix them.' >&2; \
|
|---|
| 189 | echo -n "> $$ln "; \
|
|---|
| 190 | ;; \
|
|---|
| 191 | 2) echo -n "> $$ln "; \
|
|---|
| 192 | ;; \
|
|---|
| 193 | 3) echo -n ' '; \
|
|---|
| 194 | ;; \
|
|---|
| 195 | esac; \
|
|---|
| 196 | echo -n "$$name"; \
|
|---|
| 197 | x=3; \
|
|---|
| 198 | else \
|
|---|
| 199 | case $$x in \
|
|---|
| 200 | 3) echo; \
|
|---|
| 201 | x=2; \
|
|---|
| 202 | ;; \
|
|---|
| 203 | esac; \
|
|---|
| 204 | fi; \
|
|---|
| 205 | ls=$$sum; \
|
|---|
| 206 | ln=$$name; \
|
|---|
| 207 | li=$$inode; \
|
|---|
| 208 | done
|
|---|
| 209 | touch ${_IPKGS_COOKIE}
|
|---|
| 210 |
|
|---|
| 211 | #--- clean
|
|---|
| 212 | clean-targets: clean-dev-generic
|
|---|
| 213 |
|
|---|
| 214 | clean-dev-generic:
|
|---|
| 215 | @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
|
|---|
| 216 | cd '${STAGING_DIR}'; \
|
|---|
| 217 | while read fn; do \
|
|---|
| 218 | rm -f "$$fn"; \
|
|---|
| 219 | done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
|
|---|
| 220 | fi
|
|---|
| 221 | @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
|
|---|