0c073e815fa3d520b8e0af8d5f47f12e41a8e0f5
[bcm963xx.git] / userapps / opensource / libcreduction / Makefile
1 #
2 # Makefile to call either uclibc or glibc optimizer
3
4 # Copyright (C) 2004 Broadcom Corporation
5 #
6
7 # Platform dependencies, use different utility to optimize glibc and uclibc
8 ifneq ($(strip $(BRCM_UCLIBC)),)
9   PLATFORM := uclibc
10 else
11   PLATFORM := glibc
12 endif
13
14 ifneq ($(strip $(BRCM_APP_PHONE)),)
15 LIBOPT := n
16 else
17 LIBOPT := y
18 endif
19
20 ifeq ($(PLATFORM),glibc)
21   LIBC := libc.so.6
22   LINKER := ld.so.1
23 else
24   ifeq ($(PLATFORM),uclibc)
25     LIBC := libc.so.0
26     LINKER := ld-uClibc.so.0
27   else
28     LIBC := libc.so.6
29     LINKER := ld-linux.so.2
30   endif
31 endif
32
33 # $(LIBC) and $(LINKER) is copied directly from toolchain installation, if no optimization
34 # $(LIBC) and $(LINKER) is copied from $(PLATFORM) after optimization, if we need optimization
35 # mklibs.py can optimize all the libraries, not just libc
36 # mklibs.py automatically finds all the necessary libraries, so the extralibs.mak applies to
37 # glibc or no optimization, which we have to manually specify
38
39 ifneq ($(LIBOPT),y)
40
41 TARGETS := $(LIBDIR)/$(LIBC) $(LIBDIR)/$(LINKER)
42 # Additional libraries to install
43 include extralibs.mak
44
45 libopt:
46
47 else
48
49 # Optimize libraries from archives
50 # if glibc, $(LIBC) is generated in $(PLATFORM) directory by generate_library
51 # if uclic, $(LIBC) is generated in $(PLATFORM) directory by mklibs.py 
52
53 ifeq ($(PLATFORM),glibc)
54   TARGETS := $(PLATFORM)/$(LIBC) $(PLATFORM)/$(LINKER)
55 else
56   ifeq ($(PLATFORM),uclibc)
57     TARGETS := $(PLATFORM)/lib* $(PLATFORM)/$(LINKER)
58   endif
59 endif
60 BINARIES := `find $(INSTALL_DIR) -path $(INSTALL_DIR)/lib -prune -o -type f -print | file -f - | grep ELF | cut -d':' -f1`
61
62 libopt:
63         @echo Optimizing C run-time library...
64         @if [ "$(PLATFORM)" = "glibc" ]; then \
65             @cp -f $(LIBDIR)/$(LINKER) $(PLATFORM); \
66             $(SHELL) -e generate_library $(PLATFORM) $(BINARIES); \
67         fi
68         @if [ "$(PLATFORM)" = "uclibc" ]; then \
69             python ./mklibs.py -D -L $(LIBDIR) -L $(INSTALL_DIR)/lib --target=$(CROSS_COMPILE) -d $(PLATFORM) $(BINARIES); \
70         fi
71         
72 # Additional libraries to install
73 ifeq ($(PLATFORM),glibc)
74   include extralibs.mak
75 endif   
76
77 endif
78
79 # run-time start-ups, not needed any more.
80 #ifeq ($(PLATFORM),glibc)
81 #  TARGETS += $(LIBDIR)/crt1.o
82 #else
83 #  ifeq ($(PLATFORM),uclibc)
84 #    TARGETS += $(LIBDIR)/crt0.o
85 #  endif
86 #endif
87
88 #TARGETS += $(LIBDIR)/crti.o
89 #TARGETS += $(LIBDIR)/crtn.o
90
91 all:
92
93 install: libopt
94         install $(TARGETS) $(INSTALL_DIR)/lib
95
96 clean:
97         @if [ "$(INSTALL_DIR)" != "" -a "$(INSTALL_DIR)" != "/" ]; then rm -f $(INSTALL_DIR)/lib/*; fi
98         @if [ "$(PLATFORM)" = "glibc" ]; then rm -f $(PLATFORM)/$(LIBC) $(PLATFORM)/$(LINKER); fi
99         @if [ "$(PLATFORM)" = "uclibc" ]; then rm -f $(PLATFORM)/*.0; fi