File: makemake.sh

package info (click to toggle)
mysql++ 2.0.7-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 8,548 kB
  • ctags: 2,792
  • sloc: cpp: 35,566; sh: 8,517; xml: 2,769; perl: 752; makefile: 178
file content (86 lines) | stat: -rwxr-xr-x 2,047 bytes parent folder | download
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
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
#!/bin/bash

# Display usage message
function usage() {
	echo 'usage: makemake [simple] {gcc|mingw} [args]'
	echo
	echo '    You must give one of the compiler parameters:'
	echo
	echo '        gcc: GCC C++ compiler, Unix tuning'
	echo '        mingw: MinGW port of GCC C++ compiler'
	echo
	echo 'If you give the "simple" argument, no top-level Makefile is created,'
	echo 'no config.h is created, and we don'"'"'t call "make" for you.'
	echo
	exit 1
}

# Simplify a Makefile
function simplify() {
	# Strip comments, remove pointless macros, remove $(EXE), substitute
	# .o for .$(OBJ), remove $(LDSTARTUP), and squash multiple blank
	# lines.
	TMP=tmp`basename $1`
	sed -e'/^#/d' -e'/^EXE/d' -e'/^OBJ/d' -e'/^EXTRA/d' -e'/^gcc/d' \
			-e's/\$(EXE)//g' -e's/\.\$(OBJ)/.o/g' \
			-e's/\$(LDSTARTUP) //' $1 |uniq > $TMP
	mv $TMP $1
}

# Create top-level Makefile and default config.h files if we're not in
# "simple" mode.
if [ $1 == "simple" ]
then
	SIMPLE=.simple
	shift
else
	cat > Makefile <<MAKEFILE
all:
	( cd lib && make && cd ../examples && make )

clean:
	( cd lib && make clean )
	( cd examples && make clean )
MAKEFILE

	cat > config.h <<CONFIG_H
#define HAVE_MYSQL_SHUTDOWN_LEVEL_ARG
CONFIG_H
fi

# Figure out which compiler the user wants to create Makefiles for
if [ "$1" != "gcc" -a "$1" != "mingw" ]
then
	usage
fi

# Set up common headers for new Makefiles
head1="## DO NOT EDIT.  Created from Makefile.$1 and Makefile.base."
head2="## Edit those files instead, then type 'makemake $1' to rebuild"
head3="## this Makefile."

# Create library Makefile
echo "$head1
$head2
$head3
" > lib/Makefile$SIMPLE
cat lib/Makefile.$1 lib/Makefile.base >> lib/Makefile$SIMPLE

# Create example programs Makefile
echo "$head1
$head2
$head3
" > examples/Makefile$SIMPLE
cat examples/Makefile.$1 examples/Makefile.base >> examples/Makefile$SIMPLE

if [ -n "$SIMPLE" ]
then
	# Simplify generated Makefiles
	simplify lib/Makefile$SIMPLE
	simplify examples/Makefile$SIMPLE
else
	# We're not in "simple" mode, so start build process
	shift
	make $*
fi