<commit_before>/*#
 *# Copyright 2014, NICTA
 *#
 *# This software may be distributed and modified according to the terms of
 *# the BSD 2-Clause license. Note that NO WARRANTY is provided.
 *# See "LICENSE_BSD2.txt" for details.
 *#
 *# @TAG(NICTA_BSD)
 #*/

/*# Ignore the following line. It is intended to apply to the output of this
    template.
#*/
# THIS FILE IS AUTOMATICALLY GENERATED. YOUR EDITS WILL BE OVERWRITTEN.

/*# When modifying this template be particularly careful. The awkward syntax of
    both the templating language and GNU Make come together to make it very
    easy to introduce unreadable code in this context.
#*/

/*# Various macros to make constructing makefile rules easier. #*/
/*- macro rule_cp(target, dependencies) -*/
/*? target ?*/: /*? dependencies ?*/
	@echo " [CP] $(notdir $@)"
	${Q}mkdir -p $(dir $@)
	${Q}echo "#line 1 \"$<\"" >$@
	${Q}cat "$<" >>"$@"
/*- endmacro -*/

/*- macro rule_gen(target, dependencies, item, cfiles_append=None, platform='seL4', preprocessor=None) -*/
/*- if cfiles_append -*/
/*? cfiles_append ?*/_CFILES += /*? target ?*/
/*- endif -*/
.DELETE_ON_ERROR: /*? target ?*/
/*? target ?*/: /*? dependencies ?*/
	@echo " [GEN] $(notdir $@)"
	${Q}mkdir -p $(dir $@)
	${Q}camkes.sh runner \
        ${CAMKES_FLAGS} \
        /*- for inc in options.import_path -*/ --import-path /*? inc ?*/ /*- endfor -*/ \
        --file /*? options.file[0].name ?*/ \
        --item /*? item ?*/ \
        --outfile "$@" \
        --platform /*? platform ?*/
	/*- if preprocessor != None -*/
	@echo " [PP] $(notdir $@)"
	${Q}/*? preprocessor ?*/
	/*- endif -*/
	# Reflow the generated file if it's a C source or header.
	${Q}$(if $(patsubst %.c,,$(patsubst %.h,,/*? target ?*/)),,${FMT} "$@" | ${SPONGE} "$@")
/*- endmacro -*/

# All targets need to be rebuilt if the source CAmkES descriptions change.
${TARGETS}: /*? ' '.join(imported) ?*/

/*- set instances = me.composition.instances -*/
/*- set connections = me.composition.connections -*/

/*# The terms 'group' and 'address space' are currently synonymous. We can
 *# derive the groups by collecting all the instances' address spaces.
 #*/
/*- set groups = set(map(lambda('x: x.address_space'), filter(lambda('x: not x.type.hardware'), instances))) -*/

# Generate the policy label mapping if the user requested it.
ifeq (${CONFIG_CAMKES_LABEL_MAPPING},y)
LABEL_MAPPING=$(patsubst %.cdl,%.json,$(firstword ${TARGETS}))
${TARGETS}: ${LABEL_MAPPING}
${LABEL_MAPPING}: /*? ' '.join(imported) ?*/ /*- for g in groups -*/ /*- set p = Perspective(group=g) -*/ ${SEL4_BINDIR}//*? p['elf_name'] ?*/ /*- endfor -*/
	@echo " [GEN] $(notdir $@)"
	$(Q)camkes.sh runner \
        ${CAMKES_FLAGS} \
        --file /*? options.file[0].name ?*/ \
        /*- for inc in options.import_path -*/ --import-path /*? inc ?*/ /*- endfor -*/ \
        --item label-mapping \
        /*- for g in groups -*/ \
            /*- set p = Perspective(group=g) -*/ \
            --elf /*? p['elf_name'] ?*/ \
        /*- endfor -*/ \
        --outfile "$@" \
        --platform seL4
endif

