From: John Tsiombikas Date: Tue, 25 Sep 2018 02:59:01 +0000 (+0300) Subject: - added shared library build rules X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=assman;a=commitdiff_plain;h=326501355589766ea6f9097824b1850d0beae414 - added shared library build rules - removed stubbed add_file/remove_file functions fron assman.c. they don't seem necessary. --- diff --git a/Makefile b/Makefile index 9dfa452..ab2a248 100644 --- a/Makefile +++ b/Makefile @@ -3,25 +3,44 @@ obj = $(src:.c=.o) dep = $(obj:.o=.d) name = assman +so_major = 0 +so_minor = 1 + lib_a = lib$(name).a +lib_so = lib$(name).so.$(so_major).$(so_minor) +soname = lib$(name).so.$(so_major) +devlink = lib$(name).so +shared = -shared -Wl,-soname,$(soname) warn = -pedantic -Wall dbg = -g opt = -O0 CFLAGS = $(warn) $(dbg) $(opt) $(inc) -LDFLAGS = +LDFLAGS = -lcurl + +.PHONY: all +all: $(lib_so) $(lib_a) $(soname) $(devlink) + +$(lib_so): $(obj) + $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) $(lib_a): $(obj) $(AR) rcs $@ $(obj) +$(soname): $(lib_so) + rm -f $@ && ln -s $< $@ + +$(devlink): $(soname) + rm -f $@ && ln -s $< $@ + %.d: %.c @echo "generating depfile $< -> $@" @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ .PHONY: clean clean: - rm -f $(obj) $(bin) + rm -f $(obj) $(lib_a) $(lib_so) $(soname) $(devlink) .PHONY: cleandep cleandep: diff --git a/examples/asscat/Makefile b/examples/asscat/Makefile index 6a41b75..01bdce2 100644 --- a/examples/asscat/Makefile +++ b/examples/asscat/Makefile @@ -1,11 +1,12 @@ obj = asscat.o bin = asscat root = ../.. +lib_so = $(root)/libassman.so.0.1 CFLAGS = -pedantic -Wall -g -I$(root)/src -LDFLAGS = -L$(root) -Wl,-rpath=$(root) -lassman +LDFLAGS = -L$(root) -Wl,-rpath,$(root) -lassman -$(bin): $(obj) +$(bin): $(obj) $(lib_so) $(CC) -o $@ $(obj) $(LDFLAGS) .PHONY: clean diff --git a/examples/asscat/asscat.c b/examples/asscat/asscat.c index 799b6b0..72f1673 100644 --- a/examples/asscat/asscat.c +++ b/examples/asscat/asscat.c @@ -52,7 +52,7 @@ int main(int argc, char **argv) void print_usage(const char *argv0) { - printf("Usage: %s [options] ... \n"); + printf("Usage: %s [options] ... \n", argv0); printf("Options:\n"); printf(" -prefix sets the path prefix to match for subsequent asset sources\n"); printf(" -path filesystem asset source\n"); diff --git a/src/assman.c b/src/assman.c index 735cc16..1e692bc 100644 --- a/src/assman.c +++ b/src/assman.c @@ -6,8 +6,6 @@ static int add_fop(const char *prefix, int type, struct ass_fileops *fop); static const char *match_prefix(const char *str, const char *prefix); -static int add_file(ass_file *file); -static int remove_file(ass_file *file); #define DEF_FLAGS (1 << ASS_OPEN_FALLTHROUGH) @@ -122,12 +120,6 @@ ass_file *ass_fopen(const char *fname, const char *mode) } file->file = mfile; file->fop = m->fop; - - if(add_file(file) == -1) { - m->fop->close(mfile, m->fop->udata); - free(file); - return 0; - } return file; } else { if(!(assflags & (1 << ASS_OPEN_FALLTHROUGH))) { @@ -148,12 +140,6 @@ ass_file *ass_fopen(const char *fname, const char *mode) } file->file = fp; file->fop = 0; - - if(add_file(file) == -1) { - fclose(fp); - free(file); - return 0; - } return file; } ass_errno = errno; @@ -179,7 +165,6 @@ void ass_fclose(ass_file *fp) } else { fclose(fp->file); } - remove_file(fp); free(fp); } @@ -242,14 +227,3 @@ char *ass_fgets(char *s, int size, ass_file *fp) *ptr = 0; return ptr == s ? 0 : s; } - - -static int add_file(ass_file *file) -{ - return -1; /* TODO */ -} - -static int remove_file(ass_file *file) -{ - return -1; /* TODO */ -}