Makefile 2.74 KB
Newer Older
Wolfgang Denk's avatar
Wolfgang Denk committed
1
#
2 3
# (C) Copyright 2006
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
Wolfgang Denk's avatar
Wolfgang Denk committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#
# (C) Copyright 2005
# Ladislav Michl, 2N Telekomunikace, michl@2n.cz
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#

include $(TOPDIR)/config.mk

29
LIB	= $(obj)lib$(BOARD).a
Wolfgang Denk's avatar
Wolfgang Denk committed
30

Ladislav Michl's avatar
Ladislav Michl committed
31
COBJS	:= netstar.o
Wolfgang Denk's avatar
Wolfgang Denk committed
32 33
SOBJS	:= setup.o crcek.o

34 35 36 37 38
SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c) eeprom.c \
		eeprom_start.S
OBJS	:= $(addprefix $(obj),$(COBJS))
SOBJS	:= $(addprefix $(obj),$(SOBJS))

Wolfgang Denk's avatar
Wolfgang Denk committed
39 40 41 42
gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)

LOAD_ADDR = 0x10400000
LDSCRIPT = $(TOPDIR)/board/$(BOARDDIR)/eeprom.lds
43
lnk = $(if $(obj),$(obj),.)
Wolfgang Denk's avatar
Wolfgang Denk committed
44

45
HOSTCFLAGS = -Wall -pedantic -I$(TOPDIR)/include
Wolfgang Denk's avatar
Wolfgang Denk committed
46

47 48
all:	$(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin \
		$(obj)crcek.srec $(obj)crcek.bin $(obj)crcit
Wolfgang Denk's avatar
Wolfgang Denk committed
49 50

$(LIB):	$(OBJS) $(SOBJS)
51
	$(AR) $(ARFLAGS) $@ $^
Wolfgang Denk's avatar
Wolfgang Denk committed
52

53 54 55
$(obj)eeprom.srec:	$(obj)eeprom.o $(obj)eeprom_start.o
	cd $(lnk) && $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \
		-o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \
56
		-L$(obj)../../examples/standalone -lstubs \
57
		-L$(obj)../../lib_generic -lgeneric \
Wolfgang Denk's avatar
Wolfgang Denk committed
58 59 60
		-L$(gcclibdir) -lgcc
	$(OBJCOPY) -O srec $(<:.o=) $@

61
$(obj)eeprom.bin:	$(obj)eeprom.srec
Wolfgang Denk's avatar
Wolfgang Denk committed
62 63
	$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null

64
$(obj)crcek.srec:	$(obj)crcek.o
Wolfgang Denk's avatar
Wolfgang Denk committed
65
	$(LD) -g -Ttext 0x00000000 \
66
		-o $(<:.o=) -e crcek $^
Wolfgang Denk's avatar
Wolfgang Denk committed
67 68
	$(OBJCOPY) -O srec $(<:.o=) $@

69
$(obj)crcek.bin:	$(obj)crcek.srec
Wolfgang Denk's avatar
Wolfgang Denk committed
70 71
	$(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null

72
$(obj)crcit:		$(obj)crcit.o $(obj)crc32.o
73
	$(HOSTCC) $(HOSTCFLAGS) -o $@ $^
Wolfgang Denk's avatar
Wolfgang Denk committed
74

75
$(obj)crcit.o:	crcit.c
76
	$(HOSTCC) $(HOSTCFLAGS) -o $@ -c $<
Wolfgang Denk's avatar
Wolfgang Denk committed
77

78
$(obj)crc32.o:	$(SRCTREE)/lib_generic/crc32.c
79
	$(HOSTCC) $(HOSTCFLAGS) -DUSE_HOSTCC -o $@ -c $<
Wolfgang Denk's avatar
Wolfgang Denk committed
80 81

clean:
82 83 84
	rm -f $(SOBJS) $(OBJS) $(obj)eeprom $(obj)eeprom.srec \
		$(obj)eeprom.bin $(obj)crcek $(obj)crcek.srec \
		$(obj)crcek.bin
Wolfgang Denk's avatar
Wolfgang Denk committed
85 86

distclean:	clean
87
	rm -f $(LIB) core *.bak $(obj).depend
Wolfgang Denk's avatar
Wolfgang Denk committed
88 89 90

#########################################################################

91 92
# defines $(obj).depend target
include $(SRCTREE)/rules.mk
Wolfgang Denk's avatar
Wolfgang Denk committed
93

94
sinclude $(obj).depend
Wolfgang Denk's avatar
Wolfgang Denk committed
95 96

#########################################################################