Skip to content

Commit

Permalink
Makefile support from Monodevelop, tweaked README.rdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
gokr committed Sep 21, 2009
1 parent 8bb1955 commit 3342b83
Show file tree
Hide file tree
Showing 10 changed files with 618 additions and 71 deletions.
72 changes: 72 additions & 0 deletions Makefile
@@ -0,0 +1,72 @@

EXTRA_DIST = rules.make configure Makefile.include ../../../Divan/bin/Debug/Newtonsoft.Json.dll

all: all-recursive

top_srcdir=.
include $(top_srcdir)/config.make
include $(top_srcdir)/Makefile.include
include $(top_srcdir)/rules.make

#include $(top_srcdir)/custom-hooks.make

#Warning: This is an automatically generated file, do not edit!
ifeq ($(CONFIG),DEBUG)
SUBDIRS = src samples/Trivial
endif
ifeq ($(CONFIG),RELEASE)
SUBDIRS = src samples/Trivial
endif


CONFIG_MAKE=$(top_srcdir)/config.make

%-recursive: $(CONFIG_MAKE)
@set . $$MAKEFLAGS; final_exit=:; \
case $$2 in --unix) shift ;; esac; \
case $$2 in *=*) dk="exit 1" ;; *k*) dk=: ;; *) dk="exit 1" ;; esac; \
make pre-$*-hook prefix=$(prefix) ; \
for dir in $(call quote_each,$(SUBDIRS)); do \
case "$$dir" in \
.) make $*-local || { final_exit="exit 1"; $$dk; };;\
*) (cd "$$dir" && make $*) || { final_exit="exit 1"; $$dk; };;\
esac \
done; \
make post-$*-hook prefix=$(prefix) ; \
$$final_exit

$(CONFIG_MAKE):
echo "You must run configure first"
exit 1

clean: clean-recursive
install: install-recursive
uninstall: uninstall-recursive

dist: $(CONFIG_MAKE)
rm -rf $(PACKAGE)-$(VERSION)
mkdir $(PACKAGE)-$(VERSION)
make pre-dist-hook distdir=$$distdir
for dir in $(call quote_each,$(SUBDIRS)); do \
pkgdir=`pwd`/$(PACKAGE)-$(VERSION); \
mkdir "$$pkgdir/$$dir" || true; \
case $$dir in \
.) make dist-local "distdir=$$pkgdir" || exit 1;; \
*) (cd "$$dir"; make dist-local "distdir=$$pkgdir/$$dir") || exit 1;; \
esac \
done
(make dist-local distdir=$(PACKAGE)-$(VERSION))
make
make post-dist-hook "distsir=$$distdir"
tar czvf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
rm -rf $(PACKAGE)-$(VERSION)
@echo "=========================================="
@echo "$(PACKAGE)-$(VERSION) has been packaged > $(PACKAGE)-$(VERSION).tar.gz"
@echo "=========================================="

distcheck: dist
(mkdir test; cd test; \
tar xzvf ../$(PACKAGE)-$(VERSION).tar.gz; cd $(PACKAGE)-$(VERSION); \
./configure --prefix=$$(cd `pwd`/..; pwd); \
make && make install && make dist);
rm -rf test
120 changes: 120 additions & 0 deletions Makefile.include
@@ -0,0 +1,120 @@
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 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 $(top_srcdir)/config.make
mkdir -p '$$(shell dirname '$$@')'
cp '$$<' '$$@'
$(if $3,chmod +x '$$@')

$2: $2.in $(top_srcdir)/config.make
sed -e "s,@prefix@,$(prefix)," -e "s,@PACKAGE@,$(PACKAGE)," -e "s,@expanded_libdir@,$(libdir)," -e "s,@expanded_bindir@,$(bindir)," -e "s,@expanded_datadir@,$(datadir)," < $2.in > $2
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)
87 changes: 19 additions & 68 deletions README.rdoc
Expand Up @@ -20,11 +20,6 @@ Divan is under the MIT-license, see file LICENSE.txt.
* Has CouchDB-Lucene integration!
* Offers several "hooks" for your own subclasses in order to add specializations.

== Mailinglist

We have set up a regular Mailman mailinglist[http://krampe.se/mailman/listinfo/divan] for users and developers alike, please subscribe!


== Does it work under Mono?

You bet. Foretagsplatsen uses mainly windows (Visual Studio 2008 and .Net 3.5) but Divan
Expand All @@ -34,6 +29,25 @@ requests so we detect if we are running in Mono and then we fall back on using a
Note that this bug has been <b>reported and fixed</b> in Mono trunk and should be available
in any mono release after 2.4.2.3 (I guess). Then we will remove that check.

== Getting started
1. Install git of course... :)
2. Clone Divan. The "official" repository is the one from Foretagsplatsen and we only have one branch there so far, and no tags yet:
<b>git clone git://github.com/foretagsplatsen/Divan.git</b>
3. If you are on VS2008 or Monodevelop then I suggest double clicking the Divan.sln. Hopefully the rest works out fine.
4. If you are on Mono "CLI style" then the Makefile should work, it is "vanilla generated" from Monodevelop. Then you can also run unit tests, but note that these rely on a couchdb running locally:
nunit-console2 -labels src/bin/Debug/Divan.dll
5. Run the "Trivial" sample console app. You can point it at a running CouchDB server:

