getopt_ulflags -> getopt32.
[oweals/busybox.git] / libbb / Makefile.in
1 # Makefile for busybox
2 #
3 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
4 #
5 # Licensed under the GPL v2, see the file LICENSE in this tarball.
6
7 ifndef $(LIBBB_DIR)
8 LIBBB_DIR:=$(top_builddir)/libbb
9 endif
10 srcdir=$(top_srcdir)/libbb
11
12 LIBBB-n:=
13 LIBBB-y:= \
14         ask_confirmation.c change_identity.c chomp.c \
15         compare_string_array.c concat_path_file.c copy_file.c copyfd.c \
16         crc32.c create_icmp_socket.c create_icmp6_socket.c \
17         device_open.c dump.c error_msg.c error_msg_and_die.c \
18         find_pid_by_name.c find_root_device.c fgets_str.c full_read.c \
19         full_write.c get_last_path_component.c get_line_from_file.c \
20         herror_msg.c herror_msg_and_die.c \
21         human_readable.c inet_common.c inode_hash.c isdirectory.c \
22         kernel_version.c last_char_is.c login.c \
23         make_directory.c md5.c mode_string.c mtab_file.c \
24         obscure.c parse_mode.c parse_number.c perror_msg.c \
25         perror_msg_and_die.c get_console.c process_escape_sequence.c procps.c \
26         recursive_action.c remove_file.c info_msg.c vinfo_msg.c \
27         restricted_shell.c run_parts.c run_shell.c safe_read.c safe_write.c \
28         safe_strncpy.c setup_environment.c sha1.c simplify_path.c \
29         trim.c u_signal_names.c vdprintf.c verror_msg.c \
30         vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c \
31         xgethostbyname.c xgethostbyname2.c xreadlink.c xgetlarg.c \
32         fclose_nonstdin.c fflush_stdout_and_exit.c \
33         getopt32.c default_error_retval.c wfopen_input.c speed_table.c \
34         perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \
35         warn_ignoring_args.c concat_subpath_file.c vfork_daemon_rexec.c \
36         bb_do_delay.c
37
38 # conditionally compiled objects:
39 LIBBB-$(CONFIG_FEATURE_MOUNT_LOOP)+= loop.c
40 LIBBB-$(CONFIG_LOSETUP)+= loop.c
41 LIBBB-$(CONFIG_FEATURE_MTAB_SUPPORT)+= mtab.c
42 LIBBB-$(CONFIG_PASSWD)+= pw_encrypt.c
43 LIBBB-$(CONFIG_SULOGIN)+= pw_encrypt.c
44 LIBBB-$(CONFIG_FEATURE_HTTPD_AUTH_MD5)+= pw_encrypt.c
45 LIBBB-$(CONFIG_VLOCK)+= correct_password.c
46 LIBBB-$(CONFIG_SU)+= correct_password.c
47 LIBBB-$(CONFIG_LOGIN)+= correct_password.c
48 LIBBB-$(CONFIG_DF)+= find_mount_point.c
49 LIBBB-$(CONFIG_EJECT)+= find_mount_point.c
50 LIBBB-$(CONFIG_UUENCODE)+= uuencode.c
51 LIBBB-$(CONFIG_WGET)+= uuencode.c
52
53 # We shouldn't build xregcomp.c if we don't need it - this ensures we don't
54 # require regex.h to be in the include dir even if we don't need it thereby
55 # allowing us to build busybox even if uclibc regex support is disabled.
56
57 regex-y:=
58 regex-$(CONFIG_AWK) += xregcomp.c
59 regex-$(CONFIG_SED) += xregcomp.c
60 regex-$(CONFIG_LESS) += xregcomp.c
61 regex-$(CONFIG_DEVFSD) += xregcomp.c
62 regex-$(CONFIG_MDEV) += xregcomp.c
63 regex-$(CONFIG_GREP) += xregcomp.c
64
65 # Sort has the happy side efect of returning a unique list
66 LIBBB-y += $(sort $(regex-y))
67
68 LIBBB-y:=$(patsubst %,$(srcdir)/%,$(LIBBB-y))
69
70 get-file-subparts = $(addsuffix .o,$(shell sed -n -e "s/^\#ifdef L_//p" ${1}))
71
72 # 1:N objects
73 LIBBB_MSRC0:=$(srcdir)/messages.c
74 LIBBB_MOBJ0:=$(call get-file-subparts, ${LIBBB_MSRC0})
75 LIBBB_MOBJ0:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ0))
76 $(LIBBB_MOBJ0):$(LIBBB_MSRC0)
77         $(compile.c) -DL_$(notdir $*)
78
79 LIBBB_MSRC1:=$(srcdir)/xfuncs.c
80 LIBBB_MOBJ1:=$(call get-file-subparts, ${LIBBB_MSRC1})
81 LIBBB_MOBJ1:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ1))
82 $(LIBBB_MOBJ1):$(LIBBB_MSRC1)
83         $(compile.c) -DL_$(notdir $*)
84
85 LIBBB_MSRC2:=$(srcdir)/printf.c
86 LIBBB_MOBJ2:=$(call get-file-subparts, ${LIBBB_MSRC2})
87 LIBBB_MOBJ2:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ2))
88 $(LIBBB_MOBJ2):$(LIBBB_MSRC2)
89         $(compile.c) -DL_$(notdir $*)
90
91 LIBBB_MSRC3:=$(srcdir)/xgetularg.c
92 LIBBB_MOBJ3:=$(call get-file-subparts, ${LIBBB_MSRC3})
93 LIBBB_MOBJ3:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ3))
94 $(LIBBB_MOBJ3):$(LIBBB_MSRC3)
95         $(compile.c) -DL_$(notdir $*)
96
97 LIBBB_MSRC4:=$(srcdir)/safe_strtol.c
98 LIBBB_MOBJ4:=$(call get-file-subparts, ${LIBBB_MSRC4})
99 LIBBB_MOBJ4:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ4))
100 $(LIBBB_MOBJ4):$(LIBBB_MSRC4)
101         $(compile.c) -DL_$(notdir $*)
102
103 LIBBB_MSRC5:=$(srcdir)/bb_pwd.c
104 LIBBB_MOBJ5:=$(call get-file-subparts, ${LIBBB_MSRC5})
105 LIBBB_MOBJ5:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ5))
106 $(LIBBB_MOBJ5):$(LIBBB_MSRC5)
107         $(compile.c) -DL_$(notdir $*)
108
109 LIBBB_MSRC6:=$(srcdir)/llist.c
110 LIBBB_MOBJ6:=$(call get-file-subparts, ${LIBBB_MSRC6})
111 LIBBB_MOBJ6:=$(patsubst %,$(LIBBB_DIR)/%, $(LIBBB_MOBJ6))
112 $(LIBBB_MOBJ6):$(LIBBB_MSRC6)
113         $(compile.c) -DL_$(notdir $*)
114
115 # We need the names of the object files built from MSRC for the L_ defines
116 LIBBB_ALL_MOBJ:=$(LIBBB_MOBJ0) $(LIBBB_MOBJ1) $(LIBBB_MOBJ2) $(LIBBB_MOBJ3) \
117         $(LIBBB_MOBJ4) $(LIBBB_MOBJ5) $(LIBBB_MOBJ6)
118
119 LIBBB_ALL_MSRC:=$(LIBBB_MSRC0) $(LIBBB_MSRC1) $(LIBBB_MSRC2) $(LIBBB_MSRC3) \
120         $(LIBBB_MSRC4) $(LIBBB_MSRC5) $(LIBBB_MSRC6)
121
122 LIBBB-y:=$(sort $(LIBBB-y) $(LIBBB_ALL_MSRC))
123
124 LIBBB_AR:=$(LIBBB_DIR)/libbb.a
125 libraries-y+=$(LIBBB_AR)
126
127 needcrypt-y:=
128 ifneq ($(filter $(srcdir)/pw_encrypt.c,$(LIBBB-y)),)
129 needcrypt-y:=y
130 else
131 ifneq ($(filter $(srcdir)/correct_password.c,$(LIBBB-y)),)
132 needcrypt-y:=y
133 endif
134 endif
135
136 ifeq ($(needcrypt-y),y)
137   LIBRARIES := -lcrypt $(filter-out -lcrypt,$(LIBRARIES))
138 endif
139
140 # all 1:1 objects
141 LIBBB_OBJS:=$(patsubst $(srcdir)/%.c,$(LIBBB_DIR)/%.o, $(LIBBB-y))
142 $(LIBBB_DIR)/%.o: $(srcdir)/%.c
143         $(compile.c)
144
145 LIBBB_SRC-a:=$(wildcard $(srcdir)/*.c)
146 LIBRARY_SRC-y+=$(LIBBB-y)
147 LIBRARY_SRC-a+=$(LIBBB_SRC-a)
148
149 # all defines needed for 1:N objects
150 LIBBB_DEFINE-y:=$(patsubst %,-DL_%,$(subst .o,,$(notdir $(LIBBB_ALL_MOBJ))))
151 LIBRARY_DEFINE-y+=$(LIBBB_DEFINE-y)
152 LIBRARY_DEFINE-a+=$(LIBBB_DEFINE-y)
153
154 $(LIBBB_AR): $(LIBBB_OBJS) $(LIBBB_ALL_MOBJ)
155         $(do_ar)