| 1 | MAKEFLAGS := --no-builtin-rules |
| 2 | |
| 3 | PREFIX := $(HOME) |
| 4 | PATH_TO_AWK := /usr/bin/awk |
| 5 | AWK_EXECUTABLES := \ |
| 6 | bin/khatus_bar \ |
| 7 | bin/khatus_actuate_alert_to_notify_send \ |
| 8 | bin/khatus_actuate_device_add_to_automount \ |
| 9 | bin/khatus_actuate_status_bar_to_xsetroot_name \ |
| 10 | bin/khatus_gen_bar_make_status \ |
| 11 | bin/khatus_monitor_devices \ |
| 12 | bin/khatus_monitor_energy \ |
| 13 | bin/khatus_monitor_errors \ |
| 14 | bin/khatus_parse_bluetoothctl_show \ |
| 15 | bin/khatus_parse_df_pcent \ |
| 16 | bin/khatus_parse_fan_file \ |
| 17 | bin/khatus_parse_free \ |
| 18 | bin/khatus_parse_ip_addr \ |
| 19 | bin/khatus_parse_iwconfig \ |
| 20 | bin/khatus_parse_loadavg_file \ |
| 21 | bin/khatus_parse_noaa_api \ |
| 22 | bin/khatus_parse_mpd_status_currentsong \ |
| 23 | bin/khatus_parse_pactl_list_sinks \ |
| 24 | bin/khatus_parse_ps \ |
| 25 | bin/khatus_parse_sys_block_stat \ |
| 26 | bin/khatus_parse_udevadm_monitor_block \ |
| 27 | bin/khatus_parse_upower |
| 28 | BASH_EXECUTABLE_NAMES := \ |
| 29 | khatus \ |
| 30 | khatus_sensor_bluetooth \ |
| 31 | khatus_sensor_bluetooth_power \ |
| 32 | khatus_sensor_datetime \ |
| 33 | khatus_sensor_devices \ |
| 34 | khatus_sensor_disk_io \ |
| 35 | khatus_sensor_disk_space \ |
| 36 | khatus_sensor_energy \ |
| 37 | khatus_sensor_fan \ |
| 38 | khatus_sensor_loadavg \ |
| 39 | khatus_sensor_memory \ |
| 40 | khatus_sensor_mpd \ |
| 41 | khatus_sensor_net_addr_io \ |
| 42 | khatus_sensor_net_carrier \ |
| 43 | khatus_sensor_net_wifi_status \ |
| 44 | khatus_sensor_procs \ |
| 45 | khatus_sensor_screen_brightness \ |
| 46 | khatus_sensor_temperature \ |
| 47 | khatus_sensor_volume \ |
| 48 | khatus_sensor_weather |
| 49 | BASH_EXECUTABLES := $(foreach exe,$(BASH_EXECUTABLE_NAMES),bin/$(exe)) |
| 50 | EXECUTABLES := $(AWK_EXECUTABLES) $(BASH_EXECUTABLES) |
| 51 | |
| 52 | define BUILD_AWK_EXE |
| 53 | echo '#! $(PATH_TO_AWK) -f' > $@ && \ |
| 54 | echo 'BEGIN {Node = Node ? Node : "$(shell hostname)"}' >> $@ && \ |
| 55 | echo 'BEGIN {Module = "$(notdir $@)"}' >> $@ && \ |
| 56 | cat $^ >> $@ && \ |
| 57 | chmod +x $@ |
| 58 | endef |
| 59 | |
| 60 | define BUILD_BASH_EXE |
| 61 | cat $^ > $@ && \ |
| 62 | chmod +x $@ |
| 63 | endef |
| 64 | |
| 65 | define GEN_BASH_EXE_RULE |
| 66 | bin/$(1) : src/bash/exe/$(1).sh |
| 67 | $$(BUILD_BASH_EXE) |
| 68 | endef |
| 69 | |
| 70 | .PHONY: \ |
| 71 | build \ |
| 72 | rebuild \ |
| 73 | install \ |
| 74 | uninstall \ |
| 75 | reinstall \ |
| 76 | clean |
| 77 | |
| 78 | build: | bin |
| 79 | build: $(EXECUTABLES) |
| 80 | |
| 81 | install: |
| 82 | @$(foreach filename,$(wildcard bin/*),cp -p "$(filename)" "$(PREFIX)/$(filename)"; ) |
| 83 | |
| 84 | uninstall: |
| 85 | @$(foreach filename,$(wildcard $(PREFIX)/bin/khatus*),rm "$(filename)"; ) |
| 86 | |
| 87 | reinstall: |
| 88 | @$(MAKE) -s uninstall |
| 89 | @$(MAKE) -s install |
| 90 | |
| 91 | rebuild: |
| 92 | @$(MAKE) -s clean |
| 93 | @$(MAKE) -s build |
| 94 | |
| 95 | clean: |
| 96 | rm -rf bin |
| 97 | |
| 98 | bin: |
| 99 | mkdir -p bin |
| 100 | |
| 101 | #----------------------------------------------------------------------------- |
| 102 | # Bash |
| 103 | #----------------------------------------------------------------------------- |
| 104 | $(foreach exe,$(BASH_EXECUTABLE_NAMES),$(eval $(call GEN_BASH_EXE_RULE,$(exe)))) |
| 105 | |
| 106 | #----------------------------------------------------------------------------- |
| 107 | # AWK |
| 108 | #----------------------------------------------------------------------------- |
| 109 | bin/khatus_bar: \ |
| 110 | src/awk/exe/bar.awk \ |
| 111 | src/awk/lib/cache.awk \ |
| 112 | src/awk/lib/str.awk \ |
| 113 | src/awk/lib/msg.awk \ |
| 114 | src/awk/lib/num.awk |
| 115 | $(BUILD_AWK_EXE) |
| 116 | |
| 117 | bin/khatus_actuate_alert_to_notify_send: \ |
| 118 | src/awk/exe/actuate_alert_to_notify_send.awk \ |
| 119 | src/awk/lib/str.awk \ |
| 120 | src/awk/lib/msg.awk |
| 121 | $(BUILD_AWK_EXE) |
| 122 | |
| 123 | bin/khatus_actuate_device_add_to_automount: \ |
| 124 | src/awk/exe/actuate_device_add_to_automount.awk \ |
| 125 | src/awk/lib/str.awk \ |
| 126 | src/awk/lib/msg.awk |
| 127 | $(BUILD_AWK_EXE) |
| 128 | |
| 129 | bin/khatus_actuate_status_bar_to_xsetroot_name: \ |
| 130 | src/awk/exe/actuate_status_bar_to_xsetroot_name.awk \ |
| 131 | src/awk/lib/str.awk \ |
| 132 | src/awk/lib/msg.awk |
| 133 | $(BUILD_AWK_EXE) |
| 134 | |
| 135 | bin/khatus_gen_bar_make_status: \ |
| 136 | src/awk/exe/gen_bar_make_status.awk |
| 137 | $(BUILD_AWK_EXE) |
| 138 | |
| 139 | bin/khatus_monitor_devices: \ |
| 140 | src/awk/exe/monitor_devices.awk \ |
| 141 | src/awk/lib/str.awk \ |
| 142 | src/awk/lib/msg.awk |
| 143 | $(BUILD_AWK_EXE) |
| 144 | |
| 145 | bin/khatus_monitor_energy: \ |
| 146 | src/awk/exe/monitor_energy.awk \ |
| 147 | src/awk/lib/str.awk \ |
| 148 | src/awk/lib/msg.awk \ |
| 149 | src/awk/lib/num.awk |
| 150 | $(BUILD_AWK_EXE) |
| 151 | |
| 152 | bin/khatus_monitor_errors: \ |
| 153 | src/awk/exe/monitor_errors.awk \ |
| 154 | src/awk/lib/str.awk \ |
| 155 | src/awk/lib/msg.awk |
| 156 | $(BUILD_AWK_EXE) |
| 157 | |
| 158 | bin/khatus_parse_bluetoothctl_show: \ |
| 159 | src/awk/exe/parse_bluetoothctl_show.awk \ |
| 160 | src/awk/lib/msg.awk |
| 161 | $(BUILD_AWK_EXE) |
| 162 | |
| 163 | bin/khatus_parse_df_pcent: \ |
| 164 | src/awk/exe/parse_df_pcent.awk \ |
| 165 | src/awk/lib/msg.awk |
| 166 | $(BUILD_AWK_EXE) |
| 167 | |
| 168 | bin/khatus_parse_fan_file: \ |
| 169 | src/awk/exe/parse_fan_file.awk \ |
| 170 | src/awk/lib/msg.awk |
| 171 | $(BUILD_AWK_EXE) |
| 172 | |
| 173 | bin/khatus_parse_free: \ |
| 174 | src/awk/exe/parse_free.awk \ |
| 175 | src/awk/lib/msg.awk |
| 176 | $(BUILD_AWK_EXE) |
| 177 | |
| 178 | bin/khatus_parse_ip_addr: \ |
| 179 | src/awk/exe/parse_ip_addr.awk \ |
| 180 | src/awk/lib/msg.awk |
| 181 | $(BUILD_AWK_EXE) |
| 182 | |
| 183 | bin/khatus_parse_iwconfig: \ |
| 184 | src/awk/exe/parse_iwconfig.awk \ |
| 185 | src/awk/lib/msg.awk |
| 186 | $(BUILD_AWK_EXE) |
| 187 | |
| 188 | bin/khatus_parse_loadavg_file: \ |
| 189 | src/awk/exe/parse_loadavg_file.awk \ |
| 190 | src/awk/lib/msg.awk |
| 191 | $(BUILD_AWK_EXE) |
| 192 | |
| 193 | # Order of dependencies is important for khatus_parse_noaa_api! |
| 194 | # parse_hxpipe MUST appear before parse_noaa_api, because the order in |
| 195 | # which they match lines matters! |
| 196 | bin/khatus_parse_noaa_api: \ |
| 197 | src/awk/lib/parse_hxpipe.awk \ |
| 198 | src/awk/exe/parse_noaa_api.awk \ |
| 199 | src/awk/lib/msg.awk \ |
| 200 | src/awk/lib/str.awk |
| 201 | $(BUILD_AWK_EXE) |
| 202 | |
| 203 | bin/khatus_parse_mpd_status_currentsong: \ |
| 204 | src/awk/exe/parse_mpd_status_currentsong.awk \ |
| 205 | src/awk/lib/msg.awk |
| 206 | $(BUILD_AWK_EXE) |
| 207 | |
| 208 | bin/khatus_parse_pactl_list_sinks: \ |
| 209 | src/awk/exe/parse_pactl_list_sinks.awk \ |
| 210 | src/awk/lib/msg.awk |
| 211 | $(BUILD_AWK_EXE) |
| 212 | |
| 213 | bin/khatus_parse_ps: \ |
| 214 | src/awk/exe/parse_ps.awk \ |
| 215 | src/awk/lib/msg.awk |
| 216 | $(BUILD_AWK_EXE) |
| 217 | |
| 218 | bin/khatus_parse_sys_block_stat: \ |
| 219 | src/awk/exe/parse_sys_block_stat.awk \ |
| 220 | src/awk/lib/msg.awk |
| 221 | $(BUILD_AWK_EXE) |
| 222 | |
| 223 | bin/khatus_parse_udevadm_monitor_block: \ |
| 224 | src/awk/exe/parse_udevadm_monitor_block.awk \ |
| 225 | src/awk/lib/msg.awk |
| 226 | $(BUILD_AWK_EXE) |
| 227 | |
| 228 | bin/khatus_parse_upower: \ |
| 229 | src/awk/exe/parse_upower.awk \ |
| 230 | src/awk/lib/msg.awk |
| 231 | $(BUILD_AWK_EXE) |