1 # Copyright 2010 Google Inc.
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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 BUILD_DATE = \"$(shell date -u)\"
18 BUILD_SHORT_DATE = \"$(shell date -u +%D)\"
19 BUILD_HOST = \"$(shell hostname)\"
20 BUILD_USER = \"$(shell whoami)\"
22 CFLAGS := -Wall -Os -m32 -nostdlib
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)"
31 LDFLAGS := -T $(LDSCRIPT) -nostdlib
38 SRCS = $(CSRCS) $(ASRCS)
40 OBJS = ${CSRCS:.c=.o} ${ASRCS:.S=.o}
41 INCS = ${CSRCS:.c=.h} ${ASRCS:.S=.h}
43 PROGS = sgabios.bin csum8
50 sgabios.bin: sgabios.elf
51 $(OBJCOPY) -O binary $< $@
54 sgabios.elf: .depend $(OBJS) $(LDSCRIPT) csum8
55 $(LD) $(LDFLAGS) $(OBJS) -o $@
58 $(CC) -Wall -O2 -o $@ $<
66 $(RM) $(PROGS) $(OBJS) *.elf *.srec *.com version.h
68 .depend:: $(INCS) $(SRCS) Makefile
70 $(CPP) -M $(CFLAGS) $(SRCS) >.tmpdepend && mv .tmpdepend .depend
72 ifeq (.depend, $(wildcard .depend))
75 # if no .depend file existed, add a make clean to the end of building .depend