# Static component files provided by the user.
/*- for i in instances if not i.type.hardware -*/
/*? i.name ?*/_CFILES += \
    $(/*? i.type.name ?*/_CFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_CXXFILES += \
    $(/*? i.type.name ?*/_CXXFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_OFILES += \
    $(/*? i.type.name ?*/_OFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_ASMFILES += \
    $(/*? i.type.name ?*/_ASMFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_HFILES += \
    $(/*? i.type.name ?*/_HFILES:%=$(abspath ${BUILD_DIR})/include//*? i.name ?*//static/%)
/*? rule_cp('$(abspath ${BUILD_DIR})/src/' + i.name + '/static/%', '${SOURCE_DIR}/%') ?*/
/*? rule_cp('$(abspath ${BUILD_DIR})/include/' + i.name + '/static/%', '${SOURCE_DIR}/%') ?*/
/*- endfor -*/

# Library dependencies required by glue code.
/*- for i in instances -*/
/*? i.name ?*/_instance_LIBS += ${/*? i.type.name ?*/_LIBS} ${CAMKES_CORE_LIBS}
/*- endfor -*/
/*- for g in groups -*/
/*? g ?*/_group_LIBS = ${CAMKES_CORE_LIBS}
/*- endfor -*/

# Instance entry point generation. Note that this is the instance's C entry
# point, as distinct from both its containing group's C entry point and the
# group's initial assembly entry point.
/*- for i in instances -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + i.name + '/generated/' + i.type.name + '.c', ' '.join(imported), i.name + '.source', i.name) ?*/
/*- if configuration and filter(lambda('x: x.instance == \'%s\' and x.attribute == \'simple\' and x.value ==\'true\'' % (i.name)), configuration.settings) -*/
    /*? rule_gen('$(abspath ${BUILD_DIR})/src/' + i.name + '/generated/' + i.type.name + '.simple.c', ' '.join(imported), i.name + '.simple', i.name) ?*/
/*- endif -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/include/' + i.name + '/generated/' + i.type.name + '.h', ' '.join(imported), i.name + '.header') ?*/
/*? rule_gen('$(abspath ${BUILD_DIR})/include/' + i.name + '/generated/' + 'camkes.h', ' '.join(imported), i.name + '.header') ?*/
/*- endfor -*/

# Connection code generation.
/*- set from_names = [] -*/
/*- set to_names = [] -*/
/*- for c in connections -*/
/*- if not ('%s_%s' % (c.from_instance.name, c.from_interface.name)) in from_names -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + c.from_instance.name + '/generated/' + c.from_interface.name + '_' + c.type.name + '.c', ' '.join(imported), c.name + '.from.source', c.from_instance.name) ?*/
/*- do from_names.append(('%s_%s' % (c.from_instance.name, c.from_interface.name))) -*/
/*- endif -*/
/*- if not ('%s_%s' % (c.to_instance.name, c.to_interface.name)) in to_names -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + c.to_instance.name + '/generated/' + c.to_interface.name + '_' + c.type.name + '.c', ' '.join(imported), c.name + '.to.source', c.to_instance.name) ?*/
/*- do to_names.append(('%s_%s' % (c.to_instance.name, c.to_interface.name))) -*/
/*- endif -*/

ifeq (${CONFIG_CAMKES_PRUNE_GENERATED},y)
/*# We need to provide specialised targets for the pruned c_pp files *and* o
 *# files so the generic targets in tools/common/camkes.mk won't match.
 #*/

/*# Pruned C files (from) #*/
/*- set prefix = '$(abspath ${BUILD_DIR})/src/%s/generated/%s_%s' % (c.from_instance.name, c.from_interface.name, c.type.name) -*/
/*? prefix ?*/.o: /*? prefix ?*/_pruned.c_pp
	@$(if $(filter-out 0,${V}),$(warning Using CAmkES generic .o target),)
	@echo " [CC] $(notdir $@)"
	$(Q)mkdir -p $(dir $@)
	$(Q)$(CC) -x c $(CFLAGS) $(foreach v,$(filter-out $<,$^),$(patsubst %,-I%,$(abspath $(dir ${v})))) -c $< -o $@
/*? prefix ?*/_pruned.c_pp: /*? prefix ?*/.c_pp
	@echo " [PRUNE] $(notdir $@)"
	${Q}LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CONFIG_CAMKES_LLVM_PATH}/lib prune --keep /*? c.from_interface.name ?*/__run \
	/*- if c.from_interface in c.from_instance.type.emits -*/ \
	    --keep /*? c.from_interface.name ?*/_emit_underlying \
	/*- elif c.from_interface in c.from_instance.type.dataports -*/ \
	    --keep /*? c.from_interface.name ?*/_wrap_ptr \
	    --keep /*? c.from_interface.name ?*/_unwrap_ptr \
	    /*# XXX: When pruning generated code involving dataports, the attributes
	     *# of the dataport are discarded. This is a problem because dataports
	     *# need to be page-aligned for the shared memory remapping done by the
	     *# CapDL filters to work correctly. Here we reintroduce the necessary
	     *# attributes. Note that these are expected to match the original
	     *# attributes from whatever template you're using.
	     #*/ \
	    --add-attribute '/*? c.from_interface.name ?*/_data:aligned(1 << 12)' \
	    --add-attribute '/*? c.from_interface.name ?*/_data:section("shared_/*? c.from_interface.name ?*/")' \
	/*- elif c.from_interface in c.from_instance.type.uses -*/ \
	    /*- for m in c.from_interface.type.methods -*/ \
	        --keep /*? c.from_interface.name ?*/_/*? m.name ?*/ \
	    /*- endfor -*/ \
	/*- endif -*/ \
	$(foreach i,${PRUNER_BLACKLIST},--blacklist $i) \
      --blacklist /*? c.from_interface.name ?*/_error_handler_fn \
      --output "$@" "$<"
	$(Q)${FMT} "$@" | ${SPONGE} "$@"

/*# Pruned C files (to) #*/
/*- set prefix = '$(abspath ${BUILD_DIR})/src/%s/generated/%s_%s' % (c.to_instance.name, c.to_interface.name, c.type.name) -*/
/*? prefix ?*/.o: /*? prefix ?*/_pruned.c_pp
	@$(if $(filter-out 0,${V}),$(warning Using CAmkES generic .o target),)
	@echo " [CC] $(notdir $@)"
	$(Q)mkdir -p $(dir $@)
	$(Q)$(CC) -x c $(CFLAGS) $(foreach v,$(filter-out $<,$^),$(patsubst %,-I%,$(abspath $(dir ${v})))) -c $< -o $@
/*? prefix ?*/_pruned.c_pp: /*? prefix ?*/.c_pp
	@echo " [PRUNE] $(notdir $@)"
	${Q}LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CONFIG_CAMKES_LLVM_PATH}/lib prune --keep /*? c.to_interface.name ?*/__run \
	/*- if c.to_interface in c.to_instance.type.consumes -*/ \
	    --keep /*? c.to_interface.name ?*/_poll \
	    --keep /*? c.to_interface.name ?*/_wait \
	/*- elif c.to_interface in c.to_instance.type.dataports -*/ \
	    --keep /*? c.to_interface.name ?*/_wrap_ptr \
	    --keep /*? c.to_interface.name ?*/_unwrap_ptr \
        /*# See note above. #*/ \
	    --add-attribute '/*? c.to_interface.name ?*/_data:aligned(1 << 12)' \
	    --add-attribute '/*? c.to_interface.name ?*/_data:section("shared_/*? c.to_interface.name ?*/")' \
	/*- elif c.to_interface in c.to_instance.type.provides -*/ \
	    /*# nothing extra required #*/ \
	/*- endif -*/ \
	$(foreach i,${PRUNER_BLACKLIST},--blacklist $i) \
      --blacklist /*? c.to_interface.name ?*/_error_handler_fn \
      --output "$@" "$<"
	$(Q)${FMT} "$@" | ${SPONGE} "$@"
endif

/*- endfor -*/

# Each component file may depend on the per-component generated header.
/*- for i in instances if not i.type.hardware -*/
    /*- set header = "$(abspath ${BUILD_DIR})/include/%s/generated/%s.h $(abspath ${BUILD_DIR})/include/%s/generated/camkes.h" % (i.name, i.type.name, i.name) -*/
$(/*? i.name ?*/_CFILES:%.c=%.o): /*? header ?*/
$(/*? i.name ?*/_CXXFILES:%.cxx=%.o): /*? header ?*/
# In case we are running CPP separately:
$(/*? i.name ?*/_CFILES:%.c=%.c_pp): /*? header ?*/
/*- endfor -*/

# Each (generated or static) component file compilation may depend on the
# user-provided code.
/*- for i in instances if not i.type.hardware -*/
$(/*? i.name ?*/_CFILES:%.c=%.o): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_CXXFILES} ${/*? i.name ?*/_ASMFILES}
$(/*? i.name ?*/_CXXFILES:%.cxx=%.o): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_CXXFILES} ${/*? i.name ?*/_ASMFILES}
# In case we are running CPP separately:
$(/*? i.name ?*/_CFILES:%.c=%.c_pp): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_ASMFILES}
/*- endfor -*/

