-print "void ERR_load_${type}_strings()\n";
-print "\t{\n";
-print "\tstatic int init=1;\n\n";
-print "\tif (init)\n";
-print "\t\t{\n";
-print "\t\tinit=0;\n";
-print "\t\tERR_load_strings(ERR_LIB_$type,${type}_str_functs);\n"
- if $Func;
-print "\t\tERR_load_strings(ERR_LIB_$type,${type}_str_reasons);\n"
- if $Reas;
-print "\t\t}\n";
-print "\t}\n";
+$str="";
+$str.="#ifndef NO_ERR\n";
+$str.="\t\tERR_load_strings($lib,${type}_str_functs);\n" if $Func;
+$str.="\t\tERR_load_strings($lib,${type}_str_reasons);\n" if $Reas;
+$str.="#endif\n";
+
+if (!$static)
+ {
+print <<"EOF";
+
+int ${type}_lib_error_code=0;
+
+void ERR_load_${type}_strings()
+ {
+ static int init=1;
+
+ if (${type}_lib_error_code == 0)
+ ${type}_lib_error_code=ERR_get_next_error_library();
+
+ if (init)
+ {
+ init=0;
+$str
+#ifdef ${type}_LIB_NAME
+ ${type}_lib_name->error = ERR_PACK(${type}_lib_error_code,0,0);
+ ERR_load_strings(0,${type}_lib_name);
+#endif;
+ }
+ }
+
+void ERR_${type}_error(function,reason,file,line)
+int function;
+int reason;
+char *file;
+int line;
+ {
+ if (${type}_lib_error_code == 0)
+ ${type}_lib_error_code=ERR_get_next_error_library();
+ ERR_PUT_error(${type}_lib_error_code,function,reason,file,line);
+ }
+EOF
+ }
+else # $static
+ {
+ print <<"EOF";
+
+void ERR_load_${type}_strings()
+ {
+ static int init=1;
+
+ if (init)
+ {
+ init=0;
+$str
+ }
+ }
+EOF
+ }