CFLAGS=-Wall -g %.c
        $(CC) -fPIC $(CFLAGS) -c -o $@ $<

all: timetest $(LIBFAKETIME)

timetest: timetest.o
        $(CC) $(CFLAGS) -o $@ $<

ld-so.h: dummy.c
        $(CC) -o tmp-dummy dummy.c
        objcopy --only-section .interp --output-target binary tmp-dummy tmp-dummy.interp
        awk 'BEGIN{printf("#ifdef LD_SO\n#undef LD_SO\n#endif\n\n");} NR==1{gsub (/\000/, "", $$1); printf("#define LD_SO \"%s\"\n", $$1);}' tmp-dummy.interp > ld-so.h
        rm -f tmp-dummy*

        $(CC) -shared -o $@ -Wl,-soname,$(LIBFAKETIME) $< -ldl -e __faketime_main faketime.c ld-so.h

test: all
        @echo ==== Without preloaded library...
        @echo ==== Set the date to yesterday...
        FAKE_TIME_OFFSET=-86400 LD_PRELOAD=./ ./timetest
        @echo ==== Set the date to 2000/01/01 12:13:14...
        FAKE_TIME_START=946725194 LD_PRELOAD=./ ./timetest

        -rm -f *.o *.so core timetest $(LIBFAKETIME) ld-so.h tmp-dummy*