smart-config.mk 984 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. ${_COMP_O}: lib/util.h
  16. ${_EXE}.o: lib/util.h aslstatus.h config.h
  17. .PHONY: smart-conf
  18. smart-conf: ${SMART_CONFIG_DEPS}
  19. @echo 'USING SMART CONFIG'
  20. $(eval export SMART_CONFIG=0)
  21. $(eval export COMPONENTS=$(addprefix components/,\
  22. $(call smart_config,./${_SH},./${_EXE},./components)))
  23. @+$(MAKE)
  24. ${_EXE}: ${SMART_CONFIG_OFILES}
  25. $(CC) -o $@ $^ ${LDFLAGS} ${CFLAGS}
  26. .PHONY: smart-config-clean
  27. smart-config-clean:
  28. rm -f -- ${SMART_CONFIG_EXE} ${SMART_CONFIG_OFILES}
  29. ${_COMP_C}: aslstatus.h ${_GEN}
  30. sed -nf ./${_GEN} < $< > $@