Permalink
Browse files

Introduce new config architecture, used to specify where to get sources

Goal is to make it easy for:
* Users (of the build system) to specify/override what sources are used,
  in particular for developers to point to a local source tree
* Automated systems to specify a particular long-standing config
  (This is done by setting CONFIG=configname, although we give easy targets
   for the existing configs 'woce', 'webos-ports', and 'custom')
* Automated systems to support one-off build variations by specifying a new
  version, URL, or download type by commandline parameters to make.
  (This is done by setting a config parameter at commandline, such as
   make -j16 LUNASYSMGR_VERSION=mynewversion, etc)
  • Loading branch information...
1 parent 3fc33eb commit f66f402e5e8728791a852d042f82330093b234b5 @dtzWill dtzWill committed Jun 28, 2012
View
@@ -7,6 +7,9 @@ LEVEL = .
.PHONY: woce-toolchain woce-headers clobber
.PHONY: qt4 luna-sysmgr
+.PHONY: default woce webos-ports custom
+
+include $(LEVEL)/Makefile.common
# To build packages, we need the toolchain and the staging dir setup
# For now, just list packages to be built here, in a working order.
@@ -34,8 +37,6 @@ woce-toolchain: toolchain/$(WOCE_TOOLCHAIN)/.unpacked
# Grab the rootfs, stage it, and add our required headers
woce-headers: staging/$(WOCE_ARCH)/usr/include/.staged
-include $(LEVEL)/Makefile.common
-
# Cleanup everything other than the downloads (which are sacred)
clobber::
rm -rf rootfs
View
@@ -2,8 +2,23 @@
# Default rule
.PHONY: build unpack
+.PHONY: default woce webos-ports custom
+
+ifndef CONFIG
+default: woce
+endif
+
build::
+woce:
+ $(MAKE) CONFIG=woce build
+webos-ports:
+ $(MAKE) CONFIG=webos-ports build
+custom:
+ $(MAKE) CONFIG=custom build
+test:
+ $(MAKE) CONFIG=test build
+
# LEVEL should be set by every Makefile
ifndef LEVEL
$(error "LEVEL not set in Makefile!")
@@ -21,6 +36,11 @@ include $(LEVEL)/support/srvln.mk
# Include rules for building download targets
include $(LEVEL)/support/dl.mk
+# Include 'metadata-like' file for specifying sources
+ifdef CONFIG
+ include $(LEVEL)/config/$(CONFIG).mk
+endif
+
# Include information used for cross-compiling
include $(LEVEL)/support/cross-compile.mk
View
@@ -0,0 +1,36 @@
+# custom.mk
+#
+# This file defines the sources used to drive the 'custom' build.
+#
+# Override this to use your own development versions
+# Each package needs a PREFIX_NAME, PREFIX_VERSION, and PREFIX_URL set
+# As well as a PREFIX_DLTYPE to specify the source type.
+# Valid dl types are: TGZ, BZ2, GZ, GIT, and DIR.
+# The last directly uses the specified source tree, symlinking
+# it into the appropriate build directory.
+
+$(warning You need to customize this to work correctly.)
+$(error Remove this and the line above to proceed)
+
+# Build-support
+BUILD_SUPPORT_NAME := build-support
+BUILD_SUPPORT_VERSION := v0.0.1
+BUILD_SUPPORT_URL := https://github.com/woce/$(BUILD_SUPPORT_NAME)/tarball/$(BUILD_SUPPORT_VERSION)
+BUILD_SUPPORT_DLTYPE := TGZ
+
+# LunaSysMgr
+LUNASYSMGR_NAME := LunaSysMgr
+LUNASYSMGR_VERSION := initial
+LUNASYSMGR_URL := https://github.com/woce/$(LUNASYSMGR_NAME)/tarball/$(LUNASYSMGR_VERSION)
+LUNASYSMGR_DLTYPE := TGZ
+
+# QT4 and patch
+QT4_NAME := qt4
+QT4_VERSION := 4.8.0
+QT4_URL := http://downloads.help.palm.com/opensource/3.0.5/qt4-$(QT4_VERSION).tar.gz
+QT4_DLTYPE := TGZ
+
+QT4_PATCH_NAME := qt4
+QT4_PATCH_VERSION := $(QT4_VERSION)
+QT4_PATCH_URL := http://downloads.help.palm.com/opensource/3.0.5/qt-$(QT4_VERSION).patch.gz
+QT4_PATCH_DLTYPE := GZ
View
@@ -0,0 +1,29 @@
+# webos-ports.mk
+#
+# This file defines the sources used to drive the 'webos-ports' build.
+#
+
+$(error The "webos-ports" build isn't supported yet.)
+
+# Build-support
+BUILD_SUPPORT_NAME := build-support
+BUILD_SUPPORT_VERSION := v0.0.1
+BUILD_SUPPORT_URL := https://github.com/webos-ports/$(BUILD_SUPPORT_NAME)/tarball/$(BUILD_SUPPORT_VERSION)
+BUILD_SUPPORT_DLTYPE := TGZ
+
+# LunaSysMgr
+LUNASYSMGR_NAME := LunaSysMgr
+LUNASYSMGR_VERSION := initial
+LUNASYSMGR_URL := https://github.com/webos-ports/$(LUNASYSMGR_NAME)/tarball/$(LUNASYSMGR_VERSION)
+LUNASYSMGR_DLTYPE := TGZ
+
+# QT4 and patch
+QT4_NAME := qt4
+QT4_VERSION := 4.8.0
+QT4_URL := http://downloads.help.palm.com/opensource/3.0.5/qt4-$(QT4_VERSION).tar.gz
+QT4_DLTYPE := TGZ
+
+QT4_PATCH_NAME := qt4
+QT4_PATCH_VERSION := $(QT4_VERSION)
+QT4_PATCH_URL := http://downloads.help.palm.com/opensource/3.0.5/qt-$(QT4_VERSION).patch.gz
+QT4_PATCH_DLTYPE := GZ
View
@@ -0,0 +1,27 @@
+# woce.mk
+#
+# This file defines the sources used to drive the 'woce' build.
+#
+
+# Build-support
+BUILD_SUPPORT_NAME := build-support
+BUILD_SUPPORT_VERSION := v0.0.1
+BUILD_SUPPORT_URL := https://github.com/woce/$(BUILD_SUPPORT_NAME)/tarball/$(BUILD_SUPPORT_VERSION)
+BUILD_SUPPORT_DLTYPE := TGZ
+
+# LunaSysMgr
+LUNASYSMGR_NAME := LunaSysMgr
+LUNASYSMGR_VERSION := initial
+LUNASYSMGR_URL := https://github.com/woce/$(LUNASYSMGR_NAME)/tarball/$(LUNASYSMGR_VERSION)
+LUNASYSMGR_DLTYPE := TGZ
+
+# QT4 and patch
+QT4_NAME := qt4
+QT4_VERSION := 4.8.0
+QT4_URL := http://downloads.help.palm.com/opensource/3.0.5/qt4-$(QT4_VERSION).tar.gz
+QT4_DLTYPE := TGZ
+
+QT4_PATCH_NAME := qt4
+QT4_PATCH_VERSION := $(QT4_VERSION)
+QT4_PATCH_URL := http://downloads.help.palm.com/opensource/3.0.5/qt-$(QT4_VERSION).patch.gz
+QT4_PATCH_DLTYPE := GZ
@@ -41,25 +41,19 @@ QMAKE := $(QTPATH)/bin/qmake-palm
.PHONY: build unpack patch package
package:: ipkgs/${APP_ID}_${VERSION}_armv7.ipk
build:: build/armv7-stage/.built-${VERSION}
-unpack: build/src/.unpacked
+unpack: build/.unpacked
-LUNASYSMGR_NAME := LunaSysMgr
-LUNASYSMGR_TAG := initial
-LUNASYSMGR_URL := https://github.com/woce/$(LUNASYSMGR_NAME)/tarball/$(LUNASYSMGR_TAG)
-LUNASYSMGR_DL := $(DL_DIR)/$(LUNASYSMGR_NAME)-$(LUNASYSMGR_TAG).tar.gz
-
-# Create rule for grabbing this version
-$(eval $(call DLTGZ,$(LUNASYSMGR_NAME),$(LUNASYSMGR_TAG),$(LUNASYSMGR_URL)))
+$(call DL,LUNASYSMGR)
### Unpack the software and build it
-build/src/.unpacked: sysmgr.patch $(LUNASYSMGR_DL)
+build/.unpacked: sysmgr.patch $(LUNASYSMGR_DL)
-rm -rf build
mkdir -p build/src
- tar -C build/src --strip=1 -zxf $(LUNASYSMGR_DL)
+ $(call EXTRACT,LUNASYSMGR,build/src,--strip=1)
patch -Np2 -d build/src < sysmgr.patch
touch $@
-build/armv7-stage/.built-${VERSION}: build/src/.unpacked
+build/armv7-stage/.built-${VERSION}: build/.unpacked
-rm -rf build/armv7-stage
mkdir -p build/armv7-stage
cd build/armv7-stage && \
@@ -6,29 +6,21 @@ include $(LEVEL)/Makefile.common
.PHONY: build unpack patch
build:: build/armv7/.built
-unpack:: build/src/.unpacked
+unpack:: build/.unpacked
-VERSION := 4.8.0
+$(call DL,QT4)
+$(call DL,QT4_PATCH)
-QT4_URL := http://downloads.help.palm.com/opensource/3.0.5/qt4-$(VERSION).tar.gz
-QT4_PATCH_URL := http://downloads.help.palm.com/opensource/3.0.5/qt-$(VERSION).patch.gz
-
-QT4_DL = $(DL_DIR)/qt4-$(VERSION).tar.gz
-QT4_PATCH_DL = $(DL_DIR)/qt4-patch-$(VERSION).gz
-
-$(eval $(call DLTGZ,qt4,$(VERSION),$(QT4_URL)))
-$(eval $(call DLGZ,qt4-patch,$(VERSION),$(QT4_PATCH_URL)))
-
-build/src/.unpacked: $(QT4_DL) $(QT4_PATCH_DL) qt4.patch
+build/.unpacked: $(QT4_DL) $(QT4_PATCH_DL) qt4.patch
-rm -rf build
mkdir -p build/src
- tar -C build/src --strip=1 -zxf $(QT4_DL)
+ $(call EXTRACT,QT4,build/src,--strip=1)
zcat $(QT4_PATCH_DL)| patch -Np1 -d build/src
patch -Np2 -d build/src < qt4.patch
cp qconfig-palm.h build/src/src/corelib/global/
touch $@
-build/armv7/.built: build/src/.unpacked
+build/armv7/.built: build/.unpacked
-rm -rf build/armv7
mkdir -p build/armv7
@echo "Using armv6 mkspec, since for now the armv7 mkspec doesn't exist"
View
@@ -1,52 +1,91 @@
# Useful definitions for downloading files
# Builds tar.bz2 dl rule
-# Arguments: NAME, VERSION, URL
-define DLBZ2
-$(DL_DIR)/$1-$2.tar.bz2:
+# Arguments: PREFIX (reads PREFIX_NAME, PREFIX_VERSION, and PREFIX_URL)
+# Exports PREFIX_DL to be the resulting source target (for deps, etc)
+define DLRULEBZ2
+$1_DL := $(DL_DIR)/$($1_NAME)-$($1_VERSION).tar.bz2
+$$($1_DL):
rm -f $$@ $$@.tmp
mkdir -p $(DL_DIR)
- curl -f -R -L -o $$@.tmp $3
+ curl -f -R -L -o $$@.tmp $($1_URL)
mv $$@.tmp $$@
endef
+EXTRACTRULEBZ2 = tar -C $2 $3 -axvf $($1_DL)
+
#
# Builds tar.gz dl rule
-# Arguments: NAME, VERSION, URL
-define DLTGZ
-$(DL_DIR)/$1-$2.tar.gz:
+# Arguments: PREFIX (reads PREFIX_NAME, PREFIX_VERSION, and PREFIX_URL)
+# Exports PREFIX_DL to be the resulting source target (for deps, etc)
+define DLRULETGZ
+$1_DL := $(DL_DIR)/$($1_NAME)-$($1_VERSION).tar.gz
+$$($1_DL):
rm -f $$@ $$@.tmp
mkdir -p $(DL_DIR)
- curl -f -R -L -o $$@.tmp $3
+ curl -f -R -L -o $$@.tmp $($1_URL)
mv $$@.tmp $$@
endef
+EXTRACTRULETGZ = tar -C $2 $3 -axvf $($1_DL)
#
# Builds .gz dl rule
-# Arguments: NAME, VERSION, URL
-define DLGZ
-$(DL_DIR)/$1-$2.gz:
+# Arguments: PREFIX (reads PREFIX_NAME, PREFIX_VERSION, and PREFIX_URL)
+# Exports PREFIX_DL to be the resulting source target (for deps, etc)
+define DLRULEGZ
+$1_DL := $(DL_DIR)/$($1_NAME)-$($1_VERSION).gz
+$$($1_DL):
rm -f $$@ $$@.tmp
mkdir -p $(DL_DIR)
- curl -f -R -L -o $$@.tmp $3
+ curl -f -R -L -o $$@.tmp $($1_URL)
mv $$@.tmp $$@
endef
+EXTRACTRULEGZ = $(error Cannot extract .gz to a directory)
# Builds tar.gz from specified git checkout
# Intended for exact git commit-id's as version
-# Arguments: NAME, GITREV, URL
-define DLGIT
-$(DL_DIR)/$1-$2.tar.gz:
+# Arguments: PREFIX (reads PREFIX_NAME, PREFIX_VERSION, and PREFIX_URL)
+# Exports PREFIX_DL to be the resulting source target (for deps, etc)
+# Keeps git checkout to help with updating costs
+# Timestamp (used for make deps) is set to timestamp of commit
+define DLRULEGIT
+$1_DL := $(DL_DIR)/$($1_NAME)-$($1_VERSION).tar.gz
+$$($1_DL):
rm -f $$@
mkdir -p $(DL_DIR)
if [ ! -e $(DL_DIR)/$1-git ] ; then \
- git clone -n $3 $(DL_DIR)/$1-git ; \
+ git clone -n $($1_URL) $(DL_DIR)/$1-git ; \
elif [ -L $(DL_DIR)/$1-git ] ; then \
true ; \
else \
( cd $(DL_DIR)/$1-git ; git fetch ) ; \
fi
- cd $(DL_DIR)/$1-git ; git checkout $2
+ cd $(DL_DIR)/$1-git ; git checkout $($1_VERSION)
tar -C $(DL_DIR)/$1-git -zcf $$@ .
- ( cd $(DL_DIR)/$1-git ; git log --pretty="format:%ct" -n 1 $2 ) | \
+ ( cd $(DL_DIR)/$1-git ; git log --pretty="format:%ct" -n 1 $($1_VERSION) | \
python -c 'import os,sys; time = int(sys.stdin.read()); os.utime("$$@",(time,time));'
endef
+EXTRACTRULEGIT = tar -C $2 $3 -axvf $($1_DL)
+
+# "DL" rule for directories on local machine.
+# Extract rule symlinks to the specified directory
+# (and doesn't support 'tar' options, which are almost always 'strip')
+define DLRULEDIR
+$1_DL := $($1_URL)/.exists
+$$($1_DL):
+ @touch $$@
+endef
+EXTRACTRULEDIR = rmdir $2; ln -s $($1_URL) $2
+
+ifdef CONFIG
+DLRULE = $(error No DLTYPE specified for $1, or missing config file!)
+EXTRACTRULE = $(error No DLTYPE specified for $1, or missing config file!)
+endif
+
+# Looks up the specified DL information and invokes the appropriate rule
+define DL
+$(eval $(call DLRULE$($1_DLTYPE),$1))
+endef
+# Helper to 'extract' the various download types into a source directory
+define EXTRACT
+$(call EXTRACTRULE$($1_DLTYPE),$1,$2,$3)
+endef
View
@@ -1,15 +1,10 @@
# Install staging headers
-BUILD_SUPPORT_NAME := build-support
-BUILD_SUPPORT_TAG := v0.0.1
-BUILD_SUPPORT_URL := https://github.com/woce/$(BUILD_SUPPORT_NAME)/tarball/$(BUILD_SUPPORT_TAG)
-BUILD_SUPPORT_DL := $(DL_DIR)/$(BUILD_SUPPORT_NAME)-$(BUILD_SUPPORT_TAG).tar.gz
-
-$(eval $(call DLTGZ,$(BUILD_SUPPORT_NAME),$(BUILD_SUPPORT_TAG),$(BUILD_SUPPORT_URL)))
+$(call DL,BUILD_SUPPORT)
staging/armv7/usr/include/.staged: staging/$(WOCE_ARCH)/.unpacked $(BUILD_SUPPORT_DL)
-rm -rf staging/armv7/usr/include
mkdir -p staging/armv7/usr/include
- tar -C staging/armv7/usr/include --strip=4 --wildcards -zxf $(BUILD_SUPPORT_DL) 'woce-build-support-[a-f0-9]*/staging/arm-none-linux-gnueabi/include'
- tar -C staging/armv7/usr/lib --strip=4 --wildcards -zxf $(BUILD_SUPPORT_DL) 'woce-build-support-[a-f0-9]*/staging/arm-none-linux-gnueabi/lib'
+ tar -C staging/armv7/usr/include --strip=4 --wildcards -axf $(BUILD_SUPPORT_DL) 'woce-build-support-[a-f0-9]*/staging/arm-none-linux-gnueabi/include'
+ tar -C staging/armv7/usr/lib --strip=4 --wildcards -axf $(BUILD_SUPPORT_DL) 'woce-build-support-[a-f0-9]*/staging/arm-none-linux-gnueabi/lib'
touch $@
View
@@ -2,11 +2,15 @@ TOOLCHAINS := arm-2007q3 arm-2009q1
arm-2007q3_VERSION := 2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu
arm-2009q1_VERSION := 2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu
-TC_URL = https://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-$1.tar.bz2
-
# Arguments: toolchain shortname
define TCRULE
-$(TOOLCHAIN_DIR)/$1/.unpacked: $(DL_DIR)/arm-$($1_VERSION).tar.bz2
+
+$1_NAME := arm
+$1_URL := https://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-$($1_VERSION).tar.bz2
+$1_DLTYPE := TGZ
+$$(call DL,$1)
+
+$(TOOLCHAIN_DIR)/$1/.unpacked: $$($1_DL)
rm -rf $(TOOLCHAIN_DIR)/$1
-rm -rf $(TOOLCHAIN_DIR)/$1-tmp
mkdir -p $(TOOLCHAIN_DIR)/$1-tmp
@@ -18,6 +22,3 @@ endef
# Build rules for extracting each toolchain
$(foreach t,$(TOOLCHAINS),$(eval $(call TCRULE,$t)))
-
-# Build rules for downloading each toolchain
-$(foreach t,$(TOOLCHAINS),$(eval $(call DLBZ2,arm,$($t_VERSION),$(call TC_URL,$($t_VERSION)))))

0 comments on commit f66f402

Please sign in to comment.