# A target for each binary intended to match the one in common.mk. We introduce
# our own here because we (potentially) need to link different libraries for
# different components.
/*- for i in instances if not i.type.hardware -*/
/*? i.name ?*/_instance_LDFLAGS := \<commit_msg>Tweak how generated files are pruned.<commit_after>/*#
 *# Copyright 2014, NICTA
 *#
 *# This software may be distributed and modified according to the terms of
 *# the BSD 2-Clause license. Note that NO WARRANTY is provided.
 *# See "LICENSE_BSD2.txt" for details.
 *#
 *# @TAG(NICTA_BSD)
 #*/

/*# Ignore the following line. It is intended to apply to the output of this
    template.
#*/
# THIS FILE IS AUTOMATICALLY GENERATED. YOUR EDITS WILL BE OVERWRITTEN.

/*# When modifying this template be particularly careful. The awkward syntax of
    both the templating language and GNU Make come together to make it very
    easy to introduce unreadable code in this context.
#*/

/*# Various macros to make constructing makefile rules easier. #*/
/*- macro rule_cp(target, dependencies) -*/
/*? target ?*/: /*? dependencies ?*/
	@echo " [CP] $(notdir $@)"
	${Q}mkdir -p $(dir $@)
	${Q}echo "#line 1 \"$<\"" >$@
	${Q}cat "$<" >>"$@"
