Permalink
Browse files

Simplify the makefile build system so it uses xbuild instead

Also remove the rediculously complex autoconf/automake files and
use a much simpler configure/Makefile script which just does what
we need.
  • Loading branch information...
1 parent dff6481 commit cf4f7ee0c917f923ea360683c770a1b2bec42d24 @alanmcgovern alanmcgovern committed Mar 31, 2012
View
@@ -0,0 +1,49 @@
+CONFIG=config.make
+
+XBUILD=xbuild
+XBUILD_ARGS=/verbosity:quiet /nologo /property:Configuration=$(MONOTORRENT_PROFILE)
+MAIN_SLN=src/MonoTorrent.sln
+DIST_FILE=monotorrent-$(MONOTORRENT_VERSION).tar.gz
+
+all:
+ @echo Building $(MAIN_SLN)
+ @$(XBUILD) $(XBUILD_ARGS) $(MAIN_SLN)
+
+clean:
+ @echo Cleaning $(MAIN_SLN)
+ @$(XBUILD) $(XBUILD_ARGS) $(MAIN_SLN) /t:Clean
+
+dist:
+ git archive --format=tar HEAD | gzip > $(DIST_FILE)
+
+dist-clean:
+ rm -f $(DIST_FILE)
+
+dist-check:
+
+install: $(CONFIG)
+ @echo Installing MonoTorrent libraries
+ mkdir -p $(DESTDIR)$(MONOTORRENT_INSTALL_DIR)
+ cp -R build/MonoTorrent/$(MONOTORRENT_PROFILE)/* $(DESTDIR)$(MONOTORRENT_INSTALL_DIR)/
+
+ @echo Installing pc files
+ mkdir -p $(DESTDIR)$(pkgconfigdir)
+ cp src/MonoTorrent/monotorrent.pc $(DESTDIR)$(pkgconfigdir)/
+ cp src/MonoTorrent.Dht/monotorrent.dht.pc $(DESTDIR)$(pkgconfigdir)/
+
+uninstall: $(CONFIG)
+ @echo Removing MonoTorrent libraries
+ rm -rf $(DESTDIR)/$(libdir)/monotorrent
+ @echo Removing MonoTorrent pc files
+ rm -f $(DESTDIR)$(pkgconfigdir)/monotorrent.pc
+ rm -f $(DESTDIR)$(pkgconfigdir)/monotorrent.dht.pc
+
+$(CONFIG):
+ @if ! test -e "$(CONFIG)"; then \
+ echo "You must run configure first" && exit 1; \
+ fi
+
+
+include $(CONFIG)
+
+.PHONY: all clean dist dist-clean dist-check install
View
@@ -0,0 +1,59 @@
+prefix=/usr/local
+bindir=$prefix/bin
+libdir=$prefix/lib
+profile=Debug
+pkgconfigdir=$prefix/pkgconfig
+monotorrent_version=`grep 'AssemblyFileVersion' src/MonoTorrent/AssemblyInfo.cs | grep -Eo '([0-9]\.[0-9]\.[0-9])'`
+
+while test x$1 != x; do
+ case $1 in
+ --bindir=*)
+ bindir=`echo $1 | sed s/--bindir=//`
+ ;;
+ --libdir=*)
+ libdir=`echo $1i | sed s/--libdir=//`
+ ;;
+ --prefix=*)
+ prefix=`echo $1 | sed s/--prefix=//`
+ ;;
+ --profile=*)
+ profile=`echo $1 | sed s/--profile=//`
+ ;;
+ --pkgconfigdir=*)
+ pkgconfigdir=`echo $1 s/--pkgconfigdir=//`
+ ;;
+ *)
+ echo Unknown argument $1 >&2
+ usage
+ exit 1
+ ;;
+ esac
+ shift
+done
+
+monotorrent_install_dir=$libdir/monotorrent
+
+mt_pc=src/MonoTorrent/monotorrent.pc
+cp src/MonoTorrent/monotorrent.pc.in $mt_pc
+sed -i '' s,@monotorrent_version@,$monotorrent_version, $mt_pc
+sed -i '' s,@monotorrent_install_dir@,$monotorrent_install_dir, $mt_pc
+
+mt_pc=src/MonoTorrent.Dht/monotorrent.dht.pc
+cp $mt_pc.in $mt_pc
+sed -i '' s,@monotorrent_version@,$monotorrent_version, $mt_pc
+sed -i '' s,@monotorrent_install_dir@,$monotorrent_install_dir, $mt_pc
+
+echo prefix=$prefix > config.make
+echo bindir=$bindir >> config.make
+echo libdir=$libdir >> config.make
+echo pkgconfigdir=$pkgconfigdir >> config.make
+echo '' >> config.make
+echo MONOTORRENT_INSTALL_DIR=$monotorrent_install_dir >> config.make
+echo MONOTORRENT_VERSION=$monotorrent_version >> config.make
+echo MONOTORRENT_PROFILE=$profile >> config.make
+
+echo "MonoTorrent has been configured with "
+echo " prefix = $prefix"
+echo " profile = $profile"
+echo
+
View
@@ -1,10 +0,0 @@
-
-EXTRA_DIST = expansions.m4
-
-#Warning: This is an automatically generated file, do not edit!
-if ENABLE_DEBUG
- SUBDIRS = MonoTorrent MonoTorrent.Dht
-endif
-if ENABLE_RELEASE
- SUBDIRS = MonoTorrent MonoTorrent.Dht
-endif
View
@@ -1,118 +0,0 @@
-VALID_CULTURES = ar bg ca zh-CHS cs da de el en es fi fr he hu is it ja ko nl no pl pt ro ru hr sk sq sv th tr id uk be sl et lv lt fa vi hy eu mk af fo hi sw gu ta te kn mr gl kok ar-SA bg-BG ca-ES zh-TW cs-CZ da-DK de-DE el-GR en-US fi-FI fr-FR he-IL hu-HU is-IS it-IT ja-JP ko-KR nl-NL nb-NO pl-PL pt-BR ro-RO ru-RU hr-HR sk-SK sq-AL sv-SE th-TH tr-TR id-ID uk-UA be-BY sl-SI et-EE lv-LV lt-LT fa-IR vi-VN hy-AM eu-ES mk-MK af-ZA fo-FO hi-IN sw-KE gu-IN ta-IN te-IN kn-IN mr-IN gl-ES kok-IN ar-IQ zh-CN de-CH en-GB es-MX fr-BE it-CH nl-BE nn-NO pt-PT sv-FI ar-EG zh-HK de-AT en-AU es-ES fr-CA ar-LY zh-SG de-LU en-CA es-GT fr-CH ar-DZ zh-MO en-NZ es-CR fr-LU ar-MA en-IE es-PA ar-TN en-ZA es-DO ar-OM es-VE ar-YE es-CO ar-SY es-PE ar-JO en-TT es-AR ar-LB en-ZW es-EC ar-KW en-PH es-CL ar-AE es-UY ar-BH es-PY ar-QA es-BO es-SV es-HN es-NI es-PR zh-CHT
-
-s2q=$(subst \ ,?,$1)
-q2s=$(subst ?,\ ,$1)
-# use this when result will be quoted
-unesc2=$(subst ?, ,$1)
-
-build_sources = $(FILES) $(GENERATED_FILES)
-build_sources_esc= $(call s2q,$(build_sources))
-# use unesc2, as build_sources_embed is quoted
-build_sources_embed= $(call unesc2,$(build_sources_esc:%='$(srcdir)/%'))
-
-comma__=,
-get_resource_name = $(firstword $(subst $(comma__), ,$1))
-get_culture = $(lastword $(subst ., ,$(basename $1)))
-is_cultured_resource = $(and $(word 3,$(subst ., ,$1)), $(filter $(VALID_CULTURES),$(lastword $(subst ., ,$(basename $1)))))
-
-RESOURCES_ESC=$(call s2q,$(RESOURCES))
-
-build_resx_list = $(foreach res, $(RESOURCES_ESC), $(if $(filter %.resx, $(call get_resource_name,$(res))),$(res),))
-build_non_culture_resx_list = $(foreach res, $(build_resx_list),$(if $(call is_cultured_resource,$(call get_resource_name,$(res))),,$(res)))
-build_non_culture_others_list = $(foreach res, $(filter-out $(build_resx_list),$(RESOURCES_ESC)),$(if $(call is_cultured_resource,$(call get_resource_name,$(res))),,$(res)))
-build_others_list = $(build_non_culture_others_list)
-build_xamlg_list = $(filter %.xaml.g.cs, $(FILES))
-
-# resgen all .resx resources
-build_resx_files = $(foreach res, $(build_resx_list), $(call get_resource_name,$(res)))
-build_resx_resources_esc = $(build_resx_files:.resx=.resources)
-build_resx_resources = $(call q2s,$(build_resx_resources_esc))
-
-# embed resources for the main assembly
-build_resx_resources_hack = $(subst .resx,.resources, $(build_non_culture_resx_list))
-# use unesc2, as build_resx_resources_embed is quoted
-build_resx_resources_embed = $(call unesc2,$(build_resx_resources_hack:%='-resource:%'))
-build_others_files = $(call q2s,$(foreach res, $(build_others_list),$(call get_resource_name,$(res))))
-build_others_resources = $(build_others_files)
-# use unesc2, as build_others_resources_embed is quoted
-build_others_resources_embed = $(call unesc2,$(build_others_list:%='-resource:$(srcdir)/%'))
-
-build_resources = $(build_resx_resources) $(build_others_resources)
-build_resources_embed = $(build_resx_resources_embed) $(build_others_resources_embed)
-
-# -usesourcepath is available only for resgen2
-emit_resgen_target_1=$(call q2s,$1) : $(call q2s,$(subst .resources,.resx,$1)); cd '$$(shell dirname '$$<')' && MONO_IOMAP=drive $$(RESGEN) '$$(shell basename '$$<')' '$$(shell basename '$$@')'
-emit_resgen_target_2=$(call q2s,$1) : $(call q2s,$(subst .resources,.resx,$1)); MONO_IOMAP=drive $$(RESGEN) -usesourcepath '$$<' '$$@'
-
-emit_resgen_target=$(if $(filter resgen2,$(RESGEN)),$(emit_resgen_target_2),$(emit_resgen_target_1))
-emit_resgen_targets=$(foreach res,$(build_resx_resources_esc),$(eval $(call emit_resgen_target,$(res))))
-
-build_references_ref = $(call q2s,$(foreach ref, $(call s2q,$(REFERENCES)), $(if $(filter -pkg:%, $(ref)), $(ref), $(if $(filter -r:%, $(ref)), $(ref), -r:$(ref)))))
-build_references_ref += $(call q2s,$(foreach ref, $(call s2q,$(DLL_REFERENCES)), -r:$(ref)))
-build_references_ref += $(call q2s,$(foreach ref, $(call s2q,$(PROJECT_REFERENCES)), -r:$(ref)))
-
-s2q2s=$(call unesc2,$(call s2q,$1))
-cp_actual=test -z $1 || cp $1 $2
-cp=$(call cp_actual,'$(call s2q2s,$1)','$(call s2q2s,$2)')
-
-rm_actual=test -z '$1' || rm -f '$2'
-rm=$(call rm_actual,$(call s2q2s,$1),$(call s2q2s,$2)/$(shell basename '$(call s2q2s,$1)'))
-
-EXTRA_DIST += $(build_sources) $(build_resx_files) $(build_others_files) $(ASSEMBLY_WRAPPER_IN) $(EXTRAS) $(DATA_FILES) $(build_culture_res_files)
-CLEANFILES += $(ASSEMBLY) $(ASSEMBLY).mdb $(BINARIES) $(build_resx_resources) $(build_satellite_assembly_list)
-DISTCLEANFILES = $(GENERATED_FILES) $(pc_files) $(BUILD_DIR)/*
-
-pkglib_SCRIPTS = $(ASSEMBLY)
-bin_SCRIPTS = $(BINARIES)
-
-programfilesdir = @libdir@/@PACKAGE@
-programfiles_DATA = $(PROGRAMFILES)
-linuxpkgconfigdir = @libdir@/pkgconfig
-linuxpkgconfig_DATA = $(LINUX_PKGCONFIG)
-
-
-# macros
-
-# $(call emit-deploy-target,deploy-variable-name)
-define emit-deploy-target
-$($1): $($1_SOURCE)
- mkdir -p '$$(shell dirname '$$@')'
- cp '$$<' '$$@'
-endef
-
-# $(call emit-deploy-wrapper,wrapper-variable-name,wrapper-sourcefile,x)
-# assumes that for a wrapper foo.pc its source template is foo.pc.in
-# if $3 is non-empty then wrapper is marked exec
-define emit-deploy-wrapper
-$($1): $2
- mkdir -p '$$(shell dirname '$$@')'
- cp '$$<' '$$@'
- $(if $3,chmod +x '$$@')
-
-endef
-
-# generating satellite assemblies
-
-culture_resources = $(foreach res, $(RESOURCES_ESC), $(if $(call is_cultured_resource,$(call get_resource_name, $(res))),$(res)))
-cultures = $(sort $(foreach res, $(culture_resources), $(call get_culture,$(call get_resource_name,$(res)))))
-culture_resource_dependencies = $(call q2s,$(BUILD_DIR)/$1/$(SATELLITE_ASSEMBLY_NAME): $(subst .resx,.resources,$2))
-culture_resource_commandlines = $(call unesc2,cmd_line_satellite_$1 += '/embed:$(subst .resx,.resources,$2)')
-build_satellite_assembly_list = $(call q2s,$(cultures:%=$(BUILD_DIR)/%/$(SATELLITE_ASSEMBLY_NAME)))
-build_culture_res_files = $(call q2s,$(foreach res, $(culture_resources),$(call get_resource_name,$(res))))
-install_satellite_assembly_list = $(subst $(BUILD_DIR),$(DESTDIR)$(libdir)/$(PACKAGE),$(build_satellite_assembly_list))
-
-$(eval $(foreach res, $(culture_resources), $(eval $(call culture_resource_dependencies,$(call get_culture,$(call get_resource_name,$(res))),$(call get_resource_name,$(res))))))
-$(eval $(foreach res, $(culture_resources), $(eval $(call culture_resource_commandlines,$(call get_culture,$(call get_resource_name,$(res))),$(res)))))
-
-$(build_satellite_assembly_list): $(BUILD_DIR)/%/$(SATELLITE_ASSEMBLY_NAME):
- mkdir -p '$(@D)'
- $(AL) -out:'$@' -culture:$* -t:lib $(cmd_line_satellite_$*)
-
-$(install_satellite_assembly_list):
- mkdir -p '$(@D)'
- cp $(subst $(DESTDIR)$(libdir)/$(PACKAGE), $(BUILD_DIR), $@) $@
-
-install-satellite-assemblies: $(install_satellite_assembly_list)
-
-uninstall-satellite-assemblies:
- rm -rf $(install_satellite_assembly_list)
@@ -1,127 +0,0 @@
-
-EXTRA_DIST =
-
-# Warning: This is an automatically generated file, do not edit!
-
-if ENABLE_DEBUG
-ASSEMBLY_COMPILER_COMMAND = gmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -unsafe -warn:4 -optimize- -debug "-define:TRACE;DEBUG"
-ASSEMBLY = bin/Debug/MonoTorrent.Dht.dll
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = library
-PROJECT_REFERENCES = \
- ../MonoTorrent/bin/Debug/MonoTorrent.dll
-BUILD_DIR = bin/Debug/
-
-MONOTORRENT_DLL_SOURCE=../MonoTorrent/bin/Debug/MonoTorrent.dll
-MONOTORRENT_DLL_MDB_SOURCE=../MonoTorrent/bin/Debug/MonoTorrent.dll.mdb
-MONOTORRENT_DLL_MDB=$(BUILD_DIR)/MonoTorrent.dll.mdb
-MONOTORRENT_DHT_DLL_MDB_SOURCE=bin/Debug/MonoTorrent.Dht.dll.mdb
-
-endif
-
-if ENABLE_RELEASE
-ASSEMBLY_COMPILER_COMMAND = gmcs
-ASSEMBLY_COMPILER_FLAGS = -noconfig -codepage:utf8 -unsafe -warn:4 -optimize+ -debug -define:DEBUG "-define:TRACE"
-ASSEMBLY = bin/Release/MonoTorrent.Dht.dll
-ASSEMBLY_MDB = $(ASSEMBLY).mdb
-COMPILE_TARGET = library
-PROJECT_REFERENCES = \
- ../MonoTorrent/bin/Release/MonoTorrent.dll
-BUILD_DIR = bin/Release/
-
-MONOTORRENT_DLL_SOURCE=../MonoTorrent/bin/Release/MonoTorrent.dll
-MONOTORRENT_DLL_MDB=
-MONOTORRENT_DHT_DLL_MDB_SOURCE=bin/Release/MonoTorrent.Dht.dll.mdb
-
-endif
-
-AL=al2
-SATELLITE_ASSEMBLY_NAME=$(notdir $(basename $(ASSEMBLY))).resources.dll
-
-PROGRAMFILES = \
- $(MONOTORRENT_DLL) \
- $(MONOTORRENT_DLL_MDB) \
- $(MONOTORRENT_DHT_DLL_MDB)
-
-LINUX_PKGCONFIG = \
- $(MONOTORRENT_DHT_PC)
-
-
-RESGEN=resgen2
-
-all: $(ASSEMBLY) $(PROGRAMFILES) $(LINUX_PKGCONFIG)
-
-FILES = \
- BigInteger.cs \
- DhtEngine.cs \
- EventArgs/NodeAddedEventArgs.cs \
- EventArgs/SendMessageEventArgs.cs \
- EventArgs/TaskCompleteEventArgs.cs \
- Listeners/DhtListener.cs \
- Message.cs \
- MessageException.cs \
- MessageFactory.cs \
- MessageLoop.cs \
- Messages/Errors/ErrorMessage.cs \
- Messages/Queries/AnnouncePeer.cs \
- Messages/Queries/FindNode.cs \
- Messages/Queries/GetPeers.cs \
- Messages/Queries/Ping.cs \
- Messages/Queries/QueryMessage.cs \
- Messages/Responses/AnnouncePeerResponse.cs \
- Messages/Responses/FindNodeResponse.cs \
- Messages/Responses/GetPeersResponse.cs \
- Messages/Responses/PingResponse.cs \
- Messages/Responses/ResponseMessage.cs \
- Nodes/NodeId.cs \
- RoutingTable/Bucket.cs \
- Nodes/NodeState.cs \
- Nodes/Node.cs \
- RoutingTable/RoutingTable.cs \
- Tasks/AnnounceTask.cs \
- Tasks/GetPeersTask.cs \
- Tasks/InitialiseTask.cs \
- Tasks/ITask.cs \
- Tasks/RefreshBucketTask.cs \
- Tasks/ReplaceNodeTask.cs \
- Tasks/SendMessageTask.cs \
- Tasks/Task.cs \
- TransactionId.cs \
- Nodes/TokenManager.cs \
- EventArgs/NodeFoundEventArgs.cs
-
-DATA_FILES =
-
-RESOURCES =
-
-EXTRAS = \
- monotorrent.dht.pc.in
-
-REFERENCES = \
- System \
- System.Data \
- System.Xml
-
-DLL_REFERENCES =
-
-CLEANFILES = $(PROGRAMFILES) $(LINUX_PKGCONFIG)
-
-include $(top_srcdir)/Makefile.include
-
-MONOTORRENT_DLL = $(BUILD_DIR)/MonoTorrent.dll
-MONOTORRENT_DHT_DLL_MDB = $(BUILD_DIR)/MonoTorrent.Dht.dll.mdb
-MONOTORRENT_DHT_PC = $(BUILD_DIR)/monotorrent.dht.pc
-
-$(eval $(call emit-deploy-target,MONOTORRENT_DLL))
-$(eval $(call emit-deploy-target,MONOTORRENT_DLL_MDB))
-$(eval $(call emit-deploy-wrapper,MONOTORRENT_DHT_PC,monotorrent.dht.pc))
-
-
-$(eval $(call emit_resgen_targets))
-$(build_xamlg_list): %.xaml.g.cs: %.xaml
- xamlg '$<'
-
-$(ASSEMBLY) $(ASSEMBLY_MDB): $(build_sources) $(build_resources) $(build_datafiles) $(DLL_REFERENCES) $(PROJECT_REFERENCES) $(build_xamlg_list) $(build_satellite_assembly_list)
- mkdir -p $(shell dirname $(ASSEMBLY))
- $(ASSEMBLY_COMPILER_COMMAND) $(ASSEMBLY_COMPILER_FLAGS) -out:$(ASSEMBLY) -target:$(COMPILE_TARGET) $(build_sources_embed) $(build_resources_embed) $(build_references_ref)
@@ -36,24 +36,20 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
+ <OutputPath>..\..\build\MonoTorrent\Debug\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
- <OutputType>Library</OutputType>
- <RootNamespace>MonoTorrent.Dht</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
+ <OutputPath>..\..\build\MonoTorrent\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
- <OutputType>Library</OutputType>
<DebugSymbols>true</DebugSymbols>
- <RootNamespace>MonoTorrent.Dht</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
Oops, something went wrong.

0 comments on commit cf4f7ee

Please sign in to comment.