3
* This file is part of Open Sound System.
5
* Copyright (C) 4Front Technologies 1996-2008.
7
* This this source file is released under GPL v2 license (no other versions).
8
* See the COPYING file included in the main directory of this source
9
* distribution for the license terms and conditions.
18
#include <sys/types.h>
30
char *srcdir = NULL, *blddir = NULL;
31
int verbose = 0, copy_files = 0;
32
struct stat bld_stat, src_stat;
35
copy_file (char *sname, char *tname, char *pname, int native_make)
40
unsigned char buf[4096];
42
if (strcmp (pname, ".depend") == 0)
46
if (strncmp (pname, "Makefile", 8) == 0)
49
if (strlen (pname) > 6)
51
p = pname + strlen (pname) - 6; /* Seek to the _cfg.[c-h] suffix */
52
if (strcmp (p, "_cfg.c") == 0)
54
if (strcmp (p, "_cfg.h") == 0)
60
symlink (sname, tname);
64
if ((in_fd=open(sname, O_RDONLY, 0))==-1)
70
if ((out_fd=creat(tname, 0644))==-1)
76
while ((l=read(in_fd, buf, sizeof(buf)))>0)
78
if (write(out_fd, buf, l)!=l)
96
copy_tree (char *fromdir, char *tgtdir, int native_make)
104
mkdir (tgtdir, 0700);
107
if ((dir = opendir (fromdir)) == NULL)
109
fprintf (stderr, "Bad source directory %s\n", fromdir);
113
while ((de = readdir (dir)) != NULL)
115
char sname[PATH_MAX+20], tname[PATH_MAX+20];
117
sprintf (sname, "%s/%s", fromdir, de->d_name);
119
sprintf (tname, "%s/%s", tgtdir, de->d_name);
121
sprintf (tname, "%s", de->d_name);
123
if (stat (sname, &st) == -1)
129
if ((st.st_dev == bld_stat.st_dev) && (st.st_ino == bld_stat.st_ino)) continue;
130
if ((st.st_dev == src_stat.st_dev) && (st.st_ino == src_stat.st_ino)) continue;
132
if (S_ISDIR (st.st_mode))
134
if (de->d_name[0] != '.')
136
char tmp[PATH_MAX+20];
140
sprintf (tmp, "%s/.nativemake", sname);
141
if (stat (tmp, &st2) != -1)
144
sprintf (tmp, "%s/.nocopy", sname);
145
if (stat (tmp, &st2) == -1)
146
copy_tree (sname, tname, is_native);
151
copy_file (sname, tname, de->d_name, native_make);
159
main (int argc, char *argv[])
169
fprintf (stderr, "%s: Bad usage\n", argv[0]);
176
if (stat (blddir, &bld_stat) == -1)
182
if (stat (srcdir, &src_stat) == -1)
188
for (i = 3; i < argc; i++)
190
if (strcmp (argv[i], "-v") == 0)
196
if (strcmp (argv[i], "-c") == 0)
203
f = fopen (".nocopy", "w");
205
copy_tree (srcdir, NULL, 0);
208
if ((f = fopen ("timestamp.h", "w")) == NULL)
210
perror ("timestamp.h");
216
fprintf (f, "#define OSS_COMPILE_DATE \"%04d%02d%02d%02d%02d\"\n",
218
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min);