File: Makefile

package info (click to toggle)
atari-fdisk 0.7.1-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 236 kB
  • ctags: 225
  • sloc: ansic: 2,946; makefile: 136; sh: 23
file content (133 lines) | stat: -rw-r--r-- 3,623 bytes parent folder | download | duplicates (2)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
#
# Makefile for Atari fdisk
#
# $Id: Makefile,v 1.11 1998/02/09 12:59:48 rnhodek Exp $
#
# $Log: Makefile,v $
# Revision 1.11  1998/02/09 12:59:48  rnhodek
# Remove 'diff' again from 'dist' target; doesn't work because needs
# OLDVER=
#
# Revision 1.10  1998/02/07 21:18:57  rnhodek
# Fix TAGS target, remove TAGS file on 'distclean'
# Target 'dist' also makes diff
#
# Revision 1.9  1997/08/22 16:01:56  rnhodek
# Added release target
#
# Revision 1.8  1997/08/22 12:59:35  rnhodek
# Added header and RCS keywords
#

CC = gcc
CFLAGS = -O2 -g -Wall
LD = gcc
LDFLAGS =
LIBS =

# test for cross compiling
# If not on a m68k machine, this selects a cross compiler, because
# atari-fdisk is ment to run usually on an Atari.
# It is possible to build a cross fdisk (i.e., running on a non-Atari
# machine), but you have to explicitly set COMPILE_ARCH to m68k (with
# "make COMPILE_ARCH=m68k") to avoid cross-compiling. I admit this is
# counter-intuitive...
COMPILE_ARCH = $(shell uname -m)
ifneq ($(COMPILE_ARCH),m68k)
	CROSSPREFIX=m68k-linux-
	CC := $(CROSSPREFIX)$(CC)
	LD := $(CROSSPREFIX)$(LD)
endif

BINDIR = /sbin

CSRC = atari-fdisk.c menufuncs.c partable.c readpart.c writepart.c savetab.c \
       input.c disk.c util.c
OBJS = $(subst .c,.o,$(CSRC))

.PHONY: clean reallyclean distclean install depend TAGS dist tar \
        binary binary-sub diff

atari-fdisk: $(OBJS)
	$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
	ln -f $@ fdisk

clean:
	rm -f *.o core #*#

reallyclean: clean
	rm -f atari-fdisk fdisk .depend

distclean: reallyclean
	rm -f *~ *# *.orig *.rej TAGS

install:
	install -s -m 755 -o root -g root atari-fdisk $(BINDIR)
	ln -s atari-fdisk $(BINDIR)/fdisk.atari
	[ -f $(BINDIR)/fdisk ] || ln -s atari-fdisk $(BINDIR)/fdisk

depend:
	gcc -MM $(CSRC) >.depend

TAGS:
	etags -d -T `find . -name '*.[ch]'`

dist: binary tar

tar: distclean
	cd ..; \
	name="$(notdir $(shell pwd))"; \
	namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
	mv $$name $$namev; \
	tar cf $$namev.src.tar `find $$namev -path $$namev/CVS -prune -o -type f -print`; \
	gzip -9f $$namev.src.tar; \
	mv $$namev $$name

binary: atari-fdisk
	doit=""; [ root = "`whoami`" ] || doit=sudo; $$doit $(MAKE) binary-sub
	cd tmp; \
	name="$(notdir $(shell pwd))"; \
	namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
	tar cf ../../$$namev.bin.tar * ; \
	gzip -9f ../../$$namev.bin.tar
	doit=""; [ root = "`whoami`" ] || doit=sudo; $$doit rm -rf tmp

binary-sub:
	@[ root = "`whoami`" ] || (echo "Must be root for this!"; exit 1)
	mkdir -p tmp/$(BINDIR)
	$(MAKE) install BINDIR=tmp$(BINDIR)

# usage: make diff OLDVER=<last-release-number>
diff:
	@if [ "x$(OLDVER)" = "x" ]; then \
		echo "Usage: make diff OLDVER=<last-release-number>"; \
		exit 1; \
	fi; \
	name="$(notdir $(shell pwd))"; \
	namev="$$name-$(shell perl -ne 'print "$$1\n" if /VERSION.*"(\S+)"/;' version.h)"; \
	cvs diff -u -rRELEASE-$(OLDVER) >../$$namev.diff; \
	gzip -9f ../$$namev.diff


# usage: make release VER=<release-number>
release:
	@if [ "x$(VER)" = "x" ]; then \
		echo "Usage: make release VER=<release-number>"; \
		exit 1; \
	fi
	modified=`cvs status 2>/dev/null | awk '/Status:/ { if ($$4 != "Up-to-date") print $$2 }'`; \
	if [ "x$$modified" != "x" ]; then \
		echo "There are modified files: $$modified"; \
		echo "Commit first"; \
		exit 1; \
	fi
	sed "/VERSION/s/\".*\"/\"$(VER)\"/" <version.h >version.h.new
	mv version.h.new version.h
	cvs commit -m"Raised version to $(VER)" version.h
	cvs tag RELEASE-`echo $(VER) | sed 's/\./-/g'`


ifeq ($(wildcard .depend),.depend)
include .depend
endif