2021-12-16 21:36:32 +00:00
|
|
|
prefix ?= /usr/local
|
2020-06-13 23:18:57 +00:00
|
|
|
HFILES = toml.h
|
2017-03-18 21:20:51 +00:00
|
|
|
CFILES = toml.c
|
2021-01-10 01:19:09 +00:00
|
|
|
OBJ = $(CFILES:.c=.o)
|
2020-11-02 02:31:50 +00:00
|
|
|
EXEC = toml_json toml_cat toml_sample
|
2021-12-11 01:01:52 +00:00
|
|
|
PCFILE = libtoml.pc
|
2017-03-18 21:20:51 +00:00
|
|
|
|
2019-05-02 13:33:15 +00:00
|
|
|
CFLAGS = -std=c99 -Wall -Wextra -fpic
|
2021-02-16 11:45:18 +00:00
|
|
|
LIB_VERSION = 1.0
|
2020-06-13 23:18:57 +00:00
|
|
|
LIB = libtoml.a
|
2021-02-16 11:45:18 +00:00
|
|
|
LIB_SHARED = libtoml.so.$(LIB_VERSION)
|
2020-06-13 23:18:57 +00:00
|
|
|
|
2019-02-19 23:52:01 +00:00
|
|
|
# to compile for debug: make DEBUG=1
|
|
|
|
# to compile for no debug: make
|
|
|
|
ifdef DEBUG
|
|
|
|
CFLAGS += -O0 -g
|
|
|
|
else
|
|
|
|
CFLAGS += -O2 -DNDEBUG
|
|
|
|
endif
|
2017-03-18 21:20:51 +00:00
|
|
|
|
|
|
|
|
2019-05-02 13:33:15 +00:00
|
|
|
all: $(LIB) $(LIB_SHARED) $(EXEC)
|
2017-03-18 21:20:51 +00:00
|
|
|
|
2020-06-13 23:18:57 +00:00
|
|
|
*.o: $(HFILES)
|
2017-03-18 21:20:51 +00:00
|
|
|
|
|
|
|
libtoml.a: toml.o
|
|
|
|
ar -rcs $@ $^
|
|
|
|
|
2021-02-16 11:45:18 +00:00
|
|
|
libtoml.so.$(LIB_VERSION): toml.o
|
2019-05-02 13:33:15 +00:00
|
|
|
$(CC) -shared -o $@ $^
|
|
|
|
|
2022-01-05 06:02:11 +00:00
|
|
|
$(EXEC): $(LIB)
|
2017-03-18 21:20:51 +00:00
|
|
|
|
|
|
|
install: all
|
|
|
|
install -d ${prefix}/include ${prefix}/lib
|
|
|
|
install toml.h ${prefix}/include
|
2019-05-02 13:33:15 +00:00
|
|
|
install $(LIB) ${prefix}/lib
|
|
|
|
install $(LIB_SHARED) ${prefix}/lib
|
2021-12-16 21:36:32 +00:00
|
|
|
ifeq "$(prefix)" "/usr/local"
|
|
|
|
install $(PCFILE) /usr/local/lib/pkgconfig
|
|
|
|
endif
|
2017-03-18 21:20:51 +00:00
|
|
|
|
|
|
|
clean:
|
2019-05-02 13:33:15 +00:00
|
|
|
rm -f *.o $(EXEC) $(LIB) $(LIB_SHARED)
|
2021-01-10 01:19:09 +00:00
|
|
|
|
|
|
|
|
2022-01-05 06:02:11 +00:00
|
|
|
format:
|
|
|
|
clang-format -i $(shell find . -name '*.[ch]')
|
|
|
|
|
|
|
|
.PHONY: all clean install format
|