Skip to content

Commit

Permalink
split Makefile for use with both GNU and BSD make
Browse files Browse the repository at this point in the history
  • Loading branch information
esmil committed Apr 13, 2009
1 parent 54a650c commit 5025412
Show file tree
Hide file tree
Showing 4 changed files with 163 additions and 72 deletions.
55 changes: 55 additions & 0 deletions BSDmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file is part of mktorrent
# Copyright (C) 2007, 2009 Emil Renner Berthing
#
# mktorrent 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; either version 2 of the License, or
# (at your option) any later version.
#
# mktorrent 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-1301, USA

.include Makefile

CC ?= cc
CFLAGS ?= -O2 -Wall
INSTALL ?= install
PREFIX ?= /usr/local

.ifdef USE_PTHREADS
DEFINES += -DUSE_PTHREADS
SRCS := $(SRCS:hash.c=hash_pthreads.c)
LIBS += -lpthread
.endif

.ifdef USE_OPENSSL
DEFINES += -DUSE_OPENSSL
SRCS := $(SRCS:sha1.c=)
LIBS += -lssl
.endif

.ifdef NO_LONG_OPTIONS
DEFINES += -DNO_LONG_OPTIONS
.endif

.ifdef NO_HASH_CHECK
DEFINES += -DNO_HASH_CHECK
.endif

.ifdef MAX_OPENFD
DEFINES += -DMAX_OPENFD="$(MAX_OPENFD)"
.endif

.ifdef DEBUG
DEFINES += -DDEBUG
.endif

OBJS = $(SRCS:.c=.o)

.include rules.mk
55 changes: 55 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This file is part of mktorrent
# Copyright (C) 2007, 2009 Emil Renner Berthing
#
# mktorrent 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; either version 2 of the License, or
# (at your option) any later version.
#
# mktorrent 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-1301, USA

include Makefile

CC ?= cc
CFLAGS ?= -O2 -Wall
INSTALL ?= install
PREFIX ?= /usr/local

ifdef USE_PTHREADS
DEFINES += -DUSE_PTHREADS
SRCS := $(SRCS:hash.c=hash_pthreads.c)
LIBS += -lpthread
endif

ifdef USE_OPENSSL
DEFINES += -DUSE_OPENSSL
SRCS := $(SRCS:sha1.c=)
LIBS += -lssl
endif

ifdef NO_LONG_OPTIONS
DEFINES += -DNO_LONG_OPTIONS
endif

ifdef NO_HASH_CHECK
DEFINES += -DNO_HASH_CHECK
endif

ifdef MAX_OPENFD
DEFINES += -DMAX_OPENFD="$(MAX_OPENFD)"
endif

ifdef DEBUG
DEFINES += -DDEBUG
endif

OBJS = $(SRCS:.c=.o)

include rules.mk
81 changes: 9 additions & 72 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file is part of mktorrent
# Copyright (C) 2007 Emil Renner Berthing
# Copyright (C) 2007, 2009 Emil Renner Berthing
#
# mktorrent is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -17,10 +17,11 @@

#-------------Interesting variables for you to override :)--------------------

CC ?= cc
CFLAGS ?= -O2 -Wall
INSTALL ?= install
PREFIX ?= /usr/local
# Default settings shown
#CC = cc
#CFLAGS = -O2 -Wall
#INSTALL = install
#PREFIX = /usr/local

# Use multiple POSIX threads for calculating hashes. This should be slightly
# faster. Much faster on systems with multiple CPUs and fast harddrives.
Expand Down Expand Up @@ -54,74 +55,10 @@ PREFIX ?= /usr/local
# information.
#DEBUG = 1


#-------------Nothing interesting below this line-----------------------------

program := mktorrent
version := 0.5
program = mktorrent
version = 0.6

HEADERS = mktorrent.h
SRCS := ftw.c init.c sha1.c hash.c output.c main.c
OBJS = $(SRCS:.c=.o)
LIBS :=

ifdef USE_PTHREADS
DEFINES += -DUSE_PTHREADS
SRCS := $(SRCS:hash.c=hash_pthreads.c)
LIBS += -lpthread
endif

ifdef USE_OPENSSL
DEFINES += -DUSE_OPENSSL
SRCS := $(SRCS:sha1.c=)
LIBS += -lssl
endif


ifdef NO_LONG_OPTIONS
DEFINES += -DNO_LONG_OPTIONS
endif

ifdef NO_HASH_CHECK
DEFINES += -DNO_HASH_CHECK
endif

ifdef MAX_OPENFD
DEFINES += -DMAX_OPENFD="$(MAX_OPENFD)"
endif

ifdef DEBUG
DEFINES += -DDEBUG
endif

override DEFINES += -DVERSION="\"$(version)\""
override CFLAGS += $(DEFINES)
override LDFLAGS += $(LIBS)

.PHONY: all strip indent clean install uninstall

all: $(program)

%.o : %.c $(HEADERS)
$(CC) $(CFLAGS) -c $<

$(program): $(OBJS)
$(CC) $(CFLAGS) $^ -o $(program) $(LDFLAGS)

allinone: $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) -DALLINONE main.c -o $(program) $(LDFLAGS)

strip:
strip $(program)

indent:
indent -kr -i8 *.c *.h

clean:
rm -f $(program) *.o *.c~ *.h~

install: $(program)
$(INSTALL) -m755 -D $(program) $(DESTDIR)$(PREFIX)/bin/$(program)

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(program)
SRCS = ftw.c init.c sha1.c hash.c output.c main.c
44 changes: 44 additions & 0 deletions rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This file is part of mktorrent
# Copyright (C) 2007, 2009 Emil Renner Berthing
#
# mktorrent 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; either version 2 of the License, or
# (at your option) any later version.
#
# mktorrent 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-1301, USA

.PHONY: all strip indent clean install uninstall

all: $(program)

%.o : %.c $(HEADERS)
$(CC) $(CFLAGS) $(DEFINES) -DVERSION="\"$(version)\"" -c $<

$(program): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(program) $(LDFLAGS) $(LIBS)

allinone: $(SRCS) $(HEADERS)
$(CC) $(CFLAGS) $(DEFINES) -DVERSION="\"$(version)\"" -DALLINONE main.c -o $(program) $(LDFLAGS) $(LIBS)

strip:
strip $(program)

indent:
indent -kr -i8 *.c *.h

clean:
rm -f $(program) *.o *.c~ *.h~

install: $(program)
$(INSTALL) -m755 -D $(program) $(DESTDIR)$(PREFIX)/bin/$(program)

uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(program)

0 comments on commit 5025412

Please sign in to comment.