rh 401-RPMパッケージ例-Makefileファイル1部とそれに対応するhello.specファイル


Makefile:
#
# Makefile for the "hello" open source library and application
#

VERSION=1.0
CC=gcc
CFLAGS=-O2

.PHONY: libhello all

all: hello

hello: libhello.so.1 hello.o
	$(CC) $(CFLAGS) hello.o -L. -lhello -o hello

hello.o: libhello.h

libhello: libhello.so.1

libhello.so.1: libhello.o
	$(CC) -shared -Wl,-soname,libhello.so.1 libhello.o -lc -o libhello.so.1.0
	ln -sf libhello.so.1.0 libhello.so.1
	ln -sf libhello.so.1   libhello.so

libhello.o: libhello.h
	$(CC) $(CFLAGS) -fPIC -c libhello.c

clean:
	rm -f *.o *.so* hello hello*.tar.gz

tar: clean
	cd ..; tar czvf hello-$(VERSION).tar.gz --exclude .svn hello-$(VERSION)

install: all
	install libhello.so.1.0	/usr/local/lib
	ln -sf libhello.so.1.0	/usr/local/lib/libhello.so.1
	ln -sf libhello.so.1	/usr/local/lib/libhello.so
	install hello		/usr/local/bin
	install hello.1		/usr/local/share/man/man1
#	install hello.conf	/etc/ld.so.conf.d
	/sbin/ldconfig

uninstall:
	rm -f /usr/local/lib/libhello.so*
	rm -f /usr/local/bin/hello
	rm -f /usr/local/share/man/man1/hello.1
#	rm -f /etc/ld.so.conf.d/hello.conf
	/sbin/ldconfig


hello.spec
Summary: Hello motivational software
Name: hello
Version: 1.0
Release: 1
License: Freely redistributable without restriction
Group: Applications/Productivity
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root

%description
hello is a soft skills enhancement application
used by well-managed organizations worldwide.

%prep
%setup -q

%build
make

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/local/{bin,lib,share/man/man1}
mkdir -p $RPM_BUILD_ROOT/etc/ld.so.conf.d
install libhello.so.1.0 $RPM_BUILD_ROOT/usr/local/lib
install hello $RPM_BUILD_ROOT/usr/local/bin
gzip -9c hello.1 > hello.1.gz
install hello.1.gz $RPM_BUILD_ROOT/usr/local/share/man/man1
install hello.conf $RPM_BUILD_ROOT/etc/ld.so.conf.d

%clean
make clean
rm -rf $RPM_BUILD_ROOT


%files
%defattr(-,root,root,-)
%config(noreplace) /etc/ld.so.conf.d/hello.conf
/usr/local/bin/hello
/usr/local/lib/libhello.so.1.0
%doc /usr/local/share/man/man1/hello.1.gz
%doc README


%post
ln -sf libhello.so.1.0 /usr/local/lib/libhello.so.1
ln -sf libhello.so.1 /usr/local/lib/libhello.so
/sbin/ldconfig


%changelog
* Wed Jan 27 2010 Charles Channelman <[email protected]> - 1.0-1
- Initial build.

関連リソースのダウンロード:
http://download.csdn.net/detail/t0nsha/4559332