1#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10#   http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20THRIFT = ../../compiler/cpp/thrift
21THRIFT_OMIT_FILE = test/Thrift_omit_without.thrift
22THRIFT_FILES = $(wildcard test/*.thrift) \
23		  $(THRIFT_OMIT_FILE) \
24		  ../../test/v0.16/ConstantsDemo.thrift \
25		  ../../test/v0.16/NameConflictTest.thrift \
26		  ../../test/DoubleConstantsTest.thrift \
27		  ../../test/v0.16/ThriftTest.thrift
28
29ERL_FLAG = erl
30ERL_FLAG_LEGACY = erl:legacynames
31ERL_FLAG_MAPS = erl:maps
32
33$(THRIFT_OMIT_FILE): test/Thrift_omit_with.thrift
34	grep -v omit $< >$@
35
36.generated: $(THRIFT) $(THRIFT_FILES)
37	for f in $(THRIFT_FILES) ; do \
38		$(THRIFT) --gen $(ERL_FLAG) -o test $$f ; \
39	done
40	$(THRIFT) --gen $(ERL_FLAG_LEGACY) -o test test/flags/LegacyNames.thrift
41	$(THRIFT) --gen $(ERL_FLAG_MAPS) -o test test/flags/Thrift3214.thrift
42	touch .generated
43
44all: .generated
45	$(REBAR) compile
46
47check: .generated
48	$(REBAR) eunit
49
50install: all
51	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift) ; \
52	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/ebin ; \
53	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/include ; \
54	mkdir -p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/src ; \
55	for p in ebin/*.app* ebin/*.beam include/*.hrl src/*.erl ; \
56		do $(INSTALL) $$p $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)/$$p ; \
57	done
58
59uninstall:
60	$(RM) -rf $(DESTDIR)$(ERLANG_INSTALL_LIB_DIR_thrift)
61
62clean-local:
63	$(REBAR) clean
64	$(RM)    .generated
65	$(RM) -r .rebar/
66	$(RM) -r _build/
67	$(RM) -r test/gen-erl/
68	$(RM)    $(THRIFT_OMIT_FILE)
69
70maintainer-clean-local:
71	$(RM) -r ebin/
72
73dist-hook:
74	$(RM)    $(distdir)/.generated
75	$(RM) -r $(distdir)/.rebar/
76	$(RM) -r $(distdir)/_build/
77	$(RM) -r $(distdir)/ebin/
78	$(RM) -r $(distdir)/test/gen-erl/
79	$(RM)    $(distdir)/$(THRIFT_OMIT_FILE)
80
81EXTRA_DIST = \
82	include \
83	src \
84	coding_standards.md \
85	rebar.config \
86	rebar.config.script \
87	test \
88	README.md
89
90MAINTAINERCLEANFILES = Makefile.in
91