summaryrefslogtreecommitdiffstats
path: root/rules/flash.make
blob: d4dc300ff7a860acff10b8ef523bd6af45aea977 (plain)
1
2
3
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# -*-makefile-*-
# $Id: flash.make,v 1.3 2003/10/23 15:01:19 mkl Exp $
#
# Copyright (C) 2002 by Pengutronix e.K., Hildesheim, Germany
# See CREDITS for details about who has contributed to this project. 
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# We provide this package
#
ifeq (y,$(PTXCONF_FLASH))
PACKAGES += flash
endif

#
# Paths and names 
#
FLASH			= flash-0.9.5
FLASH_URL 		= http://www.netsoc.ucd.ie/flash/$(FLASH).tar.gz
FLASH_SOURCE		= $(SRCDIR)/$(FLASH).tar.gz
FLASH_DIR 		= $(BUILDDIR)/$(FLASH)
FLASH_EXTRACT		= gzip -dc

FLASH_PATCH		= flash-0.9.5-ptx2.diff
FLASH_PATCH_URL		= http://www.pengutronix.de/software/ptxdist/temporary-src/$(FLASH_PATCH)
FLASH_PATCH_SOURCE	= $(SRCDIR)/$(FLASH_PATCH)
FLASH_PATCH_EXTRACT	= cat


# ----------------------------------------------------------------------------
# Get
# ----------------------------------------------------------------------------

flash_get: $(STATEDIR)/flash.get

flash_get_deps	=  $(FLASH_SOURCE)
flash_get_deps	+= $(FLASH_PATCH_SOURCE)

$(STATEDIR)/flash.get: $(flash_get_deps)
	@$(call targetinfo, $@)
	touch $@

$(FLASH_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, $(FLASH_URL))

$(FLASH_PATCH_SOURCE):
	@$(call targetinfo, $@)
	@$(call get, $(FLASH_PATCH_URL))


# ----------------------------------------------------------------------------
# Extract
# ----------------------------------------------------------------------------

flash_extract: $(STATEDIR)/flash.extract

$(STATEDIR)/flash.extract: $(STATEDIR)/flash.get
	@$(call targetinfo, $@)
	$(FLASH_EXTRACT) $(FLASH_SOURCE) | $(TAR) -C $(BUILDDIR) -xf -
	cd $(FLASH_DIR) && patch -p1 < $(FLASH_PATCH_SOURCE)
	touch $@


# ----------------------------------------------------------------------------
# Prepare
# ----------------------------------------------------------------------------

flash_prepare: $(STATEDIR)/flash.prepare

#
# dependencies
#
flash_prepare_deps =  \
	$(STATEDIR)/virtual-xchain.install \
	$(STATEDIR)/ncurses.compile \
	$(STATEDIR)/autoconf257.install \
        $(STATEDIR)/flash.extract

FLASH_PATH	= PATH=$(PTXCONF_PREFIX)/$(AUTOCONF257)/bin:$(CROSS_PATH)
FLASH_ENV	= $(CROSS_ENV)

#
# autoconf
#
FLASH_AUTOCONF	=  --prefix=/usr
FLASH_AUTOCONF	+= --build=$(GNU_HOST)
FLASH_AUTOCONF	+= --host=$(PTXCONF_GNU_TARGET)
FLASH_AUTOCONF	+= --with-ncurses-path=$(BUILDDIR)/ncurses-5.2

$(STATEDIR)/flash.prepare: $(flash_prepare_deps)
	@$(call targetinfo, $@)
	@$(call clean, $(FLASH_BUILDDIR))
	mkdir -p $(FLASH_DIR)
	rm -f $(FLASH_DIR)/configure
	cd $(FLASH_DIR) && autoconf
#	# Workaround for broken autoconf magic for cross compilation
	cd $(FLASH_DIR) && \
		ac_cv_func_getpgrp_void=yes	\
		ac_cv_func_setpgrp_void=yes	\
		ac_cv_sizeof_long_long=8	\
		ac_cv_func_memcmp_clean=yes	\
		ac_cv_func_getrlimit=yes	\
		$(FLASH_PATH) $(FLASH_ENV) $(FLASH_DIR)/configure $(FLASH_AUTOCONF)
	touch $@

# ----------------------------------------------------------------------------
# Compile
# ----------------------------------------------------------------------------

flash_compile: $(STATEDIR)/flash.compile

$(STATEDIR)/flash.compile: $(STATEDIR)/flash.prepare 
	@$(call targetinfo, $@)
	$(FLASH_PATH) make -C $(FLASH_DIR)
	touch $@

# ----------------------------------------------------------------------------
# Install
# ----------------------------------------------------------------------------

flash_install: $(STATEDIR)/flash.install

$(STATEDIR)/flash.install: $(STATEDIR)/flash.compile
	@$(call targetinfo, $@)
	touch $@

# ----------------------------------------------------------------------------
# Target-Install
# ----------------------------------------------------------------------------

flash_targetinstall: $(STATEDIR)/flash.targetinstall

$(STATEDIR)/flash.targetinstall: $(STATEDIR)/flash.install
	@$(call targetinfo, $@)
	install -d $(ROOTDIR)/usr/bin
	install $(FLASH_DIR)/flash $(ROOTDIR)/usr/bin
	$(CROSS_STRIP) -R .note -R .comment $(ROOTDIR)/usr/bin/flash
	touch $@
# ----------------------------------------------------------------------------
# Clean
# ----------------------------------------------------------------------------

flash_clean: 
	rm -rf $(STATEDIR)/flash.* $(FLASH_DIR)

# vim: syntax=make