On Sun, Jul 23, 2017, at 05:38, ochern wrote:
> . $TOP/build.conf
> 
> case "$target_os" in
>   gnulinux)
>     SOURCES="$SOURCES linux.c"
>     CFLAGS="-DENABLE_LINUX_FEATURES
>     ;;
>   *)
>     SOURCES="$SOURCES unix.c"
>     ;;
>   esac
> 
> OBJECTS=`src2obj $SOURCES`
> PROG=app
> 
> cat <<EOF >Makefile
> 
> $PROG: $OBJECTS
>     $CC -o $PROG $OBJECTS
> 
> o.c.:
>     $CC -c $CFLAGS \$< -o \$@
> 
> EOF

Here is my attempt to write it in mk:

< $TOP/build.conf

SOURCES=$SOURCES generic.c

SOURCES=$SOURCES `{[ "$target_os" = gnulinux ] && echo linux.c || echo
unix.c} 
CFLAGS=$CFLAGS `{[ "$target_os" = gnulinux ] && echo
-DENABLE_LINUX_FEATURES}

OBJECTS=`{./src2obj $SOURCES}
PROG=app

$PROG: $OBJECTS
        $CC -o $PROG $OBJECTS

%.o: %.c
        $CC -c $CFLAGS $prereq -o $target

Reply via email to