| 1 | # Makefile for libgloss/epiphany |
|---|
| 2 | |
|---|
| 3 | # Copyright (c) 2011, 2012 Adapteva, Inc. |
|---|
| 4 | # All rights reserved. |
|---|
| 5 | |
|---|
| 6 | # Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc |
|---|
| 7 | |
|---|
| 8 | # Redistribution and use in source and binary forms, with or without |
|---|
| 9 | # modification, are permitted provided that the following conditions are met: |
|---|
| 10 | # * Redistributions of source code must retain the above copyright notice, |
|---|
| 11 | # this list of conditions and the following disclaimer. |
|---|
| 12 | # * Redistributions in binary form must reproduce the above copyright |
|---|
| 13 | # notice, this list of conditions and the following disclaimer in the |
|---|
| 14 | # documentation and/or other materials provided with the distribution. |
|---|
| 15 | # * Neither the name of Adapteva nor the names of its contributors may be |
|---|
| 16 | # used to endorse or promote products derived from this software without |
|---|
| 17 | # specific prior written permission. |
|---|
| 18 | |
|---|
| 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 20 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 21 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 22 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|---|
| 23 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 24 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 25 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 26 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 27 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 28 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 29 | # POSSIBILITY OF SUCH DAMAGE. |
|---|
| 30 | |
|---|
| 31 | # Standard proforma copied from libnosys |
|---|
| 32 | DESTDIR = |
|---|
| 33 | VPATH = @srcdir@ |
|---|
| 34 | srcdir = @srcdir@ |
|---|
| 35 | objdir = . |
|---|
| 36 | srcroot = $(srcdir)/../.. |
|---|
| 37 | objroot = $(objdir)/../.. |
|---|
| 38 | |
|---|
| 39 | prefix = @prefix@ |
|---|
| 40 | exec_prefix = @exec_prefix@ |
|---|
| 41 | |
|---|
| 42 | host_alias = @host_alias@ |
|---|
| 43 | target_alias = @target_alias@ |
|---|
| 44 | program_transform_name = @program_transform_name@ |
|---|
| 45 | |
|---|
| 46 | bindir = @bindir@ |
|---|
| 47 | libdir = @libdir@ |
|---|
| 48 | tooldir = $(exec_prefix)/$(target_alias) |
|---|
| 49 | |
|---|
| 50 | # Multilib support variables. |
|---|
| 51 | # TOP is used instead of MULTI{BUILD,SRC}TOP. |
|---|
| 52 | MULTIDIRS = |
|---|
| 53 | MULTISUBDIR = |
|---|
| 54 | MULTIDO = true |
|---|
| 55 | MULTICLEAN = true |
|---|
| 56 | |
|---|
| 57 | INSTALL = @INSTALL@ |
|---|
| 58 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
|---|
| 59 | INSTALL_DATA = @INSTALL_DATA@ |
|---|
| 60 | |
|---|
| 61 | SHELL = /bin/sh |
|---|
| 62 | |
|---|
| 63 | CC = @CC@ |
|---|
| 64 | |
|---|
| 65 | #AS = @AS@ |
|---|
| 66 | AS = `if [ -f ${objroot}/../gas/as-new ] ; \ |
|---|
| 67 | then echo ${objroot}/../gas/as-new ; \ |
|---|
| 68 | else echo as ; fi` |
|---|
| 69 | |
|---|
| 70 | AR = @AR@ |
|---|
| 71 | |
|---|
| 72 | #LD = @LD@ |
|---|
| 73 | LD = `if [ -f ${objroot}/../ld/ld-new ] ; \ |
|---|
| 74 | then echo ${objroot}/../ld/ld-new ; \ |
|---|
| 75 | else echo ld ; fi` |
|---|
| 76 | |
|---|
| 77 | RANLIB = @RANLIB@ |
|---|
| 78 | |
|---|
| 79 | OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \ |
|---|
| 80 | then echo ${objroot}/../binutils/objdump ; \ |
|---|
| 81 | else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi` |
|---|
| 82 | OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \ |
|---|
| 83 | then echo ${objroot}/../binutils/objcopy ; \ |
|---|
| 84 | else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi` |
|---|
| 85 | |
|---|
| 86 | GCC_LDFLAGS = `if [ -d ${objroot}/../gcc ] ; \ |
|---|
| 87 | then echo -L${objroot}/../gcc ; fi` |
|---|
| 88 | |
|---|
| 89 | NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi` |
|---|
| 90 | NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi` |
|---|
| 91 | |
|---|
| 92 | INCLUDES = -I. -I$(srcdir)/.. -I$(srcdir)/../../newlib/libc/machine/epiphany |
|---|
| 93 | |
|---|
| 94 | # Note that when building the library, ${MULTILIB} is not the way multilib |
|---|
| 95 | # options are passed; they're passed in $(CFLAGS). |
|---|
| 96 | CFLAGS_FOR_TARGET = ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS} |
|---|
| 97 | LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS} |
|---|
| 98 | AR_FLAGS = qc |
|---|
| 99 | |
|---|
| 100 | .c.o: |
|---|
| 101 | $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $< |
|---|
| 102 | |
|---|
| 103 | .C.o: |
|---|
| 104 | $(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $< |
|---|
| 105 | .S.o: |
|---|
| 106 | $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $(CFLAGS) $< |
|---|
| 107 | .s.o: |
|---|
| 108 | $(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $< |
|---|
| 109 | |
|---|
| 110 | # |
|---|
| 111 | # GCC knows to run the preprocessor on .S files before it assembles them. |
|---|
| 112 | # |
|---|
| 113 | .S.o: |
|---|
| 114 | $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $< |
|---|
| 115 | |
|---|
| 116 | # |
|---|
| 117 | # this is a bogus target that'll produce an assembler from the |
|---|
| 118 | # C source with the right compiler options. this is so we can |
|---|
| 119 | # track down code generation or debug symbol bugs. |
|---|
| 120 | # |
|---|
| 121 | .c.s: |
|---|
| 122 | $(CC) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $(CFLAGS) $< |
|---|
| 123 | |
|---|
| 124 | # EPIPHANY specific stuff |
|---|
| 125 | |
|---|
| 126 | # Object files needed for all libraries |
|---|
| 127 | COMMON_OBJS = access.o \ |
|---|
| 128 | close.o \ |
|---|
| 129 | environ.o \ |
|---|
| 130 | execve.o \ |
|---|
| 131 | fork.o \ |
|---|
| 132 | fstat.o \ |
|---|
| 133 | getpid.o \ |
|---|
| 134 | gettimeofday.o \ |
|---|
| 135 | _isatty.o \ |
|---|
| 136 | kill.o \ |
|---|
| 137 | link.o \ |
|---|
| 138 | lseek.o \ |
|---|
| 139 | open.o \ |
|---|
| 140 | read.o \ |
|---|
| 141 | sbrk.o \ |
|---|
| 142 | stat.o \ |
|---|
| 143 | times.o \ |
|---|
| 144 | unlink.o \ |
|---|
| 145 | wait.o \ |
|---|
| 146 | write.o \ |
|---|
| 147 | _exit.o \ |
|---|
| 148 | epiphany-syscalls.o \ |
|---|
| 149 | epiphany-ivthandlers.o |
|---|
| 150 | |
|---|
| 151 | UNUSED_OBJS = chown.o \ |
|---|
| 152 | errno.o \ |
|---|
| 153 | gettod.o \ |
|---|
| 154 | readlink.o \ |
|---|
| 155 | symlink.o |
|---|
| 156 | |
|---|
| 157 | # Object files specific to particular targets. |
|---|
| 158 | SIMOBJS = $(COMMON_OBJS) |
|---|
| 159 | |
|---|
| 160 | OUTPUTS = libepiphany.a crt0.o |
|---|
| 161 | |
|---|
| 162 | all: $(OUTPUTS) |
|---|
| 163 | |
|---|
| 164 | # |
|---|
| 165 | # here's where we build the library for each target |
|---|
| 166 | # |
|---|
| 167 | |
|---|
| 168 | libepiphany.a: $(SIMOBJS) |
|---|
| 169 | ${AR} ${ARFLAGS} $@ $(SIMOBJS) |
|---|
| 170 | ${RANLIB} $@ |
|---|
| 171 | |
|---|
| 172 | _exit.o: _exit.S |
|---|
| 173 | $(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $< |
|---|
| 174 | |
|---|
| 175 | doc: |
|---|
| 176 | |
|---|
| 177 | clean mostlyclean: |
|---|
| 178 | rm -f $(OUTPUTS) *.i *~ *.o *-test *.srec *.dis *.map *.x |
|---|
| 179 | |
|---|
| 180 | distclean maintainer-clean realclean: clean |
|---|
| 181 | rm -f Makefile config.status $(OUTPUTS) |
|---|
| 182 | |
|---|
| 183 | .PHONY: install info install-info clean-info |
|---|
| 184 | install: |
|---|
| 185 | @for outputs in ${OUTPUTS}; do\ |
|---|
| 186 | mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \ |
|---|
| 187 | $(INSTALL_PROGRAM) $${outputs} $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \ |
|---|
| 188 | done |
|---|
| 189 | info: |
|---|
| 190 | install-info: |
|---|
| 191 | clean-info: |
|---|
| 192 | |
|---|
| 193 | Makefile: Makefile.in config.status @host_makefile_frag_path@ |
|---|
| 194 | $(SHELL) config.status |
|---|
| 195 | |
|---|
| 196 | config.status: configure |
|---|
| 197 | $(SHELL) config.status --recheck |
|---|