smart-config.mk 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # 1: shell scrtipt
  2. # 2: compiled executable
  3. # 3: components directory
  4. smart_config = $(shell sh -- $1 $2 $3)
  5. _SC := smart-config
  6. _GEN := ${_SC}/gen_comp.sed
  7. _EXE := ${_SC}/smart-config
  8. _SH := ${_SC}/smart-config.sh
  9. _COMP_C := ${_SC}/components.c
  10. _COMP_O := ${_COMP_C:.c=.o}
  11. SMART_CONFIG_EXE := ${_EXE}
  12. SMART_CONFIG_COMPONENTS_O := ${_COMP_O}
  13. SMART_CONFIG_OFILES := ${_EXE}.o ${_COMP_O}
  14. SMART_CONFIG_DEPS := ${_EXE} ${_SH}
  15. SMART_CONFIG_FILTER := man install clean uninstall
  16. ${_COMP_O}: lib/util.h
  17. ${_EXE}.o: lib/util.h aslstatus.h config.h
  18. .PHONY: smart-conf
  19. smart-conf: ${SMART_CONFIG_DEPS}
  20. @echo 'USING SMART CONFIG'
  21. $(eval export SMART_CONFIG=0)
  22. $(eval export COMPONENTS=$(addprefix components/,\
  23. $(call smart_config,./${_SH},./${_EXE},./components)))
  24. @+$(MAKE) $(filter-out ${SMART_CONFIG_FILTER},$(MAKECMDGOALS))
  25. ${_EXE}: ${SMART_CONFIG_OFILES}
  26. $(CC) -o $@ $^ ${LDFLAGS} ${CFLAGS} -Wno-lto-type-mismatch
  27. .PHONY: smart-config-clean
  28. smart-config-clean:
  29. rm -f -- ${SMART_CONFIG_EXE} ${SMART_CONFIG_OFILES}
  30. ${_COMP_C}: aslstatus.h ${_GEN}
  31. sed -nf ./${_GEN} < $< > $@