source: mainline/boot/Makefile@ 63a045c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 63a045c was 63a045c, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

Unify handling of compressed init data and use regular tar + gzip to achieve it

There are two issues this commit solves.

First is that architecture-specific code duplicates most of the init binary
handling in each architecture, each with miniscule and confusing variations.
After this commit, the init binary expansion is almost entirely handled by
unified generic code.

Second is that the way we used to generate the incorporated data is somewhat
convoluted. Previously we have a Python script which generates a zip archive
with individual deflate-compressed files and accompanying header and C files
which contain structures describing the archive contents.
The zip file is then extracted and the individual deflate-compressed files are
included in the binary via assembler code.
Since gas doesn't take particular care to be consistent between architectures,
the assembly portions are also not uniform and the build script needs to know
particulars of the architecture's assembly.

Instead of doing that, after this commit we first gzip each included file, then
we pack the gzipped files into a tar archive, and then we include the archive
into the binary using objcopy.
Linker script provides symbols for the start and end of the archive,
and the payload is in a self-describing format, so there is no need for any
generated code.

Note that we are doing the opposite of the conventional .tar.gz format.
It would be somewhat inconvenient to use .tar.gz since the uncompressed files
need to be aligned to page size, so we'd have to first decompress the entire
payload to determine the final position of the files (and hence the required
amount of memory).

  • Property mode set to 100644
