]>
Commit | Line | Data |
---|---|---|
1 | ############################################################################### | |
2 | # LFSMake # | |
3 | # by Rod Roark <rod@sunsetsystems.com> # | |
4 | # # | |
5 | # Copyright (C) 2002 Rod Roark # | |
6 | # # | |
7 | # See http://www.lfsmake.org/ for the most current standard version. # | |
8 | # # | |
9 | # These Makefiles are made available under the terms of the Artistic License, # | |
10 | # found at http://www.opensource.org/licenses/artistic-license.html. # | |
11 | ############################################################################### | |
12 | ||
13 | # URLs that are common sources of downloads. If you're having trouble with | |
14 | # a site you should change its URL to that of a suitable mirror site. | |
15 | # | |
16 | URL_IPFIRE = http://source.ipfire.org/othersrc | |
17 | URL_TOOLCHAIN = http://source.ipfire.org/toolchain | |
18 | URL_IPCOP = http://ipcop.ath.cx | |
19 | ||
20 | # Default compiler optimizations. | |
21 | # | |
22 | FLAGS_OPT = -O2 | |
23 | FLAGS_CPU = -mcpu=$(MACHINE) | |
24 | FLAGS_ARCH = -march=$(MACHINE) | |
25 | ||
26 | # Don't change this; it will be overridden by other makefiles where necessary. | |
27 | # | |
28 | ROOT = | |
29 | ||
30 | # For most packages tarballs are unpacked here and then deleted after | |
31 | # installation. | |
32 | # | |
33 | DIR_SRC = $(ROOT)/usr/src | |
34 | ||
35 | # Files are downloaded into DIR_TMP and then moved to DIR_DL, to avoid | |
36 | # messes with partially retrieved files. DIR_DL is where we will | |
37 | # save all the files that are downloaded. DIR_INFO contains the | |
38 | # file lists of installed packages. | |
39 | # | |
40 | DIR_DL = $(LFS_BASEDIR)/cache | |
41 | DIR_CHK = $(LFS_BASEDIR)/cache/check | |
42 | DIR_CONF = $(LFS_BASEDIR)/config | |
43 | DIR_INFO = $(LFS_BASEDIR)/log | |
44 | DIR_TMP = /tmp | |
45 | ||
46 | KGCC = gcc | |
47 | ||
48 | ############################################################################### | |
49 | # Common Macro Definitions | |
50 | ############################################################################### | |
51 | ||
52 | # For each package we create a list of files that it installed under | |
53 | # log/<TARGET> name. Modified files are not identified | |
54 | # | |
55 | define FIND_FILES | |
56 | cd $(ROOT)/ && find -mount \ | |
57 | -not -path './tools*' -not -path './tmp*' -not -path './usr/src*' \ | |
58 | -not -path './dev*' -not -path './proc*' -not -path './install*' | |
59 | endef | |
60 | ||
61 | # This is common starting logic for builds. | |
62 | # | |
63 | ifeq "$(ROOT)" "" | |
64 | define PREBUILD | |
65 | echo "====================================== Installing $(THISAPP) ..." | |
66 | @echo "Install started; saving file list to $(DIR_SRC)/lsalr ..." | |
67 | @if [ ! -f $(DIR_SRC)/lsalr ]; then $(FIND_FILES) > $(DIR_SRC)/lsalr; fi | |
68 | # Fix installation on partial rebuild, so modules install where they should | |
69 | # and not everytime on the last compiled kernel | |
70 | if [ -f $(DIR_SRC)/linux-$(KVER) ]; then \ | |
71 | if [ "$(SMP)" = "" ]; then \ | |
72 | cd $(DIR_SRC)/linux-$(KVER) && \ | |
73 | sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))+' Makefile; \ | |
74 | else \ | |
75 | cd $(DIR_SRC)/linux-$(KVER) && \ | |
76 | sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-smp+' Makefile; \ | |
77 | fi; \ | |
78 | fi | |
79 | endef | |
80 | else | |
81 | define PREBUILD | |
82 | echo "====================================== Installing $(THISAPP) ..." | |
83 | endef | |
84 | endif | |
85 | ||
86 | # Common end-of-installation logic for Stage 2 and beyond. | |
87 | # | |
88 | ifeq "$(ROOT)" "" | |
89 | define POSTBUILD | |
90 | @echo "Install done; saving file list to $(TARGET) ..." | |
91 | @$(FIND_FILES) > $(DIR_SRC)/lsalrnew | |
92 | @diff $(DIR_SRC)/lsalr $(DIR_SRC)/lsalrnew | grep '^> ' | sed 's/^> //' | sort > $(TARGET)_diff | |
93 | @cp -f $(DIR_SRC)/lsalrnew $(DIR_SRC)/lsalr | |
94 | @rm -f $(DIR_SRC)/lsalrnew | |
95 | sed -i -e 's+.\/++' $(TARGET)_diff | |
96 | # compare roofile ( same name as lfs script) with the list of installed files | |
97 | # special cases | |
98 | # - if the corresponding rootfile is not found, touch $(TARGET)_missing_rootfile | |
99 | # - on a partial rebuild without a new file inside TARGET_diff, just touch TARGET | |
100 | # $(TARGET)_diff : result of the diff | |
101 | # ROOTFILE : reference of include/exclude files | |
102 | # $(TARGET)_rootfile : ROOTFILE with KVER replacement | |
103 | # $(TARGET) : log result with {commented|include|added} files | |
104 | if [ -s "$(TARGET)_diff" ]; then \ | |
105 | if [ "$(PASS)" = "SMP" ]; then LFS_SCRIPT=$(firstword $(MAKEFILE_LIST))-smp; \ | |
106 | else LFS_SCRIPT=$(firstword $(MAKEFILE_LIST)); \ | |
107 | fi; \ | |
108 | echo $(LFS_SCRIPT); \ | |
109 | ROOTFILE=`find $(DIR_SRC)/config/rootfiles/common -maxdepth 1 -type f -name $$LFS_SCRIPT`; \ | |
110 | if [ "$$ROOTFILE" = "" ]; then \ | |
111 | ROOTFILE=`find $(DIR_SRC)/config/rootfiles/ver_$(IPFVER) -type f -name $$LFS_SCRIPT`; \ | |
112 | fi; \ | |
113 | if [ "$$ROOTFILE" = "" ]; then \ | |
114 | touch $(TARGET)_missing_rootfile; \ | |
115 | ROOTFILE=$(TARGET)_missing_rootfile ; \ | |
116 | echo "error $$LFS_SCRIPT not found in config/rootfiles"; \ | |
117 | fi; \ | |
118 | sed "s/KVER/$(KVER)/g" $$ROOTFILE > $(TARGET)_rootfile; \ | |
119 | for line in `cat $(TARGET)_diff`; do \ | |
120 | if grep -qE "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \ | |
121 | elif grep -qE "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \ | |
122 | else echo "+$$line" >> $(TARGET); \ | |
123 | fi; \ | |
124 | done; \ | |
125 | rm -f $(TARGET)_rootfile; \ | |
126 | else \ | |
127 | touch $(TARGET); \ | |
128 | fi | |
129 | @rm -f $(TARGET)_diff | |
130 | endef | |
131 | else | |
132 | define POSTBUILD | |
133 | @echo "===================================== Install done for $(THISAPP)." | |
134 | touch $(TARGET) | |
135 | endef | |
136 | endif | |
137 | ||
138 | define CHECK | |
139 | @echo -e "$(MESSAGE)Check: $($(notdir $@))" | |
140 | wget -T 120 -t 1 --spider -nv $($(notdir $@)) -O /dev/null | |
141 | @touch $(DIR_CHK)/$(notdir $@) | |
142 | endef | |
143 | ||
144 | define LOAD | |
145 | @echo -e "$(MESSAGE)Download: $($(notdir $@))" | |
146 | wget -T 60 -t 1 -c -nv $($(notdir $@)) -O $(DIR_TMP)/$(notdir $@) | |
147 | [ "$($(notdir $@)_MD5)" = `md5sum $(DIR_TMP)/$(notdir $@) | awk '{ print $$1 }'` ] # detect page not found answer | |
148 | mv $(DIR_TMP)/$(notdir $@) $(DIR_DL) | |
149 | endef | |
150 | ||
151 | define MD5 | |
152 | # error mean file signature don't match the one in lfs script | |
153 | [ "$($@_MD5)" = `md5sum $(DIR_DL)/$@ | awk '{ print $$1 }'` ] | |
154 | echo "$@ checksum OK" | |
155 | echo "$@" >>$(DIR_INFO)/_build.othersrc-list.log | |
156 | endef | |
157 | ||
158 | define PAK | |
159 | /usr/local/bin/packager $(PROG) $(VER) $(PAK_VER) | |
160 | endef |