| 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 | # BSD-style
|
|---|
| 8 | #all: build
|
|---|
| 9 | # same as recursive-descend
|
|---|
| 10 | all: build-all-ipkgs
|
|---|
| 11 |
|
|---|
| 12 | TCFLAGS:= ${TARGET_CFLAGS}
|
|---|
| 13 | TCXXFLAGS:= ${TARGET_CFLAGS}
|
|---|
| 14 | TCPPFLAGS:= ${TARGET_CPPFLAGS} \
|
|---|
| 15 | -DNDEBUG \
|
|---|
| 16 | -isystem ${STAGING_DIR}/include \
|
|---|
| 17 | -isystem ${STAGING_DIR}/usr/include
|
|---|
| 18 | TLDFLAGS:= ${TARGET_LDFLAGS} -Wl,-rpath -Wl,/usr/lib \
|
|---|
| 19 | -Wl,-rpath-link -Wl,${STAGING_DIR}/usr/lib \
|
|---|
| 20 | -L${STAGING_DIR}/lib -L${STAGING_DIR}/usr/lib
|
|---|
| 21 | CONFIGURE_ENV+= ${TARGET_CONFIGURE_OPTS} \
|
|---|
| 22 | ${HOST_CONFIGURE_OPTS} \
|
|---|
| 23 | CC='${TARGET_CC}' CXX='${TARGET_CXX}' \
|
|---|
| 24 | CFLAGS='$(strip ${TCFLAGS})' \
|
|---|
| 25 | CXXFLAGS='$(strip ${TCXXFLAGS})' \
|
|---|
| 26 | CPPFLAGS='$(strip ${TCPPFLAGS})' \
|
|---|
| 27 | LDFLAGS='$(strip ${TLDFLAGS})' \
|
|---|
| 28 | PKG_CONFIG_PATH='${STAGING_DIR}/usr/lib/pkgconfig'
|
|---|
| 29 | MAKE_FILE?= Makefile
|
|---|
| 30 | # this is environment for 'make all' and 'make install'
|
|---|
| 31 | MAKE_ENV?=
|
|---|
| 32 | # this is arguments for 'make all' and 'make install'
|
|---|
| 33 | XAKE_FLAGS?=
|
|---|
| 34 | # this is arguments for 'make all' ONLY
|
|---|
| 35 | MAKE_FLAGS?=
|
|---|
| 36 | # this is arguments for 'make install' ONLY
|
|---|
| 37 | FAKE_FLAGS?=
|
|---|
| 38 | ALL_TARGET?= all
|
|---|
| 39 | INSTALL_TARGET?= install
|
|---|
| 40 | MAKE_ENV+= PATH='${TARGET_PATH}' \
|
|---|
| 41 | ${HOST_CONFIGURE_OPTS} \
|
|---|
| 42 | CC='${TARGET_CC}' CXX='${TARGET_CXX}' \
|
|---|
| 43 | AR='${TARGET_CROSS}ar' RANLIB='${TARGET_CROSS}ranlib' \
|
|---|
| 44 | CFLAGS='$(strip ${TCFLAGS})' \
|
|---|
| 45 | CXXFLAGS='$(strip ${TCXXFLAGS})' \
|
|---|
| 46 | CPPFLAGS='$(strip ${TCPPFLAGS})' \
|
|---|
| 47 | LDFLAGS='$(strip ${TLDFLAGS})'
|
|---|
| 48 | MAKE_FLAGS+= ${XAKE_FLAGS}
|
|---|
| 49 | FAKE_FLAGS+= ${XAKE_FLAGS}
|
|---|
| 50 |
|
|---|
| 51 | ifeq ($(strip ${WRKDIR_BSD}),)
|
|---|
| 52 | WRKDIR_BASE:= ${BUILD_DIR}
|
|---|
| 53 | else
|
|---|
| 54 | WRKDIR_BASE:= $(shell pwd)
|
|---|
| 55 | endif
|
|---|
| 56 |
|
|---|
| 57 | _EXTRACT_COOKIE= ${WRKDIST}/.extract_done
|
|---|
| 58 | _PATCH_COOKIE= ${WRKDIST}/.prepared
|
|---|
| 59 | _CONFIGURE_COOKIE= ${WRKBUILD}/.configure_done
|
|---|
| 60 | _BUILD_COOKIE= ${WRKBUILD}/.build_done
|
|---|
| 61 | _FAKE_COOKIE= ${WRKINST}/.fake_done
|
|---|
| 62 | _IPKGS_COOKIE= ${WRKDIR}/.ipkgs_done
|
|---|
| 63 |
|
|---|
| 64 | _IN_PACKAGE:= 1
|
|---|
| 65 | include ${TOPDIR}/mk/buildhlp.mk
|
|---|
| 66 | -include info.mk
|
|---|
| 67 |
|
|---|
| 68 | # defined in buildhlp.mk ('extract' can fail, use 'patch' then)
|
|---|
| 69 | extract: ${_EXTRACT_COOKIE}
|
|---|
| 70 | patch: ${_PATCH_COOKIE}
|
|---|
| 71 |
|
|---|
| 72 | # defined below (will be moved to pkg-bottom.mk!)
|
|---|
| 73 | configure: ${_CONFIGURE_COOKIE}
|
|---|
| 74 | build: ${_BUILD_COOKIE}
|
|---|
| 75 | fake: ${_FAKE_COOKIE}
|
|---|
| 76 |
|
|---|
| 77 | # our recursive build entry point
|
|---|
| 78 | build-all-ipkgs: ${_IPKGS_COOKIE}
|
|---|
| 79 |
|
|---|
| 80 | define PKG_template
|
|---|
| 81 | IPKG_$(1)= $(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
|
|---|
| 82 | IDIR_$(1)= $(WRKDIR)/fake-${ARCH}/ipkg-$(2)
|
|---|
| 83 | ifneq (${FWRT_PACKAGE_$(1)}${DEVELOPER},)
|
|---|
| 84 | ALL_IPKGS+= $$(IPKG_$(1))
|
|---|
| 85 | ALL_IDIRS+= $${IDIR_$(1)}
|
|---|
| 86 | endif
|
|---|
| 87 | INFO_$(1)= $(IPKG_STATE_DIR)/info/$(2).list
|
|---|
| 88 |
|
|---|
| 89 | ifeq ($(FWRT_PACKAGE_$(1)),y)
|
|---|
| 90 | install-targets: $$(INFO_$(1))
|
|---|
| 91 | endif
|
|---|
| 92 |
|
|---|
| 93 | IDEPEND_$(1):= $$(strip $(5))
|
|---|
| 94 |
|
|---|
| 95 | _ALL_CONTROLS+= $$(IDIR_$(1))/CONTROL/control
|
|---|
| 96 | $$(IDIR_$(1))/CONTROL/control: ${_PATCH_COOKIE}
|
|---|
| 97 | ${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $$(IDIR_$(1)) \
|
|---|
| 98 | ./ipkg/$(2).control $(3) $(4)
|
|---|
| 99 | [ -z "$$(IDEPEND_$(1))" ] || echo "Depends: $$(IDEPEND_$(1))" >>$$(IDIR_$(1))/CONTROL/control
|
|---|
| 100 | for file in conffiles preinst postinst prerm postrm; do \
|
|---|
| 101 | [ ! -f ./ipkg/$(2).$$$$file ] || cp ./ipkg/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file; \
|
|---|
| 102 | done
|
|---|
| 103 |
|
|---|
| 104 | $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $${_FAKE_COOKIE}
|
|---|
| 105 | $${RSTRIP} $${IDIR_$(1)}
|
|---|
| 106 | @mkdir -p $${PACKAGE_DIR} '$${STAGING_DIR}/pkg' \
|
|---|
| 107 | '$${STAGING_DIR}/scripts'
|
|---|
| 108 | @if test -s '$${STAGING_DIR}/pkg/$(1)'; then \
|
|---|
| 109 | cd '$${STAGING_DIR}'; \
|
|---|
| 110 | while read fn; do \
|
|---|
| 111 | rm -f "$$$$fn"; \
|
|---|
| 112 | done <'$${STAGING_DIR}/pkg/$(1)'; \
|
|---|
| 113 | fi
|
|---|
| 114 | @rm -f '$${STAGING_DIR}/pkg/$(1)'
|
|---|
| 115 | @cd $${IDIR_$(1)}; \
|
|---|
| 116 | x=$$$$(find tmp var 2>/dev/null); if [[ -n $$$$x ]]; then \
|
|---|
| 117 | echo 'WARNING: $${IPKG_$(1)} installs files into a' \
|
|---|
| 118 | 'ramdisk location:' >&2; \
|
|---|
| 119 | echo "$$$$x" | sed 's/^/- /' >&2; \
|
|---|
| 120 | fi; \
|
|---|
| 121 | find lib \( -name lib\*.so\* -o -name lib\*.a \) \
|
|---|
| 122 | -exec echo 'WARNING: $${IPKG_$(1)} installs files in /lib -' \
|
|---|
| 123 | ' fix this!' >&2 \; -quit 2>/dev/null; \
|
|---|
| 124 | find usr ! -type d 2>/dev/null | \
|
|---|
| 125 | grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' | \
|
|---|
| 126 | tee '$${STAGING_DIR}/pkg/$(1)' | \
|
|---|
| 127 | cpio -apdlmu '$${STAGING_DIR}'
|
|---|
| 128 | @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$$$' 'pkg/$(1)' | \
|
|---|
| 129 | while read fn; do \
|
|---|
| 130 | chmod u+w $$$$fn; \
|
|---|
| 131 | printf '%s\nwq\n' '/^libdir='\''*/s##&${STAGING_DIR}#' | \
|
|---|
| 132 | ed -s $$$$fn; \
|
|---|
| 133 | done; grep 'usr/s*bin/' 'pkg/$(1)' | while read fn; do \
|
|---|
| 134 | b="$$$$(dd if="$$$$fn" bs=2 count=1 2>/dev/null)"; \
|
|---|
| 135 | [[ $$$$b = '#!' ]] || continue; \
|
|---|
| 136 | cp "$$$$fn" scripts/; \
|
|---|
| 137 | echo "scripts/$$$$(basename "$$$$fn")" >>'pkg/$(1)'; \
|
|---|
| 138 | done
|
|---|
| 139 | $${IPKG_BUILD} $${IDIR_$(1)} $${PACKAGE_DIR}
|
|---|
| 140 |
|
|---|
| 141 | clean-targets: clean-dev-$(1)
|
|---|
| 142 |
|
|---|
| 143 | clean-dev-$(1):
|
|---|
| 144 | @if test -s '$${STAGING_DIR}/pkg/$(1)'; then \
|
|---|
| 145 | cd '$${STAGING_DIR}'; \
|
|---|
| 146 | while read fn; do \
|
|---|
| 147 | rm -f "$$$$fn"; \
|
|---|
| 148 | done <'$${STAGING_DIR}/pkg/$(1)'; \
|
|---|
| 149 | fi
|
|---|
| 150 | @rm -f '$${STAGING_DIR}/pkg/$(1)'
|
|---|
| 151 |
|
|---|
| 152 | $$(INFO_$(1)): $$(IPKG_$(1))
|
|---|
| 153 | $(IPKG) install $$(IPKG_$(1))
|
|---|
| 154 | endef
|
|---|
| 155 |
|
|---|
| 156 | install-targets:
|
|---|
| 157 | install:
|
|---|
| 158 | @$(CMD_TRACE) "installing... "
|
|---|
| 159 | @$(MAKE) install-targets $(MAKE_TRACE)
|
|---|
| 160 |
|
|---|
| 161 | clean-targets:
|
|---|
| 162 | clean:
|
|---|
| 163 | @$(CMD_TRACE) "cleaning... "
|
|---|
| 164 | @$(MAKE) clean-targets $(MAKE_TRACE)
|
|---|
| 165 | rm -rf ${WRKDIR} ${ALL_IPKGS}
|
|---|
| 166 |
|
|---|
| 167 | .PHONY: all fetch refetch checksum extract patch configure \
|
|---|
| 168 | build fake package install clean build-all-ipkgs
|
|---|