Parially, a patch from Scott McKellar:
[OpenSRF.git] / src / Makefile
1 # TOP level 'src' makefile for OpenSRF
2
3 export TMPDIR   = $(TMP)/opensrf
4 export OPENSRF  = opensrf
5 export BINDIR   = $(PREFIX)/bin
6 export LIBDIR   = $(PREFIX)/lib
7 export PERLDIR  = $(LIBDIR)/perl5
8 export JSDIR    = $(LIBDIR)/javascript
9 export INCLUDEDIR= $(PREFIX)/include
10
11 export LDLIBS   += 
12 export LDFLAGS  += -Wl,-rpath=$(LIBDIR) -L $(TMPDIR) -L .
13 export CFLAGS   += -D_LARGEFILE64_SOURCE -pipe -g -Wall -O2 -fPIC -I ../../include/ -I$(LIBXML2_HEADERS) -I$(APACHE2_HEADERS) -I$(APR_HEADERS) 
14
15 ifneq ($(DEBUG), 1)
16 export CGLAGS += -DNDEBUG
17 endif
18
19 ifeq ($(OSRF_LEGACY_JSON), 1)
20 export LDLIBS += -lobjson
21 endif
22
23 all:    prep \
24         opensrf \
25         router \
26         srfsh \
27         jserver \
28         gateway \
29         java \
30         python-build
31
32 install:        install-prep \
33                 opensrf-install \
34                 gateway-install \
35                 router-install \
36                 srfsh-install \
37                 jserver-install \
38                 javascript-install \
39                 perl-install \
40                 python-install \
41                 java-install
42
43
44 # --------------------------------------------------------------------------------
45 # BINARIES and LIBS
46 # --------------------------------------------------------------------------------
47
48 prep:
49         mkdir -p $(TMPDIR)
50
51 opensrf:        prep
52         make -C libopensrf
53         make -C c-apps
54
55 router: opensrf
56         @echo $@
57         make -C router 
58
59 srfsh: opensrf
60         @echo $@
61         make -C srfsh
62
63 gateway:        opensrf
64         @echo $@
65         make -C gateway
66
67 jserver:        opensrf
68         @echo $@
69         make -C jserver
70
71
72 java:   prep
73         if [ -n "$(OSRF_INSTALL_JAVA)" ]; then echo $@; cd java && . deps.inc && make; fi;
74
75 python-build:
76         if [ -n "$(OSRF_INSTALL_PYTHON)" ]; then echo $@; make -C python build; fi;
77
78 # --------------------------------------------------------------------------------
79 # INSTALL
80 # --------------------------------------------------------------------------------
81
82 # make sure the install directories exist
83 install-prep:   
84         @echo $@
85         mkdir -p $(LIBDIR)
86         mkdir -p $(BINDIR)
87         mkdir -p $(JSDIR)
88         mkdir -p $(PERLDIR)
89         mkdir -p $(INCLUDEDIR)
90         mkdir -p $(ETCDIR)
91
92 # installs libopensrf.so, opensrf-c, headers, example configs, and osrf_ctl.sh
93 opensrf-install:        install-prep
94         @echo $@
95         cp $(TMPDIR)/libopensrf.so $(LIBDIR)/libopensrf.so
96         cp -r ../include/opensrf $(INCLUDEDIR)
97         cp libopensrf/opensrf $(BINDIR)/opensrf-c
98         make -C c-apps install
99         cp ../bin/osrf_ctl.sh $(BINDIR)
100         cp ../examples/opensrf.xml.example $(ETCDIR)
101         cp ../examples/opensrf_core.xml.example $(ETCDIR)
102         cp ../examples/srfsh.xml.example $(ETCDIR)
103         if [ ! -z "$(OSRF_LEGACY_JSON)" ]; then\
104                 cp -r ../include/objson $(INCLUDEDIR);\
105                 cp $(TMPDIR)/libobjson.so $(LIBDIR);\
106         fi
107
108 gateway-install:        install-prep opensrf-install    
109         @echo $@
110         make -C gateway install
111
112 router-install: install-prep opensrf-install
113         @echo $@
114         make -C router install
115
116 srfsh-install:  install-prep opensrf-install 
117         @echo $@
118         make -C srfsh install
119
120 jserver-install:        install-prep 
121         @echo $@
122         make -C jserver install
123
124 javascript-install:     install-prep
125         @echo $@
126         cp -r javascript/* $(JSDIR)/
127
128 perl-install:   install-prep
129         @echo $@
130         cp -r perlmods/* $(PERLDIR)/
131
132 python-install:
133         if [ -n "$(OSRF_INSTALL_PYTHON)" ]; then echo $@; make -C python install; fi;
134
135 java-install:
136         if [ -n "$(OSRF_INSTALL_JAVA)" ]; then echo $@; cd java && . deps.inc && make install; fi;
137
138 # --------------------------------------------------------------------------------
139 # CLEAN 
140 # --------------------------------------------------------------------------------
141 clean:
142         make -C libopensrf clean
143         make -C router clean
144         make -C gateway clean
145         make -C jserver clean
146         make -C srfsh clean
147         make -C c-apps clean
148         make -C java clean
149         if [ -n "$(OSRF_INSTALL_PYTHON)" ]; then echo $@; make -C python clean; fi;
150         /bin/rm -rf $(TMPDIR) *.o
151
152