1# *****************************************************************************
2# *									      *
3# *			  AREACODE Makefile for Linux			      *
4# *									      *
5# * (C) 1995-97  Ullrich von Bassewitz					      *
6# *		 Wacholderweg 14					      *
7# *		 D-70597 Stuttgart					      *
8# * EMail:	 uz@ibb.schwaben.com					      *
9# *									      *
10# *****************************************************************************
11
12
13
14# $Id$
15#
16# $Log$
17#
18#
19
20
21# ------------------------------------------------------------------------------
22# Stuff you may want to edit
23
24# The name of the data file after installation. You may want to define
25# AREACODE_DATAFILE before calling make instead
26ifdef AREACODE_DATAFILE
27DATATARGET=$(AREACODE_DATAFILE)
28else
29DATATARGET=/usr/lib/areacodes
30endif
31
32# Command line for the installation of the data file
33INSTALL	= install -o bin -g bin -m 644
34
35# ------------------------------------------------------------------------------
36# Definitions
37
38# Names of executables
39AS = gas
40AR = ar
41LD = ld
42ZIP = zip
43
44# Flags for the GNU C compiler
45CFLAGS	= -g -O2 -Wall
46
47# Name of the data file
48DATASOURCE=areacode.dat
49
50# ------------------------------------------------------------------------------
51# Implicit rules
52
53.c.o:
54	gcc $(CFLAGS) -c $<
55
56# ------------------------------------------------------------------------------
57#
58
59ifeq (.depend,$(wildcard .depend))
60all:	actest acvers
61include .depend
62else
63all:	depend
64endif
65
66
67actest:		areacode.o actest.o
68		gcc -o actest areacode.o actest.o
69
70acvers:		acvers.o
71		gcc -o acvers acvers.o
72
73areacode.o:	areacode.h areacode.c
74		gcc $(CFLAGS) -DDATA_FILENAME="\"$(DATATARGET)\"" \
75		-DCHARSET_ISO -c -o areacode.o areacode.c
76
77install:	areacode.o acvers
78		@if [ `id -u` != 0 ]; then				      \
79		    echo "";						      \
80		    echo 'Do "make install" as root';			      \
81		    echo "";						      \
82		    false;						      \
83		fi
84		@if [ -f $(DATATARGET) ]; then				      \
85		    NewVersion=`./acvers $(DATASOURCE) | awk '{ print $$3 }'`;\
86		    OldVersion=`./acvers $(DATATARGET) | awk '{ print $$3 }'`;\
87		    echo "Current datafile build number:  $$OldVersion";      \
88		    echo "Build number of new datafile:   $$NewVersion";      \
89		    if [ $$NewVersion -gt $$OldVersion ]; then                \
90			echo "Installing new datafile";			      \
91			$(INSTALL) $(DATASOURCE) $(DATATARGET);		      \
92		    else						      \
93			echo "Installed datafile is same or newer, skipping...";\
94		    fi;							      \
95		else							      \
96		    echo "Installing new datafile";			      \
97		    $(INSTALL) $(DATASOURCE) $(DATATARGET);		      \
98		fi
99
100# ------------------------------------------------------------------------------
101# Create a dependency file
102
103depend dep:
104	@echo "Creating dependency information"
105	$(CC) -MM *.c > .depend
106
107# ------------------------------------------------------------------------------
108# clean up
109
110distclean:	clean
111
112
113clean:
114	-rm -f *.bak *~ *.o .depend
115	-rm -f acvers actest
116
117zap:	distclean
118
119
120
121