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