]> git.ipfire.org Git - ipfire-2.x.git/blame - lfs/Config
BETA 1!
[ipfire-2.x.git] / lfs / Config
CommitLineData
cd1a2927
MT
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#
c7845ac1
MT
16URL_IPFIRE = http://source.ipfire.org/othersrc
17URL_TOOLCHAIN = http://source.ipfire.org/toolchain
cd1a2927
MT
18
19# Default compiler optimizations.
20#
21FLAGS_OPT = -O2
22FLAGS_CPU = -mcpu=$(MACHINE)
23FLAGS_ARCH = -march=$(MACHINE)
24
25# Don't change this; it will be overridden by other makefiles where necessary.
26#
27ROOT =
28
29# For most packages tarballs are unpacked here and then deleted after
30# installation.
31#
32DIR_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#
39DIR_DL = $(LFS_BASEDIR)/cache
40DIR_CHK = $(LFS_BASEDIR)/cache/check
3796e3d5 41DIR_CONF = $(LFS_BASEDIR)/config
cd1a2927 42DIR_INFO = $(LFS_BASEDIR)/log
05207d69 43DIR_TMP = /tmp
cd1a2927 44
03ad5f93 45KGCC = gcc
cd1a2927
MT
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#
54define 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*'
58endef
59
60# This is common starting logic for builds.
61#
62ifeq "$(ROOT)" ""
63define 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
03ad5f93
MT
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) && \
1b273e8f 72 sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-ipfire+' Makefile; \
03ad5f93
MT
73 else \
74 cd $(DIR_SRC)/linux-$(KVER) && \
1b273e8f 75 sed -i -e 's+^EXTRAVERSION.*$$+EXTRAVERSION\ =\ $(word 4,$(subst ., .,$(KVER)))-ipfire-smp+' Makefile; \
03ad5f93
MT
76 fi; \
77 fi
cd1a2927
MT
78endef
79else
80define PREBUILD
81 echo "====================================== Installing $(THISAPP) ..."
82endef
83endif
84
85# Common end-of-installation logic for Stage 2 and beyond.
86#
87ifeq "$(ROOT)" ""
88define POSTBUILD
03ad5f93 89 @echo "Install done; saving file list to $(TARGET) ..."
cd1a2927 90 @$(FIND_FILES) > $(DIR_SRC)/lsalrnew
0145f271 91 @diff $(DIR_SRC)/lsalr $(DIR_SRC)/lsalrnew | grep '^> ' | sed 's/^> //' | sort > $(TARGET)_diff
cd1a2927
MT
92 @cp -f $(DIR_SRC)/lsalrnew $(DIR_SRC)/lsalr
93 @rm -f $(DIR_SRC)/lsalrnew
0145f271 94 sed -i -e 's+.\/++' $(TARGET)_diff
cd1a2927
MT
95 # compare roofile ( same name as lfs script) with the list of installed files
96 # special cases
03ad5f93 97 # - if the corresponding rootfile is not found, touch $(TARGET)_missing_rootfile
0145f271 98 # - on a partial rebuild without a new file inside TARGET_diff, just touch TARGET
03ad5f93
MT
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
0145f271 103 if [ -s "$(TARGET)_diff" ]; then \
03ad5f93
MT
104 if [ "$(PASS)" = "SMP" ]; then LFS_SCRIPT=$(firstword $(MAKEFILE_LIST))-smp; \
105 else LFS_SCRIPT=$(firstword $(MAKEFILE_LIST)); \
106 fi; \
107 echo $(LFS_SCRIPT); \
a7ec5407 108 ROOTFILE=`find $(DIR_SRC)/config/rootfiles/common $(DIR_SRC)/config/rootfiles/packages -maxdepth 1 -type f -name $$LFS_SCRIPT`; \
03ad5f93
MT
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; \
0145f271
MT
117 sed "s/KVER/$(KVER)/g" $$ROOTFILE > $(TARGET)_rootfile; \
118 for line in `cat $(TARGET)_diff`; do \
03ad5f93 119 if grep -qE "^#$$line$$" $(TARGET)_rootfile; then echo "#$$line" >> $(TARGET); \
0145f271 120 elif grep -qE "^$$line$$" $(TARGET)_rootfile ; then echo "$$line" >> $(TARGET); \
cd1a2927
MT
121 else echo "+$$line" >> $(TARGET); \
122 fi; \
123 done; \
0145f271 124 rm -f $(TARGET)_rootfile; \
cd1a2927
MT
125 else \
126 touch $(TARGET); \
127 fi
0145f271 128 @rm -f $(TARGET)_diff
cd1a2927
MT
129endef
130else
131define POSTBUILD
132 @echo "===================================== Install done for $(THISAPP)."
133 touch $(TARGET)
134endef
135endif
136
137define CHECK
138 @echo -e "$(MESSAGE)Check: $($(notdir $@))"
139 wget -T 120 -t 1 --spider -nv $($(notdir $@)) -O /dev/null
140 @touch $(DIR_CHK)/$(notdir $@)
141endef
142
143define LOAD
144 @echo -e "$(MESSAGE)Download: $($(notdir $@))"
8a13df72 145 wget -T 60 -t 1 -c -nv $($(notdir $@)) -O $(DIR_TMP)/$(notdir $@)
cd1a2927
MT
146 [ "$($(notdir $@)_MD5)" = `md5sum $(DIR_TMP)/$(notdir $@) | awk '{ print $$1 }'` ] # detect page not found answer
147 mv $(DIR_TMP)/$(notdir $@) $(DIR_DL)
148endef
149
150define 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"
0145f271 154 echo "$@" >>$(DIR_INFO)/_build.othersrc-list.log
cd1a2927 155endef
a8b159e7
MT
156
157define PAK
5c8cfc99 158 # Bringing the files to their right place.
5b2a12ff 159 @rm -rf /install/packages/package
5c8cfc99 160 @mkdir -p /install/packages/package
3489ebac
MT
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
99e6df8e 169 chmod 755 /install/packages/package/{{,un}install,update}.sh
905fbf3e 170 cd / && tar cf /install/packages/package/files --files-from=/install/packages/package/ROOTFILES --exclude='#*'
3489ebac 171 -cat /install/packages/package/ROOTFILES | grep -v "#" > /install/packages/package/ROOTFILES
7d3af7f7 172 cd /install/packages/package && tar cf ../$(PROG)-$(VER)-$(PAK_VER).ipfire --files-from=/usr/src/src/paks/files
cab737ed 173 rm -rf /install/packages/package
5c8cfc99
MT
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 \
38965639 180 -e s/SIZE/`ls -l \/install\/packages\/$(PROG)-$(VER)-$(PAK_VER).ipfire | awk '{ print $$5 }'`/g \
5c8cfc99 181 < /usr/src/src/pakfire/meta > /install/packages/meta-$(PROG)
a8b159e7 182endef