C:\Divan\samples\Trivial>bin\Debug\Trivial.exe 192.168.9.205 5984

6. Happy coding! And ask any questions on the mailinglist.

== Mailinglist
We have set up a regular Mailman mailinglist[http://krampe.se/mailman/listinfo/divan] for users and developers alike, please subscribe!

== Contributing
...is simple. <b>All contributions should be under the MIT license</b>. Just fork and make pull requests and we will try to integrate. Feel free to bring up anything on the mailinglist. We haven't started using any issue tracker yet, but we will if it gets more popular and we when we do a proper release.

== What about documentation?

At the moment documentation is... this file! :) But there are unit tests in CouchTest.cs and
Expand All @@ -50,66 +64,3 @@ The only dependencies and their tested versions are:
* If you want to use the Lucene parts of Divan, you also need CouchDB-Lucene (0.4) installed on the server, see: http://github.com/rnewson/couchdb-lucene/tree/v0.4

The two needed dlls are included in the lib directory.

== Getting started

Well... it goes something like this:

1. First get CouchDB up and running on some box.

2. Clone Divan and build it.

3. Run the "Trivial" sample console app by pointing it at a running CouchDB server getting output similar to this:

C:\Divan\samples\Trivial>bin\Debug\Trivial.exe 192.168.9.205 5984
Using 192.168.9.205:5984
Created a CouchServer
Request: http://192.168.9.205:5984/trivial Method: HEAD
Request: http://192.168.9.205:5984/trivial Method: PUT
Created database 'trivial'
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Request: http://192.168.9.205:5984/trivial/ Method: POST
Saved 10 Cars with 170 hps each.
Request: http://192.168.9.205:5984/trivial/86a9d1ad306e204a037940c4fb0cbbe7 Method: PUT
Modified last Car with id 86a9d1ad306e204a037940c4fb0cbbe7
Request: http://192.168.9.205:5984/trivial/86a9d1ad306e204a037940c4fb0cbbe7 Method: GET
Loaded last Car Saab 93 now with 400hps.
Request: http://192.168.9.205:5984/trivial/_all_docs?include_docs=true Method: GET
Loaded all Cars: 10
Request: http://192.168.9.205:5984/trivial/1f6de464ae8034eb952b93105807f22c?rev1-208231211 Method: DELETE
Deleted car with id 1f6de464ae8034eb952b93105807f22c
Request: http://192.168.9.205:5984/trivial/44f9638877fc09e07bda6504a5bfd40d?rev1-345884075 Method: DELETE
Deleted car with id 44f9638877fc09e07bda6504a5bfd40d
Request: http://192.168.9.205:5984/trivial/591e0ef170154311aafa8a2a5fcbb310?rev1-2891194419 Method: DELETE
Deleted car with id 591e0ef170154311aafa8a2a5fcbb310
Request: http://192.168.9.205:5984/trivial/7124fada0f90ed93f88168dc6c1c8b4f?rev1-2479256166 Method: DELETE
Deleted car with id 7124fada0f90ed93f88168dc6c1c8b4f
Request: http://192.168.9.205:5984/trivial/73115c4dd3b2bcd512412813dd04b901?rev1-3993011972 Method: DELETE
Deleted car with id 73115c4dd3b2bcd512412813dd04b901
Request: http://192.168.9.205:5984/trivial/78a305543bff2f474cbcfe2ac667cc6d?rev1-1583012745 Method: DELETE
Deleted car with id 78a305543bff2f474cbcfe2ac667cc6d
Request: http://192.168.9.205:5984/trivial/86a9d1ad306e204a037940c4fb0cbbe7?rev2-1402499148 Method: DELETE
Deleted car with id 86a9d1ad306e204a037940c4fb0cbbe7
Request: http://192.168.9.205:5984/trivial/9e647b114b9ba1c8a170ed1c1951260c?rev1-30425501 Method: DELETE
Deleted car with id 9e647b114b9ba1c8a170ed1c1951260c
Request: http://192.168.9.205:5984/trivial/bad56664dec8f3d1fd30db70510f7ff2?rev1-1765374009 Method: DELETE
Deleted car with id bad56664dec8f3d1fd30db70510f7ff2
Request: http://192.168.9.205:5984/trivial/cbf0bb7f8ebc4aad02a2c90228d1076f?rev1-2425501185 Method: DELETE
Deleted car with id cbf0bb7f8ebc4aad02a2c90228d1076f
Request: http://192.168.9.205:5984/trivial Method: HEAD
Request: http://192.168.9.205:5984/trivial Method: DELETE
Deleted database


3. Look at couchTest.cs and make sure the tests are green, you may need to edit CochServer.cs with different default server ip.

4. Have fun!

9 changes: 9 additions & 0 deletions config.make
@@ -0,0 +1,9 @@
prefix=/usr/local
libdir=/usr/local/lib
bindir=/usr/local/bin
datadir=/usr/local/share
RUNTIME=mono
ASSEMBLY_VERSION=0.1.0.0
VERSION=0.1
PACKAGE=divan
CONFIG=DEBUG

0 comments on commit 3342b83

Please sign in to comment.