aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: cf76bb6c3bfd7992f6bf2f1c0c707373428d0bcd (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
##########################################################################################
#*                                                                                      *#
#*  File     : Makefile                                                   /_________/   *#
#*  Author   : Joe                                                              |       *#
#*  Date     : 04/2020                                                          |       *#
#*  Info     : BSD Makefile                                                     |       *#
#*                                                                      /       |       *#
#*                                                                      \       /       *#
#*                                                                       \_____/        *#
#*                                                                                      *#
##########################################################################################

default: all

C_SRCS_DIR	 = src
A_SRCS_DIR	 = asm
PREFIX		?= /usr/local
BINPREFIX	?= ${PREFIX}/bin
MANPREFIX	?= ${PREFIX}/share/man

C_SRCS		+= ${C_SRCS_DIR}/n_speak.c
C_SRCS		+= ${C_SRCS_DIR}/n_notify.c

C_OBJS		 = ${C_SRCS:.c=.o}

A_SRCS		 = ${A_SRCS_DIR}/r_lowbat.asm
A_SRCS		+= ${A_SRCS_DIR}/r_loop.asm
A_SRCS		+= ${A_SRCS_DIR}/r_cpyhead.asm
A_SRCS		+= ${A_SRCS_DIR}/c_args.asm
A_SRCS		+= ${A_SRCS_DIR}/f_status.asm
A_SRCS		+= ${A_SRCS_DIR}/f_percent.asm

A_OBJS		 = ${A_SRCS:.asm=.o}

CC			 = cc
CFLAGS		+= -std=c89
CFLAGS		+= -Wall
CFLAGS		+= -Wextra
CFLAGS		+= -Wno-comment
CFLAGS		+= -Wno-long-long
CFLAGS		+= -Wno-c99-extensions
CFLAGS		+= -Wno-variadic-macros
CFLAGS		+= -Werror
CFLAGS		+= -pedantic
# CFLAGS		+= -O0 -glldb
# CFLAGS		+= -fsanitize=address

CINCS		+= -I/usr/local/include
CINCS		+= -I/usr/local/include/glib-2.0
CINCS		+= -I/usr/local/lib/glib-2.0/include
CINCS		+= -I/usr/local/include/gdk-pixbuf-2.0

LDFLAGS		?=
LDLIBS		 = ${LDFLAGS}
LDLIBS		+= -L/usr/local/lib
LDLIBS		+= -L/usr/lib
LDLIBS		+= -lnotify
LDLIBS		+= -lespeak
LDLIBS		+= -lc

TARGET		 = lowbat

ASM			 = yasm
ASMFLAGS	 = -f elf64
ASMFLAGS	+= -p gas
# ASMFLAGS	+= -g

LDFLAGS		?=
LDLIBS		 = ${LDFLAGS}
LDLIBS		+= -L/usr/local/lib
LDLIBS		+= -lnotify
LDLIBS		+= -lespeak

SHELL		:= /bin/sh
RM			 = rm -f
MKDIR		 = mkdir -p
CP			 = cp -pf
MV			 = mv
SED			 = sed

.SUFFIXES: .asm .c .o

.asm.o:
	${ASM} ${ASMFLAGS} -o ${.TARGET} ${.IMPSRC}

.c.o:
	${CC} -c ${CFLAGS} ${CINCS} -o ${.TARGET} ${.IMPSRC}

${TARGET}: ${A_OBJS} ${C_OBJS}
	${CC} ${CFLAGS} -o ${.TARGET} ${A_OBJS} ${C_OBJS} ${LDLIBS}

depend:
	${CC} ${CINCS} -E -MM ${C_SRCS} > .depend
	${SED} 's/^jo/${C_SRCS_DIR}\/jo/' .depend > .depend.tmp
	${MV} .depend.tmp .depend

all:
	${MAKE} depend
	${MAKE} ${TARGET}

install: all
	${MKDIR} "${DESTDIR}${BINPREFIX}"
	${CP} ${TARGET} "${DESTDIR}${BINPREFIX}"
	${MKDIR} "${DESTDIR}${MANPREFIX}"/man1
	${CP} man/${TARGET}.1 "${DESTDIR}${MANPREFIX}"/man1

uninstall:
	${RM} "${DESTDIR}${BINPREFIX}"/${TARGET}
	${RM} "${DESTDIR}${MANPREFIX}"/man1/${TARGET}.1

clean:
	${RM} ${C_OBJS} ${A_OBJS} ${TARGET}.core .depend .depend.tmp ${TARGET}

re: clean all

.PHONY: all clean fclean re depend install uninstall

# Files prefixes
# --------------
# f: fetch
# n: notify
# r: run
# c: check