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