File: Makefile

package info (click to toggle)
crunch 3.6-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 416 kB
  • sloc: ansic: 5,012; makefile: 148
file content (120 lines) | stat: -rw-r--r-- 3,460 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
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
#   Copyright
#
#	Copyright (C) 2009-2013 Jason aka bofh28 <bofh28@gmail.com>
#
#   License
#	This program is free software; you can redistribute it and/or modify
#	it under the terms of the GNU General Public License as published by
#	the Free Software Foundation; version 2.
# 
#	This program is distributed in the hope that it will be useful,
#	but WITHOUT ANY WARRANTY; without even the implied warranty of
#	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
#	GNU General Public License for more details.
#
#	You should have received a copy of the GNU General Public License
#	along with this program; if not, write to the Free Software
#	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-13, USA
#	or see <http://www.gnu.org/licenses/gpl-2.0.html>.
#
#   Description
#
#	For standard FHS directory structure install, use command:
#	make PREFIX=/usr INSTALL_OPTIONS=geninstall

# detect Darwin = OS X enviro
UNAME_LOOKUP = $(shell uname -s)

# General variables
PACKAGE	    = crunch
VERSION	    = 3.6
PREFIX	    = /usr
DISTDIR	    = $(PACKAGE)-$(VERSION)
DISTFILES   = crunch.c crunch.1 charset.lst
BINDIR	    = $(PREFIX)/bin
LIBDIR	    = $(PREFIX)/lib/$(PACKAGE)
SHAREDIR    = $(PREFIX)/share/$(PACKAGE)
DOCDIR	    = $(PREFIX)/share/doc/$(PACKAGE)
MANDIR	    = $(PREFIX)/share/man/man1

INSTALL	    = $(shell which install)
CC	    = $(shell which gcc)
LIBFLAGS    = -lm
THREADFLAGS = -pthread
OPTFLAGS    = -g -o0
LINTFLAGS   = -Wall -pedantic
CFLAGS_STD  = $(THREADFLAGS) $(LINTFLAGS) -std=c99
VCFLAGS	    = $(CFLAGS_STD) $(OPTFLAGS)
LFS	    = $(shell getconf POSIX_V6_ILP32_OFFBIG_CFLAGS)

ifeq ($(UNAME_LOOKUP),Darwin)
#Darwin = OS X, and os x does not use root root as stated in email
  INSTALL_OPTIONS = -g $(shell id -gn) -o $(shell id -un)
# changing the CC flag from gcc is optional but Apple recommneds using LLVM clang compiler instad of gcc so it's a good practice to do so in an OS X enviro, alas not compulsory 
  CC = $(shell which cc)
#LFS flag HAS TO BE reset or it's a no-go :(
 LFS=""  
else
#non-mac as you were 
  INSTALL_OPTIONS = -g $(shell id -gn) -o $(shell id -un)
endif

# Default target
all: build

build: crunch

val:	crunch.c
	@echo "Building valgrind compatible binary..."
	$(CC) $(CPPFLAGS) $(VCFLAGS) $(CFLAGS) $(LFS) $? $(LIBFLAGS) $(LDFLAGS) -o $(PACKAGE)
	@echo "valgrind --leak-check=yes crunch ..."
	@echo ""

crunch: crunch.c
	@echo "Building binary..."
	$(CC) $(CPPFLAGS) $(CFLAGS_STD) $(CFLAGS) $(LFS) $? $(LIBFLAGS) $(LDFLAGS) -o $@
	@echo ""

# Clean target
clean:
	@echo "Cleaning sources..."
	rm -f *.o $(PACKAGE) *~ START
	@echo ""

# Install generic target
install: build
	@echo "Creating directories..."
	$(INSTALL) -d $(INSTALL_OPTIONS) \
		$(DESTDIR)$(BINDIR) \
		$(DESTDIR)$(MANDIR) \
		$(DESTDIR)$(SHAREDIR) \
		$(DESTDIR)$(DOCDIR)
	@echo "Copying binary..."
	$(INSTALL) crunch $(DESTDIR)$(BINDIR)
	@echo "Copying charset.lst..."
	$(INSTALL) -m 644 charset.lst $(DESTDIR)$(SHAREDIR)
	@echo "Copying COPYING..."
#	$(INSTALL) COPYING $(DESTDIR)$(DOCDIR)
	@echo "Installing man page..."
	$(INSTALL) crunch.1 $(DESTDIR)$(MANDIR)
	@echo ""

# Uninstall target
uninstall:
	@echo "Deleting binary and manpages..."
	rm -rf $(BTBINDIR)/
	rm -rf $(BINDIR)/$(PACKAGE)
	rm -f $(MANDIR)/crunch.1
	@echo ""

zip: clean
	cd .. ;\
	zip -r $(DISTDIR).zip $(DISTDIR)

tarball: clean
	cd .. ;\
	tar -czf $(DISTDIR).tgz $(DISTDIR)

bzip: clean
	cd .. ;\
	tar -cjf $(DISTDIR).tar.bz2 $(DISTDIR)