1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
CFLAGS := -g -O2 -Wall
INSTALL := install
DESTDIR :=
ETCDIR := /etc
BINDIR := /bin
SBINDIR := /sbin
SPECFILE := redhat/cachefilesd.spec
LNS := ln -sf
###############################################################################
#
# Determine the current package version from the specfile
#
###############################################################################
VERSION := $(word 2,$(shell grep "^Version:" $(SPECFILE)))
TARBALL := cachefilesd-$(VERSION).tar.bz2
###############################################################################
#
# Guess at the appropriate word size
#
###############################################################################
BUILDFOR := $(shell file /usr/bin/make | sed -e 's!.*ELF \(32\|64\)-bit.*!\1!')-bit
ifeq ($(BUILDFOR),32-bit)
CFLAGS += -m32
else
ifeq ($(BUILDFOR),64-bit)
CFLAGS += -m64
endif
endif
###############################################################################
#
# Build stuff
#
###############################################################################
all: cachefilesd
cachefilesd: cachefilesd.c Makefile
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ $<
###############################################################################
#
# Install everything
#
###############################################################################
MAN5 := $(DESTDIR)/usr/share/man/man5
MAN8 := $(DESTDIR)/usr/share/man/man8
install: all
$(INSTALL) -D cachefilesd $(DESTDIR)$(SBINDIR)/cachefilesd
$(INSTALL) -D -m 0644 cachefilesd.conf $(DESTDIR)$(ETCDIR)/cachefilesd.conf
$(INSTALL) -D -m 0644 cachefilesd.conf.5 $(MAN5)/cachefilesd.conf.5
$(INSTALL) -D -m 0644 cachefilesd.8 $(MAN8)/cachefilesd.8
###############################################################################
#
# Clean up
#
###############################################################################
clean:
$(RM) cachefilesd
$(RM) *.o *~
$(RM) debugfiles.list debugsources.list
distclean: clean
$(RM) -r rpmbuild $(TARBALL)
###############################################################################
#
# Generate a tarball
#
###############################################################################
$(TARBALL):
git archive --prefix=cachefilesd-$(VERSION)/ --format tar -o $(TARBALL) HEAD
tarball: $(TARBALL)
###############################################################################
#
# Generate an RPM
#
###############################################################################
SRCBALL := rpmbuild/SOURCES/$(TARBALL)
BUILDID := .local
dist := $(word 2,$(shell grep "%dist" /etc/rpm/macros.dist))
release := $(word 2,$(shell grep ^Release: $(SPECFILE)))
release := $(subst %{?dist},$(dist),$(release))
release := $(subst %{?buildid},$(BUILDID),$(release))
rpmver := $(VERSION)-$(release)
SRPM := rpmbuild/SRPMS/cachefilesd-$(rpmver).src.rpm
RPMBUILDDIRS := \
--define "_srcrpmdir $(CURDIR)/rpmbuild/SRPMS" \
--define "_rpmdir $(CURDIR)/rpmbuild/RPMS" \
--define "_sourcedir $(CURDIR)/rpmbuild/SOURCES" \
--define "_specdir $(CURDIR)/rpmbuild/SPECS" \
--define "_builddir $(CURDIR)/rpmbuild/BUILD" \
--define "_buildrootdir $(CURDIR)/rpmbuild/BUILDROOT"
RPMFLAGS := \
--define "buildid $(BUILDID)"
rpm:
mkdir -p rpmbuild
chmod ug-s rpmbuild
mkdir -p rpmbuild/{SPECS,SOURCES,BUILD,BUILDROOT,RPMS,SRPMS}
git archive --prefix=cachefilesd-$(VERSION)/ --format tar -o $(SRCBALL) HEAD
rpmbuild -ts $(SRCBALL) --define "_srcrpmdir rpmbuild/SRPMS" $(RPMFLAGS)
rpmbuild --rebuild $(SRPM) $(RPMBUILDDIRS) $(RPMFLAGS)
rpmlint: rpm
rpmlint $(SRPM) $(CURDIR)/rpmbuild/RPMS/*/cachefilesd-{,debuginfo-}$(rpmver).*.rpm
###############################################################################
#
# Build debugging
#
###############################################################################
show_vars:
@echo VERSION=$(VERSION)
@echo TARBALL=$(TARBALL)
@echo BUILDFOR=$(BUILDFOR)
|