liblist-c

C type-agnostic linked-list library
git clone https://git.sinitax.com/sinitax/liblist-c
Log | Files | Refs | LICENSE | sfeed.txt

Makefile (1258B)


      1PREFIX ?= /usr/local
      2LIBDIR ?= /lib
      3INCLDIR ?= /include
      4
      5CFLAGS = -I include -std=c99
      6CFLAGS += -Wunused-function -Wunused-variable -Wno-prototype
      7CFLAGS += -Wconversion -Wsign-compare -Werror
      8
      9ifeq "$(DEBUG)" "1"
     10CFLAGS += -Og -g
     11else
     12CFLAGS += -O2
     13endif
     14
     15ifeq "$(ASSERT_ARGS)" "1"
     16CFLAGS += -DLIBLIST_ASSERT_ARGS=1
     17endif
     18
     19all: build/liblist.so build/liblist.a build/test
     20
     21clean:
     22	rm -rf build
     23
     24cleanall: clean
     25
     26build:
     27	mkdir build
     28
     29build/liblist.a: src/list.c include/list.h liblist.api | build
     30	$(CC) -o build/tmp.o src/list.c $(CFLAGS) -r
     31	objcopy --keep-global-symbols=liblist.api build/tmp.o build/fixed.o
     32	ar rcs $@ build/fixed.o
     33
     34build/liblist.so: src/list.c include/list.h liblist.lds | build
     35	$(CC) -o $@ src/list.c $(CFLAGS) -shared -Wl,-version-script liblist.lds
     36
     37build/test: src/test.c build/liblist.a | build
     38	$(CC) -o $@ $^ -I include
     39
     40install:
     41	install -m644 include/list.h -t "$(DESTDIR)$(PREFIX)$(INCLDIR)"
     42	install -m755 build/liblist.a -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     43	install -m755 build/liblist.so -t "$(DESTDIR)$(PREFIX)$(LIBDIR)"
     44
     45uninstall:
     46	rm -f "$(DESTDIR)$(PREFIX)$(INCLDIR)/list.h"
     47	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liblist.a"
     48	rm -f "$(DESTDIR)$(PREFIX)$(LIBDIR)/liblist.so"
     49
     50.PHONY: all clean cleanall install uninstall