Permalink
Browse files

fixed that generated src.rpm files can not be built

  • Loading branch information...
ahiguti committed Nov 6, 2010
1 parent 073835a commit 669b93f950b2aead4976ef0488a582318dda7fea
View
@@ -22,6 +22,7 @@ aclocal.m4
.libs
ltmain.sh
*.la
+handlersocket/Makefile.plain
handlersocket/*.spec
libhsclient/*.spec
perl-Net-HandlerSocket/*.spec
View
@@ -24,6 +24,7 @@ rpm_perl: clean_perl rpm_dir
rpm_c: clean_c rpm_dir
sed -e "s/HANDLERSOCKET_VERSION/$(VERSION)/" handlersocket/handlersocket.spec.template > handlersocket/handlersocket.spec
+ sed -e "s|HANDLERSOCKET_MYSQL_INC|$(MYSQL_INC)|" -e "s|HANDLERSOCKET_MYSQL_LIB|$(MYSQL_LIB)|" handlersocket/Makefile.plain.template > handlersocket/Makefile.plain
tar cvfz dist/handlersocket.tar.gz handlersocket
rpmbuild --define "_topdir `pwd`/dist" -ta \
dist/handlersocket.tar.gz
@@ -0,0 +1,31 @@
+
+MYSQL_INC = HANDLERSOCKET_MYSQL_INC
+MYSQL_LIB = HANDLERSOCKET_MYSQL_LIB
+
+CXX = g++ -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC
+LIBS = $(MYSQL_LIB) -lhsclient -lpthread -lz
+CXXFLAGS = -I/usr/include/handlersocket $(MYSQL_INC)
+LDFLAGS =
+
+CXXFLAGS += -O3 -DNDEBUG
+
+HANDLERSOCKET_OBJS = database.o hstcpsvr.o hstcpsvr_worker.o
+
+all: handlersocket.so
+
+handlersocket.so: $(HANDLERSOCKET_OBJS) handlersocket.cpp
+ $(CXX) $(CXXFLAGS) -fno-strict-aliasing -shared $^ -o $@ $(LDFLAGS) \
+ -Wl,-soname -Wl,$@ $(LIBS)
+clean:
+ rm -f *.a *.so *.o
+
+LIBDIR = $(shell \
+ if [ -e /usr/lib64/mysql ]; then echo /usr/lib64; else echo /usr/lib; fi)
+
+install: handlersocket.so
+ sudo sh -c 'ulimit -c unlimited ; /etc/init.d/mysql stop ; \
+ cp handlersocket.so handlersocket.so.cpy && \
+ mv handlersocket.so.cpy \
+ $(LIBDIR)/mysql/plugin/handlersocket.so && \
+ /etc/init.d/mysql start'
+
@@ -16,18 +16,12 @@ BuildRoot: /var/tmp/%{name}-%{version}-root
%define _use_internal_dependency_generator 0
%build
-# FIXME
-TOP_SRC=`pwd`/../../..
-T=`echo $TOP_SRC | sed "s/\//\\\\\\\\\//g"`
-sed -e "s/top_srcdir =.*/top_srcdir =$T/" -e "s/top_builddir =.*/top_builddir =$T/" Makefile > Makefile.2
-rm -f Makefile
-mv Makefile.2 Makefile
-make
+make -f Makefile.plain
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/%{_libdir}/mysql/plugin
-install -m 755 .libs/handlersocket.so $RPM_BUILD_ROOT/%{_libdir}/mysql/plugin/
+install -m 755 handlersocket.so $RPM_BUILD_ROOT/%{_libdir}/mysql/plugin/
%files
%defattr(-, root, root)
View
@@ -0,0 +1,27 @@
+
+CXX = g++ -Wall -g -fno-rtti -fno-exceptions -fPIC -DPIC
+LDFLAGS =
+
+CXXFLAGS += -O3 -DNDEBUG
+
+COMMON_OBJS = config.o fatal.o socket.o string_util.o escape.o
+HSCLIENT_OBJS = $(COMMON_OBJS) hstcpcli.o
+
+all: libhsclient.a
+
+libhsclient.a: $(HSCLIENT_OBJS)
+ $(AR) rc $@ $^
+ $(AR) s $@
+
+clean:
+ rm -f *.a *.so *.o
+
+LIBDIR = $(shell \
+ if [ -e /usr/lib64/mysql ]; then echo /usr/lib64; else echo /usr/lib; fi)
+
+install: libhsclient.a
+ sudo sh -c 'cp libhsclient.a libhsclient.a.cpy && \
+ mv libhsclient.a.cpy $(LIBDIR)/libhsclient.a && \
+ mkdir -p /usr/include/handlersocket && \
+ cp -a *.hpp /usr/include/handlersocket/'
+
@@ -16,21 +16,14 @@ BuildRoot: /var/tmp/%{name}-%{version}-root
%define _use_internal_dependency_generator 0
%build
-# FIXME
-TOP_SRC=`pwd`/../../..
-T=`echo $TOP_SRC | sed "s/\//\\\\\\\\\//g"`
-sed -e "s/top_srcdir =.*/top_srcdir =$T/" -e "s/top_builddir =.*/top_builddir =$T/" Makefile > Makefile.2
-rm -f Makefile
-mv Makefile.2 Makefile
-make
+make -f Makefile.plain
%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/usr/include/handlersocket
mkdir -p $RPM_BUILD_ROOT/%{_bindir}
mkdir -p $RPM_BUILD_ROOT/%{_libdir}
-install -m 755 .libs/libhsclient.so $RPM_BUILD_ROOT/%{_libdir}
-install -m 755 .libs/libhsclient.a $RPM_BUILD_ROOT/%{_libdir}
+install -m 755 libhsclient.a $RPM_BUILD_ROOT/%{_libdir}
install -m 644 *.hpp $RPM_BUILD_ROOT/usr/include/handlersocket/
%post
@@ -42,6 +35,5 @@ install -m 644 *.hpp $RPM_BUILD_ROOT/usr/include/handlersocket/
%files
%defattr(-, root, root)
/usr/include/*
-%{_libdir}/*.so
%{_libdir}/*.a
@@ -13,8 +13,7 @@ WriteMakefile(
LD => 'g++ -fPIC',
LIBS => ['-L../libhsclient/.libs -lhsclient'], # e.g., '-lm'
DEFINE => '', # e.g., '-DHAVE_SOMETHING'
- # FIXME
- INC => '-I. -I/usr/include/handlersocket -I../libhsclient',
+ INC => '-I. -I../libhsclient',
OPTIMIZE => '-g -O3 -Wall -Wno-unused',
# Un-comment this if you add C files to link with later:
# OBJECT => '$(O_FILES)', # link all the C files too
@@ -0,0 +1,20 @@
+# use 5.010000;
+use ExtUtils::MakeMaker;
+# See lib/ExtUtils/MakeMaker.pm for details of how to influence
+# the contents of the Makefile that is written.
+WriteMakefile(
+ NAME => 'Net::HandlerSocket',
+ VERSION_FROM => 'lib/Net/HandlerSocket.pm', # finds $VERSION
+ PREREQ_PM => {}, # e.g., Module::Name => 1.1
+ ($] >= 5.005 ? ## Add these new keywords supported since 5.005
+ (ABSTRACT_FROM => 'lib/Net/HandlerSocket.pm', # retrieve abstract from module
+ AUTHOR => 'higuchi dot akira at dena dot jp>') : ()),
+ CC => 'g++ -fPIC',
+ LD => 'g++ -fPIC',
+ LIBS => ['-lhsclient'], # e.g., '-lm'
+ DEFINE => '', # e.g., '-DHAVE_SOMETHING'
+ INC => '-I. -I/usr/include/handlersocket',
+ OPTIMIZE => '-g -O3 -Wall -Wno-unused',
+ # Un-comment this if you add C files to link with later:
+ # OBJECT => '$(O_FILES)', # link all the C files too
+);
@@ -46,7 +46,7 @@ grep -rsl '^#!.*perl' . |
grep -v '.bak$' |xargs --no-run-if-empty \
%__perl -MExtUtils::MakeMaker -e 'MY->fixin(@ARGV)'
CFLAGS="$RPM_OPT_FLAGS"
-%{__perl} Makefile.PL `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '`
+%{__perl} Makefile.PL.installed `%{__perl} -MExtUtils::MakeMaker -e ' print qq|PREFIX=%{buildroot}%{_prefix}| if \$ExtUtils::MakeMaker::VERSION =~ /5\.9[1-6]|6\.0[0-5]/ '`
%{__make}
%if %maketest
%{__make} test

0 comments on commit 669b93f

Please sign in to comment.