Commit 38ac4cc9 authored by Vincent Danjean's avatar Vincent Danjean
Browse files

Add support for CPPFLAGS and LDFLAGS

parent def3fd40
...@@ -35,7 +35,7 @@ programme comme commande =RUN= et =DEBUG= par défaut. ...@@ -35,7 +35,7 @@ programme comme commande =RUN= et =DEBUG= par défaut.
* Le fichier =vpl_custom_setup.sh= * Le fichier =vpl_custom_setup.sh=
En plus de variables habituelles, le fichier =vpl_custom_setup.sh= peut maintenant définir les En plus de variables habituelles, le fichier =vpl_custom_setup.sh= peut maintenant définir les
variables d'environnement =CC=, =CFLAGS= et =LDLIBS= classiques qui seront utilisées dans toutes les variables d'environnement =CC=, =CPPFLAGS", =CFLAGS=, =LDFLAGS= et =LDLIBS= classiques qui seront utilisées dans toutes les
compilations gérées par l'activité. compilations gérées par l'activité.
#+BEGIN_SRC emacs-lisp :results output :session :exports results :eval yes #+BEGIN_SRC emacs-lisp :results output :session :exports results :eval yes
......
#!/bin/bash #!/bin/bash
C_FILES=0 C_FILES=0
export CC=${CC-'gcc'} export CC=${CC-'gcc'}
export CFLAGS=${CFLAGS-'-Wall -Werror -g'} export CPPFLAGS=${CPPFLAGS-'-Wall -Werror'}
export CFLAGS=${CFLAGS-'-g'}
export LDFLAGS=${LDFLAGS-''}
export WEAKEN_SYMBOLS export WEAKEN_SYMBOLS
compile() { compile() {
...@@ -11,8 +13,8 @@ compile() { ...@@ -11,8 +13,8 @@ compile() {
if [ "$base" != "$file" -a ! -f "$base.o" ] if [ "$base" != "$file" -a ! -f "$base.o" ]
then then
echo "Compiling $file..." echo "Compiling $file..."
echo $CC $CFLAGS -c "$file" echo $CC $CPPFLAGS $CFLAGS -c "$file"
$CC $CFLAGS -c "$file" || return 1 $CC $CPPFLAGS $CFLAGS -c "$file" || return 1
echo " done." echo " done."
C_FILES=1 C_FILES=1
fi fi
...@@ -43,7 +45,7 @@ then ...@@ -43,7 +45,7 @@ then
# compile *.c >/dev/null 2>&1 || internal_error "Compilation of a hidden file failed" # compile *.c >/dev/null 2>&1 || internal_error "Compilation of a hidden file failed"
if [ $C_FILES -gt 0 ] if [ $C_FILES -gt 0 ]
then then
$CC $LDLIBS *.o -o main_program || error "Linking into main_program failed" $CC $LDFLAGS *.o -o main_program $LDLIBS || error "Linking into main_program failed"
GENERATED_FILES=main_program GENERATED_FILES=main_program
RUN=${RUN-'./main_program'} RUN=${RUN-'./main_program'}
DEBUG=${DEBUG-'gdb --args main_program'} DEBUG=${DEBUG-'gdb --args main_program'}
......
...@@ -28,7 +28,7 @@ fi ...@@ -28,7 +28,7 @@ fi
for file in $FILES for file in $FILES
do do
base=$(basename $file .c) base=$(basename $file .c)
$CC $CFLAGS -c $file || end $? $CC $CPPFLAGS $CFLAGS -c $file || end $?
GENERATED_FILES="$GENERATED_FILES $base.o" GENERATED_FILES="$GENERATED_FILES $base.o"
if [ -n "$WEAKEN_SYMBOLS" ] && search $file $VPL_SUBFILES if [ -n "$WEAKEN_SYMBOLS" ] && search $file $VPL_SUBFILES
then then
...@@ -40,7 +40,7 @@ do ...@@ -40,7 +40,7 @@ do
objcopy $weaken_list $base.o objcopy $weaken_list $base.o
fi fi
done done
$CC $GENERATED_FILES $LDLIBS -o $NAME || end $? $CC $LDFLAGS $GENERATED_FILES $LDLIBS -o $NAME || end $?
end 0 end 0
}; };
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment