aoc-2019-c

Advent of Code 2019 Solutions in C
git clone https://git.sinitax.com/sinitax/aoc-2019-c
Log | Files | Refs | README | sfeed.txt

build.jst.tmpl (1351B)


      1#default PREFIX /usr/local
      2#default INCLDIR /include
      3#default LIBDIR /lib
      4#default CC gcc
      5
      6#ifdef LIBLIST_DEBUG
      7#define DEBUG 1
      8#endif
      9
     10#ifdef DEBUG
     11#define OPT_CFLAGS -Og -g
     12#else
     13#define OPT_CFLAGS -O2
     14#endif
     15
     16cflags = -Wunused-function -Wunused-variable -Wconversion
     17		-I include #{OPT_CFLAGS} #{EXTRA_CFLAGS} #{LIBLIST_EXTRA_CFLAGS}
     18
     19rule liba
     20	#{CC} -o $out.tmp.o $in $cflags -r
     21	objcopy --keep-global-symbols=liblist.api $out.tmp.o $out.fixed.o
     22	ar rcs $out $out.fixed.o
     23	rm $out.tmp.o $out.fixed.o
     24
     25rule libso
     26	#{CC} -o $out $in $cflags -shared -Wl,-version-script liblist.lds
     27
     28rule cc
     29	#{CC} -o $out $in $cflags
     30
     31rule mkdir
     32	mkdir $out
     33
     34target build
     35	mkdir
     36
     37target build/liblist.a
     38	liba src/list.c | include/list.h build
     39
     40target build/liblist.so
     41	libso src/list.c | include/list.h build
     42
     43target build/test
     44	cc src/test.c build/liblist.a | build
     45
     46command clean
     47	rm -rf build
     48
     49command cleanall
     50	just clean
     51
     52command install
     53	install -m755 build/liblist.a -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
     54	install -m755 build/liblist.so -t "#{DESTDIR}#{PREFIX}#{LIBDIR}"
     55	install -m644 include/list.h -t "#{DESTDIR}#{PREFIX}#{INCLDIR}"
     56
     57command uninstall
     58	rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/liblist.a"
     59	rm -f "#{DESTDIR}#{PREFIX}#{LIBDIR}/liblist.so"
     60	rm -f "#{DESTDIR}#{PREFIX}#{INCLDIR}/list.h"
     61
     62command all
     63	just build/liblist.a build/liblist.so build/test
     64