2009-10-20 00:31:17 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2009 Mark Heily <mark@heily.com>
|
|
|
|
#
|
|
|
|
# Permission to use, copy, modify, and distribute this software for any
|
|
|
|
# purpose with or without fee is hereby granted, provided that the above
|
|
|
|
# copyright notice and this permission notice appear in all copies.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
#
|
2009-11-08 02:04:16 +00:00
|
|
|
|
2009-11-07 20:29:41 +00:00
|
|
|
REPOSITORY=svn+ssh://mark.heily.com/$$HOME/svn/$(PROGRAM)
|
2009-11-07 21:13:59 +00:00
|
|
|
DIST=heily.com:$$HOME/public_html/$(PROGRAM)/dist
|
2009-11-26 06:09:44 +00:00
|
|
|
DISTFILE=$(PROGRAM)-$(VERSION).tar.gz
|
2009-10-20 00:31:17 +00:00
|
|
|
|
|
|
|
include config.mk
|
|
|
|
|
2011-05-01 20:25:07 +00:00
|
|
|
.PHONY :: install uninstall check dist dist-upload clean merge distclean fresh-build rpm edit cscope
|
2009-11-25 01:17:14 +00:00
|
|
|
|
2011-05-26 03:45:28 +00:00
|
|
|
all: $(PROGRAM).so.$(ABI_VERSION) $(PROGRAM)_debug.so $(PROGRAM).a $(PROGRAM)_debug.a
|
2010-01-30 04:42:20 +00:00
|
|
|
|
2009-11-25 01:04:27 +00:00
|
|
|
%.o: %.c $(DEPS)
|
2011-05-22 02:44:16 +00:00
|
|
|
$(CC) -c -o $@ -I./include -I./src/common -DNDEBUG $(CFLAGS) $<
|
2009-11-25 01:04:27 +00:00
|
|
|
|
2011-05-22 03:01:24 +00:00
|
|
|
$(PROGRAM).a:
|
|
|
|
rm -f *.o
|
|
|
|
$(CC) -c -I./include -I./src/common -DNDEBUG -DMAKE_STATIC=1 -static $(CFLAGS) $(SOURCES) $(LDADD)
|
|
|
|
$(AR) rcs $(PROGRAM).a *.o
|
2011-05-22 03:29:14 +00:00
|
|
|
$(STRIP) $(PROGRAM).a
|
2011-05-22 03:01:24 +00:00
|
|
|
rm *.o
|
2010-01-30 01:52:50 +00:00
|
|
|
|
2011-05-26 03:45:28 +00:00
|
|
|
$(PROGRAM)_debug.a:
|
|
|
|
rm -f *.o
|
|
|
|
$(CC) -c -I./include -I./src/common -DMAKE_STATIC=1 -pg -static $(CFLAGS) $(SOURCES) $(LDADD)
|
|
|
|
$(AR) rcs $(PROGRAM)_debug.a *.o
|
|
|
|
rm *.o
|
|
|
|
|
2011-01-15 19:13:10 +00:00
|
|
|
$(PROGRAM).so.$(ABI_VERSION): $(OBJS)
|
2011-05-22 02:44:16 +00:00
|
|
|
$(CC) -o $@ -I./include -I./src/common -shared $(LDFLAGS) -DNDEBUG $(CFLAGS) $(SOURCES) $(LDADD)
|
2011-05-22 03:29:14 +00:00
|
|
|
$(STRIP) $(PROGRAM).so.$(ABI_VERSION)
|
2011-01-15 19:13:10 +00:00
|
|
|
$(LN) -sf $(PROGRAM).so.$(ABI_VERSION) $(PROGRAM).so.$(ABI_MAJOR)
|
2010-04-03 16:18:42 +00:00
|
|
|
$(LN) -sf $(PROGRAM).so.$(ABI_VERSION) $(PROGRAM).so
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2011-05-22 02:44:16 +00:00
|
|
|
$(PROGRAM)_debug.so:
|
2011-05-25 02:10:36 +00:00
|
|
|
$(CC) -o $@ -I./include -I./src/common -shared -rdynamic $(CFLAGS) -g3 -O0 $(SOURCES) $(LDADD)
|
2011-05-22 02:44:16 +00:00
|
|
|
|
|
|
|
install: all
|
2009-11-01 19:06:43 +00:00
|
|
|
$(INSTALL) -d -m 755 $(INCLUDEDIR)/kqueue/sys
|
2009-11-08 00:59:36 +00:00
|
|
|
$(INSTALL) -m 644 include/sys/event.h $(INCLUDEDIR)/kqueue/sys/event.h
|
2009-11-07 19:24:32 +00:00
|
|
|
$(INSTALL) -d -m 755 $(LIBDIR)
|
2010-04-03 16:18:42 +00:00
|
|
|
$(INSTALL) -m 644 $(PROGRAM).so.$(ABI_VERSION) $(LIBDIR)
|
2011-01-15 19:13:10 +00:00
|
|
|
$(INSTALL) -m 644 $(PROGRAM).so.$(ABI_MAJOR) $(LIBDIR)
|
2010-04-03 16:18:42 +00:00
|
|
|
$(LN) -sf $(PROGRAM).so.$(ABI_VERSION) $(LIBDIR)/$(PROGRAM).so.$(ABI_MAJOR)
|
|
|
|
$(LN) -sf $(PROGRAM).so.$(ABI_VERSION) $(LIBDIR)/$(PROGRAM).so
|
2011-05-22 02:44:16 +00:00
|
|
|
$(INSTALL) -m 644 $(PROGRAM)_debug.so $(LIBDIR)
|
2009-11-06 00:18:53 +00:00
|
|
|
$(INSTALL) -d -m 755 $(LIBDIR)/pkgconfig
|
2009-11-01 19:06:43 +00:00
|
|
|
$(INSTALL) -m 644 libkqueue.pc $(LIBDIR)/pkgconfig
|
2009-11-06 00:18:53 +00:00
|
|
|
$(INSTALL) -d -m 755 $(MANDIR)/man2
|
2009-11-01 19:06:43 +00:00
|
|
|
$(INSTALL) -m 644 kqueue.2 $(MANDIR)/man2/kqueue.2
|
|
|
|
$(INSTALL) -m 644 kqueue.2 $(MANDIR)/man2/kevent.2
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2009-11-01 17:48:45 +00:00
|
|
|
uninstall:
|
2009-11-01 19:06:43 +00:00
|
|
|
rm -f $(INCLUDEDIR)/kqueue/sys/event.h
|
|
|
|
rm -f $(LIBDIR)/libkqueue.so
|
|
|
|
rm -f $(LIBDIR)/pkgconfig/libkqueue.pc
|
|
|
|
rm -f $(MANDIR)/man2/kqueue.2
|
|
|
|
rm -f $(MANDIR)/man2/kevent.2
|
|
|
|
rmdir $(INCLUDEDIR)/kqueue/sys $(INCLUDEDIR)/kqueue
|
2009-11-01 17:48:45 +00:00
|
|
|
|
2011-04-23 18:27:10 +00:00
|
|
|
test/config.mk:
|
|
|
|
cd test && ../configure
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2011-05-26 03:45:28 +00:00
|
|
|
check: test/config.mk
|
2011-04-23 18:27:10 +00:00
|
|
|
cd test && make check
|
2011-02-01 02:40:59 +00:00
|
|
|
|
2011-05-26 03:45:28 +00:00
|
|
|
profile: clean $(PROGRAM)_debug.a
|
|
|
|
cd test && ./kqtest
|
|
|
|
|
2011-05-22 02:44:16 +00:00
|
|
|
debug: clean all test/config.mk
|
2011-04-23 18:27:10 +00:00
|
|
|
cd test && make debug
|
|
|
|
|
|
|
|
debug-check: clean test/config.mk
|
2011-04-27 03:30:31 +00:00
|
|
|
cd test && KQUEUE_DEBUG=yes make check
|
2010-09-17 02:02:31 +00:00
|
|
|
|
2010-02-10 03:00:43 +00:00
|
|
|
$(DISTFILE): $(SOURCES) $(HEADERS)
|
2009-11-06 04:03:26 +00:00
|
|
|
mkdir $(PROGRAM)-$(VERSION)
|
2009-11-11 02:41:45 +00:00
|
|
|
cp Makefile ChangeLog configure config.inc \
|
|
|
|
$(MANS) $(EXTRA_DIST) \
|
2009-11-06 04:03:26 +00:00
|
|
|
$(PROGRAM)-$(VERSION)
|
|
|
|
cp -R $(SUBDIRS) $(PROGRAM)-$(VERSION)
|
2009-11-26 06:20:10 +00:00
|
|
|
rm -rf `find $(PROGRAM)-$(VERSION) -type d -name .svn -o -name .libs`
|
2010-02-10 03:06:47 +00:00
|
|
|
cd $(PROGRAM)-$(VERSION) && ./configure && cd test && ./configure && cd .. && make distclean
|
2009-11-06 04:03:26 +00:00
|
|
|
tar zcf $(PROGRAM)-$(VERSION).tar.gz $(PROGRAM)-$(VERSION)
|
|
|
|
rm -rf $(PROGRAM)-$(VERSION)
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2009-11-26 06:09:44 +00:00
|
|
|
dist:
|
|
|
|
rm -f $(DISTFILE)
|
|
|
|
make $(DISTFILE)
|
|
|
|
|
2010-09-18 18:52:15 +00:00
|
|
|
dist-upload: $(DISTFILE)
|
|
|
|
scp $(DISTFILE) $(DIST)
|
2009-11-07 21:13:59 +00:00
|
|
|
|
2009-10-20 00:31:17 +00:00
|
|
|
clean:
|
2011-01-15 19:13:10 +00:00
|
|
|
rm -f tags *.a *.so *.so.* *.so.*.*
|
2010-09-18 18:52:15 +00:00
|
|
|
find src -name '*.o' -exec rm {} \;
|
2010-06-09 03:25:20 +00:00
|
|
|
rm -rf pkg
|
2009-12-14 00:13:10 +00:00
|
|
|
cd test && make clean || true
|
2009-10-20 00:31:17 +00:00
|
|
|
|
2010-06-09 03:25:20 +00:00
|
|
|
distclean: clean
|
|
|
|
rm -f *.tar.gz config.mk config.h $(PROGRAM).pc $(PROGRAM).la rpm.spec
|
|
|
|
rm -rf $(PROGRAM)-$(VERSION) 2>/dev/null || true
|
|
|
|
|
2009-11-25 01:09:55 +00:00
|
|
|
fresh-build:
|
|
|
|
rm -rf /tmp/$(PROGRAM)-testbuild
|
|
|
|
svn co svn://mark.heily.com/libkqueue/trunk /tmp/$(PROGRAM)-testbuild
|
|
|
|
cd /tmp/$(PROGRAM)-testbuild && ./configure && make check
|
|
|
|
rm -rf /tmp/$(PROGRAM)-testbuild
|
|
|
|
|
2009-11-07 20:29:41 +00:00
|
|
|
merge:
|
|
|
|
svn diff $(REPOSITORY)/branches/stable $(REPOSITORY)/trunk | gvim -
|
|
|
|
@printf "Merge changes from the trunk to the stable branch [y/N]? "
|
|
|
|
@read x && test "$$x" = "y"
|
2009-11-07 21:02:10 +00:00
|
|
|
echo "ok"
|
2009-11-07 20:29:41 +00:00
|
|
|
|
2010-02-10 01:32:49 +00:00
|
|
|
tags: $(SOURCES) $(HEADERS)
|
2010-02-08 03:09:57 +00:00
|
|
|
ctags $(SOURCES) $(HEADERS)
|
2010-02-10 01:32:49 +00:00
|
|
|
|
|
|
|
edit: tags
|
|
|
|
$(EDITOR) $(SOURCES) $(HEADERS)
|
2010-01-24 23:39:45 +00:00
|
|
|
|
2010-02-10 01:32:49 +00:00
|
|
|
cscope: tags
|
2010-02-08 03:09:57 +00:00
|
|
|
cscope $(SOURCES) $(HEADERS)
|
2010-02-03 01:33:55 +00:00
|
|
|
|
2010-09-15 02:50:30 +00:00
|
|
|
# Creates an ~/rpmbuild tree
|
|
|
|
rpmbuild:
|
2010-09-17 02:02:31 +00:00
|
|
|
mkdir -p $$HOME/rpmbuild
|
|
|
|
cd $$HOME/rpmbuild && mkdir -p BUILD RPMS SOURCES SPECS SRPMS
|
2010-09-15 02:50:30 +00:00
|
|
|
grep _topdir $$HOME/.rpmmacros || \
|
|
|
|
echo "%_topdir %(echo $$HOME/rpmbuild)" >> $$HOME/.rpmmacros
|
|
|
|
|
|
|
|
rpm: rpmbuild clean $(DISTFILE)
|
2010-09-15 02:24:34 +00:00
|
|
|
mkdir -p pkg
|
2010-09-15 02:50:30 +00:00
|
|
|
cp $(DISTFILE) $$HOME/rpmbuild/SOURCES
|
|
|
|
rpmbuild -bb rpm.spec
|
|
|
|
find $$HOME/rpmbuild -name '$(PROGRAM)-$(VERSION)*.rpm' -exec mv {} ./pkg \;
|
2009-11-26 06:09:44 +00:00
|
|
|
|
2010-03-28 00:29:59 +00:00
|
|
|
deb: clean $(DISTFILE)
|
2010-06-09 03:25:20 +00:00
|
|
|
mkdir pkg && cd pkg ; \
|
|
|
|
tar zxf ../$(DISTFILE) ; \
|
|
|
|
cp ../$(DISTFILE) $(PROGRAM)_$(VERSION).orig.tar.gz ; \
|
|
|
|
cp -R ../ports/debian $(PROGRAM)-$(VERSION) ; \
|
2010-06-09 03:48:14 +00:00
|
|
|
rm -rf `find $(PROGRAM)-$(VERSION)/debian -type d -name .svn` ; \
|
2010-06-09 03:41:18 +00:00
|
|
|
perl -pi -e 's/\@\@VERSION\@\@/$(VERSION)/' $(PROGRAM)-$(VERSION)/debian/changelog ; \
|
2010-06-09 03:25:20 +00:00
|
|
|
cd $(PROGRAM)-$(VERSION) && dpkg-buildpackage -uc -us
|
2010-06-09 03:28:23 +00:00
|
|
|
lintian -i pkg/*.deb
|
|
|
|
@printf "\nThe following packages have been created:\n"
|
|
|
|
@find ./pkg -name '*.deb' | sed 's/^/ /'
|
2010-03-28 00:29:59 +00:00
|
|
|
|
2009-12-20 05:39:39 +00:00
|
|
|
debug-install:
|
|
|
|
./configure --prefix=/usr --debug=yes
|
|
|
|
make clean && make && sudo make install
|
2010-01-30 05:11:40 +00:00
|
|
|
|
|
|
|
diff:
|
|
|
|
if [ "`pwd | grep /trunk`" != "" ] ; then \
|
|
|
|
(cd .. ; $(DIFF) branches/stable trunk | less) ; \
|
|
|
|
fi
|
|
|
|
if [ "`pwd | grep /branches/stable`" != "" ] ; then \
|
|
|
|
(cd ../.. ; $(DIFF) branches/stable trunk | less) ; \
|
|
|
|
fi
|
2010-08-25 23:44:52 +00:00
|
|
|
|
2011-01-08 21:49:29 +00:00
|
|
|
# Used for testing on a Solaris guest VM
|
2010-08-26 00:32:09 +00:00
|
|
|
#
|
2011-01-08 21:49:29 +00:00
|
|
|
solaris-test:
|
2011-02-12 22:16:58 +00:00
|
|
|
make dist && scp -P 2222 libkqueue-$(VERSION).tar.gz localhost:/tmp && ssh -p 2222 localhost ". .profile ; cd /tmp ; rm -rf libkqueue-$(VERSION) ; gtar zxvf libkqueue-$(VERSION).tar.gz && cd libkqueue-$(VERSION) && ./configure && make && make check"
|