SGABIOS: fix wrong video attrs for int 10h, ah==13h
[sgabios.git] / Makefile
1 # Copyright 2010 Google Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 # $Id$
16
17 BUILD_DATE = \"$(shell date -u)\"
18 BUILD_SHORT_DATE = \"$(shell date -u +%D)\"
19 BUILD_HOST = \"$(shell hostname)\"
20 BUILD_USER = \"$(shell whoami)\"
21
22 CFLAGS := -Wall -Os -m32 -nostdlib
23
24 ASFLAGS := $(CFLAGS)
25 ASFLAGS += -DBUILD_DATE="$(BUILD_DATE)"
26 ASFLAGS += -DBUILD_SHORT_DATE="$(BUILD_SHORT_DATE)"
27 ASFLAGS += -DBUILD_HOST="$(BUILD_HOST)"
28 ASFLAGS += -DBUILD_USER="$(BUILD_USER)"
29
30 LDSCRIPT := rom16.ld
31 LDFLAGS := -T $(LDSCRIPT) -nostdlib
32 OBJCOPY := objcopy
33
34 ASRCS = sgabios.S
35
36 CSRCS =
37
38 SRCS = $(CSRCS) $(ASRCS)
39
40 OBJS = ${CSRCS:.c=.o} ${ASRCS:.S=.o}
41 INCS = ${CSRCS:.c=.h} ${ASRCS:.S=.h}
42
43 PROGS = sgabios.bin csum8
44
45 .SUFFIXES: .bin .elf
46 .PHONY: buildinfo
47
48 all: $(PROGS)
49
50 sgabios.bin: sgabios.elf
51 $(OBJCOPY) -O binary $< $@
52 ./csum8 $@
53
54 sgabios.elf: .depend $(OBJS) $(LDSCRIPT) csum8
55 $(LD) $(LDFLAGS) $(OBJS) -o $@
56
57 csum8: csum8.c
58 $(CC) -Wall -O2 -o $@ $<
59
60 sgabios.o: buildinfo
61
62
63 buildinfo:
64 touch sgabios.S
65 clean:
66 $(RM) $(PROGS) $(OBJS) *.elf *.srec *.com version.h
67
68 .depend:: $(INCS) $(SRCS) Makefile
69 $(RM) .depend
70 $(CPP) -M $(CFLAGS) $(SRCS) >.tmpdepend && mv .tmpdepend .depend
71
72 ifeq (.depend, $(wildcard .depend))
73 include .depend
74 else
75 # if no .depend file existed, add a make clean to the end of building .depend
76 .depend::
77 $(MAKE) clean
78 endif