e4766cfd7feadcd78c68e72cdf67d9b794685140
[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
43 ifneq ($(strip $(BUILD_GDBSERVER)),)
44         TARGETS += $(LIBDIR)/libthread_db.so.1
45 endif
46
47 # Additional libraries to install
48 include extralibs.mak
49
50 libopt:
51
52 else
53
54 # Optimize libraries from archives
55 # if glibc, $(LIBC) is generated in $(PLATFORM) directory by generate_library
56 # if uclic, $(LIBC) is generated in $(PLATFORM) directory by mklibs.py 
57
58 ifeq ($(PLATFORM),glibc)
59   TARGETS := $(PLATFORM)/$(LIBC) $(PLATFORM)/$(LINKER)
60 else
61   ifeq ($(PLATFORM),uclibc)
62     TARGETS := $(PLATFORM)/lib* $(PLATFORM)/$(LINKER)
63   endif
64 endif
65 BINARIES := `find $(INSTALL_DIR) -path $(INSTALL_DIR)/lib -prune -o -type f -print | file -f - | grep ELF | cut -d':' -f1`
66
67 libopt:
68         @echo Optimizing C run-time library...
69         @if [ "$(PLATFORM)" = "glibc" ]; then \
70             @cp -f $(LIBDIR)/$(LINKER) $(PLATFORM); \
71             $(SHELL) -e generate_library $(PLATFORM) $(BINARIES); \
72         fi
73         @if [ "$(PLATFORM)" = "uclibc" ]; then \
74             python ./mklibs.py -D -L $(LIBDIR) -L $(INSTALL_DIR)/lib --target=$(CROSS_COMPILE) -d $(PLATFORM) $(BINARIES); \
75         fi
76         
77 # Additional libraries to install
78 ifeq ($(PLATFORM),glibc)
79   include extralibs.mak
80 endif   
81
82 endif
83
84 # run-time start-ups, not needed any more.
85 #ifeq ($(PLATFORM),glibc)
86 #  TARGETS += $(LIBDIR)/crt1.o
87 #else
88 #  ifeq ($(PLATFORM),uclibc)
89 #    TARGETS += $(LIBDIR)/crt0.o
90 #  endif
91 #endif
92
93 #TARGETS += $(LIBDIR)/crti.o
94 #TARGETS += $(LIBDIR)/crtn.o
95
96 all:
97
98 install: libopt
99         install $(TARGETS) $(INSTALL_DIR)/lib
100         @cp -f $(LIBDIR)/libdl.so $(INSTALL_DIR)/lib/libdl.so.0
101
102 clean:
103         @if [ "$(INSTALL_DIR)" != "" -a "$(INSTALL_DIR)" != "/" ]; then rm -f $(INSTALL_DIR)/lib/*; fi
104         @if [ "$(PLATFORM)" = "glibc" ]; then rm -f $(PLATFORM)/$(LIBC) $(PLATFORM)/$(LINKER); fi
105         @if [ "$(PLATFORM)" = "uclibc" ]; then rm -f $(PLATFORM)/*.0; fi