# PURPOSE: If an appBuilder file is specified, this code converts it # into a makefile fragment. If no appBuilder file is created, this # code ensures the mandatory variables are set. app_builder_non_app_vars=COMPONENTS CHOSEN_MODULE CONFIGURE_NEMS_FILE EXTERNALS_NEMS_FILE CONFOPT all_app_builder_files=${shell ls $(ROOTDIR)/*.appBuilder} all_app_builds=${foreach file,$(all_app_builder_files),${notdir ${subst .appBuilder,,${notdir $(file)}}}} # Special flag to increase verbosity when scanning appBuilder files: VERBOSE_MAKE?=NO # NOTE: nothing else in this file is executed unless an app is specified. ######################################################################## ifneq ($(app),) # User is using an app ifeq ($(app),) define app_error Known apps: $(all_app_builds) Specify the app to build endef ${error $(app_error)} endif ifneq ($(filter $(app),$(all_app_builds)),$(app)) define app_error Known apps: $(all_app_builds) Unknown app $(app). Specify a valid app endef ${error $(app_error)} endif app_builder_file=$(ROOTDIR)/$(app).appBuilder app_builder_makefile=$(ROOTDIR)/$(app).appBuilder.mk ######################################################################## # Convert the appBuilder file to a makefile # --------------------------- define shell_prep_logic ------------------------- define shell_prep_logic if [[ $(VERBOSE_MAKE) == YES ]] ; then echo 1>&2 echo ------------------------------------------------------------------------ 1>&2 echo '\'' READ APPBUILDER FILE '\'' 1>&2 echo 1>&2 echo FROM $(app_builder_file) 1>&2 echo INTO $(app_builder_makefile) 1>&2 fi export FULL_MACHINE_ID='\''$(FULL_MACHINE_ID)'\'' export MACHINE_ID='\''$(MACHINE_ID)'\'' export NEMSDIR='\''$(NEMSDIR)'\'' export ROOTDIR='\''$(ROOTDIR)'\'' export PEX='\''$(PEX)'\'' export MACHINE_ID_DOT='\''$(MACHINE_ID_DOT)'\'' export MACHINE_ID_UNDER='\''$(MACHINE_ID_UNDER)'\'' export FULL_MACHINE_ID_DOT='\''$(FULL_MACHINE_ID_DOT)'\'' export FULL_MACHINE_ID_UNDER='\''$(FULL_MACHINE_ID_UNDER)'\'' source $(app_builder_file) > /dev/null if [[ "$(VERBOSE_MAKE)" == YES ]] ; then echo 1>&2 echo \# NON-COMPONENT-SPECIFIC VARS: 1>&2 echo 1>&2 fi cat< $(app_builder_makefile) # Do not edit this file. It is generated from: # $(app_builder_file) # Edit that file instead. EOT for var in $${VARS} ; do value=$$( eval echo '\''$${'\''"$${var}"'\''[@]}'\'' ) if [[ "Q$${value}" != Q ]] ; then echo $$var \?= $$value if [[ "$(VERBOSE_MAKE)" == YES ]] ; then echo $$var \?= \"$$value\" 1>&2 fi fi done >> "$(app_builder_makefile)" if [[ "$(VERBOSE_MAKE)" == YES ]] ; then echo 1>&2 echo \# COMPONENT-SPECIFIC VARS FOR: \[ $${COMPONENTS[@]} \] 1>&2 fi for component in $${COMPONENTS[@]} ; do if [[ $(VERBOSE_MAKE) == YES ]] ; then echo 1>&2 fi for var in $${component}_CAPDIR $${component}_BINDIR $${component}_SRCDIR $${component}_CONFOPT $${component}_BUILDOPT $${component}_MAKEOPT ; do value=$$( eval echo '\''$${'\''"$${var}"'\''[@]}'\'' ) if [[ "$${value}Q" != Q ]] ; then echo $$var \?= $$value if [[ "$(VERBOSE_MAKE)" == YES ]] ; then echo $$var \?= \"$$value\" 1>&2 fi fi done done >> $(app_builder_makefile) if [[ "$(VERBOSE_MAKE)" == YES ]] ; then echo 1>&2 echo ------------------------------------------------------------------------ 1>&2 echo 1>&2 fi echo DONE endef # ---------------------------- endef shell_prep_logic ------------------------- read_app_builder = $(shell bash -c 'export VARS="$(1)" ; $(shell_prep_logic)' ) $(info Convert $(app_builder_file)) $(info ...into $(app_builder_makefile)) ifneq (,$(call read_app_builder,$(app_builder_non_app_vars))) $(info Include $(app_builder_makefile)) include $(app_builder_makefile) else $(error Could not parse $(app_builder_file)) endif endif