From bf7ce0a305076823d705149ae3f8717cbeed2ec8 Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Tue, 7 Mar 2006 20:23:40 +0000 Subject: [PATCH] Started to switch to a Makefile-based build system (still very incomplete, so the Jamfile are still there). Set a few svn:ignore properties. --- .gitignore | 10 +++ Makefile | 57 +++++++++++++++ Makefile.common | 40 +++++++++++ configure.make | 147 +++++++++++++++++++++++++++++++++++++++ libtransmission/Makefile | 24 +++++++ macosx/Makefile | 14 ++++ 6 files changed, 292 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 Makefile.common create mode 100755 configure.make create mode 100644 libtransmission/Makefile create mode 100644 macosx/Makefile diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..71c1ecf58 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/.depend +/Makefile.config +libtransmission/*.a +libtransmission/.depend +macosx/English.lproj/*~.nib +macosx/Info.plist +macosx/Transmission.xcodeproj/*.mode1 +macosx/Transmission.xcodeproj/*.pbxuser +macosx/build +/transmissioncli diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..7186d3197 --- /dev/null +++ b/Makefile @@ -0,0 +1,57 @@ +include Makefile.config +include Makefile.common + +SRCS = transmissioncli.c +OBJS = $(SRCS:%.c=%.o) + +CFLAGS += -Ilibtransmission + +all: transmissioncli +ifeq ($(SYSTEM),Darwin) + $(MAKE) -C macosx +endif + +transmissioncli: lib $(OBJS) + $(CC) -o $@ $(OBJS) libtransmission/libtransmission.a $(LDFLAGS) + +lib: + $(MAKE) -C libtransmission + +%.o: %.c Makefile.config Makefile.common Makefile + $(CC) $(CFLAGS) -o $@ -c $< + +package-macosx: + $(RM) tmp "Transmission $(VERSION_STRING)" \ + Transmission-$(VERSION_STRING).dmg && \ + mkdir -p tmp/Transmission.app && \ + ditto macosx/build/Debug/Transmission.app tmp/Transmission.app && \ + ditto AUTHORS tmp/AUTHORS.txt && \ + ditto LICENSE tmp/LICENSE.txt && \ + ditto NEWS tmp/NEWS.txt && \ + strip -S tmp/Transmission.app/Contents/MacOS/Transmission && \ + ( echo "[InternetShortcut]"; \ + echo "URL=http://transmission.m0k.org/" ) > \ + tmp/Homepage.url && \ + ( echo "[InternetShortcut]"; \ + echo "URL=http://transmission.m0k.org/forum/" ) > \ + tmp/Forums.url && \ + ( echo "[InternetShortcut]"; \ + echo "URL=http://transmission.m0k.org/contribute.php" ) > \ + tmp/Contribute.url && \ + mv tmp "Transmission $(VERSION_STRING)" && \ + hdiutil create -format UDZO -srcfolder \ + "Transmission $(VERSION_STRING)" Transmission-$(VERSION_STRING).dmg && \ + rm -rf "Transmission $(VERSION_STRING)" + +clean: + $(RM) transmissioncli $(OBJS) + $(MAKE) -C libtransmission clean +ifeq ($(SYSTEM),Darwin) + $(MAKE) -C macosx clean +endif + +.depend: $(SRCS) Makefile + $(RM) .depend + $(foreach SRC, $(SRCS), $(CC) -MM -Ilibtransmission $(SRC) >> .depend;) + +include .depend diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 000000000..934fbe9a9 --- /dev/null +++ b/Makefile.common @@ -0,0 +1,40 @@ +VERSION_MAJOR = 0 +VERSION_MINOR = 5 +VERSION_STRING = 0.6-svn + +RM = rm -Rf +CFLAGS += -g -Wall -W -O3 -funroll-loops +CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE +CFLAGS += -DVERSION_MAJOR=$(VERSION_MAJOR) +CFLAGS += -DVERSION_MINOR=$(VERSION_MINOR) +CFLAGS += -DVERSION_STRING=\"$(VERSION_STRING)\" +CFLAGS += -DSYS_$(shell echo $(SYSTEM) | dd conv=ucase 2>/dev/null) + +ifeq ($(SYSTEM),BeOS) +ifeq ($(BEOS_NETSERVER),yes) +CFLAGS += -DBEOS_NETSERVER +LDFLAGS += -lnet +else +LDFLAGS += -lbind -lsocket +endif +endif +ifeq ($(SYSTEM),Darwin) +CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 +endif + +ifeq ($(MATH),yes) +LDFLAGS += -lm +endif + +ifeq ($(PTHREAD),yes) +ifeq ($(SYSTEM),FreeBSD) +LDFLAGS += -pthread +else +LDFLAGS += -lpthread +endif +endif + +ifeq ($(OPENSSL),yes) +CFLAGS += -DHAVE_OPENSSL +LDFLAGS += -lcrypto +endif diff --git a/configure.make b/configure.make new file mode 100755 index 000000000..f6de9550b --- /dev/null +++ b/configure.make @@ -0,0 +1,147 @@ +#! /bin/sh + +# +# Default settings +# +SYSTEM= +BEOS_NETSERVER=no +MATH=no +PTHREAD=no +OPENSSL= +CC="${CC-cc}" +CFLAGS="${CFLAGS}" +LDFLAGS="${LDFLAGS}" + + +# +# Functions +# +usage() +{ + cat << EOF + +Options: + --disable-openssl Disable OpenSSL, use built-in SHA1 implementation + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags + +EOF +} + +openssl_test() +{ + cat > testconf.c << EOF + #include + #include + int main() + { + SHA1( 0, 0, 0 ); + } +EOF + if $CC $CFLAGS $LDFLAGS -o testconf testconf.c -lcrypto > /dev/null 2>&1 + then + echo "yes" + OPENSSL=yes + else + echo "missing, using built-in SHA1 implementation" + OPENSSL=no + fi + rm -f testconf.c testconf +} + + +# +# Parse options +# +while [ $# -ne 0 ]; do + param=`expr "opt$1" : 'opt[^=]*=\(.*\)'` + + case "x$1" in + x--disable-openssl) + OPENSSL=no + ;; + x--help) + usage + exit 0 + ;; + esac + shift +done + +# +# System-specific flags +# +SYSTEM=`uname -s` +case $SYSTEM in + BeOS) + RELEASE=`uname -r` + case $RELEASE in + 6.0*|5.0.4) # Zeta or R5 / BONE beta 7 + ;; + 5.0*) # R5 / net_server + BEOS_NETSERVER=yes + ;; + *) + echo "Unsupported BeOS version" + exit 1 + ;; + esac + ;; + + Darwin) + # Make sure the Universal SDK is installed + if [ ! -d /Developer/SDKs/MacOSX10.4u.sdk ]; then + cat << EOF +You need to install the Universal SDK in order to build Transmission: + Get your Xcode CD or package + Restart the install + When it gets to "Installation Type", select "Customize" + Select "Mac OS X 10.4 (Universal) SDL" under "Cross Development" + Finish the install. +EOF + exit 1 + fi + PTHREAD=yes + ;; + + FreeBSD|NetBSD|OpenBSD|Linux) + MATH=yes + PTHREAD=yes + ;; + + *) + echo "Unsupported operating system" + exit 1 ;; +esac +echo "System: $SYSTEM" + +# +# OpenSSL settings +# +echo -n "OpenSSL: " +if [ "$OPENSSL" = no ]; then + echo "disabled, using built-in SHA1 implementation" +else + openssl_test +fi + +# +# Generate Makefile.config +# +rm -f Makefile.config +cat > Makefile.config << EOF +SYSTEM = $SYSTEM +BEOS_NETSERVER = $BEOS_NETSERVER +MATH = $MATH +PTHREAD = $PTHREAD +OPENSSL = $OPENSSL +CC = $CC +CFLAGS = $CFLAGS +LDFLAGS = $LDFLAGS +EOF + +echo +echo "To build Transmission, run 'make'." diff --git a/libtransmission/Makefile b/libtransmission/Makefile new file mode 100644 index 000000000..1f7cc5f61 --- /dev/null +++ b/libtransmission/Makefile @@ -0,0 +1,24 @@ +include ../Makefile.config +include ../Makefile.common + +SRCS = transmission.c bencode.c net.c tracker.c peer.c inout.c \ + metainfo.c sha1.c utils.c fdlimit.c clients.c completion.c \ + platform.c ratecontrol.c choking.c +OBJS = $(SRCS:%.c=%.o) + +CFLAGS += -D__TRANSMISSION__ + +libtransmission.a: $(OBJS) + libtool -static $(OBJS) -o $@ + +%.o: %.c ../Makefile.config ../Makefile.common Makefile + $(CC) $(CFLAGS) -o $@ -c $< + +clean: + $(RM) libtransmission.a $(OBJS) + +.depend: $(SRCS) Makefile + $(RM) .depend + $(foreach SRC, $(SRCS), $(CC) -MM $(SRC) -D__TRANSMISSION__ >> .depend;) + +include .depend diff --git a/macosx/Makefile b/macosx/Makefile new file mode 100644 index 000000000..f8f67b93c --- /dev/null +++ b/macosx/Makefile @@ -0,0 +1,14 @@ +include ../Makefile.config +include ../Makefile.common + +SRCS = $(shell ls *.m *.h *.plist) + +Transmission.app: $(SRCS) Info.plist + xcodebuild -configuration Debug | grep -v "^$$" + +Info.plist: Info.plist.in ../Makefile.common + $(RM) $@ + sed "s/%%VERSION%%/$(VERSION_STRING)/g" < $< > $@ + +clean: + $(RM) Info.plist build