Masahiro Yamada | ce28d7a | 2013-10-17 17:34:47 +0900 | [diff] [blame] | 1 | # our default target |
| 2 | .PHONY: all |
| 3 | all: |
| 4 | |
| 5 | include $(TOPDIR)/config.mk |
| 6 | |
| 7 | LIB := $(obj)built-in.o |
| 8 | LIBGCC = $(obj)libgcc.o |
| 9 | SRCS := |
| 10 | |
| 11 | include Makefile |
| 12 | |
| 13 | # Backward compatible: obj-y is preferable |
| 14 | COBJS := $(sort $(COBJS) $(COBJS-y)) |
| 15 | SOBJS := $(sort $(SOBJS) $(SOBJS-y)) |
| 16 | |
| 17 | # Going forward use the following |
| 18 | obj-y := $(sort $(obj-y)) |
| 19 | extra-y := $(sort $(extra-y)) |
| 20 | lib-y := $(sort $(lib-y)) |
| 21 | |
Masahiro Yamada | ac7e735 | 2013-10-17 20:38:51 +0900 | [diff] [blame] | 22 | subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) |
| 23 | obj-y := $(patsubst %/, %/built-in.o, $(obj-y)) |
| 24 | subdir-obj-y := $(filter %/built-in.o, $(obj-y)) |
| 25 | subdir-obj-y := $(addprefix $(obj),$(subdir-obj-y)) |
| 26 | |
Masahiro Yamada | ce28d7a | 2013-10-17 17:34:47 +0900 | [diff] [blame] | 27 | SRCS += $(COBJS:.o=.c) $(SOBJS:.o=.S) \ |
| 28 | $(wildcard $(obj-y:.o=.c) $(obj-y:.o=.S) $(lib-y:.o=.c) $(lib-y:.o=.S) $(extra-y:.o=.c) $(extra-y:.o=.S)) |
| 29 | OBJS := $(addprefix $(obj),$(COBJS) $(SOBJS) $(obj-y)) |
| 30 | |
| 31 | LGOBJS := $(addprefix $(obj),$(sort $(GLSOBJS) $(GLCOBJS)) $(lib-y)) |
| 32 | |
| 33 | all: $(LIB) $(addprefix $(obj),$(extra-y)) |
| 34 | |
| 35 | $(LIB): $(obj).depend $(OBJS) |
| 36 | $(call cmd_link_o_target, $(OBJS)) |
| 37 | |
| 38 | ifneq ($(strip $(lib-y)),) |
| 39 | all: $(LIBGCC) |
| 40 | |
| 41 | $(LIBGCC): $(obj).depend $(LGOBJS) |
| 42 | $(call cmd_link_o_target, $(LGOBJS)) |
| 43 | endif |
| 44 | |
Masahiro Yamada | ac7e735 | 2013-10-17 20:38:51 +0900 | [diff] [blame] | 45 | ifneq ($(subdir-obj-y),) |
| 46 | # Descending |
| 47 | $(subdir-obj-y): $(subdir-y) |
| 48 | |
| 49 | $(subdir-y): FORCE |
| 50 | $(MAKE) -C $@ -f $(TOPDIR)/scripts/Makefile.build |
| 51 | endif |
| 52 | |
Masahiro Yamada | ce28d7a | 2013-10-17 17:34:47 +0900 | [diff] [blame] | 53 | ######################################################################### |
| 54 | |
| 55 | # defines $(obj).depend target |
| 56 | |
| 57 | include $(TOPDIR)/rules.mk |
| 58 | |
| 59 | sinclude $(obj).depend |
| 60 | |
| 61 | ######################################################################### |
Masahiro Yamada | ac7e735 | 2013-10-17 20:38:51 +0900 | [diff] [blame] | 62 | |
| 63 | .PHONY: FORCE |