# lib.rules: rules for building libraries # # The make variable $(TARGET) must be set before file inclusion # The inclusion adds a make target `lib' for creating the requested # library out of all files in the $(OBJS) list. # # # Library selection: The variable $A selects between # DOS/Windows libraries: A = lib # Unix static libraries: A = a # Unix shared libraries: A = so # # File name for a specific library TARGET_lib= $(LIB_PATH)/$(TARGET).lib TARGET_a = $(LIB_PATH)/lib$(TARGET).a TARGET_so = $(LIB_PATH)/lib$(TARGET).$(SHAREDLIB_SUFFIX) # The file name to be used here TARGETLIB = ${TARGET_$(A)} lib: ${lib.ctor} $(LIB_PATH) subdirs $(TARGETLIB) ${lib.dtor} $(LIB_PATH): -@mkdir -p $@ subdirs:: # # Rule how to create a static library # $(LIB_PATH)/lib$(TARGET).a: $(OBJS) -$(RM) $@ $(AR) rv $@ $(OBJS) -$(RANLIB) $@ # # Rule how to create a shared library (Linux, IRIX, ...) # File Extension .so # $(LIB_PATH)/lib$(TARGET).so: $(OBJS) -$(RM) $@ $(LINK_SHARED) $(OBJS) -o $@ $(RPATH) $(LIBS) # # Rule how to create a shared library (HPUX, ?) # File extension.sl # Please note that $(LIBS) isn't used here. # $(LIB_PATH)/lib$(TARGET).sl: $(OBJS) -$(RM) $@ $(LINK_SHARED) $(OBJS) -o $@ $(RPATH) $(LIBS) # # Rule how to create a MSDOS/Windows library # $(LIB_PATH)/$(TARGET).lib: $(OBJS) lib -OUT:$(TARGETFILE_PARAMETER) $(OBJS) # # Rule how to remove the built library from the object directory # libclean:: -$(RM) $(TARGETLIB) clean:: -$(RM) *.o so_locations $(MAKEDEPENDENCIES) -$(RM) -rf ii_files/ help:: help.lib help.lib: @ echo 'Make targets from lib.rules:' @ echo ' lib .............. compile library ${TARGETLIB}, specified by the current $$TARGET' @ echo ' the compiled library will be copied into $$LIB_PATH' @ echo ' libclean ......... delete library ${TARGETLIB} from the object directory' @ echo ' library directory' @ echo makevars:: makevars.lib makevars.lib: @ echo 'Make variables used in from lib.rules:' @ echo ' TARGET ........... the name of the library, to be used with -l$$TARGET at link time' @ echo ' A ................ the extension/type of the library, possible selections are:' @ echo ' DOS/Windows libraries: A = lib' @ echo ' Unix static libraries: A = a' @ echo ' Unix shared libraries: A = so' @ echo ' OBJS ............. the list of object files to put in the library' @ echo ' LIB_PATH ......... where to copy the library after creation' @ echo ' OBJ_PATH ......... where the compiled library resides' @ echo ' LINK_SHARED ...... command to create a shared Unix library' @ echo ' RPATH ............ optional rpath paramater for the shared Unix library' @ echo ' LIBS ............. other libraries to be linked with the shared Unix library' @ echo debug:: debug.lib debug.lib: @ echo 'Make variables used in lib.rules:' @ echo ' TARGET ........... $(TARGET)' @ echo ' A ................ $(A)' @ echo ' OBJS ............. $(OBJS)' @ echo ' LIB_PATH ......... $(LIB_PATH)' @ echo ' OBJ_PATH ......... $(OBJ_PATH)' @ echo ' LD ............... $(LD)' @ echo ' LDFLAGS .......... $(LDFLAGS)' @ echo ' LD_SHARED ........ $(LD_SHARED)' @ echo ' LINK_SHARED ...... $(LINK_SHARED)' @ echo ' RPATH ............ $(RPATH)' @ echo ' LIBS ............. $(LIBS)' @ echo