Addons updated to new doc format
[io.git] / Makefile
blob4e88e5d45e8dbcaac1c88b0ad3a45b160f9b6c80
1 INSTALL_PREFIX ?= /usr/local
3 SYS ?= $(shell uname -s)
5 NEEDS_DL := Darwin Linux SunOS syllable
6 ifneq (,$(findstring $(SYS),$(NEEDS_DL)))
7 LFLAGS +=-ldl
8 endif
10 NEEDS_M := FreeBSD Linux NetBSD DragonFly
11 ifneq (,$(findstring $(SYS),$(NEEDS_M)))
12 LFLAGS +=-lm
13 endif
15 #NEEDS_PTHREAD := FreeBSD Linux NetBSD
16 #ifneq (,$(findstring $(SYS),$(NEEDS_PTHREAD)))
17 #LFLAGS +=-lpthread
18 #endif
20 DLL_SUFFIX := so
21 DLL_COMMAND := -shared -Wl,-soname="libiovmall.so"
22 FLAT_NAMESPACE :=
24 LINKDLL := $(CC)
25 LINKDLLOUTFLAG := -o
26 LINKDIRFLAG := -L
27 LINKLIBFLAG := -l
28 DLL_LIB_SUFFIX :=
29 CCOUTFLAG := -o
30 AROUTFLAG :=
31 RANLIB ?= ranlib
32 AR ?= ar
33 ARFLAGS := rcu
35 ifeq ($(SYS),Darwin)
36 DLL_SUFFIX := dylib
37 DLL_COMMAND := -dynamiclib
38 FLAT_NAMESPACE := -flat_namespace
39 endif
41 ifneq (,$(findstring CYGW,$(SYS)))
42 DLL_SUFFIX := dll
43 BINARY_SUFFIX := .exe
44 endif
46 ifneq (,$(findstring MINGW,$(SYS)))
47 DLL_SUFFIX := dll
48 BINARY_SUFFIX := .exe
49 endif
51 ifneq (,$(findstring Windows,$(SYS)))
52 CC := cl -nologo
53 LINKDLL := link
54 LINKDLLOUTFLAG :=-out:
55 DLL_SUFFIX := dll
56 DLL_COMMAND := -dll -debug /INCREMENTAL:NO -subsystem:CONSOLE
57 DLL_EXTRA_LIBS := ws2_32.lib shell32.lib
58 FLAT_NAMESPACE :=
59 AR := link -lib
60 ARFLAGS :=
61 AROUTFLAG := -out:
62 VMALL := vmall_
63 BINARY_SUFFIX := .exe
64 endif
66 ###########################
68 date := $(shell date +'%Y-%m-%d')
70 #libs := $(shell ls libs)
71 libs := basekit coroutine garbagecollector iovm
73 all: addons
75 testaddon:
76 ./_build/binaries/io_static$(BINARY_SUFFIX) addons/$(addon)/tests/run.io
78 vm:
79 for dir in $(libs); do INSTALL_PREFIX=$(INSTALL_PREFIX) $(MAKE) -C libs/$$dir; done
80 $(MAKE) vmlib
81 cd tools; $(MAKE)
82 ifneq (,$(findstring Windows,$(SYS)))
83 mt.exe -manifest tools/_build/binaries/io.exe.manifest -outputresource:tools/_build/binaries/io.exe
84 rm tools/_build/binaries/io.exe.manifest
85 mt.exe -manifest tools/_build/binaries/io_static.exe.manifest -outputresource:tools/_build/binaries/io_static.exe
86 rm tools/_build/binaries/io_static.exe.manifest
87 endif
88 mkdir -p _build/binaries || true
89 cp tools/_build/binaries/* _build/binaries
91 addons: vm
92 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io
93 @if [ -f errors ]; then cat errors; echo; echo "Note: addons do not to build when libs or headers are missing"; echo; rm errors; fi
95 vmlib:
96 mkdir -p _build || true
97 mkdir -p _build/dll || true
98 $(LINKDLL) $(DLL_COMMAND) $(LINKDLLOUTFLAG)_build/dll/libiovmall.$(DLL_SUFFIX) libs/*/_build/$(VMALL)objs/*.o $(LFLAGS) $(DLL_EXTRA_LIBS)
99 ifneq (,$(findstring Windows,$(SYS)))
100 mt.exe -manifest _build/dll/libiovmall.dll.manifest -outputresource:_build/dll/libiovmall.dll
101 rm _build/dll/libiovmall.dll.manifest
102 endif
103 mkdir -p _build/lib || true
104 $(AR) $(ARFLAGS) $(AROUTFLAG)_build/lib/libiovmall.a\
105 libs/*/_build/$(VMALL)objs/*.o
106 mkdir -p _build/headers || true
107 cp libs/*/_build/headers/* _build/headers
109 # Unlink the io binary before copying so running Io processes will keep running
110 install:
111 umask 022
112 mkdir -p $(INSTALL_PREFIX)/bin || true
113 mkdir -p $(INSTALL_PREFIX)/lib || true
114 rm -f $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
115 cp _build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin || true
116 chmod ugo+rx $(INSTALL_PREFIX)/bin/io$(BINARY_SUFFIX)
117 cp _build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin || true
118 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX) || true
119 cp _build/dll/* $(INSTALL_PREFIX)/lib || true
120 cp _build/dll/* $(INSTALL_PREFIX)/bin || true
121 cp _build/lib/* $(INSTALL_PREFIX)/lib || true
122 rm -rf $(INSTALL_PREFIX)/lib/io || true
123 mkdir -p $(INSTALL_PREFIX)/lib/io || true
124 cp -fR addons $(INSTALL_PREFIX)/lib/io
125 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
127 linkInstall:
128 mkdir -p $(INSTALL_PREFIX)/bin || true
129 mkdir -p $(INSTALL_PREFIX)/lib || true
130 ln -sf `pwd`/_build/binaries/io$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
131 chmod ugo+rx $(INSTALL_PREFIX)/bin/io
132 ln -sf `pwd`/_build/binaries/io_static$(BINARY_SUFFIX) $(INSTALL_PREFIX)/bin
133 chmod ugo+rx $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
134 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/lib
135 ln -sf `pwd`/_build/dll/* $(INSTALL_PREFIX)/bin
136 ln -sf `pwd`/_build/lib/* $(INSTALL_PREFIX)/lib
137 rm -rf $(INSTALL_PREFIX)/lib/io || true
138 mkdir -p $(INSTALL_PREFIX)/lib/io || true
139 ln -s `pwd`/addons $(INSTALL_PREFIX)/lib/io/addons
140 chmod -R ugo+rX $(INSTALL_PREFIX)/lib/io
142 uninstall:
143 rm -rf $(INSTALL_PREFIX)/lib/io
144 rm $(INSTALL_PREFIX)/bin/io
145 rm $(INSTALL_PREFIX)/bin/io_static$(BINARY_SUFFIX)
146 rm $(INSTALL_PREFIX)/bin/libiovmall.*
147 rm $(INSTALL_PREFIX)/lib/libiovmall.*
149 doc:
150 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io docs
152 cleanDocs:
153 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io cleanDocs
155 clean:
156 for dir in $(libs); do \
157 $(MAKE) -C libs/$$dir clean; \
158 done
160 cd tools; $(MAKE) cleanDocs; cd ..
161 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io clean || true
162 -rm -f IoBindingsInit.*
163 -rm -rf _build
164 -rm -rf projects/osx/build
165 -rm -rf projects/osxvm/build
166 $(MAKE) -C tools clean
168 testvm:
169 cd tools; make test
171 testaddons:
172 _build/binaries/io$(BINARY_SUFFIX) build.io runUnitTests
174 test:
175 $(MAKE) testvm
176 $(MAKE) testaddons
178 dist:
179 -rm -f Io-*.tar.gz
180 echo "#define IO_VERSION_NUMBER "$(shell date +'%Y%m%d') > libs/iovm/source/IoVersion.h
181 git add libs/iovm/source/IoVersion.h | true
182 git commit -q --no-verify -m "setting version string for release" | true
183 git archive --format=tar --prefix=Io-$(date)/ HEAD | gzip > Io-$(date).tar.gz
184 ls -al Io-$(date).tar.gz
186 metrics:
187 ls -1 libs/iovm/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " iovm"'
188 ls -1 libs/basekit/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " basekit"'
189 ls -1 libs/coroutine/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " libcoroutine"'
190 ls -1 libs/*/source/*.c | io -e 'File standardInput readLines map(asFile contents occurancesOfSeq(";")) sum .. " total in core"'
192 aptget:
193 _build/binaries/io$(BINARY_SUFFIX) build.io aptget
195 emerge:
196 _build/binaries/io$(BINARY_SUFFIX) build.io emerge
198 port:
199 _build/binaries/io$(BINARY_SUFFIX) build.io port
201 urpmi:
202 _build/binaries/io$(BINARY_SUFFIX) build.io urpmi
204 .DEFAULT:
205 ./_build/binaries/io_static$(BINARY_SUFFIX) build.io -a $@