OSDN Git Service

7d8a1e4add64cef78b917190ec094508dba7554c
[uclinux-h8/uClibc.git] / extra / config / Makefile
1 top_srcdir ?= ../../
2
3 include $(top_srcdir)Rules.mak
4 include $(top_srcdir)Makerules
5
6 # ugh
7 top_srcdir:=$(shell cd $(top_srcdir) && pwd)/
8 ifdef O
9 top_builddir ?= ../../
10 else
11 top_builddir = ../../
12 endif
13 srctree := $(top_srcdir)
14 src := extra/config
15 obj := $(top_builddir)$(src)
16
17 generated := $(patsubst %_shipped,%,$(wildcard *_shipped))
18 generated := $(addprefix $(obj)/,$(generated:.c=.o))
19
20 include $(top_srcdir)extra/config/Makefile.kconfig
21 PHONY += $(always)
22 chk-lxdialog := $(top_srcdir)$(src)/lxdialog/check-lxdialog.sh
23 check-lxdialog := cd $(obj) && $(chk-lxdialog)
24 HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) -c '$(check-lxdialog) -ccflags')
25 HOST_LOADLIBES   = $(shell $(CONFIG_SHELL) -c '$(check-lxdialog) -ldflags $(HOSTCC)')
26 HOST_EXTRACFLAGS += -DLOCALE
27 HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) -c '$(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS)')
28
29 # do not create temporary object in the readonly srctree
30 $(obj)/dochecklxdialog:
31         $(Q)cd $(obj) && $(CONFIG_SHELL) $(chk-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
32 HOSTCFLAGS_lex.zconf.o  := -I$(top_srcdir)$(src)
33 HOSTCFLAGS_zconf.tab.o  := -I$(top_srcdir)$(src)
34 conf-objs := $(addprefix $(obj)/,$(conf-objs))
35 mconf-objs := $(addprefix $(obj)/,$(mconf-objs))
36 kxgettext-objs := $(addprefix $(obj)/,$(kxgettext-objs))
37
38 ifeq ($(findstring mconf,$(MAKECMDGOALS)),mconf)
39 hostprogs-y += mconf
40 endif
41
42 #BUILD_CFLAGS-config = -W -Wall -pedantic
43 #BUILD_CFLAGS-lxdialog = -W -Wall -pedantic
44
45 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
46 host-csingle:= $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
47 host-cmulti := $(foreach m,$(__hostprogs),\
48            $(if $($(m)-cxxobjs),,$(if $($(m)-objs),$(m))))
49 host-cobjs  := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
50
51 conf mconf kxgettext: %: $(obj)/%
52 $(obj)/conf $(obj)/mconf $(obj)/kxgettext: BUILD_LDFLAGS=$(HOST_LOADLIBES)
53 $(obj)/conf: $(conf-objs)
54         $(hcompile.u)
55 $(obj)/mconf: $(mconf-objs)
56         $(hcompile.u)
57 $(obj)/kxgettext: $(kxgettext-objs)
58         $(hcompile.u)
59
60 $(host-csingle) $(host-cmulti) $(host-cobjs): BUILD_CFLAGS=$(HOST_EXTRACFLAGS) \
61                                         $(HOSTCFLAGS) $(HOSTCFLAGS_$(@F))
62
63 host-cobjs.nogen := $(filter-out $(generated),$(host-cobjs))
64 host-cobjs.generated := $(filter $(generated),$(host-cobjs))
65
66 $(host-cobjs.nogen): $(obj)/%.o: $(top_srcdir)$(src)/%.c
67         $(hcompile.o)
68 $(host-cobjs.generated): $(obj)/%.o: $(obj)/%.c
69         $(hcompile.o)
70
71 ifndef LKC_GENPARSER
72 $(obj)/%:: $(top_srcdir)$(src)/%_shipped
73         @$(disp_gen)
74         $(Q)cat $< > $@
75 endif
76 clean:
77         $(do_rm) $(clean-files) conf
78 distclean: clean
79         $(do_rm) $(lxdialog) $(conf-objs) $(mconf-objs) \
80                 $(kxgettext-objs) \
81                 $(hostprogs-y) $(qconf-cxxobjs) $(qconf-objs) $(gconf-objs) \
82                 .depend
83         $(do_rm) -r $(top_builddir)include/config
84
85 FORCE:
86 .PHONY: FORCE clean distclean $(always)