summaryrefslogtreecommitdiffstats
path: root/testsuites/automake/compile.am
blob: 01eaf56b080dce69944d3d3d4c6c6d6de7a19da1 (plain) (blame)
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
##
## $Id$
##

## -------------------------------------------------------------------------
## NOTE: This file is rather immature and has to be considered to be
## almost experimental.
##
## Expect frequent changes -- It deserves to be cleaned up :(
## -------------------------------------------------------------------------

if RTEMS_USE_GCC
## All the stuff below is specific to gcc
GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS)
endif # RTEMS_USE_GCC

LINK_LIBS = $(LD_LIBS)

#
# How to compile stuff into ${ARCH} subdirectory
#

COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@

CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
	$(AM_LDFLAGS) $(LDFLAGS) -o $@

CCASCOMPILE = $(CCAS) $(AM_CCASFLAGS) $(CCASFLAGS)

${ARCH}/%.o: %.c $(ARCH)/$(dirstamp)
	${COMPILE} -o $@ -c $<

${ARCH}/%.o: %.cc $(ARCH)/$(dirstamp)
	${CXXCOMPILE} -o $@ -c $<

${ARCH}/%.o: %.S $(ARCH)/$(dirstamp)
	${CCASCOMPILE} -DASM -o $@ -c $<

${ARCH}/$(dirstamp):
	@$(mkdir_p) $(ARCH)
	@: > $(ARCH)/$(dirstamp)

# Dependency files for use by gmake
# NOTE: we don't put them into $(ARCH)
#       so that 'make clean' doesn't blow it away

DEPEND=Depends-${ARCH}

# We deliberately don't have anything depend on the
# $(DEPEND) file; otherwise it will get rebuilt even
# on 'make clean'
#

if RTEMS_USE_GCC
## HACK: Specific to gcc
## FIXME: The approach below is known to be conceptionally broken.
depend-gcc: $(C_FILES) $(CC_FILES) $(S_FILES)
##       Use gcc -M to generate dependencies
##       Replace foo.o with $(ARCH)/foo.o
##       Replace $(ARCH) value with string $(ARCH)
##           so that it will for debug cases
	$(COMPILE) -M   $^    |  \
	sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
	    -e 's?$(ARCH)/?$$(ARCH)/?'   >$(DEPEND).tmp
	mv $(DEPEND).tmp $(DEPEND)

# pull in dependencies if they exist
ifeq (${DEPEND},$(wildcard ${DEPEND}))
include ${DEPEND}
@ENDIF@
endif
depend: depend-am

# spell out all the LINK_FILE's, rather than using -lbsp, so
#  that $(LINK_FILES) can be a dependency

LINK_OBJS = \
    $(OBJS) \
    $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)

LINK_FILES =\
    $(START_FILE) \
    $(OBJS) \
    $(MANAGERS_NOT_WANTED:%=$(PROJECT_LIB)/no-%.rel)

## -------------------------------------------------------------------------
## Setup the variant build subdirectory
ARCH = o-optimize

## -------------------------------------------------------------------------
CC = @CC@ $(GCCSPECS)
CXX = @CXX@ $(GCCSPECS)
CPP = @CPP@ $(GCCSPECS)
CCAS = @CCAS@ $(GCCSPECS)

LD = @LD@
OBJCOPY = @OBJCOPY@
NM = @NM@
SIZE = @SIZE@
STRIP = @STRIP@

##
AM_CPPFLAGS = $(RTEMS_CPPFLAGS)
AM_CFLAGS = $(RTEMS_CFLAGS)
AM_CXXFLAGS = $(RTEMS_CXXFLAGS)
AM_CCASFLAGS = $(CPU_CFLAGS) $(RTEMS_CPPFLAGS) $(RTEMS_CCASFLAGS)

clean-local:
	$(RM) -r o-optimize
	$(RM) Depends-o-optimize.tmp