- added shared library build rules
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 25 Sep 2018 02:59:01 +0000 (05:59 +0300)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 25 Sep 2018 02:59:01 +0000 (05:59 +0300)
- removed stubbed add_file/remove_file functions fron assman.c. they don't seem necessary.

Makefile
examples/asscat/Makefile
examples/asscat/asscat.c
src/assman.c

index 9dfa452..ab2a248 100644 (file)
--- 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:
index 6a41b75..01bdce2 100644 (file)
@@ -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
index 799b6b0..72f1673 100644 (file)
@@ -52,7 +52,7 @@ int main(int argc, char **argv)
 
 void print_usage(const char *argv0)
 {
-       printf("Usage: %s [options] <file 1> <file 2> ... <file n>\n");
+       printf("Usage: %s [options] <file 1> <file 2> ... <file n>\n", argv0);
        printf("Options:\n");
        printf(" -prefix <prefix>   sets the path prefix to match for subsequent asset sources\n");
        printf(" -path <path>       filesystem asset source\n");
index 735cc16..1e692bc 100644 (file)
@@ -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 */
-}