/*- endmacro -*/

/*- macro rule_gen(target, dependencies, item, cfiles_append=None, platform='seL4', preprocessor=None) -*/
/*- if cfiles_append -*/
/*? cfiles_append ?*/_CFILES += /*? target ?*/
/*- endif -*/
.DELETE_ON_ERROR: /*? target ?*/
/*? target ?*/: /*? dependencies ?*/
	@echo " [GEN] $(notdir $@)"
	${Q}mkdir -p $(dir $@)
	${Q}camkes.sh runner \
        ${CAMKES_FLAGS} \
        /*- for inc in options.import_path -*/ --import-path /*? inc ?*/ /*- endfor -*/ \
        --file /*? options.file[0].name ?*/ \
        --item /*? item ?*/ \
        --outfile "$@" \
        --platform /*? platform ?*/
	/*- if preprocessor != None -*/
	@echo " [PP] $(notdir $@)"
	${Q}/*? preprocessor ?*/
	/*- endif -*/
	# Reflow the generated file if it's a C source or header.
	${Q}$(if $(patsubst %.c,,$(patsubst %.h,,/*? target ?*/)),,${FMT} "$@" | ${SPONGE} "$@")
/*- endmacro -*/

# All targets need to be rebuilt if the source CAmkES descriptions change.
${TARGETS}: /*? ' '.join(imported) ?*/

/*- set instances = me.composition.instances -*/
/*- set connections = me.composition.connections -*/

/*# The terms 'group' and 'address space' are currently synonymous. We can
 *# derive the groups by collecting all the instances' address spaces.
 #*/
/*- set groups = set(map(lambda('x: x.address_space'), filter(lambda('x: not x.type.hardware'), instances))) -*/

