| 1 |
|
| 2 |
RAW_CC = gcc |
| 3 |
RAW_FLAGS = -Wall -O2 |
| 4 |
LINK_OPT = |
| 5 |
VERSION = 1.5.7 |
| 6 |
# Try to determine the host system |
| 7 |
SYS := $(shell uname -s | tr -d "[0-9]" | tr -d "-" | tr "[A-Z]" "[a-z]") |
| 8 |
|
| 9 |
|
| 10 |
# You can cross compile this program for Win32 using Linux and the |
| 11 |
# MinGW compiler. See the README for details. If you have already |
| 12 |
# installed MinGW, put the location ($PREFIX) here: |
| 13 |
CR_BASE = /usr/local/cross-tools/i386-mingw32msvc/bin |
| 14 |
|
| 15 |
# You shouldn't need to change anything below this line |
| 16 |
#--------------------------------------------------------------------- |
| 17 |
|
| 18 |
# This should be commented out when debugging is done |
| 19 |
#RAW_FLAGS += -D__DEBUG -ggdb |
| 20 |
|
| 21 |
NAME = foremost |
| 22 |
MAN_PAGES = $(NAME).8.gz |
| 23 |
|
| 24 |
RAW_FLAGS += -DVERSION=\"$(VERSION)\" |
| 25 |
|
| 26 |
# Where we get installed |
| 27 |
BIN = /usr/local/bin |
| 28 |
MAN = /usr/share/man/man8 |
| 29 |
CONF= /usr/local/etc |
| 30 |
# Setup for compiling and cross-compiling for Windows |
| 31 |
# The CR_ prefix refers to cross compiling from OSX to Windows |
| 32 |
CR_CC = $(CR_BASE)/gcc |
| 33 |
CR_OPT = $(RAW_FLAGS) -D__WIN32 |
| 34 |
CR_LINK = -liberty |
| 35 |
CR_STRIP = $(CR_BASE)/strip |
| 36 |
CR_GOAL = $(NAME).exe |
| 37 |
WINCC = $(RAW_CC) $(RAW_FLAGS) -D__WIN32 |
| 38 |
|
| 39 |
# Generic "how to compile C files" |
| 40 |
CC = $(RAW_CC) $(RAW_FLAGS) -D__UNIX |
| 41 |
.c.o: |
| 42 |
$(CC) -c $< |
| 43 |
|
| 44 |
|
| 45 |
# Definitions we'll need later (and that should rarely change) |
| 46 |
HEADER_FILES = main.h ole.h extract.h |
| 47 |
SRC = main.c state.c helpers.c config.c cli.c engine.c dir.c extract.c api.c |
| 48 |
OBJ = main.o state.o helpers.o config.o cli.o engine.o dir.o extract.o api.o |
| 49 |
DOCS = Makefile README CHANGES $(MAN_PAGES) foremost.conf |
| 50 |
WINDOC = README.txt CHANGES.txt |
| 51 |
|
| 52 |
|
| 53 |
#--------------------------------------------------------------------- |
| 54 |
# OPERATING SYSTEM DIRECTIVES |
| 55 |
#--------------------------------------------------------------------- |
| 56 |
|
| 57 |
all: $(SYS) goals |
| 58 |
|
| 59 |
goals: $(NAME) |
| 60 |
|
| 61 |
linux: CC += -D__LINUX -DLARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 |
| 62 |
linux: goals |
| 63 |
|
| 64 |
sunos: solaris |
| 65 |
solaris: CC += -D__SOLARIS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 |
| 66 |
solaris: goals |
| 67 |
|
| 68 |
darwin: CC += -D__MACOSX |
| 69 |
darwin: goals |
| 70 |
|
| 71 |
mac: CC += -D__MACOSX |
| 72 |
mac: goals |
| 73 |
|
| 74 |
netbsd: unix |
| 75 |
openbsd: unix |
| 76 |
freebsd: unix |
| 77 |
|
| 78 |
gnu: CC += -DPATH_MAX=4096 |
| 79 |
gnu: unix |
| 80 |
|
| 81 |
gnu/kfreebsd: unix |
| 82 |
unix: goals |
| 83 |
|
| 84 |
#Fore some reasons BSD variants get confused on how to build engine.o |
| 85 |
#so lets make it real clear |
| 86 |
|
| 87 |
engine.o: engine.c |
| 88 |
$(CC) -c engine.c |
| 89 |
|
| 90 |
|
| 91 |
# Common commands for compiling versions for Windows. |
| 92 |
# See cross and windows directives below. |
| 93 |
win_general: LINK_OPT = $(CR_LINK) |
| 94 |
win_general: GOAL = $(CR_GOAL) |
| 95 |
win_general: goals |
| 96 |
$(STRIP) $(CR_GOAL) |
| 97 |
|
| 98 |
# Cross compiling from Linux to Windows. See README for more info |
| 99 |
cross: CC = $(CR_CC) $(CR_OPT) |
| 100 |
cross: STRIP = $(CR_STRIP) |
| 101 |
cross: win_general |
| 102 |
|
| 103 |
# See the README for information on Windows compilation |
| 104 |
windows: CC = $(WINCC) |
| 105 |
windows: STRIP = strip |
| 106 |
windows: win_general |
| 107 |
|
| 108 |
cygwin_nt.: unix |
| 109 |
cygwin: unix |
| 110 |
|
| 111 |
|
| 112 |
#--------------------------------------------------------------------- |
| 113 |
# COMPILE THE PROGRAMS |
| 114 |
# This section must be updated each time you add an algorithm |
| 115 |
#--------------------------------------------------------------------- |
| 116 |
|
| 117 |
foremost: $(OBJ) |
| 118 |
$(CC) $(OBJ) -o $(NAME) $(LINK_OPT) |
| 119 |
|
| 120 |
|
| 121 |
#--------------------------------------------------------------------- |
| 122 |
# INSTALLATION AND REMOVAL |
| 123 |
#--------------------------------------------------------------------- |
| 124 |
|
| 125 |
install: goals |
| 126 |
install -m 755 $(NAME) $(BIN) |
| 127 |
install -m 444 $(MAN_PAGES) $(MAN) |
| 128 |
install -m 444 foremost.conf $(CONF) |
| 129 |
macinstall: BIN = /usr/local/bin/ |
| 130 |
macinstall: MAN = /usr/share/man/man1/ |
| 131 |
macinstall: CONF = /usr/local/etc/ |
| 132 |
macinstall: mac install |
| 133 |
|
| 134 |
|
| 135 |
uninstall: |
| 136 |
rm -f -- $(BIN)/{$(RM_GOALS)} |
| 137 |
rm -f -- $(MAN)/{$(RM_DOCS)} |
| 138 |
|
| 139 |
macuninstall: BIN = /usr/bin |
| 140 |
macuninstall: MAN = /usr/share/man/man1 |
| 141 |
macuninstall: uninstall |
| 142 |
|
| 143 |
#--------------------------------------------------------------------- |
| 144 |
# CLEAN UP |
| 145 |
#--------------------------------------------------------------------- |
| 146 |
|
| 147 |
# This is used for debugging |
| 148 |
preflight: |
| 149 |
grep -n RBF *.1 *.h *.c README CHANGES |
| 150 |
|
| 151 |
nice: |
| 152 |
rm -f -- *~ |
| 153 |
|
| 154 |
clean: nice |
| 155 |
rm -f -- *.o |
| 156 |
rm -f -- $(CR_GOAL) $(NAME) $(WIN_DOC) |
| 157 |
rm -f -- $(TAR_FILE).gz $(DEST_DIR).zip $(DEST_DIR).zip.gpg |
| 158 |
|
| 159 |
#------------------------------------------------------------------------- |
| 160 |
# MAKING PACKAGES |
| 161 |
#------------------------------------------------------------------------- |
| 162 |
|
| 163 |
EXTRA_FILES = |
| 164 |
DEST_DIR = $(NAME)-$(VERSION) |
| 165 |
TAR_FILE = $(DEST_DIR).tar |
| 166 |
PKG_FILES = $(SRC) $(HEADER_FILES) $(DOCS) $(EXTRA_FILES) |
| 167 |
|
| 168 |
# This packages me up to send to somebody else |
| 169 |
package: clean |
| 170 |
rm -f $(TAR_FILE) $(TAR_FILE).gz |
| 171 |
mkdir $(DEST_DIR) |
| 172 |
cp $(PKG_FILES) $(DEST_DIR) |
| 173 |
tar cvf $(TAR_FILE) $(DEST_DIR) |
| 174 |
rm -rf $(DEST_DIR) |
| 175 |
gzip $(TAR_FILE) |
| 176 |
|
| 177 |
|
| 178 |
# This Makefile is designed for Mac OSX to package the file. |
| 179 |
# To do this on a linux box, The big line below starting with "/usr/bin/tbl" |
| 180 |
# should be replaced with: |
| 181 |
# |
| 182 |
# man ./$(MD5GOAL).1 | col -bx > README.txt |
| 183 |
# |
| 184 |
# and the "flip -d" command should be replaced with dos2unix |
| 185 |
# |
| 186 |
# The flip command can be found at: |
| 187 |
# http://ccrma-www.stanford.edu/~craig/utility/flip/# |
| 188 |
win-doc: |
| 189 |
/usr/bin/tbl ./$(MD5GOAL).1 | /usr/bin/groff -S -Wall -mtty-char -mandoc -Tascii | /usr/bin/col > README.txt |
| 190 |
cp CHANGES CHANGES.txt |
| 191 |
flip -d $(WINDOC) |
| 192 |
|
| 193 |
cross-pkg: clean cross win-doc |
| 194 |
rm -f $(DEST_DIR).zip |
| 195 |
zip $(DEST_DIR).zip $(CR_MD5GOAL) $(CR_SHA1GOAL) $(CR_SHA256GOAL) $(WINDOC) |
| 196 |
rm -f $(WINDOC) |
| 197 |
|
| 198 |
world: package cross-pkg |