permission mods
[feisty_meow.git] / scripts / clam / cpp / preconditions.sh
1 #!/bin/bash
2 # prepares the project for compilation by creating the appropriate directories.
3
4 # make sure our temp directory is there.
5 if [ ! -d $CLAM_TMP ]; then mkdir -p $CLAM_TMP; fi
6
7 # if the clean flag is defined, then we need to quit.  we should not be
8 # creating directories or doing other tasks for a build that is really
9 # a cleanup session.
10 if [ ! -z "$CLEAN" ]; then
11   exit 0
12 fi
13
14 # make sure generated files have a home.
15 if [ ! -d $TARGETS_STORE ]; then mkdir -p $TARGETS_STORE; fi
16 # create the generated files storage area.
17 if [ ! -d $OUTPUT_ROOT ]; then mkdir -p $OUTPUT_ROOT; fi
18 # create the top level object directory if it doesn't exist.
19 if [ ! -d $BASE_OUTPUT_PATH ]; then mkdir -p $BASE_OUTPUT_PATH; fi
20 # create the project level object directory if it is non-existent.
21 if [ ! -d $OUTPUT_PATH ]; then mkdir -p $OUTPUT_PATH; fi
22 # create a directory to hold any debugging files, if necessary.
23 if [ ! -d $PDB_DIR ]; then mkdir -p $PDB_DIR; fi
24 #
25 ####if [ ! -d $TESTS_DIR ]; then mkdir $TESTS_DIR; fi
26 #
27 if [ ! -d $EXECUTABLE_DIR ]; then mkdir -p $EXECUTABLE_DIR; fi
28 #
29 if [ ! -d $DYNAMIC_LIBRARY_DIR ]; then mkdir -p $DYNAMIC_LIBRARY_DIR; fi
30 #
31 if [ ! -d $STATIC_LIBRARY_DIR ]; then mkdir -p $STATIC_LIBRARY_DIR; fi
32
33 # set versions on any extras that were specified in the makefile.
34 if [ ! -z "$EXTRA_VERSIONS" ]; then
35   for i in $EXTRA_VERSIONS; do
36     $CLAM_BINARIES/version_stamper$EXE_END $i $PARAMETER_FILE
37   done
38 fi
39
40 # we whack any zero length objects found, since those are generally artifacts
41 # of an aborted compilation.
42 $FIND "$OBJECT_DIR" -type f -size 0 -exec rm -f {} ';'
43
44 # we also clean out the specific targets that we intend to build.  we don't
45 # want phony old versions sitting around confusing us.
46 if [ ! -z "$NO_COMPILE" ]; then
47 #  echo "we're removing these now: $ACTUAL_TARGETS"
48   rm -f $ACTUAL_TARGETS
49 fi
50
51 if [ ! -z "$TEST_MAKEFILE" ]; then
52
53 # this will only work if the LOCAL_LIBS_USED and SOURCE are exported
54
55 #??, STATIC_LIBRARY_DIR
56
57   #echo "compiler=$COMPILER"
58   #echo "OP_SYSTEM=$OP_SYSTEM"
59
60   #echo "checking for all local libs: $LOCAL_LIBS_USED"
61   failed_check=
62   for i in $LOCAL_LIBS_USED; do
63   #echo curr lib is $STATIC_LIBRARY_DIR/$i$LIB_ENDING
64     if [ ! -f "$STATIC_LIBRARY_DIR/$i$LIB_ENDING" ]; then
65       echo "Missing a local library: $i$LIB_ENDING"
66       failed_check=true
67     fi
68   done
69   if [ "$failed_check" != "" ]; then
70     exit 1  # failure.  
71   fi
72   
73   #echo "checking for all source files: $SOURCE"
74   failed_check=
75   for i in $SOURCE; do
76   #echo curr src file is $i
77     if [ ! -f "$i" ]; then
78       echo "Missing a source file: $i"
79       failed_check=true
80     fi
81   done
82   if [ "$failed_check" != "" ]; then
83     exit 1  # failure.  
84   fi
85 fi
86
87