# Generate the policy label mapping if the user requested it.
ifeq (${CONFIG_CAMKES_LABEL_MAPPING},y)
LABEL_MAPPING=$(patsubst %.cdl,%.json,$(firstword ${TARGETS}))
${TARGETS}: ${LABEL_MAPPING}
${LABEL_MAPPING}: /*? ' '.join(imported) ?*/ /*- for g in groups -*/ /*- set p = Perspective(group=g) -*/ ${SEL4_BINDIR}//*? p['elf_name'] ?*/ /*- endfor -*/
	@echo " [GEN] $(notdir $@)"
	$(Q)camkes.sh runner \
        ${CAMKES_FLAGS} \
        --file /*? options.file[0].name ?*/ \
        /*- for inc in options.import_path -*/ --import-path /*? inc ?*/ /*- endfor -*/ \
        --item label-mapping \
        /*- for g in groups -*/ \
            /*- set p = Perspective(group=g) -*/ \
            --elf /*? p['elf_name'] ?*/ \
        /*- endfor -*/ \
        --outfile "$@" \
        --platform seL4
endif

# Static component files provided by the user.
/*- for i in instances if not i.type.hardware -*/
/*? i.name ?*/_CFILES += \
    $(/*? i.type.name ?*/_CFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_CXXFILES += \
    $(/*? i.type.name ?*/_CXXFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_OFILES += \
    $(/*? i.type.name ?*/_OFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_ASMFILES += \
    $(/*? i.type.name ?*/_ASMFILES:%=$(abspath ${BUILD_DIR})/src//*? i.name ?*//static/%)
/*? i.name ?*/_HFILES += \
    $(/*? i.type.name ?*/_HFILES:%=$(abspath ${BUILD_DIR})/include//*? i.name ?*//static/%)
/*? rule_cp('$(abspath ${BUILD_DIR})/src/' + i.name + '/static/%', '${SOURCE_DIR}/%') ?*/
/*? rule_cp('$(abspath ${BUILD_DIR})/include/' + i.name + '/static/%', '${SOURCE_DIR}/%') ?*/
/*- endfor -*/

# Library dependencies required by glue code.
/*- for i in instances -*/
/*? i.name ?*/_instance_LIBS += ${/*? i.type.name ?*/_LIBS} ${CAMKES_CORE_LIBS}
/*- endfor -*/
/*- for g in groups -*/
/*? g ?*/_group_LIBS = ${CAMKES_CORE_LIBS}
/*- endfor -*/

# Instance entry point generation. Note that this is the instance's C entry
# point, as distinct from both its containing group's C entry point and the
# group's initial assembly entry point.
/*- for i in instances -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + i.name + '/generated/' + i.type.name + '.c', ' '.join(imported), i.name + '.source', i.name) ?*/
/*- if configuration and filter(lambda('x: x.instance == \'%s\' and x.attribute == \'simple\' and x.value ==\'true\'' % (i.name)), configuration.settings) -*/
    /*? rule_gen('$(abspath ${BUILD_DIR})/src/' + i.name + '/generated/' + i.type.name + '.simple.c', ' '.join(imported), i.name + '.simple', i.name) ?*/
/*- endif -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/include/' + i.name + '/generated/' + i.type.name + '.h', ' '.join(imported), i.name + '.header') ?*/
/*? rule_gen('$(abspath ${BUILD_DIR})/include/' + i.name + '/generated/' + 'camkes.h', ' '.join(imported), i.name + '.header') ?*/
/*- endfor -*/

# Connection code generation.
/*- set from_names = [] -*/
/*- set to_names = [] -*/
/*- for c in connections -*/
/*- if not ('%s_%s' % (c.from_instance.name, c.from_interface.name)) in from_names -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + c.from_instance.name + '/generated/' + c.from_interface.name + '_' + c.type.name + '.c', ' '.join(imported), c.name + '.from.source', c.from_instance.name) ?*/
/*- do from_names.append(('%s_%s' % (c.from_instance.name, c.from_interface.name))) -*/
/*- endif -*/
/*- if not ('%s_%s' % (c.to_instance.name, c.to_interface.name)) in to_names -*/
/*? rule_gen('$(abspath ${BUILD_DIR})/src/' + c.to_instance.name + '/generated/' + c.to_interface.name + '_' + c.type.name + '.c', ' '.join(imported), c.name + '.to.source', c.to_instance.name) ?*/
/*- do to_names.append(('%s_%s' % (c.to_instance.name, c.to_interface.name))) -*/
/*- endif -*/

ifeq (${CONFIG_CAMKES_PRUNE_GENERATED},y)
/*# We need to provide specialised targets for the pruned c_pp files *and* o
 *# files so the generic targets in tools/common/camkes.mk won't match.
 #*/

/*# Pruned C files (from) #*/
/*- set prefix = '$(abspath ${BUILD_DIR})/src/%s/generated/%s_%s' % (c.from_instance.name, c.from_interface.name, c.type.name) -*/
/*? prefix ?*/.o: /*? prefix ?*/_pruned.c_pp
	@$(if $(filter-out 0,${V}),$(warning Using CAmkES generic .o target),)
	@echo " [CC] $(notdir $@)"
	$(Q)mkdir -p $(dir $@)
	$(Q)$(CC) -x c $(CFLAGS) $(foreach v,$(filter-out $<,$^),$(patsubst %,-I%,$(abspath $(dir ${v})))) -c $< -o $@
/*? prefix ?*/_pruned.c_pp: /*? prefix ?*/.c_pp
	@echo " [PRUNE] $(notdir $@)"
	${Q}LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CONFIG_CAMKES_LLVM_PATH}/lib prune --keep /*? c.from_interface.name ?*/__run \
	/*- if c.from_interface in c.from_instance.type.emits -*/ \
	    --keep /*? c.from_interface.name ?*/_emit_underlying \
	/*- elif c.from_interface in c.from_instance.type.dataports -*/ \
	    --keep /*? c.from_interface.name ?*/_wrap_ptr \
	    --keep /*? c.from_interface.name ?*/_unwrap_ptr \
	    /*# XXX: When pruning generated code involving dataports, the attributes
	     *# of the dataport are discarded. This is a problem because dataports
	     *# need to be page-aligned for the shared memory remapping done by the
	     *# CapDL filters to work correctly. Here we reintroduce the necessary
	     *# attributes. Note that these are expected to match the original
	     *# attributes from whatever template you're using.
	     #*/ \
	    --add-attribute '/*? c.from_interface.name ?*/_data:aligned(1 << 12)' \
	    --add-attribute '/*? c.from_interface.name ?*/_data:section("shared_/*? c.from_interface.name ?*/")' \
	/*- elif c.from_interface in c.from_instance.type.uses -*/ \
	    /*- for m in c.from_interface.type.methods -*/ \
	        --keep /*? c.from_interface.name ?*/_/*? m.name ?*/ \
	    /*- endfor -*/ \
	/*- endif -*/ \
	  /*# unconditionally keep some things verification refers to. #*/ \
	  --keep camkes_get_tls \
	  --keep seL4_Call \
	  --keep seL4_Notify \
	  --keep seL4_Poll \
	  --keep seL4_ReplyWait \
	  --keep seL4_Wait \
	$(foreach i,${PRUNER_BLACKLIST},--blacklist $i) \
      --blacklist /*? c.from_interface.name ?*/_error_handler_fn \
      --output "$@" "$<"
	@# We prepend a declaration of abort because it gets pruned and is needed for
	@# verification.
	$(Q)sh -c "echo 'void abort(void);'; cat $@" | ${FMT} | ${SPONGE} "$@"

/*# Pruned C files (to) #*/
/*- set prefix = '$(abspath ${BUILD_DIR})/src/%s/generated/%s_%s' % (c.to_instance.name, c.to_interface.name, c.type.name) -*/
/*? prefix ?*/.o: /*? prefix ?*/_pruned.c_pp
	@$(if $(filter-out 0,${V}),$(warning Using CAmkES generic .o target),)
	@echo " [CC] $(notdir $@)"
	$(Q)mkdir -p $(dir $@)
	$(Q)$(CC) -x c $(CFLAGS) $(foreach v,$(filter-out $<,$^),$(patsubst %,-I%,$(abspath $(dir ${v})))) -c $< -o $@
/*? prefix ?*/_pruned.c_pp: /*? prefix ?*/.c_pp
	@echo " [PRUNE] $(notdir $@)"
	${Q}LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${CONFIG_CAMKES_LLVM_PATH}/lib prune --keep /*? c.to_interface.name ?*/__run \
	/*- if c.to_interface in c.to_instance.type.consumes -*/ \
	    --keep /*? c.to_interface.name ?*/_poll \
	    --keep /*? c.to_interface.name ?*/_wait \
	/*- elif c.to_interface in c.to_instance.type.dataports -*/ \
	    --keep /*? c.to_interface.name ?*/_wrap_ptr \
	    --keep /*? c.to_interface.name ?*/_unwrap_ptr \
        /*# See note above. #*/ \
	    --add-attribute '/*? c.to_interface.name ?*/_data:aligned(1 << 12)' \
	    --add-attribute '/*? c.to_interface.name ?*/_data:section("shared_/*? c.to_interface.name ?*/")' \
	/*- elif c.to_interface in c.to_instance.type.provides -*/ \
	    /*# nothing extra required #*/ \
	/*- endif -*/ \
	  /*# unconditionally keep some things verification refers to. #*/ \
	  --keep camkes_get_tls \
	  --keep seL4_Call \
	  --keep seL4_Notify \
	  --keep seL4_Poll \
	  --keep seL4_ReplyWait \
	  --keep seL4_Wait \
	$(foreach i,${PRUNER_BLACKLIST},--blacklist $i) \
      --blacklist /*? c.to_interface.name ?*/_error_handler_fn \
      --output "$@" "$<"
	@# We prepend a declaration of abort because it gets pruned and is needed for
	@# verification.
	$(Q)sh -c "echo 'void abort(void);'; cat $@" | ${FMT} | ${SPONGE} "$@"
endif

/*- endfor -*/

# Each component file may depend on the per-component generated header.
/*- for i in instances if not i.type.hardware -*/
    /*- set header = "$(abspath ${BUILD_DIR})/include/%s/generated/%s.h $(abspath ${BUILD_DIR})/include/%s/generated/camkes.h" % (i.name, i.type.name, i.name) -*/
$(/*? i.name ?*/_CFILES:%.c=%.o): /*? header ?*/
$(/*? i.name ?*/_CXXFILES:%.cxx=%.o): /*? header ?*/
# In case we are running CPP separately:
$(/*? i.name ?*/_CFILES:%.c=%.c_pp): /*? header ?*/
/*- endfor -*/

# Each (generated or static) component file compilation may depend on the
# user-provided code.
/*- for i in instances if not i.type.hardware -*/
$(/*? i.name ?*/_CFILES:%.c=%.o): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_CXXFILES} ${/*? i.name ?*/_ASMFILES}
$(/*? i.name ?*/_CXXFILES:%.cxx=%.o): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_CXXFILES} ${/*? i.name ?*/_ASMFILES}
# In case we are running CPP separately:
$(/*? i.name ?*/_CFILES:%.c=%.c_pp): ${/*? i.name ?*/_HFILES} ${/*? i.name ?*/_CFILES} ${/*? i.name ?*/_ASMFILES}
/*- endfor -*/

# A target for each binary intended to match the one in common.mk. We introduce
# our own here because we (potentially) need to link different libraries for
# different components.
/*- for i in instances if not i.type.hardware -*/
/*? i.name ?*/_instance_LDFLAGS := \
{'fraction_non_alphanumeric': 0.23432992394440075, 'fraction_numerical': 0.002185505726025002, 'mean_word_length': 3.0047260633642567, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7626744', 'n_tokens_mistral': 8793, 'n_tokens_neox': 8496, 'n_words': 1961}