summaryrefslogtreecommitdiff
path: root/js/config/Make.rules.js
blob: 4cea63850fea9183e85dc30aa8fa539c536001ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# **********************************************************************
#
# Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

#
# Select an installation base directory. The directory will be created
# if it does not exist.
#
prefix		?= /opt/Ice-$(VERSION)

#
# Define to yes for an optimized build.
#
OPTIMIZE 	?= no

#
# Google Closure Compiler
#
CLOSURE_PATH=/opt/closure

#
# Closure Flags
#
CLOSUREFLAGS	= --language_in ECMASCRIPT5

#
# jslint flags
#
LINTFLAGS 	= --verbose

#
# NodeJS executable
#
NODE 		?= node

# ----------------------------------------------------------------------
# Don't change anything below this line!
# ----------------------------------------------------------------------

#
# Common definitions
#
ice_language = js
slice_translator = slice2js

bindir = $(top_srcdir)/bin
libdir = $(top_srcdir)/lib

install_libdir 	  = $(prefix)/lib
install_moduledir = $(prefix)/node_modules/icejs

ifeq ($(OPTIMIZE),yes)
mklibtargets	= $(libdir)/$(1).min.js $(libdir)/$(1).min.js.gz

installlib	= $(INSTALL) $(2)/$(3).min.js $(1); \
		  $(INSTALL) $(2)/$(3).min.js.gz $(1) \
		  $(INSTALL) $(2)/$(3).js $(1); \
                  $(INSTALL) $(2)/$(3).js.gz $(1)
else
mklibtargets	= $(libdir)/$(1).js $(libdir)/$(1).js.gz

installlib	= $(INSTALL) $(2)/$(3).js $(1); \
		  $(INSTALL) $(2)/$(3).js.gz $(1)
endif

installmodule	= if test ! -d $(1)/$(3) ; \
	    	  then \
			echo "Creating $(1)/$(3)..." ; \
			mkdir -p $(1)/$(3) ; \
			chmod a+rx $(1)/$(3) ; \
		  fi ; \
		  for f in "$(2)"; \
		  do \
		      cp $$f $(1)/$(3); \
		  done;


ifeq ($(shell test -f $(top_srcdir)/config/Make.common.rules && echo 0),0)
    include $(top_srcdir)/config/Make.common.rules
else
    include $(top_srcdir)/../config/Make.common.rules
endif


ifdef ice_src_dist
    ifeq ($(ice_cpp_dir), $(ice_dir)/cpp)
        SLICE2JS 	= $(ice_cpp_dir)/bin/slice2js
        SLICEPARSERLIB 	= $(ice_cpp_dir)/lib/$(call mklibfilename,Slice,$(VERSION))
    else
        SLICE2JS 	= $(ice_cpp_dir)/$(binsubdir)/slice2js
    endif
else
    SLICE2JS 		= $(ice_js_dir)/$(binsubdir)/slice2js
endif

all:: $(TARGETS)

ifneq ($(GEN_SRCS),)
clean::
	rm -rf $(GEN_SRCS)
else
clean::
endif

ifneq ($(TARGETS),)
clean:: 
	rm -rf $(TARGETS)
endif

%.js: $(SDIR)/%.ice $(SLICE2JS) $(SLICEPARSERLIB)
	rm -f $(*F).js
	$(SLICE2JS) $(SLICE2JSFLAGS) $<

%.js: %.ice $(SLICE2JS) $(SLICEPARSERLIB)
	rm -f $(*F).js
	$(SLICE2JS) $(SLICE2JSFLAGS) $<

index.html: $(GEN_SRCS) $(top_srcdir)/test/Common/index.html
	cp $(top_srcdir)/test/Common/index.html .

$(libdir)/$(LIBNAME).js $(libdir)/$(LIBNAME).js.gz: $(SRCS)
	@rm -f $(libdir)/$(LIBNAME).js $(libdir)/$(LIBNAME).js.gz
	$(NODE) $(top_srcdir)/config/makebundle.js "$(MODULES)" $(SRCS) > $(libdir)/$(LIBNAME).js
	gzip -c9 $(libdir)/$(LIBNAME).js > $(libdir)/$(LIBNAME).js.gz

ifeq ($(OPTIMIZE),yes)
$(libdir)/$(LIBNAME).min.js $(libdir)/$(LIBNAME).min.js.gz: $(libdir)/$(LIBNAME).js
	@rm -f $(libdir)/$(LIBNAME).min.js $(libdir)/$(LIBNAME).min.js.gz
	$(NODE) $(top_srcdir)/config/makebundle.js "$(MODULES)" $(SRCS) > $(libdir)/$(LIBNAME).tmp.js
	java -jar $(CLOSURE_PATH)/compiler.jar $(CLOSUREFLAGS) --js $(libdir)/$(LIBNAME).js --js_output_file $(libdir)/$(LIBNAME).min.js
	gzip -c9 $(libdir)/$(LIBNAME).min.js > $(libdir)/$(LIBNAME).min.js.gz
	rm -f $(libdir)/$(LIBNAME).tmp.js
endif

.PHONY : lint

install::

EVERYTHING		= all clean install lint
EVERYTHING_EXCEPT_ALL	= install clean lint