aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: b2492abbab2d56323a518a1d9b9e0c1eafa0a456 (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
# See LICENSE file for copyright and license details.

include config.mk

CC   = cc

# Used for debugging and not as usual
OBJ  = ${SRC:.c=.o}

OPTIM   = -O2 -pipe
STD     = -ansi --std=c89 -pedantic
WARNS   = -Werror -Wall

LDFLAGS =
CFLAGS  = ${WARNS} ${STD} -DLIBVER=\"${LIBVER}\" ${OPTIM}

# CFLAGS for debugging
CDFLAGS = ${WARNS} ${STD} -DLIBVER=\"${LIBVER}\" -g

all: ${LIBNAME:=.a} ${LIBNAME:=.so}
	@echo ${STD}.

debug: ${OBJ}

.c.o:
	${CC} ${CDFLAGS} -c $< -o $@

# Make shared and archive directories
${ARDIR} ${SHDIR}:
	mkdir -p $@

# Make archive file
${LIBNAME:=.a}: ${ARDIR} ${AROBJ}
	ar rcs $@ ${AROBJ}

# Make shared file
${LIBNAME:=.so}: ${SHDIR} ${SHOBJ}
	${CC} ${LDFLAGS} -shared ${SHOBJ} -o $@

clean:
	rm -rf bin ${LIBNAME}.* *.core ${OBJ}
	cd test && make clean

tests: all
	cd test && make clean tests

${INSTALL_LIB_DIR}:
	mkdir -p $@

${INSTALL_INC_DIR}:
	mkdir -p $@

install: all ${INSTALL_LIB_DIR} ${INSTALL_INC_DIR}
	cp ${LIBNAME:=.a}  ${INSTALL_LIB_DIR}/${LIBNAME:=.a}
	cp ${LIBNAME:=.so} ${INSTALL_LIB_DIR}/${LIBNAME:=.so}
	cp src/string2.h   ${INSTALL_INC_DIR}/string2.h

# Generated by makemk script
include target.mk