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