updated make file to remove user defined files
[otp-base.git] / tools / .appgen / blank_app_rel / Makefile
blob6c861b68ccab217a719faa9d1094ce49c3786916
1 # ----------------------------------------------------
2 # Make file for creating a release.
3 # ----------------------------------------------------
5 ##
6 # Basename of this release.
7 ##
8 RELS=$(shell basename `pwd`)
10 include ../../build/otp.mk
12 include ./vsn.mk
14 USR_LIBPATH=../../lib
15 ERLWARE_LIB_PATH=$(ERLWARE_HOME)/application_packages/$(TARGET_ERTS_VSN)/lib
16 FSLIB_DIR=$(ERLWARE_LIB_PATH)/$(shell ls $(ERLWARE_LIB_PATH) | grep fslib | sort -r | head -n 1)
17 INSTALL_DIR=/usr/local/lib
18 ABS_USER_LIBPATH=$(shell cd ../../lib;pwd)
19 ERL=$(shell ERL=$(which erl); if [ "$${ERL}" = "" ];then ERL=$(ERLWARE_HOME)/bin/erl; fi; echo $${ERL})
20 FAXIEN=$(shell FAXIEN=$(which faxien); if [ "$${FAXIEN}" = "" ];then FAXIEN=$(ERLWARE_HOME)/bin/faxien; fi; echo $${FAXIEN})
22 # ----------------------------------------------------
23 # CREATE DIR STRUCTURE HERE
24 # ----------------------------------------------------
26 BUILD_FILES=fs_boot_smithe.beam fs_lists.beam fs_lib.beam
28 LOCAL_DIR=local
29 PACKAGE_DIR=$(RELS)-$(REL_VSN)
31 DIR_STRUCTURE= \
32 $(LOCAL_DIR) \
33 $(LOCAL_DIR)/log/$(REL_VSN) \
35 RELEASE_DEFINITION_FILES= \
36 $(RELS).rel \
37 $(RELS).script \
38 $(RELS).boot
40 LOCAL_RELEASE_DEFINITION_FILES= \
41 $(LOCAL_DIR)/$(RELS).script \
42 $(LOCAL_DIR)/$(RELS).boot
44 LOCAL_TARGET_FILES=$(LOCAL_HTTP_CONF) $(LOCAL_DIR)/$(RELS).config $(LOCAL_RELEASE_DEFINITION_FILES)
46 LOCAL_TARGETS=$(DIR_STRUCTURE) $(LOCAL_DIR)/$(RELS).sh vsnit $(LOCAL_TARGET_FILES)
48 # ----------------------------------------------------
49 # TARGETS
50 # ----------------------------------------------------
52 all debug opt instr script: $(LOCAL_TARGETS)
54 package: $(PACKAGE_DIR)
56 $(DIR_STRUCTURE):
57 mkdir -p $@
59 clean:
60 $(RM) -r $(PACKAGE_DIR)
61 $(RM) $(REL_SCRIPTS) $(TARGET_FILES)
62 $(RM) -r $(LOCAL_DIR) $(PRODN_DIR)
63 $(RM) $(RELS).rel
64 $(RM) -r $(RELS)
65 $(RM) $(RELS)*.tgz
66 $(RM) $(RELS).rel.src.tmp
67 $(RM) $(RELEASE_DEFINITION_FILES)
69 # ----------------------------------------------------
70 # TARGETS FOR LOCAL MODE
71 # ----------------------------------------------------
73 # startup script for local mode
74 $(LOCAL_DIR)/$(RELS).sh:
75 @echo '#!/bin/sh' > $@
76 @echo "cd $(CURDIR)/$(LOCAL_DIR)" >> $@
77 @echo "$(ERL) -name $${USER}_$(RELS) -boot $(RELS) -config $(RELS).config \$$@" >> $@
78 chmod +x $@
79 @echo
80 @echo "==== Start local node with \"sh $@\" ===="
81 @echo
83 # Create the config file for local mode.
84 $(LOCAL_DIR)/$(RELS).config: $(RELS).config.src
85 sed -e 's;%LOG_OTP%;$(CURDIR)/$(LOCAL_DIR)/log/$(REL_VSN);' \
86 -e 's;%REL_NAME%;$(RELS);g' \
87 -e 's;%HOME%;$(HOME);g' \
88 -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \
89 -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \
90 -e "s;%HOSTNAME%;`hostname --long`;" \
91 $< > $@
93 # Create the release file for local mode.
94 vsnit: $(RELS).rel.src
95 sed -e 's;%REL_VSN%;$(REL_VSN);' \
96 -e 's;%REL_NAME%;$(RELS);' \
97 -e 's;%ERTS_VSN%;$(TARGET_ERTS_VSN);' \
98 $< > $<.tmp
100 # Create and position script and boot files for local mode.
101 $(LOCAL_RELEASE_DEFINITION_FILES):
102 @echo "FSLIB_DIR: $(FSLIB_DIR)"
103 @ $(ERL) -pz $(FSLIB_DIR)/ebin \
104 -noshell \
105 -s fs_lib commandline_apply fs_boot_smithe make_script_and_boot [\"$(ERLWARE_LIB_PATH)/*\",\"$(ERL_RUN_TOP)/*\",\"$(USR_LIBPATH)\"] \
106 \"$$(basename `pwd`).rel.src.tmp\" \
107 [local] \
108 -s init stop
109 mv $(RELEASE_DEFINITION_FILES) $(LOCAL_DIR)/
111 # ----------------------------------------------------
112 # TARGETS FOR PACKAGE CREATION
113 # ----------------------------------------------------
115 # Create the config file for a package.
116 $(PACKAGE_DIR)/releases/$(REL_VSN)/$(RELS).config: $(RELS).config.src
117 mkdir -p `dirname $@`
118 sed -e 's;%LOG_OTP%;/tmp/;' \
119 -e 's;%REL_NAME%;$(RELS);g' \
120 -e 's;%REL_VSN%;$(REL_VSN);g' \
121 -e 's;%HOME%;$(HOME);g' \
122 -e 's;%BROADCAST_ADDRESS%;$(BROADCAST_ADDRESS);g' \
123 -e 's;%CONTACT_NODE%;$(CONTACT_NODE);g' \
124 $< > $@
126 # Create the executable script
127 $(PACKAGE_DIR)/bin/$(RELS): $(RELS).src
128 mkdir -p $(PACKAGE_DIR)/bin
129 sed -e 's;%REL_VSN%;$(REL_VSN);g' \
130 -e "s;%TARGET_ERTS_VSN%;$(TARGET_ERTS_VSN);" \
131 -e "s;%INVOCATION_SUFFIX%;-detached;" \
132 $< > $@
135 $(PACKAGE_DIR): $(LOCAL_TARGETS) $(PACKAGE_DIR)/bin/$(RELS) $(PACKAGE_DIR)/releases/$(REL_VSN)/$(RELS).config
136 cp $(LOCAL_DIR)/$(RELS).rel $@/releases/$(REL_VSN)
137 @echo "FSLIB_DIR: $(FSLIB_DIR)"
138 rm -rf $@/lib
139 mkdir $@/lib
140 @ $(ERL) -pz $(FSLIB_DIR)/ebin \
141 -noshell \
142 -s fs_lib commandline_apply fs_boot_smithe stage_apps [\"$(ERLWARE_LIB_PATH)/*\",\"$(USR_LIBPATH)/*\"] \
143 \"$(LOCAL_DIR)/$(RELS).rel\" \
144 $@/lib \
145 -s init stop
147 # ----------------------------------------------------
148 # TARGETS FOR INSTALLATION
149 # ----------------------------------------------------
151 install: $(PACKAGE_DIR)
152 $(FAXIEN) install-release $(PACKAGE_DIR)