This repository has been archived by the owner on Sep 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rhtv-config.c
192 lines (169 loc) · 3.55 KB
/
rhtv-config.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**[txh]********************************************************************
Copyright (c) 2003 by Salvador Eduardo Tropea
Covered by the GPL license.
Description:
Small program to help configuring packages using Turbo Vision.
***************************************************************************/
#define Uses_getcwd
#define Uses_stdio
#define Uses_string
#define Uses_limits
#define Uses_stdlib
#include <compatlayer.h>
#define VERSION "1.0.0"
#if defined(TVOS_DOS) || defined(TVOS_Win32) || defined(TVOSf_QNX4)
// Currently only static linking is supported for DOS and Win32.
#define ONLY_STATIC 1
#else
#define ONLY_STATIC 0
#endif
static char *curdir=TVCONFIG_REF_DIR;
static int lcurdir;
static
void StdInc(void)
{
puts(TVCONFIG_RHIDE_STDINC);
}
/*static
char *FixRelative(const char *s)
{
if (strncmp(s,"../../",6)==0)
{
char *ret=(char *)malloc(lcurdir+strlen(s)+1-5);
sprintf(ret,"%s%s",curdir,s+5);
return ret;
}
return strdup(s);
}*/
static
void Include(void)
{
char *copy=strdup(TVCONFIG_INCLUDE);
char *s=strtok(copy," ");
while (s)
{
if (*s && *s!='.')
{
printf("-I%s ",s);
}
s=strtok(NULL," ");
}
}
static
void SLibs(void)
{
char *copy=strdup(TVCONFIG_RHIDE_OS_LIBS);
char *s=strtok(copy," ");
if (ONLY_STATIC)
printf("-lrhtv ");
else
printf("-Wl,-dn -lrhtv -Wl,-dy ");
while (s)
{
if (*s && *s!='.')
{
printf("-l%s ",s);
}
s=strtok(NULL," ");
}
}
static
void DLibs(void)
{
if (ONLY_STATIC)
SLibs();
else
{
char *copy=strdup(TVCONFIG_RHIDE_OS_LIBS);
char *s=strtok(copy," ");
#if !defined(TVOSf_QNXRtP)
printf("-lrhtv ");
#else
printf("-lrhtv -lncursesS");
#endif /* TVOSf_QNXRtP */
if (strstr(TVCONFIG_RHIDE_OS_LIBS,"tvfintl"))
printf("-ltvfintl");
}
}
static
void DirLibs(void)
{
char *copy=strdup(TVCONFIG_TVOBJ);
char *s=strtok(copy," ");
while (s)
{
if (*s && *s!='.')
{
printf("-L%s ",s);
}
s=strtok(NULL," ");
}
}
static
void Usage(void)
{
fputs("Turbo Vision configuration tool v" VERSION "\n",stderr);
fputs("Copyright (c) 2003 by Salvador E. Tropea.\n",stderr);
fputs("That's free software covered by the GPL license.\n",stderr);
fprintf(stderr,"Usage: rhtv-config.exe OPTION\n");
fprintf(stderr,"Available options: [Only one can be specified]\n");
fprintf(stderr,"\t--stdinc\n");
fprintf(stderr,"\t--include\n");
fprintf(stderr,"\t--slibs [for linking static]\n");
fprintf(stderr,"\t--dlibs [for linking dynamic]\n");
fprintf(stderr,"\t--dir-libs\n");
fprintf(stderr,"\t--cflags\n");
fprintf(stderr,"\t--cppflags\n");
fprintf(stderr,"\t--version\n");
}
static
void UnknowOp(const char *s)
{
fprintf(stderr,"Unknown option: %s\n\n",s);
Usage();
}
static
void SetUpCurDir(void)
{
lcurdir=strlen(curdir);
}
int main(int argc, char *argv[])
{
char *op;
if (argc!=2)
{
Usage();
return 1;
}
op=argv[1];
if (op[0]!='-' || op[1]!='-')
{
UnknowOp(op);
return 2;
}
SetUpCurDir();
op+=2;
if (strcmp(op,"stdinc")==0)
StdInc();
else if (strcmp(op,"include")==0)
Include();
else if (strcmp(op,"slibs")==0)
SLibs();
else if (strcmp(op,"dlibs")==0)
DLibs();
else if (strcmp(op,"dir-libs")==0)
DirLibs();
else if (strcmp(op,"cflags")==0)
fputs(TVCONFIG_CFLAGS,stdout);
else if (strcmp(op,"cppflags")==0)
fputs(TVCONFIG_CXXFLAGS,stdout);
else if (strcmp(op,"version")==0)
fputs("Turbo Vision configuration tool v" VERSION,stdout);
else
{
UnknowOp(op);
return 2;
}
printf("\n");
return 0;
}