-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·121 lines (102 loc) · 4.09 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·121 lines (102 loc) · 4.09 KB
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
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
116
117
118
119
120
121
#!/bin/bash
# HFSUtils - Simple Build Script
# This script builds hfsutils without needing autoconf/configure
# Pass through environment variables
export CC="${CC:-gcc}"
export CXX="${CXX:-g++}"
export CFLAGS="${CFLAGS:--g -O2}"
export CXXFLAGS="${CXXFLAGS:--g -O2}"
export LDFLAGS="${LDFLAGS:-}"
export PREFIX="${PREFIX:-/usr/local}"
export DESTDIR="${DESTDIR:-}"
echo "Building HFSUtils..."
echo "CC=$CC"
echo "CFLAGS=$CFLAGS"
echo "PREFIX=$PREFIX"
if [ -n "$DESTDIR" ]; then
echo "DESTDIR=$DESTDIR"
fi
# Create build directory if it doesn't exist
mkdir -p build/obj
# Create .stamp if it doesn't exit too
mkdir -p libhfs/.stamp
mkdir -p librsrc/.stamp
mkdir -p hfsck/.stamp
# Build libhfs
echo "Building libhfs..."
cd libhfs
if [ ! -f configure ]; then
echo "Error: libhfs/configure not found!"
exit 1
fi
if [ ! -f config.status ]; then
echo "Configuring libhfs..."
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$PREFIX"
fi
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" || { echo "Failed to build libhfs"; exit 1; }
cd ..
# Build librsrc
echo "Building librsrc..."
cd librsrc
if [ ! -f configure ]; then
echo "Error: librsrc/configure not found!"
exit 1
fi
if [ ! -f config.status ]; then
echo "Configuring librsrc..."
CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" ./configure --prefix="$PREFIX"
fi
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" || { echo "Failed to build librsrc"; exit 1; }
cd ..
# Build hfsck with journaling support
echo "Building hfsck..."
cd hfsck
# Try autotools first, but don't fail if it doesn't work
if [ -f configure ] && [ -f config.status ]; then
echo "Trying autotools build..."
if make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" 2>/dev/null; then
echo "hfsck built successfully with autotools"
cd ..
# Continue to main utilities
else
echo "Autotools build failed, falling back to manual compilation..."
fi
else
echo "Autotools not properly configured, using manual compilation..."
fi
# Manual compilation (either as fallback or primary method)
if [ ! -f hfsck ]; then
echo "Building hfsck manually with journaling support..."
# Compile all source files
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c *.c || { echo "Failed to compile hfsck sources"; exit 1; }
# Compile common sources
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/suid.c -o suid.o || { echo "Failed to compile suid.c"; exit 1; }
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/version.c -o version.o || { echo "Failed to compile version.c"; exit 1; }
$CC $CFLAGS -I./../include -I./../include/common -I./../libhfs -I./../src/common -DHAVE_CONFIG_H -c ../src/common/hfs_detect.c -o hfs_detect.o || { echo "Failed to compile hfs_detect.c"; exit 1; }
# Link hfsck with journaling support
$CC $CFLAGS -o hfsck ck_btree.o ck_mdb.o ck_volume.o hfsck.o main.o util.o journal.o suid.o version.o hfs_detect.o ./../libhfs/libhfs.a || { echo "Failed to link hfsck"; exit 1; }
echo "hfsck built successfully with manual compilation"
fi
cd ..
# Build main utilities
echo "Building hfsutil..."
make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" PREFIX="$PREFIX" || { echo "Failed to build hfsutil"; exit 1; }
# Build standalone mkfs utilities
echo "Building standalone mkfs.hfs and mkfs.hfs+ utilities..."
make -C src/mkfs all CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" || { echo "Failed to build mkfs utilities"; exit 1; }
if [ -f hfsutil ]; then
echo "Build complete! The hfsutil binary is ready."
echo ""
echo "To install system-wide, run:"
echo " sudo make install"
echo ""
echo "To install to a custom location, run:"
echo " make install PREFIX=/custom/path"
echo " make install DESTDIR=/staging/area"
echo ""
echo "To create traditional command symlinks, run:"
echo " sudo make install-symlinks"
else
echo "Build failed - hfsutil binary not created"
exit 1
fi