]> git.ozlabs.org Git - yaboot.git/blob - Makefile
eabea8965e2f7868974ac45565bfa13ef875a26b
[yaboot.git] / Makefile
1 ## Setup
2
3 include Config
4
5 VERSION = 1.3.8-rc3
6 # Debug mode (spam/verbose)
7 DEBUG = 0
8 # make install vars
9 ROOT =
10 PREFIX = usr/local
11 MANDIR = man
12 # command used to get root (needed for tarball creation)
13 GETROOT = fakeroot
14
15 # We use fixed addresses to avoid overlap when relocating
16 # and other trouble with initrd
17
18 # Load the bootstrap at 2Mb
19 TEXTADDR        = 0x200000
20 # Malloc block at 3Mb -> 4Mb
21 MALLOCADDR      = 0x300000
22 MALLOCSIZE      = 0x100000
23 # Load kernel at 20Mb and ramdisk just after
24 KERNELADDR      = 0x01400000
25
26 # Set this to the prefix of your cross-compiler, if you have one.
27 # Else leave it empty.
28 #
29 CROSS = 
30
31 # The flags for the yaboot binary.
32 #
33 YBCFLAGS = -Os $(CFLAGS) -nostdinc -Wall -isystem `gcc -print-file-name=include` -fsigned-char
34 YBCFLAGS += -DVERSION=\"${VERSION}\"    #"
35 YBCFLAGS += -DTEXTADDR=$(TEXTADDR) -DDEBUG=$(DEBUG)
36 YBCFLAGS += -DMALLOCADDR=$(MALLOCADDR) -DMALLOCSIZE=$(MALLOCSIZE)
37 YBCFLAGS += -DKERNELADDR=$(KERNELADDR)
38 YBCFLAGS += -I ./include
39
40 ifeq ($(CONFIG_COLOR_TEXT),y)
41 YBCFLAGS += -DCONFIG_COLOR_TEXT
42 endif
43
44 ifeq ($(CONFIG_SET_COLORMAP),y)
45 YBCFLAGS += -DCONFIG_SET_COLORMAP
46 endif
47
48 ifeq ($(USE_MD5_PASSWORDS),y)
49 YBCFLAGS += -DUSE_MD5_PASSWORDS
50 endif
51
52 ifeq ($(CONFIG_FS_XFS),y)
53 YBCFLAGS += -DCONFIG_FS_XFS
54 endif
55
56 ifeq ($(CONFIG_FS_REISERFS),y)
57 YBCFLAGS += -DCONFIG_FS_REISERFS
58 endif
59
60 # Link flags
61 #
62 LFLAGS = -Ttext $(TEXTADDR) -Bstatic 
63
64 # Libraries
65 #
66 LLIBS = lib/libext2fs.a
67
68 # For compiling userland utils
69 #
70 UCFLAGS = -Os $(CFLAGS) -Wall -I/usr/include
71
72 # For compiling build-tools that run on the host.
73 #
74 HOSTCC = gcc
75 HOSTCFLAGS = -O2 $(CFLAGS) -Wall -I/usr/include
76
77 ## End of configuration section
78
79 OBJS = second/crt0.o second/yaboot.o second/cache.o second/prom.o second/file.o \
80         second/partition.o second/fs.o second/cfg.o second/setjmp.o second/cmdline.o \
81         second/fs_of.o second/fs_ext2.o second/fs_iso.o second/iso_util.o \
82         lib/nosys.o lib/string.o lib/strtol.o lib/vsprintf.o lib/ctype.o lib/malloc.o lib/strstr.o
83
84 ifeq ($(USE_MD5_PASSWORDS),y)
85 OBJS += second/md5.o
86 endif
87
88 ifeq ($(CONFIG_FS_XFS),y)
89 OBJS += second/fs_xfs.o
90 endif
91
92 ifeq ($(CONFIG_FS_REISERFS),y)
93 OBJS += second/fs_reiserfs.o
94 endif
95
96 # compilation
97 CC              := $(CROSS)gcc
98 LD              := $(CROSS)ld
99 AS              := $(CROSS)as
100 OBJCOPY         := $(CROSS)objcopy
101
102 lgcc = `$(CC) -print-libgcc-file-name`
103
104 all: yaboot addnote mkofboot
105
106 yaboot: $(OBJS)
107         $(LD) $(LFLAGS) $(OBJS) $(LLIBS) $(lgcc) -o second/$@
108         chmod -x second/yaboot
109
110 addnote:
111         $(CC) $(UCFLAGS) -o util/addnote util/addnote.c
112
113 elfextract:
114         $(CC) $(UCFLAGS) -o util/elfextract util/elfextract.c
115
116 mkofboot:
117         ln -sf ybin ybin/mkofboot
118         @if [ $$(grep '^VERSION=' ybin/ybin | cut -f2 -d=) != ${VERSION} ] ; then       \
119                 echo "ybin/ybin: warning: VERSION  mismatch";                           \
120                 false;                                                                  \
121         fi
122
123 %.o: %.c
124         $(CC) $(YBCFLAGS) -c -o $@ $<
125
126 %.o: %.S
127         $(CC) $(YBCFLAGS) -D__ASSEMBLY__  -c -o $@ $<
128
129 dep:
130         makedepend -Iinclude *.c lib/*.c util/*.c gui/*.c
131
132 docs:
133         make -C doc all
134
135 bindist: all
136         mkdir ../yaboot-binary-${VERSION}
137         $(GETROOT) make ROOT=../yaboot-binary-${VERSION} install
138         mkdir -p -m 755 ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot
139         cp -a COPYING ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/COPYING
140         cp -a README ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/README
141         cp -a doc/README.rs6000 ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/README.rs6000
142         cp -a doc/yaboot-howto.html ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/yaboot-howto.html
143         cp -a doc/yaboot-howto.sgml ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/yaboot-howto.sgml
144         mv ../yaboot-binary-${VERSION}/etc/yaboot.conf ../yaboot-binary-${VERSION}/usr/local/share/doc/yaboot/
145         rmdir ../yaboot-binary-${VERSION}/etc
146         $(GETROOT) tar -C ../yaboot-binary-${VERSION} -zcvpf ../yaboot-binary-${VERSION}.tar.gz .
147         rm -rf ../yaboot-binary-${VERSION}
148
149 clean:
150         rm -f second/yaboot util/addnote util/elfextract $(OBJS)
151         find . -not -path './\{arch\}*' -name '#*' | xargs rm -f
152         find . -not -path './\{arch\}*' -name '.#*' | xargs rm -f
153         find . -not -path './\{arch\}*' -name '*~' | xargs rm -f
154         find . -not -path './\{arch\}*' -name '*.swp' | xargs rm -f
155         find . -not -path './\{arch\}*' -name ',,*' | xargs rm -rf
156         -gunzip man/*.gz
157         rm -rf man.deb
158
159 cleandocs:
160         make -C doc clean
161
162 ## removes arch revision control crap, only to be called for making
163 ## release tarballs.  arch should have a export command like cvs...
164
165 archclean:
166         rm -rf '{arch}'
167         find . -type d -name .arch-ids | xargs rm -rf
168         rm -f 0arch-timestamps0
169
170 maintclean: clean cleandocs
171
172 release: docs bindist clean
173
174 strip: all
175         strip second/yaboot
176         strip --remove-section=.comment second/yaboot
177         strip util/addnote
178         strip --remove-section=.comment --remove-section=.note util/addnote
179
180 install: all strip
181         install -d -o root -g root -m 0755 ${ROOT}/etc/
182         install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/sbin/
183         install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/lib
184         install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/lib/yaboot
185         install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/${MANDIR}/man5/
186         install -d -o root -g root -m 0755 ${ROOT}/${PREFIX}/${MANDIR}/man8/
187         install -o root -g root -m 0644 second/yaboot ${ROOT}/$(PREFIX)/lib/yaboot
188         install -o root -g root -m 0755 util/addnote ${ROOT}/${PREFIX}/lib/yaboot/addnote
189         install -o root -g root -m 0644 first/ofboot ${ROOT}/${PREFIX}/lib/yaboot/ofboot
190         install -o root -g root -m 0755 ybin/ofpath ${ROOT}/${PREFIX}/sbin/ofpath
191         install -o root -g root -m 0755 ybin/ybin ${ROOT}/${PREFIX}/sbin/ybin
192         install -o root -g root -m 0755 ybin/yabootconfig ${ROOT}/${PREFIX}/sbin/yabootconfig
193         rm -f ${ROOT}/${PREFIX}/sbin/mkofboot
194         ln -s ybin ${ROOT}/${PREFIX}/sbin/mkofboot
195         @gzip -9 man/*.[58]
196         install -o root -g root -m 0644 man/bootstrap.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/bootstrap.8.gz
197         install -o root -g root -m 0644 man/mkofboot.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/mkofboot.8.gz
198         install -o root -g root -m 0644 man/ofpath.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/ofpath.8.gz
199         install -o root -g root -m 0644 man/yaboot.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/yaboot.8.gz
200         install -o root -g root -m 0644 man/yabootconfig.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/yabootconfig.8.gz
201         install -o root -g root -m 0644 man/ybin.8.gz ${ROOT}/${PREFIX}/${MANDIR}/man8/ybin.8.gz
202         install -o root -g root -m 0644 man/yaboot.conf.5.gz ${ROOT}/${PREFIX}/${MANDIR}/man5/yaboot.conf.5.gz
203         @gunzip man/*.gz
204         @if [ ! -e ${ROOT}/etc/yaboot.conf ] ; then                                             \
205                 echo "install -o root -g root -m 0644 etc/yaboot.conf ${ROOT}/etc/yaboot.conf"; \
206                 install -o root -g root -m 0644 etc/yaboot.conf ${ROOT}/etc/yaboot.conf;        \
207          else                                                                                   \
208                 echo "/etc/yaboot.conf already exists, leaving it alone";                       \
209          fi
210         @echo
211         @echo "Installation successful."
212         @echo
213         @echo "An example /etc/yaboot.conf has been installed (unless /etc/yaboot.conf already existed)"
214         @echo "You may either alter that file to match your system, or alternatively run yabootconfig"
215         @echo "yabootconfig will generate a simple and valid /etc/yaboot.conf for your system"
216         @echo
217
218 deinstall:
219         rm -f ${ROOT}/${PREFIX}/sbin/ofpath
220         rm -f ${ROOT}/${PREFIX}/sbin/ybin
221         rm -f ${ROOT}/${PREFIX}/sbin/yabootconfig
222         rm -f ${ROOT}/${PREFIX}/sbin/mkofboot
223         rm -f ${ROOT}/${PREFIX}/lib/yaboot/yaboot
224         rm -f ${ROOT}/${PREFIX}/lib/yaboot/ofboot
225         rm -f ${ROOT}/${PREFIX}/lib/yaboot/addnote
226         @rmdir ${ROOT}/${PREFIX}/lib/yaboot || true
227         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/bootstrap.8.gz
228         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/mkofboot.8.gz
229         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/ofpath.8.gz
230         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/yaboot.8.gz
231         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/yabootconfig.8.gz
232         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man8/ybin.8.gz
233         rm -f ${ROOT}/${PREFIX}/${MANDIR}/man5/yaboot.conf.5.gz
234         @if [ -L ${ROOT}/boot/yaboot -a ! -e ${ROOT}/boot/yaboot ] ; then rm -f ${ROOT}/boot/yaboot ; fi
235         @if [ -L ${ROOT}/boot/ofboot.b -a ! -e ${ROOT}/boot/ofboot.b ] ; then rm -f ${ROOT}/boot/ofboot.b ; fi
236         @echo
237         @echo "Deinstall successful."
238         @echo "${ROOT}/etc/yaboot.conf has not been removed, you may remove it yourself if you wish."
239
240 uninstall: deinstall