ObjFW  Check-in [5d0b1e33bc]

Overview
Comment:Make it possible to compile libraries using objfw-compile.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 5d0b1e33bc0b3c8d3103340cefbbf403c8c23ba5cfcd731a55a2a661ec1ae3ae
User & Date: js on 2010-10-17 19:30:16
Other Links: manifest | tags
Context
2010-10-19
19:38
Fix method signature being different in .h and .m file. check-in: 198e343d1f user: js tags: trunk
2010-10-17
19:30
Make it possible to compile libraries using objfw-compile. check-in: 5d0b1e33bc user: js tags: trunk
2010-10-15
18:46
D'oh. Rename namespace to ns in the block declaration.
This unbreaks ObjC++.
check-in: bd02818a56 user: js tags: trunk
Changes

Modified utils/objfw-compile from [580e65d425] to [32d4cb25d4].

12
13
14
15
16
17
18
19
20


21
22
23
24
25
26
27
12
13
14
15
16
17
18


19
20
21
22
23
24
25
26
27







-
-
+
+








CPPFLAGS="$CPPFLAGS $($OBJFW_CONFIG --cppflags)"
OBJC="$($OBJFW_CONFIG --objc)"
OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --objcflags)"
LIBS="$LIBS $($OBJFW_CONFIG --libs)"
LDFLAGS="$LDFLAGS $($OBJFW_CONFIG --ldflags)"

if test x"$1" = "x" -o x"$2" = "x"; then
	echo "Syntax: objfw-compile outname source1.m source2.m ..."
if test x"$1" = "x"; then
	echo "Syntax: objfw-compile -o outname source1.m source2.m ..."
	exit 1
fi

status_compiling() {
	printf "\033[K\033[0;33mCompiling \033[1;33m$1\033[0;33m...\033[0m\r"
}
status_compiled() {
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
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







+
-
+


-
+
+

+
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+

+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+

+







}
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="$1"
out=""
objs=""
link="no"
shift
out_prefix=""
out_suffix=""

while test x"$1" != "x"; do
case "$out" in
	case "$1" in
	*.c | *.C | *.cpp | *.cxx | *.C | *.h | *.m | *.mm | *.M)
		echo "The first paramter must be the output name!" 1>&2
		exit 1
		;;
esac
		-o|--out)
			shift
			out="$1"
			;;
		-l|--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
while test x"$1" != "x"; do
	case "$1" in

			export LIB_MAJOR="${1%.*}"
			export LIB_MINOR="${1#*.}"

			OBJCFLAGS="$OBJCFLAGS $($OBJFW_CONFIG --lib-cflags)"
			LDFLAGS="$LDFLAGS $($OBJFW_CONFIG --lib-ldflags)"
			out_prefix="$($OBJFW_CONFIG --lib-prefix)"
			out_suffix="$($OBJFW_CONFIG --lib-suffix)"
			;;
		-*)
			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
88
89
90
91
92
93
94





95
96
97
98
99





100
115
116
117
118
119
120
121
122
123
124
125
126





127
128
129
130
131
132







+
+
+
+
+
-
-
-
-
-
+
+
+
+
+

			exit 1
			;;
	esac

	shift
done

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

if test ! -f "$out" -o x"$link" = x"yes"; then
	status_linking $out
	$OBJC -o $out $objs $LIBS $ENV_LIBS $LDFLAGS $ENV_LDFLAGS || \
		status_link_failed $out $?
	status_linked $out
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

Modified utils/objfw-config.in from [252ff61b48] to [5afa048543].

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
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











+
+
+
+




















+
+
+
+







#!/bin/sh
prefix="@prefix@"
exec_prefix="@exec_prefix@"
libdir="@libdir@"
CFLAGS=""
CPPFLAGS="-I@includedir@"
CXXFLAGS=""
OBJC="@OBJC@"
OBJCFLAGS="@GNU_RUNTIME@ -fexceptions -fobjc-exceptions"
OBJCFLAGS="$OBJCFLAGS -fconstant-string-class=OFConstantString"
OBJCFLAGS="$OBJCFLAGS @NO_CONST_CFSTRINGS@ @BLOCKS_FLAGS@ @NO_WARN_UNUSED@"
LIB_CFLAGS="@LIB_CFLAGS@"
LIB_LDFLAGS="@LIB_LDFLAGS@"
LIB_PREFIX="@LIB_PREFIX@"
LIB_SUFFIX="@LIB_SUFFIX@"
LDFLAGS=""
LDFLAGS_REEXPORT="@LDFLAGS_REEXPORT@"
LDFLAGS_RPATH="@LDFLAGS_RPATH@"
LIBS="-L${libdir} -lobjfw @LIBS@"
VERSION="0.4-dev"

show_help() {
	cat <<__EOF__
objfw-config: Available arguments are:

	--all		Outputs all flags + libs
	--cflags	Outputs the required CFLAGS
	--cppflags	Outputs the required CPPFLAGS
	--cxxflags	Outputs the required CXXFLAGS
	--objc		Outputs the OBJC used to compile ObjFW
	--objcflags	Outputs the required OBJCFLAGS
	--ldflags	Outputs the required LDFLAGS
	--reexport	Outputs LDFLAGS to reexport ObjFW
	--rpath		Outputs LDFLAGS for using rpath
	--libs		Outputs the required LIBS
	--lib-cflags	Outputs CFLAGS for building a library"
	--lib-ldflags	Outputs LDFLAGS for building a library"
	--lib-prefix	Outputs the prefix for libraries"
	--lib-suffix	Outputs the suffix for libraries"
	--version	Outputs the installed version
__EOF__
	exit 0
}

test -z "$1" && show_help

58
59
60
61
62
63
64




































65
66
67
68
69
70
71
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







			;;
		--objcflags)
			printf "%s" "$OBJCFLAGS"
			;;
		--libs)
			printf "%s" "$LIBS"
			;;
		--lib-cflags)
			if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then
				echo "LIB_MAJOR and LIB_MINOR need to be set!" \
					1>&2
				exit 1
			fi

			printf "%s" "$LIB_CFLAGS"
			;;
		--lib-ldflags)
			if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then
				echo "LIB_MAJOR and LIB_MINOR need to be set!" \
					1>&2
				exit 1
			fi

			printf "%s" "$LIB_LDFLAGS"
			;;
		--lib-prefix)
			if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then
				echo "LIB_MAJOR and LIB_MINOR need to be set!" \
					1>&2
				exit 1
			fi

			printf "%s" "$LIB_PREFIX"
			;;
		--lib-suffix)
			if test x"$LIB_MAJOR" = x"" -o x"$LIB_MINOR" = x""; then
				echo "LIB_MAJOR and LIB_MINOR need to be set!" \
					1>&2
				exit 1
			fi

			printf "%s" "$LIB_SUFFIX"
			;;
		--ldflags)
			printf "%s" "$LDFLAGS"
			;;
		--reexport)
			printf "%s" "$LDFLAGS_REEXPORT"
			;;
		--rpath)