aboutsummaryrefslogtreecommitdiffstats
path: root/code/unix/Conscript-sdk
blob: d5450134108153c51656c7e095369ead42dafd3c (plain)
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
# sdk

Import qw( SDK_NAME Q3_VER CC CXX LINK );

# http://www.devdaily.com/perl/edu/articles/pl010005/pl010005.shtml
#----------------------------(  promptUser  )-----------------------------#
#                                                                         #
#  FUNCTION:	promptUser                                                #
#                                                                         #
#  PURPOSE:	Prompt the user for some type of input, and return the    #
#		input back to the calling program.                        #
#                                                                         #
#  ARGS:	$promptString - what you want to prompt the user with     #
#		$defaultValue - (optional) a default value for the prompt #
#                                                                         #
#-------------------------------------------------------------------------#

sub promptUser {

   #-------------------------------------------------------------------#
   #  two possible input arguments - $promptString, and $defaultValue  #
   #  make the input arguments local variables.                        #
   #-------------------------------------------------------------------#

   local($promptString,$defaultValue) = @_;

   #-------------------------------------------------------------------#
   #  if there is a default value, use the first print statement; if   #
   #  no default is provided, print the second string.                 #
   #-------------------------------------------------------------------#

   if ($defaultValue) {
      print $promptString, "[", $defaultValue, "]: ";
   } else {
      print $promptString, ": ";
   }

   $| = 1;               # force a flush after our print
   $_ = <STDIN>;         # get the input from STDIN (presumably the keyboard)


   #------------------------------------------------------------------#
   # remove the newline character from the end of the input the user  #
   # gave us.                                                         #
   #------------------------------------------------------------------#

   chomp;

   #-----------------------------------------------------------------#
   #  if we had a $default value, and the user gave us input, then   #
   #  return the input; if we had a default, and they gave us no     #
   #  no input, return the $defaultValue.                            #
   #                                                                 # 
   #  if we did not have a default value, then just return whatever  #
   #  the user gave us.  if they just hit the <enter> key,           #
   #  the calling routine will have to deal with that.               #
   #-----------------------------------------------------------------#

   if ("$defaultValue") {
      return $_ ? $_ : $defaultValue;    # return $_ if it has a value
   } else {
      return $_;
   }
}

sub launch {

  print("Building MOD SDK (version $Q3_VER)\n");
  print("Before building the mod sdk, your CVS tree must be completely clean!\nIf there are some temporary files and binaries in the tree, they can get included in the distribution and cause problems.\n");
  $ok = &promptUser("Ready to build mod sdk [y/n]? ");
  if ($ok ne 'y')
  {
    print("aborting\n");
    return 0;
  }  
  # create the dirs:
  $RAW_DATA = "mod-sdk-$Q3_VER";
  system("rm -rf $RAW_DATA ; mkdir -p $RAW_DATA/code");
  # actual code
  system("cp -R cgame game q3_ui ui $RAW_DATA/code");
  # UI stuff
  system("cp -R ../ui $RAW_DATA");
  # tools
  system("cp -R ../lcc ../q3asm $RAW_DATA");
  # build scripts
  system("cp Construct $RAW_DATA/code");
  system("mkdir $RAW_DATA/code/unix ; cp unix/cons unix/pcons-2.3.1 unix/Conscript-pk3 $RAW_DATA/code/unix");
  system("cp unix/mod-sdk-data/Makefile $RAW_DATA/code/");
  # cleanup some stuff
  system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
  # test that the build works just fine
  $host=`hostname`; chomp($host);
  if ($host ne 'antares')
  {
    system("rm -rf /tmp/$RAW_DATA ; cp -R $RAW_DATA /tmp");
    system("cd /tmp/$RAW_DATA/code ; make");
    if ($? ne 0)
    {
      printf("ERROR: test build failed\n");
      return 0;
    }
    printf("build test successful\n");
  }
  # make a setup out of this
  system("cp -R unix/setup/setup.sh unix/setup/setup.data $RAW_DATA");
  # TODO: splash!
  system("cp unix/mod-sdk-data/setup.xml unix/mod-sdk-data/config.sh unix/mod-sdk-data/postinstall.sh $RAW_DATA/setup.data");
  # mod-sdk-data/Q3A_EULA.txt is a copy of stuff that is usually in $Q3SETUPMEDIA .. can't be arsed
  system("cp unix/mod-sdk-data/Q3A_EULA.txt $RAW_DATA");
  # I love those dirty hacks
  system("cd $RAW_DATA/setup.data/bin ; ln -s Linux FreeBSD ; ln -s Linux OpenBSD ; ln -s Linux NetBSD");
  # cleanup some stuff
  system("find $RAW_DATA -name CVS -exec rm -rf {} \\; 2>/dev/null");
  # weeee
  system("unix/mod-sdk-data/makeself/makeself.sh $RAW_DATA $SDK_NAME \"Quake III Arena mod SDK\" ./setup.sh $Q3_VER");
  return 1;
}

print("in Conscript-sdk\n");

$env = new cons();
Command $env "$SDK_NAME", "[perl] &launch()";