summarylogtreecommitdiffstats
path: root/Makefile.patch
blob: e0b76697a768d1e8c7728c91f669b465b3f6312f (plain)
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
--- fastahack-1.0.0.orig/Makefile	2019-09-04 11:46:27.000000000 +0530
+++ fastahack-1.0.0.new/Makefile	2023-06-01 23:24:46.491068502 +0530
@@ -1,21 +1,38 @@
+# Courtesy https://github.com/ekg/fastahack/pull/10
+# Use ?= to allow overriding from the env or command-line, e.g.
+#
+#	make CXXFLAGS="-O3 -fPIC" install
+#
+# Package managers will override many of these variables automatically, so
+# this is aimed at making it easy to create packages (Debian packages,
+# FreeBSD ports, MacPorts, pkgsrc, Arch build system, etc.)
 
-# Use ?= to allow overriding from the env or command-line
 CXX ?=		g++
 CXXFLAGS ?=	-O3
-PREFIX ?=	./stage
-STRIP_CMD ?=	strip
-INSTALL ?=	install -c
+DESTDIR ?=	stage
+PREFIX ?=	/usr/local
+STRIP ?=	strip
+INSTALL ?=	install -c 
 MKDIR ?=	mkdir -p
-
+AR ?=		ar
+LDFLAGS ?=
+INSTALL_LIB = $(INSTALL) -p -m 644
 # Required flags that we shouldn't override
+# Must be compiler-independent
 CXXFLAGS +=	-D_FILE_OFFSET_BITS=64
 
-OBJS =	Fasta.o FastaHack.o split.o disorder.o
+BIN =	fastahack
+LIB =	libfastahack.a
+OBJS =	Fasta.o split.o disorder.o
+MAIN =	FastaHack.o
+
+all:	$(BIN) $(LIB)
 
-all:	fastahack
+$(BIN): $(OBJS) $(MAIN)
+	$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(MAIN) -o $(BIN)
 
-fastahack: $(OBJS)
-	$(CXX) $(CXXFLAGS) $(OBJS) -o fastahack
+$(LIB): $(OBJS)
+	$(AR) -rs $(LIB) $(OBJS)
 
 FastaHack.o: Fasta.h FastaHack.cpp
 	$(CXX) $(CXXFLAGS) -c FastaHack.cpp
@@ -29,14 +46,18 @@
 disorder.o: disorder.c disorder.h
 	$(CXX) $(CXXFLAGS) -c disorder.c
 
-install: fastahack
+install: all
 	$(MKDIR) $(DESTDIR)$(PREFIX)/bin
-	$(INSTALL) fastahack $(DESTDIR)$(PREFIX)/bin
+	$(MKDIR) $(DESTDIR)$(PREFIX)/include/fastahack
+	$(MKDIR) $(DESTDIR)$(PREFIX)/lib
+	$(INSTALL) $(BIN) $(DESTDIR)$(PREFIX)/bin
+	$(INSTALL) *.h $(DESTDIR)$(PREFIX)/include/fastahack
+	$(INSTALL_LIB) $(LIB) $(DESTDIR)$(PREFIX)/lib
 
 install-strip: install
-	$(STRIP_CMD) $(DESTDIR)$(PREFIX)/bin/fastahack
+	$(STRIP) $(DESTDIR)$(PREFIX)/bin/$(BIN)
 
 clean:
-	rm -rf fastahack *.o stage
+	rm -rf $(BIN) $(LIB) $(OBJS) $(DESTDIR)
 
 .PHONY: clean