1570af302Sopenharmony_ciB:=src 2570af302Sopenharmony_ciSRCS:=$(sort $(wildcard src/*/*.c)) 3570af302Sopenharmony_ciOBJS:=$(SRCS:src/%.c=$(B)/%.o) 4570af302Sopenharmony_ciLOBJS:=$(SRCS:src/%.c=$(B)/%.lo) 5570af302Sopenharmony_ciDIRS:=$(patsubst src/%/,%,$(sort $(dir $(SRCS)))) 6570af302Sopenharmony_ciBDIRS:=$(DIRS:%=$(B)/%) 7570af302Sopenharmony_ciNAMES:=$(SRCS:src/%.c=%) 8570af302Sopenharmony_ciCFLAGS:=-I$(B)/common -Isrc/common #YSROOT_PATH) 9570af302Sopenharmony_ciLDLIBS:=$(B)/common/libtest.a 10570af302Sopenharmony_ciAR = $(CROSS_COMPILE)ar 11570af302Sopenharmony_ciRANLIB = $(CROSS_COMPILE)ranlib 12570af302Sopenharmony_ciRUN_TEST = $(RUN_WRAP) $(B)/common/runtest.exe -w '$(RUN_WRAP)' 13570af302Sopenharmony_ci 14570af302Sopenharmony_ciall: 15570af302Sopenharmony_ci%.mk: 16570af302Sopenharmony_ci# turn off evil implicit rules 17570af302Sopenharmony_ci.SUFFIXES: 18570af302Sopenharmony_ci%: %.o 19570af302Sopenharmony_ci%: %.c 20570af302Sopenharmony_ci%: %.cc 21570af302Sopenharmony_ci%: %.C 22570af302Sopenharmony_ci%: %.cpp 23570af302Sopenharmony_ci%: %.p 24570af302Sopenharmony_ci%: %.f 25570af302Sopenharmony_ci%: %.F 26570af302Sopenharmony_ci%: %.r 27570af302Sopenharmony_ci%: %.s 28570af302Sopenharmony_ci%: %.S 29570af302Sopenharmony_ci%: %.mod 30570af302Sopenharmony_ci%: %.sh 31570af302Sopenharmony_ci%: %,v 32570af302Sopenharmony_ci%: RCS/%,v 33570af302Sopenharmony_ci%: RCS/% 34570af302Sopenharmony_ci%: s.% 35570af302Sopenharmony_ci%: SCCS/s.% 36570af302Sopenharmony_ci 37570af302Sopenharmony_ciconfig.mak: 38570af302Sopenharmony_ci cp config.mak.def $@ 39570af302Sopenharmony_ci-include config.mak 40570af302Sopenharmony_ci 41570af302Sopenharmony_cidefine default_template 42570af302Sopenharmony_ci$(1).BINS_TEMPL:=bin.exe bin-static.exe 43570af302Sopenharmony_ci$(1).NAMES:=$$(filter $(1)/%,$$(NAMES)) 44570af302Sopenharmony_ci$(1).OBJS:=$$($(1).NAMES:%=$(B)/%.o) 45570af302Sopenharmony_ciendef 46570af302Sopenharmony_ci$(foreach d,$(DIRS),$(eval $(call default_template,$(d)))) 47570af302Sopenharmony_cicommon.BINS_TEMPL:= 48570af302Sopenharmony_ciapi.BINS_TEMPL:= 49570af302Sopenharmony_cimath.BINS_TEMPL:=bin.exe 50570af302Sopenharmony_ci 51570af302Sopenharmony_cidefine template 52570af302Sopenharmony_ciD:=$$(patsubst %/,%,$$(dir $(1))) 53570af302Sopenharmony_ciN:=$(1) 54570af302Sopenharmony_ci$(1).BINS := $$($$(D).BINS_TEMPL:bin%=$(B)/$(1)%) 55570af302Sopenharmony_ci-include src/$(1).mk 56570af302Sopenharmony_ci#$$(warning D $$(D) N $$(N) B $$($(1).BINS)) 57570af302Sopenharmony_ci$(B)/$(1).exe $(B)/$(1)-static.exe: $$($(1).OBJS) 58570af302Sopenharmony_ci$(B)/$(1).so: $$($(1).LOBJS) 59570af302Sopenharmony_ci# make sure dynamic and static binaries are not run parallel (matters for some tests eg ipc) 60570af302Sopenharmony_ci$(B)/$(1)-static.err: $(B)/$(1).err 61570af302Sopenharmony_ciendef 62570af302Sopenharmony_ci$(foreach n,$(NAMES),$(eval $(call template,$(n)))) 63570af302Sopenharmony_ci 64570af302Sopenharmony_ciBINS:=$(foreach n,$(NAMES),$($(n).BINS)) $(B)/api/main.exe 65570af302Sopenharmony_ciLIBS:=$(foreach n,$(NAMES),$($(n).LIBS)) $(B)/common/runtest.exe 66570af302Sopenharmony_ciERRS:=$(BINS:%.exe=%.err) 67570af302Sopenharmony_ci 68570af302Sopenharmony_cidebug: 69570af302Sopenharmony_ci @echo NAMES $(NAMES) 70570af302Sopenharmony_ci @echo BINS $(BINS) 71570af302Sopenharmony_ci @echo LIBS $(LIBS) 72570af302Sopenharmony_ci @echo ERRS $(ERRS) 73570af302Sopenharmony_ci @echo DIRS $(DIRS) 74570af302Sopenharmony_ci 75570af302Sopenharmony_cidefine target_template 76570af302Sopenharmony_ci$(1).ERRS:=$$(filter $(B)/$(1)/%,$$(ERRS)) 77570af302Sopenharmony_ci$(B)/$(1)/all: $(B)/$(1)/REPORT 78570af302Sopenharmony_ci$(B)/$(1)/run: $(B)/$(1)/cleanerr $(B)/$(1)/REPORT 79570af302Sopenharmony_ci$(B)/$(1)/cleanerr: 80570af302Sopenharmony_ci rm -f $$(filter-out $(B)/$(1)/%-static.err,$$($(1).ERRS)) 81570af302Sopenharmony_ci$(B)/$(1)/clean: 82570af302Sopenharmony_ci rm -f $$(filter $(B)/$(1)/%,$$(OBJS) $$(LOBJS) $$(BINS) $$(LIBS)) $(B)/$(1)/*.err 83570af302Sopenharmony_ci$(B)/$(1)/REPORT: $$($(1).ERRS) 84570af302Sopenharmony_ci cat $(B)/$(1)/*.err >$$@ 85570af302Sopenharmony_cirun: $(B)/$(1)/run 86570af302Sopenharmony_ci$(B)/REPORT: $(B)/$(1)/REPORT 87570af302Sopenharmony_ci.PHONY: $(B)/$(1)/all $(B)/$(1)/clean 88570af302Sopenharmony_ciendef 89570af302Sopenharmony_ci$(foreach d,$(DIRS),$(eval $(call target_template,$(d)))) 90570af302Sopenharmony_ci 91570af302Sopenharmony_ci$(B)/common/libtest.a: $(common.OBJS) 92570af302Sopenharmony_ci rm -f $@ 93570af302Sopenharmony_ci $(AR) rc $@ $^ 94570af302Sopenharmony_ci $(RANLIB) $@ 95570af302Sopenharmony_ci 96570af302Sopenharmony_ci$(B)/common/all: $(B)/common/runtest.exe 97570af302Sopenharmony_ci 98570af302Sopenharmony_ci$(ERRS): $(B)/common/runtest.exe | $(BDIRS) 99570af302Sopenharmony_ci$(BINS) $(LIBS): $(B)/common/libtest.a 100570af302Sopenharmony_ci$(OBJS): src/common/test.h | $(BDIRS) 101570af302Sopenharmony_ci$(BDIRS): 102570af302Sopenharmony_ci mkdir -p $@ 103570af302Sopenharmony_ci 104570af302Sopenharmony_ci$(B)/common/options.h: src/common/options.h.in 105570af302Sopenharmony_ci $(CC) -E - <$< | awk ' \ 106570af302Sopenharmony_ci /optiongroups_unistd_end/ {s=1; next} \ 107570af302Sopenharmony_ci !s || !NF || /^#/ {next} \ 108570af302Sopenharmony_ci !a {a=$$1; if(NF==1)next} \ 109570af302Sopenharmony_ci {print "#define "a" "$$NF; a=""}' >$@.tmp 110570af302Sopenharmony_ci mv $@.tmp $@ 111570af302Sopenharmony_ci 112570af302Sopenharmony_ci$(B)/common/mtest.o: src/common/mtest.h 113570af302Sopenharmony_ci$(math.OBJS): src/common/mtest.h 114570af302Sopenharmony_ci 115570af302Sopenharmony_ci$(B)/api/main.exe: $(api.OBJS) 116570af302Sopenharmony_ciapi/main.OBJS:=$(api.OBJS) 117570af302Sopenharmony_ci$(api.OBJS):$(B)/common/options.h 118570af302Sopenharmony_ci$(api.OBJS):CFLAGS+=-pedantic-errors -Werror -Wno-unused -D_XOPEN_SOURCE=700 119570af302Sopenharmony_ci 120570af302Sopenharmony_ciall run: $(B)/REPORT 121570af302Sopenharmony_ci grep FAIL $< || echo PASS 122570af302Sopenharmony_ciclean: 123570af302Sopenharmony_ci rm -f $(OBJS) $(BINS) $(LIBS) $(B)/common/libtest.a $(B)/common/runtest.exe $(B)/common/options.h $(B)/*/*.err 124570af302Sopenharmony_cicleanall: clean 125570af302Sopenharmony_ci rm -f $(B)/REPORT $(B)/*/REPORT 126570af302Sopenharmony_ci$(B)/REPORT: 127570af302Sopenharmony_ci cat $^ >$@ 128570af302Sopenharmony_ci 129570af302Sopenharmony_ci$(B)/%.o:: src/%.c 130570af302Sopenharmony_ci $(CC) $(CFLAGS) $($*.CFLAGS) -c -o $@ $< 2>$@.err || echo BUILDERROR $@; cat $@.err 131570af302Sopenharmony_ci$(B)/%.s:: src/%.c 132570af302Sopenharmony_ci $(CC) $(CFLAGS) $($*.CFLAGS) -S -o $@ $< || echo BUILDERROR $@; cat $@.err 133570af302Sopenharmony_ci$(B)/%.lo:: src/%.c 134570af302Sopenharmony_ci $(CC) $(CFLAGS) $($*.CFLAGS) -fPIC -DSHARED -c -o $@ $< 2>$@.err || echo BUILDERROR $@; cat $@.err 135570af302Sopenharmony_ci$(B)/%.so: $(B)/%.lo 136570af302Sopenharmony_ci $(CC) -shared $(LDFLAGS) $($*.so.LDFLAGS) -o $@ $(sort $< $($*.so.LOBJS)) $(LDLIBS) $($*.so.LDLIBS) 2>$@.err || echo BUILDERROR $@; cat $@.err 137570af302Sopenharmony_ci$(B)/%-static.exe: $(B)/%.o 138570af302Sopenharmony_ci $(CC) -static $(LDFLAGS) $($*-static.LDFLAGS) -o $@ $(sort $< $($*-static.OBJS)) $(LDLIBS) $($*-static.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err 139570af302Sopenharmony_ci$(B)/%.exe: $(B)/%.o 140570af302Sopenharmony_ci $(CC) $(LDFLAGS) $($*.LDFLAGS) -o $@ $(sort $< $($*.OBJS)) $(LDLIBS) $($*.LDLIBS) 2>$@.ld.err || echo BUILDERROR $@; cat $@.ld.err 141570af302Sopenharmony_ci 142570af302Sopenharmony_ci%.o.err: %.o 143570af302Sopenharmony_ci touch $@ 144570af302Sopenharmony_ci%.lo.err: %.lo 145570af302Sopenharmony_ci touch $@ 146570af302Sopenharmony_ci%.so.err: %.so 147570af302Sopenharmony_ci touch $@ 148570af302Sopenharmony_ci%.ld.err: %.exe 149570af302Sopenharmony_ci touch $@ 150570af302Sopenharmony_ci%.err: %.exe 151570af302Sopenharmony_ci $(RUN_TEST) $< >$@ || true 152570af302Sopenharmony_ci 153570af302Sopenharmony_ci.PHONY: all run clean cleanall 154570af302Sopenharmony_ci 155