OSDN Git Service

fa360e4c9a6bbd2df8001d26db40fe6516c3fbb7
[uclinux-h8/uClibc.git] / libc / stdlib / Makefile
1 # Makefile for uClibc
2 #
3 # Copyright (C) 2000 by Lineo, inc.
4 # Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
5 #
6 # This program is free software; you can redistribute it and/or modify it under
7 # the terms of the GNU Library General Public License as published by the Free
8 # Software Foundation; either version 2 of the License, or (at your option) any
9 # later version.
10 #
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 # FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Library General Public License
17 # along with this program; if not, write to the Free Software Foundation, Inc.,
18 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #
20 # Derived in part from the Linux-8086 C library, the GNU C Library, and several
21 # other sundry sources.  Files within this library are copyright by their
22 # respective copyright holders.
23
24 TOPDIR=../../
25 include $(TOPDIR)Rules.mak
26
27 DIRS =
28 ifeq ($(MALLOC),y)
29     DIRS += malloc
30 endif
31 ifeq ($(MALLOC_SIMPLE),y)
32     DIRS += malloc-simple
33 endif
34 ifeq ($(MALLOC_STANDARD),y)
35     DIRS += malloc-standard
36 endif
37
38 MSRC := stdlib.c
39 MOBJ = abs.o labs.o atoi.o atol.o strtol.o strtoul.o _stdlib_strto_l.o \
40        qsort.o bsearch.o \
41        llabs.o atoll.o strtoll.o strtoull.o _stdlib_strto_ll.o
42 # (aliases) strtoq.o strtouq.o
43 ifeq ($(UCLIBC_HAS_XLOCALE),y)
44 MOBJx = strtol_l.o strtoul_l.o _stdlib_strto_l_l.o \
45          strtoll_l.o strtoull_l.o _stdlib_strto_ll_l.o
46 endif
47
48 MSRC1 := strtod.c
49 MOBJ1 = 
50 MOBJ1x =
51
52 ifeq ($(UCLIBC_HAS_FLOATS),y)
53         MOBJ += atof.o
54         MOBJ1 += strtod.o strtof.o strtold.o __strtofpmax.o __fp_range_check.o
55 ifeq ($(UCLIBC_HAS_XLOCALE),y)
56         MOBJ1x += strtod_l.o strtof_l.o strtold_l.o __strtofpmax_l.o
57 endif
58 ifeq ($(UCLIBC_HAS_WCHAR),y)
59         MOBJ1 += wcstod.o wcstof.o wcstold.o __wcstofpmax.o
60 ifeq ($(UCLIBC_HAS_XLOCALE),y)
61         MOBJ1x += wcstod_l.o wcstof_l.o wcstold_l.o __wcstofpmax_l.o
62 endif
63 endif
64 endif
65
66 ifeq ($(UCLIBC_HAS_WCHAR),y)
67         MOBJ += mblen.o mbtowc.o wctomb.o mbstowcs.o wcstombs.o \
68                 _stdlib_mb_cur_max.o _stdlib_wcsto_l.o _stdlib_wcsto_ll.o \
69                 wcstol.o wcstoul.o wcstoll.o wcstoull.o
70 ifeq ($(UCLIBC_HAS_XLOCALE),y)
71         MOBJx += _stdlib_wcsto_l_l.o _stdlib_wcsto_ll_l.o \
72                  wcstol_l.o wcstoul_l.o wcstoll_l.o wcstoull_l.o
73 endif
74 endif
75 # (aliases) wcstoq.o wcstouq.o
76 # wcstod wcstof wcstold
77
78 MSRC2 := atexit.c
79 MOBJ2 = on_exit.o __cxa_atexit.o __cxa_finalize.o __exit_handler.o exit.o
80 ifeq ($(COMPAT_ATEXIT),y)
81 MOBJ2 += old_atexit.o
82 endif
83
84 CSRC = \
85         abort.c getenv.c mkdtemp.c mktemp.c realpath.c mkstemp.c mkstemp64.c \
86         rand.c random.c random_r.c setenv.c system.c div.c ldiv.c lldiv.c \
87         getpt.c ptsname.c grantpt.c unlockpt.c gcvt.c drand48-iter.c jrand48.c \
88         jrand48_r.c lrand48.c lrand48_r.c mrand48.c mrand48_r.c nrand48.c \
89         nrand48_r.c rand_r.c srand48.c srand48_r.c seed48.c seed48_r.c \
90         valloc.c posix_memalign.c a64l.c l64a.c
91 ifeq ($(UCLIBC_HAS_FLOATS),y)
92         CSRC += drand48.c drand48_r.c erand48.c erand48_r.c
93 endif
94 COBJ := $(patsubst %.c,%.o, $(CSRC))
95
96 OBJS := $(MOBJ) $(MOBJx) $(MOBJ1) $(MOBJ1x) $(MOBJ2) $(COBJ)
97
98 NONSHARED_OBJS := atexit.o
99
100 OBJ_LIST := ../obj.stdlib
101
102 NONSHARED_OBJ_LIST := ../nonshared_obj.stdlib
103
104 all: $(OBJ_LIST) $(NONSHARED_OBJ_LIST) subdirs
105
106 $(OBJ_LIST): $(OBJS)
107         $(STRIPTOOL) -x -R .note -R .comment $^
108         echo $(patsubst %, stdlib/%, $^) > $@
109
110 $(NONSHARED_OBJ_LIST): $(NONSHARED_OBJS)
111         $(STRIPTOOL) -x -R .note -R .comment $^
112         echo $(patsubst %, stdlib/%, $^) > $@
113
114 $(MOBJ): $(MSRC)
115         $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
116
117 $(MOBJx): $(MSRC)
118         $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o
119
120 $(MOBJ1): $(MSRC1)
121         $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
122
123 $(MOBJ1x): $(MSRC1)
124         $(CC) $(CFLAGS) -DL_$* -D__UCLIBC_DO_XLOCALE $< -c -o $*.o
125
126 $(MOBJ2) atexit.o: $(MSRC2)
127         $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
128
129 $(COBJ): %.o : %.c
130         $(CC) $(CFLAGS) -c $< -o $@
131
132 subdirs: $(patsubst %, _dir_%, $(DIRS))
133 subdirs_clean: $(patsubst %, _dirclean_%, $(ALL_SUBDIRS))
134
135 $(patsubst %, _dir_%, $(DIRS)) : dummy
136         $(MAKE) -C $(patsubst _dir_%, %, $@)
137
138 $(patsubst %, _dirclean_%, $(ALL_SUBDIRS)) : dummy
139         $(MAKE) -C $(patsubst _dirclean_%, %, $@) clean
140
141 clean: subdirs_clean
142         $(RM) *.o *~ core
143
144 .PHONY: dummy