improve makefile portability. patch by Stig Brautaset
[couchdbimport.git] / Makefile
blobba958735e63a53655b80c72243c379235c47dcae
1 # CouchDb Makefile
2 # (c) 2006 Jan Lehnardt <jan@php.net>
3 # This program is Free Software. See license.txt
6 UNICODE_INCLUDE_DIR ?= $(shell icu-config --prefix)
7 UNICODE_LIB_DIR ?= $(shell icu-config --icudata-install-dir)
8 ERLANG_INCLUDE_DIR ?= /usr/lib/erlang/driver
9 COUCHDB_INSTALL_DIR ?= /usr/local/couchdb
10 ERL ?= /usr/bin/erl
11 ERLC ?= /usr/bin/erlc
13 BUILD_DIR ?= ./build
14 DIST_DIR ?= ./dist
16 GCC ?= /usr/bin/gcc
17 CPP ?= /usr/bin/g++
18 INSTALL ?= /usr/bin/install
20 CPPFLAGS=-D_DEBUG
21 LDFLAGS=-L$(UNICODE_LIB_DIR) -L$(BUILD_DIR)/
23 install: couchdb
24 cp -R dist/common/* $(COUCHDB_INSTALL_DIR)/
25 mkdir $(COUCHDB_INSTALL_DIR)/lib $(COUCHDB_INSTALL_DIR)/bin $(COUCHDB_INSTALL_DIR)/boot $(COUCHDB_INSTALL_DIR)/js
26 cp src/js/js src/js/json.js src/js/main.js $(COUCHDB_INSTALL_DIR)/js/
27 cp dist/unix/bin/startCouchDb.sh $(COUCHDB_INSTALL_DIR)/bin/
28 cp $(BUILD_DIR)/couch_erl_driver.so $(COUCHDB_INSTALL_DIR)/lib/
29 mv $(COUCHDB_INSTALL_DIR)/couch_httpd.conf.src $(COUCHDB_INSTALL_DIR)/couch_httpd.conf
30 ./dist/unix/bin/config.sh
31 mv ./dist/unix/couch.ini $(COUCHDB_INSTALL_DIR)/
32 mv ./dist/unix/bin/couch_erl $(COUCHDB_INSTALL_DIR)/bin/couch_erl
33 chmod +x $(COUCHDB_INSTALL_DIR)/bin/couch_erl
35 cp couch.boot $(COUCHDB_INSTALL_DIR)/boot/
37 $(ERL) -noshell -run build_couch output_full_libs $(COUCHDB_INSTALL_DIR)
39 #couchdb
41 couchdb: host $(BUILD_DIR)/couch_erl_driver.so build/build_couch.beam build/couch.boot
42 cd src/js && make -f Makefile.ref && cd ../../
43 # $(ERL) -noshell -run build/build_couch compile_all
45 @echo "CouchDb has been built successfully!"
47 host:
48 ifeq ($(strip $(HOST)),)
49 @echo "Cannot determine HOST. exiting...";
50 exit 1;
51 endif
54 $(BUILD_DIR)/couch_erl_driver.so:
55 ifeq ($(HOST),Linux)
56 $(GCC) -w -rdynamic -shared -fPIC -I$(UNICODE_INCLUDE_DIR) -I$(ERLANG_INCLUDE_DIR) src/CouchDb/couch_erl_driver.c $(LDFLAGS) -o $(BUILD_DIR)/couch_erl_driver.so -licuuc -licudata -licui18n
57 endif
59 ifeq ($(HOST),Darwin)
60 $(GCC) -w -bundle -flat_namespace -undefined suppress -I$(UNICODE_INCLUDE_DIR) -I$(ERLANG_INCLUDE_DIR) src/CouchDb/couch_erl_driver.c $(LDFLAGS) -o $(BUILD_DIR)/couch_erl_driver.so -licudata -licuuc -licui18n
61 endif
64 build/couch.boot:
65 $(ERL) -noshell -run build_couch compile_all
67 build/build_couch.beam: build/build_couch.erl
68 $(ERLC) build/build_couch.erl
70 # clean
71 clean: clean_all clean_js
73 clean_js:
74 @cd src/js; make -f Makefile.ref clobber
76 clean_all:
77 rm -rf src/CouchDb/*.beam src/couch_inets/*.beam build/couch.rel build/couch.app build/couch_erl_driver.so build_couch.beam couch.script couch.boot
79 .PHONY: clean CouchDb host dist clean_js