]> git.ipfire.org Git - ipfire-2.x.git/blob - lfs/Config
6266b1f14599365ff5495e4bb76ba21cf69641c0
[ipfire-2.x.git] / lfs / Config
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
19 # Default compiler optimizations.
20 #
21 FLAGS_OPT = -O2
22 FLAGS_CPU = -mcpu=$(MACHINE)
23 FLAGS_ARCH = -march=$(MACHINE)
24
25 # Don't change this; it will be overridden by other makefiles where necessary.
26 #
27 ROOT =
28
29 # For most packages tarballs are unpacked here and then deleted after
30 # installation.
31 #
32 DIR_SRC = $(ROOT)/usr/src
33
34 # Files are downloaded into DIR_TMP and then moved to DIR_DL, to avoid
35 # messes with partially retrieved files. DIR_DL is where we will
36 # save all the files that are downloaded. DIR_INFO contains the
37 # file lists of installed packages.
38 #
39 DIR_DL = $(LFS_BASEDIR)/cache
40 DIR_CHK = $(LFS_BASEDIR)/cache/check
41 DIR_CONF = $(LFS_BASEDIR)/config
42 DIR_INFO = $(LFS_BASEDIR)/log
43 DIR_TMP = /tmp
44
45 KGCC = gcc
46
47 ###############################################################################
48 # Common Macro Definitions
49 ###############################################################################
50
51 # For each package we create a list of files that it installed under
52 # log/<TARGET> name. Modified files are not identified
53 #
54 define FIND_FILES
55 cd $(ROOT)/ && find -mount \
56 -not -path './tools*' -not -path './tmp*' -not -path './usr/src*' \
57 -not -path './dev*' -not -path './proc*' -not -path './install*'
58 endef
59
60 # This is common starting logic for builds.
61 #
62 ifeq "$(ROOT)" ""
63 define PREBUILD
64 echo "====================================== Installing $(THISAPP) ..."
65 @echo "Install started; saving file list to $(DIR_SRC)/lsalr ..."
66 @if [ ! -f $(DIR_SRC)/lsalr ]; then $(FIND_FILES) > $(DIR_SRC)/lsalr; fi
67 # Fix installation on partial rebuild, so modules install where they should
68 # and not everytime on the last compiled kernel
69 if [ -f $(DIR_SRC)/linux-$(KVER) ]; then \
70 if [ "$(SMP)" = "" ]; then \
71 cd $(DIR_SRC)/linux-$(KVER) && \
72 sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-ipfire+' Makefile; \
73 else \
74 cd $(DIR_SRC)/linux-$(KVER) && \
75 sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-ipfire-smp+' Makefile; \
76 fi; \
77 fi
78 endef
79 else
80 define PREBUILD
81 echo "====================================== Installing $(THISAPP) ..."
82 endef
83 endif
84
85 # Common end-of-installation logic for Stage 2 and beyond.
86 #
87 ifeq "$(ROOT)" ""
88 define POSTBUILD
89 @echo "Install done; saving file list to $(TARGET) ..."
90 @$(FIND_FILES) > $(DIR_SRC)/lsalrnew
91 @diff $(DIR_SRC)/lsalr $(DIR_SRC)/lsalrnew | grep '^> ' | sed 's/^> //' | sort > $(TARGET)_diff
92 @cp -f $(DIR_SRC)/lsalrnew $(DIR_SRC)/lsalr
93 @rm -f $(DIR_SRC)/lsalrnew
94 sed -i -e 's+.\/++' $(TARGET)_diff
95 # compare roofile ( same name as lfs script) with the list of installed files
96 # special cases
97 # - if the corresponding rootfile is not found, touch $(TARGET)_missing_rootfile
98 # - on a partial rebuild without a new file inside TARGET_diff, just touch TARGET
99 # $(TARGET)_diff : result of the diff
100 # ROOTFILE : reference of include/exclude files
101 # $(TARGET)_rootfile : ROOTFILE with KVER replacement
102 # $(TARGET) : log result with {commented|include|added} files
103 if [ -s "$(TARGET)_diff" ]; then \
104 if [ "$(PASS)" = "SMP" ]; then LFS_SCRIPT=$(firstword $(MAKEFILE_LIST))-smp; \
105 else LFS_SCRIPT=$(firstword $(MAKEFILE_LIST)); \
106 fi; \
107 echo $(LFS_SCRIPT); \
108 ROOTFILE=`find $(DIR_SRC)/config/rootfiles/common $(DIR_SRC)/config/rootfiles/packages -maxdepth 1 -type f -name $$LFS_SCRIPT`; \
109 if [ "$$ROOTFILE" = "" ]; then \
110 ROOTFILE=`find $(DIR_SRC)/config/rootfiles/ver_$(IPFVER) -type f -name $$LFS_SCRIPT`; \
111 fi; \
112 if [ "$$ROOTFILE" = "" ]; then \
113 touch $(TARGET)_missing_rootfile; \
114 ROOTFILE=$(TARGET)_missing_rootfile ; \
115 echo "error $$LFS_SCRIPT not found in config/rootfiles"; \
116 fi; \
117 sed "s/KVER/$(KVER)/g" $$ROOTFILE > $(TARGET)_rootfile; \
118 for line in `cat $(TARGET)_diff`; do \
119 if grep -qE "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
120 elif grep -qE "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
121 else echo "+$$line" >> $(TARGET); \
122 fi; \
123 done; \
124 rm -f $(TARGET)_rootfile; \
125 else \
126 touch $(TARGET); \
127 fi
128 @rm -f $(TARGET)_diff
129 endef
130 else
131 define POSTBUILD
132 @echo "===================================== Install done for $(THISAPP)."
133 touch $(TARGET)
134 endef
135 endif
136
137 define CHECK
138 @echo -e "$(MESSAGE)Check: $($(notdir $@))"
139 wget -T 120 -t 1 --spider -nv $($(notdir $@)) -O /dev/null
140 @touch $(DIR_CHK)/$(notdir $@)
141 endef
142
143 define LOAD
144 @echo -e "$(MESSAGE)Download: $($(notdir $@))"
145 wget -T 60 -t 1 -c -nv $($(notdir $@)) -O $(DIR_TMP)/$(notdir $@)
146 [ "$($(notdir $@)_MD5)" = `md5sum $(DIR_TMP)/$(notdir $@) | awk '{ print $$1 }'` ] # detect page not found answer
147 mv $(DIR_TMP)/$(notdir $@) $(DIR_DL)
148 endef
149
150 define MD5
151 # error mean file signature don't match the one in lfs script
152 [ "$($@_MD5)" = `md5sum $(DIR_DL)/$@ | awk '{ print $$1 }'` ]
153 echo "$@ checksum OK"
154 echo "$@" >>$(DIR_INFO)/_build.othersrc-list.log
155 endef
156
157 define PAK
158 # Bringing the files to their right place.
159 @rm -rf /install/packages/package
160 @mkdir -p /install/packages/package
161 if [ -e "/usr/src/src/paks $(PROG)" ]; then \
162 cp -f /usr/src/src/paks/$(PROG)/{,un}install.sh /usr/src/src/paks/$(PROG)/update.sh \
163 /install/packages/package; \
164 else \
165 cp -f /usr/src/src/paks/default/{,un}install.sh /usr/src/src/paks/default/update.sh \
166 /install/packages/package; \
167 fi
168 sed -e "s/KVER/$(KVER)/g" < /usr/src/config/rootfiles/packages/$(PROG) > /install/packages/package/ROOTFILES
169 chmod 755 /install/packages/package/{{,un}install,update}.sh
170 cd / && tar cf /install/packages/package/files --files-from=/install/packages/package/ROOTFILES --exclude='#*'
171 -cat /install/packages/package/ROOTFILES | grep -v "#" > /install/packages/package/ROOTFILES
172 cd /install/packages/package && tar cf ../$(PROG)-$(VER)-$(PAK_VER).ipfire --files-from=/usr/src/src/paks/files
173 rm -rf /install/packages/package
174 sed -e s/NAME/$(PROG)/g \
175 -e s/VER/$(VER)/g \
176 -e s/RELEASE/$(PAK_VER)/g \
177 -e s/DEPS/$(DEPS)/g \
178 -e s/DESCDE/$(DESCDE)/g \
179 -e s/DESCEN/$(DESCEN)/g \
180 -e s/SIZE/`ls -l \/install\/packages\/$(PROG)-$(VER)-$(PAK_VER).ipfire | awk '{ print $$5 }'`/g \
181 < /usr/src/src/pakfire/meta > /install/packages/meta-$(PROG)
182 endef