robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 1 | # honggfuzz - Makefile |
| 2 | # ----------------------------------------- |
| 3 | # |
| 4 | # Author: Robert Swiecki <swiecki@google.com> |
| 5 | # |
robert.swiecki@gmail.com | ba85c3e | 2015-02-02 14:55:16 +0000 | [diff] [blame] | 6 | # Copyright 2010-2015 by Google Inc. All Rights Reserved. |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | # you may not use this file except in compliance with the License. |
| 10 | # You may obtain a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | # See the License for the specific language governing permissions and |
| 18 | # limitations under the License. |
| 19 | |
| 20 | |
robert.swiecki@gmail.com | ef829fa | 2011-06-22 13:51:57 +0000 | [diff] [blame] | 21 | CC = gcc |
robert.swiecki@gmail.com | 4c1ad43 | 2015-02-03 11:04:13 +0000 | [diff] [blame] | 22 | CFLAGS += -c -std=c11 -I. -I/usr/local/include -I/usr/include \ |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 23 | -D_GNU_SOURCE \ |
robert.swiecki@gmail.com | 71a2f9d | 2015-02-02 21:32:23 +0000 | [diff] [blame] | 24 | -Wall -Wextra -Wno-override-init -Werror |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 25 | |
robert.swiecki@gmail.com | ef829fa | 2011-06-22 13:51:57 +0000 | [diff] [blame] | 26 | LD = gcc |
robert.swiecki@gmail.com | 882900b | 2015-02-11 13:56:22 +0000 | [diff] [blame] | 27 | LDFLAGS += -lm -lpthread -L/usr/local/include -L/usr/include |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 28 | |
robert.swiecki@gmail.com | e7190b9 | 2015-02-14 23:05:42 +0000 | [diff] [blame] | 29 | SRCS = honggfuzz.c log.c files.c fuzz.c util.c report.c |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 30 | |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 31 | OBJS = $(SRCS:.c=.o) |
| 32 | BIN = honggfuzz |
| 33 | |
robert.swiecki@gmail.com | 448d281 | 2015-02-02 20:57:13 +0000 | [diff] [blame] | 34 | OS ?= $(shell uname -s) |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 35 | |
robert.swiecki@gmail.com | a0d8714 | 2015-02-14 13:11:18 +0000 | [diff] [blame] | 36 | ARCH_SRCS := $(wildcard posix/*.c) |
robert.swiecki@gmail.com | b0cac5b | 2015-02-17 00:19:59 +0000 | [diff] [blame] | 37 | ARCH = POSIX |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 38 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 39 | ifeq ($(OS),Linux) |
robert.swiecki@gmail.com | c5f5be6 | 2015-02-15 17:17:21 +0000 | [diff] [blame] | 40 | ifeq ("$(wildcard /usr/include/bfd.h)","") |
| 41 | WARN_LIBRARY += "binutils-dev " |
| 42 | endif |
| 43 | ifeq ("$(wildcard /usr/include/libunwind-ptrace.h)","") |
robert.swiecki@gmail.com | 66ee275 | 2015-02-16 20:49:44 +0000 | [diff] [blame] | 44 | WARN_LIBRARY += "libunwind-dev/libunwind8-dev " |
robert.swiecki@gmail.com | f8440e0 | 2015-02-03 14:44:35 +0000 | [diff] [blame] | 45 | endif |
robert.swiecki@gmail.com | 26eee24 | 2015-02-16 12:21:36 +0000 | [diff] [blame] | 46 | LDFLAGS += -lunwind-ptrace -lunwind-generic -lbfd -lopcodes |
robert.swiecki@gmail.com | a0d8714 | 2015-02-14 13:11:18 +0000 | [diff] [blame] | 47 | ARCH_SRCS := $(wildcard linux/*.c) |
robert.swiecki@gmail.com | b0cac5b | 2015-02-17 00:19:59 +0000 | [diff] [blame] | 48 | ARCH = LINUX |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 49 | endif |
| 50 | ifeq ($(OS),Darwin) |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 51 | CC ?= cc |
robert.swiecki@gmail.com | 65fa911 | 2015-02-02 20:55:36 +0000 | [diff] [blame] | 52 | CFLAGS = -arch x86_64 -O3 -g -ggdb -c -std=c99 -I. -I~/.homebrew/include -I/usr/include \ |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 53 | -x objective-c \ |
| 54 | -D_GNU_SOURCE \ |
| 55 | -pedantic \ |
| 56 | -Wall -Werror -Wimplicit -Wunused -Wcomment -Wchar-subscripts -Wuninitialized -Wcast-align \ |
| 57 | -Wreturn-type -Wpointer-arith |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 58 | LD ?= cc |
robert.swiecki@gmail.com | 65fa911 | 2015-02-02 20:55:36 +0000 | [diff] [blame] | 59 | LDFLAGS = -F/System/Library/PrivateFrameworks -framework CoreSymbolication -framework IOKit \ |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 60 | -framework Foundation -framework ApplicationServices -framework Symbolication \ |
| 61 | -framework CoreServices -framework CrashReporterSupport -framework CoreFoundation \ |
| 62 | -framework CommerceKit -lm -L/usr/include -L$(shell echo ~)/.homebrew/lib |
robert.swiecki@gmail.com | a0d8714 | 2015-02-14 13:11:18 +0000 | [diff] [blame] | 63 | ARCH_SRCS = $(wildcard mac/*.c) |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 64 | MIG_OUTPUT = mach_exc.h mach_excUser.c mach_excServer.h mach_excServer.c |
| 65 | MIG_OBJECTS = mach_excUser.o mach_excServer.o |
groebert@google.com | 43216c8 | 2015-02-13 11:11:38 +0000 | [diff] [blame] | 66 | #CRASH_REPORT = third_party/CrashReport_Yosemite.o |
| 67 | CRASH_REPORT = third_party/CrashReport_Mavericks.o |
robert.swiecki@gmail.com | b0cac5b | 2015-02-17 00:19:59 +0000 | [diff] [blame] | 68 | ARCH = DARWIN |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 69 | endif |
robert.swiecki@gmail.com | b0cac5b | 2015-02-17 00:19:59 +0000 | [diff] [blame] | 70 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 71 | SRCS += $(ARCH_SRCS) |
robert.swiecki@gmail.com | b0cac5b | 2015-02-17 00:19:59 +0000 | [diff] [blame] | 72 | CFLAGS += -D_HF_ARCH=${ARCH} |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 73 | |
robert.swiecki@gmail.com | f761052 | 2015-02-16 10:52:02 +0000 | [diff] [blame] | 74 | all: warn_libs $(BIN) |
| 75 | |
| 76 | .c.o: %.c |
| 77 | $(CC) $(CFLAGS) -o $@ $< |
| 78 | |
robert.swiecki@gmail.com | c5f5be6 | 2015-02-15 17:17:21 +0000 | [diff] [blame] | 79 | warn_libs: |
| 80 | ifdef WARN_LIBRARY |
robert.swiecki@gmail.com | 66ee275 | 2015-02-16 20:49:44 +0000 | [diff] [blame] | 81 | @/bin/echo -e "*********************************************************" |
| 82 | @/bin/echo -e "Development libraries which are most likely missing on your OS:" |
| 83 | @/bin/echo "$(WARN_LIBRARY)" |
| 84 | @/bin/echo -e "*********************************************************" |
robert.swiecki@gmail.com | c5f5be6 | 2015-02-15 17:17:21 +0000 | [diff] [blame] | 85 | else |
| 86 | @/bin/true |
| 87 | endif |
| 88 | |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 89 | $(BIN): $(MIG_OBJECTS) $(OBJS) |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 90 | $(LD) -o $(BIN) $(OBJS) $(MIG_OBJECTS) $(CRASH_REPORT) $(LDFLAGS) |
groebert@google.com | 1bd4c21 | 2013-06-19 11:13:56 +0000 | [diff] [blame] | 91 | |
| 92 | $(MIG_OUTPUT): /usr/include/mach/mach_exc.defs |
| 93 | mig -header mach_exc.h -user mach_excUser.c -sheader mach_excServer.h -server mach_excServer.c /usr/include/mach/mach_exc.defs |
| 94 | |
| 95 | $(MIG_OBJECTS): $(MIG_OUTPUT) |
| 96 | $(CC) $(CFLAGS) mach_excUser.c |
| 97 | $(CC) $(CFLAGS) mach_excServer.c |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 98 | |
| 99 | clean: |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 100 | $(RM) core $(OBJS) $(BIN) $(MIG_OUTPUT) $(MIG_OBJECTS) |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 101 | |
| 102 | indent: |
robert.swiecki@gmail.com | 5be8882 | 2015-02-14 13:12:09 +0000 | [diff] [blame] | 103 | indent -linux -l100 -lc100 -nut -i4 -sob -c33 -cp33 *.c *.h */*.c */*.h; rm -f *~ */*~ |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 104 | |
| 105 | depend: |
robert.swiecki@gmail.com | 42f2a3e | 2015-02-17 00:20:49 +0000 | [diff] [blame^] | 106 | makedepend -Y. -Y* -- $(SRCS) |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 107 | |
robert.swiecki | 3bb518c | 2010-10-14 00:48:24 +0000 | [diff] [blame] | 108 | # DO NOT DELETE |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 109 | |
| 110 | honggfuzz.o: common.h log.h files.h fuzz.h util.h |
| 111 | log.o: common.h log.h |
| 112 | files.o: common.h files.h log.h |
robert.swiecki@gmail.com | 42f2a3e | 2015-02-17 00:20:49 +0000 | [diff] [blame^] | 113 | fuzz.o: common.h fuzz.h arch.h files.h log.h report.h util.h |
robert.swiecki@gmail.com | cc050fd | 2015-02-02 20:00:42 +0000 | [diff] [blame] | 114 | util.o: common.h log.h |
robert.swiecki@gmail.com | 42f2a3e | 2015-02-17 00:20:49 +0000 | [diff] [blame^] | 115 | report.o: common.h report.h log.h util.h |
| 116 | linux/ptrace.o: common.h linux/ptrace.h files.h linux/bfd.h linux/unwind.h |
| 117 | linux/ptrace.o: log.h util.h |
| 118 | linux/arch.o: common.h arch.h linux/ptrace.h log.h util.h |
| 119 | linux/bfd.o: common.h linux/bfd.h files.h log.h util.h |
| 120 | linux/unwind.o: common.h linux/unwind.h log.h |