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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
|
/*******************************************************/
/** PREDICT installation program by KD2BD. **/
/** This program is compiled and executed through **/
/** the "configure" script in this directory. **/
/** It checks for the existence of a soundcard, **/
/** creates an appropriate "predict.h" file based **/
/** on the directory in which PREDICT was installed, **/
/** compiles PREDICT and associated utilities, and **/
/** sets symbolic links between the executables **/
/** generated and the installation directory **/
/** specified (/usr/local/bin by default). **/
/** **/
/** Created: Oct 1999 -==- Last update: 14-May-2006 **/
/*******************************************************/
#include <curses.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
char version[10];
void logo()
{
attrset(COLOR_PAIR(6)|A_REVERSE|A_BOLD);
mvprintw(3,18," ");
mvprintw(4,18," --== PREDICT v%s ==-- ",version);
mvprintw(5,18," Released by John A. Magliacane, KD2BD ");
mvprintw(6,18," May 2006 ");
mvprintw(7,18," ");
}
int main (argc,argv)
char argc, *argv[];
{
int x, cc, dsp=-1;
char pwd[80], src_path[255], dest_path[255], ans, destination[80];
FILE *infile, *outfile;
initscr();
start_color();
cbreak();
scrollok(stdscr,TRUE);
init_pair(1,COLOR_WHITE,COLOR_BLUE);
init_pair(2,COLOR_RED,COLOR_BLUE);
init_pair(3,COLOR_CYAN,COLOR_BLUE);
init_pair(4,COLOR_GREEN,COLOR_BLUE);
init_pair(5,COLOR_YELLOW,COLOR_BLUE);
init_pair(6,COLOR_RED,COLOR_WHITE);
cc=0;
getcwd(pwd,79);
dsp=open("/dev/dsp",O_WRONLY);
if (dsp!=-1)
close(dsp);
infile=fopen(".version","r");
fscanf(infile,"%s",version);
fclose(infile);
bkgdset(COLOR_PAIR(1)|A_BOLD);
clear();
refresh();
logo();
attrset(COLOR_PAIR(5)|A_BOLD);
mvprintw(10,2,"PREDICT is a satellite tracking and orbital prediction program written for\n");
printw(" Linux and similar operating systems by John A. Magliacane, KD2BD.\n");
printw(" PREDICT is free software. You can redistribute it and/or modify it under\n");
printw(" the terms of the GNU General Public License as published by the Free\n");
printw(" Software Foundation, either version 2 of the License or any later version.\n\n");
printw(" PREDICT is distributed in the hope that it will useful, but WITHOUT ANY\n");
printw(" WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS\n");
printw(" FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n");
printw(" details.\n\n");
attrset(COLOR_PAIR(1)|A_BOLD);
printw(" Do you accept these conditions and wish to install this software? [Y/N] ");
refresh();
do
{
ans=getch();
} while (ans!='n' && ans!='N' && ans!='y' && ans!='Y' && ans!=27);
if (ans=='y' || ans=='Y')
{
clear();
curs_set(0);
logo();
attrset(COLOR_PAIR(4)|A_BOLD);
printw("\n\n\n\n PREDICT appears to be installed under %s/\n",pwd);
if (dsp!=-1)
printw(" An audio device was found at /dev/dsp");
else
printw(" No soundcard was found in your system... Bummer!");
/* Write predict.h */
outfile=fopen("predict.h","w");
fprintf(outfile,"/* This file was generated by the installer program */\n\n");
fprintf(outfile,"char *predictpath={\"%s/\"}, ",pwd);
if (dsp==-1)
fprintf(outfile, "soundcard=0,");
else
fprintf(outfile, "soundcard=1,");
fprintf(outfile, " *version={\"%s\"};\n",version);
fclose(outfile);
printw("\n predict.h was successfully created!\n");
attrset(COLOR_PAIR(3)|A_BOLD);
printw("\n Now compiling PREDICT. (This may take a while...)\n");
refresh();
/* Compile PREDICT... */
cc=system("cc -Wall -O3 -s -fomit-frame-pointer -lm -lncurses -pthread predict.c -o predict");
/* Create vocalizer.h */
outfile=fopen("vocalizer/vocalizer.h","w");
fprintf(outfile,"/* This file was generated by the installer program */\n\n");
fprintf(outfile,"char *path={\"%s/vocalizer/\"};\n",pwd);
fclose(outfile);
if (dsp!=-1 && cc==0)
{
attrset(COLOR_PAIR(3)|A_BOLD);
printw(" Compiling vocalizer...\n");
refresh();
system("cc -Wall -O3 -s -fomit-frame-pointer vocalizer/vocalizer.c -o vocalizer/vocalizer");
}
/* Now install the programs and man page by creating symlinks
between the newly created executables and the destination
directory. The default destination directory for the
executables is /usr/local/bin. This default may be
overridden by specifying a different path as an argument
to this program (ie: installer /usr/bin). Normally this
is passed along from the "configure" script. */
if (argc==2)
strncpy(destination,argv[1],78);
else
strncpy(destination,"/usr/local/bin/",15);
/* Ensure a trailing '/' is
present in "destination". */
x=strlen(destination);
if (destination[x-1]!='/' && x!=0)
{
destination[x]='/';
destination[x+1]=0;
}
if (cc==0)
{
attrset(COLOR_PAIR(3)|A_BOLD);
printw(" Linking PREDICT binaries to %s\n\n",destination);
sprintf(dest_path,"%spredict",destination);
unlink(dest_path);
sprintf(src_path,"%s/predict",pwd);
symlink(src_path,dest_path);
sprintf(dest_path,"%sxpredict",destination);
unlink(dest_path);
sprintf(src_path,"%s/xpredict",pwd);
symlink(src_path,dest_path);
unlink("/usr/local/man/man1/predict.1");
sprintf(dest_path,"%s/docs/man/predict.1",pwd);
symlink(dest_path,"/usr/local/man/man1/predict.1");
attrset(COLOR_PAIR(5)|A_BOLD);
printw(" Don't forget to check out the new graphical\n");
printw(" client applications under the 'clients' directory!");
attrset(COLOR_PAIR(1)|A_BOLD);
printw("\n\n Done! Visit http://www.qsl.net/kd2bd/predict.html for the latest news!");
}
else
{
attrset(COLOR_PAIR(2)|A_BOLD);
printw(" *** Compilation failed. Program not installed. :-(");
beep();
}
}
refresh();
unlink("installer");
curs_set(1);
refresh();
endwin();
exit(0);
}
|