ObjFW  Diff

Differences From Artifact [238d9fe9f5]:

To Artifact [a7608ce4ad]:


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
}
status_link_failed() {
	printf "\033[K\033[0;31mFailed to link \033[1;31m$1\033[0;31m!"
	printf "\033[0m\n"
	exit $2
}

flags_done="no"
out=""
objs=""
link="no"
lib="no"
out_prefix=""
out_suffix=""

while test x"$1" != "x"; do
	case "$1" in
		-o|--out)
			shift
			out="$1"
			;;
		--lib)
			if test x"flags_done" = x"yes"; then
				printf "The --lib flag needs to be specified "
				printf "before any source file!\n"
				exit 1
			fi

			shift

			if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+" >/dev/null
			then
				echo "$1 is not a valid library version!"
				exit 1
			fi







|














<
<
<
<
<
<







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
}
status_link_failed() {
	printf "\033[K\033[0;31mFailed to link \033[1;31m$1\033[0;31m!"
	printf "\033[0m\n"
	exit $2
}

srcs=""
out=""
objs=""
link="no"
lib="no"
out_prefix=""
out_suffix=""

while test x"$1" != "x"; do
	case "$1" in
		-o|--out)
			shift
			out="$1"
			;;
		--lib)






			shift

			if ! echo "$1" | grep "^[0-9]\+\.[0-9]\+" >/dev/null
			then
				echo "$1 is not a valid library version!"
				exit 1
			fi
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
			OBJCFLAGS="$OBJCFLAGS $1"
			;;
		-*)
			echo "Unknown option: $1"
			exit 1
			;;
		*.m)
			flags_done="yes"
			obj="${1%.m}.o"
			objs="$objs $obj"
			build="no"
			deps=$($OBJC -E -M $CPPFLAGS $ENV_CPPFLAGS $1 | \
			       sed 's/.*: //' | sed 's/\\//g')

			if test -f "$obj"; then
				for dep in $deps; do
					test "$dep" -nt $obj && build="yes"
				done
			else
				build="yes"
			fi

			if test x"$build" = x"yes"; then
				link="yes"
				status_compiling $1
				$OBJC $CPPFLAGS $OBJCFLAGS -c -o $obj $1 || \
					status_compile_failed $1 $?
				status_compiled $1
			fi
			;;
		*)
			echo "Only .m files can be compiled!" 1>&2
			exit 1
			;;
	esac

	shift
done

if test x"$out" = x""; then
	echo "No output name specified! Use -o or --out!"
	exit 1
fi

























test x"$lib" = x"no" && out_suffix="$($OBJFW_CONFIG --prog-suffix)"

if test ! -f "$out_prefix$out$out_suffix" -o x"$link" = x"yes"; then
	status_linking $out_prefix$out$out_suffix
	$OBJC -o $out_prefix$out$out_suffix $objs $LIBS $ENV_LIBS $LDFLAGS \
		$ENV_LDFLAGS || status_link_failed $out $?
	status_linked $out_prefix$out$out_suffix
fi







<
<
<
<
<
<
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<














>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>









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
			OBJCFLAGS="$OBJCFLAGS $1"
			;;
		-*)
			echo "Unknown option: $1"
			exit 1
			;;
		*.m)






			srcs="$srcs $1"















			;;
		*)
			echo "Only .m files can be compiled!" 1>&2
			exit 1
			;;
	esac

	shift
done

if test x"$out" = x""; then
	echo "No output name specified! Use -o or --out!"
	exit 1
fi

for i in $srcs; do
	obj="${i%.m}.o"
	objs="$objs $obj"
	build="no"
	deps=$($OBJC -E -M $CPPFLAGS $ENV_CPPFLAGS $i | \
	       sed 's/.*: //' | sed 's/\\//g')

	if test -f "$obj"; then
		for dep in $deps; do
			test "$dep" -nt $obj && build="yes"
		done
	else
		build="yes"
	fi

	if test x"$build" = x"yes"; then
		link="yes"
		status_compiling $i
		$OBJC $CPPFLAGS $OBJCFLAGS -c -o $obj $i || \
			status_compile_failed $i $?
		status_compiled $i
	fi
done

test x"$lib" = x"no" && out_suffix="$($OBJFW_CONFIG --prog-suffix)"

if test ! -f "$out_prefix$out$out_suffix" -o x"$link" = x"yes"; then
	status_linking $out_prefix$out$out_suffix
	$OBJC -o $out_prefix$out$out_suffix $objs $LIBS $ENV_LIBS $LDFLAGS \
		$ENV_LDFLAGS || status_link_failed $out $?
	status_linked $out_prefix$out$out_suffix
fi