1#
2# %CopyrightBegin%
3#
4# Copyright Ericsson AB 2003-2016. All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# 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, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18# %CopyrightEnd%
19#
20
21include $(ERL_TOP)/make/target.mk
22include $(ERL_TOP)/make/$(TARGET)/otp.mk
23include $(ERL_TOP)/erts/vsn.mk
24
25VERSION_HEADER = erlang.nsh
26MAKENSIS = makensis
27MAKENSISFLAGS = /V2
28CUSTOM_MODERN=custom_modern.exe
29
30# This is not the way we usually do in our makefiles,
31# but making release is the ONLY thing we do with this one,
32# Its not called during ordinary recursive make.
33all: release
34
35opt debug depend:
36	@echo Nothing to do for "'"$@"'" on $(TARGET)
37
38clean:
39	rm -f $(VERSION_HEADER)
40
41include $(ERL_TOP)/make/otp_release_targets.mk
42
43TARGET_DIR = $(RELEASE_PATH)
44
45ifdef MSYSTEM
46 ifeq ($(MSYSTEM),$(filter $(MSYSTEM),MSYS MINGW32 MINGW64))
47  USEMSYS := true
48 endif
49endif
50
51ifeq ($(USEMSYS),true)
52
53  MAKENSISFLAGS = //V2
54  WTESTROOT=$(shell (msys2win_path.sh "$(RELEASE_PATH)"))
55  WTARGET_DIR=$(shell (msys2win_path.sh "$(TARGET_DIR)"))
56
57else
58
59  MAKENSISFLAGS = /V2
60  WTESTROOT=$(shell (cygpath -d "$(RELEASE_PATH)" 2>/dev/null || cygpath -w "$(RELEASE_PATH)"))
61  WTARGET_DIR=$(shell (cygpath -d "$(TARGET_DIR)" 2>/dev/null || cygpath -d "$(TARGET_DIR)"))
62
63endif
64
65ifeq ($(CONFIG_SUBTYPE),win64)
66  WINTYPE=win64
67else
68  WINTYPE=win32
69endif
70
71REDIST_FILE=$(shell (sh ./find_redist.sh || echo ""))
72ifeq ($(USEMSYS),true)
73	NICEREDISTFILE=$(shell (msys2win_path.sh -m "$(REDIST_FILE)" 2>/dev/null || echo ""))
74else
75	NICEREDISTFILE=$(shell (cygpath -d -m "$(REDIST_FILE)" 2>/dev/null || echo ""))
76endif
77
78REDIST_TARGET=$(shell (sh ./find_redist.sh -n || echo ""))
79REDIST_DLL_VERSION=$(shell (sh ./dll_version_helper.sh $(NICEREDISTFILE) || echo ""))
80REDIST_DLL_NAME=$(shell (sh ./dll_version_helper.sh -n $(NICEREDISTFILE) || echo ""))
81
82release_spec:
83	@NSIS_VER=`makensis /hdrinfo | head -1 | awk '{print $$2}'`; \
84	case $$NSIS_VER in \
85	v2.0b*) \
86	  echo '!define MUI_VERSION "$(SYSTEM_VSN)"' > $(VERSION_HEADER);\
87	  echo '!define ERTS_VERSION "$(VSN)"' >> $(VERSION_HEADER);\
88	  echo '!define TESTROOT "$(WTESTROOT)"' >> $(VERSION_HEADER);\
89	  echo '!define OUTFILEDIR "$(WTARGET_DIR)"' >> $(VERSION_HEADER);\
90	  if [ -f "$(RELEASE_PATH)/docs/doc/index.html" ];\
91	  then\
92		echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \
93	  fi;\
94	  $(MAKENSIS) erlang.nsi;;\
95	v2.*) \
96	  echo '!define OTP_VERSION "$(SYSTEM_VSN)"' > $(VERSION_HEADER);\
97	  echo '!define ERTS_VERSION "$(VSN)"' >> $(VERSION_HEADER);\
98	  echo '!define TESTROOT "$(WTESTROOT)"' >> $(VERSION_HEADER);\
99	  echo '!define OUTFILEDIR "$(WTARGET_DIR)"' >> $(VERSION_HEADER);\
100	  echo '!define WINTYPE "$(WINTYPE)"' >> $(VERSION_HEADER);\
101	  if [ -f $(CUSTOM_MODERN) ];\
102	  then \
103		echo '!define HAVE_CUSTOM_MODERN 1' >> $(VERSION_HEADER); \
104	  fi;\
105	  if [ '!' -z "$(REDIST_FILE)" -a '!' -z "$(REDIST_DLL_VERSION)" ];\
106	  then \
107		cp $(REDIST_FILE) "$(RELEASE_PATH)/$(REDIST_TARGET)";\
108		echo '!define HAVE_REDIST_FILE 1'  >> $(VERSION_HEADER); \
109		echo '!define REDIST_DLL_VERSION "$(REDIST_DLL_VERSION)"' >> $(VERSION_HEADER);\
110		echo '!define REDIST_DLL_NAME "$(REDIST_DLL_NAME)"' >> $(VERSION_HEADER);\
111		echo '!define REDIST_EXECUTABLE "$(REDIST_TARGET)"' >> $(VERSION_HEADER);\
112	  fi;\
113	  if [ -f "$(RELEASE_PATH)/docs/doc/index.html" ];\
114	  then \
115		echo '!define HAVE_DOCS 1' >> $(VERSION_HEADER); \
116	  fi;\
117	  echo "Running $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi";\
118	  $(MAKENSIS) $(MAKENSISFLAGS) erlang20.nsi;;\
119	*) \
120	  echo 'Unsupported NSIS version';;\
121	esac
122
123release_docs release_docs_spec docs:
124
125