commit 89fa814

uint  ·  2026-10-24 18:59:28 +0000 UTC
parent f2f3bd5
Improve Makefile
2 files changed,  +22, -7
+21, -6
 1@@ -1,15 +1,30 @@
 2 CC = cc
 3+AR = ar
 4 CFLAGS = -ansi -pedantic -Wall -Wextra
 5+
 6 SRC = expl.c
 7-OUT = expl
 8+HDR = expl.h
 9+OUT = expl.o
10+LIB = libexpl.a
11+TEST_SRC = test.c
12+TEST_OUT = expl
13 
14-all: ${SRC}
15-	${CC} ${CFLAGS} -o ${OUT} ${SRC}
16+all: ${LIB}
17 
18-compile_flags:
19-	rm -f compile_flags.txt
20-	for f in ${CFLAGS}; do echo $$f >> compile_flags.txt; do
21+${OUT}: ${SRC} ${HDR}
22+	${CC} ${CFLAGS} -c ${SRC} -o ${OUT}
23+
24+${LIB}: ${OUT}
25+	${AR} rcs ${LIB} ${OUT}
26+
27+test: ${TEST_OUT}
28+	./${TEST_OUT}
29+
30+${TEST_OUT}: ${TEST_SRC} ${LIB}
31+	${CC} ${CFLAGS} -o ${TEST_OUT} ${TEST_SRC} ${LIB}
32 
33+clean:
34+	rm -f ${OUT} ${LIB} ${TEST_OUT}
35 
36 compile_flags:
37 	printf '%s\n' ${CFLAGS} > compile_flags.txt
+1, -1
1@@ -7,7 +7,7 @@ larger configuration languages.
2 For maximum compatibility, it's written in ANSI C.
3 
4 #### Usage
5-An extract from `expl.c`:
6+An extract from `test.c`:
7 
8 ``` c
9 static expl_value