loaders: PNM: Fix save_ascii_rgb888
[gfxprim/pasky.git] / lib.mk
blobb8e4a20552ba567c304e831f61270803500af092
2 # Most of the libraries just generate object files that
3 # are later linked in build into the libGP.so
5 ifndef LIBNAME
6 $(error LIBNAME not defined, fix your library Makefile)
7 endif
9 ifeq ($(BUILDLIB),yes)
11 # Rules for single library, applied only when objects
12 # are not linked to the libGP.so. This generates libGP_$(LIBNAME).
15 include $(TOPDIR)/libver.mk
17 LIB_NAME=libGP_$(LIBNAME)
18 BUILD_DIR=$(TOPDIR)/build/
20 STATIC_LIB=$(LIB_NAME).$(LIB_VERSION).a
21 DYNAMIC_LIB=$(LIB_NAME).so.$(LIB_VERSION).$(LIB_RELEASE)
22 SONAME=$(LIB_NAME).so.$(LIB_MAJOR)
23 SYMLINKS=$(LIB_NAME).so.$(LIB_MAJOR) $(LIB_NAME).so
25 LIBS=$(BUILD_DIR)$(STATIC_LIB) $(BUILD_DIR)$(DYNAMIC_LIB)
27 ALL+=$(LIBS) $(SYMLINKS)
28 CLEAN+=$(LIBS) $(addprefix $(BUILD_DIR),$(SYMLINKS))
31 # OBJECTS are set in post.mk so we need to duplicate the values in
32 # OBJS here too to have correct dependencies
34 OBJS=$(CSOURCES:.c=.o)
36 $(BUILD_DIR)$(DYNAMIC_LIB): $(OBJS)
37 ifdef VERBOSE
38 rm -f $@
39 $(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
40 else
41 @rm -f $(@)
42 @echo "LD $@"
43 @$(CC) -fPIC --shared -Wl,-soname -Wl,$(SONAME) $^ -o $@
44 endif
46 $(BUILD_DIR)$(STATIC_LIB): $(OBJS)
47 ifdef VERBOSE
48 $(AR) rcs $@ $^
49 else
50 @echo "AR $@"
51 @$(AR) rcs $@ $^
52 endif
54 $(SYMLINKS): $(BUILD_DIR)$(DYNAMIC_LIB)
55 ifdef VERBOSE
56 rm -f $(BUILD_DIR)$@
57 cd $(BUILD_DIR) && ln -s $(DYNAMIC_LIB) $@
58 else
59 @echo "LN $@"
60 @rm -f $(BUILD_DIR)$@
61 @cd $(BUILD_DIR) && ln -s $(DYNAMIC_LIB) $@
62 endif
64 else
66 # If we are not executed from the top Makefile, trigger
67 # libGP.so rebuild.
69 include $(TOPDIR)/config.mk
71 ifndef TOP_MAKE
72 ALL+=rebuild_lib
74 rebuild_lib:
75 @$(MAKE) --no-print-directory -C $(TOPDIR)/build/
76 endif
77 endif