# # params.inc.mak # # Common macro definitions for building OCS # # See ocs-kit-base/Makefile for sample Makefile used to build kit downloaders # # Note: This file is used also in base/kit/packages. Ensure changes are # reflected there as necessary # ifndef PREBUILT_ROOT_DIR PREBUILT_ROOT_DIR=/pcc/lsf_madison/Emerald/kit-source endif PREBUILT_RPMDIR_NOARCH=$(PREBUILT_ROOT_DIR)/$(KITNAME)/noarch PREBUILT_RPMDIR_X86=$(PREBUILT_ROOT_DIR)/$(KITNAME)/i386 PREBUILT_RPMDIR_X86_64=$(PREBUILT_ROOT_DIR)/$(KITNAME)/x86_64 ifndef BUILDISO BUILDISO=/space/kusu/rhel/kusu-20071212051206-2923.rhel-5.x86_64.iso endif TMPDIR=/tmp # SPECFILE must be fully-qualified; use the built-in naming convention # whenever possible for consistency ifndef SPECFILE SPECFILE=$(PWD)/$(NAME).spec endif BUILDROOT=$(TMPDIR)/$(NAME)-build RPMSRCROOT=$(BUILDROOT)/$(NAME) # if VERSION needs to be defined differently than what exists in the .spec # file, it can be overridden ifndef VERSION VERSION = $(shell grep ^Version: $(SPECFILE) | awk '{print $$2}') endif ifndef RELEASE RELEASE = $(shell grep ^Release: $(SPECFILE) | awk '{print $$2}') endif ARCH = $(shell arch) ifdef TARREV TGZBASENAME=$(NAME)-$(VERSION).$(TARREV) else TGZBASENAME=$(NAME)-$(VERSION) endif TGZFILENAME=$(TMPDIR)/$(TGZBASENAME).tar.gz ifndef TOPDIR RPMBUILD=rpmbuild else RPMBUILD=rpmbuild --define "_topdir $(TOPDIR)" endif RPMBUILD_TARBALL=$(RPMBUILD) -ta SRPMBUILD_TARBALL=$(RPMBUILD) -ts # # The 'builddirs' target creates a "workspace" for generating the SRPM # # Essentially "/tmp/-build/ is the root directory # for the SRPM. All files put there are included in the tar.gz used # to create the SRM. # ifdef TOPDIR rpm: rpmdirs create_tarball else rpm: create_tarball endif $(RPMBUILD_TARBALL) $(TGZFILENAME) rm -f $(TGZFILENAME) ifdef TOPDIR srpm: rpmdirs create_tarball else srpm: create_tarball endif $(SRPMBUILD_TARBALL) $(TGZFILENAME) rm -f $(TGZFILENAME) create_tarball: builddirs preprpm ( cd $(BUILDROOT); tar czf $(TGZFILENAME) $(NAME) ) rm -rf $(BUILDROOT) builddirs: rm -rf $(BUILDROOT) && mkdir -p $(RPMSRCROOT) # Generic target to update the release number in the spec file defined # by $(SPECFILE) update: awk -f ../scripts/updrel.awk $(SPECFILE) >$(SPECFILE).new mv $(SPECFILE).new $(SPECFILE) rpmlint: rpmlint -v $(SPECFILE) rpmdirs: $(TOPDIR)/BUILD $(TOPDIR)/SRPMS $(TOPDIR)/SPECS $(TOPDIR)/RPMS $(TOPDIR)/BUILD: mkdir $(TOPDIR)/BUILD $(TOPDIR)/SRPMS: mkdir $(TOPDIR)/SRPMS $(TOPDIR)/SPECS: mkdir $(TOPDIR)/SPECS $(TOPDIR)/RPMS: mkdir $(TOPDIR)/RPMS # Rule for checking if target RPMs exist before building them. # Must set RPMTARGETS in calling Makefile. ifndef RPMTARGETS RPMTARGETS=$(NAME)-$(VERSION)-$(RELEASE).$(ARCH).rpm endif get_prebuilt_rpms: @echo "Copy over prebuilt RPMs (if they exist)..." @for p in $(RPMTARGETS); do \ if [ -f "$(PREBUILT_RPMDIR_NOARCH)/$$p" ]; then \ echo " Found prebuilt RPM: $(PREBUILT_RPMDIR_NOARCH)/$$p"; \ cp "$(PREBUILT_RPMDIR_NOARCH)/$$p" $(TOPDIR)/RPMS/noarch; \ elif [ -f "$(PREBUILT_RPMDIR_X86)/$$p" ]; then \ echo " Found prebuilt RPM: $(PREBUILT_RPMDIR_X86)/$$p"; \ cp "$(PREBUILT_RPMDIR_X86)/$$p" $(TOPDIR)/RPMS/i386; \ elif [ -f "$(PREBUILT_RPMDIR_X86_64)/$$p" ]; then \ echo " Found prebuilt RPM: $(PREBUILT_RPMDIR_X86_64)/$$p"; \ cp "$(PREBUILT_RPMDIR_X86_64)/$$p" $(TOPDIR)/RPMS/x86_64; \ fi; \ done check_and_build_rpms: get_prebuilt_rpms @echo "Check if target RPMs exist..."; \ rebuild=0; \ for p in $(RPMTARGETS); do \ if [ `find $(TOPDIR)/RPMS -name $$p | wc -l` -ne 0 ]; then \ echo " Package $$p exists."; \ else \ echo " Package $$p does not exist."; \ rebuild=1; \ fi; \ done; \ if [ $$rebuild -eq 1 ]; then \ make rpm; \ else \ echo "All target RPMs exist. No RPMs will be rebuilt."; \ echo "Only rebuilding source RPM..."; \ make srpm; \ fi # Rule for cleaning target RPMs. # Must set RPMTARGETS in calling Makefile. clean_rpms: @echo "Cleaning up RPMs and SRPMs..."; -@for p in $(RPMTARGETS); do \ find $(TOPDIR)/RPMS -name $$p -exec rm -f {} \; ; \ srpm=`echo $$p | sed -e 's/\..*\.rpm//'`.src.rpm; \ find $(TOPDIR)/SRPMS -name $$srpm -exec rm -f {} \; ; \ done