aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 400251521151705288f2765f13a2478ea34d42ea (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
default: all

SHELL		:= /bin/sh
# ============================================ DIRS ============================================== #
C_SRCS_DIR	= src
A_SRCS_DIR	= asm
# =========================================== FILES ============================================== #
C_SRCS		 = ${C_SRCS_DIR}/jo_main.c
C_SRCS		+= ${C_SRCS_DIR}/jo_printf.c
# ------------------------------------------------------------------------------------------------ #
C_OBJS		= ${C_SRCS:.c=.o}
# ========================================== COMPILER ============================================ #
CC			= clang
# ------------------------------------------------------------------------------------------------ #
CFLAGS		= -std=c89
CFLAGS		+= -Wall
CFLAGS		+= -Wextra
CFLAGS		+= -Werror
CFLAGS		+= -pedantic
CFLAGS		+= ${DEBUG}
# CFLAGS		+= ${OPTI}
# ------------------------------------------------------------------------------------------------ #
OPTI		= -O2 -pipe
DEBUG		= -glldb
# ------------------------------------------------------------------------------------------------ #
TARGET		= lowbat
# ========================================== ASSEMBLER =========================================== #
ASM			= nasm
ASMFLAGS	= -f
ASMARCH		= elf64_fbsd
# ============================================ UNIX ============================================== #
RM			= rm -f
MKDIR		= mkdir -p
CP			= cp
MV			= mv
SED			= sed
# ============================================ RULES ============================================= #

.SUFFIXES: .c .o

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

${TARGET}: ${C_OBJS}
	${CC} ${CFLAGS} -I${C_SRCS_DIR} -o ${.TARGET} ${.ALLSRC}

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

all: depend ${TARGET}

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

fclean: clean
	${RM} ${TARGET}

re: fclean all

.PHONY: all clean fclean re depend

-include "./.depend"