summaryrefslogtreecommitdiff
path: root/extra/gcc-uClibc/Makefile
blob: bbe17cc9976a70187051618c24d3fe67d8b1d869 (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
# Makefile for building a fake gcc/binutils toolchain
# that simply spoofs the location of the C library
#
# Copyright (C) 2000-2002 Erik Andersen <andersen@uclibc.org>
#

TOPDIR = ../../
include $(TOPDIR)Rules.mak

UCLIBC_DIR := $(shell (cd $(TOPDIR); /bin/pwd))
GCC_BIN := $(shell which $(CC))
LD_BIN := $(shell which $(LD))
GCCINCDIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")

all:	$(TARGET_ARCH)-uclibc-gcc $(TARGET_ARCH)-uclibc-ld

gcc-uClibc.h:	Makefile $(TOPDIR)/.config
	@echo "/* this file was autogenerated by make */" > $@
	@echo "#define UCLIBC_TARGET_PREFIX " \"$(TARGET_PREFIX)\" >> $@
	@echo "#define UCLIBC_DEVEL_PREFIX " \"$(DEVEL_PREFIX)\" >> $@
	@echo "#define UCLIBC_BUILD_DIR " \"$(UCLIBC_DIR)\" >> $@
	@echo "#define GCC_BIN " \"$(GCC_BIN)\" >> $@
	@echo "#define LIBGCC_DIR " \"$(LIBGCC_DIR)\" >> $@
	@echo "#define TARGET_ARCH " \"$(TARGET_ARCH)\" >> $@
	@echo "#define DYNAMIC_LINKER " \"$(DYNAMIC_LINKER)\" >> $@
	@echo "#define BUILD_DYNAMIC_LINKER " \"$(UCLIBC_DIR)/lib/$(UCLIBC_LDSO)\" >> $@
ifeq ($(strip $(HAVE_SHARED)),y)
	@echo "#define __UCLIBC_HAS_SHARED__ 1" >> $@
else
	@echo "#undef __UCLIBC_HAS_SHARED__" >> $@
endif
ifeq ($(strip $(UCLIBC_HAS_MMU)),y)
	@echo "#define __UCLIBC_HAS_MMU__ 1" >> $@
else
	@echo "#undef __UCLIBC_HAS_MMU__" >> $@
endif
ifeq ($(strip $(HAS_ELF)),y)
	@echo "#define __HAS_ELF__ 1" >> $@
else
	@echo "#undef __HAS_ELF__" >> $@
endif
ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
	@echo "#define __UCLIBC_CTOR_DTOR__ 1" >> $@
ifeq ($(strip $(UCLIBC_PROFILING)),y)
	@echo "#define __UCLIBC_PROFILING__ 1" >> $@
else
	@echo "#undef __UCLIBC_PROFILING__" >> $@
endif
else
	@echo "#undef __UCLIBC_CTOR_DTOR__" >> $@
endif

$(TARGET_ARCH)-uclibc-gcc:	gcc-uClibc.c gcc-uClibc.h
	$(HOSTCC) $(HOSTCFLAGS) -s $< -o $@

$(TARGET_ARCH)-uclibc-ld:	Makefile $(TOPDIR)/.config
	@echo "#!/bin/sh" > $@
	@echo "# This file was autogenerated by make" >> $@
	@echo "exec $(LD_BIN) \"\$$@\" -L$(DEVEL_PREFIX)/usr/lib " \
		"-L$(DEVEL_PREFIX)/lib -L$(UCLIBC_DIR)" >> $@
	chmod a+x $@

install:	all
	$(INSTALL) -d $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin
	$(INSTALL) -d $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin
	$(INSTALL) -m 755 $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
	$(INSTALL) -m 755 $(TARGET_ARCH)-uclibc-ld $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/
	ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-cc
	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/gcc
	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/cc
	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-ld  $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/ld
ifeq ($(strip $(UCLIBC_CTOR_DTOR)),y)
	ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-g++
	ln -fs $(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-c++
	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/c++
	ln -fs $(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-gcc $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/g++
endif
	for app in addr2line ar as cpp gasp nm objcopy \
	    objdump ranlib size strings strip; do \
	  APPNAME=`which $(CROSS)$${app} 2>/dev/null`; \
	  if [ -x "$$APPNAME" ] ; then \
	    ln -fs "$$APPNAME" $(PREFIX)$(DEVEL_TOOL_PREFIX)/bin/$${app}; \
	    ln -fs "$$APPNAME" $(PREFIX)$(SYSTEM_DEVEL_PREFIX)/bin/$(TARGET_ARCH)-uclibc-$${app}; \
	  fi; \
	done

clean:
	$(RM) gcc-uClibc.h *-uclibc-gcc *-uclibc-ld core