OSDN Git Service

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