Merge ^/head r304700 through r304884.
This commit is contained in:
commit
491cdc1b53
6
UPDATING
6
UPDATING
@ -31,6 +31,12 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 12.x IS SLOW:
|
||||
disable the most expensive debugging functionality run
|
||||
"ln -s 'abort:false,junk:false' /etc/malloc.conf".)
|
||||
|
||||
20160824:
|
||||
r304787 changed some ioctl interfaces between the iSCSI userspace
|
||||
programs and the kernel. ctladm, ctld, iscsictl, and iscsid must be
|
||||
rebuilt to work with new kernels. __FreeBSD_version has been bumped
|
||||
to 1200005.
|
||||
|
||||
20160818:
|
||||
The UDP receive code has been updated to only treat incoming UDP
|
||||
packets that were addressed to an L2 broadcast address as L3
|
||||
|
@ -32,7 +32,7 @@
|
||||
.\" @(#)dd.1 8.2 (Berkeley) 1/13/94
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd February 28, 2016
|
||||
.Dd August 25, 2016
|
||||
.Dt DD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -414,7 +414,7 @@ Check for (even) parity errors on a file:
|
||||
To create an image of a Mode-1 CD-ROM, which is a commonly used format
|
||||
for data CD-ROM disks, use a block size of 2048 bytes:
|
||||
.Pp
|
||||
.Dl "dd if=/dev/acd0 of=filename.iso bs=2048"
|
||||
.Dl "dd if=/dev/cd0 of=filename.iso bs=2048"
|
||||
.Pp
|
||||
Write a filesystem image to a memory stick, padding the end with zeros,
|
||||
if necessary, to a 1MiB boundary:
|
||||
|
@ -84,6 +84,14 @@ create_test_inputs2()
|
||||
{
|
||||
create_test_dir
|
||||
|
||||
if ! getconf MIN_HOLE_SIZE "$(pwd)"; then
|
||||
echo "getconf MIN_HOLE_SIZE $(pwd) failed; sparse files probably" \
|
||||
"not supported by file system"
|
||||
mount
|
||||
atf_skip "Test's work directory does not support sparse files;" \
|
||||
"try with a different TMPDIR?"
|
||||
fi
|
||||
|
||||
for filesize in 1 512 $(( 2 * $KB )) $(( 10 * $KB )) $(( 512 * $KB )); \
|
||||
do
|
||||
atf_check -e ignore -o empty -s exit:0 \
|
||||
|
@ -59,7 +59,7 @@ translator psinfo_t < struct proc *T > {
|
||||
pr_gid = T->p_ucred->cr_rgid;
|
||||
pr_egid = T->p_ucred->cr_groups[0];
|
||||
pr_addr = 0;
|
||||
pr_psargs = (T->p_args->ar_args == 0) ? "" :
|
||||
pr_psargs = (T->p_args == 0) ? "" :
|
||||
memstr(T->p_args->ar_args, ' ', T->p_args->ar_length);
|
||||
pr_arglen = T->p_args->ar_length;
|
||||
pr_jailid = T->p_ucred->cr_prison->pr_id;
|
||||
|
@ -875,11 +875,11 @@ case "${targ}" in
|
||||
;;
|
||||
mips*el-*-freebsd*)
|
||||
targ_defvec=bfd_elf32_tradlittlemips_vec
|
||||
targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf32_ntradbigmisp_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
|
||||
targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
|
||||
;;
|
||||
mips*-*-freebsd*)
|
||||
targ_defvec=bfd_elf32_tradbigmips_vec
|
||||
targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmisp_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
|
||||
targ_selvecs="bfd_elf32_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_ntradlittlemips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_big_vec ecoff_little_vec"
|
||||
;;
|
||||
mips*-dec-* | mips*el-*-ecoff*)
|
||||
targ_defvec=ecoff_little_vec
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -426,6 +426,7 @@ __LA_DECL void archive_entry_copy_mac_metadata(struct archive_entry *, const voi
|
||||
#define ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY 0x10000000
|
||||
#define ARCHIVE_ENTRY_ACL_ENTRY_SUCCESSFUL_ACCESS 0x20000000
|
||||
#define ARCHIVE_ENTRY_ACL_ENTRY_FAILED_ACCESS 0x40000000
|
||||
#define ARCHIVE_ENTRY_ACL_ENTRY_INHERITED 0x80000000
|
||||
|
||||
#define ARCHIVE_ENTRY_ACL_INHERITANCE_NFS4 \
|
||||
(ARCHIVE_ENTRY_ACL_ENTRY_FILE_INHERIT \
|
||||
@ -501,8 +502,8 @@ __LA_DECL int archive_entry_acl_next_w(struct archive_entry *, int /* want_type
|
||||
* ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT - Include "default:" before each
|
||||
* default ACL entry, as used in old Solaris ACLs.
|
||||
*/
|
||||
#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 1024
|
||||
#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 2048
|
||||
#define ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID 16384
|
||||
#define ARCHIVE_ENTRY_ACL_STYLE_MARK_DEFAULT 32768
|
||||
__LA_DECL const wchar_t *archive_entry_acl_text_w(struct archive_entry *,
|
||||
int /* flags */);
|
||||
__LA_DECL const char *archive_entry_acl_text(struct archive_entry *,
|
||||
|
@ -411,75 +411,116 @@ setup_acls(struct archive_read_disk *a,
|
||||
{
|
||||
const char *accpath;
|
||||
acl_t acl;
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
int r;
|
||||
#endif
|
||||
|
||||
accpath = archive_entry_sourcepath(entry);
|
||||
if (accpath == NULL)
|
||||
accpath = archive_entry_pathname(entry);
|
||||
|
||||
if (*fd < 0 && a->tree != NULL) {
|
||||
if (a->follow_symlinks ||
|
||||
archive_entry_filetype(entry) != AE_IFLNK)
|
||||
*fd = a->open_on_current_dir(a->tree,
|
||||
accpath, O_RDONLY | O_NONBLOCK);
|
||||
if (*fd < 0) {
|
||||
if (a->tree_enter_working_dir(a->tree) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Couldn't access %s", accpath);
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
archive_entry_acl_clear(entry);
|
||||
|
||||
acl = NULL;
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
/* Try NFS4 ACL first. */
|
||||
#if HAVE_ACL_GET_FD_NP
|
||||
if (*fd >= 0)
|
||||
acl = acl_get_fd(*fd);
|
||||
acl = acl_get_fd_np(*fd, ACL_TYPE_NFS4);
|
||||
#endif
|
||||
if (acl == NULL) {
|
||||
#if HAVE_ACL_GET_LINK_NP
|
||||
else if (!a->follow_symlinks)
|
||||
acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
|
||||
if (!a->follow_symlinks)
|
||||
acl = acl_get_link_np(accpath, ACL_TYPE_NFS4);
|
||||
#else
|
||||
else if ((!a->follow_symlinks)
|
||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
||||
/* We can't get the ACL of a symlink, so we assume it can't
|
||||
have one. */
|
||||
acl = NULL;
|
||||
if ((!a->follow_symlinks)
|
||||
&& (archive_entry_filetype(entry) == AE_IFLNK)) }
|
||||
/* We can't get the ACL of a symlink, so we assume
|
||||
it can't have one. */
|
||||
acl = NULL;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
acl = acl_get_file(accpath, ACL_TYPE_NFS4);
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
acl_is_trivial_np(acl, &r);
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
}
|
||||
#endif
|
||||
if (acl == NULL)
|
||||
acl = acl_get_file(accpath, ACL_TYPE_NFS4);
|
||||
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
if (acl_is_trivial_np(acl, &r) == 0) {
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
r = translate_acl(a, entry, acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
acl_free(acl);
|
||||
return (ARCHIVE_OK);
|
||||
return (r);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Retrieve access ACL from file. */
|
||||
if (*fd >= 0)
|
||||
acl = acl_get_fd(*fd);
|
||||
if (acl == NULL) {
|
||||
#if HAVE_ACL_GET_LINK_NP
|
||||
else if (!a->follow_symlinks)
|
||||
acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
|
||||
if (!a->follow_symlinks)
|
||||
acl = acl_get_link_np(accpath, ACL_TYPE_ACCESS);
|
||||
#else
|
||||
else if ((!a->follow_symlinks)
|
||||
&& (archive_entry_filetype(entry) == AE_IFLNK))
|
||||
/* We can't get the ACL of a symlink, so we assume it can't
|
||||
have one. */
|
||||
acl = NULL;
|
||||
if ((!a->follow_symlinks)
|
||||
&& (archive_entry_filetype(entry) == AE_IFLNK)) {
|
||||
/* We can't get the ACL of a symlink, so we assume it
|
||||
can't have one. */
|
||||
acl = NULL;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
}
|
||||
if (acl == NULL)
|
||||
acl = acl_get_file(accpath, ACL_TYPE_ACCESS);
|
||||
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl,
|
||||
#if HAVE_ACL_IS_TRIVIAL_NP
|
||||
/* Ignore "trivial" ACLs that just mirror the file mode. */
|
||||
if (acl_is_trivial_np(acl, &r) == 0) {
|
||||
if (r) {
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
r = translate_acl(a, entry, acl,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
||||
acl_free(acl);
|
||||
acl = NULL;
|
||||
if (r != 0)
|
||||
return (r);
|
||||
}
|
||||
|
||||
/* Only directories can have default ACLs. */
|
||||
if (S_ISDIR(archive_entry_mode(entry))) {
|
||||
acl = acl_get_file(accpath, ACL_TYPE_DEFAULT);
|
||||
if (acl != NULL) {
|
||||
translate_acl(a, entry, acl,
|
||||
r = translate_acl(a, entry, acl,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
||||
acl_free(acl);
|
||||
if (r != 0)
|
||||
return (r);
|
||||
}
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
@ -535,19 +576,23 @@ translate_acl(struct archive_read_disk *a,
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_entry_type_t acl_type;
|
||||
acl_flagset_t acl_flagset;
|
||||
int brand, r;
|
||||
int brand;
|
||||
#endif
|
||||
acl_entry_t acl_entry;
|
||||
acl_permset_t acl_permset;
|
||||
int i, entry_acl_type;
|
||||
int s, ae_id, ae_tag, ae_perm;
|
||||
int r, s, ae_id, ae_tag, ae_perm;
|
||||
const char *ae_name;
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
|
||||
// Make sure the "brand" on this ACL is consistent
|
||||
// with the default_entry_acl_type bits provided.
|
||||
acl_get_brand_np(acl, &brand);
|
||||
if (acl_get_brand_np(acl, &brand) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to read ACL brand");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
switch (brand) {
|
||||
case ACL_BRAND_POSIX:
|
||||
switch (default_entry_acl_type) {
|
||||
@ -555,31 +600,43 @@ translate_acl(struct archive_read_disk *a,
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
||||
break;
|
||||
default:
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Invalid ACL entry type for POSIX.1e ACL");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
break;
|
||||
case ACL_BRAND_NFS4:
|
||||
if (default_entry_acl_type & ~ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"ACL brand mismatch");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// XXX set warning message?
|
||||
return ARCHIVE_FAILED;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Invalid ACL brand");
|
||||
return (ARCHIVE_FAILED);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
|
||||
if (s == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
while (s == 1) {
|
||||
ae_id = -1;
|
||||
ae_name = NULL;
|
||||
ae_perm = 0;
|
||||
|
||||
acl_get_tag_type(acl_entry, &acl_tag);
|
||||
if (acl_get_tag_type(acl_entry, &acl_tag) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL tag type");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
switch (acl_tag) {
|
||||
case ACL_USER:
|
||||
ae_id = (int)*(uid_t *)acl_get_qualifier(acl_entry);
|
||||
@ -619,8 +676,12 @@ translate_acl(struct archive_read_disk *a,
|
||||
// non-NFSv4 ACLs
|
||||
entry_acl_type = default_entry_acl_type;
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
r = acl_get_entry_type_np(acl_entry, &acl_type);
|
||||
if (r == 0) {
|
||||
if (default_entry_acl_type == ARCHIVE_ENTRY_ACL_TYPE_NFS4) {
|
||||
if (acl_get_entry_type_np(acl_entry, &acl_type) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL type from an NFSv4 ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
switch (acl_type) {
|
||||
case ACL_ENTRY_TYPE_ALLOW:
|
||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALLOW;
|
||||
@ -634,40 +695,64 @@ translate_acl(struct archive_read_disk *a,
|
||||
case ACL_ENTRY_TYPE_ALARM:
|
||||
entry_acl_type = ARCHIVE_ENTRY_ACL_TYPE_ALARM;
|
||||
break;
|
||||
default:
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Unknown NFSv4 ACL entry type: %d", acl_type);
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
||||
* in the ae_perm bitmap.
|
||||
*/
|
||||
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
|
||||
// non-NFSv4 ACLs
|
||||
r = acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
if (r == 0) {
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (acl_get_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit))
|
||||
/*
|
||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
||||
* in the ae_perm bitmap.
|
||||
*/
|
||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get flagset from an NFSv4 ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
r = acl_get_flag_np(acl_flagset, acl_inherit_map[i].platform_inherit);
|
||||
if (r == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to check flag in a NFSv4 ACL flagset");
|
||||
return (ARCHIVE_FAILED);
|
||||
} else if (r)
|
||||
ae_perm |= acl_inherit_map[i].archive_inherit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
acl_get_permset(acl_entry, &acl_permset);
|
||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL permission set");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
|
||||
/*
|
||||
* acl_get_perm() is spelled differently on different
|
||||
* platforms; see above.
|
||||
*/
|
||||
if (ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm))
|
||||
r = ACL_GET_PERM(acl_permset, acl_perm_map[i].platform_perm);
|
||||
if (r == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to check permission in an ACL permission set");
|
||||
return (ARCHIVE_FAILED);
|
||||
} else if (r)
|
||||
ae_perm |= acl_perm_map[i].archive_perm;
|
||||
}
|
||||
|
||||
archive_entry_acl_add_entry(entry, entry_acl_type,
|
||||
r = archive_entry_acl_add_entry(entry, entry_acl_type,
|
||||
ae_perm, ae_tag,
|
||||
ae_id, ae_name);
|
||||
if (r != 0)
|
||||
return (r);
|
||||
|
||||
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
|
||||
if (s == -1) {
|
||||
archive_set_error(&a->archive, errno,
|
||||
"Failed to get ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
@ -203,6 +203,10 @@ static int archive_read_format_tar_read_header(struct archive_read *,
|
||||
static int checksum(struct archive_read *, const void *);
|
||||
static int pax_attribute(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const char *key, const char *value);
|
||||
static int pax_attribute_acl(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, const char *, int);
|
||||
static int pax_attribute_xattr(struct archive_entry *, const char *,
|
||||
const char *);
|
||||
static int pax_header(struct archive_read *, struct tar *,
|
||||
struct archive_entry *, char *attr);
|
||||
static void pax_time(const char *, int64_t *sec, long *nanos);
|
||||
@ -1128,8 +1132,15 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
if (tar->entry_bytes_remaining < 0) {
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry has negative size?");
|
||||
err = ARCHIVE_WARN;
|
||||
"Tar entry has negative size");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (tar->entry_bytes_remaining == INT64_MAX) {
|
||||
/* Note: tar_atol returns INT64_MAX on overflow */
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry size overflow");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
tar->realsize = tar->entry_bytes_remaining;
|
||||
archive_entry_set_size(entry, tar->entry_bytes_remaining);
|
||||
@ -1695,6 +1706,52 @@ pax_attribute_xattr(struct archive_entry *entry,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
pax_attribute_acl(struct archive_read *a, struct tar *tar,
|
||||
struct archive_entry *entry, const char *value, int type)
|
||||
{
|
||||
int r;
|
||||
const char* errstr;
|
||||
|
||||
switch (type) {
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
||||
errstr = "SCHILY.acl.access";
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
||||
errstr = "SCHILY.acl.default";
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_NFS4:
|
||||
errstr = "SCHILY.acl.ace";
|
||||
break;
|
||||
default:
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL type: %d", type);
|
||||
return(ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
if (tar->sconv_acl == NULL) {
|
||||
tar->sconv_acl =
|
||||
archive_string_conversion_from_charset(
|
||||
&(a->archive), "UTF-8", 1);
|
||||
if (tar->sconv_acl == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
r = archive_acl_parse_l(archive_entry_acl(entry), value, type,
|
||||
tar->sconv_acl);
|
||||
if (r != ARCHIVE_OK) {
|
||||
if (r == ARCHIVE_FATAL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"%s %s", "Can't allocate memory for ",
|
||||
errstr);
|
||||
return (r);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC, "%s %s", "Parse error: ", errstr);
|
||||
}
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse a single key=value attribute. key/value pointers are
|
||||
* assumed to point into reasonably long-lived storage.
|
||||
@ -1805,53 +1862,20 @@ pax_attribute(struct archive_read *a, struct tar *tar,
|
||||
case 'S':
|
||||
/* We support some keys used by the "star" archiver */
|
||||
if (strcmp(key, "SCHILY.acl.access") == 0) {
|
||||
if (tar->sconv_acl == NULL) {
|
||||
tar->sconv_acl =
|
||||
archive_string_conversion_from_charset(
|
||||
&(a->archive), "UTF-8", 1);
|
||||
if (tar->sconv_acl == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
r = archive_acl_parse_l(archive_entry_acl(entry),
|
||||
value, ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
|
||||
tar->sconv_acl);
|
||||
if (r != ARCHIVE_OK) {
|
||||
err = r;
|
||||
if (err == ARCHIVE_FATAL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate memory for "
|
||||
"SCHILY.acl.access");
|
||||
return (err);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Parse error: SCHILY.acl.access");
|
||||
}
|
||||
r = pax_attribute_acl(a, tar, entry, value,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
return (r);
|
||||
} else if (strcmp(key, "SCHILY.acl.default") == 0) {
|
||||
if (tar->sconv_acl == NULL) {
|
||||
tar->sconv_acl =
|
||||
archive_string_conversion_from_charset(
|
||||
&(a->archive), "UTF-8", 1);
|
||||
if (tar->sconv_acl == NULL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
r = archive_acl_parse_l(archive_entry_acl(entry),
|
||||
value, ARCHIVE_ENTRY_ACL_TYPE_DEFAULT,
|
||||
tar->sconv_acl);
|
||||
if (r != ARCHIVE_OK) {
|
||||
err = r;
|
||||
if (err == ARCHIVE_FATAL) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate memory for "
|
||||
"SCHILY.acl.default");
|
||||
return (err);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_MISC,
|
||||
"Parse error: SCHILY.acl.default");
|
||||
}
|
||||
r = pax_attribute_acl(a, tar, entry, value,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
return (r);
|
||||
} else if (strcmp(key, "SCHILY.acl.ace") == 0) {
|
||||
r = pax_attribute_acl(a, tar, entry, value,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
if (r == ARCHIVE_FATAL)
|
||||
return (r);
|
||||
} else if (strcmp(key, "SCHILY.devmajor") == 0) {
|
||||
archive_entry_set_rdevmajor(entry,
|
||||
(dev_t)tar_atol10(value, strlen(value)));
|
||||
|
@ -418,18 +418,30 @@ zip_time(const char *p)
|
||||
* id1+size1+data1 + id2+size2+data2 ...
|
||||
* triplets. id and size are 2 bytes each.
|
||||
*/
|
||||
static void
|
||||
process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
static int
|
||||
process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
while (offset < extra_length - 4) {
|
||||
if (extra_length == 0) {
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
if (extra_length < 4) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Too-small extra data: Need at least 4 bytes, but only found %d bytes", (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
while (offset <= extra_length - 4) {
|
||||
unsigned short headerid = archive_le16dec(p + offset);
|
||||
unsigned short datasize = archive_le16dec(p + offset + 2);
|
||||
|
||||
offset += 4;
|
||||
if (offset + datasize > extra_length) {
|
||||
break;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Extra data overflow: Need %d bytes but only found %d bytes",
|
||||
(int)datasize, (int)(extra_length - offset));
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Header id 0x%04x, length %d\n",
|
||||
@ -715,13 +727,13 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
}
|
||||
offset += datasize;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (offset != extra_length)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Extra data field contents do not match reported size!\n");
|
||||
if (offset != extra_length) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Malformed extra data: Consumed %d bytes of %d bytes",
|
||||
(int)offset, (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#endif
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -840,7 +852,9 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
process_extra(h, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, h, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
__archive_read_consume(a, extra_length);
|
||||
|
||||
/* Work around a bug in Info-Zip: When reading from a pipe, it
|
||||
@ -1293,7 +1307,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
|
||||
&& bytes_avail > zip->entry_bytes_remaining) {
|
||||
bytes_avail = (ssize_t)zip->entry_bytes_remaining;
|
||||
}
|
||||
if (bytes_avail <= 0) {
|
||||
if (bytes_avail < 0) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated ZIP file body");
|
||||
return (ARCHIVE_FATAL);
|
||||
@ -2691,7 +2705,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
|
||||
"Truncated ZIP file header");
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
process_extra(p + filename_length, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, p + filename_length, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mac resource fork files are stored under the
|
||||
|
@ -138,6 +138,7 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
acl_permset_t acl_permset;
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_flagset_t acl_flagset;
|
||||
int r;
|
||||
#endif
|
||||
int ret;
|
||||
int ae_type, ae_permset, ae_tag, ae_id;
|
||||
@ -145,16 +146,25 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
gid_t ae_gid;
|
||||
const char *ae_name;
|
||||
int entries;
|
||||
int i, r;
|
||||
int i;
|
||||
|
||||
ret = ARCHIVE_OK;
|
||||
entries = archive_acl_reset(abstract_acl, ae_requested_type);
|
||||
if (entries == 0)
|
||||
return (ARCHIVE_OK);
|
||||
acl = acl_init(entries);
|
||||
if (acl == (acl_t)NULL) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to initialize ACL working storage");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
|
||||
&ae_permset, &ae_tag, &ae_id, &ae_name) == ARCHIVE_OK) {
|
||||
acl_create_entry(&acl, &acl_entry);
|
||||
if (acl_create_entry(&acl, &acl_entry) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to create a new ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
switch (ae_tag) {
|
||||
case ARCHIVE_ENTRY_ACL_USER:
|
||||
@ -185,53 +195,84 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
/* XXX */
|
||||
break;
|
||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL tag: %d", ae_tag);
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
r = 0;
|
||||
switch (ae_type) {
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DENY:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_DENY);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_AUDIT:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_AUDIT);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ALARM:
|
||||
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
|
||||
r = acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALARM);
|
||||
break;
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_ACCESS:
|
||||
case ARCHIVE_ENTRY_ACL_TYPE_DEFAULT:
|
||||
// These don't translate directly into the system ACL.
|
||||
break;
|
||||
default:
|
||||
// XXX error handling here.
|
||||
break;
|
||||
archive_set_error(a, ARCHIVE_ERRNO_MISC,
|
||||
"Unknown ACL entry type: %d", ae_type);
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
if (r != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to set ACL entry type");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
#endif
|
||||
|
||||
acl_get_permset(acl_entry, &acl_permset);
|
||||
acl_clear_perms(acl_permset);
|
||||
if (acl_get_permset(acl_entry, &acl_permset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to get ACL permission set");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
if (acl_clear_perms(acl_permset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to clear ACL permissions");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
|
||||
for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
|
||||
if (ae_permset & acl_perm_map[i].archive_perm)
|
||||
acl_add_perm(acl_permset,
|
||||
acl_perm_map[i].platform_perm);
|
||||
if (acl_add_perm(acl_permset,
|
||||
acl_perm_map[i].platform_perm) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to add ACL permission");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
|
||||
// non-NFSv4 ACLs
|
||||
r = acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
if (r == 0) {
|
||||
acl_clear_flags_np(acl_flagset);
|
||||
if (acl_type == ACL_TYPE_NFS4) {
|
||||
if (acl_get_flagset_np(acl_entry, &acl_flagset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to get flagset from an NFSv4 ACL entry");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
if (acl_clear_flags_np(acl_flagset) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to clear flags from an NFSv4 ACL flagset");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit)
|
||||
acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit);
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit) {
|
||||
if (acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit) != 0) {
|
||||
archive_set_error(a, errno,
|
||||
"Failed to add flag to NFSv4 ACL flagset");
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -2401,8 +2401,18 @@ check_symlinks(struct archive_write_disk *a)
|
||||
r = lstat(a->name, &st);
|
||||
if (r != 0) {
|
||||
/* We've hit a dir that doesn't exist; stop now. */
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
break;
|
||||
} else {
|
||||
/* Note: This effectively disables deep directory
|
||||
* support when security checks are enabled.
|
||||
* Otherwise, very long pathnames that trigger
|
||||
* an error here could evade the sandbox.
|
||||
* TODO: We could do better, but it would probably
|
||||
* require merging the symlink checks with the
|
||||
* deep-directory editing. */
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
} else if (S_ISLNK(st.st_mode)) {
|
||||
if (c == '\0') {
|
||||
/*
|
||||
|
@ -70,6 +70,8 @@ static void add_pax_attr_int(struct archive_string *,
|
||||
static void add_pax_attr_time(struct archive_string *,
|
||||
const char *key, int64_t sec,
|
||||
unsigned long nanos);
|
||||
static int add_pax_acl(struct archive_write *,
|
||||
struct archive_entry *, struct pax *, int);
|
||||
static ssize_t archive_write_pax_data(struct archive_write *,
|
||||
const void *, size_t);
|
||||
static int archive_write_pax_close(struct archive_write *);
|
||||
@ -450,6 +452,43 @@ get_entry_symlink(struct archive_write *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_OK);
|
||||
}
|
||||
|
||||
/* Add ACL to pax header */
|
||||
static int
|
||||
add_pax_acl(struct archive_write *a,
|
||||
struct archive_entry *entry, struct pax *pax, int flags)
|
||||
{
|
||||
const char *p;
|
||||
const char *attr;
|
||||
int r;
|
||||
|
||||
if (flags & ARCHIVE_ENTRY_ACL_TYPE_ACCESS)
|
||||
attr = "SCHILY.acl.access";
|
||||
else if (flags & ARCHIVE_ENTRY_ACL_TYPE_DEFAULT)
|
||||
attr = "SCHILY.acl.default";
|
||||
else if (flags & ARCHIVE_ENTRY_ACL_TYPE_NFS4)
|
||||
attr = "SCHILY.acl.ace";
|
||||
else
|
||||
return(ARCHIVE_FATAL);
|
||||
|
||||
r = archive_entry_acl_text_l(entry, flags, &p, NULL,
|
||||
pax->sconv_utf8);
|
||||
if (r != 0) {
|
||||
if (errno == ENOMEM) {
|
||||
archive_set_error(&a->archive, ENOMEM, "%s %s",
|
||||
"Can't allocate memory for ", attr);
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT, "%s %s %s",
|
||||
"Can't translate ", attr, " to UTF-8");
|
||||
return(ARCHIVE_WARN);
|
||||
} else if (p != NULL && *p != '\0') {
|
||||
add_pax_attr(&(pax->pax_header),
|
||||
attr, p);
|
||||
}
|
||||
return(ARCHIVE_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO: Consider adding 'comment' and 'charset' fields to
|
||||
* archive_entry so that clients can specify them. Also, consider
|
||||
@ -466,6 +505,7 @@ archive_write_pax_header(struct archive_write *a,
|
||||
const char *p;
|
||||
const char *suffix;
|
||||
int need_extension, r, ret;
|
||||
int acl_access, acl_default, acl_nfs4;
|
||||
int sparse_count;
|
||||
uint64_t sparse_total, real_size;
|
||||
struct pax *pax;
|
||||
@ -1017,16 +1057,6 @@ archive_write_pax_header(struct archive_write *a,
|
||||
if (!need_extension && p != NULL && *p != '\0')
|
||||
need_extension = 1;
|
||||
|
||||
/* If there are non-trivial ACL entries, we need an extension. */
|
||||
if (!need_extension && archive_entry_acl_count(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS) > 0)
|
||||
need_extension = 1;
|
||||
|
||||
/* If there are non-trivial ACL entries, we need an extension. */
|
||||
if (!need_extension && archive_entry_acl_count(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) > 0)
|
||||
need_extension = 1;
|
||||
|
||||
/* If there are extended attributes, we need an extension */
|
||||
if (!need_extension && archive_entry_xattr_count(entry_original) > 0)
|
||||
need_extension = 1;
|
||||
@ -1035,6 +1065,17 @@ archive_write_pax_header(struct archive_write *a,
|
||||
if (!need_extension && sparse_count > 0)
|
||||
need_extension = 1;
|
||||
|
||||
acl_access = archive_entry_acl_count(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS);
|
||||
acl_default = archive_entry_acl_count(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT);
|
||||
acl_nfs4 = archive_entry_acl_count(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4);
|
||||
|
||||
/* If there are any ACL entries, we need an extension */
|
||||
if (!need_extension && (acl_access + acl_default + acl_nfs4) > 0)
|
||||
need_extension = 1;
|
||||
|
||||
/*
|
||||
* Libarchive used to include these in extended headers for
|
||||
* restricted pax format, but that confused people who
|
||||
@ -1086,43 +1127,26 @@ archive_write_pax_header(struct archive_write *a,
|
||||
add_pax_attr(&(pax->pax_header), "SCHILY.fflags", p);
|
||||
|
||||
/* I use star-compatible ACL attributes. */
|
||||
r = archive_entry_acl_text_l(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
|
||||
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
|
||||
&p, NULL, pax->sconv_utf8);
|
||||
if (r != 0) {
|
||||
if (errno == ENOMEM) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate memory for "
|
||||
"ACL.access");
|
||||
if (acl_access > 0) {
|
||||
ret = add_pax_acl(a, entry_original, pax,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_ACCESS |
|
||||
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID);
|
||||
if (ret == ARCHIVE_FATAL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Can't translate ACL.access to UTF-8");
|
||||
ret = ARCHIVE_WARN;
|
||||
} else if (p != NULL && *p != '\0') {
|
||||
add_pax_attr(&(pax->pax_header),
|
||||
"SCHILY.acl.access", p);
|
||||
}
|
||||
r = archive_entry_acl_text_l(entry_original,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
|
||||
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID,
|
||||
&p, NULL, pax->sconv_utf8);
|
||||
if (r != 0) {
|
||||
if (errno == ENOMEM) {
|
||||
archive_set_error(&a->archive, ENOMEM,
|
||||
"Can't allocate memory for "
|
||||
"ACL.default");
|
||||
if (acl_default > 0) {
|
||||
ret = add_pax_acl(a, entry_original, pax,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT |
|
||||
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID);
|
||||
if (ret == ARCHIVE_FATAL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (acl_nfs4 > 0) {
|
||||
ret = add_pax_acl(a, entry_original, pax,
|
||||
ARCHIVE_ENTRY_ACL_TYPE_NFS4 |
|
||||
ARCHIVE_ENTRY_ACL_STYLE_EXTRA_ID);
|
||||
if (ret == ARCHIVE_FATAL)
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
archive_set_error(&a->archive,
|
||||
ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Can't translate ACL.default to UTF-8");
|
||||
ret = ARCHIVE_WARN;
|
||||
} else if (p != NULL && *p != '\0') {
|
||||
add_pax_attr(&(pax->pax_header),
|
||||
"SCHILY.acl.default", p);
|
||||
}
|
||||
|
||||
/* We use GNU-tar-compatible sparse attributes. */
|
||||
|
@ -182,7 +182,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* If our output buffer is full, dump it and keep going. */
|
||||
if (i > (sizeof(outbuff) - 20)) {
|
||||
if (i > (sizeof(outbuff) - 128)) {
|
||||
outbuff[i] = '\0';
|
||||
fprintf(f, "%s", outbuff);
|
||||
i = 0;
|
||||
|
@ -392,11 +392,9 @@ int c4iw_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
|
||||
t4_sq_produce(&qhp->wq, len16);
|
||||
idx += DIV_ROUND_UP(len16*16, T4_EQ_ENTRY_SIZE);
|
||||
}
|
||||
if (t4_wq_db_enabled(&qhp->wq)) {
|
||||
t4_ring_sq_db(&qhp->wq, idx, dev_is_t5(qhp->rhp),
|
||||
len16, wqe);
|
||||
} else
|
||||
ring_kernel_db(qhp, qhp->wq.sq.qid, idx);
|
||||
|
||||
t4_ring_sq_db(&qhp->wq, idx, dev_is_t5(qhp->rhp),
|
||||
len16, wqe);
|
||||
qhp->wq.sq.queue[qhp->wq.sq.size].status.host_wq_pidx = \
|
||||
(qhp->wq.sq.wq_pidx);
|
||||
pthread_spin_unlock(&qhp->lock);
|
||||
@ -458,11 +456,9 @@ int c4iw_post_receive(struct ibv_qp *ibqp, struct ibv_recv_wr *wr,
|
||||
wr = wr->next;
|
||||
num_wrs--;
|
||||
}
|
||||
if (t4_wq_db_enabled(&qhp->wq))
|
||||
t4_ring_rq_db(&qhp->wq, idx, dev_is_t5(qhp->rhp),
|
||||
len16, wqe);
|
||||
else
|
||||
ring_kernel_db(qhp, qhp->wq.rq.qid, idx);
|
||||
|
||||
t4_ring_rq_db(&qhp->wq, idx, dev_is_t5(qhp->rhp),
|
||||
len16, wqe);
|
||||
qhp->wq.rq.queue[qhp->wq.rq.size].status.host_wq_pidx = \
|
||||
(qhp->wq.rq.wq_pidx);
|
||||
pthread_spin_unlock(&qhp->lock);
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE
|
||||
AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE
|
||||
|
||||
lib_LTLIBRARIES = libsqlite3.la
|
||||
libsqlite3_la_SOURCES = sqlite3.c
|
||||
|
@ -305,6 +305,7 @@ PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
READLINE_LIBS = @READLINE_LIBS@
|
||||
SED = @SED@
|
||||
SESSION_FLAGS = @SESSION_FLAGS@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
@ -362,7 +363,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE
|
||||
AM_CFLAGS = @THREADSAFE_FLAGS@ @DYNAMIC_EXTENSION_FLAGS@ @FTS5_FLAGS@ @JSON1_FLAGS@ @SESSION_FLAGS@ -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE
|
||||
lib_LTLIBRARIES = libsqlite3.la
|
||||
libsqlite3_la_SOURCES = sqlite3.c
|
||||
libsqlite3_la_LDFLAGS = -no-undefined -version-info 8:6:8
|
||||
|
971
contrib/sqlite3/Makefile.msc
Normal file
971
contrib/sqlite3/Makefile.msc
Normal file
@ -0,0 +1,971 @@
|
||||
#### DO NOT EDIT ####
|
||||
# This makefile is automatically generated from the Makefile.msc at
|
||||
# the root of the canonical SQLite source tree (not the
|
||||
# amalgamation tarball) using the tool/mkmsvcmin.tcl
|
||||
# script.
|
||||
#
|
||||
|
||||
#
|
||||
# nmake Makefile for SQLite
|
||||
#
|
||||
###############################################################################
|
||||
############################## START OF OPTIONS ###############################
|
||||
###############################################################################
|
||||
|
||||
# The toplevel directory of the source tree. This is the directory
|
||||
# that contains this "Makefile.msc".
|
||||
#
|
||||
TOP = .
|
||||
|
||||
|
||||
# Set this non-0 to enable full warnings (-W4, etc) when compiling.
|
||||
#
|
||||
!IFNDEF USE_FULLWARN
|
||||
USE_FULLWARN = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to enable full runtime error checks (-RTC1, etc). This
|
||||
# has no effect if (any) optimizations are enabled.
|
||||
#
|
||||
!IFNDEF USE_RUNTIME_CHECKS
|
||||
USE_RUNTIME_CHECKS = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to use "stdcall" calling convention for the core library
|
||||
# and shell executable.
|
||||
#
|
||||
!IFNDEF USE_STDCALL
|
||||
USE_STDCALL = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to have the shell executable link against the core dynamic
|
||||
# link library.
|
||||
#
|
||||
!IFNDEF DYNAMIC_SHELL
|
||||
DYNAMIC_SHELL = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to enable extra code that attempts to detect misuse of the
|
||||
# SQLite API.
|
||||
#
|
||||
!IFNDEF API_ARMOR
|
||||
API_ARMOR = 0
|
||||
!ENDIF
|
||||
|
||||
# If necessary, create a list of harmless compiler warnings to disable when
|
||||
# compiling the various tools. For the SQLite source code itself, warnings,
|
||||
# if any, will be disabled from within it.
|
||||
#
|
||||
!IFNDEF NO_WARN
|
||||
!IF $(USE_FULLWARN)!=0
|
||||
NO_WARN = -wd4054 -wd4055 -wd4100 -wd4127 -wd4130 -wd4152 -wd4189 -wd4206
|
||||
NO_WARN = $(NO_WARN) -wd4210 -wd4232 -wd4305 -wd4306 -wd4702 -wd4706
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to use the library paths and other options necessary for
|
||||
# Windows Phone 8.1.
|
||||
#
|
||||
!IFNDEF USE_WP81_OPTS
|
||||
USE_WP81_OPTS = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to split the SQLite amalgamation file into chunks to
|
||||
# be used for debugging with Visual Studio.
|
||||
#
|
||||
!IFNDEF SPLIT_AMALGAMATION
|
||||
SPLIT_AMALGAMATION = 0
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Set this non-0 to dynamically link to the MSVC runtime library.
|
||||
#
|
||||
!IFNDEF USE_CRT_DLL
|
||||
USE_CRT_DLL = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to link to the RPCRT4 library.
|
||||
#
|
||||
!IFNDEF USE_RPCRT4_LIB
|
||||
USE_RPCRT4_LIB = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to generate assembly code listings for the source code
|
||||
# files.
|
||||
#
|
||||
!IFNDEF USE_LISTINGS
|
||||
USE_LISTINGS = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to attempt setting the native compiler automatically
|
||||
# for cross-compiling the command line tools needed during the compilation
|
||||
# process.
|
||||
#
|
||||
!IFNDEF XCOMPILE
|
||||
XCOMPILE = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to use the native libraries paths for cross-compiling
|
||||
# the command line tools needed during the compilation process.
|
||||
#
|
||||
!IFNDEF USE_NATIVE_LIBPATHS
|
||||
USE_NATIVE_LIBPATHS = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this 0 to skip the compiling and embedding of version resources.
|
||||
#
|
||||
!IFNDEF USE_RC
|
||||
USE_RC = 1
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to compile binaries suitable for the WinRT environment.
|
||||
# This setting does not apply to any binaries that require Tcl to operate
|
||||
# properly (i.e. the text fixture, etc).
|
||||
#
|
||||
!IFNDEF FOR_WINRT
|
||||
FOR_WINRT = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to compile binaries suitable for the UWP environment.
|
||||
# This setting does not apply to any binaries that require Tcl to operate
|
||||
# properly (i.e. the text fixture, etc).
|
||||
#
|
||||
!IFNDEF FOR_UWP
|
||||
FOR_UWP = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this non-0 to compile binaries suitable for the Windows 10 platform.
|
||||
#
|
||||
!IFNDEF FOR_WIN10
|
||||
FOR_WIN10 = 0
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Set this to non-0 to create and use PDBs.
|
||||
#
|
||||
!IFNDEF SYMBOLS
|
||||
SYMBOLS = 1
|
||||
!ENDIF
|
||||
|
||||
# Set this to non-0 to use the SQLite debugging heap subsystem.
|
||||
#
|
||||
!IFNDEF MEMDEBUG
|
||||
MEMDEBUG = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this to non-0 to use the Win32 native heap subsystem.
|
||||
#
|
||||
!IFNDEF WIN32HEAP
|
||||
WIN32HEAP = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this to non-0 to enable OSTRACE() macros, which can be useful when
|
||||
# debugging.
|
||||
#
|
||||
!IFNDEF OSTRACE
|
||||
OSTRACE = 0
|
||||
!ENDIF
|
||||
|
||||
# Set this to one of the following values to enable various debugging
|
||||
# features. Each level includes the debugging options from the previous
|
||||
# levels. Currently, the recognized values for DEBUG are:
|
||||
#
|
||||
# 0 == NDEBUG: Disables assert() and other runtime diagnostics.
|
||||
# 1 == SQLITE_ENABLE_API_ARMOR: extra attempts to detect misuse of the API.
|
||||
# 2 == Disables NDEBUG and all optimizations and then enables PDBs.
|
||||
# 3 == SQLITE_DEBUG: Enables various diagnostics messages and code.
|
||||
# 4 == SQLITE_WIN32_MALLOC_VALIDATE: Validate the Win32 native heap per call.
|
||||
# 5 == SQLITE_DEBUG_OS_TRACE: Enables output from the OSTRACE() macros.
|
||||
# 6 == SQLITE_ENABLE_IOTRACE: Enables output from the IOTRACE() macros.
|
||||
#
|
||||
!IFNDEF DEBUG
|
||||
DEBUG = 0
|
||||
!ENDIF
|
||||
|
||||
# Enable use of available compiler optimizations? Normally, this should be
|
||||
# non-zero. Setting this to zero, thus disabling all compiler optimizations,
|
||||
# can be useful for testing.
|
||||
#
|
||||
!IFNDEF OPTIMIZATIONS
|
||||
OPTIMIZATIONS = 2
|
||||
!ENDIF
|
||||
|
||||
# Set this to non-0 to enable support for the session extension.
|
||||
#
|
||||
!IFNDEF SESSION
|
||||
SESSION = 0
|
||||
!ENDIF
|
||||
|
||||
# Set the source code file to be used by executables and libraries when
|
||||
# they need the amalgamation.
|
||||
#
|
||||
!IFNDEF SQLITE3C
|
||||
!IF $(SPLIT_AMALGAMATION)!=0
|
||||
SQLITE3C = sqlite3-all.c
|
||||
!ELSE
|
||||
SQLITE3C = sqlite3.c
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# Set the include code file to be used by executables and libraries when
|
||||
# they need SQLite.
|
||||
#
|
||||
!IFNDEF SQLITE3H
|
||||
SQLITE3H = sqlite3.h
|
||||
!ENDIF
|
||||
|
||||
# This is the name to use for the SQLite dynamic link library (DLL).
|
||||
#
|
||||
!IFNDEF SQLITE3DLL
|
||||
!IF $(FOR_WIN10)!=0
|
||||
SQLITE3DLL = winsqlite3.dll
|
||||
!ELSE
|
||||
SQLITE3DLL = sqlite3.dll
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the name to use for the SQLite import library (LIB).
|
||||
#
|
||||
!IFNDEF SQLITE3LIB
|
||||
!IF $(FOR_WIN10)!=0
|
||||
SQLITE3LIB = winsqlite3.lib
|
||||
!ELSE
|
||||
SQLITE3LIB = sqlite3.lib
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the name to use for the SQLite shell executable (EXE).
|
||||
#
|
||||
!IFNDEF SQLITE3EXE
|
||||
!IF $(FOR_WIN10)!=0
|
||||
SQLITE3EXE = winsqlite3shell.exe
|
||||
!ELSE
|
||||
SQLITE3EXE = sqlite3.exe
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the argument used to set the program database (PDB) file for the
|
||||
# SQLite shell executable (EXE).
|
||||
#
|
||||
!IFNDEF SQLITE3EXEPDB
|
||||
!IF $(FOR_WIN10)!=0
|
||||
SQLITE3EXEPDB =
|
||||
!ELSE
|
||||
SQLITE3EXEPDB = /pdb:sqlite3sh.pdb
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# These are the "standard" SQLite compilation options used when compiling for
|
||||
# the Windows platform.
|
||||
#
|
||||
!IFNDEF OPT_FEATURE_FLAGS
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS3=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
|
||||
!ENDIF
|
||||
|
||||
# Should the session extension be enabled? If so, add compilation options
|
||||
# to enable it.
|
||||
#
|
||||
!IF $(SESSION)!=0
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_SESSION=1
|
||||
OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_PREUPDATE_HOOK=1
|
||||
!ENDIF
|
||||
|
||||
# These are the "extended" SQLite compilation options used when compiling for
|
||||
# the Windows 10 platform.
|
||||
#
|
||||
!IFNDEF EXT_FEATURE_FLAGS
|
||||
!IF $(FOR_WIN10)!=0
|
||||
EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_ENABLE_FTS4=1
|
||||
EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_SYSTEM_MALLOC=1
|
||||
EXT_FEATURE_FLAGS = $(EXT_FEATURE_FLAGS) -DSQLITE_OMIT_LOCALTIME=1
|
||||
!ELSE
|
||||
EXT_FEATURE_FLAGS =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
###############################################################################
|
||||
############################### END OF OPTIONS ################################
|
||||
###############################################################################
|
||||
|
||||
# When compiling for the Windows 10 platform, the PLATFORM macro must be set
|
||||
# to an appropriate value (e.g. x86, x64, arm, arm64, etc).
|
||||
#
|
||||
!IF $(FOR_WIN10)!=0
|
||||
!IFNDEF PLATFORM
|
||||
!ERROR Using the FOR_WIN10 option requires a value for PLATFORM.
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This assumes that MSVC is always installed in 32-bit Program Files directory
|
||||
# and sets the variable for use in locating other 32-bit installs accordingly.
|
||||
#
|
||||
PROGRAMFILES_X86 = $(VCINSTALLDIR)\..\..
|
||||
PROGRAMFILES_X86 = $(PROGRAMFILES_X86:\\=\)
|
||||
|
||||
# Check for the predefined command macro CC. This should point to the compiler
|
||||
# binary for the target platform. If it is not defined, simply define it to
|
||||
# the legacy default value 'cl.exe'.
|
||||
#
|
||||
!IFNDEF CC
|
||||
CC = cl.exe
|
||||
!ENDIF
|
||||
|
||||
# Check for the predefined command macro CSC. This should point to a working
|
||||
# C Sharp compiler binary. If it is not defined, simply define it to the
|
||||
# legacy default value 'csc.exe'.
|
||||
#
|
||||
!IFNDEF CSC
|
||||
CSC = csc.exe
|
||||
!ENDIF
|
||||
|
||||
# Check for the command macro LD. This should point to the linker binary for
|
||||
# the target platform. If it is not defined, simply define it to the legacy
|
||||
# default value 'link.exe'.
|
||||
#
|
||||
!IFNDEF LD
|
||||
LD = link.exe
|
||||
!ENDIF
|
||||
|
||||
# Check for the predefined command macro RC. This should point to the resource
|
||||
# compiler binary for the target platform. If it is not defined, simply define
|
||||
# it to the legacy default value 'rc.exe'.
|
||||
#
|
||||
!IFNDEF RC
|
||||
RC = rc.exe
|
||||
!ENDIF
|
||||
|
||||
# Check for the MSVC runtime library path macro. Otherwise, this value will
|
||||
# default to the 'lib' directory underneath the MSVC installation directory.
|
||||
#
|
||||
!IFNDEF CRTLIBPATH
|
||||
CRTLIBPATH = $(VCINSTALLDIR)\lib
|
||||
!ENDIF
|
||||
|
||||
CRTLIBPATH = $(CRTLIBPATH:\\=\)
|
||||
|
||||
# Check for the command macro NCC. This should point to the compiler binary
|
||||
# for the platform the compilation process is taking place on. If it is not
|
||||
# defined, simply define it to have the same value as the CC macro. When
|
||||
# cross-compiling, it is suggested that this macro be modified via the command
|
||||
# line (since nmake itself does not provide a built-in method to guess it).
|
||||
# For example, to use the x86 compiler when cross-compiling for x64, a command
|
||||
# line similar to the following could be used (all on one line):
|
||||
#
|
||||
# nmake /f Makefile.msc sqlite3.dll
|
||||
# XCOMPILE=1 USE_NATIVE_LIBPATHS=1
|
||||
#
|
||||
# Alternatively, the full path and file name to the compiler binary for the
|
||||
# platform the compilation process is taking place may be specified (all on
|
||||
# one line):
|
||||
#
|
||||
# nmake /f Makefile.msc sqlite3.dll
|
||||
# "NCC=""%VCINSTALLDIR%\bin\cl.exe"""
|
||||
# USE_NATIVE_LIBPATHS=1
|
||||
#
|
||||
!IFDEF NCC
|
||||
NCC = $(NCC:\\=\)
|
||||
!ELSEIF $(XCOMPILE)!=0
|
||||
NCC = "$(VCINSTALLDIR)\bin\$(CC)"
|
||||
NCC = $(NCC:\\=\)
|
||||
!ELSE
|
||||
NCC = $(CC)
|
||||
!ENDIF
|
||||
|
||||
# Check for the MSVC native runtime library path macro. Otherwise,
|
||||
# this value will default to the 'lib' directory underneath the MSVC
|
||||
# installation directory.
|
||||
#
|
||||
!IFNDEF NCRTLIBPATH
|
||||
NCRTLIBPATH = $(VCINSTALLDIR)\lib
|
||||
!ENDIF
|
||||
|
||||
NCRTLIBPATH = $(NCRTLIBPATH:\\=\)
|
||||
|
||||
# Check for the Platform SDK library path macro. Otherwise, this
|
||||
# value will default to the 'lib' directory underneath the Windows
|
||||
# SDK installation directory (the environment variable used appears
|
||||
# to be available when using Visual C++ 2008 or later via the
|
||||
# command line).
|
||||
#
|
||||
!IFNDEF NSDKLIBPATH
|
||||
NSDKLIBPATH = $(WINDOWSSDKDIR)\lib
|
||||
!ENDIF
|
||||
|
||||
NSDKLIBPATH = $(NSDKLIBPATH:\\=\)
|
||||
|
||||
# Check for the UCRT library path macro. Otherwise, this value will
|
||||
# default to the version-specific, platform-specific 'lib' directory
|
||||
# underneath the Windows SDK installation directory.
|
||||
#
|
||||
!IFNDEF UCRTLIBPATH
|
||||
UCRTLIBPATH = $(WINDOWSSDKDIR)\lib\$(WINDOWSSDKLIBVERSION)\ucrt\$(PLATFORM)
|
||||
!ENDIF
|
||||
|
||||
UCRTLIBPATH = $(UCRTLIBPATH:\\=\)
|
||||
|
||||
# C compiler and options for use in building executables that
|
||||
# will run on the platform that is doing the build.
|
||||
#
|
||||
!IF $(USE_FULLWARN)!=0
|
||||
BCC = $(NCC) -nologo -W4 $(CCOPTS) $(BCCOPTS)
|
||||
!ELSE
|
||||
BCC = $(NCC) -nologo -W3 $(CCOPTS) $(BCCOPTS)
|
||||
!ENDIF
|
||||
|
||||
# Check if assembly code listings should be generated for the source
|
||||
# code files to be compiled.
|
||||
#
|
||||
!IF $(USE_LISTINGS)!=0
|
||||
BCC = $(BCC) -FAcs
|
||||
!ENDIF
|
||||
|
||||
# Check if the native library paths should be used when compiling
|
||||
# the command line tools used during the compilation process. If
|
||||
# so, set the necessary macro now.
|
||||
#
|
||||
!IF $(USE_NATIVE_LIBPATHS)!=0
|
||||
NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)"
|
||||
|
||||
!IFDEF NUCRTLIBPATH
|
||||
NUCRTLIBPATH = $(NUCRTLIBPATH:\\=\)
|
||||
NLTLIBPATHS = $(NLTLIBPATHS) "/LIBPATH:$(NUCRTLIBPATH)"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# C compiler and options for use in building executables that
|
||||
# will run on the target platform. (BCC and TCC are usually the
|
||||
# same unless your are cross-compiling.)
|
||||
#
|
||||
!IF $(USE_FULLWARN)!=0
|
||||
TCC = $(CC) -nologo -W4 -DINCLUDE_MSVC_H=1 $(CCOPTS) $(TCCOPTS)
|
||||
!ELSE
|
||||
TCC = $(CC) -nologo -W3 $(CCOPTS) $(TCCOPTS)
|
||||
!ENDIF
|
||||
|
||||
TCC = $(TCC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) -fp:precise
|
||||
RCC = $(RC) -DSQLITE_OS_WIN=1 -I. -I$(TOP) $(RCOPTS) $(RCCOPTS)
|
||||
|
||||
# Check if we want to use the "stdcall" calling convention when compiling.
|
||||
# This is not supported by the compilers for non-x86 platforms. It should
|
||||
# also be noted here that building any target with these "stdcall" options
|
||||
# will most likely fail if the Tcl library is also required. This is due
|
||||
# to how the Tcl library functions are declared and exported (i.e. without
|
||||
# an explicit calling convention, which results in "cdecl").
|
||||
#
|
||||
!IF $(USE_STDCALL)!=0 || $(FOR_WIN10)!=0
|
||||
!IF "$(PLATFORM)"=="x86"
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
|
||||
!ELSE
|
||||
!IFNDEF PLATFORM
|
||||
CORE_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
|
||||
SHELL_CCONV_OPTS = -Gz -DSQLITE_CDECL=__cdecl -DSQLITE_APICALL=__stdcall -DSQLITE_CALLBACK=__stdcall -DSQLITE_SYSAPI=__stdcall
|
||||
!ELSE
|
||||
CORE_CCONV_OPTS =
|
||||
SHELL_CCONV_OPTS =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
!ELSE
|
||||
CORE_CCONV_OPTS =
|
||||
SHELL_CCONV_OPTS =
|
||||
!ENDIF
|
||||
|
||||
# These are additional compiler options used for the core library.
|
||||
#
|
||||
!IFNDEF CORE_COMPILE_OPTS
|
||||
!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
|
||||
CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS) -DSQLITE_API=__declspec(dllexport)
|
||||
!ELSE
|
||||
CORE_COMPILE_OPTS = $(CORE_CCONV_OPTS)
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# These are the additional targets that the core library should depend on
|
||||
# when linking.
|
||||
#
|
||||
!IFNDEF CORE_LINK_DEP
|
||||
!IF $(DYNAMIC_SHELL)!=0
|
||||
CORE_LINK_DEP =
|
||||
!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
|
||||
CORE_LINK_DEP = sqlite3.def
|
||||
!ELSE
|
||||
CORE_LINK_DEP =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# These are additional linker options used for the core library.
|
||||
#
|
||||
!IFNDEF CORE_LINK_OPTS
|
||||
!IF $(DYNAMIC_SHELL)!=0
|
||||
CORE_LINK_OPTS =
|
||||
!ELSEIF $(FOR_WIN10)==0 || "$(PLATFORM)"=="x86"
|
||||
CORE_LINK_OPTS = /DEF:sqlite3.def
|
||||
!ELSE
|
||||
CORE_LINK_OPTS =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# These are additional compiler options used for the shell executable.
|
||||
#
|
||||
!IFNDEF SHELL_COMPILE_OPTS
|
||||
!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
|
||||
SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS) -DSQLITE_API=__declspec(dllimport)
|
||||
!ELSE
|
||||
SHELL_COMPILE_OPTS = $(SHELL_CCONV_OPTS)
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the source code that the shell executable should be compiled
|
||||
# with.
|
||||
#
|
||||
!IFNDEF SHELL_CORE_SRC
|
||||
!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
|
||||
SHELL_CORE_SRC =
|
||||
!ELSE
|
||||
SHELL_CORE_SRC = $(SQLITE3C)
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the core library that the shell executable should depend on.
|
||||
#
|
||||
!IFNDEF SHELL_CORE_DEP
|
||||
!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
|
||||
SHELL_CORE_DEP = $(SQLITE3DLL)
|
||||
!ELSE
|
||||
SHELL_CORE_DEP =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# This is the core library that the shell executable should link with.
|
||||
#
|
||||
!IFNDEF SHELL_CORE_LIB
|
||||
!IF $(DYNAMIC_SHELL)!=0 || $(FOR_WIN10)!=0
|
||||
SHELL_CORE_LIB = $(SQLITE3LIB)
|
||||
!ELSE
|
||||
SHELL_CORE_LIB =
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# These are additional linker options used for the shell executable.
|
||||
#
|
||||
!IFNDEF SHELL_LINK_OPTS
|
||||
SHELL_LINK_OPTS = $(SHELL_CORE_LIB)
|
||||
!ENDIF
|
||||
|
||||
# Check if assembly code listings should be generated for the source
|
||||
# code files to be compiled.
|
||||
#
|
||||
!IF $(USE_LISTINGS)!=0
|
||||
TCC = $(TCC) -FAcs
|
||||
!ENDIF
|
||||
|
||||
# When compiling the library for use in the WinRT environment,
|
||||
# the following compile-time options must be used as well to
|
||||
# disable use of Win32 APIs that are not available and to enable
|
||||
# use of Win32 APIs that are specific to Windows 8 and/or WinRT.
|
||||
#
|
||||
!IF $(FOR_WINRT)!=0
|
||||
TCC = $(TCC) -DSQLITE_OS_WINRT=1
|
||||
RCC = $(RCC) -DSQLITE_OS_WINRT=1
|
||||
TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
|
||||
RCC = $(RCC) -DWINAPI_FAMILY=WINAPI_FAMILY_APP
|
||||
!ENDIF
|
||||
|
||||
# C compiler options for the Windows 10 platform (needs MSVC 2015).
|
||||
#
|
||||
!IF $(FOR_WIN10)!=0
|
||||
TCC = $(TCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
|
||||
BCC = $(BCC) /d2guard4 -D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE
|
||||
!ENDIF
|
||||
|
||||
# Also, we need to dynamically link to the correct MSVC runtime
|
||||
# when compiling for WinRT (e.g. debug or release) OR if the
|
||||
# USE_CRT_DLL option is set to force dynamically linking to the
|
||||
# MSVC runtime library.
|
||||
#
|
||||
!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0
|
||||
!IF $(DEBUG)>1
|
||||
TCC = $(TCC) -MDd
|
||||
BCC = $(BCC) -MDd
|
||||
!ELSE
|
||||
TCC = $(TCC) -MD
|
||||
BCC = $(BCC) -MD
|
||||
!ENDIF
|
||||
!ELSE
|
||||
!IF $(DEBUG)>1
|
||||
TCC = $(TCC) -MTd
|
||||
BCC = $(BCC) -MTd
|
||||
!ELSE
|
||||
TCC = $(TCC) -MT
|
||||
BCC = $(BCC) -MT
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Define -DNDEBUG to compile without debugging (i.e., for production usage)
|
||||
# Omitting the define will cause extra debugging code to be inserted and
|
||||
# includes extra comments when "EXPLAIN stmt" is used.
|
||||
#
|
||||
!IF $(DEBUG)==0
|
||||
TCC = $(TCC) -DNDEBUG
|
||||
BCC = $(BCC) -DNDEBUG
|
||||
RCC = $(RCC) -DNDEBUG
|
||||
!ENDIF
|
||||
|
||||
!IF $(DEBUG)>0 || $(API_ARMOR)!=0 || $(FOR_WIN10)!=0
|
||||
TCC = $(TCC) -DSQLITE_ENABLE_API_ARMOR=1
|
||||
RCC = $(RCC) -DSQLITE_ENABLE_API_ARMOR=1
|
||||
!ENDIF
|
||||
|
||||
!IF $(DEBUG)>2
|
||||
TCC = $(TCC) -DSQLITE_DEBUG=1
|
||||
RCC = $(RCC) -DSQLITE_DEBUG=1
|
||||
!ENDIF
|
||||
|
||||
!IF $(DEBUG)>4 || $(OSTRACE)!=0
|
||||
TCC = $(TCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
|
||||
RCC = $(RCC) -DSQLITE_FORCE_OS_TRACE=1 -DSQLITE_DEBUG_OS_TRACE=1
|
||||
!ENDIF
|
||||
|
||||
!IF $(DEBUG)>5
|
||||
TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE=1
|
||||
RCC = $(RCC) -DSQLITE_ENABLE_IOTRACE=1
|
||||
!ENDIF
|
||||
|
||||
# Prevent warnings about "insecure" MSVC runtime library functions
|
||||
# being used.
|
||||
#
|
||||
TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
|
||||
BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
|
||||
RCC = $(RCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS
|
||||
|
||||
# Prevent warnings about "deprecated" POSIX functions being used.
|
||||
#
|
||||
TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
|
||||
BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
|
||||
RCC = $(RCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS
|
||||
|
||||
# Use the SQLite debugging heap subsystem?
|
||||
#
|
||||
!IF $(MEMDEBUG)!=0
|
||||
TCC = $(TCC) -DSQLITE_MEMDEBUG=1
|
||||
RCC = $(RCC) -DSQLITE_MEMDEBUG=1
|
||||
|
||||
# Use native Win32 heap subsystem instead of malloc/free?
|
||||
#
|
||||
!ELSEIF $(WIN32HEAP)!=0
|
||||
TCC = $(TCC) -DSQLITE_WIN32_MALLOC=1
|
||||
RCC = $(RCC) -DSQLITE_WIN32_MALLOC=1
|
||||
|
||||
# Validate the heap on every call into the native Win32 heap subsystem?
|
||||
#
|
||||
!IF $(DEBUG)>3
|
||||
TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
|
||||
RCC = $(RCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Compiler options needed for programs that use the readline() library.
|
||||
#
|
||||
!IFNDEF READLINE_FLAGS
|
||||
READLINE_FLAGS = -DHAVE_READLINE=0
|
||||
!ENDIF
|
||||
|
||||
# The library that programs using readline() must link against.
|
||||
#
|
||||
!IFNDEF LIBREADLINE
|
||||
LIBREADLINE =
|
||||
!ENDIF
|
||||
|
||||
# Should the database engine be compiled threadsafe
|
||||
#
|
||||
TCC = $(TCC) -DSQLITE_THREADSAFE=1
|
||||
RCC = $(RCC) -DSQLITE_THREADSAFE=1
|
||||
|
||||
# Do threads override each others locks by default (1), or do we test (-1)
|
||||
#
|
||||
TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
|
||||
RCC = $(RCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1
|
||||
|
||||
# Any target libraries which libsqlite must be linked against
|
||||
#
|
||||
!IFNDEF TLIBS
|
||||
TLIBS =
|
||||
!ENDIF
|
||||
|
||||
# Flags controlling use of the in memory btree implementation
|
||||
#
|
||||
# SQLITE_TEMP_STORE is 0 to force temporary tables to be in a file, 1 to
|
||||
# default to file, 2 to default to memory, and 3 to force temporary
|
||||
# tables to always be in memory.
|
||||
#
|
||||
TCC = $(TCC) -DSQLITE_TEMP_STORE=1
|
||||
RCC = $(RCC) -DSQLITE_TEMP_STORE=1
|
||||
|
||||
# Enable/disable loadable extensions, and other optional features
|
||||
# based on configuration. (-DSQLITE_OMIT*, -DSQLITE_ENABLE*).
|
||||
# The same set of OMIT and ENABLE flags should be passed to the
|
||||
# LEMON parser generator and the mkkeywordhash tool as well.
|
||||
|
||||
# These are the required SQLite compilation options used when compiling for
|
||||
# the Windows platform.
|
||||
#
|
||||
REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_MAX_TRIGGER_DEPTH=100
|
||||
|
||||
# If we are linking to the RPCRT4 library, enable features that need it.
|
||||
#
|
||||
!IF $(USE_RPCRT4_LIB)!=0
|
||||
REQ_FEATURE_FLAGS = $(REQ_FEATURE_FLAGS) -DSQLITE_WIN32_USE_UUID=1
|
||||
!ENDIF
|
||||
|
||||
# Add the required and optional SQLite compilation options into the command
|
||||
# lines used to invoke the MSVC code and resource compilers.
|
||||
#
|
||||
TCC = $(TCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
|
||||
RCC = $(RCC) $(REQ_FEATURE_FLAGS) $(OPT_FEATURE_FLAGS) $(EXT_FEATURE_FLAGS)
|
||||
|
||||
# Add in any optional parameters specified on the commane line, e.g.
|
||||
# nmake /f Makefile.msc all "OPTS=-DSQLITE_ENABLE_FOO=1 -DSQLITE_OMIT_FOO=1"
|
||||
#
|
||||
TCC = $(TCC) $(OPTS)
|
||||
RCC = $(RCC) $(OPTS)
|
||||
|
||||
# If compiling for debugging, add some defines.
|
||||
#
|
||||
!IF $(DEBUG)>1
|
||||
TCC = $(TCC) -D_DEBUG
|
||||
BCC = $(BCC) -D_DEBUG
|
||||
RCC = $(RCC) -D_DEBUG
|
||||
!ENDIF
|
||||
|
||||
# If optimizations are enabled or disabled (either implicitly or
|
||||
# explicitly), add the necessary flags.
|
||||
#
|
||||
!IF $(DEBUG)>1 || $(OPTIMIZATIONS)==0
|
||||
TCC = $(TCC) -Od
|
||||
BCC = $(BCC) -Od
|
||||
!IF $(USE_RUNTIME_CHECKS)!=0
|
||||
TCC = $(TCC) -RTC1
|
||||
BCC = $(BCC) -RTC1
|
||||
!ENDIF
|
||||
!ELSEIF $(OPTIMIZATIONS)>=3
|
||||
TCC = $(TCC) -Ox
|
||||
BCC = $(BCC) -Ox
|
||||
!ELSEIF $(OPTIMIZATIONS)==2
|
||||
TCC = $(TCC) -O2
|
||||
BCC = $(BCC) -O2
|
||||
!ELSEIF $(OPTIMIZATIONS)==1
|
||||
TCC = $(TCC) -O1
|
||||
BCC = $(BCC) -O1
|
||||
!ENDIF
|
||||
|
||||
# If symbols are enabled (or compiling for debugging), enable PDBs.
|
||||
#
|
||||
!IF $(DEBUG)>1 || $(SYMBOLS)!=0
|
||||
TCC = $(TCC) -Zi
|
||||
BCC = $(BCC) -Zi
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Command line prefixes for compiling code, compiling resources,
|
||||
# linking, etc.
|
||||
#
|
||||
LTCOMPILE = $(TCC) -Fo$@
|
||||
LTRCOMPILE = $(RCC) -r
|
||||
LTLIB = lib.exe
|
||||
LTLINK = $(TCC) -Fe$@
|
||||
|
||||
# If requested, link to the RPCRT4 library.
|
||||
#
|
||||
!IF $(USE_RPCRT4_LIB)!=0
|
||||
LTLINK = $(LTLINK) rpcrt4.lib
|
||||
!ENDIF
|
||||
|
||||
# If a platform was set, force the linker to target that.
|
||||
# Note that the vcvars*.bat family of batch files typically
|
||||
# set this for you. Otherwise, the linker will attempt
|
||||
# to deduce the binary type based on the object files.
|
||||
!IFDEF PLATFORM
|
||||
LTLINKOPTS = /NOLOGO /MACHINE:$(PLATFORM)
|
||||
LTLIBOPTS = /NOLOGO /MACHINE:$(PLATFORM)
|
||||
!ELSE
|
||||
LTLINKOPTS = /NOLOGO
|
||||
LTLIBOPTS = /NOLOGO
|
||||
!ENDIF
|
||||
|
||||
# When compiling for use in the WinRT environment, the following
|
||||
# linker option must be used to mark the executable as runnable
|
||||
# only in the context of an application container.
|
||||
#
|
||||
!IF $(FOR_WINRT)!=0
|
||||
LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER
|
||||
!IF "$(VISUALSTUDIOVERSION)"=="12.0" || "$(VISUALSTUDIOVERSION)"=="14.0"
|
||||
!IFNDEF STORELIBPATH
|
||||
!IF "$(PLATFORM)"=="x86"
|
||||
STORELIBPATH = $(CRTLIBPATH)\store
|
||||
!ELSEIF "$(PLATFORM)"=="x64"
|
||||
STORELIBPATH = $(CRTLIBPATH)\store\amd64
|
||||
!ELSEIF "$(PLATFORM)"=="ARM"
|
||||
STORELIBPATH = $(CRTLIBPATH)\store\arm
|
||||
!ELSE
|
||||
STORELIBPATH = $(CRTLIBPATH)\store
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
STORELIBPATH = $(STORELIBPATH:\\=\)
|
||||
LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(STORELIBPATH)"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# When compiling for Windows Phone 8.1, an extra library path is
|
||||
# required.
|
||||
#
|
||||
!IF $(USE_WP81_OPTS)!=0
|
||||
!IFNDEF WP81LIBPATH
|
||||
!IF "$(PLATFORM)"=="x86"
|
||||
WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
|
||||
!ELSEIF "$(PLATFORM)"=="ARM"
|
||||
WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\ARM
|
||||
!ELSE
|
||||
WP81LIBPATH = $(PROGRAMFILES_X86)\Windows Phone Kits\8.1\lib\x86
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# When compiling for Windows Phone 8.1, some extra linker options
|
||||
# are also required.
|
||||
#
|
||||
!IF $(USE_WP81_OPTS)!=0
|
||||
!IFDEF WP81LIBPATH
|
||||
LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(WP81LIBPATH)"
|
||||
!ENDIF
|
||||
LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE
|
||||
LTLINKOPTS = $(LTLINKOPTS) WindowsPhoneCore.lib RuntimeObject.lib PhoneAppModelHost.lib
|
||||
LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:kernel32.lib /NODEFAULTLIB:ole32.lib
|
||||
!ENDIF
|
||||
|
||||
# When compiling for UWP or the Windows 10 platform, some extra linker
|
||||
# options are also required.
|
||||
#
|
||||
!IF $(FOR_UWP)!=0 || $(FOR_WIN10)!=0
|
||||
LTLINKOPTS = $(LTLINKOPTS) /DYNAMICBASE /NODEFAULTLIB:kernel32.lib
|
||||
LTLINKOPTS = $(LTLINKOPTS) mincore.lib
|
||||
!IFDEF PSDKLIBPATH
|
||||
LTLINKOPTS = $(LTLINKOPTS) "/LIBPATH:$(PSDKLIBPATH)"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
!IF $(FOR_WIN10)!=0
|
||||
LTLINKOPTS = $(LTLINKOPTS) /guard:cf "/LIBPATH:$(UCRTLIBPATH)"
|
||||
!IF $(DEBUG)>1
|
||||
LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrtd.lib /DEFAULTLIB:ucrtd.lib
|
||||
!ELSE
|
||||
LTLINKOPTS = $(LTLINKOPTS) /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
# If either debugging or symbols are enabled, enable PDBs.
|
||||
#
|
||||
!IF $(DEBUG)>1 || $(SYMBOLS)!=0
|
||||
LDFLAGS = /DEBUG $(LDOPTS)
|
||||
!ELSE
|
||||
LDFLAGS = $(LDOPTS)
|
||||
!ENDIF
|
||||
|
||||
|
||||
# You should not have to change anything below this line
|
||||
###############################################################################
|
||||
|
||||
|
||||
# Object files for the amalgamation.
|
||||
#
|
||||
LIBOBJS1 = sqlite3.lo
|
||||
|
||||
# Determine the real value of LIBOBJ based on the 'configure' script
|
||||
#
|
||||
LIBOBJ = $(LIBOBJS1)
|
||||
|
||||
# Determine if embedded resource compilation and usage are enabled.
|
||||
#
|
||||
!IF $(USE_RC)!=0
|
||||
LIBRESOBJS = sqlite3res.lo
|
||||
!ELSE
|
||||
LIBRESOBJS =
|
||||
!ENDIF
|
||||
|
||||
|
||||
# Additional compiler options for the shell. These are only effective
|
||||
# when the shell is not being dynamically linked.
|
||||
#
|
||||
!IF $(DYNAMIC_SHELL)==0 && $(FOR_WIN10)==0
|
||||
SHELL_COMPILE_OPTS = $(SHELL_COMPILE_OPTS) -DSQLITE_SHELL_JSON1 -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
|
||||
!ENDIF
|
||||
|
||||
|
||||
# This is the default Makefile target. The objects listed here
|
||||
# are what get build when you type just "make" with no arguments.
|
||||
#
|
||||
all: dll shell
|
||||
|
||||
# Dynamic link library section.
|
||||
#
|
||||
dll: $(SQLITE3DLL)
|
||||
|
||||
# Shell executable.
|
||||
#
|
||||
shell: $(SQLITE3EXE)
|
||||
|
||||
|
||||
$(SQLITE3DLL): $(LIBOBJ) $(LIBRESOBJS) $(CORE_LINK_DEP)
|
||||
$(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL $(CORE_LINK_OPTS) /OUT:$@ $(LIBOBJ) $(LIBRESOBJS) $(LTLIBS) $(TLIBS)
|
||||
|
||||
Replace.exe:
|
||||
$(CSC) /target:exe $(TOP)\Replace.cs
|
||||
|
||||
sqlite3.def: Replace.exe $(LIBOBJ)
|
||||
echo EXPORTS > sqlite3.def
|
||||
dumpbin /all $(LIBOBJ) \
|
||||
| .\Replace.exe "^\s+/EXPORT:_?(sqlite3_[^@,]*)(?:@\d+|,DATA)?$$" $$1 true \
|
||||
| sort >> sqlite3.def
|
||||
|
||||
$(SQLITE3EXE): $(TOP)\shell.c $(SHELL_CORE_DEP) $(LIBRESOBJS) $(SHELL_CORE_SRC) $(SQLITE3H)
|
||||
$(LTLINK) $(SHELL_COMPILE_OPTS) $(READLINE_FLAGS) $(TOP)\shell.c $(SHELL_CORE_SRC) \
|
||||
/link $(SQLITE3EXEPDB) $(LDFLAGS) $(LTLINKOPTS) $(SHELL_LINK_OPTS) $(LTLIBPATHS) $(LIBRESOBJS) $(LIBREADLINE) $(LTLIBS) $(TLIBS)
|
||||
|
||||
|
||||
# Rule to build the amalgamation
|
||||
#
|
||||
sqlite3.lo: $(SQLITE3C)
|
||||
$(LTCOMPILE) $(CORE_COMPILE_OPTS) -c $(SQLITE3C)
|
||||
|
||||
|
||||
# Rule to build the Win32 resources object file.
|
||||
#
|
||||
!IF $(USE_RC)!=0
|
||||
_HASHCHAR=^#
|
||||
!IF ![echo !IFNDEF VERSION > rcver.vc] && \
|
||||
![for /F "delims=" %V in ('type "$(SQLITE3H)" ^| find "$(_HASHCHAR)define SQLITE_VERSION "') do (echo VERSION = ^^%V >> rcver.vc)] && \
|
||||
![echo !ENDIF >> rcver.vc]
|
||||
!INCLUDE rcver.vc
|
||||
!ENDIF
|
||||
|
||||
RESOURCE_VERSION = $(VERSION:^#=)
|
||||
RESOURCE_VERSION = $(RESOURCE_VERSION:define=)
|
||||
RESOURCE_VERSION = $(RESOURCE_VERSION:SQLITE_VERSION=)
|
||||
RESOURCE_VERSION = $(RESOURCE_VERSION:"=)
|
||||
RESOURCE_VERSION = $(RESOURCE_VERSION:.=,)
|
||||
|
||||
$(LIBRESOBJS): $(TOP)\sqlite3.rc rcver.vc $(SQLITE3H)
|
||||
echo #ifndef SQLITE_RESOURCE_VERSION > sqlite3rc.h
|
||||
echo #define SQLITE_RESOURCE_VERSION $(RESOURCE_VERSION) >> sqlite3rc.h
|
||||
echo #endif >> sqlite3rc.h
|
||||
$(LTRCOMPILE) -fo $(LIBRESOBJS) -DRC_VERONLY $(TOP)\sqlite3.rc
|
||||
!ENDIF
|
||||
|
||||
|
||||
clean:
|
||||
del /Q *.exp *.lo *.ilk *.lib *.obj *.ncb *.pdb *.sdf *.suo 2>NUL
|
||||
del /Q *.bsc *.def *.cod *.da *.bb *.bbg *.vc gmon.out 2>NUL
|
||||
del /Q $(SQLITE3EXE) $(SQLITE3DLL) Replace.exe 2>NUL
|
223
contrib/sqlite3/Replace.cs
Normal file
223
contrib/sqlite3/Replace.cs
Normal file
@ -0,0 +1,223 @@
|
||||
/*
|
||||
** 2016 February 26
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** This file contains C# code to perform regular expression replacements
|
||||
** using the standard input and output channels.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#region Assembly Metadata
|
||||
[assembly: AssemblyTitle("Replace Tool")]
|
||||
[assembly: AssemblyDescription("Replace text using standard input/output.")]
|
||||
[assembly: AssemblyCompany("SQLite Development Team")]
|
||||
[assembly: AssemblyProduct("SQLite")]
|
||||
[assembly: AssemblyCopyright("Public Domain")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: Guid("95a0513f-8863-48cd-a76f-cb80868cb578")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: AssemblyConfiguration("Debug")]
|
||||
#else
|
||||
[assembly: AssemblyConfiguration("Release")]
|
||||
#endif
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace Replace
|
||||
{
|
||||
/// <summary>
|
||||
/// This enumeration is used to represent all the possible exit codes from
|
||||
/// this tool.
|
||||
/// </summary>
|
||||
internal enum ExitCode
|
||||
{
|
||||
/// <summary>
|
||||
/// The file download was a success.
|
||||
/// </summary>
|
||||
Success = 0,
|
||||
|
||||
/// <summary>
|
||||
/// The command line arguments are missing (i.e. null). Generally,
|
||||
/// this should not happen.
|
||||
/// </summary>
|
||||
MissingArgs = 1,
|
||||
|
||||
/// <summary>
|
||||
/// The wrong number of command line arguments was supplied.
|
||||
/// </summary>
|
||||
WrongNumArgs = 2,
|
||||
|
||||
/// <summary>
|
||||
/// The "matchingOnly" flag could not be converted to a value of the
|
||||
/// <see cref="Boolean"/> type.
|
||||
/// </summary>
|
||||
BadMatchingOnlyFlag = 3,
|
||||
|
||||
/// <summary>
|
||||
/// An exception was caught in <see cref="Main" />. Generally, this
|
||||
/// should not happen.
|
||||
/// </summary>
|
||||
Exception = 4
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
internal static class Replace
|
||||
{
|
||||
#region Private Support Methods
|
||||
/// <summary>
|
||||
/// This method displays an error message to the console and/or
|
||||
/// displays the command line usage information for this tool.
|
||||
/// </summary>
|
||||
/// <param name="message">
|
||||
/// The error message to display, if any.
|
||||
/// </param>
|
||||
/// <param name="usage">
|
||||
/// Non-zero to display the command line usage information.
|
||||
/// </param>
|
||||
private static void Error(
|
||||
string message,
|
||||
bool usage
|
||||
)
|
||||
{
|
||||
if (message != null)
|
||||
Console.WriteLine(message);
|
||||
|
||||
string fileName = Path.GetFileName(
|
||||
Process.GetCurrentProcess().MainModule.FileName);
|
||||
|
||||
Console.WriteLine(String.Format(
|
||||
"usage: {0} <regExPattern> <regExSubSpec> <matchingOnly>",
|
||||
fileName));
|
||||
}
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
#region Program Entry Point
|
||||
/// <summary>
|
||||
/// This is the entry-point for this tool. It handles processing the
|
||||
/// command line arguments, reading from the standard input channel,
|
||||
/// replacing any matching lines of text, and writing to the standard
|
||||
/// output channel.
|
||||
/// </summary>
|
||||
/// <param name="args">
|
||||
/// The command line arguments.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// Zero upon success; non-zero on failure. This will be one of the
|
||||
/// values from the <see cref="ExitCode" /> enumeration.
|
||||
/// </returns>
|
||||
private static int Main(
|
||||
string[] args
|
||||
)
|
||||
{
|
||||
//
|
||||
// NOTE: Sanity check the command line arguments.
|
||||
//
|
||||
if (args == null)
|
||||
{
|
||||
Error(null, true);
|
||||
return (int)ExitCode.MissingArgs;
|
||||
}
|
||||
|
||||
if (args.Length != 3)
|
||||
{
|
||||
Error(null, true);
|
||||
return (int)ExitCode.WrongNumArgs;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
//
|
||||
// NOTE: Create a regular expression from the first command
|
||||
// line argument. Then, grab the replacement string,
|
||||
// which is the second argument.
|
||||
//
|
||||
Regex regEx = new Regex(args[0]);
|
||||
string replacement = args[1];
|
||||
|
||||
//
|
||||
// NOTE: Attempt to convert the third argument to a boolean.
|
||||
//
|
||||
bool matchingOnly;
|
||||
|
||||
if (!bool.TryParse(args[2], out matchingOnly))
|
||||
{
|
||||
Error(null, true);
|
||||
return (int)ExitCode.BadMatchingOnlyFlag;
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE: Grab the standard input and output channels from the
|
||||
// console.
|
||||
//
|
||||
TextReader inputTextReader = Console.In;
|
||||
TextWriter outputTextWriter = Console.Out;
|
||||
|
||||
//
|
||||
// NOTE: Loop until end-of-file is hit on the standard input
|
||||
// stream.
|
||||
//
|
||||
while (true)
|
||||
{
|
||||
//
|
||||
// NOTE: Read a line from the standard input channel. If
|
||||
// null is returned here, there is no more input and
|
||||
// we are done.
|
||||
//
|
||||
string inputLine = inputTextReader.ReadLine();
|
||||
|
||||
if (inputLine == null)
|
||||
break;
|
||||
|
||||
//
|
||||
// NOTE: Perform regular expression replacements on this
|
||||
// line, if any. Then, write the modified line to
|
||||
// the standard output channel.
|
||||
//
|
||||
string outputLine = regEx.Replace(inputLine, replacement);
|
||||
|
||||
if (!matchingOnly || !String.Equals(
|
||||
inputLine, outputLine, StringComparison.Ordinal))
|
||||
{
|
||||
outputTextWriter.WriteLine(outputLine);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// NOTE: At this point, everything has succeeded.
|
||||
//
|
||||
return (int)ExitCode.Success;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//
|
||||
// NOTE: An exception was caught. Report it via the console
|
||||
// and return failure.
|
||||
//
|
||||
Error(e.ToString(), false);
|
||||
return (int)ExitCode.Exception;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
347
contrib/sqlite3/compile
Executable file
347
contrib/sqlite3/compile
Executable file
@ -0,0 +1,347 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2012-10-14.11; # UTC
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# This file is maintained in Automake, please report
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
nl='
|
||||
'
|
||||
|
||||
# We need space, tab and new line, in precisely that order. Quoting is
|
||||
# there to prevent tools from complaining about whitespace usage.
|
||||
IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
case $file in
|
||||
/ | /[!/]*) # absolute file, and not a UNC file
|
||||
if test -z "$file_conv"; then
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
;;
|
||||
CYGWIN*)
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
file_conv=wine
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# func_cl_dashL linkdir
|
||||
# Make cl look for libraries in LINKDIR
|
||||
func_cl_dashL ()
|
||||
{
|
||||
func_file_conv "$1"
|
||||
if test -z "$lib_path"; then
|
||||
lib_path=$file
|
||||
else
|
||||
lib_path="$lib_path;$file"
|
||||
fi
|
||||
linker_opts="$linker_opts -LIBPATH:$file"
|
||||
}
|
||||
|
||||
# func_cl_dashl library
|
||||
# Do a library search-path lookup for cl
|
||||
func_cl_dashl ()
|
||||
{
|
||||
lib=$1
|
||||
found=no
|
||||
save_IFS=$IFS
|
||||
IFS=';'
|
||||
for dir in $lib_path $LIB
|
||||
do
|
||||
IFS=$save_IFS
|
||||
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.dll.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/$lib.lib"; then
|
||||
found=yes
|
||||
lib=$dir/$lib.lib
|
||||
break
|
||||
fi
|
||||
if test -f "$dir/lib$lib.a"; then
|
||||
found=yes
|
||||
lib=$dir/lib$lib.a
|
||||
break
|
||||
fi
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
if test "$found" != yes; then
|
||||
lib=$lib.lib
|
||||
fi
|
||||
}
|
||||
|
||||
# func_cl_wrapper cl arg...
|
||||
# Adjust compile command to suit cl
|
||||
func_cl_wrapper ()
|
||||
{
|
||||
# Assume a capable shell
|
||||
lib_path=
|
||||
shared=:
|
||||
linker_opts=
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.[oO][bB][jJ])
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fo"$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
func_file_conv "$2"
|
||||
set x "$@" -Fe"$file"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
-I)
|
||||
eat=1
|
||||
func_file_conv "$2" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-I*)
|
||||
func_file_conv "${1#-I}" mingw
|
||||
set x "$@" -I"$file"
|
||||
shift
|
||||
;;
|
||||
-l)
|
||||
eat=1
|
||||
func_cl_dashl "$2"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-l*)
|
||||
func_cl_dashl "${1#-l}"
|
||||
set x "$@" "$lib"
|
||||
shift
|
||||
;;
|
||||
-L)
|
||||
eat=1
|
||||
func_cl_dashL "$2"
|
||||
;;
|
||||
-L*)
|
||||
func_cl_dashL "${1#-L}"
|
||||
;;
|
||||
-static)
|
||||
shared=false
|
||||
;;
|
||||
-Wl,*)
|
||||
arg=${1#-Wl,}
|
||||
save_ifs="$IFS"; IFS=','
|
||||
for flag in $arg; do
|
||||
IFS="$save_ifs"
|
||||
linker_opts="$linker_opts $flag"
|
||||
done
|
||||
IFS="$save_ifs"
|
||||
;;
|
||||
-Xlinker)
|
||||
eat=1
|
||||
linker_opts="$linker_opts $2"
|
||||
;;
|
||||
-*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||
func_file_conv "$1"
|
||||
set x "$@" -Tp"$file"
|
||||
shift
|
||||
;;
|
||||
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||
func_file_conv "$1" mingw
|
||||
set x "$@" "$file"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
if test -n "$linker_opts"; then
|
||||
linker_opts="-link$linker_opts"
|
||||
fi
|
||||
exec "$@" $linker_opts
|
||||
exit 1
|
||||
}
|
||||
|
||||
eat=
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Wrapper for compilers which do not understand '-c -o'.
|
||||
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||
arguments, and rename the output as expected.
|
||||
|
||||
If you are trying to build a whole package this is not the
|
||||
right script to run: please start by reading the file 'INSTALL'.
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit $?
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "compile $scriptversion"
|
||||
exit $?
|
||||
;;
|
||||
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
|
||||
func_cl_wrapper "$@" # Doesn't return...
|
||||
;;
|
||||
esac
|
||||
|
||||
ofile=
|
||||
cfile=
|
||||
|
||||
for arg
|
||||
do
|
||||
if test -n "$eat"; then
|
||||
eat=
|
||||
else
|
||||
case $1 in
|
||||
-o)
|
||||
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||
# So we strip '-o arg' only if arg is an object.
|
||||
eat=1
|
||||
case $2 in
|
||||
*.o | *.obj)
|
||||
ofile=$2
|
||||
;;
|
||||
*)
|
||||
set x "$@" -o "$2"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*.c)
|
||||
cfile=$1
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set x "$@" "$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
if test -z "$ofile" || test -z "$cfile"; then
|
||||
# If no '-o' option was seen then we might have been invoked from a
|
||||
# pattern rule where we don't need one. That is ok -- this is a
|
||||
# normal compilation that the losing compiler can handle. If no
|
||||
# '.c' file was seen then we are probably linking. That is also
|
||||
# ok.
|
||||
exec "$@"
|
||||
fi
|
||||
|
||||
# Name of file we expect compiler to create.
|
||||
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||
|
||||
# Create the lock directory.
|
||||
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||
# that we are using for the .o file. Also, base the name on the expected
|
||||
# object file name, since that is what matters with a parallel build.
|
||||
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||
while true; do
|
||||
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
done
|
||||
# FIXME: race condition here if user kills between mkdir and trap.
|
||||
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||
|
||||
# Run the compile.
|
||||
"$@"
|
||||
ret=$?
|
||||
|
||||
if test -f "$cofile"; then
|
||||
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||
elif test -f "${cofile}bj"; then
|
||||
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||
fi
|
||||
|
||||
rmdir "$lockdir"
|
||||
exit $ret
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
241
contrib/sqlite3/configure
vendored
241
contrib/sqlite3/configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.12.1.
|
||||
# Generated by GNU Autoconf 2.69 for sqlite 3.14.1.
|
||||
#
|
||||
# Report bugs to <http://www.sqlite.org>.
|
||||
#
|
||||
@ -590,8 +590,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='sqlite'
|
||||
PACKAGE_TARNAME='sqlite'
|
||||
PACKAGE_VERSION='3.12.1'
|
||||
PACKAGE_STRING='sqlite 3.12.1'
|
||||
PACKAGE_VERSION='3.14.1'
|
||||
PACKAGE_STRING='sqlite 3.14.1'
|
||||
PACKAGE_BUGREPORT='http://www.sqlite.org'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -637,6 +637,7 @@ am__EXEEXT_TRUE
|
||||
LTLIBOBJS
|
||||
LIBOBJS
|
||||
EXTRA_SHELL_OBJ
|
||||
SESSION_FLAGS
|
||||
JSON1_FLAGS
|
||||
FTS5_FLAGS
|
||||
DYNAMIC_EXTENSION_FLAGS
|
||||
@ -776,6 +777,7 @@ enable_threadsafe
|
||||
enable_dynamic_extensions
|
||||
enable_fts5
|
||||
enable_json1
|
||||
enable_session
|
||||
enable_static_shell
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
@ -1328,7 +1330,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures sqlite 3.12.1 to adapt to many kinds of systems.
|
||||
\`configure' configures sqlite 3.14.1 to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1398,7 +1400,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of sqlite 3.12.1:";;
|
||||
short | recursive ) echo "Configuration of sqlite 3.14.1:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1425,6 +1427,7 @@ Optional Features:
|
||||
support loadable extensions [default=yes]
|
||||
--enable-fts5 include fts5 support [default=no]
|
||||
--enable-json1 include json1 support [default=no]
|
||||
--enable-session enable the session extension [default=no]
|
||||
--enable-static-shell statically link libsqlite3 into shell tool
|
||||
[default=yes]
|
||||
|
||||
@ -1518,7 +1521,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
sqlite configure 3.12.1
|
||||
sqlite configure 3.14.1
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@ -1838,11 +1841,102 @@ $as_echo "$ac_res" >&6; }
|
||||
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
||||
|
||||
} # ac_fn_c_check_decl
|
||||
|
||||
# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
|
||||
# -------------------------------------------------------
|
||||
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
|
||||
# the include files in INCLUDES and setting the cache variable VAR
|
||||
# accordingly.
|
||||
ac_fn_c_check_header_mongrel ()
|
||||
{
|
||||
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
|
||||
if eval \${$3+:} false; then :
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
|
||||
$as_echo_n "checking for $2... " >&6; }
|
||||
if eval \${$3+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
fi
|
||||
eval ac_res=\$$3
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
||||
$as_echo "$ac_res" >&6; }
|
||||
else
|
||||
# Is the header compilable?
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
|
||||
$as_echo_n "checking $2 usability... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
$4
|
||||
#include <$2>
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"; then :
|
||||
ac_header_compiler=yes
|
||||
else
|
||||
ac_header_compiler=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
|
||||
$as_echo "$ac_header_compiler" >&6; }
|
||||
|
||||
# Is the header present?
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
|
||||
$as_echo_n "checking $2 presence... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <$2>
|
||||
_ACEOF
|
||||
if ac_fn_c_try_cpp "$LINENO"; then :
|
||||
ac_header_preproc=yes
|
||||
else
|
||||
ac_header_preproc=no
|
||||
fi
|
||||
rm -f conftest.err conftest.i conftest.$ac_ext
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
|
||||
$as_echo "$ac_header_preproc" >&6; }
|
||||
|
||||
# So? What about this header?
|
||||
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
|
||||
yes:no: )
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
|
||||
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
|
||||
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
|
||||
;;
|
||||
no:yes:* )
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
|
||||
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
|
||||
$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
|
||||
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
|
||||
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
|
||||
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
|
||||
( $as_echo "## ------------------------------------ ##
|
||||
## Report this to http://www.sqlite.org ##
|
||||
## ------------------------------------ ##"
|
||||
) | sed "s/^/$as_me: WARNING: /" >&2
|
||||
;;
|
||||
esac
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
|
||||
$as_echo_n "checking for $2... " >&6; }
|
||||
if eval \${$3+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
eval "$3=\$ac_header_compiler"
|
||||
fi
|
||||
eval ac_res=\$$3
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
||||
$as_echo "$ac_res" >&6; }
|
||||
fi
|
||||
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
||||
|
||||
} # ac_fn_c_check_header_mongrel
|
||||
cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by sqlite $as_me 3.12.1, which was
|
||||
It was created by sqlite $as_me 3.14.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@ -2708,7 +2802,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='sqlite'
|
||||
VERSION='3.12.1'
|
||||
VERSION='3.14.1'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@ -12946,28 +13040,46 @@ ac_config_files="$ac_config_files Makefile sqlite3.pc"
|
||||
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------
|
||||
# Two options to enable readline compatible libraries:
|
||||
#
|
||||
# --enable-editline
|
||||
# --enable-readline
|
||||
#
|
||||
# Both are enabled by default. If, after command line processing both are
|
||||
# still enabled, the script searches for editline first and automatically
|
||||
# disables readline if it is found. So, to use readline explicitly, the
|
||||
# user must pass "--disable-editline". To disable command line editing
|
||||
# support altogether, "--disable-editline --disable-readline".
|
||||
#
|
||||
# When searching for either library, check for headers before libraries
|
||||
# as some distros supply packages that contain libraries but not header
|
||||
# files, which come as a separate development package.
|
||||
#
|
||||
# Check whether --enable-editline was given.
|
||||
if test "${enable_editline+set}" = set; then :
|
||||
enableval=$enable_editline;
|
||||
else
|
||||
enable_editline=yes
|
||||
fi
|
||||
|
||||
# Check whether --enable-readline was given.
|
||||
if test "${enable_readline+set}" = set; then :
|
||||
enableval=$enable_readline;
|
||||
else
|
||||
enable_readline=no
|
||||
fi
|
||||
|
||||
if test x"$enable_editline" != xno ; then
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readline" >&5
|
||||
|
||||
if test x"$enable_editline" != xno ; then :
|
||||
|
||||
for ac_header in editline/readline.h
|
||||
do :
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "editline/readline.h" "ac_cv_header_editline_readline_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_editline_readline_h" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_EDITLINE_READLINE_H 1
|
||||
_ACEOF
|
||||
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readline" >&5
|
||||
$as_echo_n "checking for library containing readline... " >&6; }
|
||||
if ${ac_cv_search_readline+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
@ -13020,25 +13132,38 @@ $as_echo "$ac_cv_search_readline" >&6; }
|
||||
ac_res=$ac_cv_search_readline
|
||||
if test "$ac_res" != no; then :
|
||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
||||
enable_readline=no
|
||||
else
|
||||
enable_editline=no
|
||||
fi
|
||||
|
||||
READLINE_LIBS=$LIBS
|
||||
if test x"$LIBS" != "x"; then
|
||||
|
||||
$as_echo "#define HAVE_EDITLINE 1" >>confdefs.h
|
||||
|
||||
else
|
||||
unset ac_cv_search_readline
|
||||
fi
|
||||
LIBS=$sLIBS
|
||||
READLINE_LIBS=$LIBS
|
||||
enable_readline=no
|
||||
|
||||
fi
|
||||
if test x"$enable_readline" != xno ; then
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
|
||||
|
||||
{ ac_cv_search_readline=; unset ac_cv_search_readline;}
|
||||
LIBS=$sLIBS
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
fi
|
||||
|
||||
if test x"$enable_readline" != xno ; then :
|
||||
|
||||
for ac_header in readline/readline.h
|
||||
do :
|
||||
ac_fn_c_check_header_mongrel "$LINENO" "readline/readline.h" "ac_cv_header_readline_readline_h" "$ac_includes_default"
|
||||
if test "x$ac_cv_header_readline_readline_h" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_READLINE_READLINE_H 1
|
||||
_ACEOF
|
||||
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetent" >&5
|
||||
$as_echo_n "checking for library containing tgetent... " >&6; }
|
||||
if ${ac_cv_search_tgetent+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
@ -13062,7 +13187,7 @@ return tgetent ();
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
for ac_lib in '' curses ncurses ncursesw; do
|
||||
for ac_lib in '' termcap curses ncurses ncursesw; do
|
||||
if test -z "$ac_lib"; then
|
||||
ac_res="none required"
|
||||
else
|
||||
@ -13094,7 +13219,7 @@ if test "$ac_res" != no; then :
|
||||
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readline" >&5
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing readline" >&5
|
||||
$as_echo_n "checking for library containing readline... " >&6; }
|
||||
if ${ac_cv_search_readline+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
@ -13118,7 +13243,7 @@ return readline ();
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
for ac_lib in '' readline; do
|
||||
for ac_lib in '' readline edit; do
|
||||
if test -z "$ac_lib"; then
|
||||
ac_res="none required"
|
||||
else
|
||||
@ -13148,25 +13273,23 @@ ac_res=$ac_cv_search_readline
|
||||
if test "$ac_res" != no; then :
|
||||
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
|
||||
|
||||
else
|
||||
enable_readline=no
|
||||
fi
|
||||
|
||||
for ac_func in readline
|
||||
do :
|
||||
ac_fn_c_check_func "$LINENO" "readline" "ac_cv_func_readline"
|
||||
if test "x$ac_cv_func_readline" = xyes; then :
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define HAVE_READLINE 1
|
||||
_ACEOF
|
||||
$as_echo "#define HAVE_READLINE 1" >>confdefs.h
|
||||
|
||||
READLINE_LIBS=$LIBS
|
||||
|
||||
fi
|
||||
|
||||
LIBS=$sLIBS
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
READLINE_LIBS=$LIBS
|
||||
LIBS=$sLIBS
|
||||
|
||||
fi
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
@ -13385,7 +13508,7 @@ else
|
||||
enable_fts5=no
|
||||
fi
|
||||
|
||||
if test x"$enable_fts5" == "xyes"; then
|
||||
if test x"$enable_fts5" = "xyes"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing log" >&5
|
||||
$as_echo_n "checking for library containing log... " >&6; }
|
||||
if ${ac_cv_search_log+:} false; then :
|
||||
@ -13457,12 +13580,28 @@ else
|
||||
enable_json1=no
|
||||
fi
|
||||
|
||||
if test x"$enable_json1" == "xyes"; then
|
||||
if test x"$enable_json1" = "xyes"; then
|
||||
JSON1_FLAGS=-DSQLITE_ENABLE_JSON1
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-session
|
||||
#
|
||||
# Check whether --enable-session was given.
|
||||
if test "${enable_session+set}" = set; then :
|
||||
enableval=$enable_session;
|
||||
else
|
||||
enable_session=no
|
||||
fi
|
||||
|
||||
if test x"$enable_session" = "xyes"; then
|
||||
SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
|
||||
fi
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-static-shell
|
||||
#
|
||||
@ -13473,7 +13612,7 @@ else
|
||||
enable_static_shell=yes
|
||||
fi
|
||||
|
||||
if test x"$enable_static_shell" == "xyes"; then
|
||||
if test x"$enable_static_shell" = "xyes"; then
|
||||
EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT
|
||||
else
|
||||
EXTRA_SHELL_OBJ=libsqlite3.la
|
||||
@ -14088,7 +14227,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by sqlite $as_me 3.12.1, which was
|
||||
This file was extended by sqlite $as_me 3.14.1, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -14145,7 +14284,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
sqlite config.status 3.12.1
|
||||
sqlite config.status 3.14.1
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#
|
||||
|
||||
AC_PREREQ(2.61)
|
||||
AC_INIT(sqlite, 3.12.1, http://www.sqlite.org)
|
||||
AC_INIT(sqlite, 3.14.1, http://www.sqlite.org)
|
||||
AC_CONFIG_SRCDIR([sqlite3.c])
|
||||
|
||||
# Use automake.
|
||||
@ -30,39 +30,52 @@ AC_FUNC_STRERROR_R
|
||||
AC_CONFIG_FILES([Makefile sqlite3.pc])
|
||||
AC_SUBST(BUILD_CFLAGS)
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
#-------------------------------------------------------------------------
|
||||
# Two options to enable readline compatible libraries:
|
||||
#
|
||||
# --enable-editline
|
||||
# --enable-readline
|
||||
#
|
||||
AC_ARG_ENABLE(editline, [AS_HELP_STRING(
|
||||
[--enable-editline],
|
||||
[use BSD libedit])],
|
||||
[], [enable_editline=yes])
|
||||
AC_ARG_ENABLE(readline, [AS_HELP_STRING(
|
||||
[--enable-readline],
|
||||
[use readline])],
|
||||
[], [enable_readline=no])
|
||||
if test x"$enable_editline" != xno ; then
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS([readline],[edit],[enable_readline=no],[enable_editline=no])
|
||||
READLINE_LIBS=$LIBS
|
||||
if test x"$LIBS" != "x"; then
|
||||
AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline)
|
||||
else
|
||||
unset ac_cv_search_readline
|
||||
fi
|
||||
LIBS=$sLIBS
|
||||
fi
|
||||
if test x"$enable_readline" != xno ; then
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(tgetent, curses ncurses ncursesw, [], [])
|
||||
AC_SEARCH_LIBS(readline, readline, [], [enable_readline=no])
|
||||
AC_CHECK_FUNCS(readline, [], [])
|
||||
READLINE_LIBS=$LIBS
|
||||
LIBS=$sLIBS
|
||||
fi
|
||||
# Both are enabled by default. If, after command line processing both are
|
||||
# still enabled, the script searches for editline first and automatically
|
||||
# disables readline if it is found. So, to use readline explicitly, the
|
||||
# user must pass "--disable-editline". To disable command line editing
|
||||
# support altogether, "--disable-editline --disable-readline".
|
||||
#
|
||||
# When searching for either library, check for headers before libraries
|
||||
# as some distros supply packages that contain libraries but not header
|
||||
# files, which come as a separate development package.
|
||||
#
|
||||
AC_ARG_ENABLE(editline, [AS_HELP_STRING([--enable-editline],[use BSD libedit])])
|
||||
AC_ARG_ENABLE(readline, [AS_HELP_STRING([--enable-readline],[use readline])])
|
||||
|
||||
AS_IF([ test x"$enable_editline" != xno ],[
|
||||
AC_CHECK_HEADERS([editline/readline.h],[
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS([readline],[edit],[
|
||||
AC_DEFINE([HAVE_EDITLINE],1,Define to use BSD editline)
|
||||
READLINE_LIBS=$LIBS
|
||||
enable_readline=no
|
||||
])
|
||||
AS_UNSET(ac_cv_search_readline)
|
||||
LIBS=$sLIBS
|
||||
])
|
||||
])
|
||||
|
||||
AS_IF([ test x"$enable_readline" != xno ],[
|
||||
AC_CHECK_HEADERS([readline/readline.h],[
|
||||
sLIBS=$LIBS
|
||||
LIBS=""
|
||||
AC_SEARCH_LIBS(tgetent, termcap curses ncurses ncursesw, [], [])
|
||||
AC_SEARCH_LIBS(readline,[readline edit], [
|
||||
AC_DEFINE([HAVE_READLINE],1,Define to use readline or wrapper)
|
||||
READLINE_LIBS=$LIBS
|
||||
])
|
||||
LIBS=$sLIBS
|
||||
])
|
||||
])
|
||||
|
||||
AC_SUBST(READLINE_LIBS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
@ -103,7 +116,7 @@ AC_SUBST(DYNAMIC_EXTENSION_FLAGS)
|
||||
AC_ARG_ENABLE(fts5, [AS_HELP_STRING(
|
||||
[--enable-fts5], [include fts5 support [default=no]])],
|
||||
[], [enable_fts5=no])
|
||||
if test x"$enable_fts5" == "xyes"; then
|
||||
if test x"$enable_fts5" = "xyes"; then
|
||||
AC_SEARCH_LIBS(log, m)
|
||||
FTS5_FLAGS=-DSQLITE_ENABLE_FTS5
|
||||
fi
|
||||
@ -116,12 +129,24 @@ AC_SUBST(FTS5_FLAGS)
|
||||
AC_ARG_ENABLE(json1, [AS_HELP_STRING(
|
||||
[--enable-json1], [include json1 support [default=no]])],
|
||||
[], [enable_json1=no])
|
||||
if test x"$enable_json1" == "xyes"; then
|
||||
if test x"$enable_json1" = "xyes"; then
|
||||
JSON1_FLAGS=-DSQLITE_ENABLE_JSON1
|
||||
fi
|
||||
AC_SUBST(JSON1_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-session
|
||||
#
|
||||
AC_ARG_ENABLE(session, [AS_HELP_STRING(
|
||||
[--enable-session], [enable the session extension [default=no]])],
|
||||
[], [enable_session=no])
|
||||
if test x"$enable_session" = "xyes"; then
|
||||
SESSION_FLAGS="-DSQLITE_ENABLE_SESSION -DSQLITE_ENABLE_PREUPDATE_HOOK"
|
||||
fi
|
||||
AC_SUBST(SESSION_FLAGS)
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# --enable-static-shell
|
||||
#
|
||||
@ -129,7 +154,7 @@ AC_ARG_ENABLE(static-shell, [AS_HELP_STRING(
|
||||
[--enable-static-shell],
|
||||
[statically link libsqlite3 into shell tool [default=yes]])],
|
||||
[], [enable_static_shell=yes])
|
||||
if test x"$enable_static_shell" == "xyes"; then
|
||||
if test x"$enable_static_shell" = "xyes"; then
|
||||
EXTRA_SHELL_OBJ=sqlite3-sqlite3.$OBJEXT
|
||||
else
|
||||
EXTRA_SHELL_OBJ=libsqlite3.la
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
83
contrib/sqlite3/sqlite3.rc
Normal file
83
contrib/sqlite3/sqlite3.rc
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
** 2012 September 2
|
||||
**
|
||||
** The author disclaims copyright to this source code. In place of
|
||||
** a legal notice, here is a blessing:
|
||||
**
|
||||
** May you do good and not evil.
|
||||
** May you find forgiveness for yourself and forgive others.
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
******************************************************************************
|
||||
**
|
||||
** This file contains code and resources that are specific to Windows.
|
||||
*/
|
||||
|
||||
#if !defined(_WIN32_WCE)
|
||||
#include "winresrc.h"
|
||||
#else
|
||||
#include "windows.h"
|
||||
#endif /* !defined(_WIN32_WCE) */
|
||||
|
||||
#if !defined(VS_FF_NONE)
|
||||
# define VS_FF_NONE 0x00000000L
|
||||
#endif /* !defined(VS_FF_NONE) */
|
||||
|
||||
#include "sqlite3.h"
|
||||
#include "sqlite3rc.h"
|
||||
|
||||
/*
|
||||
* English (U.S.) resources
|
||||
*/
|
||||
|
||||
#if defined(_WIN32)
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif /* defined(_WIN32) */
|
||||
|
||||
/*
|
||||
* Icon
|
||||
*/
|
||||
|
||||
#if !defined(RC_VERONLY)
|
||||
#define IDI_SQLITE 101
|
||||
|
||||
IDI_SQLITE ICON "..\\art\\sqlite370.ico"
|
||||
#endif /* !defined(RC_VERONLY) */
|
||||
|
||||
/*
|
||||
* Version
|
||||
*/
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION SQLITE_RESOURCE_VERSION
|
||||
PRODUCTVERSION SQLITE_RESOURCE_VERSION
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#if defined(_DEBUG)
|
||||
FILEFLAGS VS_FF_DEBUG
|
||||
#else
|
||||
FILEFLAGS VS_FF_NONE
|
||||
#endif /* defined(_DEBUG) */
|
||||
FILEOS VOS__WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "SQLite Development Team"
|
||||
VALUE "FileDescription", "SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine."
|
||||
VALUE "FileVersion", SQLITE_VERSION
|
||||
VALUE "InternalName", "sqlite3"
|
||||
VALUE "LegalCopyright", "http://www.sqlite.org/copyright.html"
|
||||
VALUE "ProductName", "SQLite"
|
||||
VALUE "ProductVersion", SQLITE_VERSION
|
||||
VALUE "SourceId", SQLITE_SOURCE_ID
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 0x4b0
|
||||
END
|
||||
END
|
@ -15,12 +15,10 @@
|
||||
** as extensions by SQLite should #include this file instead of
|
||||
** sqlite3.h.
|
||||
*/
|
||||
#ifndef _SQLITE3EXT_H_
|
||||
#define _SQLITE3EXT_H_
|
||||
#ifndef SQLITE3EXT_H
|
||||
#define SQLITE3EXT_H
|
||||
#include "sqlite3.h"
|
||||
|
||||
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
||||
|
||||
/*
|
||||
** The following structure holds pointers to all of the SQLite API
|
||||
** routines.
|
||||
@ -281,8 +279,21 @@ struct sqlite3_api_routines {
|
||||
int (*db_cacheflush)(sqlite3*);
|
||||
/* Version 3.12.0 and later */
|
||||
int (*system_errno)(sqlite3*);
|
||||
/* Version 3.14.0 and later */
|
||||
int (*trace_v2)(sqlite3*,unsigned,int(*)(unsigned,void*,void*,void*),void*);
|
||||
char *(*expanded_sql)(sqlite3_stmt*);
|
||||
};
|
||||
|
||||
/*
|
||||
** This is the function signature used for all extension entry points. It
|
||||
** is also defined in the file "loadext.c".
|
||||
*/
|
||||
typedef int (*sqlite3_loadext_entry)(
|
||||
sqlite3 *db, /* Handle to the database. */
|
||||
char **pzErrMsg, /* Used to set error string on failure. */
|
||||
const sqlite3_api_routines *pThunk /* Extension API function pointers. */
|
||||
);
|
||||
|
||||
/*
|
||||
** The following macros redefine the API routines so that they are
|
||||
** redirected through the global sqlite3_api structure.
|
||||
@ -526,6 +537,9 @@ struct sqlite3_api_routines {
|
||||
#define sqlite3_db_cacheflush sqlite3_api->db_cacheflush
|
||||
/* Version 3.12.0 and later */
|
||||
#define sqlite3_system_errno sqlite3_api->system_errno
|
||||
/* Version 3.14.0 and later */
|
||||
#define sqlite3_trace_v2 sqlite3_api->trace_v2
|
||||
#define sqlite3_expanded_sql sqlite3_api->expanded_sql
|
||||
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
|
||||
|
||||
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
|
||||
@ -543,4 +557,4 @@ struct sqlite3_api_routines {
|
||||
# define SQLITE_EXTENSION_INIT3 /*no-op*/
|
||||
#endif
|
||||
|
||||
#endif /* _SQLITE3EXT_H_ */
|
||||
#endif /* SQLITE3EXT_H */
|
||||
|
440
contrib/sqlite3/tea/Makefile.in
Normal file
440
contrib/sqlite3/tea/Makefile.in
Normal file
@ -0,0 +1,440 @@
|
||||
# Makefile.in --
|
||||
#
|
||||
# This file is a Makefile for Sample TEA Extension. If it has the name
|
||||
# "Makefile.in" then it is a template for a Makefile; to generate the
|
||||
# actual Makefile, run "./configure", which is a configuration script
|
||||
# generated by the "autoconf" program (constructs like "@foo@" will get
|
||||
# replaced in the actual Makefile.
|
||||
#
|
||||
# Copyright (c) 1999 Scriptics Corporation.
|
||||
# Copyright (c) 2002-2005 ActiveState Corporation.
|
||||
#
|
||||
# See the file "license.terms" for information on usage and redistribution
|
||||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
#
|
||||
# RCS: @(#) $Id: Makefile.in,v 1.59 2005/07/26 19:17:02 mdejong Exp $
|
||||
|
||||
#========================================================================
|
||||
# Add additional lines to handle any additional AC_SUBST cases that
|
||||
# have been added in a customized configure script.
|
||||
#========================================================================
|
||||
|
||||
#SAMPLE_NEW_VAR = @SAMPLE_NEW_VAR@
|
||||
|
||||
#========================================================================
|
||||
# Nothing of the variables below this line should need to be changed.
|
||||
# Please check the TARGETS section below to make sure the make targets
|
||||
# are correct.
|
||||
#========================================================================
|
||||
|
||||
#========================================================================
|
||||
# The names of the source files is defined in the configure script.
|
||||
# The object files are used for linking into the final library.
|
||||
# This will be used when a dist target is added to the Makefile.
|
||||
# It is not important to specify the directory, as long as it is the
|
||||
# $(srcdir) or in the generic, win or unix subdirectory.
|
||||
#========================================================================
|
||||
|
||||
PKG_SOURCES = @PKG_SOURCES@
|
||||
PKG_OBJECTS = @PKG_OBJECTS@
|
||||
|
||||
PKG_STUB_SOURCES = @PKG_STUB_SOURCES@
|
||||
PKG_STUB_OBJECTS = @PKG_STUB_OBJECTS@
|
||||
|
||||
#========================================================================
|
||||
# PKG_TCL_SOURCES identifies Tcl runtime files that are associated with
|
||||
# this package that need to be installed, if any.
|
||||
#========================================================================
|
||||
|
||||
PKG_TCL_SOURCES = @PKG_TCL_SOURCES@
|
||||
|
||||
#========================================================================
|
||||
# This is a list of public header files to be installed, if any.
|
||||
#========================================================================
|
||||
|
||||
PKG_HEADERS = @PKG_HEADERS@
|
||||
|
||||
#========================================================================
|
||||
# "PKG_LIB_FILE" refers to the library (dynamic or static as per
|
||||
# configuration options) composed of the named objects.
|
||||
#========================================================================
|
||||
|
||||
PKG_LIB_FILE = @PKG_LIB_FILE@
|
||||
PKG_STUB_LIB_FILE = @PKG_STUB_LIB_FILE@
|
||||
|
||||
lib_BINARIES = $(PKG_LIB_FILE)
|
||||
BINARIES = $(lib_BINARIES)
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
datarootdir = @datarootdir@
|
||||
datadir = @datadir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
|
||||
DESTDIR =
|
||||
|
||||
PKG_DIR = $(PACKAGE_NAME)$(PACKAGE_VERSION)
|
||||
pkgdatadir = $(datadir)/$(PKG_DIR)
|
||||
pkglibdir = $(libdir)/$(PKG_DIR)
|
||||
pkgincludedir = $(includedir)/$(PKG_DIR)
|
||||
|
||||
top_builddir = .
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
CC = @CC@
|
||||
CFLAGS_DEFAULT = @CFLAGS_DEFAULT@
|
||||
CFLAGS_WARNING = @CFLAGS_WARNING@
|
||||
CLEANFILES = @CLEANFILES@
|
||||
EXEEXT = @EXEEXT@
|
||||
LDFLAGS_DEFAULT = @LDFLAGS_DEFAULT@
|
||||
MAKE_LIB = @MAKE_LIB@
|
||||
MAKE_SHARED_LIB = @MAKE_SHARED_LIB@
|
||||
MAKE_STATIC_LIB = @MAKE_STATIC_LIB@
|
||||
MAKE_STUB_LIB = @MAKE_STUB_LIB@
|
||||
OBJEXT = @OBJEXT@
|
||||
RANLIB = @RANLIB@
|
||||
RANLIB_STUB = @RANLIB_STUB@
|
||||
SHLIB_CFLAGS = @SHLIB_CFLAGS@
|
||||
SHLIB_LD = @SHLIB_LD@
|
||||
SHLIB_LD_LIBS = @SHLIB_LD_LIBS@
|
||||
STLIB_LD = @STLIB_LD@
|
||||
#TCL_DEFS = @TCL_DEFS@
|
||||
TCL_BIN_DIR = @TCL_BIN_DIR@
|
||||
TCL_SRC_DIR = @TCL_SRC_DIR@
|
||||
#TK_BIN_DIR = @TK_BIN_DIR@
|
||||
#TK_SRC_DIR = @TK_SRC_DIR@
|
||||
|
||||
# This is no longer necessary even for packages that use private Tcl headers
|
||||
#TCL_TOP_DIR_NATIVE = @TCL_TOP_DIR_NATIVE@
|
||||
# Not used, but retained for reference of what libs Tcl required
|
||||
#TCL_LIBS = @TCL_LIBS@
|
||||
|
||||
#========================================================================
|
||||
# TCLLIBPATH seeds the auto_path in Tcl's init.tcl so we can test our
|
||||
# package without installing. The other environment variables allow us
|
||||
# to test against an uninstalled Tcl. Add special env vars that you
|
||||
# require for testing here (like TCLX_LIBRARY).
|
||||
#========================================================================
|
||||
|
||||
EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR)
|
||||
#EXTRA_PATH = $(top_builddir):$(TCL_BIN_DIR):$(TK_BIN_DIR)
|
||||
TCLLIBPATH = $(top_builddir)
|
||||
TCLSH_ENV = TCL_LIBRARY=`@CYGPATH@ $(TCL_SRC_DIR)/library` \
|
||||
@LD_LIBRARY_PATH_VAR@="$(EXTRA_PATH):$(@LD_LIBRARY_PATH_VAR@)" \
|
||||
PATH="$(EXTRA_PATH):$(PATH)" \
|
||||
TCLLIBPATH="$(TCLLIBPATH)"
|
||||
# TK_LIBRARY=`@CYGPATH@ $(TK_SRC_DIR)/library`
|
||||
|
||||
TCLSH_PROG = @TCLSH_PROG@
|
||||
TCLSH = $(TCLSH_ENV) $(TCLSH_PROG)
|
||||
|
||||
#WISH_PROG = @WISH_PROG@
|
||||
#WISH = $(TCLSH_ENV) $(WISH_PROG)
|
||||
|
||||
|
||||
SHARED_BUILD = @SHARED_BUILD@
|
||||
|
||||
INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ -I$(srcdir)/..
|
||||
#INCLUDES = @PKG_INCLUDES@ @TCL_INCLUDES@ @TK_INCLUDES@ @TK_XINCLUDES@
|
||||
|
||||
PKG_CFLAGS = @PKG_CFLAGS@
|
||||
|
||||
# TCL_DEFS is not strictly need here, but if you remove it, then you
|
||||
# must make sure that configure.in checks for the necessary components
|
||||
# that your library may use. TCL_DEFS can actually be a problem if
|
||||
# you do not compile with a similar machine setup as the Tcl core was
|
||||
# compiled with.
|
||||
#DEFS = $(TCL_DEFS) @DEFS@ $(PKG_CFLAGS)
|
||||
DEFS = @DEFS@ $(PKG_CFLAGS)
|
||||
|
||||
CONFIG_CLEAN_FILES = Makefile pkgIndex.tcl
|
||||
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LIBS = @PKG_LIBS@ @LIBS@
|
||||
AR = @AR@
|
||||
CFLAGS = @CFLAGS@
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
|
||||
#========================================================================
|
||||
# Start of user-definable TARGETS section
|
||||
#========================================================================
|
||||
|
||||
#========================================================================
|
||||
# TEA TARGETS. Please note that the "libraries:" target refers to platform
|
||||
# independent files, and the "binaries:" target inclues executable programs and
|
||||
# platform-dependent libraries. Modify these targets so that they install
|
||||
# the various pieces of your package. The make and install rules
|
||||
# for the BINARIES that you specified above have already been done.
|
||||
#========================================================================
|
||||
|
||||
all: binaries libraries doc
|
||||
|
||||
#========================================================================
|
||||
# The binaries target builds executable programs, Windows .dll's, unix
|
||||
# shared/static libraries, and any other platform-dependent files.
|
||||
# The list of targets to build for "binaries:" is specified at the top
|
||||
# of the Makefile, in the "BINARIES" variable.
|
||||
#========================================================================
|
||||
|
||||
binaries: $(BINARIES)
|
||||
|
||||
libraries:
|
||||
|
||||
|
||||
#========================================================================
|
||||
# Your doc target should differentiate from doc builds (by the developer)
|
||||
# and doc installs (see install-doc), which just install the docs on the
|
||||
# end user machine when building from source.
|
||||
#========================================================================
|
||||
|
||||
doc:
|
||||
@echo "If you have documentation to create, place the commands to"
|
||||
@echo "build the docs in the 'doc:' target. For example:"
|
||||
@echo " xml2nroff sample.xml > sample.n"
|
||||
@echo " xml2html sample.xml > sample.html"
|
||||
|
||||
install: all install-binaries install-libraries install-doc
|
||||
|
||||
install-binaries: binaries install-lib-binaries install-bin-binaries
|
||||
|
||||
#========================================================================
|
||||
# This rule installs platform-independent files, such as header files.
|
||||
# The list=...; for p in $$list handles the empty list case x-platform.
|
||||
#========================================================================
|
||||
|
||||
install-libraries: libraries
|
||||
@mkdir -p $(DESTDIR)$(includedir)
|
||||
@echo "Installing header files in $(DESTDIR)$(includedir)"
|
||||
@list='$(PKG_HEADERS)'; for i in $$list; do \
|
||||
echo "Installing $(srcdir)/$$i" ; \
|
||||
$(INSTALL_DATA) $(srcdir)/$$i $(DESTDIR)$(includedir) ; \
|
||||
done;
|
||||
|
||||
#========================================================================
|
||||
# Install documentation. Unix manpages should go in the $(mandir)
|
||||
# directory.
|
||||
#========================================================================
|
||||
|
||||
install-doc: doc
|
||||
@mkdir -p $(DESTDIR)$(mandir)/mann
|
||||
@echo "Installing documentation in $(DESTDIR)$(mandir)"
|
||||
@list='$(srcdir)/doc/*.n'; for i in $$list; do \
|
||||
echo "Installing $$i"; \
|
||||
rm -f $(DESTDIR)$(mandir)/mann/`basename $$i`; \
|
||||
$(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/mann ; \
|
||||
done
|
||||
|
||||
test: binaries libraries
|
||||
@echo "SQLite TEA distribution does not include tests"
|
||||
|
||||
shell: binaries libraries
|
||||
@$(TCLSH) $(SCRIPT)
|
||||
|
||||
gdb:
|
||||
$(TCLSH_ENV) gdb $(TCLSH_PROG) $(SCRIPT)
|
||||
|
||||
depend:
|
||||
|
||||
#========================================================================
|
||||
# $(PKG_LIB_FILE) should be listed as part of the BINARIES variable
|
||||
# mentioned above. That will ensure that this target is built when you
|
||||
# run "make binaries".
|
||||
#
|
||||
# The $(PKG_OBJECTS) objects are created and linked into the final
|
||||
# library. In most cases these object files will correspond to the
|
||||
# source files above.
|
||||
#========================================================================
|
||||
|
||||
$(PKG_LIB_FILE): $(PKG_OBJECTS)
|
||||
-rm -f $(PKG_LIB_FILE)
|
||||
${MAKE_LIB}
|
||||
$(RANLIB) $(PKG_LIB_FILE)
|
||||
|
||||
$(PKG_STUB_LIB_FILE): $(PKG_STUB_OBJECTS)
|
||||
-rm -f $(PKG_STUB_LIB_FILE)
|
||||
${MAKE_STUB_LIB}
|
||||
$(RANLIB_STUB) $(PKG_STUB_LIB_FILE)
|
||||
|
||||
#========================================================================
|
||||
# We need to enumerate the list of .c to .o lines here.
|
||||
#
|
||||
# In the following lines, $(srcdir) refers to the toplevel directory
|
||||
# containing your extension. If your sources are in a subdirectory,
|
||||
# you will have to modify the paths to reflect this:
|
||||
#
|
||||
# sample.$(OBJEXT): $(srcdir)/generic/sample.c
|
||||
# $(COMPILE) -c `@CYGPATH@ $(srcdir)/generic/sample.c` -o $@
|
||||
#
|
||||
# Setting the VPATH variable to a list of paths will cause the makefile
|
||||
# to look into these paths when resolving .c to .obj dependencies.
|
||||
# As necessary, add $(srcdir):$(srcdir)/compat:....
|
||||
#========================================================================
|
||||
|
||||
VPATH = $(srcdir):$(srcdir)/generic:$(srcdir)/unix:$(srcdir)/win
|
||||
|
||||
.c.@OBJEXT@:
|
||||
$(COMPILE) -c `@CYGPATH@ $<` -o $@
|
||||
|
||||
#========================================================================
|
||||
# Distribution creation
|
||||
# You may need to tweak this target to make it work correctly.
|
||||
#========================================================================
|
||||
|
||||
#COMPRESS = tar cvf $(PKG_DIR).tar $(PKG_DIR); compress $(PKG_DIR).tar
|
||||
COMPRESS = gtar zcvf $(PKG_DIR).tar.gz $(PKG_DIR)
|
||||
DIST_ROOT = /tmp/dist
|
||||
DIST_DIR = $(DIST_ROOT)/$(PKG_DIR)
|
||||
|
||||
dist-clean:
|
||||
rm -rf $(DIST_DIR) $(DIST_ROOT)/$(PKG_DIR).tar.*
|
||||
|
||||
dist: dist-clean
|
||||
mkdir -p $(DIST_DIR)
|
||||
cp -p $(srcdir)/README* $(srcdir)/license* \
|
||||
$(srcdir)/aclocal.m4 $(srcdir)/configure $(srcdir)/*.in \
|
||||
$(DIST_DIR)/
|
||||
chmod 664 $(DIST_DIR)/Makefile.in $(DIST_DIR)/aclocal.m4
|
||||
chmod 775 $(DIST_DIR)/configure $(DIST_DIR)/configure.in
|
||||
|
||||
for i in $(srcdir)/*.[ch]; do \
|
||||
if [ -f $$i ]; then \
|
||||
cp -p $$i $(DIST_DIR)/ ; \
|
||||
fi; \
|
||||
done;
|
||||
|
||||
mkdir $(DIST_DIR)/tclconfig
|
||||
cp $(srcdir)/tclconfig/install-sh $(srcdir)/tclconfig/tcl.m4 \
|
||||
$(DIST_DIR)/tclconfig/
|
||||
chmod 664 $(DIST_DIR)/tclconfig/tcl.m4
|
||||
chmod +x $(DIST_DIR)/tclconfig/install-sh
|
||||
|
||||
list='demos doc generic library mac tests unix win'; \
|
||||
for p in $$list; do \
|
||||
if test -d $(srcdir)/$$p ; then \
|
||||
mkdir $(DIST_DIR)/$$p; \
|
||||
cp -p $(srcdir)/$$p/*.* $(DIST_DIR)/$$p/; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
(cd $(DIST_ROOT); $(COMPRESS);)
|
||||
|
||||
#========================================================================
|
||||
# End of user-definable section
|
||||
#========================================================================
|
||||
|
||||
#========================================================================
|
||||
# Don't modify the file to clean here. Instead, set the "CLEANFILES"
|
||||
# variable in configure.in
|
||||
#========================================================================
|
||||
|
||||
clean:
|
||||
-test -z "$(BINARIES)" || rm -f $(BINARIES)
|
||||
-rm -f *.$(OBJEXT) core *.core
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean: clean
|
||||
-rm -f *.tab.c
|
||||
-rm -f $(CONFIG_CLEAN_FILES)
|
||||
-rm -f config.h config.cache config.log config.status
|
||||
|
||||
#========================================================================
|
||||
# Install binary object libraries. On Windows this includes both .dll and
|
||||
# .lib files. Because the .lib files are not explicitly listed anywhere,
|
||||
# we need to deduce their existence from the .dll file of the same name.
|
||||
# Library files go into the lib directory.
|
||||
# In addition, this will generate the pkgIndex.tcl
|
||||
# file in the install location (assuming it can find a usable tclsh shell)
|
||||
#
|
||||
# You should not have to modify this target.
|
||||
#========================================================================
|
||||
|
||||
install-lib-binaries: binaries
|
||||
@mkdir -p $(DESTDIR)$(pkglibdir)
|
||||
@list='$(lib_BINARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(pkglibdir)/$$p; \
|
||||
stub=`echo $$p|sed -e "s/.*\(stub\).*/\1/"`; \
|
||||
if test "x$$stub" = "xstub"; then \
|
||||
echo " $(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||
$(RANLIB_STUB) $(DESTDIR)$(pkglibdir)/$$p; \
|
||||
else \
|
||||
echo " $(RANLIB) $(DESTDIR)$(pkglibdir)/$$p"; \
|
||||
$(RANLIB) $(DESTDIR)$(pkglibdir)/$$p; \
|
||||
fi; \
|
||||
ext=`echo $$p|sed -e "s/.*\.//"`; \
|
||||
if test "x$$ext" = "xdll"; then \
|
||||
lib=`basename $$p|sed -e 's/.[^.]*$$//'`.lib; \
|
||||
if test -f $$lib; then \
|
||||
echo " $(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib"; \
|
||||
$(INSTALL_DATA) $$lib $(DESTDIR)$(pkglibdir)/$$lib; \
|
||||
fi; \
|
||||
fi; \
|
||||
fi; \
|
||||
done
|
||||
@list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
|
||||
if test -f $(srcdir)/$$p; then \
|
||||
destp=`basename $$p`; \
|
||||
echo " Install $$destp $(DESTDIR)$(pkglibdir)/$$destp"; \
|
||||
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(pkglibdir)/$$destp; \
|
||||
fi; \
|
||||
done
|
||||
@if test "x$(SHARED_BUILD)" = "x1"; then \
|
||||
echo " Install pkgIndex.tcl $(DESTDIR)$(pkglibdir)"; \
|
||||
$(INSTALL_DATA) pkgIndex.tcl $(DESTDIR)$(pkglibdir); \
|
||||
fi
|
||||
|
||||
#========================================================================
|
||||
# Install binary executables (e.g. .exe files and dependent .dll files)
|
||||
# This is for files that must go in the bin directory (located next to
|
||||
# wish and tclsh), like dependent .dll files on Windows.
|
||||
#
|
||||
# You should not have to modify this target, except to define bin_BINARIES
|
||||
# above if necessary.
|
||||
#========================================================================
|
||||
|
||||
install-bin-binaries: binaries
|
||||
@mkdir -p $(DESTDIR)$(bindir)
|
||||
@list='$(bin_BINARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p"; \
|
||||
$(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$p; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
.SUFFIXES: .c .$(OBJEXT)
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) \
|
||||
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
||||
|
||||
uninstall-binaries:
|
||||
list='$(lib_BINARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(pkglibdir)/$$p; \
|
||||
done
|
||||
list='$(PKG_TCL_SOURCES)'; for p in $$list; do \
|
||||
p=`basename $$p`; \
|
||||
rm -f $(DESTDIR)$(pkglibdir)/$$p; \
|
||||
done
|
||||
list='$(bin_BINARIES)'; for p in $$list; do \
|
||||
rm -f $(DESTDIR)$(bindir)/$$p; \
|
||||
done
|
||||
|
||||
.PHONY: all binaries clean depend distclean doc install libraries test
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
36
contrib/sqlite3/tea/README
Normal file
36
contrib/sqlite3/tea/README
Normal file
@ -0,0 +1,36 @@
|
||||
This is the SQLite extension for Tcl using the Tcl Extension
|
||||
Architecture (TEA). For additional information on SQLite see
|
||||
|
||||
http://www.sqlite.org/
|
||||
|
||||
|
||||
UNIX BUILD
|
||||
==========
|
||||
|
||||
Building under most UNIX systems is easy, just run the configure script
|
||||
and then run make. For more information about the build process, see
|
||||
the tcl/unix/README file in the Tcl src dist. The following minimal
|
||||
example will install the extension in the /opt/tcl directory.
|
||||
|
||||
$ cd sqlite-*-tea
|
||||
$ ./configure --prefix=/opt/tcl
|
||||
$ make
|
||||
$ make install
|
||||
|
||||
WINDOWS BUILD
|
||||
=============
|
||||
|
||||
The recommended method to build extensions under windows is to use the
|
||||
Msys + Mingw build process. This provides a Unix-style build while
|
||||
generating native Windows binaries. Using the Msys + Mingw build tools
|
||||
means that you can use the same configure script as per the Unix build
|
||||
to create a Makefile. See the tcl/win/README file for the URL of
|
||||
the Msys + Mingw download.
|
||||
|
||||
If you have VC++ then you may wish to use the files in the win
|
||||
subdirectory and build the extension using just VC++. These files have
|
||||
been designed to be as generic as possible but will require some
|
||||
additional maintenance by the project developer to synchronise with
|
||||
the TEA configure.in and Makefile.in files. Instructions for using the
|
||||
VC++ makefile are written in the first part of the Makefile.vc
|
||||
file.
|
9
contrib/sqlite3/tea/aclocal.m4
vendored
Normal file
9
contrib/sqlite3/tea/aclocal.m4
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
#
|
||||
# Include the TEA standard macro set
|
||||
#
|
||||
|
||||
builtin(include,tclconfig/tcl.m4)
|
||||
|
||||
#
|
||||
# Add here whatever m4 macros you want to define for your package
|
||||
#
|
9977
contrib/sqlite3/tea/configure
vendored
Executable file
9977
contrib/sqlite3/tea/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
201
contrib/sqlite3/tea/configure.ac
Normal file
201
contrib/sqlite3/tea/configure.ac
Normal file
@ -0,0 +1,201 @@
|
||||
#!/bin/bash -norc
|
||||
dnl This file is an input file used by the GNU "autoconf" program to
|
||||
dnl generate the file "configure", which is run during Tcl installation
|
||||
dnl to configure the system for the local environment.
|
||||
#
|
||||
# RCS: @(#) $Id: configure.in,v 1.43 2005/07/26 19:17:05 mdejong Exp $
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Sample configure.in for Tcl Extensions. The only places you should
|
||||
# need to modify this file are marked by the string __CHANGE__
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# __CHANGE__
|
||||
# Set your package name and version numbers here.
|
||||
#
|
||||
# This initializes the environment with PACKAGE_NAME and PACKAGE_VERSION
|
||||
# set as provided. These will also be added as -D defs in your Makefile
|
||||
# so you can encode the package version directly into the source files.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
AC_INIT([sqlite], [3.14.1])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Call TEA_INIT as the first TEA_ macro to set up initial vars.
|
||||
# This will define a ${TEA_PLATFORM} variable == "unix" or "windows"
|
||||
# as well as PKG_LIB_FILE and PKG_STUB_LIB_FILE.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_INIT([3.9])
|
||||
|
||||
AC_CONFIG_AUX_DIR(tclconfig)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Load the tclConfig.sh file
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_PATH_TCLCONFIG
|
||||
TEA_LOAD_TCLCONFIG
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Load the tkConfig.sh file if necessary (Tk extension)
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
#TEA_PATH_TKCONFIG
|
||||
#TEA_LOAD_TKCONFIG
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Handle the --prefix=... option by defaulting to what Tcl gave.
|
||||
# Must be called after TEA_LOAD_TCLCONFIG and before TEA_SETUP_COMPILER.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
TEA_PREFIX
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# Standard compiler checks.
|
||||
# This sets up CC by using the CC env var, or looks for gcc otherwise.
|
||||
# This also calls AC_PROG_CC, AC_PROG_INSTALL and a few others to create
|
||||
# the basic setup necessary to compile executables.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
TEA_SETUP_COMPILER
|
||||
|
||||
#-----------------------------------------------------------------------
|
||||
# __CHANGE__
|
||||
# Specify the C source files to compile in TEA_ADD_SOURCES,
|
||||
# public headers that need to be installed in TEA_ADD_HEADERS,
|
||||
# stub library C source files to compile in TEA_ADD_STUB_SOURCES,
|
||||
# and runtime Tcl library files in TEA_ADD_TCL_SOURCES.
|
||||
# This defines PKG(_STUB)_SOURCES, PKG(_STUB)_OBJECTS, PKG_HEADERS
|
||||
# and PKG_TCL_SOURCES.
|
||||
#-----------------------------------------------------------------------
|
||||
|
||||
TEA_ADD_SOURCES([tclsqlite3.c])
|
||||
TEA_ADD_HEADERS([])
|
||||
TEA_ADD_INCLUDES([-I\"`\${CYGPATH} \${srcdir}/generic`\"])
|
||||
TEA_ADD_LIBS([])
|
||||
TEA_ADD_CFLAGS([-DSQLITE_ENABLE_FTS3=1])
|
||||
TEA_ADD_CFLAGS([-DSQLITE_3_SUFFIX_ONLY=1])
|
||||
TEA_ADD_CFLAGS([-DSQLITE_ENABLE_RTREE=1])
|
||||
TEA_ADD_STUB_SOURCES([])
|
||||
TEA_ADD_TCL_SOURCES([])
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# The --with-system-sqlite causes the TCL bindings to SQLite to use
|
||||
# the system shared library for SQLite rather than statically linking
|
||||
# against its own private copy. This is dangerous and leads to
|
||||
# undersirable dependences and is not recommended.
|
||||
# Patchs from rmax.
|
||||
#--------------------------------------------------------------------
|
||||
AC_ARG_WITH([system-sqlite],
|
||||
[AC_HELP_STRING([--with-system-sqlite],
|
||||
[use a system-supplied libsqlite3 instead of the bundled one])],
|
||||
[], [with_system_sqlite=no])
|
||||
if test x$with_system_sqlite != xno; then
|
||||
AC_CHECK_HEADER([sqlite3.h],
|
||||
[AC_CHECK_LIB([sqlite3],[sqlite3_initialize],
|
||||
[AC_DEFINE(USE_SYSTEM_SQLITE)
|
||||
LIBS="$LIBS -lsqlite3"])])
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# __CHANGE__
|
||||
# Choose which headers you need. Extension authors should try very
|
||||
# hard to only rely on the Tcl public header files. Internal headers
|
||||
# contain private data structures and are subject to change without
|
||||
# notice.
|
||||
# This MUST be called after TEA_LOAD_TCLCONFIG / TEA_LOAD_TKCONFIG
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_PUBLIC_TCL_HEADERS
|
||||
#TEA_PRIVATE_TCL_HEADERS
|
||||
|
||||
#TEA_PUBLIC_TK_HEADERS
|
||||
#TEA_PRIVATE_TK_HEADERS
|
||||
#TEA_PATH_X
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check whether --enable-threads or --disable-threads was given.
|
||||
# This auto-enables if Tcl was compiled threaded.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_ENABLE_THREADS
|
||||
if test "${TCL_THREADS}" = "1" ; then
|
||||
AC_DEFINE(SQLITE_THREADSAFE, 1, [Trigger sqlite threadsafe build])
|
||||
# Not automatically added by Tcl because its assumed Tcl links to them,
|
||||
# but it may not if it isn't really a threaded build.
|
||||
TEA_ADD_LIBS([$THREADS_LIBS])
|
||||
else
|
||||
AC_DEFINE(SQLITE_THREADSAFE, 0, [Trigger sqlite non-threadsafe build])
|
||||
fi
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# The statement below defines a collection of symbols related to
|
||||
# building as a shared library instead of a static library.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_ENABLE_SHARED
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This macro figures out what flags to use with the compiler/linker
|
||||
# when building shared/static debug/optimized objects. This information
|
||||
# can be taken from the tclConfig.sh file, but this figures it all out.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_CONFIG_CFLAGS
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Set the default compiler switches based on the --enable-symbols option.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_ENABLE_SYMBOLS
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Everyone should be linking against the Tcl stub library. If you
|
||||
# can't for some reason, remove this definition. If you aren't using
|
||||
# stubs, you also need to modify the SHLIB_LD_LIBS setting below to
|
||||
# link against the non-stubbed Tcl library. Add Tk too if necessary.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
AC_DEFINE(USE_TCL_STUBS, 1, [Use Tcl stubs])
|
||||
#AC_DEFINE(USE_TK_STUBS, 1, [Use Tk stubs])
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Redefine fdatasync as fsync on systems that lack fdatasync
|
||||
#--------------------------------------------------------------------
|
||||
#
|
||||
#AC_CHECK_FUNC(fdatasync, , AC_DEFINE(fdatasync, fsync))
|
||||
# Check for library functions that SQLite can optionally use.
|
||||
AC_CHECK_FUNCS([fdatasync usleep fullfsync localtime_r gmtime_r])
|
||||
|
||||
AC_FUNC_STRERROR_R
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# This macro generates a line to use when building a library. It
|
||||
# depends on values set by the TEA_ENABLE_SHARED, TEA_ENABLE_SYMBOLS,
|
||||
# and TEA_LOAD_TCLCONFIG macros above.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_MAKE_LIB
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Determine the name of the tclsh and/or wish executables in the
|
||||
# Tcl and Tk build directories or the location they were installed
|
||||
# into. These paths are used to support running test cases only,
|
||||
# the Makefile should not be making use of these paths to generate
|
||||
# a pkgIndex.tcl file or anything else at extension build time.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
TEA_PROG_TCLSH
|
||||
#TEA_PROG_WISH
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Finally, substitute all of the various values into the Makefile.
|
||||
# You may alternatively have a special pkgIndex.tcl.in or other files
|
||||
# which require substituting th AC variables in. Include these here.
|
||||
#--------------------------------------------------------------------
|
||||
|
||||
AC_OUTPUT([Makefile pkgIndex.tcl])
|
15
contrib/sqlite3/tea/doc/sqlite3.n
Normal file
15
contrib/sqlite3/tea/doc/sqlite3.n
Normal file
@ -0,0 +1,15 @@
|
||||
.TH sqlite3 n 4.1 "Tcl-Extensions"
|
||||
.HS sqlite3 tcl
|
||||
.BS
|
||||
.SH NAME
|
||||
sqlite3 \- an interface to the SQLite3 database engine
|
||||
.SH SYNOPSIS
|
||||
\fBsqlite3\fI command_name ?filename?\fR
|
||||
.br
|
||||
.SH DESCRIPTION
|
||||
SQLite3 is a self-contains, zero-configuration, transactional SQL database
|
||||
engine. This extension provides an easy to use interface for accessing
|
||||
SQLite database files from Tcl.
|
||||
.PP
|
||||
For full documentation see \fIhttp://www.sqlite.org/\fR and
|
||||
in particular \fIhttp://www.sqlite.org/tclsqlite.html\fR.
|
4276
contrib/sqlite3/tea/generic/tclsqlite3.c
Normal file
4276
contrib/sqlite3/tea/generic/tclsqlite3.c
Normal file
File diff suppressed because it is too large
Load Diff
6
contrib/sqlite3/tea/license.terms
Normal file
6
contrib/sqlite3/tea/license.terms
Normal file
@ -0,0 +1,6 @@
|
||||
The author disclaims copyright to this source code. In place of
|
||||
a legal notice, here is a blessing:
|
||||
|
||||
May you do good and not evil.
|
||||
May you find forgiveness for yourself and forgive others.
|
||||
May you share freely, never taking more than you give.
|
7
contrib/sqlite3/tea/pkgIndex.tcl.in
Normal file
7
contrib/sqlite3/tea/pkgIndex.tcl.in
Normal file
@ -0,0 +1,7 @@
|
||||
#
|
||||
# Tcl package index file
|
||||
#
|
||||
# Note sqlite*3* init specifically
|
||||
#
|
||||
package ifneeded sqlite3 @PACKAGE_VERSION@ \
|
||||
[list load [file join $dir @PKG_LIB_FILE@] Sqlite3]
|
528
contrib/sqlite3/tea/tclconfig/install-sh
Normal file
528
contrib/sqlite3/tea/tclconfig/install-sh
Normal file
@ -0,0 +1,528 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2011-04-20.01; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch.
|
||||
|
||||
nl='
|
||||
'
|
||||
IFS=" "" $nl"
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit=${DOITPROG-}
|
||||
if test -z "$doit"; then
|
||||
doit_exec=exec
|
||||
else
|
||||
doit_exec=$doit
|
||||
fi
|
||||
|
||||
# Put in absolute file names if you don't have them in your path;
|
||||
# or use environment vars.
|
||||
|
||||
chgrpprog=${CHGRPPROG-chgrp}
|
||||
chmodprog=${CHMODPROG-chmod}
|
||||
chownprog=${CHOWNPROG-chown}
|
||||
cmpprog=${CMPPROG-cmp}
|
||||
cpprog=${CPPROG-cp}
|
||||
mkdirprog=${MKDIRPROG-mkdir}
|
||||
mvprog=${MVPROG-mv}
|
||||
rmprog=${RMPROG-rm}
|
||||
stripprog=${STRIPPROG-strip}
|
||||
|
||||
posix_glob='?'
|
||||
initialize_posix_glob='
|
||||
test "$posix_glob" != "?" || {
|
||||
if (set -f) 2>/dev/null; then
|
||||
posix_glob=
|
||||
else
|
||||
posix_glob=:
|
||||
fi
|
||||
}
|
||||
'
|
||||
|
||||
posix_mkdir=
|
||||
|
||||
# Desired mode of installed file.
|
||||
mode=0755
|
||||
|
||||
chgrpcmd=
|
||||
chmodcmd=$chmodprog
|
||||
chowncmd=
|
||||
mvcmd=$mvprog
|
||||
rmcmd="$rmprog -f"
|
||||
stripcmd=
|
||||
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dst_arg=
|
||||
|
||||
copy_on_change=false
|
||||
no_target_directory=
|
||||
|
||||
usage="\
|
||||
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
-c (ignored)
|
||||
-C install only if different (preserve the last data modification time)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-S $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
|
||||
RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test $# -ne 0; do
|
||||
case $1 in
|
||||
-c) ;;
|
||||
|
||||
-C) copy_on_change=true;;
|
||||
|
||||
-d) dir_arg=true;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift;;
|
||||
|
||||
--help) echo "$usage"; exit $?;;
|
||||
|
||||
-m) mode=$2
|
||||
case $mode in
|
||||
*' '* | *' '* | *'
|
||||
'* | *'*'* | *'?'* | *'['*)
|
||||
echo "$0: invalid mode: $mode" >&2
|
||||
exit 1;;
|
||||
esac
|
||||
shift;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift;;
|
||||
|
||||
-s) stripcmd=$stripprog;;
|
||||
|
||||
-S) stripcmd="$stripprog $2"
|
||||
shift;;
|
||||
|
||||
-t) dst_arg=$2
|
||||
shift;;
|
||||
|
||||
-T) no_target_directory=true;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit $?;;
|
||||
|
||||
--) shift
|
||||
break;;
|
||||
|
||||
-*) echo "$0: invalid option: $1" >&2
|
||||
exit 1;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
|
||||
# When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dst_arg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dst_arg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dst_arg=$arg
|
||||
done
|
||||
fi
|
||||
|
||||
if test $# -eq 0; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if test -z "$dir_arg"; then
|
||||
do_exit='(exit $ret); exit $ret'
|
||||
trap "ret=129; $do_exit" 1
|
||||
trap "ret=130; $do_exit" 2
|
||||
trap "ret=141; $do_exit" 13
|
||||
trap "ret=143; $do_exit" 15
|
||||
|
||||
# Set umask so as not to create temps with too-generous modes.
|
||||
# However, 'strip' requires both read and write access to temps.
|
||||
case $mode in
|
||||
# Optimize common cases.
|
||||
*644) cp_umask=133;;
|
||||
*755) cp_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw='% 200'
|
||||
fi
|
||||
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
|
||||
*)
|
||||
if test -z "$stripcmd"; then
|
||||
u_plus_rw=
|
||||
else
|
||||
u_plus_rw=,u+rw
|
||||
fi
|
||||
cp_umask=$mode$u_plus_rw;;
|
||||
esac
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
dstdir=$dst
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
else
|
||||
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dst_arg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dst_arg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dst_arg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dstdir=$dst
|
||||
dst=$dstdir/`basename "$src"`
|
||||
dstdir_status=0
|
||||
else
|
||||
# Prefer dirname, but fall back on a substitute if dirname fails.
|
||||
dstdir=`
|
||||
(dirname "$dst") 2>/dev/null ||
|
||||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
X"$dst" : 'X\(//\)[^/]' \| \
|
||||
X"$dst" : 'X\(//\)$' \| \
|
||||
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
|
||||
echo X"$dst" |
|
||||
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)[^/].*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\/\)$/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
/^X\(\/\).*/{
|
||||
s//\1/
|
||||
q
|
||||
}
|
||||
s/.*/./; q'
|
||||
`
|
||||
|
||||
test -d "$dstdir"
|
||||
dstdir_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
obsolete_mkdir_used=false
|
||||
|
||||
if test $dstdir_status != 0; then
|
||||
case $posix_mkdir in
|
||||
'')
|
||||
# Create intermediate dirs using mode 755 as modified by the umask.
|
||||
# This is like FreeBSD 'install' as of 1997-10-28.
|
||||
umask=`umask`
|
||||
case $stripcmd.$umask in
|
||||
# Optimize common cases.
|
||||
*[2367][2367]) mkdir_umask=$umask;;
|
||||
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
|
||||
|
||||
*[0-7])
|
||||
mkdir_umask=`expr $umask + 22 \
|
||||
- $umask % 100 % 40 + $umask % 20 \
|
||||
- $umask % 10 % 4 + $umask % 2
|
||||
`;;
|
||||
*) mkdir_umask=$umask,go-w;;
|
||||
esac
|
||||
|
||||
# With -d, create the new directory with the user-specified mode.
|
||||
# Otherwise, rely on $mkdir_umask.
|
||||
if test -n "$dir_arg"; then
|
||||
mkdir_mode=-m$mode
|
||||
else
|
||||
mkdir_mode=
|
||||
fi
|
||||
|
||||
posix_mkdir=false
|
||||
case $umask in
|
||||
*[123567][0-7][0-7])
|
||||
# POSIX mkdir -p sets u+wx bits regardless of umask, which
|
||||
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
|
||||
;;
|
||||
*)
|
||||
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
|
||||
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
|
||||
|
||||
if (umask $mkdir_umask &&
|
||||
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
|
||||
then
|
||||
if test -z "$dir_arg" || {
|
||||
# Check for POSIX incompatibilities with -m.
|
||||
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
|
||||
# other-writeable bit of parent directory when it shouldn't.
|
||||
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
|
||||
ls_ld_tmpdir=`ls -ld "$tmpdir"`
|
||||
case $ls_ld_tmpdir in
|
||||
d????-?r-*) different_mode=700;;
|
||||
d????-?--*) different_mode=755;;
|
||||
*) false;;
|
||||
esac &&
|
||||
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
|
||||
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
|
||||
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
|
||||
}
|
||||
}
|
||||
then posix_mkdir=:
|
||||
fi
|
||||
rmdir "$tmpdir/d" "$tmpdir"
|
||||
else
|
||||
# Remove any dirs left behind by ancient mkdir implementations.
|
||||
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
|
||||
fi
|
||||
trap '' 0;;
|
||||
esac;;
|
||||
esac
|
||||
|
||||
if
|
||||
$posix_mkdir && (
|
||||
umask $mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
|
||||
)
|
||||
then :
|
||||
else
|
||||
|
||||
# The umask is ridiculous, or mkdir does not conform to POSIX,
|
||||
# or it failed possibly due to a race condition. Create the
|
||||
# directory the slow way, step by step, checking for races as we go.
|
||||
|
||||
case $dstdir in
|
||||
/*) prefix='/';;
|
||||
-*) prefix='./';;
|
||||
*) prefix='';;
|
||||
esac
|
||||
|
||||
eval "$initialize_posix_glob"
|
||||
|
||||
oIFS=$IFS
|
||||
IFS=/
|
||||
$posix_glob set -f
|
||||
set fnord $dstdir
|
||||
shift
|
||||
$posix_glob set +f
|
||||
IFS=$oIFS
|
||||
|
||||
prefixes=
|
||||
|
||||
for d
|
||||
do
|
||||
test -z "$d" && continue
|
||||
|
||||
prefix=$prefix$d
|
||||
if test -d "$prefix"; then
|
||||
prefixes=
|
||||
else
|
||||
if $posix_mkdir; then
|
||||
(umask=$mkdir_umask &&
|
||||
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
|
||||
# Don't fail if two instances are running concurrently.
|
||||
test -d "$prefix" || exit 1
|
||||
else
|
||||
case $prefix in
|
||||
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
|
||||
*) qprefix=$prefix;;
|
||||
esac
|
||||
prefixes="$prefixes '$qprefix'"
|
||||
fi
|
||||
fi
|
||||
prefix=$prefix/
|
||||
done
|
||||
|
||||
if test -n "$prefixes"; then
|
||||
# Don't fail if two instances are running concurrently.
|
||||
(umask $mkdir_umask &&
|
||||
eval "\$doit_exec \$mkdirprog $prefixes") ||
|
||||
test -d "$dstdir" || exit 1
|
||||
obsolete_mkdir_used=true
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
|
||||
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
|
||||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
|
||||
else
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
|
||||
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
|
||||
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
|
||||
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
|
||||
|
||||
# If -C, don't bother to copy if it wouldn't change the file.
|
||||
if $copy_on_change &&
|
||||
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
|
||||
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
|
||||
|
||||
eval "$initialize_posix_glob" &&
|
||||
$posix_glob set -f &&
|
||||
set X $old && old=:$2:$4:$5:$6 &&
|
||||
set X $new && new=:$2:$4:$5:$6 &&
|
||||
$posix_glob set +f &&
|
||||
|
||||
test "$old" = "$new" &&
|
||||
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
|
||||
then
|
||||
rm -f "$dsttmp"
|
||||
else
|
||||
# Rename the file to the real destination.
|
||||
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
|
||||
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
{
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
test ! -f "$dst" ||
|
||||
$doit $rmcmd -f "$dst" 2>/dev/null ||
|
||||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
|
||||
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
|
||||
} ||
|
||||
{ echo "$0: cannot unlink or rename $dst" >&2
|
||||
(exit 1); exit 1
|
||||
}
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dst"
|
||||
}
|
||||
fi || exit 1
|
||||
|
||||
trap '' 0
|
||||
fi
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
4168
contrib/sqlite3/tea/tclconfig/tcl.m4
Normal file
4168
contrib/sqlite3/tea/tclconfig/tcl.m4
Normal file
File diff suppressed because it is too large
Load Diff
414
contrib/sqlite3/tea/win/makefile.vc
Normal file
414
contrib/sqlite3/tea/win/makefile.vc
Normal file
@ -0,0 +1,414 @@
|
||||
# makefile.vc -- -*- Makefile -*-
|
||||
#
|
||||
# Microsoft Visual C++ makefile for use with nmake.exe v1.62+ (VC++ 5.0+)
|
||||
#
|
||||
# This makefile is based upon the Tcl 8.4 Makefile.vc and modified to
|
||||
# make it suitable as a general package makefile. Look for the word EDIT
|
||||
# which marks sections that may need modification. As a minumum you will
|
||||
# need to change the PROJECT, DOTVERSION and DLLOBJS variables to values
|
||||
# relevant to your package.
|
||||
#
|
||||
# See the file "license.terms" for information on usage and redistribution
|
||||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
#
|
||||
# Copyright (c) 1995-1996 Sun Microsystems, Inc.
|
||||
# Copyright (c) 1998-2000 Ajuba Solutions.
|
||||
# Copyright (c) 2001 ActiveState Corporation.
|
||||
# Copyright (c) 2001-2002 David Gravereaux.
|
||||
# Copyright (c) 2003 Pat Thoyts
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
# RCS: @(#)$Id: makefile.vc,v 1.4 2004/07/26 08:22:05 patthoyts Exp $
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
!if !defined(MSDEVDIR) && !defined(MSVCDIR) && !defined(VCINSTALLDIR) && !defined(MSSDK) && !defined(WINDOWSSDKDIR)
|
||||
MSG = ^
|
||||
You will need to run vcvars32.bat from Developer Studio, first, to setup^
|
||||
the environment. Jump to this line to read the new instructions.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# HOW TO USE this makefile:
|
||||
#
|
||||
# 1) It is now necessary to have %MSVCDir% set in the environment. This is
|
||||
# used as a check to see if vcvars32.bat had been run prior to running
|
||||
# nmake or during the installation of Microsoft Visual C++, MSVCDir had
|
||||
# been set globally and the PATH adjusted. Either way is valid.
|
||||
#
|
||||
# You'll need to run vcvars32.bat contained in the MsDev's vc(98)/bin
|
||||
# directory to setup the proper environment, if needed, for your current
|
||||
# setup. This is a needed bootstrap requirement and allows the swapping of
|
||||
# different environments to be easier.
|
||||
#
|
||||
# 2) To use the Platform SDK (not expressly needed), run setenv.bat after
|
||||
# vcvars32.bat according to the instructions for it. This can also turn on
|
||||
# the 64-bit compiler, if your SDK has it.
|
||||
#
|
||||
# 3) Targets are:
|
||||
# all -- Builds everything.
|
||||
# <project> -- Builds the project (eg: nmake sample)
|
||||
# test -- Builds and runs the test suite.
|
||||
# install -- Installs the built binaries and libraries to $(INSTALLDIR)
|
||||
# in an appropriate subdirectory.
|
||||
# clean/realclean/distclean -- varying levels of cleaning.
|
||||
#
|
||||
# 4) Macros usable on the commandline:
|
||||
# INSTALLDIR=<path>
|
||||
# Sets where to install Tcl from the built binaries.
|
||||
# C:\Progra~1\Tcl is assumed when not specified.
|
||||
#
|
||||
# OPTS=static,msvcrt,staticpkg,threads,symbols,profile,loimpact,none
|
||||
# Sets special options for the core. The default is for none.
|
||||
# Any combination of the above may be used (comma separated).
|
||||
# 'none' will over-ride everything to nothing.
|
||||
#
|
||||
# static = Builds a static library of the core instead of a
|
||||
# dll. The shell will be static (and large), as well.
|
||||
# msvcrt = Effects the static option only to switch it from
|
||||
# using libcmt(d) as the C runtime [by default] to
|
||||
# msvcrt(d). This is useful for static embedding
|
||||
# support.
|
||||
# staticpkg = Effects the static option only to switch
|
||||
# tclshXX.exe to have the dde and reg extension linked
|
||||
# inside it.
|
||||
# threads = Turns on full multithreading support.
|
||||
# thrdalloc = Use the thread allocator (shared global free pool).
|
||||
# symbols = Adds symbols for step debugging.
|
||||
# profile = Adds profiling hooks. Map file is assumed.
|
||||
# loimpact = Adds a flag for how NT treats the heap to keep memory
|
||||
# in use, low. This is said to impact alloc performance.
|
||||
#
|
||||
# STATS=memdbg,compdbg,none
|
||||
# Sets optional memory and bytecode compiler debugging code added
|
||||
# to the core. The default is for none. Any combination of the
|
||||
# above may be used (comma separated). 'none' will over-ride
|
||||
# everything to nothing.
|
||||
#
|
||||
# memdbg = Enables the debugging memory allocator.
|
||||
# compdbg = Enables byte compilation logging.
|
||||
#
|
||||
# MACHINE=(IX86|IA64|ALPHA)
|
||||
# Set the machine type used for the compiler, linker, and
|
||||
# resource compiler. This hook is needed to tell the tools
|
||||
# when alternate platforms are requested. IX86 is the default
|
||||
# when not specified.
|
||||
#
|
||||
# TMP_DIR=<path>
|
||||
# OUT_DIR=<path>
|
||||
# Hooks to allow the intermediate and output directories to be
|
||||
# changed. $(OUT_DIR) is assumed to be
|
||||
# $(BINROOT)\(Release|Debug) based on if symbols are requested.
|
||||
# $(TMP_DIR) will de $(OUT_DIR)\<buildtype> by default.
|
||||
#
|
||||
# TESTPAT=<file>
|
||||
# Reads the tests requested to be run from this file.
|
||||
#
|
||||
# CFG_ENCODING=encoding
|
||||
# name of encoding for configuration information. Defaults
|
||||
# to cp1252
|
||||
#
|
||||
# 5) Examples:
|
||||
#
|
||||
# Basic syntax of calling nmake looks like this:
|
||||
# nmake [-nologo] -f makefile.vc [target|macrodef [target|macrodef] [...]]
|
||||
#
|
||||
# Standard (no frills)
|
||||
# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
|
||||
# Setting environment for using Microsoft Visual C++ tools.
|
||||
# c:\tcl_src\win\>nmake -f makefile.vc all
|
||||
# c:\tcl_src\win\>nmake -f makefile.vc install INSTALLDIR=c:\progra~1\tcl
|
||||
#
|
||||
# Building for Win64
|
||||
# c:\tcl_src\win\>c:\progra~1\micros~1\vc98\bin\vcvars32.bat
|
||||
# Setting environment for using Microsoft Visual C++ tools.
|
||||
# c:\tcl_src\win\>c:\progra~1\platfo~1\setenv.bat /pre64 /RETAIL
|
||||
# Targeting Windows pre64 RETAIL
|
||||
# c:\tcl_src\win\>nmake -f makefile.vc MACHINE=IA64
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
#==============================================================================
|
||||
###############################################################################
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
!if !exist("makefile.vc")
|
||||
MSG = ^
|
||||
You must run this makefile only from the directory it is in.^
|
||||
Please `cd` to its location first.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Project specific information (EDIT)
|
||||
#
|
||||
# You should edit this with the name and version of your project. This
|
||||
# information is used to generate the name of the package library and
|
||||
# it's install location.
|
||||
#
|
||||
# For example, the sample extension is going to build sample04.dll and
|
||||
# would install it into $(INSTALLDIR)\lib\sample04
|
||||
#
|
||||
# You need to specify the object files that need to be linked into your
|
||||
# binary here.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
PROJECT = sqlite3
|
||||
!include "rules.vc"
|
||||
|
||||
# nmakehelp -V <file> <tag> will search the file for tag, skips until a
|
||||
# number and returns all character until a character not in [0-9.ab]
|
||||
# is read.
|
||||
|
||||
!if [echo REM = This file is generated from Makefile.vc > versions.vc]
|
||||
!endif
|
||||
# get project version from row "AC_INIT([sqlite], [3.7.14])"
|
||||
!if [echo DOTVERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\configure.in AC_INIT >> versions.vc]
|
||||
!endif
|
||||
!include "versions.vc"
|
||||
|
||||
VERSION = $(DOTVERSION:.=)
|
||||
STUBPREFIX = $(PROJECT)stub
|
||||
|
||||
DLLOBJS = \
|
||||
$(TMP_DIR)\tclsqlite3.obj
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Target names and paths ( shouldn't need changing )
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
BINROOT = .
|
||||
ROOT = ..
|
||||
|
||||
PRJIMPLIB = $(OUT_DIR)\$(PROJECT)$(VERSION)$(SUFX).lib
|
||||
PRJLIBNAME = $(PROJECT)$(VERSION)$(SUFX).$(EXT)
|
||||
PRJLIB = $(OUT_DIR)\$(PRJLIBNAME)
|
||||
|
||||
PRJSTUBLIBNAME = $(STUBPREFIX)$(VERSION).lib
|
||||
PRJSTUBLIB = $(OUT_DIR)\$(PRJSTUBLIBNAME)
|
||||
|
||||
### Make sure we use backslash only.
|
||||
PRJ_INSTALL_DIR = $(_INSTALLDIR)\$(PROJECT)$(DOTVERSION)
|
||||
LIB_INSTALL_DIR = $(PRJ_INSTALL_DIR)
|
||||
BIN_INSTALL_DIR = $(PRJ_INSTALL_DIR)
|
||||
DOC_INSTALL_DIR = $(PRJ_INSTALL_DIR)
|
||||
SCRIPT_INSTALL_DIR = $(PRJ_INSTALL_DIR)
|
||||
INCLUDE_INSTALL_DIR = $(_TCLDIR)\include
|
||||
|
||||
### The following paths CANNOT have spaces in them.
|
||||
GENERICDIR = $(ROOT)\generic
|
||||
WINDIR = $(ROOT)\win
|
||||
LIBDIR = $(ROOT)\library
|
||||
DOCDIR = $(ROOT)\doc
|
||||
TOOLSDIR = $(ROOT)\tools
|
||||
COMPATDIR = $(ROOT)\compat
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Compile flags
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
!if !$(DEBUG)
|
||||
!if $(OPTIMIZING)
|
||||
### This cranks the optimization level to maximize speed
|
||||
cdebug = -O2 -Op -Gs
|
||||
!else
|
||||
cdebug =
|
||||
!endif
|
||||
!else if "$(MACHINE)" == "IA64"
|
||||
### Warnings are too many, can't support warnings into errors.
|
||||
cdebug = -Z7 -Od -GZ
|
||||
!else
|
||||
cdebug = -Z7 -WX -Od -GZ
|
||||
!endif
|
||||
|
||||
### Declarations common to all compiler options
|
||||
cflags = -nologo -c -W3 -YX -Fp$(TMP_DIR)^\
|
||||
|
||||
!if $(MSVCRT)
|
||||
!if $(DEBUG)
|
||||
crt = -MDd
|
||||
!else
|
||||
crt = -MD
|
||||
!endif
|
||||
!else
|
||||
!if $(DEBUG)
|
||||
crt = -MTd
|
||||
!else
|
||||
crt = -MT
|
||||
!endif
|
||||
!endif
|
||||
|
||||
INCLUDES = $(TCL_INCLUDES) -I"$(WINDIR)" -I"$(GENERICDIR)" \
|
||||
-I"$(ROOT)\.."
|
||||
BASE_CLFAGS = $(cflags) $(cdebug) $(crt) $(INCLUDES) \
|
||||
-DSQLITE_3_SUFFIX_ONLY=1 -DSQLITE_ENABLE_RTREE=1 \
|
||||
-DSQLITE_ENABLE_FTS3=1 -DSQLITE_OMIT_DEPRECATED=1
|
||||
CON_CFLAGS = $(cflags) $(cdebug) $(crt) -DCONSOLE -DSQLITE_ENABLE_FTS3=1
|
||||
TCL_CFLAGS = -DBUILD_sqlite -DUSE_TCL_STUBS \
|
||||
-DPACKAGE_VERSION="\"$(DOTVERSION)\"" $(BASE_CLFAGS) \
|
||||
$(OPTDEFINES)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Link flags
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
!if $(DEBUG)
|
||||
ldebug = -debug:full -debugtype:cv
|
||||
!else
|
||||
ldebug = -release -opt:ref -opt:icf,3
|
||||
!endif
|
||||
|
||||
### Declarations common to all linker options
|
||||
lflags = -nologo -machine:$(MACHINE) $(ldebug)
|
||||
|
||||
!if $(PROFILE)
|
||||
lflags = $(lflags) -profile
|
||||
!endif
|
||||
|
||||
!if $(ALIGN98_HACK) && !$(STATIC_BUILD)
|
||||
### Align sections for PE size savings.
|
||||
lflags = $(lflags) -opt:nowin98
|
||||
!else if !$(ALIGN98_HACK) && $(STATIC_BUILD)
|
||||
### Align sections for speed in loading by choosing the virtual page size.
|
||||
lflags = $(lflags) -align:4096
|
||||
!endif
|
||||
|
||||
!if $(LOIMPACT)
|
||||
lflags = $(lflags) -ws:aggressive
|
||||
!endif
|
||||
|
||||
dlllflags = $(lflags) -dll
|
||||
conlflags = $(lflags) -subsystem:console
|
||||
guilflags = $(lflags) -subsystem:windows
|
||||
baselibs = $(TCLSTUBLIB)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# TclTest flags
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
!IF "$(TESTPAT)" != ""
|
||||
TESTFLAGS = $(TESTFLAGS) -file $(TESTPAT)
|
||||
!ENDIF
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Project specific targets (EDIT)
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
all: setup $(PROJECT)
|
||||
$(PROJECT): setup $(PRJLIB)
|
||||
install: install-binaries install-libraries install-docs
|
||||
|
||||
# Tests need to ensure we load the right dll file we
|
||||
# have to handle the output differently on Win9x.
|
||||
#
|
||||
!if "$(OS)" == "Windows_NT" || "$(MSVCDIR)" == "IDE"
|
||||
test: setup $(PROJECT)
|
||||
set TCL_LIBRARY=$(ROOT)/library
|
||||
$(TCLSH) <<
|
||||
load $(PRJLIB:\=/)
|
||||
cd "$(ROOT)/tests"
|
||||
set argv "$(TESTFLAGS)"
|
||||
source all.tcl
|
||||
<<
|
||||
!else
|
||||
test: setup $(PROJECT)
|
||||
echo Please wait while the test results are collected
|
||||
set TCL_LIBRARY=$(ROOT)/library
|
||||
$(TCLSH) << >tests.log
|
||||
load $(PRJLIB:\=/)
|
||||
cd "$(ROOT)/tests"
|
||||
set argv "$(TESTFLAGS)"
|
||||
source all.tcl
|
||||
<<
|
||||
type tests.log | more
|
||||
!endif
|
||||
|
||||
setup:
|
||||
@if not exist $(OUT_DIR)\nul mkdir $(OUT_DIR)
|
||||
@if not exist $(TMP_DIR)\nul mkdir $(TMP_DIR)
|
||||
|
||||
$(PRJLIB): $(DLLOBJS)
|
||||
$(link32) $(dlllflags) -out:$@ $(baselibs) @<<
|
||||
$**
|
||||
<<
|
||||
-@del $*.exp
|
||||
|
||||
$(PRJSTUBLIB): $(PRJSTUBOBJS)
|
||||
$(lib32) -nologo -out:$@ $(PRJSTUBOBJS)
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Implicit rules
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
{$(WINDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
{$(GENERICDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
{$(COMPATDIR)}.c{$(TMP_DIR)}.obj::
|
||||
$(cc32) $(TCL_CFLAGS) -DBUILD_$(PROJECT) -Fo$(TMP_DIR)\ @<<
|
||||
$<
|
||||
<<
|
||||
|
||||
{$(WINDIR)}.rc{$(TMP_DIR)}.res:
|
||||
$(rc32) -fo $@ -r -i "$(GENERICDIR)" -D__WIN32__ \
|
||||
!if $(DEBUG)
|
||||
-d DEBUG \
|
||||
!endif
|
||||
!if $(TCL_THREADS)
|
||||
-d TCL_THREADS \
|
||||
!endif
|
||||
!if $(STATIC_BUILD)
|
||||
-d STATIC_BUILD \
|
||||
!endif
|
||||
$<
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES:.c .rc
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Installation. (EDIT)
|
||||
#
|
||||
# You may need to modify this section to reflect the final distribution
|
||||
# of your files and possibly to generate documentation.
|
||||
#
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
install-binaries:
|
||||
@echo Installing binaries to '$(SCRIPT_INSTALL_DIR)'
|
||||
@if not exist "$(SCRIPT_INSTALL_DIR)" mkdir "$(SCRIPT_INSTALL_DIR)"
|
||||
@$(CPY) $(PRJLIB) "$(SCRIPT_INSTALL_DIR)" >NUL
|
||||
|
||||
install-libraries:
|
||||
@echo Installing libraries to '$(SCRIPT_INSTALL_DIR)'
|
||||
@if exist $(LIBDIR) $(CPY) $(LIBDIR)\*.tcl "$(SCRIPT_INSTALL_DIR)"
|
||||
@echo Installing package index in '$(SCRIPT_INSTALL_DIR)'
|
||||
@type << >"$(SCRIPT_INSTALL_DIR)\pkgIndex.tcl"
|
||||
package ifneeded $(PROJECT) $(DOTVERSION) \
|
||||
[list load [file join $$dir $(PRJLIBNAME)] sqlite3]
|
||||
<<
|
||||
|
||||
install-docs:
|
||||
@echo Installing documentation files to '$(DOC_INSTALL_DIR)'
|
||||
@if exist $(DOCDIR) $(CPY) $(DOCDIR)\*.n "$(DOC_INSTALL_DIR)"
|
||||
|
||||
#---------------------------------------------------------------------
|
||||
# Clean up
|
||||
#---------------------------------------------------------------------
|
||||
|
||||
clean:
|
||||
@if exist $(TMP_DIR)\nul $(RMDIR) $(TMP_DIR)
|
||||
@if exist $(WINDIR)\version.vc del $(WINDIR)\version.vc
|
||||
|
||||
realclean: clean
|
||||
@if exist $(OUT_DIR)\nul $(RMDIR) $(OUT_DIR)
|
||||
|
||||
distclean: realclean
|
||||
@if exist $(WINDIR)\nmakehlp.exe del $(WINDIR)\nmakehlp.exe
|
||||
@if exist $(WINDIR)\nmakehlp.obj del $(WINDIR)\nmakehlp.obj
|
694
contrib/sqlite3/tea/win/nmakehlp.c
Normal file
694
contrib/sqlite3/tea/win/nmakehlp.c
Normal file
@ -0,0 +1,694 @@
|
||||
/*
|
||||
* ----------------------------------------------------------------------------
|
||||
* nmakehlp.c --
|
||||
*
|
||||
* This is used to fix limitations within nmake and the environment.
|
||||
*
|
||||
* Copyright (c) 2002 by David Gravereaux.
|
||||
* Copyright (c) 2006 by Pat Thoyts
|
||||
*
|
||||
* See the file "license.terms" for information on usage and redistribution of
|
||||
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#include <windows.h>
|
||||
#define NO_SHLWAPI_GDI
|
||||
#define NO_SHLWAPI_STREAM
|
||||
#define NO_SHLWAPI_REG
|
||||
#include <shlwapi.h>
|
||||
#pragma comment (lib, "user32.lib")
|
||||
#pragma comment (lib, "kernel32.lib")
|
||||
#pragma comment (lib, "shlwapi.lib")
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
/*
|
||||
* This library is required for x64 builds with _some_ versions of MSVC
|
||||
*/
|
||||
#if defined(_M_IA64) || defined(_M_AMD64)
|
||||
#if _MSC_VER >= 1400 && _MSC_VER < 1500
|
||||
#pragma comment(lib, "bufferoverflowU")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* ISO hack for dumb VC++ */
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* protos */
|
||||
|
||||
static int CheckForCompilerFeature(const char *option);
|
||||
static int CheckForLinkerFeature(const char *option);
|
||||
static int IsIn(const char *string, const char *substring);
|
||||
static int SubstituteFile(const char *substs, const char *filename);
|
||||
static int QualifyPath(const char *path);
|
||||
static const char *GetVersionFromFile(const char *filename, const char *match);
|
||||
static DWORD WINAPI ReadFromPipe(LPVOID args);
|
||||
|
||||
/* globals */
|
||||
|
||||
#define CHUNK 25
|
||||
#define STATICBUFFERSIZE 1000
|
||||
typedef struct {
|
||||
HANDLE pipe;
|
||||
char buffer[STATICBUFFERSIZE];
|
||||
} pipeinfo;
|
||||
|
||||
pipeinfo Out = {INVALID_HANDLE_VALUE, '\0'};
|
||||
pipeinfo Err = {INVALID_HANDLE_VALUE, '\0'};
|
||||
|
||||
/*
|
||||
* exitcodes: 0 == no, 1 == yes, 2 == error
|
||||
*/
|
||||
|
||||
int
|
||||
main(
|
||||
int argc,
|
||||
char *argv[])
|
||||
{
|
||||
char msg[300];
|
||||
DWORD dwWritten;
|
||||
int chars;
|
||||
|
||||
/*
|
||||
* Make sure children (cl.exe and link.exe) are kept quiet.
|
||||
*/
|
||||
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
||||
|
||||
/*
|
||||
* Make sure the compiler and linker aren't effected by the outside world.
|
||||
*/
|
||||
|
||||
SetEnvironmentVariable("CL", "");
|
||||
SetEnvironmentVariable("LINK", "");
|
||||
|
||||
if (argc > 1 && *argv[1] == '-') {
|
||||
switch (*(argv[1]+1)) {
|
||||
case 'c':
|
||||
if (argc != 3) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -c <compiler option>\n"
|
||||
"Tests for whether cl.exe supports an option\n"
|
||||
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 2;
|
||||
}
|
||||
return CheckForCompilerFeature(argv[2]);
|
||||
case 'l':
|
||||
if (argc != 3) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -l <linker option>\n"
|
||||
"Tests for whether link.exe supports an option\n"
|
||||
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 2;
|
||||
}
|
||||
return CheckForLinkerFeature(argv[2]);
|
||||
case 'f':
|
||||
if (argc == 2) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -f <string> <substring>\n"
|
||||
"Find a substring within another\n"
|
||||
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 2;
|
||||
} else if (argc == 3) {
|
||||
/*
|
||||
* If the string is blank, there is no match.
|
||||
*/
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
return IsIn(argv[2], argv[3]);
|
||||
}
|
||||
case 's':
|
||||
if (argc == 2) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -s <substitutions file> <file>\n"
|
||||
"Perform a set of string map type substutitions on a file\n"
|
||||
"exitcodes: 0\n",
|
||||
argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 2;
|
||||
}
|
||||
return SubstituteFile(argv[2], argv[3]);
|
||||
case 'V':
|
||||
if (argc != 4) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -V filename matchstring\n"
|
||||
"Extract a version from a file:\n"
|
||||
"eg: pkgIndex.tcl \"package ifneeded http\"",
|
||||
argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 0;
|
||||
}
|
||||
printf("%s\n", GetVersionFromFile(argv[2], argv[3]));
|
||||
return 0;
|
||||
case 'Q':
|
||||
if (argc != 3) {
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -Q path\n"
|
||||
"Emit the fully qualified path\n"
|
||||
"exitcodes: 0 == no, 1 == yes, 2 == error\n", argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars,
|
||||
&dwWritten, NULL);
|
||||
return 2;
|
||||
}
|
||||
return QualifyPath(argv[2]);
|
||||
}
|
||||
}
|
||||
chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"usage: %s -c|-f|-l|-Q|-s|-V ...\n"
|
||||
"This is a little helper app to equalize shell differences between WinNT and\n"
|
||||
"Win9x and get nmake.exe to accomplish its job.\n",
|
||||
argv[0]);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, chars, &dwWritten, NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int
|
||||
CheckForCompilerFeature(
|
||||
const char *option)
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
DWORD threadID;
|
||||
char msg[300];
|
||||
BOOL ok;
|
||||
HANDLE hProcess, h, pipeThreads[2];
|
||||
char cmdline[100];
|
||||
|
||||
hProcess = GetCurrentProcess();
|
||||
|
||||
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
||||
ZeroMemory(&si, sizeof(STARTUPINFO));
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
si.dwFlags = STARTF_USESTDHANDLES;
|
||||
si.hStdInput = INVALID_HANDLE_VALUE;
|
||||
|
||||
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = FALSE;
|
||||
|
||||
/*
|
||||
* Create a non-inheritible pipe.
|
||||
*/
|
||||
|
||||
CreatePipe(&Out.pipe, &h, &sa, 0);
|
||||
|
||||
/*
|
||||
* Dupe the write side, make it inheritible, and close the original.
|
||||
*/
|
||||
|
||||
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
|
||||
|
||||
/*
|
||||
* Same as above, but for the error side.
|
||||
*/
|
||||
|
||||
CreatePipe(&Err.pipe, &h, &sa, 0);
|
||||
DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
|
||||
|
||||
/*
|
||||
* Base command line.
|
||||
*/
|
||||
|
||||
lstrcpy(cmdline, "cl.exe -nologo -c -TC -Zs -X -Fp.\\_junk.pch ");
|
||||
|
||||
/*
|
||||
* Append our option for testing
|
||||
*/
|
||||
|
||||
lstrcat(cmdline, option);
|
||||
|
||||
/*
|
||||
* Filename to compile, which exists, but is nothing and empty.
|
||||
*/
|
||||
|
||||
lstrcat(cmdline, " .\\nul");
|
||||
|
||||
ok = CreateProcess(
|
||||
NULL, /* Module name. */
|
||||
cmdline, /* Command line. */
|
||||
NULL, /* Process handle not inheritable. */
|
||||
NULL, /* Thread handle not inheritable. */
|
||||
TRUE, /* yes, inherit handles. */
|
||||
DETACHED_PROCESS, /* No console for you. */
|
||||
NULL, /* Use parent's environment block. */
|
||||
NULL, /* Use parent's starting directory. */
|
||||
&si, /* Pointer to STARTUPINFO structure. */
|
||||
&pi); /* Pointer to PROCESS_INFORMATION structure. */
|
||||
|
||||
if (!ok) {
|
||||
DWORD err = GetLastError();
|
||||
int chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
|
||||
(300-chars), 0);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close our references to the write handles that have now been inherited.
|
||||
*/
|
||||
|
||||
CloseHandle(si.hStdOutput);
|
||||
CloseHandle(si.hStdError);
|
||||
|
||||
WaitForInputIdle(pi.hProcess, 5000);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
/*
|
||||
* Start the pipe reader threads.
|
||||
*/
|
||||
|
||||
pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
|
||||
pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
|
||||
|
||||
/*
|
||||
* Block waiting for the process to end.
|
||||
*/
|
||||
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
/*
|
||||
* Wait for our pipe to get done reading, should it be a little slow.
|
||||
*/
|
||||
|
||||
WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
|
||||
CloseHandle(pipeThreads[0]);
|
||||
CloseHandle(pipeThreads[1]);
|
||||
|
||||
/*
|
||||
* Look for the commandline warning code in both streams.
|
||||
* - in MSVC 6 & 7 we get D4002, in MSVC 8 we get D9002.
|
||||
*/
|
||||
|
||||
return !(strstr(Out.buffer, "D4002") != NULL
|
||||
|| strstr(Err.buffer, "D4002") != NULL
|
||||
|| strstr(Out.buffer, "D9002") != NULL
|
||||
|| strstr(Err.buffer, "D9002") != NULL
|
||||
|| strstr(Out.buffer, "D2021") != NULL
|
||||
|| strstr(Err.buffer, "D2021") != NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
CheckForLinkerFeature(
|
||||
const char *option)
|
||||
{
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
SECURITY_ATTRIBUTES sa;
|
||||
DWORD threadID;
|
||||
char msg[300];
|
||||
BOOL ok;
|
||||
HANDLE hProcess, h, pipeThreads[2];
|
||||
char cmdline[100];
|
||||
|
||||
hProcess = GetCurrentProcess();
|
||||
|
||||
ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
||||
ZeroMemory(&si, sizeof(STARTUPINFO));
|
||||
si.cb = sizeof(STARTUPINFO);
|
||||
si.dwFlags = STARTF_USESTDHANDLES;
|
||||
si.hStdInput = INVALID_HANDLE_VALUE;
|
||||
|
||||
ZeroMemory(&sa, sizeof(SECURITY_ATTRIBUTES));
|
||||
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
sa.lpSecurityDescriptor = NULL;
|
||||
sa.bInheritHandle = TRUE;
|
||||
|
||||
/*
|
||||
* Create a non-inheritible pipe.
|
||||
*/
|
||||
|
||||
CreatePipe(&Out.pipe, &h, &sa, 0);
|
||||
|
||||
/*
|
||||
* Dupe the write side, make it inheritible, and close the original.
|
||||
*/
|
||||
|
||||
DuplicateHandle(hProcess, h, hProcess, &si.hStdOutput, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
|
||||
|
||||
/*
|
||||
* Same as above, but for the error side.
|
||||
*/
|
||||
|
||||
CreatePipe(&Err.pipe, &h, &sa, 0);
|
||||
DuplicateHandle(hProcess, h, hProcess, &si.hStdError, 0, TRUE,
|
||||
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE);
|
||||
|
||||
/*
|
||||
* Base command line.
|
||||
*/
|
||||
|
||||
lstrcpy(cmdline, "link.exe -nologo ");
|
||||
|
||||
/*
|
||||
* Append our option for testing.
|
||||
*/
|
||||
|
||||
lstrcat(cmdline, option);
|
||||
|
||||
ok = CreateProcess(
|
||||
NULL, /* Module name. */
|
||||
cmdline, /* Command line. */
|
||||
NULL, /* Process handle not inheritable. */
|
||||
NULL, /* Thread handle not inheritable. */
|
||||
TRUE, /* yes, inherit handles. */
|
||||
DETACHED_PROCESS, /* No console for you. */
|
||||
NULL, /* Use parent's environment block. */
|
||||
NULL, /* Use parent's starting directory. */
|
||||
&si, /* Pointer to STARTUPINFO structure. */
|
||||
&pi); /* Pointer to PROCESS_INFORMATION structure. */
|
||||
|
||||
if (!ok) {
|
||||
DWORD err = GetLastError();
|
||||
int chars = snprintf(msg, sizeof(msg) - 1,
|
||||
"Tried to launch: \"%s\", but got error [%u]: ", cmdline, err);
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS|
|
||||
FORMAT_MESSAGE_MAX_WIDTH_MASK, 0L, err, 0, (LPVOID)&msg[chars],
|
||||
(300-chars), 0);
|
||||
WriteFile(GetStdHandle(STD_ERROR_HANDLE), msg, lstrlen(msg), &err,NULL);
|
||||
return 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Close our references to the write handles that have now been inherited.
|
||||
*/
|
||||
|
||||
CloseHandle(si.hStdOutput);
|
||||
CloseHandle(si.hStdError);
|
||||
|
||||
WaitForInputIdle(pi.hProcess, 5000);
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
/*
|
||||
* Start the pipe reader threads.
|
||||
*/
|
||||
|
||||
pipeThreads[0] = CreateThread(NULL, 0, ReadFromPipe, &Out, 0, &threadID);
|
||||
pipeThreads[1] = CreateThread(NULL, 0, ReadFromPipe, &Err, 0, &threadID);
|
||||
|
||||
/*
|
||||
* Block waiting for the process to end.
|
||||
*/
|
||||
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
/*
|
||||
* Wait for our pipe to get done reading, should it be a little slow.
|
||||
*/
|
||||
|
||||
WaitForMultipleObjects(2, pipeThreads, TRUE, 500);
|
||||
CloseHandle(pipeThreads[0]);
|
||||
CloseHandle(pipeThreads[1]);
|
||||
|
||||
/*
|
||||
* Look for the commandline warning code in the stderr stream.
|
||||
*/
|
||||
|
||||
return !(strstr(Out.buffer, "LNK1117") != NULL ||
|
||||
strstr(Err.buffer, "LNK1117") != NULL ||
|
||||
strstr(Out.buffer, "LNK4044") != NULL ||
|
||||
strstr(Err.buffer, "LNK4044") != NULL);
|
||||
}
|
||||
|
||||
static DWORD WINAPI
|
||||
ReadFromPipe(
|
||||
LPVOID args)
|
||||
{
|
||||
pipeinfo *pi = (pipeinfo *) args;
|
||||
char *lastBuf = pi->buffer;
|
||||
DWORD dwRead;
|
||||
BOOL ok;
|
||||
|
||||
again:
|
||||
if (lastBuf - pi->buffer + CHUNK > STATICBUFFERSIZE) {
|
||||
CloseHandle(pi->pipe);
|
||||
return (DWORD)-1;
|
||||
}
|
||||
ok = ReadFile(pi->pipe, lastBuf, CHUNK, &dwRead, 0L);
|
||||
if (!ok || dwRead == 0) {
|
||||
CloseHandle(pi->pipe);
|
||||
return 0;
|
||||
}
|
||||
lastBuf += dwRead;
|
||||
goto again;
|
||||
|
||||
return 0; /* makes the compiler happy */
|
||||
}
|
||||
|
||||
static int
|
||||
IsIn(
|
||||
const char *string,
|
||||
const char *substring)
|
||||
{
|
||||
return (strstr(string, substring) != NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* GetVersionFromFile --
|
||||
* Looks for a match string in a file and then returns the version
|
||||
* following the match where a version is anything acceptable to
|
||||
* package provide or package ifneeded.
|
||||
*/
|
||||
|
||||
static const char *
|
||||
GetVersionFromFile(
|
||||
const char *filename,
|
||||
const char *match)
|
||||
{
|
||||
size_t cbBuffer = 100;
|
||||
static char szBuffer[100];
|
||||
char *szResult = NULL;
|
||||
FILE *fp = fopen(filename, "rt");
|
||||
|
||||
if (fp != NULL) {
|
||||
/*
|
||||
* Read data until we see our match string.
|
||||
*/
|
||||
|
||||
while (fgets(szBuffer, cbBuffer, fp) != NULL) {
|
||||
LPSTR p, q;
|
||||
|
||||
p = strstr(szBuffer, match);
|
||||
if (p != NULL) {
|
||||
/*
|
||||
* Skip to first digit.
|
||||
*/
|
||||
|
||||
while (*p && !isdigit(*p)) {
|
||||
++p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find ending whitespace.
|
||||
*/
|
||||
|
||||
q = p;
|
||||
while (*q && (isalnum(*q) || *q == '.')) {
|
||||
++q;
|
||||
}
|
||||
|
||||
memcpy(szBuffer, p, q - p);
|
||||
szBuffer[q-p] = 0;
|
||||
szResult = szBuffer;
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
return szResult;
|
||||
}
|
||||
|
||||
/*
|
||||
* List helpers for the SubstituteFile function
|
||||
*/
|
||||
|
||||
typedef struct list_item_t {
|
||||
struct list_item_t *nextPtr;
|
||||
char * key;
|
||||
char * value;
|
||||
} list_item_t;
|
||||
|
||||
/* insert a list item into the list (list may be null) */
|
||||
static list_item_t *
|
||||
list_insert(list_item_t **listPtrPtr, const char *key, const char *value)
|
||||
{
|
||||
list_item_t *itemPtr = malloc(sizeof(list_item_t));
|
||||
if (itemPtr) {
|
||||
itemPtr->key = strdup(key);
|
||||
itemPtr->value = strdup(value);
|
||||
itemPtr->nextPtr = NULL;
|
||||
|
||||
while(*listPtrPtr) {
|
||||
listPtrPtr = &(*listPtrPtr)->nextPtr;
|
||||
}
|
||||
*listPtrPtr = itemPtr;
|
||||
}
|
||||
return itemPtr;
|
||||
}
|
||||
|
||||
static void
|
||||
list_free(list_item_t **listPtrPtr)
|
||||
{
|
||||
list_item_t *tmpPtr, *listPtr = *listPtrPtr;
|
||||
while (listPtr) {
|
||||
tmpPtr = listPtr;
|
||||
listPtr = listPtr->nextPtr;
|
||||
free(tmpPtr->key);
|
||||
free(tmpPtr->value);
|
||||
free(tmpPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* SubstituteFile --
|
||||
* As windows doesn't provide anything useful like sed and it's unreliable
|
||||
* to use the tclsh you are building against (consider x-platform builds -
|
||||
* eg compiling AMD64 target from IX86) we provide a simple substitution
|
||||
* option here to handle autoconf style substitutions.
|
||||
* The substitution file is whitespace and line delimited. The file should
|
||||
* consist of lines matching the regular expression:
|
||||
* \s*\S+\s+\S*$
|
||||
*
|
||||
* Usage is something like:
|
||||
* nmakehlp -S << $** > $@
|
||||
* @PACKAGE_NAME@ $(PACKAGE_NAME)
|
||||
* @PACKAGE_VERSION@ $(PACKAGE_VERSION)
|
||||
* <<
|
||||
*/
|
||||
|
||||
static int
|
||||
SubstituteFile(
|
||||
const char *substitutions,
|
||||
const char *filename)
|
||||
{
|
||||
size_t cbBuffer = 1024;
|
||||
static char szBuffer[1024], szCopy[1024];
|
||||
char *szResult = NULL;
|
||||
list_item_t *substPtr = NULL;
|
||||
FILE *fp, *sp;
|
||||
|
||||
fp = fopen(filename, "rt");
|
||||
if (fp != NULL) {
|
||||
|
||||
/*
|
||||
* Build a list of substutitions from the first filename
|
||||
*/
|
||||
|
||||
sp = fopen(substitutions, "rt");
|
||||
if (sp != NULL) {
|
||||
while (fgets(szBuffer, cbBuffer, sp) != NULL) {
|
||||
unsigned char *ks, *ke, *vs, *ve;
|
||||
ks = (unsigned char*)szBuffer;
|
||||
while (ks && *ks && isspace(*ks)) ++ks;
|
||||
ke = ks;
|
||||
while (ke && *ke && !isspace(*ke)) ++ke;
|
||||
vs = ke;
|
||||
while (vs && *vs && isspace(*vs)) ++vs;
|
||||
ve = vs;
|
||||
while (ve && *ve && !(*ve == '\r' || *ve == '\n')) ++ve;
|
||||
*ke = 0, *ve = 0;
|
||||
list_insert(&substPtr, (char*)ks, (char*)vs);
|
||||
}
|
||||
fclose(sp);
|
||||
}
|
||||
|
||||
/* debug: dump the list */
|
||||
#ifdef _DEBUG
|
||||
{
|
||||
int n = 0;
|
||||
list_item_t *p = NULL;
|
||||
for (p = substPtr; p != NULL; p = p->nextPtr, ++n) {
|
||||
fprintf(stderr, "% 3d '%s' => '%s'\n", n, p->key, p->value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Run the substitutions over each line of the input
|
||||
*/
|
||||
|
||||
while (fgets(szBuffer, cbBuffer, fp) != NULL) {
|
||||
list_item_t *p = NULL;
|
||||
for (p = substPtr; p != NULL; p = p->nextPtr) {
|
||||
char *m = strstr(szBuffer, p->key);
|
||||
if (m) {
|
||||
char *cp, *op, *sp;
|
||||
cp = szCopy;
|
||||
op = szBuffer;
|
||||
while (op != m) *cp++ = *op++;
|
||||
sp = p->value;
|
||||
while (sp && *sp) *cp++ = *sp++;
|
||||
op += strlen(p->key);
|
||||
while (*op) *cp++ = *op++;
|
||||
*cp = 0;
|
||||
memcpy(szBuffer, szCopy, sizeof(szCopy));
|
||||
}
|
||||
}
|
||||
printf(szBuffer);
|
||||
}
|
||||
|
||||
list_free(&substPtr);
|
||||
}
|
||||
fclose(fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* QualifyPath --
|
||||
*
|
||||
* This composes the current working directory with a provided path
|
||||
* and returns the fully qualified and normalized path.
|
||||
* Mostly needed to setup paths for testing.
|
||||
*/
|
||||
|
||||
static int
|
||||
QualifyPath(
|
||||
const char *szPath)
|
||||
{
|
||||
char szCwd[MAX_PATH + 1];
|
||||
char szTmp[MAX_PATH + 1];
|
||||
char *p;
|
||||
GetCurrentDirectory(MAX_PATH, szCwd);
|
||||
while ((p = strchr(szPath, '/')) && *p)
|
||||
*p = '\\';
|
||||
PathCombine(szTmp, szCwd, szPath);
|
||||
PathCanonicalize(szCwd, szTmp);
|
||||
printf("%s\n", szCwd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: c
|
||||
* c-basic-offset: 4
|
||||
* fill-column: 78
|
||||
* indent-tabs-mode: t
|
||||
* tab-width: 8
|
||||
* End:
|
||||
*/
|
711
contrib/sqlite3/tea/win/rules.vc
Normal file
711
contrib/sqlite3/tea/win/rules.vc
Normal file
@ -0,0 +1,711 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# rules.vc --
|
||||
#
|
||||
# Microsoft Visual C++ makefile include for decoding the commandline
|
||||
# macros. This file does not need editing to build Tcl.
|
||||
#
|
||||
# See the file "license.terms" for information on usage and redistribution
|
||||
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
#
|
||||
# Copyright (c) 2001-2003 David Gravereaux.
|
||||
# Copyright (c) 2003-2008 Patrick Thoyts
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
!ifndef _RULES_VC
|
||||
_RULES_VC = 1
|
||||
|
||||
cc32 = $(CC) # built-in default.
|
||||
link32 = link
|
||||
lib32 = lib
|
||||
rc32 = $(RC) # built-in default.
|
||||
|
||||
!ifndef INSTALLDIR
|
||||
### Assume the normal default.
|
||||
_INSTALLDIR = C:\Program Files\Tcl
|
||||
!else
|
||||
### Fix the path separators.
|
||||
_INSTALLDIR = $(INSTALLDIR:/=\)
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Set the proper copy method to avoid overwrite questions
|
||||
# to the user when copying files and selecting the right
|
||||
# "delete all" method.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if "$(OS)" == "Windows_NT"
|
||||
RMDIR = rmdir /S /Q
|
||||
ERRNULL = 2>NUL
|
||||
!if ![ver | find "4.0" > nul]
|
||||
CPY = echo y | xcopy /i >NUL
|
||||
COPY = copy >NUL
|
||||
!else
|
||||
CPY = xcopy /i /y >NUL
|
||||
COPY = copy /y >NUL
|
||||
!endif
|
||||
!else # "$(OS)" != "Windows_NT"
|
||||
CPY = xcopy /i >_JUNK.OUT # On Win98 NUL does not work here.
|
||||
COPY = copy >_JUNK.OUT # On Win98 NUL does not work here.
|
||||
RMDIR = deltree /Y
|
||||
NULL = \NUL # Used in testing directory existence
|
||||
ERRNULL = >NUL # Win9x shell cannot redirect stderr
|
||||
!endif
|
||||
MKDIR = mkdir
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
# Determine the host and target architectures and compiler version.
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
_HASH=^#
|
||||
_VC_MANIFEST_EMBED_EXE=
|
||||
_VC_MANIFEST_EMBED_DLL=
|
||||
VCVER=0
|
||||
!if ![echo VCVERSION=_MSC_VER > vercl.x] \
|
||||
&& ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \
|
||||
&& ![echo ARCH=IX86 >> vercl.x] \
|
||||
&& ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \
|
||||
&& ![echo ARCH=AMD64 >> vercl.x] \
|
||||
&& ![echo $(_HASH)endif >> vercl.x] \
|
||||
&& ![cl -nologo -TC -P vercl.x $(ERRNULL)]
|
||||
!include vercl.i
|
||||
!if ![echo VCVER= ^\> vercl.vc] \
|
||||
&& ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc]
|
||||
!include vercl.vc
|
||||
!endif
|
||||
!endif
|
||||
!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc]
|
||||
!endif
|
||||
|
||||
!if ![reg query HKLM\Hardware\Description\System\CentralProcessor\0 /v Identifier | findstr /i x86]
|
||||
NATIVE_ARCH=IX86
|
||||
!else
|
||||
NATIVE_ARCH=AMD64
|
||||
!endif
|
||||
|
||||
# Since MSVC8 we must deal with manifest resources.
|
||||
!if $(VCVERSION) >= 1400
|
||||
_VC_MANIFEST_EMBED_EXE=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;1
|
||||
_VC_MANIFEST_EMBED_DLL=if exist $@.manifest mt -nologo -manifest $@.manifest -outputresource:$@;2
|
||||
!endif
|
||||
|
||||
!ifndef MACHINE
|
||||
MACHINE=$(ARCH)
|
||||
!endif
|
||||
|
||||
!ifndef CFG_ENCODING
|
||||
CFG_ENCODING = \"cp1252\"
|
||||
!endif
|
||||
|
||||
!message ===============================================================================
|
||||
|
||||
#----------------------------------------------------------
|
||||
# build the helper app we need to overcome nmake's limiting
|
||||
# environment.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if !exist(nmakehlp.exe)
|
||||
!if [$(cc32) -nologo nmakehlp.c -link -subsystem:console > nul]
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Test for compiler features
|
||||
#----------------------------------------------------------
|
||||
|
||||
### test for optimizations
|
||||
!if [nmakehlp -c -Ot]
|
||||
!message *** Compiler has 'Optimizations'
|
||||
OPTIMIZING = 1
|
||||
!else
|
||||
!message *** Compiler does not have 'Optimizations'
|
||||
OPTIMIZING = 0
|
||||
!endif
|
||||
|
||||
OPTIMIZATIONS =
|
||||
|
||||
!if [nmakehlp -c -Ot]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -Ot
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -Oi]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -Oi
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -Op]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -Op
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -fp:strict]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -fp:strict
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -Gs]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -Gs
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -GS]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -GS
|
||||
!endif
|
||||
|
||||
!if [nmakehlp -c -GL]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -GL
|
||||
!endif
|
||||
|
||||
DEBUGFLAGS =
|
||||
|
||||
!if [nmakehlp -c -RTC1]
|
||||
DEBUGFLAGS = $(DEBUGFLAGS) -RTC1
|
||||
!elseif [nmakehlp -c -GZ]
|
||||
DEBUGFLAGS = $(DEBUGFLAGS) -GZ
|
||||
!endif
|
||||
|
||||
COMPILERFLAGS =-W3 -DUNICODE -D_UNICODE
|
||||
|
||||
# In v13 -GL and -YX are incompatible.
|
||||
!if [nmakehlp -c -YX]
|
||||
!if ![nmakehlp -c -GL]
|
||||
OPTIMIZATIONS = $(OPTIMIZATIONS) -YX
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!if "$(MACHINE)" == "IX86"
|
||||
### test for pentium errata
|
||||
!if [nmakehlp -c -QI0f]
|
||||
!message *** Compiler has 'Pentium 0x0f fix'
|
||||
COMPILERFLAGS = $(COMPILERFLAGS) -QI0f
|
||||
!else
|
||||
!message *** Compiler does not have 'Pentium 0x0f fix'
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!if "$(MACHINE)" == "IA64"
|
||||
### test for Itanium errata
|
||||
!if [nmakehlp -c -QIA64_Bx]
|
||||
!message *** Compiler has 'B-stepping errata workarounds'
|
||||
COMPILERFLAGS = $(COMPILERFLAGS) -QIA64_Bx
|
||||
!else
|
||||
!message *** Compiler does not have 'B-stepping errata workarounds'
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!if "$(MACHINE)" == "IX86"
|
||||
### test for -align:4096, when align:512 will do.
|
||||
!if [nmakehlp -l -opt:nowin98]
|
||||
!message *** Linker has 'Win98 alignment problem'
|
||||
ALIGN98_HACK = 1
|
||||
!else
|
||||
!message *** Linker does not have 'Win98 alignment problem'
|
||||
ALIGN98_HACK = 0
|
||||
!endif
|
||||
!else
|
||||
ALIGN98_HACK = 0
|
||||
!endif
|
||||
|
||||
LINKERFLAGS =
|
||||
|
||||
!if [nmakehlp -l -ltcg]
|
||||
LINKERFLAGS =-ltcg
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Decode the options requested.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if "$(OPTS)" == "" || [nmakehlp -f "$(OPTS)" "none"]
|
||||
STATIC_BUILD = 0
|
||||
TCL_THREADS = 1
|
||||
DEBUG = 0
|
||||
SYMBOLS = 0
|
||||
PROFILE = 0
|
||||
PGO = 0
|
||||
MSVCRT = 0
|
||||
LOIMPACT = 0
|
||||
TCL_USE_STATIC_PACKAGES = 0
|
||||
USE_THREAD_ALLOC = 1
|
||||
UNCHECKED = 0
|
||||
!else
|
||||
!if [nmakehlp -f $(OPTS) "static"]
|
||||
!message *** Doing static
|
||||
STATIC_BUILD = 1
|
||||
!else
|
||||
STATIC_BUILD = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "msvcrt"]
|
||||
!message *** Doing msvcrt
|
||||
MSVCRT = 1
|
||||
!else
|
||||
MSVCRT = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "staticpkg"]
|
||||
!message *** Doing staticpkg
|
||||
TCL_USE_STATIC_PACKAGES = 1
|
||||
!else
|
||||
TCL_USE_STATIC_PACKAGES = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "nothreads"]
|
||||
!message *** Compile explicitly for non-threaded tcl
|
||||
TCL_THREADS = 0
|
||||
!else
|
||||
TCL_THREADS = 1
|
||||
USE_THREAD_ALLOC= 1
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "symbols"]
|
||||
!message *** Doing symbols
|
||||
DEBUG = 1
|
||||
!else
|
||||
DEBUG = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "pdbs"]
|
||||
!message *** Doing pdbs
|
||||
SYMBOLS = 1
|
||||
!else
|
||||
SYMBOLS = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "profile"]
|
||||
!message *** Doing profile
|
||||
PROFILE = 1
|
||||
!else
|
||||
PROFILE = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "pgi"]
|
||||
!message *** Doing profile guided optimization instrumentation
|
||||
PGO = 1
|
||||
!elseif [nmakehlp -f $(OPTS) "pgo"]
|
||||
!message *** Doing profile guided optimization
|
||||
PGO = 2
|
||||
!else
|
||||
PGO = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "loimpact"]
|
||||
!message *** Doing loimpact
|
||||
LOIMPACT = 1
|
||||
!else
|
||||
LOIMPACT = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "thrdalloc"]
|
||||
!message *** Doing thrdalloc
|
||||
USE_THREAD_ALLOC = 1
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "tclalloc"]
|
||||
!message *** Doing tclalloc
|
||||
USE_THREAD_ALLOC = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(OPTS) "unchecked"]
|
||||
!message *** Doing unchecked
|
||||
UNCHECKED = 1
|
||||
!else
|
||||
UNCHECKED = 0
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
!if !$(STATIC_BUILD)
|
||||
# Make sure we don't build overly fat DLLs.
|
||||
MSVCRT = 1
|
||||
# We shouldn't statically put the extensions inside the shell when dynamic.
|
||||
TCL_USE_STATIC_PACKAGES = 0
|
||||
!endif
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Figure-out how to name our intermediate and output directories.
|
||||
# We wouldn't want different builds to use the same .obj files
|
||||
# by accident.
|
||||
#----------------------------------------------------------
|
||||
|
||||
#----------------------------------------
|
||||
# Naming convention:
|
||||
# t = full thread support.
|
||||
# s = static library (as opposed to an
|
||||
# import library)
|
||||
# g = linked to the debug enabled C
|
||||
# run-time.
|
||||
# x = special static build when it
|
||||
# links to the dynamic C run-time.
|
||||
#----------------------------------------
|
||||
SUFX = tsgx
|
||||
|
||||
!if $(DEBUG)
|
||||
BUILDDIRTOP = Debug
|
||||
!else
|
||||
BUILDDIRTOP = Release
|
||||
!endif
|
||||
|
||||
!if "$(MACHINE)" != "IX86"
|
||||
BUILDDIRTOP =$(BUILDDIRTOP)_$(MACHINE)
|
||||
!endif
|
||||
!if $(VCVER) > 6
|
||||
BUILDDIRTOP =$(BUILDDIRTOP)_VC$(VCVER)
|
||||
!endif
|
||||
|
||||
!if !$(DEBUG) || $(DEBUG) && $(UNCHECKED)
|
||||
SUFX = $(SUFX:g=)
|
||||
!endif
|
||||
|
||||
TMP_DIRFULL = .\$(BUILDDIRTOP)\$(PROJECT)_ThreadedDynamicStaticX
|
||||
|
||||
!if !$(STATIC_BUILD)
|
||||
TMP_DIRFULL = $(TMP_DIRFULL:Static=)
|
||||
SUFX = $(SUFX:s=)
|
||||
EXT = dll
|
||||
!if $(MSVCRT)
|
||||
TMP_DIRFULL = $(TMP_DIRFULL:X=)
|
||||
SUFX = $(SUFX:x=)
|
||||
!endif
|
||||
!else
|
||||
TMP_DIRFULL = $(TMP_DIRFULL:Dynamic=)
|
||||
EXT = lib
|
||||
!if !$(MSVCRT)
|
||||
TMP_DIRFULL = $(TMP_DIRFULL:X=)
|
||||
SUFX = $(SUFX:x=)
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!if !$(TCL_THREADS)
|
||||
TMP_DIRFULL = $(TMP_DIRFULL:Threaded=)
|
||||
SUFX = $(SUFX:t=)
|
||||
!endif
|
||||
|
||||
!ifndef TMP_DIR
|
||||
TMP_DIR = $(TMP_DIRFULL)
|
||||
!ifndef OUT_DIR
|
||||
OUT_DIR = .\$(BUILDDIRTOP)
|
||||
!endif
|
||||
!else
|
||||
!ifndef OUT_DIR
|
||||
OUT_DIR = $(TMP_DIR)
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Decode the statistics requested.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if "$(STATS)" == "" || [nmakehlp -f "$(STATS)" "none"]
|
||||
TCL_MEM_DEBUG = 0
|
||||
TCL_COMPILE_DEBUG = 0
|
||||
!else
|
||||
!if [nmakehlp -f $(STATS) "memdbg"]
|
||||
!message *** Doing memdbg
|
||||
TCL_MEM_DEBUG = 1
|
||||
!else
|
||||
TCL_MEM_DEBUG = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(STATS) "compdbg"]
|
||||
!message *** Doing compdbg
|
||||
TCL_COMPILE_DEBUG = 1
|
||||
!else
|
||||
TCL_COMPILE_DEBUG = 0
|
||||
!endif
|
||||
!endif
|
||||
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Decode the checks requested.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if "$(CHECKS)" == "" || [nmakehlp -f "$(CHECKS)" "none"]
|
||||
TCL_NO_DEPRECATED = 0
|
||||
WARNINGS = -W3
|
||||
!else
|
||||
!if [nmakehlp -f $(CHECKS) "nodep"]
|
||||
!message *** Doing nodep check
|
||||
TCL_NO_DEPRECATED = 1
|
||||
!else
|
||||
TCL_NO_DEPRECATED = 0
|
||||
!endif
|
||||
!if [nmakehlp -f $(CHECKS) "fullwarn"]
|
||||
!message *** Doing full warnings check
|
||||
WARNINGS = -W4
|
||||
!if [nmakehlp -l -warn:3]
|
||||
LINKERFLAGS = $(LINKERFLAGS) -warn:3
|
||||
!endif
|
||||
!else
|
||||
WARNINGS = -W3
|
||||
!endif
|
||||
!if [nmakehlp -f $(CHECKS) "64bit"] && [nmakehlp -c -Wp64]
|
||||
!message *** Doing 64bit portability warnings
|
||||
WARNINGS = $(WARNINGS) -Wp64
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!if $(PGO) > 1
|
||||
!if [nmakehlp -l -ltcg:pgoptimize]
|
||||
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pgoptimize
|
||||
!else
|
||||
MSG=^
|
||||
This compiler does not support profile guided optimization.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
!elseif $(PGO) > 0
|
||||
!if [nmakehlp -l -ltcg:pginstrument]
|
||||
LINKERFLAGS = $(LINKERFLAGS:-ltcg=) -ltcg:pginstrument
|
||||
!else
|
||||
MSG=^
|
||||
This compiler does not support profile guided optimization.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Set our defines now armed with our options.
|
||||
#----------------------------------------------------------
|
||||
|
||||
OPTDEFINES = -DTCL_CFGVAL_ENCODING=$(CFG_ENCODING) -DSTDC_HEADERS
|
||||
|
||||
!if $(TCL_MEM_DEBUG)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_MEM_DEBUG
|
||||
!endif
|
||||
!if $(TCL_COMPILE_DEBUG)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_COMPILE_DEBUG -DTCL_COMPILE_STATS
|
||||
!endif
|
||||
!if $(TCL_THREADS)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_THREADS=1
|
||||
!if $(USE_THREAD_ALLOC)
|
||||
OPTDEFINES = $(OPTDEFINES) -DUSE_THREAD_ALLOC=1
|
||||
!endif
|
||||
!endif
|
||||
!if $(STATIC_BUILD)
|
||||
OPTDEFINES = $(OPTDEFINES) -DSTATIC_BUILD
|
||||
!endif
|
||||
!if $(TCL_NO_DEPRECATED)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_NO_DEPRECATED
|
||||
!endif
|
||||
|
||||
!if !$(DEBUG)
|
||||
OPTDEFINES = $(OPTDEFINES) -DNDEBUG
|
||||
!if $(OPTIMIZING)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_OPTIMIZED
|
||||
!endif
|
||||
!endif
|
||||
!if $(PROFILE)
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_PROFILED
|
||||
!endif
|
||||
!if "$(MACHINE)" == "IA64" || "$(MACHINE)" == "AMD64"
|
||||
OPTDEFINES = $(OPTDEFINES) -DTCL_CFG_DO64BIT
|
||||
!endif
|
||||
!if $(VCVERSION) < 1300
|
||||
OPTDEFINES = $(OPTDEFINES) -DNO_STRTOI64
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Locate the Tcl headers to build against
|
||||
#----------------------------------------------------------
|
||||
|
||||
!if "$(PROJECT)" == "tcl"
|
||||
|
||||
_TCL_H = ..\generic\tcl.h
|
||||
|
||||
!else
|
||||
|
||||
# If INSTALLDIR set to tcl root dir then reset to the lib dir.
|
||||
!if exist("$(_INSTALLDIR)\include\tcl.h")
|
||||
_INSTALLDIR=$(_INSTALLDIR)\lib
|
||||
!endif
|
||||
|
||||
!if !defined(TCLDIR)
|
||||
!if exist("$(_INSTALLDIR)\..\include\tcl.h")
|
||||
TCLINSTALL = 1
|
||||
_TCLDIR = $(_INSTALLDIR)\..
|
||||
_TCL_H = $(_INSTALLDIR)\..\include\tcl.h
|
||||
TCLDIR = $(_INSTALLDIR)\..
|
||||
!else
|
||||
MSG=^
|
||||
Failed to find tcl.h. Set the TCLDIR macro.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
!else
|
||||
_TCLDIR = $(TCLDIR:/=\)
|
||||
!if exist("$(_TCLDIR)\include\tcl.h")
|
||||
TCLINSTALL = 1
|
||||
_TCL_H = $(_TCLDIR)\include\tcl.h
|
||||
!elseif exist("$(_TCLDIR)\generic\tcl.h")
|
||||
TCLINSTALL = 0
|
||||
_TCL_H = $(_TCLDIR)\generic\tcl.h
|
||||
!else
|
||||
MSG =^
|
||||
Failed to find tcl.h. The TCLDIR macro does not appear correct.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Extract various version numbers from tcl headers
|
||||
# The generated file is then included in the makefile.
|
||||
#--------------------------------------------------------------
|
||||
|
||||
!if [echo REM = This file is generated from rules.vc > versions.vc]
|
||||
!endif
|
||||
!if [echo TCL_MAJOR_VERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V "$(_TCL_H)" TCL_MAJOR_VERSION >> versions.vc]
|
||||
!endif
|
||||
!if [echo TCL_MINOR_VERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V "$(_TCL_H)" TCL_MINOR_VERSION >> versions.vc]
|
||||
!endif
|
||||
!if [echo TCL_PATCH_LEVEL = \>> versions.vc] \
|
||||
&& [nmakehlp -V "$(_TCL_H)" TCL_PATCH_LEVEL >> versions.vc]
|
||||
!endif
|
||||
|
||||
# If building the tcl core then we need additional package versions
|
||||
!if "$(PROJECT)" == "tcl"
|
||||
!if [echo PKG_HTTP_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\http\pkgIndex.tcl http >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_TCLTEST_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\tcltest\pkgIndex.tcl tcltest >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_MSGCAT_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\msgcat\pkgIndex.tcl msgcat >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_PLATFORM_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform " >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_SHELL_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\platform\pkgIndex.tcl "platform::shell" >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_DDE_VER = \>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\dde\pkgIndex.tcl "dde " >> versions.vc]
|
||||
!endif
|
||||
!if [echo PKG_REG_VER =\>> versions.vc] \
|
||||
&& [nmakehlp -V ..\library\reg\pkgIndex.tcl registry >> versions.vc]
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!include versions.vc
|
||||
|
||||
#--------------------------------------------------------------
|
||||
# Setup tcl version dependent stuff headers
|
||||
#--------------------------------------------------------------
|
||||
|
||||
!if "$(PROJECT)" != "tcl"
|
||||
|
||||
TCL_VERSION = $(TCL_MAJOR_VERSION)$(TCL_MINOR_VERSION)
|
||||
|
||||
!if $(TCL_VERSION) < 81
|
||||
TCL_DOES_STUBS = 0
|
||||
!else
|
||||
TCL_DOES_STUBS = 1
|
||||
!endif
|
||||
|
||||
!if $(TCLINSTALL)
|
||||
TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)$(SUFX).exe"
|
||||
!if !exist($(TCLSH)) && $(TCL_THREADS)
|
||||
TCLSH = "$(_TCLDIR)\bin\tclsh$(TCL_VERSION)t$(SUFX).exe"
|
||||
!endif
|
||||
TCLSTUBLIB = "$(_TCLDIR)\lib\tclstub$(TCL_VERSION).lib"
|
||||
TCLIMPLIB = "$(_TCLDIR)\lib\tcl$(TCL_VERSION)$(SUFX).lib"
|
||||
TCL_LIBRARY = $(_TCLDIR)\lib
|
||||
TCLREGLIB = "$(_TCLDIR)\lib\tclreg13$(SUFX:t=).lib"
|
||||
TCLDDELIB = "$(_TCLDIR)\lib\tcldde14$(SUFX:t=).lib"
|
||||
COFFBASE = \must\have\tcl\sources\to\build\this\target
|
||||
TCLTOOLSDIR = \must\have\tcl\sources\to\build\this\target
|
||||
TCL_INCLUDES = -I"$(_TCLDIR)\include"
|
||||
!else
|
||||
TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)$(SUFX).exe"
|
||||
!if !exist($(TCLSH)) && $(TCL_THREADS)
|
||||
TCLSH = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclsh$(TCL_VERSION)t$(SUFX).exe"
|
||||
!endif
|
||||
TCLSTUBLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclstub$(TCL_VERSION).lib"
|
||||
TCLIMPLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcl$(TCL_VERSION)$(SUFX).lib"
|
||||
TCL_LIBRARY = $(_TCLDIR)\library
|
||||
TCLREGLIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tclreg13$(SUFX:t=).lib"
|
||||
TCLDDELIB = "$(_TCLDIR)\win\$(BUILDDIRTOP)\tcldde14$(SUFX:t=).lib"
|
||||
COFFBASE = "$(_TCLDIR)\win\coffbase.txt"
|
||||
TCLTOOLSDIR = $(_TCLDIR)\tools
|
||||
TCL_INCLUDES = -I"$(_TCLDIR)\generic" -I"$(_TCLDIR)\win"
|
||||
!endif
|
||||
|
||||
!endif
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Locate the Tk headers to build against
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
!if "$(PROJECT)" == "tk"
|
||||
_TK_H = ..\generic\tk.h
|
||||
_INSTALLDIR = $(_INSTALLDIR)\..
|
||||
!endif
|
||||
|
||||
!ifdef PROJECT_REQUIRES_TK
|
||||
!if !defined(TKDIR)
|
||||
!if exist("$(_INSTALLDIR)\..\include\tk.h")
|
||||
TKINSTALL = 1
|
||||
_TKDIR = $(_INSTALLDIR)\..
|
||||
_TK_H = $(_TKDIR)\include\tk.h
|
||||
TKDIR = $(_TKDIR)
|
||||
!elseif exist("$(_TCLDIR)\include\tk.h")
|
||||
TKINSTALL = 1
|
||||
_TKDIR = $(_TCLDIR)
|
||||
_TK_H = $(_TKDIR)\include\tk.h
|
||||
TKDIR = $(_TKDIR)
|
||||
!endif
|
||||
!else
|
||||
_TKDIR = $(TKDIR:/=\)
|
||||
!if exist("$(_TKDIR)\include\tk.h")
|
||||
TKINSTALL = 1
|
||||
_TK_H = $(_TKDIR)\include\tk.h
|
||||
!elseif exist("$(_TKDIR)\generic\tk.h")
|
||||
TKINSTALL = 0
|
||||
_TK_H = $(_TKDIR)\generic\tk.h
|
||||
!else
|
||||
MSG =^
|
||||
Failed to find tk.h. The TKDIR macro does not appear correct.
|
||||
!error $(MSG)
|
||||
!endif
|
||||
!endif
|
||||
!endif
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# Extract Tk version numbers
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
!if defined(PROJECT_REQUIRES_TK) || "$(PROJECT)" == "tk"
|
||||
|
||||
!if [echo TK_MAJOR_VERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V $(_TK_H) TK_MAJOR_VERSION >> versions.vc]
|
||||
!endif
|
||||
!if [echo TK_MINOR_VERSION = \>> versions.vc] \
|
||||
&& [nmakehlp -V $(_TK_H) TK_MINOR_VERSION >> versions.vc]
|
||||
!endif
|
||||
!if [echo TK_PATCH_LEVEL = \>> versions.vc] \
|
||||
&& [nmakehlp -V $(_TK_H) TK_PATCH_LEVEL >> versions.vc]
|
||||
!endif
|
||||
|
||||
!include versions.vc
|
||||
|
||||
TK_DOTVERSION = $(TK_MAJOR_VERSION).$(TK_MINOR_VERSION)
|
||||
TK_VERSION = $(TK_MAJOR_VERSION)$(TK_MINOR_VERSION)
|
||||
|
||||
!if "$(PROJECT)" != "tk"
|
||||
!if $(TKINSTALL)
|
||||
WISH = "$(_TKDIR)\bin\wish$(TK_VERSION)$(SUFX).exe"
|
||||
TKSTUBLIB = "$(_TKDIR)\lib\tkstub$(TK_VERSION).lib"
|
||||
TKIMPLIB = "$(_TKDIR)\lib\tk$(TK_VERSION)$(SUFX).lib"
|
||||
TK_INCLUDES = -I"$(_TKDIR)\include"
|
||||
!else
|
||||
WISH = "$(_TKDIR)\win\$(BUILDDIRTOP)\wish$(TCL_VERSION)$(SUFX).exe"
|
||||
TKSTUBLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tkstub$(TCL_VERSION).lib"
|
||||
TKIMPLIB = "$(_TKDIR)\win\$(BUILDDIRTOP)\tk$(TCL_VERSION)$(SUFX).lib"
|
||||
TK_INCLUDES = -I"$(_TKDIR)\generic" -I"$(_TKDIR)\win" -I"$(_TKDIR)\xlib"
|
||||
!endif
|
||||
!endif
|
||||
|
||||
!endif
|
||||
|
||||
#----------------------------------------------------------
|
||||
# Display stats being used.
|
||||
#----------------------------------------------------------
|
||||
|
||||
!message *** Intermediate directory will be '$(TMP_DIR)'
|
||||
!message *** Output directory will be '$(OUT_DIR)'
|
||||
!message *** Suffix for binaries will be '$(SUFX)'
|
||||
!message *** Optional defines are '$(OPTDEFINES)'
|
||||
!message *** Compiler version $(VCVER). Target machine is $(MACHINE)
|
||||
!message *** Host architecture is $(NATIVE_ARCH)
|
||||
!message *** Compiler options '$(COMPILERFLAGS) $(OPTIMIZATIONS) $(DEBUGFLAGS) $(WARNINGS)'
|
||||
!message *** Link options '$(LINKERFLAGS)'
|
||||
|
||||
!endif
|
||||
|
@ -18,26 +18,26 @@
|
||||
#
|
||||
# logfilename [owner:group] mode count size when flags [/pid_file] [sig_num]
|
||||
/var/log/all.log 600 7 * @T00 J
|
||||
/var/log/amd.log 644 7 100 * J
|
||||
/var/log/auth.log 600 7 100 @0101T JC
|
||||
/var/log/console.log 600 5 100 * J
|
||||
/var/log/cron 600 3 100 * JC
|
||||
/var/log/amd.log 644 7 1000 * J
|
||||
/var/log/auth.log 600 7 1000 @0101T JC
|
||||
/var/log/console.log 600 5 1000 * J
|
||||
/var/log/cron 600 3 1000 * JC
|
||||
/var/log/daily.log 640 7 * @T00 JN
|
||||
/var/log/debug.log 600 7 100 * JC
|
||||
/var/log/init.log 644 3 100 * J
|
||||
/var/log/kerberos.log 600 7 100 * J
|
||||
/var/log/lpd-errs 644 7 100 * JC
|
||||
/var/log/debug.log 600 7 1000 * JC
|
||||
/var/log/init.log 644 3 1000 * J
|
||||
/var/log/kerberos.log 600 7 1000 * J
|
||||
/var/log/lpd-errs 644 7 1000 * JC
|
||||
/var/log/maillog 640 7 * @T00 JC
|
||||
/var/log/messages 644 5 100 @0101T JC
|
||||
/var/log/messages 644 5 1000 @0101T JC
|
||||
/var/log/monthly.log 640 12 * $M1D0 JN
|
||||
/var/log/pflog 600 3 100 * JB /var/run/pflogd.pid
|
||||
/var/log/ppp.log root:network 640 3 100 * JC
|
||||
/var/log/devd.log 644 3 100 * JC
|
||||
/var/log/security 600 10 100 * JC
|
||||
/var/log/pflog 600 3 1000 * JB /var/run/pflogd.pid
|
||||
/var/log/ppp.log root:network 640 3 1000 * JC
|
||||
/var/log/devd.log 644 3 1000 * JC
|
||||
/var/log/security 600 10 1000 * JC
|
||||
/var/log/sendmail.st 640 10 * 168 BN
|
||||
/var/log/utx.log 644 3 * @01T05 B
|
||||
/var/log/weekly.log 640 5 * $W6D0 JN
|
||||
/var/log/xferlog 600 7 100 * JC
|
||||
/var/log/xferlog 600 7 1000 * JC
|
||||
|
||||
<include> /etc/newsyslog.conf.d/*
|
||||
<include> /usr/local/etc/newsyslog.conf.d/*
|
||||
|
@ -1,6 +1,4 @@
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
# In the following text, the symbol '#' introduces
|
||||
# a comment, which continues from that symbol until
|
||||
# the end of the line. A plain comment line has a
|
||||
@ -46,7 +44,7 @@
|
||||
# by the International Bureau of Weights and Measures
|
||||
# (BIPM). See www.bipm.fr for more information.
|
||||
#
|
||||
# 3. The current definition of the relationship between UTC
|
||||
# 3. The current defintion of the relationship between UTC
|
||||
# and TAI dates from 1 January 1972. A number of different
|
||||
# time scales were in use before than epoch, and it can be
|
||||
# quite difficult to compute precise timestamps and time
|
||||
|
@ -29,6 +29,8 @@ ntpd_precmd()
|
||||
rc_flags="-g $rc_flags"
|
||||
fi
|
||||
|
||||
ntpd_init_leapfile
|
||||
|
||||
if [ ! -f $ntp_db_leapfile ]; then
|
||||
ntpd_fetch_leapfile
|
||||
fi
|
||||
@ -67,15 +69,27 @@ current_ntp_ts() {
|
||||
}
|
||||
|
||||
get_ntp_leapfile_ver() {
|
||||
# Leapfile update date (version number).
|
||||
expr "$(awk '$1 == "#$" { print $2 }' "$1" 2>/dev/null)" : \
|
||||
'^\([1-9][0-9]*\)$' \| 0
|
||||
}
|
||||
|
||||
get_ntp_leapfile_expiry() {
|
||||
# Leapfile expiry date.
|
||||
expr "$(awk '$1 == "#@" { print $2 }' "$1" 2>/dev/null)" : \
|
||||
'^\([1-9][0-9]*\)$' \| 0
|
||||
}
|
||||
|
||||
ntpd_init_leapfile() {
|
||||
# Refresh working leapfile with an invalid hash due to
|
||||
# FreeBSD id header. Ntpd will ignore leapfiles with a
|
||||
# mismatch hash. The file must be the virgin file from
|
||||
# the source.
|
||||
if [ ! -f $ntp_db_leapfile ]; then
|
||||
cp -p $ntp_src_leapfile $ntp_db_leapfile
|
||||
fi
|
||||
}
|
||||
|
||||
ntpd_fetch_leapfile() {
|
||||
local ntp_tmp_leapfile rc verbose
|
||||
|
||||
@ -88,19 +102,23 @@ ntpd_fetch_leapfile() {
|
||||
ntp_tmp_leapfile="/var/run/ntpd.leap-seconds.list"
|
||||
|
||||
ntp_ver_no_src=$(get_ntp_leapfile_ver $ntp_src_leapfile)
|
||||
ntp_expiry_src=$(get_ntp_leapfile_expiry $ntp_src_leapfile)
|
||||
ntp_ver_no_db=$(get_ntp_leapfile_ver $ntp_db_leapfile)
|
||||
ntp_expiry_db=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
|
||||
$verbose ntp_src_leapfile version is $ntp_ver_no_src
|
||||
$verbose ntp_db_leapfile version is $ntp_ver_no_db
|
||||
|
||||
if [ "$ntp_ver_no_src" -gt "$ntp_ver_no_db" ]; then
|
||||
if [ "$ntp_ver_no_src" -gt "$ntp_ver_no_db" -o \
|
||||
"$ntp_ver_no_src" -eq "$ntp_ver_no_db" -a \
|
||||
"$ntp_expiry_src" -gt "$ntp_expiry_db" ]; then
|
||||
$verbose replacing $ntp_db_leapfile with $ntp_src_leapfile
|
||||
cp -p $ntp_src_leapfile $ntp_db_leapfile
|
||||
ntp_ver_no_db=$ntp_ver_no_src
|
||||
else
|
||||
$verbose not replacing $ntp_db_leapfile with $ntp_src_leapfile
|
||||
fi
|
||||
ntp_leap_expiry=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
|
||||
ntp_leapfile_expiry_seconds=$((ntp_leapfile_expiry_days*86400))
|
||||
ntp_leap_expiry=$(get_ntp_leapfile_expiry $ntp_db_leapfile)
|
||||
ntp_leap_fetch_date=$((ntp_leap_expiry-ntp_leapfile_expiry_seconds))
|
||||
if [ $(current_ntp_ts) -ge $ntp_leap_fetch_date ]; then
|
||||
$verbose Within ntp leapfile expiry limit, initiating fetch
|
||||
@ -108,8 +126,11 @@ ntpd_fetch_leapfile() {
|
||||
$verbose fetching $url
|
||||
fetch $ntp_leapfile_fetch_opts -o $ntp_tmp_leapfile $url && break
|
||||
done
|
||||
ntp_ver_no_tmp=$(get_ntp_leapfile_ver $ntp_tmp_leapfile)
|
||||
ntp_expiry_tmp=$(get_ntp_leapfile_expiry $ntp_tmp_leapfile)
|
||||
if [ "$ntp_expiry_tmp" -gt "$ntp_leap_expiry" ]; then
|
||||
if [ "$ntp_ver_no_tmp" -gt "$ntp_ver_no_db" -o \
|
||||
"$ntp_ver_no_tmp" -eq "$ntp_ver_no_db" -a \
|
||||
"$ntp_expiry_tmp" -gt "$ntp_expiry_db" ]; then
|
||||
$verbose using $url as $ntp_db_leapfile
|
||||
mv $ntp_tmp_leapfile $ntp_db_leapfile
|
||||
else
|
||||
|
@ -39,4 +39,23 @@ char *basename_r(const char *, char *);
|
||||
char *dirname(char *);
|
||||
__END_DECLS
|
||||
|
||||
/*
|
||||
* In FreeBSD 12, the prototype of dirname() was modified to comply to
|
||||
* POSIX. This function may now modify its input. Unfortunately, our
|
||||
* copy of xinstall(8) shipped with previous versions of FreeBSD is
|
||||
* built using the host headers and libc during the bootstrapping phase
|
||||
* and depends on the old behavior.
|
||||
*
|
||||
* Apply a workaround where we explicitly link against dirname@FBSD_1.0
|
||||
* in case this function is called on constant strings, instead of
|
||||
* making the build fail.
|
||||
*/
|
||||
#if defined(__generic) && !defined(__cplusplus)
|
||||
__BEGIN_DECLS
|
||||
char *__old_dirname(const char *);
|
||||
__END_DECLS
|
||||
__sym_compat(dirname, __old_dirname, FBSD_1.0);
|
||||
#define dirname(x) __generic(x, const char *, __old_dirname, dirname)(x)
|
||||
#endif
|
||||
|
||||
#endif /* !_LIBGEN_H_ */
|
||||
|
@ -32,12 +32,13 @@
|
||||
#ifndef _XLOCALE_LOCALE_H
|
||||
#define _XLOCALE_LOCALE_H
|
||||
|
||||
/* Bit shifting order of LC_*_MASK should match XLC_* and LC_* order. */
|
||||
#define LC_COLLATE_MASK (1<<0)
|
||||
#define LC_CTYPE_MASK (1<<1)
|
||||
#define LC_MESSAGES_MASK (1<<2)
|
||||
#define LC_MONETARY_MASK (1<<3)
|
||||
#define LC_NUMERIC_MASK (1<<4)
|
||||
#define LC_TIME_MASK (1<<5)
|
||||
#define LC_MONETARY_MASK (1<<2)
|
||||
#define LC_NUMERIC_MASK (1<<3)
|
||||
#define LC_TIME_MASK (1<<4)
|
||||
#define LC_MESSAGES_MASK (1<<5)
|
||||
#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | LC_MESSAGES_MASK | \
|
||||
LC_MONETARY_MASK | LC_NUMERIC_MASK | LC_TIME_MASK)
|
||||
#define LC_GLOBAL_LOCALE ((locale_t)-1)
|
||||
|
@ -43,7 +43,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
|
||||
libcompat \
|
||||
libcrypt \
|
||||
libdevctl \
|
||||
libdevdctl \
|
||||
${_libdevdctl} \
|
||||
libdevinfo \
|
||||
libdevstat \
|
||||
libdpv \
|
||||
@ -60,6 +60,7 @@ SUBDIR= ${SUBDIR_BOOTSTRAP} \
|
||||
${_libgssapi} \
|
||||
${_librpcsec_gss} \
|
||||
${_libiconv_modules} \
|
||||
libifc \
|
||||
libipsec \
|
||||
libjail \
|
||||
libkiconv \
|
||||
@ -187,6 +188,10 @@ _clang= clang
|
||||
_cuse= libcuse
|
||||
.endif
|
||||
|
||||
.if ${MK_CXX} != "no"
|
||||
_libdevdctl= libdevdctl
|
||||
.endif
|
||||
|
||||
.if ${MK_TOOLCHAIN} != "no"
|
||||
_libelftc= libelftc
|
||||
_libpe= libpe
|
||||
|
@ -211,8 +211,6 @@ TESTS_SRCS= \
|
||||
test_write_disk_perms.c \
|
||||
test_write_disk_secure.c \
|
||||
test_write_disk_secure744.c \
|
||||
test_write_disk_secure745.c \
|
||||
test_write_disk_secure746.c \
|
||||
test_write_disk_sparse.c \
|
||||
test_write_disk_symlink.c \
|
||||
test_write_disk_times.c \
|
||||
|
@ -33,8 +33,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <link.h>
|
||||
#include "libc_private.h"
|
||||
|
||||
int __getosreldate(void);
|
||||
|
||||
/*
|
||||
* This is private to libc. It is intended for wrapping syscall stubs in order
|
||||
* to avoid having to put SIGSYS signal handlers in place to test for presence
|
||||
|
@ -31,7 +31,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
dirname(char *path)
|
||||
(dirname)(char *path)
|
||||
{
|
||||
const char *in, *prev, *begin, *end;
|
||||
char *out;
|
||||
|
@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <nl_types.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
@ -56,7 +55,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <unistd.h>
|
||||
#include "un-namespace.h"
|
||||
|
||||
#include "../locale/setlocale.h" /* for ENCODING_LEN */
|
||||
#include "../locale/xlocale_private.h"
|
||||
|
||||
#define _DEFAULT_NLS_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L:/usr/local/share/nls/%L/%N.cat:/usr/local/share/nls/%N/%L"
|
||||
|
||||
@ -115,9 +114,10 @@ catopen(const char *name, int type)
|
||||
{
|
||||
struct stat sbuf;
|
||||
struct catentry *np;
|
||||
char *base, *cptr, *cptr1, *lang, *nlspath, *pathP, *pcode;
|
||||
char *plang, *pter, *tmpptr;
|
||||
char *base, *cptr, *cptr1, *nlspath, *pathP, *pcode;
|
||||
char *plang, *pter;
|
||||
int saverr, spcleft;
|
||||
const char *lang, *tmpptr;
|
||||
char path[PATH_MAX];
|
||||
|
||||
/* sanity checking */
|
||||
@ -129,7 +129,7 @@ catopen(const char *name, int type)
|
||||
lang = NULL;
|
||||
else {
|
||||
if (type == NL_CAT_LOCALE)
|
||||
lang = setlocale(LC_MESSAGES, NULL);
|
||||
lang = querylocale(LC_MESSAGES_MASK, __get_locale());
|
||||
else
|
||||
lang = getenv("LANG");
|
||||
|
||||
|
@ -139,8 +139,11 @@ fgetln(FILE *fp, size_t *lenp)
|
||||
(void)memcpy((void *)(fp->_lb._base + off), (void *)fp->_p,
|
||||
len - off);
|
||||
off = len;
|
||||
if (__srefill(fp))
|
||||
break; /* EOF or error: return partial line */
|
||||
if (__srefill(fp)) {
|
||||
if (__sfeof(fp))
|
||||
break;
|
||||
goto error;
|
||||
}
|
||||
if ((p = memchr((void *)fp->_p, '\n', (size_t)fp->_r)) == NULL)
|
||||
continue;
|
||||
|
||||
|
@ -53,7 +53,6 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
|
||||
ORIENT(fp, 1);
|
||||
|
||||
len = 0;
|
||||
/* WEOF or error: return partial line, see fgetln(3). */
|
||||
while ((wc = __fgetwc(fp, locale)) != WEOF) {
|
||||
#define GROW 512
|
||||
if (len * sizeof(wchar_t) >= fp->_lb._size &&
|
||||
@ -65,7 +64,7 @@ fgetwln_l(FILE * __restrict fp, size_t *lenp, locale_t locale)
|
||||
if (wc == L'\n')
|
||||
break;
|
||||
}
|
||||
if (len == 0)
|
||||
if (len == 0 || (wc == WEOF && !__sfeof(fp)))
|
||||
goto error;
|
||||
|
||||
FUNLOCKFILE(fp);
|
||||
|
@ -53,19 +53,9 @@ __fputwc(wchar_t wc, FILE *fp, locale_t locale)
|
||||
size_t i, len;
|
||||
struct xlocale_ctype *l = XLOCALE_CTYPE(locale);
|
||||
|
||||
if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
|
||||
/*
|
||||
* Assume single-byte locale with no special encoding.
|
||||
* A more careful test would be to check
|
||||
* _CurrentRuneLocale->encoding.
|
||||
*/
|
||||
*buf = (unsigned char)wc;
|
||||
len = 1;
|
||||
} else {
|
||||
if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
|
||||
fp->_flags |= __SERR;
|
||||
return (WEOF);
|
||||
}
|
||||
if ((len = l->__wcrtomb(buf, wc, &fp->_mbstate)) == (size_t)-1) {
|
||||
fp->_flags |= __SERR;
|
||||
return (WEOF);
|
||||
}
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
|
@ -125,7 +125,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
|
||||
|
||||
if (fp->_r <= 0 && __srefill(fp)) {
|
||||
/* If fp is at EOF already, we just need space for the NUL. */
|
||||
if (__sferror(fp) || expandtofit(linep, 1, linecapp))
|
||||
if (!__sfeof(fp) || expandtofit(linep, 1, linecapp))
|
||||
goto error;
|
||||
FUNLOCKFILE(fp);
|
||||
(*linep)[0] = '\0';
|
||||
@ -137,7 +137,7 @@ getdelim(char ** __restrict linep, size_t * __restrict linecapp, int delim,
|
||||
if (sappend(linep, &linelen, linecapp, fp->_p, fp->_r))
|
||||
goto error;
|
||||
if (__srefill(fp)) {
|
||||
if (__sferror(fp))
|
||||
if (!__sfeof(fp))
|
||||
goto error;
|
||||
goto done; /* hit EOF */
|
||||
}
|
||||
|
@ -364,6 +364,7 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
|
||||
int nextarg; /* 1-based argument index */
|
||||
va_list orgap; /* original argument pointer */
|
||||
char *convbuf; /* wide to multibyte conversion result */
|
||||
int savserr;
|
||||
|
||||
static const char xdigs_lower[16] = "0123456789abcdef";
|
||||
static const char xdigs_upper[16] = "0123456789ABCDEF";
|
||||
@ -460,6 +461,9 @@ __vfprintf(FILE *fp, locale_t locale, const char *fmt0, va_list ap)
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
savserr = fp->_flags & __SERR;
|
||||
fp->_flags &= ~__SERR;
|
||||
|
||||
convbuf = NULL;
|
||||
fmt = (char *)fmt0;
|
||||
argtable = NULL;
|
||||
@ -1031,6 +1035,8 @@ number: if ((dprec = prec) >= 0)
|
||||
free(convbuf);
|
||||
if (__sferror(fp))
|
||||
ret = EOF;
|
||||
else
|
||||
fp->_flags |= savserr;
|
||||
if ((argtable != NULL) && (argtable != statargtable))
|
||||
free (argtable);
|
||||
return (ret);
|
||||
|
@ -444,6 +444,7 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
|
||||
int nextarg; /* 1-based argument index */
|
||||
va_list orgap; /* original argument pointer */
|
||||
wchar_t *convbuf; /* multibyte to wide conversion result */
|
||||
int savserr;
|
||||
|
||||
static const char xdigs_lower[16] = "0123456789abcdef";
|
||||
static const char xdigs_upper[16] = "0123456789ABCDEF";
|
||||
@ -536,6 +537,9 @@ __vfwprintf(FILE *fp, locale_t locale, const wchar_t *fmt0, va_list ap)
|
||||
return (EOF);
|
||||
}
|
||||
|
||||
savserr = fp->_flags & __SERR;
|
||||
fp->_flags &= ~__SERR;
|
||||
|
||||
convbuf = NULL;
|
||||
fmt = (wchar_t *)fmt0;
|
||||
argtable = NULL;
|
||||
@ -1096,6 +1100,8 @@ number: if ((dprec = prec) >= 0)
|
||||
free(convbuf);
|
||||
if (__sferror(fp))
|
||||
ret = EOF;
|
||||
else
|
||||
fp->_flags |= savserr;
|
||||
if ((argtable != NULL) && (argtable != statargtable))
|
||||
free (argtable);
|
||||
return (ret);
|
||||
|
20
lib/libifc/Makefile
Normal file
20
lib/libifc/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PACKAGE= lib${LIB}
|
||||
LIB= ifc
|
||||
# Don't build shared library, for now.
|
||||
NO_PIC=
|
||||
|
||||
SHLIBDIR?= /lib
|
||||
SHLIB_MAJOR= 1
|
||||
SRCS= libifc.c libifc_internal.c
|
||||
|
||||
INCSDIR= ${INCLUDEDIR}
|
||||
INCS= libifc.h
|
||||
|
||||
#MAN= libifco.3
|
||||
|
||||
CFLAGS+= -I${.CURDIR}
|
||||
WARNS?=6
|
||||
|
||||
.include <bsd.lib.mk>
|
397
lib/libifc/libifc.c
Normal file
397
lib/libifc/libifc.c
Normal file
@ -0,0 +1,397 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "libifc.h"
|
||||
#include "libifc_internal.h"
|
||||
|
||||
|
||||
libifc_handle_t *
|
||||
libifc_open(void)
|
||||
{
|
||||
struct libifc_handle *h;
|
||||
|
||||
h = calloc(1, sizeof(struct libifc_handle));
|
||||
|
||||
for (int i = 0; i <= AF_MAX; i++) {
|
||||
h->sockets[i] = -1;
|
||||
}
|
||||
|
||||
return (h);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
libifc_close(libifc_handle_t *h)
|
||||
{
|
||||
for (int i = 0; i <= AF_MAX; i++) {
|
||||
if (h->sockets[i] != -1) {
|
||||
(void)close(h->sockets[i]);
|
||||
}
|
||||
}
|
||||
free(h);
|
||||
}
|
||||
|
||||
|
||||
libifc_errtype
|
||||
libifc_err_errtype(libifc_handle_t *h)
|
||||
{
|
||||
return (h->error.errtype);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
libifc_err_errno(libifc_handle_t *h)
|
||||
{
|
||||
return (h->error.errcode);
|
||||
}
|
||||
|
||||
|
||||
unsigned long
|
||||
libifc_err_ioctlreq(libifc_handle_t *h)
|
||||
{
|
||||
return (h->error.ioctl_request);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
libifc_get_description(libifc_handle_t *h, const char *name, char **description)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
char *descr = NULL;
|
||||
size_t descrlen = 64;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
for (;;) {
|
||||
if ((descr = reallocf(descr, descrlen)) == NULL) {
|
||||
h->error.errtype = OTHER;
|
||||
h->error.errcode = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
ifr.ifr_buffer.buffer = descr;
|
||||
ifr.ifr_buffer.length = descrlen;
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFDESCR,
|
||||
&ifr) != 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (ifr.ifr_buffer.buffer == descr) {
|
||||
if (strlen(descr) > 0) {
|
||||
*description = strdup(descr);
|
||||
free(descr);
|
||||
return (0);
|
||||
}
|
||||
} else if (ifr.ifr_buffer.length > descrlen) {
|
||||
descrlen = ifr.ifr_buffer.length;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
free(descr);
|
||||
h->error.errtype = OTHER;
|
||||
h->error.errcode = 0;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
libifc_set_description(libifc_handle_t *h, const char *name,
|
||||
const char *newdescription)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
int desclen;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
desclen = strlen(newdescription);
|
||||
|
||||
/*
|
||||
* Unset description if the new description is 0 characters long.
|
||||
* TODO: Decide whether this should be an error condition instead.
|
||||
*/
|
||||
if (desclen == 0) {
|
||||
return (libifc_unset_description(h, name));
|
||||
}
|
||||
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
|
||||
ifr.ifr_buffer.length = desclen + 1;
|
||||
ifr.ifr_buffer.buffer = strdup(newdescription);
|
||||
if (ifr.ifr_buffer.buffer == NULL) {
|
||||
h->error.errtype = OTHER;
|
||||
h->error.errcode = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) != 0) {
|
||||
free(ifr.ifr_buffer.buffer);
|
||||
return (-1);
|
||||
}
|
||||
free(ifr.ifr_buffer.buffer);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_unset_description(libifc_handle_t *h, const char *name)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_buffer.length = 0;
|
||||
ifr.ifr_buffer.buffer = NULL;
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFDESCR, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
char *tmpname;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
tmpname = strdup(newname);
|
||||
if (tmpname == NULL) {
|
||||
h->error.errtype = OTHER;
|
||||
h->error.errcode = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_data = tmpname;
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFNAME, &ifr) != 0) {
|
||||
free(tmpname);
|
||||
return (-1);
|
||||
}
|
||||
free(tmpname);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_mtu = mtu;
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMTU, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMTU, &ifr) == -1) {
|
||||
return (-1);
|
||||
}
|
||||
*mtu = ifr.ifr_mtu;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_set_metric(libifc_handle_t *h, const char *name, const int mtu)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
ifr.ifr_mtu = mtu;
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFMETRIC, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFMETRIC, &ifr) == -1) {
|
||||
return (-1);
|
||||
}
|
||||
*metric = ifr.ifr_metric;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_set_capability(libifc_handle_t *h, const char *name,
|
||||
const int capability)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
struct libifc_capabilities ifcap;
|
||||
int flags;
|
||||
int value;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
if (libifc_get_capability(h, name, &ifcap) != 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
value = capability;
|
||||
flags = ifcap.curcap;
|
||||
if (value < 0) {
|
||||
value = -value;
|
||||
flags &= ~value;
|
||||
} else {
|
||||
flags |= value;
|
||||
}
|
||||
flags &= ifcap.reqcap;
|
||||
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
|
||||
/*
|
||||
* TODO: Verify that it's safe to not have ifr.ifr_curcap
|
||||
* set for this request.
|
||||
*/
|
||||
ifr.ifr_reqcap = flags;
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCSIFCAP, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_get_capability(libifc_handle_t *h, const char *name,
|
||||
struct libifc_capabilities *capability)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCGIFCAP, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
capability->curcap = ifr.ifr_curcap;
|
||||
capability->reqcap = ifr.ifr_reqcap;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_destroy_interface(libifc_handle_t *h, const char *name)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFDESTROY, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
int libifc_create_interface(libifc_handle_t *h, const char *name, char **ifname)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
|
||||
memset(&ifr, 0, sizeof(struct ifreq));
|
||||
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
|
||||
|
||||
/*
|
||||
* TODO:
|
||||
* Insert special snowflake handling here. See GitHub issue #12 for details.
|
||||
* In the meantime, hard-nosupport interfaces that need special handling.
|
||||
*/
|
||||
if ((strncmp(name, "wlan", strlen("wlan")) == 0) ||
|
||||
(strncmp(name, "vlan", strlen("vlan")) == 0) ||
|
||||
(strncmp(name, "vxlan", strlen("vxlan")) == 0)) {
|
||||
h->error.errtype = OTHER;
|
||||
h->error.errcode = ENOSYS;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/* No special handling for this interface type. */
|
||||
|
||||
if (libifc_ioctlwrap(h, AF_LOCAL, SIOCIFCREATE2, &ifr) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
*ifname = strdup(ifr.ifr_name);
|
||||
return (0);
|
||||
}
|
111
lib/libifc/libifc.h
Normal file
111
lib/libifc/libifc.h
Normal file
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
typedef enum {
|
||||
OTHER, IOCTL, SOCKET
|
||||
} libifc_errtype;
|
||||
|
||||
/*
|
||||
* Opaque definition so calling application can just pass a
|
||||
* pointer to it for library use.
|
||||
*/
|
||||
struct libifc_handle;
|
||||
typedef struct libifc_handle libifc_handle_t;
|
||||
|
||||
struct libifc_capabilities {
|
||||
/** Current capabilities (ifconfig prints this as 'options')*/
|
||||
int curcap;
|
||||
/** Requested capabilities (ifconfig prints this as 'capabilities')*/
|
||||
int reqcap;
|
||||
};
|
||||
|
||||
|
||||
/** Retrieves a new state object for use in other API calls.
|
||||
* Example usage:
|
||||
*{@code
|
||||
* // Create state object
|
||||
* libifc_handle_t *lifh = libifc_open();
|
||||
*
|
||||
* // Do stuff with it
|
||||
*
|
||||
* // Dispose of the state object
|
||||
* libifc_close(lifh);
|
||||
* lifh = NULL;
|
||||
*}
|
||||
*/
|
||||
libifc_handle_t *libifc_open(void);
|
||||
|
||||
/** Frees resources held in the provided state object.
|
||||
* @param h The state object to close.
|
||||
* @see #libifc_open(void)
|
||||
*/
|
||||
void libifc_close(libifc_handle_t *h);
|
||||
|
||||
/** Identifies what kind of error occured. */
|
||||
libifc_errtype libifc_err_errtype(libifc_handle_t *h);
|
||||
|
||||
/** Retrieves the errno associated with the error, if any. */
|
||||
int libifc_err_errno(libifc_handle_t *h);
|
||||
|
||||
/** If error type was IOCTL, this identifies which request failed. */
|
||||
unsigned long libifc_err_ioctlreq(libifc_handle_t *h);
|
||||
|
||||
int libifc_get_description(libifc_handle_t *h, const char *name,
|
||||
char **description);
|
||||
int libifc_set_description(libifc_handle_t *h, const char *name,
|
||||
const char *newdescription);
|
||||
int libifc_unset_description(libifc_handle_t *h, const char *name);
|
||||
int libifc_set_name(libifc_handle_t *h, const char *name, const char *newname);
|
||||
int libifc_set_mtu(libifc_handle_t *h, const char *name, const int mtu);
|
||||
int libifc_get_mtu(libifc_handle_t *h, const char *name, int *mtu);
|
||||
|
||||
int libifc_set_metric(libifc_handle_t *h, const char *name, const int metric);
|
||||
int libifc_get_metric(libifc_handle_t *h, const char *name, int *metric);
|
||||
|
||||
int libifc_set_capability(libifc_handle_t *h, const char *name,
|
||||
const int capability);
|
||||
int libifc_get_capability(libifc_handle_t *h, const char *name,
|
||||
struct libifc_capabilities *capability);
|
||||
|
||||
/** Destroy a virtual interface
|
||||
* @param name Interface to destroy
|
||||
*/
|
||||
int libifc_destroy_interface(libifc_handle_t *h, const char *name);
|
||||
|
||||
/** Creates a (virtual) interface
|
||||
* @param name Name of interface to create. Example: bridge or bridge42
|
||||
* @param name ifname Is set to actual name of created interface
|
||||
*/
|
||||
int libifc_create_interface(libifc_handle_t *h, const char *name,
|
||||
char **ifname);
|
100
lib/libifc/libifc_internal.c
Normal file
100
lib/libifc/libifc_internal.c
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
|
||||
#include <net/if.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
#include "libifc.h" // Needed for libifc_errstate
|
||||
#include "libifc_internal.h"
|
||||
|
||||
int
|
||||
libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode)
|
||||
{
|
||||
if (rcode != 0) {
|
||||
h->error.errtype = IOCTL;
|
||||
h->error.ioctl_request = request;
|
||||
h->error.errcode = errno;
|
||||
}
|
||||
return (rcode);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily,
|
||||
unsigned long request, struct ifreq *ifr)
|
||||
{
|
||||
int s;
|
||||
|
||||
if (libifc_socket(h, addressfamily, &s) != 0) {
|
||||
return (-1);
|
||||
}
|
||||
|
||||
int rcode = ioctl(s, request, ifr);
|
||||
return (libifc_ioctlwrap_ret(h, request, rcode));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function to get socket for the specified address family.
|
||||
* If the socket doesn't already exist, attempt to create it.
|
||||
*/
|
||||
int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s)
|
||||
{
|
||||
if (addressfamily > AF_MAX) {
|
||||
h->error.errtype = SOCKET;
|
||||
h->error.errcode = EINVAL;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (h->sockets[addressfamily] != -1) {
|
||||
*s = h->sockets[addressfamily];
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* We don't have a socket of that type available. Create one. */
|
||||
h->sockets[addressfamily] = socket(addressfamily, SOCK_DGRAM, 0);
|
||||
if (h->sockets[addressfamily] == -1) {
|
||||
h->error.errtype = SOCKET;
|
||||
h->error.errcode = errno;
|
||||
return (-1);
|
||||
}
|
||||
|
||||
*s = h->sockets[addressfamily];
|
||||
return (0);
|
||||
}
|
87
lib/libifc/libifc_internal.h
Normal file
87
lib/libifc/libifc_internal.h
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "libifc.h"
|
||||
|
||||
|
||||
struct errstate {
|
||||
/**
|
||||
* Type of error.
|
||||
*/
|
||||
libifc_errtype errtype;
|
||||
|
||||
/**
|
||||
* The error occured in this ioctl() request.
|
||||
* Populated if errtype = IOCTL
|
||||
*/
|
||||
unsigned long ioctl_request;
|
||||
|
||||
/**
|
||||
* The value of the global errno variable when the error occured.
|
||||
*/
|
||||
int errcode;
|
||||
};
|
||||
|
||||
struct libifc_handle {
|
||||
struct errstate error;
|
||||
int sockets[AF_MAX + 1];
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves socket for address family <paramref name="addressfamily"> from
|
||||
* cache, or creates it if it doesn't already exist.
|
||||
* @param addressfamily The address family of the socket to retrieve
|
||||
* @param s The retrieved socket.
|
||||
* @return 0 on success, -1 on failure.
|
||||
* {@example
|
||||
* This example shows how to retrieve a socket from the cache.
|
||||
* {@code
|
||||
* static void myfunc() \{
|
||||
* int s;
|
||||
* if (libifc_socket(AF_LOCAL, &s) != 0) \{
|
||||
* // Handle error state here
|
||||
* \}
|
||||
* // user code here
|
||||
* \}
|
||||
* }
|
||||
* }
|
||||
*/
|
||||
int libifc_socket(libifc_handle_t *h, const int addressfamily, int *s);
|
||||
|
||||
/** Function used by other wrapper functions to populate _errstate when appropriate.*/
|
||||
int libifc_ioctlwrap_ret(libifc_handle_t *h, unsigned long request, int rcode);
|
||||
|
||||
/** Function to wrap ioctl() and automatically populate libifc_errstate when appropriate.*/
|
||||
int libifc_ioctlwrap(libifc_handle_t *h, const int addressfamily,
|
||||
unsigned long request, struct ifreq *ifr);
|
@ -439,7 +439,7 @@ dos_readdir(struct open_file *fd, struct dirent *d)
|
||||
u_char fn[261];
|
||||
DOS_DIR dd;
|
||||
size_t res;
|
||||
u_int chk, i, x, xdn;
|
||||
u_int chk, x, xdn;
|
||||
int err;
|
||||
|
||||
x = chk = 0;
|
||||
@ -598,7 +598,7 @@ lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep)
|
||||
u_char lfn[261];
|
||||
u_char sfn[13];
|
||||
u_int nsec, lsec, xdn, chk, sec, ent, x;
|
||||
int err, ok, i;
|
||||
int err, ok;
|
||||
|
||||
if (!clus)
|
||||
for (ent = 0; ent < 2; ent++)
|
||||
@ -774,11 +774,11 @@ fatget(DOS_FS *fs, u_int *c)
|
||||
int err = 0;
|
||||
|
||||
if (fat.unit != dd->d_unit) {
|
||||
/* fat cache was changed to another device, dont use it */
|
||||
/* fat cache was changed to another device, don't use it */
|
||||
err = ioread(fs, secbyt(fs->lsnfat) + fatoff(fs->fatsz, *c), buf,
|
||||
fs->fatsz != 32 ? 2 : 4);
|
||||
if (err)
|
||||
return err;
|
||||
return (err);
|
||||
} else {
|
||||
offset = fatoff(fs->fatsz, *c);
|
||||
nbyte = fs->fatsz != 32 ? 2 : 4;
|
||||
|
@ -645,7 +645,7 @@ _mips_get_tls(void)
|
||||
".set\tmips64r2\n\t"
|
||||
"rdhwr\t%0, $29\n\t"
|
||||
".set\tpop"
|
||||
: "=v" (_rv));
|
||||
: "=r" (_rv));
|
||||
/*
|
||||
* XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317'
|
||||
*
|
||||
@ -670,7 +670,7 @@ _mips_get_tls(void)
|
||||
".set\tmips32r2\n\t"
|
||||
"rdhwr\t%0, $29\n\t"
|
||||
".set\tpop"
|
||||
: "=v" (_rv));
|
||||
: "=r" (_rv));
|
||||
/*
|
||||
* XXXSS See 'git show c6be4f4d2d1b71c04de5d3bbb6933ce2dbcdb317'
|
||||
*
|
||||
|
@ -7515,7 +7515,7 @@ smpphycontrol(struct cam_device *device, int argc, char **argv,
|
||||
response = malloc(sizeof(*response));
|
||||
if (response == NULL) {
|
||||
warn("%s: unable to allocate %zd bytes", __func__,
|
||||
sizeof(*request));
|
||||
sizeof(*response));
|
||||
retval = 1;
|
||||
goto bailout;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd July 14, 2015
|
||||
.Dd August 25, 2016
|
||||
.Dt GGATEC 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -161,10 +161,10 @@ option.
|
||||
Use a CD-ROM device on a remote host.
|
||||
.Bd -literal -offset indent
|
||||
server# cat /etc/gg.exports
|
||||
client RO /dev/acd0
|
||||
client RO /dev/cd0
|
||||
server# ggated
|
||||
|
||||
client# ggatec create -o ro server /dev/acd0
|
||||
client# ggatec create -o ro server /dev/cd0
|
||||
ggate0
|
||||
client# mount_cd9660 /dev/ggate0 /cdrom
|
||||
.Ed
|
||||
|
@ -24,7 +24,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd January 27, 2016
|
||||
.Dd August 25, 2016
|
||||
.Dt GGATED 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -87,7 +87,7 @@ An alternate location for the exports file.
|
||||
.Pp
|
||||
The format of an exports file is as follows:
|
||||
.Bd -literal -offset indent
|
||||
1.2.3.4 RO /dev/acd0
|
||||
1.2.3.4 RO /dev/cd0
|
||||
1.2.3.0/24 RW /tmp/test.img
|
||||
hostname WO /tmp/image
|
||||
.Ed
|
||||
@ -108,7 +108,7 @@ option.
|
||||
.Sh EXAMPLES
|
||||
Export CD-ROM device and a file:
|
||||
.Bd -literal -offset indent
|
||||
# echo "1.2.3.0/24 RO /dev/acd0" > /etc/gg.exports
|
||||
# echo "1.2.3.0/24 RO /dev/cd0" > /etc/gg.exports
|
||||
# echo "client RW /image" >> /etc/gg.exports
|
||||
# ggated
|
||||
.Ed
|
||||
|
9
share/examples/libifc/Makefile
Normal file
9
share/examples/libifc/Makefile
Normal file
@ -0,0 +1,9 @@
|
||||
# $FreeBSD$
|
||||
|
||||
default:
|
||||
$(CC) -Wall -fPIC -lifc -g -o example_setdescription setdescription.c
|
||||
$(CC) -Wall -fPIC -lifc -g -o example_setmtu setmtu.c
|
||||
$(CC) -Wall -fPIC -lifc -g -o example_ifdestroy ifdestroy.c
|
||||
$(CC) -Wall -fPIC -lifc -g -o example_ifcreate ifcreate.c
|
||||
clean:
|
||||
rm -f example_*
|
93
share/examples/libifc/ifcreate.c
Normal file
93
share/examples/libifc/ifcreate.c
Normal file
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libifc.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
errx(EINVAL, "Invalid number of arguments."
|
||||
" Only one argument is accepted, and it should be the name"
|
||||
" of the interface to be created.");
|
||||
}
|
||||
|
||||
char *ifname, *ifactualname;
|
||||
|
||||
/* We have a static number of arguments. Therefore we can do it simple. */
|
||||
ifname = strdup(argv[1]);
|
||||
|
||||
printf("Requested interface name: %s\n", ifname);
|
||||
|
||||
libifc_handle_t *lifh = libifc_open();
|
||||
if (libifc_create_interface(lifh, ifname, &ifactualname) == 0) {
|
||||
printf("Successfully created interface '%s'\n", ifactualname);
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
free(ifactualname);
|
||||
return (0);
|
||||
} else {
|
||||
switch (libifc_err_errtype(lifh)) {
|
||||
case SOCKET:
|
||||
warnx("couldn't create socket. This shouldn't happen.\n");
|
||||
break;
|
||||
case IOCTL:
|
||||
if (libifc_err_ioctlreq(lifh) == SIOCIFCREATE2) {
|
||||
warnx(
|
||||
"Failed to create interface (SIOCIFCREATE2)\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warnx(
|
||||
"This is a thorough example accommodating for temporary"
|
||||
" 'not implemented yet' errors. That's likely what happened"
|
||||
" now. If not, your guess is as good as mine. ;)"
|
||||
" Error code: %d\n", libifc_err_errno(
|
||||
lifh));
|
||||
break;
|
||||
}
|
||||
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
free(ifactualname);
|
||||
return (-1);
|
||||
}
|
||||
}
|
87
share/examples/libifc/ifdestroy.c
Normal file
87
share/examples/libifc/ifdestroy.c
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libifc.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2) {
|
||||
errx(EINVAL, "Invalid number of arguments."
|
||||
" Only one argument is accepted, and it should be the name"
|
||||
" of the interface to be destroyed.");
|
||||
}
|
||||
|
||||
char *ifname;
|
||||
|
||||
/* We have a static number of arguments. Therefore we can do it simple. */
|
||||
ifname = strdup(argv[1]);
|
||||
|
||||
printf("Interface name: %s\n", ifname);
|
||||
|
||||
libifc_handle_t *lifh = libifc_open();
|
||||
if (libifc_destroy_interface(lifh, ifname) == 0) {
|
||||
printf("Successfully destroyed interface '%s'.", ifname);
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
return (0);
|
||||
} else {
|
||||
switch (libifc_err_errtype(lifh)) {
|
||||
case SOCKET:
|
||||
warnx("couldn't create socket. This shouldn't happen.\n");
|
||||
break;
|
||||
case IOCTL:
|
||||
if (libifc_err_ioctlreq(lifh) == SIOCIFDESTROY) {
|
||||
warnx(
|
||||
"Failed to destroy interface (SIOCIFDESTROY)\n");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warnx(
|
||||
"Should basically never end up here in this example.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
return (-1);
|
||||
}
|
||||
}
|
91
share/examples/libifc/setdescription.c
Normal file
91
share/examples/libifc/setdescription.c
Normal file
@ -0,0 +1,91 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libifc.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
errx(EINVAL, "Invalid number of arguments."
|
||||
" First argument should be interface name, second argument"
|
||||
" should be the description to set.");
|
||||
}
|
||||
|
||||
char *ifname, *ifdescr, *curdescr;
|
||||
/* We have a static number of arguments. Therefore we can do it simple. */
|
||||
ifname = strdup(argv[1]);
|
||||
ifdescr = strdup(argv[2]);
|
||||
curdescr = NULL;
|
||||
|
||||
printf("Interface name: %s\n", ifname);
|
||||
|
||||
libifc_handle_t *lifh = libifc_open();
|
||||
if (libifc_get_description(lifh, ifname, &curdescr) == 0) {
|
||||
printf("Old description: %s\n", curdescr);
|
||||
}
|
||||
|
||||
printf("New description: %s\n\n", ifdescr);
|
||||
|
||||
if (libifc_set_description(lifh, ifname, ifdescr) == 0) {
|
||||
printf("New description successfully set.\n");
|
||||
} else {
|
||||
switch (libifc_err_errtype(lifh)) {
|
||||
case SOCKET:
|
||||
err(libifc_err_errno(lifh), "Socket error");
|
||||
break;
|
||||
case IOCTL:
|
||||
err(libifc_err_errno(
|
||||
lifh), "IOCTL(%lu) error",
|
||||
libifc_err_ioctlreq(lifh));
|
||||
break;
|
||||
case OTHER:
|
||||
err(libifc_err_errno(lifh), "Other error");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(ifname);
|
||||
free(ifdescr);
|
||||
free(curdescr);
|
||||
ifname = NULL;
|
||||
ifdescr = NULL;
|
||||
curdescr = NULL;
|
||||
|
||||
libifc_close(lifh);
|
||||
return (0);
|
||||
}
|
94
share/examples/libifc/setmtu.c
Normal file
94
share/examples/libifc/setmtu.c
Normal file
@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Marie Helene Kvello-Aune
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* thislist of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <net/if.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libifc.h>
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 3) {
|
||||
errx(EINVAL, "Invalid number of arguments."
|
||||
" First argument should be interface name, second argument"
|
||||
" should be the MTU to set.");
|
||||
}
|
||||
|
||||
char *ifname, *ptr;
|
||||
int mtu;
|
||||
|
||||
/* We have a static number of arguments. Therefore we can do it simple. */
|
||||
ifname = strdup(argv[1]);
|
||||
mtu = (int)strtol(argv[2], &ptr, 10);
|
||||
|
||||
printf("Interface name: %s\n", ifname);
|
||||
printf("New MTU: %d", mtu);
|
||||
|
||||
libifc_handle_t *lifh = libifc_open();
|
||||
if (libifc_set_mtu(lifh, ifname, mtu) == 0) {
|
||||
printf("Successfully changed MTU of %s to %d\n", ifname, mtu);
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
return (0);
|
||||
} else {
|
||||
switch (libifc_err_errtype(lifh)) {
|
||||
case SOCKET:
|
||||
warnx("couldn't create socket. This shouldn't happen.\n");
|
||||
break;
|
||||
case IOCTL:
|
||||
if (libifc_err_ioctlreq(lifh) == SIOCSIFMTU) {
|
||||
warnx("Failed to set MTU (SIOCSIFMTU)\n");
|
||||
} else {
|
||||
warnx(
|
||||
"Failed to set MTU due to error in unexpected ioctl() call %lu. Error code: %i.\n",
|
||||
libifc_err_ioctlreq(lifh),
|
||||
libifc_err_errno(lifh));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
warnx(
|
||||
"Should basically never end up here in this example.\n");
|
||||
break;
|
||||
}
|
||||
|
||||
libifc_close(lifh);
|
||||
lifh = NULL;
|
||||
free(ifname);
|
||||
return (-1);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
.\" Copyright (c) 2015 Nuxi, https://nuxi.nl/
|
||||
.\" Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
|
||||
.\"
|
||||
.\" Redistribution and use in source and binary forms, with or without
|
||||
.\" modification, are permitted provided that the following conditions
|
||||
@ -22,17 +22,25 @@
|
||||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.Dd October 22, 2015
|
||||
.Dd August 24, 2016
|
||||
.Dt CLOUDABI 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm cloudabi ,
|
||||
.Nm cloudabi32 ,
|
||||
.Nm cloudabi64
|
||||
.Nd CloudABI support
|
||||
.Sh SYNOPSIS
|
||||
Support for 64-bit CloudABI executables can be compiled into the kernel
|
||||
Support for 32-bit CloudABI executables can be compiled into the kernel
|
||||
by adding this line to the kernel configuration file:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "options COMPAT_CLOUDABI32"
|
||||
.Ed
|
||||
.Pp
|
||||
Similarly,
|
||||
support for 64-bit CloudABI executables can be enabled by adding this
|
||||
line:
|
||||
.Bd -ragged -offset indent
|
||||
.Cd "options COMPAT_CLOUDABI64"
|
||||
.Ed
|
||||
.Pp
|
||||
@ -40,6 +48,7 @@ CloudABI support can also be loaded at boot time from
|
||||
.Xr loader.conf 5 :
|
||||
.Bd -literal -offset indent
|
||||
cloudabi_load="YES"
|
||||
cloudabi32_load="YES"
|
||||
cloudabi64_load="YES"
|
||||
.Ed
|
||||
.Sh DESCRIPTION
|
||||
@ -52,19 +61,21 @@ and hardened against security exploits.
|
||||
.Pp
|
||||
Support for CloudABI on
|
||||
.Fx
|
||||
consists of two separate kernel modules.
|
||||
consists of three separate kernel modules.
|
||||
The
|
||||
.Nm cloudabi
|
||||
kernel module implements all of the system calls that do not depend on
|
||||
data structures that differ between architectures.
|
||||
data structures that differ between hardware architectures.
|
||||
.Pp
|
||||
The
|
||||
.Nm cloudabi32
|
||||
and
|
||||
.Nm cloudabi64
|
||||
kernel module provides implementations of all of the machine-dependent
|
||||
system calls.
|
||||
It assumes that pointers stored in data structures provided as system
|
||||
call arguments are 64 bits in size.
|
||||
It also provides the image activator that loads and starts 64-bit ELF
|
||||
kernel modules provide implementations of all of the machine-dependent
|
||||
system calls,
|
||||
assuming that pointers stored in data structures are either 32 bits or
|
||||
64 bits in size.
|
||||
These modules also provide the image activators that load and start ELF
|
||||
executables.
|
||||
.Pp
|
||||
Though the
|
||||
@ -72,8 +83,12 @@ Though the
|
||||
module can be loaded on any architecture supported by
|
||||
.Fx ,
|
||||
the
|
||||
.Nm cloudabi32
|
||||
module is only available on i386 and amd64.
|
||||
The same holds for the
|
||||
.Nm cloudabi64
|
||||
module is only available for amd64 and arm64.
|
||||
module,
|
||||
which is only available for amd64 and arm64.
|
||||
.Pp
|
||||
A full cross compilation toolchain for CloudABI is available in the
|
||||
.Pa devel/cloudabi-toolchain
|
||||
@ -93,6 +108,9 @@ restricted set of resources.
|
||||
.Xr linux 4 ,
|
||||
.Xr elf 5
|
||||
.Pp
|
||||
CloudABI for FreeBSD:
|
||||
.Pa https://nuxi.nl/cloudabi/freebsd/ .
|
||||
.Pp
|
||||
cloudlibc on GitHub:
|
||||
.Pa https://github.com/NuxiNL/cloudlibc .
|
||||
.Pp
|
||||
|
@ -82,6 +82,7 @@ LIBIBMAD?= ${DESTDIR}${LIBDIR}/libibmad.a
|
||||
LIBIBSDP?= ${DESTDIR}${LIBDIR}/libibsdp.a
|
||||
LIBIBUMAD?= ${DESTDIR}${LIBDIR}/libibumad.a
|
||||
LIBIBVERBS?= ${DESTDIR}${LIBDIR}/libibverbs.a
|
||||
LIBIFC?= ${DESTDIR}${LIBDIR}/libifc.a
|
||||
LIBIPSEC?= ${DESTDIR}${LIBDIR}/libipsec.a
|
||||
LIBJAIL?= ${DESTDIR}${LIBDIR}/libjail.a
|
||||
LIBKADM5CLNT?= ${DESTDIR}${LIBDIR}/libkadm5clnt.a
|
||||
|
@ -128,6 +128,11 @@ CWARNFLAGS+= -Wno-error=address \
|
||||
-Wno-error=unused-value
|
||||
.endif
|
||||
|
||||
# GCC 5.3.0
|
||||
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 50300
|
||||
CWARNFLAGS+= -Wno-error=strict-overflow
|
||||
.endif
|
||||
|
||||
# GCC 6.1.0
|
||||
.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 60100
|
||||
CWARNFLAGS+= -Wno-error=misleading-indentation \
|
||||
|
@ -105,6 +105,7 @@ _LIBRARIES= \
|
||||
heimntlm \
|
||||
heimsqlite \
|
||||
hx509 \
|
||||
ifc \
|
||||
ipsec \
|
||||
jail \
|
||||
kadm5clnt \
|
||||
|
@ -23,6 +23,7 @@ _src_env_conf_included_: .NOTMAIN
|
||||
.if make(*install*) && ${.MAKE.LEVEL} == 0
|
||||
META_MODE= normal
|
||||
MK_META_MODE= no
|
||||
.export MK_META_MODE
|
||||
.endif
|
||||
|
||||
# If we were found via .../share/mk we need to replace that
|
||||
|
231
sys/amd64/cloudabi32/cloudabi32_sysvec.c
Normal file
231
sys/amd64/cloudabi32/cloudabi32_sysvec.c
Normal file
@ -0,0 +1,231 @@
|
||||
/*-
|
||||
* Copyright (c) 2015-2016 Nuxi, https://nuxi.nl/
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/imgact.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysent.h>
|
||||
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
|
||||
#include <machine/frame.h>
|
||||
#include <machine/pcb.h>
|
||||
#include <machine/vmparam.h>
|
||||
|
||||
#include <compat/cloudabi/cloudabi_util.h>
|
||||
|
||||
#include <compat/cloudabi32/cloudabi32_syscall.h>
|
||||
#include <compat/cloudabi32/cloudabi32_util.h>
|
||||
|
||||
#include <compat/ia32/ia32_signal.h>
|
||||
#include <compat/ia32/ia32_util.h>
|
||||
|
||||
extern const char *cloudabi32_syscallnames[];
|
||||
extern struct sysent cloudabi32_sysent[];
|
||||
|
||||
extern unsigned long ia32_maxssiz;
|
||||
|
||||
static int
|
||||
cloudabi32_fixup_tcb(register_t **stack_base, struct image_params *imgp)
|
||||
{
|
||||
int error;
|
||||
uint32_t args[2];
|
||||
|
||||
/* Place auxiliary vector and TCB on the stack. */
|
||||
error = cloudabi32_fixup(stack_base, imgp);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* On i386, the TCB is referred to by %gs:0. Reuse the empty
|
||||
* space normally used by the return address (args[0]) to store
|
||||
* a single element array, containing a pointer to the TCB. %gs
|
||||
* base will point to this.
|
||||
*
|
||||
* Also let the first argument of the entry point (args[1])
|
||||
* refer to the auxiliary vector, which is stored right after
|
||||
* the TCB.
|
||||
*/
|
||||
args[0] = (uintptr_t)*stack_base;
|
||||
args[1] = (uintptr_t)*stack_base +
|
||||
roundup(sizeof(cloudabi32_tcb_t), sizeof(register_t));
|
||||
*stack_base -= howmany(sizeof(args), sizeof(register_t));
|
||||
return (copyout(args, *stack_base, sizeof(args)));
|
||||
}
|
||||
|
||||
static void
|
||||
cloudabi32_proc_setregs(struct thread *td, struct image_params *imgp,
|
||||
unsigned long stack)
|
||||
{
|
||||
|
||||
ia32_setregs(td, imgp, stack);
|
||||
(void)cpu_set_user_tls(td, (void *)stack);
|
||||
}
|
||||
|
||||
static int
|
||||
cloudabi32_fetch_syscall_args(struct thread *td, struct syscall_args *sa)
|
||||
{
|
||||
struct trapframe *frame = td->td_frame;
|
||||
int error;
|
||||
|
||||
/* Obtain system call number. */
|
||||
sa->code = frame->tf_rax;
|
||||
if (sa->code >= CLOUDABI32_SYS_MAXSYSCALL)
|
||||
return (ENOSYS);
|
||||
sa->callp = &cloudabi32_sysent[sa->code];
|
||||
sa->narg = sa->callp->sy_narg;
|
||||
|
||||
/*
|
||||
* Fetch system call arguments.
|
||||
*
|
||||
* The vDSO has already made sure that the arguments are
|
||||
* eight-byte aligned. Pointers and size_t parameters are
|
||||
* zero-extended. This makes it possible to copy in the
|
||||
* arguments directly. As long as the call doesn't use 32-bit
|
||||
* data structures, we can just invoke the same system call
|
||||
* implementation used by 64-bit processes.
|
||||
*/
|
||||
error = copyin((void *)frame->tf_rcx, sa->args,
|
||||
sa->narg * sizeof(sa->args[0]));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
/* Default system call return values. */
|
||||
td->td_retval[0] = 0;
|
||||
td->td_retval[1] = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void
|
||||
cloudabi32_set_syscall_retval(struct thread *td, int error)
|
||||
{
|
||||
struct trapframe *frame = td->td_frame;
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
/*
|
||||
* System call succeeded.
|
||||
*
|
||||
* Simply copy out the 64-bit return values into the
|
||||
* same buffer provided for system call arguments. The
|
||||
* vDSO will copy them to the right spot, truncating
|
||||
* pointers and size_t values to 32 bits.
|
||||
*/
|
||||
frame->tf_rax = copyout(td->td_retval, (void *)frame->tf_rcx,
|
||||
sizeof(td->td_retval)) == 0 ? 0 : CLOUDABI_EFAULT;
|
||||
break;
|
||||
case ERESTART:
|
||||
/* Restart system call. */
|
||||
frame->tf_rip -= frame->tf_err;
|
||||
frame->tf_r10 = frame->tf_rcx;
|
||||
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
|
||||
break;
|
||||
case EJUSTRETURN:
|
||||
break;
|
||||
default:
|
||||
/* System call returned an error. */
|
||||
frame->tf_rax = cloudabi_convert_errno(error);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cloudabi32_schedtail(struct thread *td)
|
||||
{
|
||||
struct trapframe *frame = td->td_frame;
|
||||
register_t retval[2];
|
||||
|
||||
/* Return values for processes returning from fork. */
|
||||
if ((td->td_pflags & TDP_FORKING) != 0) {
|
||||
retval[0] = CLOUDABI_PROCESS_CHILD;
|
||||
retval[1] = td->td_tid;
|
||||
copyout(retval, (void *)frame->tf_rcx, sizeof(retval));
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cloudabi32_thread_setregs(struct thread *td,
|
||||
const cloudabi32_threadattr_t *attr, uint32_t tcb)
|
||||
{
|
||||
stack_t stack;
|
||||
uint32_t args[3];
|
||||
void *frameptr;
|
||||
int error;
|
||||
|
||||
/* Perform standard register initialization. */
|
||||
stack.ss_sp = TO_PTR(attr->stack);
|
||||
stack.ss_size = attr->stack_size - sizeof(args);
|
||||
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack);
|
||||
|
||||
/*
|
||||
* Copy the arguments for the thread entry point onto the stack
|
||||
* (args[1] and args[2]). Similar to process startup, use the
|
||||
* otherwise unused return address (args[0]) for TLS.
|
||||
*/
|
||||
args[0] = tcb;
|
||||
args[1] = td->td_tid;
|
||||
args[2] = attr->argument;
|
||||
frameptr = (void *)td->td_frame->tf_rsp;
|
||||
error = copyout(args, frameptr, sizeof(args));
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
return (cpu_set_user_tls(td, frameptr));
|
||||
}
|
||||
|
||||
static struct sysentvec cloudabi32_elf_sysvec = {
|
||||
.sv_size = CLOUDABI32_SYS_MAXSYSCALL,
|
||||
.sv_table = cloudabi32_sysent,
|
||||
.sv_fixup = cloudabi32_fixup_tcb,
|
||||
.sv_name = "CloudABI ELF32",
|
||||
.sv_coredump = elf32_coredump,
|
||||
.sv_pagesize = IA32_PAGE_SIZE,
|
||||
.sv_minuser = FREEBSD32_MINUSER,
|
||||
.sv_maxuser = FREEBSD32_MAXUSER,
|
||||
.sv_stackprot = VM_PROT_READ | VM_PROT_WRITE,
|
||||
.sv_copyout_strings = cloudabi32_copyout_strings,
|
||||
.sv_setregs = cloudabi32_proc_setregs,
|
||||
.sv_fixlimit = ia32_fixlimit,
|
||||
.sv_maxssiz = &ia32_maxssiz,
|
||||
.sv_flags = SV_ABI_CLOUDABI | SV_CAPSICUM | SV_IA32 | SV_ILP32,
|
||||
.sv_set_syscall_retval = cloudabi32_set_syscall_retval,
|
||||
.sv_fetch_syscall_args = cloudabi32_fetch_syscall_args,
|
||||
.sv_syscallnames = cloudabi32_syscallnames,
|
||||
.sv_schedtail = cloudabi32_schedtail,
|
||||
};
|
||||
|
||||
INIT_SYSENTVEC(elf_sysvec, &cloudabi32_elf_sysvec);
|
||||
|
||||
Elf32_Brandinfo cloudabi32_brand = {
|
||||
.brand = ELFOSABI_CLOUDABI,
|
||||
.machine = EM_386,
|
||||
.sysvec = &cloudabi32_elf_sysvec,
|
||||
.compat_3_brand = "CloudABI",
|
||||
};
|
@ -171,9 +171,9 @@ cloudabi64_thread_setregs(struct thread *td,
|
||||
return (error);
|
||||
|
||||
/* Perform standard register initialization. */
|
||||
stack.ss_sp = (void *)attr->stack;
|
||||
stack.ss_sp = TO_PTR(attr->stack);
|
||||
stack.ss_size = tcbptr - attr->stack;
|
||||
cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack);
|
||||
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack);
|
||||
|
||||
/*
|
||||
* Pass in the thread ID of the new thread and the argument
|
||||
|
@ -614,6 +614,9 @@ options COMPAT_FREEBSD32
|
||||
# Emulate spx device for client side of SVR3 local X interface
|
||||
#XXX#options SPX_HACK
|
||||
|
||||
# Enable 32-bit runtime support for CloudABI binaries.
|
||||
options COMPAT_CLOUDABI32
|
||||
|
||||
# Enable 64-bit runtime support for CloudABI binaries.
|
||||
options COMPAT_CLOUDABI64
|
||||
|
||||
|
@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/pci/pcivar.h>
|
||||
#include <dev/pci/pcireg.h>
|
||||
|
||||
#include <machine/cpu.h>
|
||||
#include <machine/md_var.h>
|
||||
|
||||
#include "vmm_util.h"
|
||||
@ -51,6 +52,10 @@ static int iommu_avail;
|
||||
SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, initialized, CTLFLAG_RD, &iommu_avail,
|
||||
0, "bhyve iommu initialized?");
|
||||
|
||||
static int iommu_enable = 1;
|
||||
SYSCTL_INT(_hw_vmm_iommu, OID_AUTO, enable, CTLFLAG_RDTUN, &iommu_enable, 0,
|
||||
"Enable use of I/O MMU (required for PCI passthrough).");
|
||||
|
||||
static struct iommu_ops *ops;
|
||||
static void *host_domain;
|
||||
|
||||
@ -148,7 +153,7 @@ IOMMU_DISABLE(void)
|
||||
(*ops->disable)();
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
iommu_init(void)
|
||||
{
|
||||
int error, bus, slot, func;
|
||||
@ -156,6 +161,9 @@ iommu_init(void)
|
||||
const char *name;
|
||||
device_t dev;
|
||||
|
||||
if (!iommu_enable)
|
||||
return;
|
||||
|
||||
if (vmm_is_intel())
|
||||
ops = &iommu_ops_intel;
|
||||
else if (vmm_is_amd())
|
||||
@ -174,8 +182,13 @@ iommu_init(void)
|
||||
*/
|
||||
maxaddr = vmm_mem_maxaddr();
|
||||
host_domain = IOMMU_CREATE_DOMAIN(maxaddr);
|
||||
if (host_domain == NULL)
|
||||
panic("iommu_init: unable to create a host domain");
|
||||
if (host_domain == NULL) {
|
||||
printf("iommu_init: unable to create a host domain");
|
||||
IOMMU_CLEANUP();
|
||||
ops = NULL;
|
||||
iommu_avail = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create 1:1 mappings from '0' to 'maxaddr' for devices assigned to
|
||||
@ -216,7 +229,16 @@ iommu_cleanup(void)
|
||||
void *
|
||||
iommu_create_domain(vm_paddr_t maxaddr)
|
||||
{
|
||||
static volatile int iommu_initted;
|
||||
|
||||
if (iommu_initted < 2) {
|
||||
if (atomic_cmpset_int(&iommu_initted, 0, 1)) {
|
||||
iommu_init();
|
||||
atomic_store_rel_int(&iommu_initted, 2);
|
||||
} else
|
||||
while (iommu_initted == 1)
|
||||
cpu_spinwait();
|
||||
}
|
||||
return (IOMMU_CREATE_DOMAIN(maxaddr));
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,6 @@ struct iommu_ops {
|
||||
extern struct iommu_ops iommu_ops_intel;
|
||||
extern struct iommu_ops iommu_ops_amd;
|
||||
|
||||
void iommu_init(void);
|
||||
void iommu_cleanup(void);
|
||||
void *iommu_host_domain(void);
|
||||
void *iommu_create_domain(vm_paddr_t maxaddr);
|
||||
|
@ -224,11 +224,6 @@ SYSCTL_INT(_hw_vmm, OID_AUTO, trace_guest_exceptions, CTLFLAG_RDTUN,
|
||||
&trace_guest_exceptions, 0,
|
||||
"Trap into hypervisor on all guest exceptions and reflect them back");
|
||||
|
||||
static int vmm_force_iommu = 0;
|
||||
TUNABLE_INT("hw.vmm.force_iommu", &vmm_force_iommu);
|
||||
SYSCTL_INT(_hw_vmm, OID_AUTO, force_iommu, CTLFLAG_RDTUN, &vmm_force_iommu, 0,
|
||||
"Force use of I/O MMU even if no passthrough devices were found.");
|
||||
|
||||
static void vm_free_memmap(struct vm *vm, int ident);
|
||||
static bool sysmem_mapping(struct vm *vm, struct mem_map *mm);
|
||||
static void vcpu_notify_event_locked(struct vcpu *vcpu, bool lapic_intr);
|
||||
@ -358,8 +353,6 @@ vmm_handler(module_t mod, int what, void *arg)
|
||||
switch (what) {
|
||||
case MOD_LOAD:
|
||||
vmmdev_init();
|
||||
if (vmm_force_iommu || ppt_avail_devices() > 0)
|
||||
iommu_init();
|
||||
error = vmm_init();
|
||||
if (error == 0)
|
||||
vmm_initialized = 1;
|
||||
@ -396,9 +389,6 @@ static moduledata_t vmm_kmod = {
|
||||
/*
|
||||
* vmm initialization has the following dependencies:
|
||||
*
|
||||
* - iommu initialization must happen after the pci passthru driver has had
|
||||
* a chance to attach to any passthru devices (after SI_SUB_CONFIGURE).
|
||||
*
|
||||
* - VT-x initialization requires smp_rendezvous() and therefore must happen
|
||||
* after SMP is fully functional (after SI_SUB_SMP).
|
||||
*/
|
||||
@ -893,6 +883,8 @@ vm_assign_pptdev(struct vm *vm, int bus, int slot, int func)
|
||||
("vm_assign_pptdev: iommu must be NULL"));
|
||||
maxaddr = sysmem_maxaddr(vm);
|
||||
vm->iommu = iommu_create_domain(maxaddr);
|
||||
if (vm->iommu == NULL)
|
||||
return (ENXIO);
|
||||
vm_iommu_map(vm);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ __FBSDID("$FreeBSD$");
|
||||
#define LOSC_MAGIC 0x16aa0000
|
||||
#define LOSC_BUSY_MASK 0x00000380
|
||||
|
||||
#define IS_SUN7I (allwinner_soc_family() == ALLWINNERSOC_SUN7I)
|
||||
#define IS_SUN7I (sc->type == A20_RTC)
|
||||
|
||||
#define YEAR_MIN (IS_SUN7I ? 1970 : 2010)
|
||||
#define YEAR_MAX (IS_SUN7I ? 2100 : 2073)
|
||||
@ -108,6 +108,7 @@ static struct ofw_compat_data compat_data[] = {
|
||||
|
||||
struct aw_rtc_softc {
|
||||
struct resource *res;
|
||||
int type;
|
||||
bus_size_t rtc_date;
|
||||
bus_size_t rtc_time;
|
||||
};
|
||||
@ -169,8 +170,9 @@ aw_rtc_attach(device_t dev)
|
||||
device_printf(dev, "could not allocate resources\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) {
|
||||
|
||||
sc->type = ofw_bus_search_compatible(dev, compat_data)->ocd_data;
|
||||
switch (sc->type) {
|
||||
case A10_RTC:
|
||||
case A20_RTC:
|
||||
sc->rtc_date = A10_RTC_DATE_REG;
|
||||
|
230
sys/arm/allwinner/aw_ts.c
Normal file
230
sys/arm/allwinner/aw_ts.c
Normal file
@ -0,0 +1,230 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Emmanuel Vadot <manu@freebsd.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Allwinner Touch Sreen driver
|
||||
* Touch screen part is not done, only the thermal sensor part is.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/rman.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <machine/bus.h>
|
||||
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
#include <dev/ofw/openfirm.h>
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#define READ(_sc, _r) bus_read_4((_sc)->res[0], (_r))
|
||||
#define WRITE(_sc, _r, _v) bus_write_4((_sc)->res[0], (_r), (_v))
|
||||
|
||||
/* Control register 0 */
|
||||
#define TP_CTRL0 0x00
|
||||
#define TP_CTRL0_TACQ(x) ((x & 0xFF) << 0)
|
||||
#define TP_CTRL0_FS_DIV(x) ((x & 0xF) << 16)
|
||||
#define TP_CTRL0_CLK_DIV(x) ((x & 0x3) << 20)
|
||||
#define TP_CTRL0_CLK_SELECT(x) ((x & 0x1) << 22)
|
||||
|
||||
/* Control register 1 */
|
||||
#define TP_CTRL1 0x04
|
||||
#define TP_CTRL1_MODE_EN (1 << 4)
|
||||
|
||||
/* Control register 2 */
|
||||
#define TP_CTRL2 0x08
|
||||
|
||||
/* Control register 3 */
|
||||
#define TP_CTRL3 0x0C
|
||||
|
||||
/* Int/FIFO control register */
|
||||
#define TP_FIFOC 0x10
|
||||
#define TP_FIFOC_TEMP_IRQ_ENABLE (1 << 18)
|
||||
|
||||
/* Int/FIFO status register */
|
||||
#define TP_FIFOS 0x14
|
||||
#define TP_FIFOS_TEMP_IRQ_PENDING (1 << 18)
|
||||
|
||||
/* Temperature Period Register */
|
||||
#define TP_TPR 0x18
|
||||
#define TP_TPR_TEMP_EN (1 << 16)
|
||||
#define TP_TPR_TEMP_PERIOD(x) (x << 0)
|
||||
|
||||
/* Common data register */
|
||||
#define TP_CDAT 0x1C
|
||||
|
||||
/* Temperature data register */
|
||||
#define TEMP_DATA 0x20
|
||||
|
||||
/* TP Data register*/
|
||||
#define TP_DATA 0x24
|
||||
|
||||
/* TP IO config register */
|
||||
#define TP_IO_CONFIG 0x28
|
||||
|
||||
/* TP IO port data register */
|
||||
#define TP_IO_DATA 0x2C
|
||||
|
||||
struct aw_ts_softc {
|
||||
device_t dev;
|
||||
struct resource * res[2];
|
||||
void * intrhand;
|
||||
int temp_data;
|
||||
int temp_offset;
|
||||
int temp_step;
|
||||
};
|
||||
|
||||
static struct resource_spec aw_ts_spec[] = {
|
||||
{ SYS_RES_MEMORY, 0, RF_ACTIVE },
|
||||
{ SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
|
||||
{ -1, 0 }
|
||||
};
|
||||
|
||||
#define A10_TS 1
|
||||
#define A13_TS 2
|
||||
|
||||
#define AW_TS_TEMP_SYSCTL 1
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
{"allwinner,sun4i-a10-ts", A10_TS},
|
||||
{"allwinner,sun5i-a13-ts", A13_TS},
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
aw_ts_intr(void *arg)
|
||||
{
|
||||
struct aw_ts_softc *sc;
|
||||
int val;
|
||||
|
||||
sc= (struct aw_ts_softc *)arg;
|
||||
|
||||
val = READ(sc, TP_FIFOS);
|
||||
if (val & TP_FIFOS_TEMP_IRQ_PENDING) {
|
||||
/* Convert the value to millicelsius then millikelvin */
|
||||
sc->temp_data = (READ(sc, TEMP_DATA) * sc->temp_step - sc->temp_offset)
|
||||
+ 273150;
|
||||
}
|
||||
|
||||
WRITE(sc, TP_FIFOS, val);
|
||||
}
|
||||
|
||||
static int
|
||||
aw_ts_probe(device_t dev)
|
||||
{
|
||||
|
||||
if (!ofw_bus_status_okay(dev))
|
||||
return (ENXIO);
|
||||
|
||||
if (ofw_bus_search_compatible(dev, compat_data)->ocd_data == 0)
|
||||
return (ENXIO);
|
||||
|
||||
device_set_desc(dev, "Allwinner Touch Screen controller");
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
|
||||
static int
|
||||
aw_ts_attach(device_t dev)
|
||||
{
|
||||
struct aw_ts_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
sc->dev = dev;
|
||||
|
||||
if (bus_alloc_resources(dev, aw_ts_spec, sc->res) != 0) {
|
||||
device_printf(dev, "could not allocate memory resource\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if (bus_setup_intr(dev, sc->res[1],
|
||||
INTR_TYPE_MISC | INTR_MPSAFE, NULL, aw_ts_intr, sc,
|
||||
&sc->intrhand)) {
|
||||
bus_release_resources(dev, aw_ts_spec, sc->res);
|
||||
device_printf(dev, "cannot setup interrupt handler\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
/*
|
||||
* Thoses magic values were taken from linux which take them from
|
||||
* the allwinner SDK or found them by deduction
|
||||
*/
|
||||
switch (ofw_bus_search_compatible(dev, compat_data)->ocd_data) {
|
||||
case A10_TS:
|
||||
sc->temp_offset = 257000;
|
||||
sc->temp_step = 133;
|
||||
break;
|
||||
case A13_TS:
|
||||
sc->temp_offset = 144700;
|
||||
sc->temp_step = 100;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Enable clock and set divisers */
|
||||
WRITE(sc, TP_CTRL0, TP_CTRL0_CLK_SELECT(0) |
|
||||
TP_CTRL0_CLK_DIV(2) |
|
||||
TP_CTRL0_FS_DIV(7) |
|
||||
TP_CTRL0_TACQ(63));
|
||||
|
||||
/* Enable TS module */
|
||||
WRITE(sc, TP_CTRL1, TP_CTRL1_MODE_EN);
|
||||
|
||||
/* Enable Temperature, period is ~2s */
|
||||
WRITE(sc, TP_TPR, TP_TPR_TEMP_EN | TP_TPR_TEMP_PERIOD(1953));
|
||||
|
||||
/* Enable temp irq */
|
||||
WRITE(sc, TP_FIFOC, TP_FIFOC_TEMP_IRQ_ENABLE);
|
||||
|
||||
/* Add sysctl */
|
||||
SYSCTL_ADD_PROC(device_get_sysctl_ctx(dev),
|
||||
SYSCTL_CHILDREN(device_get_sysctl_tree(dev)),
|
||||
OID_AUTO, "temperature", CTLTYPE_INT | CTLFLAG_RD,
|
||||
&sc->temp_data, 0, sysctl_handle_int,
|
||||
"IK3", "CPU Temperature");
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static device_method_t aw_ts_methods[] = {
|
||||
DEVMETHOD(device_probe, aw_ts_probe),
|
||||
DEVMETHOD(device_attach, aw_ts_attach),
|
||||
|
||||
DEVMETHOD_END
|
||||
};
|
||||
|
||||
static driver_t aw_ts_driver = {
|
||||
"aw_ts",
|
||||
aw_ts_methods,
|
||||
sizeof(struct aw_ts_softc),
|
||||
};
|
||||
static devclass_t aw_ts_devclass;
|
||||
|
||||
DRIVER_MODULE(aw_ts, simplebus, aw_ts_driver, aw_ts_devclass, 0, 0);
|
@ -52,10 +52,17 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
|
||||
#include "iicbus_if.h"
|
||||
#include <dev/extres/regulator/regulator.h>
|
||||
|
||||
#include "gpio_if.h"
|
||||
#include "iicbus_if.h"
|
||||
#include "regdev_if.h"
|
||||
|
||||
MALLOC_DEFINE(M_AXP81X_REG, "AXP81x regulator", "AXP81x power regulator");
|
||||
|
||||
#define AXP_ICTYPE 0x03
|
||||
#define AXP_POWERCTL2 0x12
|
||||
#define AXP_POWERCTL2_DC1SW (1 << 7)
|
||||
#define AXP_POWERBAT 0x32
|
||||
#define AXP_POWERBAT_SHUTDOWN (1 << 7)
|
||||
#define AXP_IRQEN1 0x40
|
||||
@ -96,6 +103,37 @@ static struct resource_spec axp81x_spec[] = {
|
||||
{ -1, 0 }
|
||||
};
|
||||
|
||||
struct axp81x_regdef {
|
||||
intptr_t id;
|
||||
char *name;
|
||||
char *supply_name;
|
||||
uint8_t enable_reg;
|
||||
uint8_t enable_mask;
|
||||
};
|
||||
|
||||
enum axp81x_reg_id {
|
||||
AXP81X_REG_ID_DC1SW
|
||||
};
|
||||
|
||||
static struct axp81x_regdef axp81x_regdefs[] = {
|
||||
{
|
||||
.id = AXP81X_REG_ID_DC1SW,
|
||||
.name = "dc1sw",
|
||||
.enable_reg = AXP_POWERCTL2,
|
||||
.enable_mask = AXP_POWERCTL2_DC1SW,
|
||||
},
|
||||
};
|
||||
|
||||
struct axp81x_softc;
|
||||
|
||||
struct axp81x_reg_sc {
|
||||
struct regnode *regnode;
|
||||
device_t base_dev;
|
||||
struct axp81x_regdef *def;
|
||||
phandle_t xref;
|
||||
struct regnode_std_param *param;
|
||||
};
|
||||
|
||||
struct axp81x_softc {
|
||||
struct resource *res;
|
||||
uint16_t addr;
|
||||
@ -103,6 +141,10 @@ struct axp81x_softc {
|
||||
device_t gpiodev;
|
||||
struct mtx mtx;
|
||||
int busy;
|
||||
|
||||
/* Regulators */
|
||||
struct axp81x_reg_sc **regs;
|
||||
int nregs;
|
||||
};
|
||||
|
||||
#define AXP_LOCK(sc) mtx_lock(&(sc)->mtx)
|
||||
@ -150,6 +192,56 @@ axp81x_write(device_t dev, uint8_t reg, uint8_t val)
|
||||
return (iicbus_transfer(dev, msg, 2));
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_regnode_init(struct regnode *regnode)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_regnode_enable(struct regnode *regnode, bool enable, int *udelay)
|
||||
{
|
||||
struct axp81x_reg_sc *sc;
|
||||
uint8_t val;
|
||||
|
||||
sc = regnode_get_softc(regnode);
|
||||
|
||||
axp81x_read(sc->base_dev, sc->def->enable_reg, &val, 1);
|
||||
if (enable)
|
||||
val |= sc->def->enable_mask;
|
||||
else
|
||||
val &= ~sc->def->enable_mask;
|
||||
axp81x_write(sc->base_dev, sc->def->enable_reg, val);
|
||||
|
||||
*udelay = 0;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_regnode_set_voltage(struct regnode *regnode, int min_uvolt,
|
||||
int max_uvolt, int *udelay)
|
||||
{
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_regnode_get_voltage(struct regnode *regnode, int *uvolt)
|
||||
{
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static regnode_method_t axp81x_regnode_methods[] = {
|
||||
/* Regulator interface */
|
||||
REGNODEMETHOD(regnode_init, axp81x_regnode_init),
|
||||
REGNODEMETHOD(regnode_enable, axp81x_regnode_enable),
|
||||
REGNODEMETHOD(regnode_set_voltage, axp81x_regnode_set_voltage),
|
||||
REGNODEMETHOD(regnode_get_voltage, axp81x_regnode_get_voltage),
|
||||
REGNODEMETHOD_END
|
||||
};
|
||||
DEFINE_CLASS_1(axp81x_regnode, axp81x_regnode_class, axp81x_regnode_methods,
|
||||
sizeof(struct axp81x_reg_sc), regnode_class);
|
||||
|
||||
static void
|
||||
axp81x_shutdown(void *devp, int howto)
|
||||
{
|
||||
@ -417,6 +509,56 @@ axp81x_get_node(device_t dev, device_t bus)
|
||||
return (ofw_bus_get_node(dev));
|
||||
}
|
||||
|
||||
static struct axp81x_reg_sc *
|
||||
axp81x_reg_attach(device_t dev, phandle_t node,
|
||||
struct axp81x_regdef *def)
|
||||
{
|
||||
struct axp81x_reg_sc *reg_sc;
|
||||
struct regnode_init_def initdef;
|
||||
struct regnode *regnode;
|
||||
|
||||
memset(&initdef, 0, sizeof(initdef));
|
||||
regulator_parse_ofw_stdparam(dev, node, &initdef);
|
||||
initdef.id = def->id;
|
||||
initdef.ofw_node = node;
|
||||
regnode = regnode_create(dev, &axp81x_regnode_class, &initdef);
|
||||
if (regnode == NULL) {
|
||||
device_printf(dev, "cannot create regulator\n");
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
reg_sc = regnode_get_softc(regnode);
|
||||
reg_sc->regnode = regnode;
|
||||
reg_sc->base_dev = dev;
|
||||
reg_sc->def = def;
|
||||
reg_sc->xref = OF_xref_from_node(node);
|
||||
reg_sc->param = regnode_get_stdparam(regnode);
|
||||
|
||||
regnode_register(regnode);
|
||||
|
||||
return (reg_sc);
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_regdev_map(device_t dev, phandle_t xref, int ncells, pcell_t *cells,
|
||||
intptr_t *num)
|
||||
{
|
||||
struct axp81x_softc *sc;
|
||||
int i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
for (i = 0; i < sc->nregs; i++) {
|
||||
if (sc->regs[i] == NULL)
|
||||
continue;
|
||||
if (sc->regs[i]->xref == xref) {
|
||||
*num = sc->regs[i]->def->id;
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
static int
|
||||
axp81x_probe(device_t dev)
|
||||
{
|
||||
@ -435,8 +577,10 @@ static int
|
||||
axp81x_attach(device_t dev)
|
||||
{
|
||||
struct axp81x_softc *sc;
|
||||
struct axp81x_reg_sc *reg;
|
||||
uint8_t chip_id;
|
||||
int error;
|
||||
phandle_t rnode, child;
|
||||
int error, i;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
@ -454,6 +598,29 @@ axp81x_attach(device_t dev)
|
||||
device_printf(dev, "chip ID 0x%02x\n", chip_id);
|
||||
}
|
||||
|
||||
sc->nregs = nitems(axp81x_regdefs);
|
||||
sc->regs = malloc(sizeof(struct axp81x_reg_sc *) * sc->nregs,
|
||||
M_AXP81X_REG, M_WAITOK | M_ZERO);
|
||||
|
||||
/* Attach known regulators that exist in the DT */
|
||||
rnode = ofw_bus_find_child(ofw_bus_get_node(dev), "regulators");
|
||||
if (rnode > 0) {
|
||||
for (i = 0; i < sc->nregs; i++) {
|
||||
child = ofw_bus_find_child(rnode,
|
||||
axp81x_regdefs[i].name);
|
||||
if (child == 0)
|
||||
continue;
|
||||
reg = axp81x_reg_attach(dev, child, &axp81x_regdefs[i]);
|
||||
if (reg == NULL) {
|
||||
device_printf(dev,
|
||||
"cannot attach regulator %s\n",
|
||||
axp81x_regdefs[i].name);
|
||||
return (ENXIO);
|
||||
}
|
||||
sc->regs[i] = reg;
|
||||
}
|
||||
}
|
||||
|
||||
/* Enable IRQ on short power key press */
|
||||
axp81x_write(dev, AXP_IRQEN1, 0);
|
||||
axp81x_write(dev, AXP_IRQEN2, 0);
|
||||
@ -495,6 +662,9 @@ static device_method_t axp81x_methods[] = {
|
||||
DEVMETHOD(gpio_pin_toggle, axp81x_gpio_pin_toggle),
|
||||
DEVMETHOD(gpio_map_gpios, axp81x_gpio_map_gpios),
|
||||
|
||||
/* Regdev interface */
|
||||
DEVMETHOD(regdev_map, axp81x_regdev_map),
|
||||
|
||||
/* OFW bus interface */
|
||||
DEVMETHOD(ofw_bus_get_node, axp81x_get_node),
|
||||
|
||||
@ -511,9 +681,10 @@ static devclass_t axp81x_devclass;
|
||||
extern devclass_t ofwgpiobus_devclass, gpioc_devclass;
|
||||
extern driver_t ofw_gpiobus_driver, gpioc_driver;
|
||||
|
||||
DRIVER_MODULE(axp81x, iicbus, axp81x_driver, axp81x_devclass, 0, 0);
|
||||
DRIVER_MODULE(ofw_gpiobus, axp81x_pmu, ofw_gpiobus_driver,
|
||||
ofwgpiobus_devclass, 0, 0);
|
||||
EARLY_DRIVER_MODULE(axp81x, iicbus, axp81x_driver, axp81x_devclass, 0, 0,
|
||||
BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE);
|
||||
EARLY_DRIVER_MODULE(ofw_gpiobus, axp81x_pmu, ofw_gpiobus_driver,
|
||||
ofwgpiobus_devclass, 0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_LATE);
|
||||
DRIVER_MODULE(gpioc, axp81x_pmu, gpioc_driver, gpioc_devclass, 0, 0);
|
||||
MODULE_VERSION(axp81x, 1);
|
||||
MODULE_DEPEND(axp81x, iicbus, 1, 1, 1);
|
||||
|
@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <dev/ofw/ofw_bus.h>
|
||||
#include <dev/ofw/ofw_bus_subr.h>
|
||||
#include <dev/ofw/ofw_subr.h>
|
||||
#include <dev/fdt/fdt_common.h>
|
||||
|
||||
#include <dev/extres/clk/clk_gate.h>
|
||||
|
||||
@ -89,11 +90,14 @@ static struct ofw_compat_data compat_data[] = {
|
||||
(uintptr_t)"Allwinner APB0 Clock Gates" },
|
||||
|
||||
{ "allwinner,sun8i-h3-bus-gates-clk",
|
||||
(uintptr_t)"Allwinner Bus Clock Gates"},
|
||||
(uintptr_t)"Allwinner Bus Clock Gates" },
|
||||
|
||||
{ "allwinner,sun9i-a80-apbs-gates-clk",
|
||||
(uintptr_t)"Allwinner APBS Clock Gates" },
|
||||
|
||||
{ "allwinner,sunxi-multi-bus-gates-clk",
|
||||
(uintptr_t)"Allwinner Multi Bus Clock Gates" },
|
||||
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
@ -118,6 +122,43 @@ aw_gate_create(device_t dev, bus_addr_t paddr, struct clkdom *clkdom,
|
||||
return (clknode_gate_register(clkdom, &def));
|
||||
}
|
||||
|
||||
static int
|
||||
aw_gate_add(device_t dev, struct clkdom *clkdom, phandle_t node,
|
||||
bus_addr_t paddr)
|
||||
{
|
||||
const char **names;
|
||||
uint32_t *indices;
|
||||
clk_t clk_parent;
|
||||
int index, nout, error;
|
||||
|
||||
indices = NULL;
|
||||
|
||||
nout = clk_parse_ofw_out_names(dev, node, &names, &indices);
|
||||
if (nout == 0) {
|
||||
device_printf(dev, "no clock outputs found\n");
|
||||
return (ENOENT);
|
||||
}
|
||||
if (indices == NULL) {
|
||||
device_printf(dev, "no clock-indices property\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
error = clk_get_by_ofw_index(dev, node, 0, &clk_parent);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "cannot parse clock parent\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
for (index = 0; index < nout; index++) {
|
||||
error = aw_gate_create(dev, paddr, clkdom,
|
||||
clk_get_name(clk_parent), names[index], indices[index]);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
aw_gate_probe(device_t dev)
|
||||
{
|
||||
@ -138,16 +179,11 @@ static int
|
||||
aw_gate_attach(device_t dev)
|
||||
{
|
||||
struct clkdom *clkdom;
|
||||
const char **names;
|
||||
int index, nout, error;
|
||||
uint32_t *indices;
|
||||
clk_t clk_parent;
|
||||
bus_addr_t paddr;
|
||||
bus_size_t psize;
|
||||
phandle_t node;
|
||||
phandle_t node, child;
|
||||
|
||||
node = ofw_bus_get_node(dev);
|
||||
indices = NULL;
|
||||
|
||||
if (ofw_reg_to_paddr(node, 0, &paddr, &psize, NULL) != 0) {
|
||||
device_printf(dev, "cannot parse 'reg' property\n");
|
||||
@ -156,44 +192,21 @@ aw_gate_attach(device_t dev)
|
||||
|
||||
clkdom = clkdom_create(dev);
|
||||
|
||||
nout = clk_parse_ofw_out_names(dev, node, &names, &indices);
|
||||
if (nout == 0) {
|
||||
device_printf(dev, "no clock outputs found\n");
|
||||
error = ENOENT;
|
||||
goto fail;
|
||||
}
|
||||
if (indices == NULL) {
|
||||
device_printf(dev, "no clock-indices property\n");
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
error = clk_get_by_ofw_index(dev, 0, 0, &clk_parent);
|
||||
if (error != 0) {
|
||||
device_printf(dev, "cannot parse clock parent\n");
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
for (index = 0; index < nout; index++) {
|
||||
error = aw_gate_create(dev, paddr, clkdom,
|
||||
clk_get_name(clk_parent), names[index], indices[index]);
|
||||
if (error)
|
||||
goto fail;
|
||||
}
|
||||
if (ofw_bus_is_compatible(dev, "allwinner,sunxi-multi-bus-gates-clk")) {
|
||||
for (child = OF_child(node); child > 0; child = OF_peer(child))
|
||||
aw_gate_add(dev, clkdom, child, paddr);
|
||||
} else
|
||||
aw_gate_add(dev, clkdom, node, paddr);
|
||||
|
||||
if (clkdom_finit(clkdom) != 0) {
|
||||
device_printf(dev, "cannot finalize clkdom initialization\n");
|
||||
error = ENXIO;
|
||||
goto fail;
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if (bootverbose)
|
||||
clkdom_dump(clkdom);
|
||||
|
||||
return (0);
|
||||
|
||||
fail:
|
||||
return (error);
|
||||
}
|
||||
|
||||
static device_method_t aw_gate_methods[] = {
|
||||
|
@ -160,28 +160,47 @@ aw_modclk_set_freq(struct clknode *clk, uint64_t fin, uint64_t *fout,
|
||||
int flags, int *stop)
|
||||
{
|
||||
struct aw_modclk_sc *sc;
|
||||
uint32_t val, m, n, best_m, best_n;
|
||||
uint32_t val, m, n, src, best_m, best_n, best_src;
|
||||
uint64_t cur_freq;
|
||||
int64_t best_diff, cur_diff;
|
||||
int error;
|
||||
|
||||
sc = clknode_get_softc(clk);
|
||||
best_n = best_m = 0;
|
||||
best_diff = (int64_t)*fout;
|
||||
best_src = 0;
|
||||
|
||||
for (n = 0; n <= CLK_RATIO_N_MAX; n++)
|
||||
for (m = 0; m <= CLK_RATIO_M_MAX; m++) {
|
||||
cur_freq = fin / (1 << n) / (m + 1);
|
||||
cur_diff = (int64_t)*fout - cur_freq;
|
||||
if (cur_diff >= 0 && cur_diff < best_diff) {
|
||||
best_diff = cur_diff;
|
||||
best_m = m;
|
||||
best_n = n;
|
||||
for (src = 0; src < CLK_SRC_SEL_MAX; src++) {
|
||||
error = clknode_set_parent_by_idx(clk, src);
|
||||
if (error != 0)
|
||||
continue;
|
||||
error = clknode_get_freq(clknode_get_parent(clk), &fin);
|
||||
if (error != 0)
|
||||
continue;
|
||||
|
||||
for (n = 0; n <= CLK_RATIO_N_MAX; n++)
|
||||
for (m = 0; m <= CLK_RATIO_M_MAX; m++) {
|
||||
cur_freq = fin / (1 << n) / (m + 1);
|
||||
cur_diff = (int64_t)*fout - cur_freq;
|
||||
if (cur_diff >= 0 && cur_diff < best_diff) {
|
||||
best_src = src;
|
||||
best_diff = cur_diff;
|
||||
best_m = m;
|
||||
best_n = n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (best_diff == (int64_t)*fout)
|
||||
return (ERANGE);
|
||||
|
||||
error = clknode_set_parent_by_idx(clk, best_src);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
error = clknode_get_freq(clknode_get_parent(clk), &fin);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
|
||||
DEVICE_LOCK(sc);
|
||||
MODCLK_READ(sc, &val);
|
||||
val &= ~(CLK_RATIO_N | CLK_RATIO_M);
|
||||
|
@ -142,6 +142,15 @@ __FBSDID("$FreeBSD$");
|
||||
#define A31_PLL6_DEFAULT_K 0x1
|
||||
#define A31_PLL6_TIMEOUT 10
|
||||
|
||||
#define A64_PLLHSIC_LOCK (1 << 28)
|
||||
#define A64_PLLHSIC_FRAC_CLK_OUT (1 << 25)
|
||||
#define A64_PLLHSIC_PLL_MODE_SEL (1 << 24)
|
||||
#define A64_PLLHSIC_PLL_SDM_EN (1 << 20)
|
||||
#define A64_PLLHSIC_FACTOR_N (0x7f << 8)
|
||||
#define A64_PLLHSIC_FACTOR_N_SHIFT 8
|
||||
#define A64_PLLHSIC_PRE_DIV_M (0xf << 0)
|
||||
#define A64_PLLHSIC_PRE_DIV_M_SHIFT 0
|
||||
|
||||
#define A80_PLL4_CLK_OUT_EN (1 << 20)
|
||||
#define A80_PLL4_PLL_DIV2 (1 << 18)
|
||||
#define A80_PLL4_PLL_DIV1 (1 << 16)
|
||||
@ -172,6 +181,7 @@ enum aw_pll_type {
|
||||
AWPLL_A23_PLL1,
|
||||
AWPLL_A31_PLL1,
|
||||
AWPLL_A31_PLL6,
|
||||
AWPLL_A64_PLLHSIC,
|
||||
AWPLL_A80_PLL4,
|
||||
};
|
||||
|
||||
@ -601,6 +611,7 @@ a31_pll6_init(device_t dev, bus_addr_t reg, struct clknode_init_def *def)
|
||||
val &= ~(A31_PLL6_FACTOR_N | A31_PLL6_FACTOR_K | A31_PLL6_BYPASS_EN);
|
||||
val |= (A31_PLL6_DEFAULT_N << A31_PLL6_FACTOR_N_SHIFT);
|
||||
val |= (A31_PLL6_DEFAULT_K << A31_PLL6_FACTOR_K_SHIFT);
|
||||
val |= AW_PLL_ENABLE;
|
||||
CLKDEV_WRITE_4(dev, reg, val);
|
||||
|
||||
/* Wait for PLL to become stable */
|
||||
@ -613,9 +624,6 @@ a31_pll6_init(device_t dev, bus_addr_t reg, struct clknode_init_def *def)
|
||||
|
||||
CLKDEV_DEVICE_UNLOCK(dev);
|
||||
|
||||
if (retry == 0)
|
||||
return (ETIMEDOUT);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -663,6 +671,40 @@ a80_pll4_recalc(struct aw_pll_sc *sc, uint64_t *freq)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
a64_pllhsic_recalc(struct aw_pll_sc *sc, uint64_t *freq)
|
||||
{
|
||||
uint32_t val, n, m;
|
||||
|
||||
DEVICE_LOCK(sc);
|
||||
PLL_READ(sc, &val);
|
||||
DEVICE_UNLOCK(sc);
|
||||
|
||||
n = ((val & A64_PLLHSIC_FACTOR_N) >> A64_PLLHSIC_FACTOR_N_SHIFT) + 1;
|
||||
m = ((val & A64_PLLHSIC_PRE_DIV_M) >> A64_PLLHSIC_PRE_DIV_M_SHIFT) + 1;
|
||||
|
||||
*freq = (*freq * n) / m;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
static int
|
||||
a64_pllhsic_init(device_t dev, bus_addr_t reg, struct clknode_init_def *def)
|
||||
{
|
||||
uint32_t val;
|
||||
|
||||
/*
|
||||
* PLL_HSIC default is 480MHz, just enable it.
|
||||
*/
|
||||
CLKDEV_DEVICE_LOCK(dev);
|
||||
CLKDEV_READ_4(dev, reg, &val);
|
||||
val |= AW_PLL_ENABLE;
|
||||
CLKDEV_WRITE_4(dev, reg, val);
|
||||
CLKDEV_DEVICE_UNLOCK(dev);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
#define PLL(_type, _recalc, _set_freq, _init) \
|
||||
[(_type)] = { \
|
||||
.recalc = (_recalc), \
|
||||
@ -681,6 +723,7 @@ static struct aw_pll_funcs aw_pll_func[] = {
|
||||
PLL(AWPLL_A31_PLL1, a31_pll1_recalc, NULL, NULL),
|
||||
PLL(AWPLL_A31_PLL6, a31_pll6_recalc, NULL, a31_pll6_init),
|
||||
PLL(AWPLL_A80_PLL4, a80_pll4_recalc, NULL, NULL),
|
||||
PLL(AWPLL_A64_PLLHSIC, a64_pllhsic_recalc, NULL, a64_pllhsic_init),
|
||||
};
|
||||
|
||||
static struct ofw_compat_data compat_data[] = {
|
||||
@ -694,6 +737,7 @@ static struct ofw_compat_data compat_data[] = {
|
||||
{ "allwinner,sun6i-a31-pll6-clk", AWPLL_A31_PLL6 },
|
||||
{ "allwinner,sun8i-a23-pll1-clk", AWPLL_A23_PLL1 },
|
||||
{ "allwinner,sun9i-a80-pll4-clk", AWPLL_A80_PLL4 },
|
||||
{ "allwinner,sun50i-a64-pllhsic-clk", AWPLL_A64_PLLHSIC },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
|
@ -14,6 +14,7 @@ arm/allwinner/aw_nmi.c optional intrng
|
||||
arm/allwinner/aw_if_dwc.c optional dwc
|
||||
arm/allwinner/aw_rsb.c optional rsb
|
||||
arm/allwinner/aw_rtc.c standard
|
||||
arm/allwinner/aw_ts.c standard
|
||||
arm/allwinner/aw_wdog.c standard
|
||||
arm/allwinner/aw_machdep.c standard
|
||||
arm/allwinner/aw_mp.c optional smp
|
||||
|
@ -438,6 +438,13 @@ bounce_bus_dmamem_alloc(bus_dma_tag_t dmat, void** vaddr, int flags,
|
||||
mflags |= M_ZERO;
|
||||
if (flags & BUS_DMA_NOCACHE)
|
||||
attr = VM_MEMATTR_UNCACHEABLE;
|
||||
else if ((flags & BUS_DMA_COHERENT) != 0 &&
|
||||
(dmat->bounce_flags & BF_COHERENT) == 0)
|
||||
/*
|
||||
* If we have a non-coherent tag, and are trying to allocate
|
||||
* a coherent block of memory it needs to be uncached.
|
||||
*/
|
||||
attr = VM_MEMATTR_UNCACHEABLE;
|
||||
else
|
||||
attr = VM_MEMATTR_DEFAULT;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -139,9 +139,9 @@ cloudabi64_thread_setregs(struct thread *td,
|
||||
stack_t stack;
|
||||
|
||||
/* Perform standard register initialization. */
|
||||
stack.ss_sp = (void *)attr->stack;
|
||||
stack.ss_sp = TO_PTR(attr->stack);
|
||||
stack.ss_size = attr->stack_size;
|
||||
cpu_set_upcall(td, (void *)attr->entry_point, NULL, &stack);
|
||||
cpu_set_upcall(td, TO_PTR(attr->entry_point), NULL, &stack);
|
||||
|
||||
/*
|
||||
* Pass in the thread ID of the new thread and the argument
|
||||
|
@ -86,6 +86,7 @@ options WITNESS_SKIPSPIN # Don't run witness on spinlocks for speed
|
||||
options MALLOC_DEBUG_MAXZONES=8 # Separate malloc(9) zones
|
||||
|
||||
# SoC support
|
||||
options SOC_ALLWINNER_A64
|
||||
options SOC_CAVM_THUNDERX
|
||||
options SOC_HISI_HI6220
|
||||
|
||||
@ -103,6 +104,7 @@ options PCI_IOV # PCI SR-IOV support
|
||||
# Ethernet NICs
|
||||
device mii
|
||||
device miibus # MII bus support
|
||||
device awg # Allwinner EMAC Gigabit Ethernet
|
||||
device em # Intel PRO/1000 Gigabit Ethernet Family
|
||||
device igb # Intel PRO/1000 PCIE Server Gigabit Family
|
||||
device ix # Intel 10Gb Ethernet Family
|
||||
@ -118,6 +120,7 @@ device da
|
||||
device pass # Passthrough device (direct ATA/SCSI access)
|
||||
|
||||
# MMC/SD/SDIO Card slot support
|
||||
device aw_mmc # Allwinner SD/MMC controller
|
||||
device mmc # mmc/sd bus
|
||||
device mmcsd # mmc/sd flash cards
|
||||
device dwmmc
|
||||
@ -125,18 +128,45 @@ device dwmmc
|
||||
# Serial (COM) ports
|
||||
device uart # Generic UART driver
|
||||
device uart_ns8250 # ns8250-type UART driver
|
||||
device uart_snps
|
||||
device pl011
|
||||
|
||||
# USB support
|
||||
options USB_DEBUG # enable debug msgs
|
||||
device aw_ehci # Allwinner EHCI USB interface (USB 2.0)
|
||||
device aw_usbphy # Allwinner USB PHY
|
||||
device dwcotg # DWC OTG controller
|
||||
device ohci # OHCI PCI->USB interface
|
||||
device ehci # EHCI PCI->USB interface (USB 2.0)
|
||||
device ohci # OHCI USB interface
|
||||
device ehci # EHCI USB interface (USB 2.0)
|
||||
device xhci # XHCI PCI->USB interface (USB 3.0)
|
||||
device usb # USB Bus (required)
|
||||
device ukbd # Keyboard
|
||||
device umass # Disks/Mass storage - Requires scbus and da
|
||||
|
||||
# GPIO
|
||||
device aw_gpio # Allwinner GPIO controller
|
||||
device gpio
|
||||
device fdt_pinctrl
|
||||
|
||||
# I2C
|
||||
device aw_rsb # Allwinner Reduced Serial Bus
|
||||
device iicbus
|
||||
|
||||
# Clock and reset controllers
|
||||
device aw_ccu # Allwinner clock controller
|
||||
|
||||
# Interrupt controllers
|
||||
device aw_nmi # Allwinner NMI support
|
||||
|
||||
# Real-time clock support
|
||||
device aw_rtc # Allwinner Real-time Clock
|
||||
|
||||
# Watchdog controllers
|
||||
device aw_wdog # Allwinner Watchdog
|
||||
|
||||
# Power management controllers
|
||||
device axp81x # X-Powers AXP81x PMIC
|
||||
|
||||
# Pseudo devices.
|
||||
device loop # Network loopback
|
||||
device random # Entropy device
|
||||
@ -148,6 +178,13 @@ device gif # IPv6 and IPv4 tunneling
|
||||
device firmware # firmware assist module
|
||||
device psci # Support for ARM PSCI
|
||||
|
||||
# EXT_RESOURCES pseudo devices
|
||||
options EXT_RESOURCES
|
||||
device clk
|
||||
device phy
|
||||
device hwreset
|
||||
device regulator
|
||||
|
||||
# The `bpf' device enables the Berkeley Packet Filter.
|
||||
# Be aware of the administrative consequences of enabling this!
|
||||
# Note that 'bpf' is required for DHCP.
|
||||
|
@ -44,6 +44,8 @@
|
||||
#include <sys/_lock.h>
|
||||
#include <sys/_mutex.h>
|
||||
|
||||
#include <vm/_vm_radix.h>
|
||||
|
||||
#ifdef _KERNEL
|
||||
|
||||
#define vtophys(va) pmap_kextract((vm_offset_t)(va))
|
||||
@ -80,6 +82,7 @@ struct pmap {
|
||||
struct pmap_statistics pm_stats; /* pmap statictics */
|
||||
pd_entry_t *pm_l0;
|
||||
TAILQ_HEAD(,pv_chunk) pm_pvchunk; /* list of mappings in pmap */
|
||||
struct vm_radix pm_root; /* spare page table pages */
|
||||
};
|
||||
|
||||
typedef struct pv_entry {
|
||||
|
@ -120,7 +120,6 @@ efi_parsedev(struct devdesc **dev, const char *devspec, const char **path)
|
||||
free(idev);
|
||||
return (err);
|
||||
}
|
||||
*dev = idev;
|
||||
cp = strchr(np + 1, ':');
|
||||
} else
|
||||
#endif
|
||||
|
@ -46,7 +46,7 @@ static int userboot_zfs_found;
|
||||
/* Minimum version required */
|
||||
#define USERBOOT_VERSION USERBOOT_VERSION_3
|
||||
|
||||
#define MALLOCSZ (10*1024*1024)
|
||||
#define MALLOCSZ (64*1024*1024)
|
||||
|
||||
struct loader_callbacks *callbacks;
|
||||
void *callbacks_arg;
|
||||
|
@ -1512,7 +1512,8 @@ cfiscsi_ioctl_handoff(struct ctl_iscsi *ci)
|
||||
*/
|
||||
cs->cs_cmdsn = cihp->cmdsn;
|
||||
cs->cs_statsn = cihp->statsn;
|
||||
cs->cs_max_data_segment_length = cihp->max_recv_data_segment_length;
|
||||
cs->cs_max_recv_data_segment_length = cihp->max_recv_data_segment_length;
|
||||
cs->cs_max_send_data_segment_length = cihp->max_send_data_segment_length;
|
||||
cs->cs_max_burst_length = cihp->max_burst_length;
|
||||
cs->cs_first_burst_length = cihp->first_burst_length;
|
||||
cs->cs_immediate_data = !!cihp->immediate_data;
|
||||
@ -1652,9 +1653,10 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
|
||||
"<target_portal_group_tag>%u</target_portal_group_tag>"
|
||||
"<header_digest>%s</header_digest>"
|
||||
"<data_digest>%s</data_digest>"
|
||||
"<max_data_segment_length>%zd</max_data_segment_length>"
|
||||
"<max_burst_length>%zd</max_burst_length>"
|
||||
"<first_burst_length>%zd</first_burst_length>"
|
||||
"<max_recv_data_segment_length>%d</max_recv_data_segment_length>"
|
||||
"<max_send_data_segment_length>%d</max_send_data_segment_length>"
|
||||
"<max_burst_length>%d</max_burst_length>"
|
||||
"<first_burst_length>%d</first_burst_length>"
|
||||
"<immediate_data>%d</immediate_data>"
|
||||
"<iser>%d</iser>"
|
||||
"<offload>%s</offload>"
|
||||
@ -1665,7 +1667,8 @@ cfiscsi_ioctl_list(struct ctl_iscsi *ci)
|
||||
cs->cs_target->ct_tag,
|
||||
cs->cs_conn->ic_header_crc32c ? "CRC32C" : "None",
|
||||
cs->cs_conn->ic_data_crc32c ? "CRC32C" : "None",
|
||||
cs->cs_max_data_segment_length,
|
||||
cs->cs_max_recv_data_segment_length,
|
||||
cs->cs_max_send_data_segment_length,
|
||||
cs->cs_max_burst_length,
|
||||
cs->cs_first_burst_length,
|
||||
cs->cs_immediate_data,
|
||||
@ -1794,12 +1797,12 @@ static void
|
||||
cfiscsi_ioctl_limits(struct ctl_iscsi *ci)
|
||||
{
|
||||
struct ctl_iscsi_limits_params *cilp;
|
||||
struct icl_drv_limits idl;
|
||||
int error;
|
||||
|
||||
cilp = (struct ctl_iscsi_limits_params *)&(ci->data);
|
||||
|
||||
error = icl_limits(cilp->offload, false,
|
||||
&cilp->data_segment_limit);
|
||||
error = icl_limits(cilp->offload, false, &idl);
|
||||
if (error != 0) {
|
||||
ci->status = CTL_ISCSI_ERROR;
|
||||
snprintf(ci->error_str, sizeof(ci->error_str),
|
||||
@ -1808,6 +1811,13 @@ cfiscsi_ioctl_limits(struct ctl_iscsi *ci)
|
||||
return;
|
||||
}
|
||||
|
||||
cilp->max_recv_data_segment_length =
|
||||
idl.idl_max_recv_data_segment_length;
|
||||
cilp->max_send_data_segment_length =
|
||||
idl.idl_max_send_data_segment_length;
|
||||
cilp->max_burst_length = idl.idl_max_burst_length;
|
||||
cilp->first_burst_length = idl.idl_first_burst_length;
|
||||
|
||||
ci->status = CTL_ISCSI_OK;
|
||||
}
|
||||
|
||||
@ -2466,12 +2476,12 @@ cfiscsi_datamove_in(union ctl_io *io)
|
||||
/*
|
||||
* Truncate to maximum data segment length.
|
||||
*/
|
||||
KASSERT(response->ip_data_len < cs->cs_max_data_segment_length,
|
||||
("ip_data_len %zd >= max_data_segment_length %zd",
|
||||
response->ip_data_len, cs->cs_max_data_segment_length));
|
||||
KASSERT(response->ip_data_len < cs->cs_max_send_data_segment_length,
|
||||
("ip_data_len %zd >= max_send_data_segment_length %d",
|
||||
response->ip_data_len, cs->cs_max_send_data_segment_length));
|
||||
if (response->ip_data_len + len >
|
||||
cs->cs_max_data_segment_length) {
|
||||
len = cs->cs_max_data_segment_length -
|
||||
cs->cs_max_send_data_segment_length) {
|
||||
len = cs->cs_max_send_data_segment_length -
|
||||
response->ip_data_len;
|
||||
KASSERT(len <= sg_len, ("len %zd > sg_len %zd",
|
||||
len, sg_len));
|
||||
@ -2529,7 +2539,7 @@ cfiscsi_datamove_in(union ctl_io *io)
|
||||
i++;
|
||||
}
|
||||
|
||||
if (response->ip_data_len == cs->cs_max_data_segment_length) {
|
||||
if (response->ip_data_len == cs->cs_max_send_data_segment_length) {
|
||||
/*
|
||||
* Can't stuff more data into the current PDU;
|
||||
* queue it. Note that's not enough to check
|
||||
|
@ -84,9 +84,10 @@ struct cfiscsi_session {
|
||||
struct cv cs_maintenance_cv;
|
||||
bool cs_terminating;
|
||||
bool cs_tasks_aborted;
|
||||
size_t cs_max_data_segment_length;
|
||||
size_t cs_max_burst_length;
|
||||
size_t cs_first_burst_length;
|
||||
int cs_max_recv_data_segment_length;
|
||||
int cs_max_send_data_segment_length;
|
||||
int cs_max_burst_length;
|
||||
int cs_first_burst_length;
|
||||
bool cs_immediate_data;
|
||||
char cs_initiator_name[CTL_ISCSI_NAME_LEN];
|
||||
char cs_initiator_addr[CTL_ISCSI_ADDR_LEN];
|
||||
|
@ -622,7 +622,7 @@ struct ctl_iscsi_handoff_params {
|
||||
char target_name[CTL_ISCSI_NAME_LEN];
|
||||
int socket;
|
||||
int portal_group_tag;
|
||||
|
||||
|
||||
/*
|
||||
* Connection parameters negotiated by ctld(8).
|
||||
*/
|
||||
@ -630,17 +630,17 @@ struct ctl_iscsi_handoff_params {
|
||||
ctl_iscsi_digest data_digest;
|
||||
uint32_t cmdsn;
|
||||
uint32_t statsn;
|
||||
uint32_t max_recv_data_segment_length;
|
||||
uint32_t max_burst_length;
|
||||
uint32_t first_burst_length;
|
||||
int max_recv_data_segment_length;
|
||||
int max_burst_length;
|
||||
int first_burst_length;
|
||||
uint32_t immediate_data;
|
||||
char offload[CTL_ISCSI_OFFLOAD_LEN];
|
||||
#ifdef ICL_KERNEL_PROXY
|
||||
int connection_id;
|
||||
int spare[1];
|
||||
#else
|
||||
int spare[2];
|
||||
int spare;
|
||||
#endif
|
||||
int max_send_data_segment_length;
|
||||
};
|
||||
|
||||
struct ctl_iscsi_list_params {
|
||||
@ -671,11 +671,15 @@ struct ctl_iscsi_terminate_params {
|
||||
};
|
||||
|
||||
struct ctl_iscsi_limits_params {
|
||||
/* passed to kernel */
|
||||
char offload[CTL_ISCSI_OFFLOAD_LEN];
|
||||
/* passed to kernel */
|
||||
size_t data_segment_limit;
|
||||
/* passed to userland */
|
||||
int spare[4];
|
||||
|
||||
/* passed to userland */
|
||||
size_t spare;
|
||||
int max_recv_data_segment_length;
|
||||
int max_send_data_segment_length;
|
||||
int max_burst_length;
|
||||
int first_burst_length;
|
||||
};
|
||||
|
||||
#ifdef ICL_KERNEL_PROXY
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user