File size: 6.4 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29.PHONY: all build_dist clean_dist clean
30
31include Makefile.common
32
33all: $(VERSION_DEF) $(COMMON_MAKEFILE) $(COMMON_HEADER) $(CONFIG_MAKEFILE) $(CONFIG_HEADER) $(PREBUILD) build_dist
34 $(MAKE) -r -f $(BUILD) PRECHECK=$(PRECHECK)
35ifneq ($(POSTBUILD),)
36 $(MAKE) -r -f $(POSTBUILD) PRECHECK=$(PRECHECK)
37endif
38
39build_dist: clean_dist
40 mkdir -p "$(DIST_PATH)/app/"
41 mkdir -p "$(DIST_PATH)/cfg/"
42 mkdir -p "$(DIST_PATH)/data/"
43 mkdir -p "$(DIST_PATH)/lib/"
44 mkdir -p "$(DIST_PATH)/loc/"
45 mkdir -p "$(DIST_PATH)/log/"
46 mkdir -p "$(DIST_PATH)/srv/"
47 mkdir -p "$(DIST_PATH)/test/"
48 mkdir -p "$(DIST_PATH)/tmp/"
49 mkdir -p "$(DIST_PATH)/vol/"
50 mkdir -p "$(DIST_PATH)/w/"
51 for file in $(RD_SRVS) ; do \
52 cp "$$file" "$(DIST_PATH)/srv/" ; \
53 done
54 for file in $(RD_LIBS) ; do \
55 cp "$$file" "$(DIST_PATH)/lib/" ; \
56 done
57ifeq ($(CONFIG_DEVEL_FILES), y)
58 mkdir -p "$(DIST_PATH)/inc/c/"
59 cp -r -L "$(USPACE_PATH)/lib/c/include/." "$(DIST_PATH)/inc/c/"
60 cp -r -L "$(ROOT_PATH)/abi/include/." "$(DIST_PATH)/inc/c/"
61 cp -r -L "$(USPACE_PATH)/lib/c/arch/$(UARCH)/include/." "$(DIST_PATH)/inc/c/"
62 cat "$(USPACE_PATH)/lib/c/arch/$(UARCH)/_link.ld" | sed 's/^STARTUP(.*)$$//g' > "$(DIST_PATH)/inc/_link.ld"
63endif
64 for file in $(RD_APPS) ; do \
65 cp "$$file" "$(DIST_PATH)/app/" ; \
66 done
67 for file in $(RD_DATA) ; do \
68 cp "$$file" "$(DIST_PATH)/" ; \
69 done
70ifeq ($(CONFIG_PCUT_TESTS),y)
71 echo "echo Running all tests..." >"$(DIST_PATH)/test/run_all"
72 echo "<html><head><title>HelenOS test results</title></head><body>" >"$(DIST_PATH)/test/test.html"
73 echo "<h1>HelenOS test results</h1><ul>" >>"$(DIST_PATH)/test/test.html"
74 for file in $(RD_TESTS) ; do \
75 file2=`basename $$file`; \
76 cp "$$file" "$(DIST_PATH)/test/" ; \
77 echo "echo ' ->' $$file2" >>"$(DIST_PATH)/test/run_all"; \
78 echo "/test/$$file2 | to /test/$$file2.out" >>"$(DIST_PATH)/test/run_all"; \
79 echo "cat /test/$$file2.out" >>"$(DIST_PATH)/test/run_all"; \
80 echo "cp -f /test/$$file2.out /data/web/result-$$file2.txt" >>"$(DIST_PATH)/test/run_all"; \
81 echo "<li><a href=\"result-$$file2.txt\">$$file2</a></li>" >>"$(DIST_PATH)/test/test.html"; \
82 done
83 echo "cp -f /test/test.html /data/web/test.html" >>"$(DIST_PATH)/test/run_all"
84 echo "</ul></body></html>" >>"$(DIST_PATH)/test/test.html"
85endif
86
87ifeq ($(CONFIG_PCUT_SELF_TESTS),y)
88 echo "echo Running all PCUT self-tests..." >"$(DIST_PATH)/test/run_pcut"
89 echo "<html><head><title>Results of PCUT self-tests on HelenOS</title></head><body>" >"$(DIST_PATH)/test/pcut.html"
90 echo "<h1>Results of PCUT self-tests on HelenOS</h1><ul>" >>"$(DIST_PATH)/test/pcut.html"
91 for file in $(USPACE_PATH)/lib/pcut/test-libpcut-*; do \
92 file2=`basename $$file`; \
93 name=`echo "$$file2" | sed 's/test-libpcut-//'`; \
94 cp "$$file" "$(DIST_PATH)/test/" ; \
95 echo "echo ' ->' $$name" >>"$(DIST_PATH)/test/run_pcut"; \
96 echo "/test/$$file2 | to /test/$$file2.out" >>"$(DIST_PATH)/test/run_pcut"; \
97 echo "cat /test/$$file2.out" >>"$(DIST_PATH)/test/run_pcut"; \
98 echo "cp -f /test/$$file2.out /data/web/result-$$file2.txt" >>"$(DIST_PATH)/test/run_pcut"; \
99 echo "<li><a href=\"result-$$file2.txt\">$$name</a></li>" >>"$(DIST_PATH)/test/pcut.html"; \
100 done
101 echo "cp -f /test/pcut.html /data/web/pcut.html" >>"$(DIST_PATH)/test/run_pcut"
102 echo "</ul></body></html>" >>"$(DIST_PATH)/test/pcut.html"
103endif
104
105 for drv in $(RD_DRVS) ; do \
106 drv_dir="`dirname "$$drv"`" ; \
107 drv_name="`basename "$$drv"`" ; \
108 mkdir -p "$(DIST_PATH)/$(DRVS_PATH)/$$drv_name" ; \
109 cp "$(USPACE_PATH)/$(DRVS_PATH)/$$drv_dir/$$drv_name/$$drv_name" "$(DIST_PATH)/$(DRVS_PATH)/$$drv_name/" ; \
110 cp "$(USPACE_PATH)/$(DRVS_PATH)/$$drv_dir/$$drv_name/$$drv_name.ma" "$(DIST_PATH)/$(DRVS_PATH)/$$drv_name/" ; \
111 done
112 for file in $(RD_DRV_CFG) ; do \
113 file_dir="`dirname "$$file"`" ; \
114 file_name="`basename "$$file"`" ; \
115 cp "$(USPACE_PATH)/$(DRVS_PATH)/$$file_dir/$$file_name/"*".dev" "$(DIST_PATH)/$(DRVS_PATH)/$$file_name/" ; \
116 done
117 for file in $(RD_DRVS_FW) ; do \
118 file_dir="`dirname "$$file"`" ; \
119 file_name="`basename "$$file"`" ; \
120 cp "$(USPACE_PATH)/$(DRVS_PATH)/$$file_dir/$$file_name/$$file_name.fw" "$(DIST_PATH)/$(DRVS_PATH)/$$file_name/" ; \
121 done
122 if ls $(DIST_OVERLAY_PATH)/* >/dev/null 2>/dev/null; then \
123 cp -r -L $(DIST_OVERLAY_PATH)/* "$(DIST_PATH)"; \
124 fi
125
126clean: clean_dist
127 $(MAKE) -r -f $(BUILD) clean PRECHECK=$(PRECHECK)
128ifneq ($(POSTBUILD),)
129 $(MAKE) -r -f $(POSTBUILD) clean PRECHECK=$(PRECHECK)
130endif
131 rm -f $(POST_OUTPUT) $(BOOT_OUTPUT) arch/*/include/common.h
132 find generic/src/ arch/*/src/ genarch/src/ -name '*.o' -follow -exec rm \{\} \;
133 find . -name '*.d' -follow -exec rm \{\} \;
134
135clean_dist:
136 rm -f $(INITRD).img $(COMPS).o $(COMPS).tar $(LINK)
137 find $(USPACE_PATH)/dist -mindepth 1 -maxdepth 1 -type f -exec rm \{\} \;
138 rm -f $(USPACE_PATH)/dist/app/*
139 rm -f $(USPACE_PATH)/dist/cfg/*
140 rm -f $(USPACE_PATH)/dist/srv/*
141 rm -rf $(USPACE_PATH)/dist/drv/*
142 rm -rf $(USPACE_PATH)/dist/lib/*
143 rm -rf $(USPACE_PATH)/dist/inc/*
144 rm -f $(USPACE_PATH)/dist/app/*
145 rm -f $(USPACE_PATH)/dist/test/*
146 rm -f $(USPACE_PATH)/dist/cfg/net/*
147 rm -f $(USPACE_PATH)/dist/w/*
Note: See TracBrowser for help on using the repository browser.