#-------------------------------------------------------------- # # We need to run "make menuconfig" to get users options # and then we run make to create a distribution # #-------------------------------------------------------------- TOPDIR=./ CONFIG_CONFIG_IN = Config.in CONFIG_DEFCONFIG = .defconfig CONFIG = config PADS_CONFIG ?= .config export ARCH=powerpc export CROSS_COMPILE=ppc_4xxFP- # Pull in the user's configuration file ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),) -include $(TOPDIR)$(PADS_CONFIG) endif TAR_OPTIONS=$(subst ",, $(PADS_TAR_OPTIONS)) -xf #" ifeq ($(strip $(PADS_HAVE_DOT_CONFIG)),y) TARGETS:="" include package/Makefile.in # we want bash as shell if possible SHELL:=$(shell if [ -x "$$BASH" ]; then echo $$BASH; \ else if [ -x /bin/bash ]; then echo /bin/bash; \ else echo sh; fi; fi) # kconfig uses CONFIG_SHELL CONFIG_SHELL:=$(SHELL) export SHELL CONFIG_SHELL ############################################################# # # You should probably leave this stuff alone unless you know # what you are doing. # ############################################################# all: world #In this section, we neeed .config include .config.cmd # We explicitly specify the build order of the first targets, # otherwise with 'include package/*/*.mk' they all end up in # alphabetical order. The alternative is to use explicit dependencies # to define the build order, for example have the asterisk target # depend on linux. TARGETS+=toolchain linux skeleton busybox export PADS_VERSION=2.2.3-1 # We also need the various per-package makefiles which we add to TARGETS include package/*/*.mk target_debug: @echo "TARGETS=$(TARGETS)" TARGETS_CLEAN:=$(patsubst %,%-clean, $(TARGETS)) TARGETS_SOURCE:=$(patsubst %,%-source, $(TARGETS)) TARGETS_DIRCLEAN:=$(patsubst %,%-dirclean,$(TARGETS)) TARGETS_IMAGE:=$(patsubst %,%-image,$(TARGETS)) ############################################################################# # Custom Path ############################################################################# TOOLS_BIN=$(BASE_DIR)/toolchain/usr/bin PATH:= /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin PATH:= $(PATH):$(TOOLS_BIN) world: prebuild clean_version_info $(DL_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \ $(PERSISTENT_STORAGE) $(PERSISTENT1_STORAGE) $(PERSISTENT2_STORAGE) \ set_version_info $(TARGETS) postbuild .PHONY: all world clean dirclean distclean source clean_version_info set_version_info \ $(TARGETS) $(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) \ $(TARGETS_IMAGE) $(DL_DIR) $(BUILD_DIR) $(TOOL_BUILD_DIR) $(STAGING_DIR) ############################################################# # # staging and target directories do NOT list these as # dependancies anywhere else # ############################################################# $(DL_DIR): @mkdir -p $(DL_DIR) $(BUILD_DIR): @mkdir -p $(BUILD_DIR) $(TOOL_BUILD_DIR): @mkdir -p $(TOOL_BUILD_DIR) $(STAGING_DIR): @mkdir -p $(STAGING_DIR)/lib @mkdir -p $(STAGING_DIR)/include @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME) $(TARGET_DIR): mkdir -p $(TARGET_DIR) $(PERSISTENT_STORAGE): mkdir -p $(PERSISTENT_STORAGE) $(PERSISTENT1_STORAGE): mkdir -p $(PERSISTENT1_STORAGE) @echo "Dummy file to cause image creation" > $(PERSISTENT1_STORAGE)/create_image $(PERSISTENT2_STORAGE): mkdir -p $(PERSISTENT2_STORAGE) @echo "Dummy file to cause image creation" > $(PERSISTENT2_STORAGE)/create_image clean_version_info: @rm -f $(PERSISTENT_STORAGE)/version_info.txt set_version_info: @date > $(PERSISTENT_STORAGE)/version_info.txt @echo "PADS version " $(PADS_VERSION) >> $(PERSISTENT_STORAGE)/version_info.txt .PHONY: image FUDGE=$(shell sed -n 's/PADS_RAMDISK_OVERHEAD=\(.*\)/\1/p' .config) ROOTFS_SIZE=$(shell ./utils/calc_size $(FUDGE)) DATE_TAG=$(shell date) OLD_DATE_TAG=$(shell grep IMAGE_CREATION_DATE $(PERSISTENT_STORAGE)/version_info.txt | cut -d= -f 2-) OLD_BURNDATE_TAG=$(shell grep IMAGE_CREATION_DATE= images/autorun | cut -d= -f 2- | cut -d\" -f 2) OLD_LINUX_VERSION=$(shell grep LINUX_VERSION= images/autorun | cut -d= -f 2- | cut -d\" -f 2) OLD_LINUX_BUILDNUMBER=$(shell grep LINUX_BUILDNUMBER= images/autorun | cut -d= -f 2- | cut -d\" -f 2) UBOOT_VERSION=$(shell grep UBOOT_VER= package/uboot/uboot.mk | cut -d= -f 2-) OLD_UBOOT_VERSION=$(shell grep UBOOT_VERSION= images/autorun | cut -d= -f 2- | cut -d\" -f 2) OLD_PADS_VERSION=$(shell grep PADS_VERSION= images/autorun | cut -d= -f 2- | cut -d\" -f 2) tagimages: # automatically updated the version info file with correct creation date @if [ -z "`grep IMAGE_CREATION_DATE $(PERSISTENT_STORAGE)/version_info.txt`" ]; then \ echo "IMAGE_CREATION_DATE=$(DATE_TAG)" >> $(PERSISTENT_STORAGE)/version_info.txt; \ else \ sed -i "s|$(OLD_DATE_TAG)|$(DATE_TAG)|" $(PERSISTENT_STORAGE)/version_info.txt; \ fi # automatically updated the autorun burn file with correct creation date @sed -i "s|$(OLD_BURNDATE_TAG)|$(DATE_TAG)|" images/autorun # automatically updated the autorun burn file with correct version numbers @sed -i "s|$(OLD_LINUX_VERSION)|$(LINUX_VER)|" images/autorun @sed -i "s|$(OLD_LINUX_BUILDNUMBER)|$(LINUX_BUILDNUM)|" images/autorun @sed -i "s|$(OLD_UBOOT_VERSION)|$(UBOOT_VERSION)|" images/autorun @sed -i "s|$(OLD_PADS_VERSION)|$(PADS_VERSION)|" images/autorun createimages: tagimages $(TARGETS_IMAGE) @mkdir -p images/no_trailer @if [ -n "`ls $(TARGET_DIR)/persistent/* 2>/dev/null`" ]; then \ rm -f .persistent_moved_to_flash; \ utils/persistent_to_flash.sh; \ touch .persistent_moved_to_flash; \ fi mkfs.jffs2 -n -b -p -r build_warp/persistent -e 131072 -o images/no_trailer/image.jffs2 mkfs.jffs2 -n -b -p -r build_warp/persistent1 -e 131072 -o images/no_trailer/image1.jffs2 mkfs.jffs2 -n -b -p -r build_warp/persistent2 -e 131072 -o images/no_trailer/image2.jffs2 genext2fs -U -m0 -d build_warp/root -b $(ROOTFS_SIZE) -N 2048 images/rootfs.img @gzip -v9 images/rootfs.img mkimage -T ramdisk -C gzip -n 'PIKA Warp $(PADS_VERSION)' \ -d images/rootfs.img.gz images/no_trailer/uRamdisk @rm images/rootfs.img.gz @if [ -f .persistent_moved_to_flash ]; then \ utils/persistent_to_nfs.sh; \ rm -f .persistent_moved_to_flash; \ fi @if [ `stat -c %s images/no_trailer/uRamdisk` -gt 50331648 ]; then \ echo; \ echo "WARNING!!!! Ramdisk image is too large and will not boot."; \ echo "Size must be less than 48M"; \ fi $(WARPTRAILER) -p kernel -V $(LINUX_VER)-$(LINUX_BUILDNUM) \ -o images/kernel-$(LINUX_VER)-$(LINUX_BUILDNUM).wrp images/no_trailer/cuImage.warp $(WARPTRAILER) -p root -V $(PADS_VERSION) -r $(ROOTFS_SIZE) \ -o images/ramdisk-$(PADS_VERSION).wrp images/no_trailer/uRamdisk $(WARPTRAILER) -p persistent -V $(PADS_VERSION) \ -o images/persistent-$(PADS_VERSION).wrp images/no_trailer/image.jffs2 [ -s images/no_trailer/image1.jffs2 ] && \ $(WARPTRAILER) -p persistent1 -V $(PADS_VERSION) \ -o images/persistent1-$(PADS_VERSION).wrp images/no_trailer/image1.jffs2; [ -s images/no_trailer/image2.jffs2 ] && \ $(WARPTRAILER) -p persistent2 -V $(PADS_VERSION) \ -o images/persistent2-$(PADS_VERSION).wrp images/no_trailer/image2.jffs2 ifeq ($(strip $(PADS_GDB_NOSTRIP)),y) stripimage: echo "Not stripping the image as the GDB no strip option is enabled." else stripimage: # busybox has no man application so delete man pages rm -rf $(TARGET_DIR)/usr/man rm -rf $(TARGET_DIR)/usr/share/man rm -rf $(TARGET_DIR)/usr/share/info rm -rf $(TARGET_DIR)/usr/share/emacs rm -rf $(TARGET_DIR)/usr/share/gtk-doc rm -rf $(TARGET_DIR)/usr/share/doc rm -rf $(TARGET_DIR)/usr/local/share/man rm -rf $(TARGET_DIR)/usr/include # remove static libraries, not needed on system with no compiler rm -f `find $(TARGET_DIR) -name "*.a"` rm -f `find $(TARGET_DIR) -name "*.la"` rm -f `find $(TARGET_DIR) -name "*.lo"` # strip libraries, not needed on system with no debugger @for lib in `find $(TARGET_DIR) -name "*.so*"`; do \ if [ -f $$lib ]; then \ if [[ $$lib == "$(TARGET_DIR)/lib/libpthread.so" || $$lib == "$(TARGET_DIR)/lib/libpthread.so_orig" || $$lib == "$(TARGET_DIR)/lib/libc.so" \ || $$lib == "$(TARGET_DIR)/lib/libc.so_orig" || $$lib == "$(TARGET_DIR)/lib/libc.so.6" || $$lib == "$(TARGET_DIR)/lib/libc-2.3.5.so" ]]; then \ echo "Skipping $$lib"; \ else \ $(BASE_DIR)/toolchain/usr/bin/powerpc-linux-strip --strip-all $$lib; \ fi \ fi \ done endif ifeq ($(strip $(PADS_PACKAGE_FREEPBX)),y) image: stripimage createimages else image: createimages endif images: image smallimage: stripimage image ########################################################### # # Cleanup # ########################################################## clean: $(TARGETS_CLEAN) dirclean: $(TARGETS_DIRCLEAN) rm -rf $(STAGING_DIR) $(TARGET_DIR) $(IMAGE_DIR) $(PERSISTENT_STORAGE) \ $(PERSISTENT1_STORAGE) $(PERSISTENT2_STORAGE) else # ifeq ($(strip $(PADS_HAVE_DOT_CONFIG)),y) ######################################################### # # Configuration # ######################################################### all: menuconfig endif # ifeq ($(strip $(PADS_HAVE_DOT_CONFIG)),y) $(CONFIG)/conf: $(MAKE) -C $(CONFIG) conf $(CONFIG)/mconf: $(MAKE) -C $(CONFIG) ncurses conf mconf # If a file named prebuild is present, execute it. This file # is intended for user-specific steps. If steps should only # be executed once, the user script should include steps to # touch a file and then check for its existence before executing. prebuild: @if [ -f prebuild_steps.sh ]; then \ echo; \ if [ -x prebuild_steps.sh ]; then \ echo "Executing prebuild steps."; \ ./prebuild_steps.sh; \ echo; \ else \ echo "prebuild_steps.sh is not executable"; \ echo; \ exit 1; \ fi \ fi menuconfig: $(CONFIG)/mconf prebuild @$(CONFIG)/mconf $(CONFIG_CONFIG_IN) @if [ -f .config ]; then \ ln -sf .config pads_config; \ fi defconfig: $(CONFIG)/conf prebuild @ln -sf pads_defconfig .defconfig $(CONFIG)/conf -d $(CONFIG_CONFIG_IN) @ln -sf .config pads_config oldconfig: $(CONFIG)/conf prebuild @$(CONFIG)/conf -o $(CONFIG_CONFIG_IN) @ln -sf .config pads_config # The following targets are used to switch # between default package selections easily # without needing to select/deselect using # menuconfig asteriskconfig: asteriskdefconfig menuconfig asteriskdefconfig: asteriskdefaults oldconfig freepbxconfig: freepbxdefconfig menuconfig freepbxdefconfig: freepbxdefaults oldconfig minimalconfig: minimaldefconfig menuconfig minimaldefconfig: minimaldefaults oldconfig # The following defaults targets should never # be called directly. Create your default build # by calling the config targets above. asteriskdefaults: @cp -f defconfigs/asterisk_defconfig .config freepbxdefaults: @cp -f defconfigs/freepbx_defconfig .config minimaldefaults: @cp -f defconfigs/minimal_defconfig .config postbuild: -find $(PERSISTENT_STORAGE)/etc -type d -name .svn | xargs $(RM) -r