aboutsummaryrefslogtreecommitdiff
path: root/experimental/Makefile
blob: 9d94f551ff875c46162aa5612b87ba4a5d4fcc37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# Startdate: 2022-09-28
# References:
#    BUILD_DIR and per-.cpp file https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
#    https://bgstack15.ddns.net/blog/posts/2019/11/04/sample-makefile/ 2022-09-28-4 15:34
awkbin     :=$(shell which awk)
cpbin      :=$(shell which cp)
echobin    :=$(shell which echo)
findbin    :=$(shell which find)
grepbin    :=$(shell which grep)
installbin :=$(shell which install)
rmbin      :=$(shell which rm)
sedbin     :=$(shell which sed)
sortbin    :=$(shell which sort)
truebin    :=$(shell which true)

CXX = g++
CC = gcc

# to get full debug symbols, add to both FLAGS: -g
# to make all warnings act as errors: -Wall -Weffc++ -Wextra -Wsign-conversion -Werror
CXXFLAGS = -g -std=c++17 -Wall -Weffc++ -Wextra -Wsign-conversion -Werror
CCFLAGS = -g -Wno-deprecated-declarations \
	`pkg-config --cflags x11` \
	`pkg-config --cflags gtk+-3.0` \
	`pkg-config --cflags inih` \
	$(DEBUGFLAGS)
#	`pkg-config --cflags xapp` \
CCFLAGS2 = -g -Wsign-conversion -Werror \
	`pkg-config --cflags inih`

# to remove all debug symbols: -s
# to add full debug symbols: -g
LDFLAGS = -g \
	`pkg-config --libs x11` \
	`pkg-config --libs gtk+-3.0` \
	`pkg-config --libs inih`

ifneq (,$(ENABLE_LIBXDO))
CCFLAGS += -DENABLE_LIBXDO=1
LDFLAGS += -lxdo
# -lxdo is not available in pkg-config.
endif

LDFLAGS2 = -g \
	`pkg-config --libs inih`

ifneq (,$(DEBUG))
CCFLAGS+=-DDEBUG=1
endif
ifneq (,$(ENABLE_SOCKETS))
CCFLAGS+=-DENABLE_SOCKETS=1
endif

src = $(wildcard *.c)
src := $(filter-out readconf.c, $(src))
#src2 = $(wildcard read*.c)
obj = $(src:.c=.o)
#obj2 = $(src2:.c=.o)

BUILD_DIR ?= .

OUTEXE = keyboard-leds-trayicons
#OUTEXE2 = readconf

all: $(OUTEXE) $(OUTEXE2)
#all: $(OUTEXE)

$(obj):

#$(obj2):

$(BUILD_DIR)/%.o: %.c
	$(CC) -c $(CCFLAGS) -o $@ $<

#$(BUILD_DIR)/readconf.o: readconf.c
#	$(CC) -c $(CCFLAGS2) -o $@ $<

# link
$(OUTEXE): $(obj)
	$(CC) -o $@ $^ $(LDFLAGS)

#$(OUTEXE2): $(obj2)
#	$(CC) -o $@ $^ $(LDFLAGS2)

.PHONY: clean cleanall list

list:
	@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' -e '\.(cp*|o)' -e '^$$'

clean:
	rm -f $(obj) $(obj2)

cleanall:
	rm -f $(obj) $(OUTEXE) $(obj2) $(OUTEXE2)
bgstack15