File: Makefile

package info (click to toggle)
funtools 1.4.4+dfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 16,168 kB
  • ctags: 10,760
  • sloc: ansic: 87,238; sh: 9,727; lex: 4,595; asm: 3,281; ada: 1,681; makefile: 1,458; pascal: 1,089; cpp: 1,001; cs: 879; perl: 161; yacc: 64; sed: 32; csh: 10; tcl: 9
file content (754 lines) | stat: -rw-r--r-- 21,555 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
#
# This file is a Makefile for Funtools.  If it has the name "Makefile.in"
# then it is a template for a Makefile;  to generate the actual Makefile,
# run "./configure", which is a configuration script generated by the
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#

PACKAGE = funtools
VERSION = 1.4.4

DISTNAME = funtools-${VERSION}
DISTDIR = ../export/${DISTNAME}
FTPDIR	= ../ftp

#----------------------------------------------------------------
# Things you can change to personalize the Makefile for your own
# site (you can make these changes in either Makefile.in or
# Makefile, but changes to Makefile will get lost if you re-run
# the configuration script).
#----------------------------------------------------------------

# Default top-level directories in which to install architecture-
# specific files (exec_prefix) and machine-independent files such
# as scripts (prefix).  The values specified here may be overridden
# at configure-time with the --exec-prefix and --prefix options
# to the "configure" script.

prefix =		/home/eric
exec_prefix =		${prefix}

# The following definition can be set to non-null for special systems
# like AFS with replication.  It allows the pathnames used for installation
# to be different than those used for actually reference files at
# run-time.  INSTALL_ROOT is prepended to $prefix and $exec_prefix
# when installing files.
INSTALL_ROOT =

# Directory in which to install the .a or .so binary for the FUNTOOLS library:
LIB_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/lib

# Directory in which to install the program wish:
BIN_INSTALL_DIR =	$(INSTALL_ROOT)$(exec_prefix)/bin

# Directory in which to install the funtools.h include file:
INCLUDE_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/include

# Top-level directory for manual entries:
MAN_INSTALL_DIR =	$(INSTALL_ROOT)$(prefix)/man

# Top-level directory for share entries:
MAN_SHARE_DIR =		$(INSTALL_ROOT)$(prefix)/share/funtools

# util files are in the util subdirectory
UTIL_INC =		-I./util
# UTIL_LIBS =		-L./util -lutil

# fitsy files are in the fitsy subdirectory
FITSY_INC =		-I./fitsy
# FITSY_LIBS =		-L./fitsy -lfitsy

# wcs files are in the wcs subdirectory
WCS_INC =		-I./wcs
# WCS_LIBS =		-L./wcs -lwcs

# filter files are in the filter subdirectory
FILTER_INC =        	-I./filter
# FILTER_LIBS =		-L./filter -lfilter

# extra includes for compiling
INCLUDES =		$(UTIL_INC) $(FILTER_INC) $(WCS_INC) $(FITSY_INC)

# extra libs
EXTRA_LIBS =		 -ldl

# the full set of libraries for linking
LIBS = 			$(UTIL_LIBS) $(FILTER_LIBS) $(WCS_LIBS) $(FITSY_LIBS) \
			$(EXTRA_LIBS) -lm

# To change the compiler switches, for example to change from -O
# to -g, change the following line:
CFLAGS = 		-g -W -Wall -Wno-implicit-int -fPIC

# To add ld switches, change the following line:
LDFLAGS =		-g -rdynamic

# whether to set the FPU in double round mode
USE_FPU_DOUBLE =	0

# Some versions of make, like SGI's, use the following variable to
# determine which shell to use for executing commands:
SHELL =			/bin/sh

# extra modules added by configure.in to fix OS bugs
EXTRA_OBJS = 		

# special definitions for funcalc (based on filter configuration)
FUNCALC_CC =		NULL
FUNCALC_CFLAGS =	\"-O2\"

# if enabled-shared was specified, this will exand to "shlib" and trigger
# building of the shared library
DOSHARED =	
DOMAINLIB =	

# There are just too many different versions of "install" around;
# better to use the install-sh script that comes with the distribution,
# which is slower but guaranteed to work.

INSTALL = 		./install-sh -c
INSTALL_PROGRAM =	${INSTALL}
INSTALL_DATA =		${INSTALL} -m 644

# which awk-like program do we have?
PRE=			
POST=			|\& cat
AWK =			gawk
PIPEGLUE =		
GUNZIP =		gzip -dcf
GNUPLOT =		gnuplot

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in.  You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

AC_FLAGS =		-DHAVE_CONFIG_H
RANLIB =		ranlib
EXE =			

#----------------------------------------------------------------
# The information below should be usable as is.  The configure
# script won't modify it and you shouldn't need to modify it
# either.
#----------------------------------------------------------------

CC  =		gcc

CC_SWITCHES =	-I. ${CFLAGS} -DUSE_DL=1 ${INCLUDES} ${AC_FLAGS}

DEPEND_SWITCHES = -I. ${CFLAGS} ${INCLUDES} ${AC_FLAGS}

SRCS =		funcol.c funcopy.c funtab.c funim.c funinfo.c \
		funopen.c funopenp.c funparam.c funtext.c funwcs.c \
		funview.c funutil.c

OBJS =		funcol.o funcopy.o funtab.o funim.o funinfo.o \
		funopen.o funopenp.o funparam.o funtext.o funwcs.o \
		funview.o funutil.o

# these are all the modules going into the "normal" funtools library
LIBOBJS =	${OBJS}

# the default library for this package
DEFLIB =	libfuntools.a

# the actual library we are building (if this is a subpackage)
LIB =		libfuntools.a

# this is used in the link line
# LLIB =	$(LIB)
LLIB =		$(LIB)

# libraries containing main as subroutines
MAINLIB =	lib$(PACKAGE)MainLib.a

PROGS =		funcalc funcen funcnts funcone fundisp funhead funhist \
		funimage funjoin funmerge funsky funtable

MAINLIBOBJS =	funcalc_main.o funcen_main.o funcnts_main.o funcone_main.o \
		fundisp_main.o funhead_main.o funhist_main.o \
		funimage_main.o funmerge_main.o funsky_main.o funtable_main.o \
		funjoin_main.o 

PROGS2 =	_sort

TEMPLATES =	funcnts_plot.tmpl funhist_plot.tmpl funcnts_sed.tmpl \
		funtools_ds9.tmpl funds9.tmpl funtbl.tmpl funindex.tmpl

SCRIPTS =	funcnts.plot funhist.plot funcnts.sed funds9 funtbl funindex

DS9HELPERS =	funtools.ds9

FILES =		funcalc.sed

DEVEL =		

# Subdirectories to run make in for the primary targets.

SUBLIBS =	util fitsy wcs filter

SUBDIRS =	$(SUBLIBS) gnu funtest faq

all:		lib progs progs2 scripts ds9helpers

progs:		$(PROGS)

progs2:		$(PROGS2)

scripts:	$(SCRIPTS)

ds9helpers:	$(DS9HELPERS)

devel:		$(DEVEL)

libutil:	FORCE
		@(echo Making libutil.a in util ...; \
		  cd util; $(MAKE) libutil; mv libutil.a ..)

sublib:		FORCE
		@for dir in $(SUBLIBS); do \
		   echo " "; \
		   echo Making library in $$dir ...; \
		   (cd $$dir; $(MAKE)) ; \
		done

lib:		$(LIB) $(DOMAINLIB) $(DOSHARED)

$(LIB):		sublib $(LIBOBJS)
		ar cruv $(LIB) $(LIBOBJS)
		$(RANLIB) $(LIB)

funmainlib.c:	$(MAINLIBOBJS) mkfunmainlib
		echo $(PROGS) | ./mkfunmainlib > funmainlib.c;

shlib:		sublib $(LIBOBJS)
		@(rm -rf $(PACKAGE)tmp; mkdir $(PACKAGE)tmp; \
		(cd $(PACKAGE)tmp && ar x ../$(LIB)); \
		CC='$(CC)' CXX=$(CXX) \
		./mklib -o $(PACKAGE) $(PACKAGE)tmp/*.o; \
		rm -rf $(PACKAGE)tmp;)

mainlib:	$(MAINLIBOBJS) funmainlib.o lex.calc.o
		@(ar cruv lib$(PACKAGE)MainLib.a \
		$(MAINLIBOBJS) funmainlib.o lex.calc.o; \
		$(RANLIB) lib$(PACKAGE)MainLib.a)

shmainlib:	mainlib
		@(rm -rf $(PACKAGE)tmp; mkdir $(PACKAGE)tmp; \
		(cd $(PACKAGE)tmp && ar x ../lib$(PACKAGE)MainLib.a); \
		CC='$(CC)' CXX='$(CXX)' \
		./mklib -o $(PACKAGE)MainLib -L. -lfuntools $(PACKAGE)tmp/*.o;\
		rm -rf $(PACKAGE)tmp;)

tclfun:		$(LIB) tclmainlib.o tclfun.o
		@(ar cruv libtclfun.a tclmainlib.o tclfun.o; \
		$(RANLIB) libtclfun.a)

shtclfun:	tclfun
		@(rm -rf $(PACKAGE)tmp; mkdir $(PACKAGE)tmp; \
		(cd $(PACKAGE)tmp && ar x ../$(LIB) && ar x ../libtclfun.a); \
		CC='$(CC)' CXX='$(CXX)' \
		./mklib -o tclfun $(PACKAGE)tmp/*.o; \
		rm -rf $(PACKAGE)tmp; \
		test -r pkgIndex.tcl && mv pkgIndex.tcl pkgIndex.tcl-old; \
		SHLIB=libtclfun.so; \
		test -r libtclfun.dylib && SHLIB=libtclfun.dylib; \
		echo "pkg_mkIndex -direct . $${SHLIB}; exit" | tclsh;)

tclfun.c:	FORCE
		echo $(PROGS) | ./mkfunmainlib -tcl > tclfun.c


tclmainlib.o:	util/tclmainlib.c
		$(CC) -c $(CC_SWITCHES) util/tclmainlib.c

funcalc:	funcalc.o lex.calc.o lib
		$(CC) $(LDFLAGS) funcalc.o lex.calc.o -o funcalc \
		$(LLIB) $(LIBS)

funcen:		funcen.o lib
		$(CC) $(LDFLAGS) funcen.o -o funcen $(LLIB) $(LIBS)

funcnts:	funcnts.o lib
		$(CC) $(LDFLAGS) funcnts.o -o funcnts $(LLIB) $(LIBS)

funcone:	funcone.o lib
		$(CC) $(LDFLAGS) funcone.o -o funcone $(LLIB) $(LIBS)

fundisp:	fundisp.o lib
		$(CC) $(LDFLAGS) fundisp.o -o fundisp $(LLIB) $(LIBS)

funhist:	funhist.o lib
		$(CC) $(LDFLAGS) funhist.o -o funhist $(LLIB) $(LIBS)

funhead:	funhead.o lib
		$(CC) $(LDFLAGS) funhead.o -o funhead $(LLIB) $(LIBS)

funimage:	funimage.o lib
		$(CC) $(LDFLAGS) funimage.o -o funimage $(LLIB) $(LIBS)

funjoin:	funjoin.o lib
		$(CC) $(LDFLAGS) funjoin.o -o funjoin $(LLIB) $(LIBS)

funmerge:	funmerge.o lib
		$(CC) $(LDFLAGS) funmerge.o -o funmerge $(LLIB) $(LIBS)

funsky:	funsky.o lib
		$(CC) $(LDFLAGS) funsky.o -o funsky $(LLIB) $(LIBS)

funtable:	funtable.o lib
		$(CC) $(LDFLAGS) funtable.o -o funtable $(LLIB) $(LIBS)

_sort:		FORCE
		@(echo " "; echo "Making in gnu ..."; cd gnu; $(MAKE))

funcalc_main.o:	funcalc.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funcalc_main" \
		-o funcalc_main.o funcalc.c
funcen_main.o:	funcen.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funcen_main" \
		-o funcen_main.o funcen.c

funcnts_main.o:	funcnts.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funcnts_main" \
		-o funcnts_main.o funcnts.c
funcone_main.o:	funcone.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funcone_main" \
		-o funcone_main.o funcone.c
fundisp_main.o:	fundisp.c
		$(CC) -c $(CC_SWITCHES) -Dmain="fundisp_main" \
		-o fundisp_main.o fundisp.c
funhist_main.o:	funhist.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funhist_main" \
		-o funhist_main.o funhist.c
funhead_main.o:	funhead.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funhead_main" \
		-o funhead_main.o funhead.c
funimage_main.o:	funimage.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funimage_main" \
		-o funimage_main.o funimage.c
funjoin_main.o:	funjoin.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funjoin_main" \
		-o funjoin_main.o funjoin.c
funmerge_main.o:	funmerge.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funmerge_main" \
		-o funmerge_main.o funmerge.c
funsky_main.o:	funsky.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funsky_main" \
		-o funsky_main.o funsky.c

funtable_main.o:	funtable.c
		$(CC) -c $(CC_SWITCHES) -Dmain="funtable_main" \
		-o funtable_main.o funtable.c

funcnts.plot:	funcnts_plot.tmpl
		sed -e 's#AWK#$(AWK)#g' funcnts_plot.tmpl > funcnts.plot
		chmod +x funcnts.plot

funhist.plot:	funhist_plot.tmpl
		sed -e 's#AWK#$(AWK)#g' funhist_plot.tmpl > funhist.plot
		chmod +x funhist.plot

funds9:		funds9.tmpl
		sed -e 's#AWK#$(AWK)#g;s#GNUPLOT#$(GNUPLOT)#g' funds9.tmpl > funds9
		chmod +x funds9

funtbl:		funtbl.tmpl
		sed -e 's#AWK#$(AWK)#g;' funtbl.tmpl > funtbl
		chmod +x funtbl

funindex:	funindex.tmpl
		cp -p funindex.tmpl funindex
		chmod +x funindex

funcnts.sed:	funcnts_sed.tmpl
		cp funcnts_sed.tmpl funcnts.sed
		chmod +x funcnts.sed

funtools.ds9:	funtools_ds9.tmpl
		sed -e 's#PRE#$(PRE)#g;s#POST#$(POST)#g;s#GUNZIP#$(GUNZIP)#g' funtools_ds9.tmpl > funtools.ds9

diff:
		@-(for file in "`ls *.c`";				\
		    do							\
			echo $$file;					\
			diff /soft/saord/funtools-*/$$file .;	\
		    done;)

install::	install-binaries

install::	$(DOSHARED)_install

install::
		@for dir in $(SUBDIRS); do \
		   echo " "; \
		   echo Installing in $$dir ...; \
		   (cd $$dir; $(MAKE) $@) ; \
		done

install::	install-man

install::	install-share

install::	install-data

FORCE:

# Note: before running ranlib below, must cd to target directory because
# some ranlibs write to current directory, and this might not always be
# possible (e.g. if installing as root).

# this nop-op gets executed if we are not building shared libraries
_install:

shlib_install:
	@-(for i in `ls *.so* *.dylib *.sl 2>/dev/null` ; \
	   do \
	   if [ -h $$i ] ; then \
		echo "Installing link $$i" ; \
		tar cf - $$i | (cd $(LIB_INSTALL_DIR); tar xf -) ; \
	   else \
		echo "Installing $$i" ; \
		$(INSTALL_DATA) $$i $(LIB_INSTALL_DIR)/$$i ; \
		chmod 555 $(LIB_INSTALL_DIR)/$$i; \
	   fi; \
	   done;)

install-binaries: lib $(PROGS) $(SCRIPTS) $(DS9HELPERS)
	@for i in $(LIB_INSTALL_DIR) $(INCLUDE_INSTALL_DIR) $(BIN_INSTALL_DIR) ; \
	    do \
	    if [ ! -d $$i ] ; then \
		echo "Making directory $$i"; \
		mkdir $$i; \
		chmod 755 $$i; \
		else true; \
		fi; \
	    done;
	@if [ "$(LIB)" ] ; then \
	    XLIB=`basename $(LIB)`; \
	    echo "Installing $$XLIB"; \
	    $(INSTALL_DATA) $$XLIB $(LIB_INSTALL_DIR)/$$XLIB; \
	    (cd $(LIB_INSTALL_DIR); $(RANLIB) $$XLIB); \
	    chmod 555 $(LIB_INSTALL_DIR)/$$XLIB; \
        fi;
	@echo "Installing funtools.h"
	@$(INSTALL_DATA) funtools.h $(INCLUDE_INSTALL_DIR)/funtools.h
	@echo "Installing funtoolsP.h"
	@$(INSTALL_DATA) funtoolsP.h $(INCLUDE_INSTALL_DIR)/funtoolsP.h
	@for i in $(PROGS) ; \
	    do \
	        echo "Installing $$i$(EXE)" ; \
		$(INSTALL_PROGRAM) $$i$(EXE) $(BIN_INSTALL_DIR)/$$i$(EXE) ; \
	    done;
	@for i in $(SCRIPTS) ; \
	    do \
	        echo "Installing $$i" ; \
		$(INSTALL_PROGRAM) $$i $(BIN_INSTALL_DIR)/$$i ; \
	    done;
	@for i in $(DS9HELPERS) ; \
	    do \
		echo "Installing $$i" ; \
		$(INSTALL_DATA) $$i $(BIN_INSTALL_DIR)/$$i ; \
	    done;
	@for i in $(FILES) ; \
	    do \
		echo "Installing $$i" ; \
		$(INSTALL_DATA) $$i $(BIN_INSTALL_DIR)/$$i ; \
	    done;

install-man:
	@if [ ! -d $(MAN_INSTALL_DIR) ] ; then \
	    echo "Making directory $(MAN_INSTALL_DIR)"; \
	    mkdir $(MAN_INSTALL_DIR); \
	    chmod 755 $(MAN_INSTALL_DIR); \
	    else true; \
	fi;
	@-(for i in `ls ./man/man?/*.?` ; \
	    do \
		B=`basename $$i`; \
		E=`echo $$i | awk -F. '{print $$NF}'`; \
		M="$(MAN_INSTALL_DIR)/man$$E"; \
		if [ ! -d $$M ] ; then \
		    echo "Making directory $$M"; \
		    mkdir $$M; \
		    chmod 755 $$M; \
		    else true; \
		fi; \
		echo "Installing $$B" ; \
		$(INSTALL_DATA) $$i $$M/$$B; \
	    done;)

install-share:
	@if [ ! -d $(MAN_SHARE_DIR) ] ; then \
	    echo "Making directory $(MAN_SHARE_DIR)"; \
	    mkdir -p $(MAN_SHARE_DIR); \
	    chmod 755 $(MAN_SHARE_DIR); \
	    else true; \
	fi;
	@-(for i in `ls ./doc/sman/fun?.*` ; \
	    do \
		B=`basename $$i`; \
		echo "Installing $$B" ; \
		$(INSTALL_DATA) $$i $(MAN_SHARE_DIR)/$$B; \
	    done;)

install-data: install-pkgconfig

install-pkgconfig:
	@-(mkdir -p $(LIB_INSTALL_DIR)/pkgconfig; \
	echo "Installing funtools.pc" ; \
	$(INSTALL_DATA) funtools.pc $(LIB_INSTALL_DIR)/pkgconfig;)

Makefile:	Makefile.in
		$(SHELL) config.status

RM =		rm -f

topclean:
		$(RM) *.a *.so *.so.? *.so.?.? *.o *.dylib \
			$(PROGS) tmain \
			$(SCRIPTS) $(DS9HELPERS) \
			$(DEVEL) *.exe \
			core core.[0-9]* errs *pure* .nfs* \
			foo* *~ *.log \#* TAGS *.E a.out errors \
			gmon.out *.pg *.bak \
			config.info config.log \
			doc/*~ doc/*.bak
		$(RM) -r autom4te.cache

binclean:
		$(RM) ./lib/* ./include/* ./bin/*

subclean:
		for dir in $(SUBDIRS); do \
		  echo making clean in subdir $$dir ; \
		  (cd $$dir; if [ -f Makefile ]; then $(MAKE) clean; fi); \
		done

clean:		topclean binclean subclean

pclean:
		$(RM) $(PROGS) $(DEVEL)

distclean:	clean
		$(RM) config.status config.cache config.log funtools.pc

Distclean:	distclean
		for dir in $(SUBDIRS); do \
		  echo making clean in $$dir ; \
		  (cd $$dir; if [ -f Makefile ]; then $(MAKE) distclean; fi); \
		done


depend:
		makedepend -- $(DEPEND_SWITCHES) -- $(SRCS)

.c.o:
		$(CC) -c $(CC_SWITCHES) $<

funopen.o:	funopen.c funtools.h funtoolsP.h
funparam.o:	funparam.c funtools.h funtoolsP.h
funim.o:	funim.c funtools.h funtoolsP.h
funtab.o:	funtab.c funtools.h funtoolsP.h
funcol.o:	funcol.c funtools.h funtoolsP.h
funcopy.o:	funcopy.c funtools.h funtoolsP.h
funutil.o:	funutil.c funtools.h funtoolsP.h
funview.o:	funview.c funtools.h funtoolsP.h
funwcs.o:	funwcs.c funtools.h funtoolsP.h
funinfo.o:	funinfo.c funtools.h funtoolsP.h
funimage.o:	funimage.c funtools.h funtoolsP.h
funhist.o:	funhist.c funtools.h funtoolsP.h
fundisp.o:	fundisp.c funtools.h funtoolsP.h
funhead.o:	funhead.c funtools.h funtoolsP.h
funcnts.o:	funcnts.c funtools.h funtoolsP.h
funcen.o:	funcen.c funtools.h funtoolsP.h
funcone.o:	funcone.c funtools.h funtoolsP.h
funjoin.o:	funjoin.c funtools.h funtoolsP.h
funmerge.o:	funmerge.c funtools.h funtoolsP.h
funsky.o:	funsky.c funtools.h funtoolsP.h
funtable.o:	funtable.c funtools.h funtoolsP.h chandra.h
funcalc.o:	funcalc.c calc.h funtools.h funtoolsP.h
		$(CC) -c $(CC_SWITCHES) $< \
		-DFUN_INCLUDE="\"-I${prefix}/include\"" \
		-DFUNCALC_CC="$(FUNCALC_CC)" \
		-DFUNCALC_CFLAGS="$(FUNCALC_CFLAGS)" \
		-DFUN_LIB="\"-L${exec_prefix}/lib -lfuntools ${EXTRA_LIBS} -lm\""
lex.calc.o:	 lex.calc.c tabcalc_c.h

headers:	tabcalc_c.h
tabcalc_c.h:	tabcalc.c
		$(RM) tabcalc_c.h
		./inc.sed TABCALC_C < tabcalc.c > tabcalc_c.h

# remake the parser
LEX =		flex -Pcalc

parser:		calc.l
		@($(LEX) calc.l; \
		sed "s/yytext_ptr/calctext_ptr/g" < lex.calc.c > nlex.calc.c; \
		mv nlex.calc.c lex.calc.c)

funtools.h:	configure.ac
		@($(RM) -r ofuntools.h; \
		MAJOR=`echo "${VERSION}" | awk -F. '{print $$1}'`; \
		MINOR=`echo "${VERSION}" | awk -F. '{print $$2}'`; \
		PATCH=`echo "${VERSION}" | awk -F. '{print $$3}'`; \
		sed "s/^#define FUN_VERSION.*/#define FUN_VERSION \"$(VERSION)\"/;s/^#define FUN_MAJOR_VERSION.*/#define FUN_MAJOR_VERSION $${MAJOR}/;s/^#define FUN_MINOR_VERSION.*/#define FUN_MINOR_VERSION $${MINOR}/;s/^#define FUN_PATCH_LEVEL.*/#define FUN_PATCH_LEVEL $${PATCH}/;" < funtools.h > nfuntools.h; \
		mv funtools.h ofuntools.h; \
		mv nfuntools.h funtools.h)


#
# Target to create a proper FUNTOOLS distribution from information in the
# master source directory.  DISTDIR must be defined to indicate where
# to put the distribution.  DISTDIR must be an absolute path name.
#

configure:	configure.ac
		autoconf

Configure:	FORCE
		@for dir in $(SUBDIRS); do \
		   if [ -x $$dir/configure ]; then \
		     echo " "; \
		     echo Autoconf in $$dir ...; \
		     (cd $$dir; autoconf) ; \
		   fi; \
		done

Confiles:	
		@(for dir in $(SUBDIRS); do \
		   echo " "; \
		   echo Copying configure files to $$dir ...; \
		   cp -p aclocal.m4 tcl.m4 gcc33.m4 \
			conf.h.in config.sub config.guess install-sh $$dir; \
		done)

dist:		configure
		($(RM) -r $(DISTDIR); \
		mkdir $(DISTDIR); \
		cp -p README INSTALL COPYING $(DISTDIR)/.; \
		cp -p *.c *.h *.l $(DISTDIR)/.; \
		cp -p Makefile.in $(DISTDIR)/.; \
		chmod 664 $(DISTDIR)/Makefile.in; \
		cp -p conf.h.in $(DISTDIR)/.; \
		chmod 664 $(DISTDIR)/conf.h.in; \
		cp -p configure.ac $(DISTDIR)/.; \
		chmod 644 $(DISTDIR)/configure.ac; \
		cp -p  *.m4 $(DISTDIR)/.; \
		chmod 644 $(DISTDIR)/*.m4; \
		cp -p configure $(DISTDIR)/.; \
		chmod 755 $(DISTDIR)/configure; \
		cp -p config.sub config.guess $(DISTDIR)/.; \
		chmod 755 $(DISTDIR)/config.sub $(DISTDIR)/config.guess; \
		cp -p saoconfig $(DISTDIR)/.; \
		chmod 775 $(DISTDIR)/saoconfig; \
		cp -p install-sh $(DISTDIR)/.; \
		chmod +x $(DISTDIR)/install-sh; \
		cp -p funtools.pc.in $(DISTDIR)/.; \
		chmod +x $(DISTDIR)/funtools.pc.in; \
		cp -p inc.sed $(DISTDIR)/.; \
		chmod +x $(DISTDIR)/inc.sed; \
		cp -p mklib $(DISTDIR)/.; \
		chmod +x $(DISTDIR)/mklib; \
		cp -p mkfunmainlib $(DISTDIR)/.; \
		chmod +x $(DISTDIR)/mkfunmainlib; \
		cp -pR util filter fitsy wcs gnu $(DISTDIR)/.;\
		cp -pR funtest txt faq $(DISTDIR)/.;\
		cp -p $(TEMPLATES) $(DISTDIR)/.; \
		cp -p $(FILES) $(DISTDIR)/.; \
		mkdir $(DISTDIR)/doc; \
		cp -p ./doc/*.html ./doc/*.c  $(DISTDIR)/doc/.; \
		cp -p ./doc/*.ps ./doc/*.pdf $(DISTDIR)/doc/.; \
		cp -p ./doc/Makefile $(DISTDIR)/doc/.; \
		cp -p ./doc/szlong.c $(DISTDIR)/doc/.; \
		mkdir $(DISTDIR)/doc/sman; \
		cp -p ./doc/sman/* $(DISTDIR)/doc/sman/.; \
		mkdir $(DISTDIR)/man; \
		cp -p -R ./man/* $(DISTDIR)/man/.)

release:	dist
		(cd $(DISTDIR); cd ..; \
		tar cf - $(DISTNAME) | \
		gzip -9 -c > $(FTPDIR)/$(DISTNAME).tar.gz)

tar:
		($(RM) -r config.cache; \
		cd ..; \
		tar cf - $(DISTNAME) | gzip -9 -c > $(DISTNAME).tar.gz)

errcheck:
		@-egrep 'error|warning' foo | egrep -v "^lex.*but not used"

itar:
		(cd doc/sman; \
		tar cf - . | gzip -9 -c > ../../../$(DISTNAME)-iman.tar.gz)

sman:
		@(cd doc && $(MAKE) index)

docs:
		@(cd doc; $(MAKE))

untar:
		(make clean; cd ..; \
		$(RM) -r o$(DISTNAME); mv $(DISTNAME) o$(DISTNAME); \
		tar xfz $(DISTNAME).tar.gz)

pure:		funcalc.pure funcen.pure funcnts.pure funcone.pure \
		fundisp.pure funhead.pure funimage.pure funhist.pure \
		funmerge.pure funsky.pure funtable.pure \
		funjoin.pure 

funcen.pure:	lib funcen.o
		purify $(CC) $(LDFLAGS) funcen.o -o funcen.pure \
		$(LLIB) $(LIBS)

funcnts.pure:	lib funcnts.o
		purify $(CC) $(LDFLAGS) funcnts.o -o funcnts.pure \
		$(LLIB) $(LIBS)

funcone.pure:	lib funcone.o
		purify $(CC) $(LDFLAGS) funcone.o -o funcone.pure \
		$(LLIB) $(LIBS)

fundisp.pure:	lib fundisp.o
		purify $(CC) $(LDFLAGS) fundisp.o -o fundisp.pure \
		$(LLIB) $(LIBS)

funhead.pure:	lib funhead.o
		purify $(CC) $(LDFLAGS) funhead.o -o funhead.pure \
		$(LLIB) $(LIBS)

funsky.pure:	lib funsky.o
		purify $(CC) $(LDFLAGS) funsky.o -o funsky.pure \
		$(LLIB) $(LIBS)

funtable.pure:	lib funtable.o
		purify $(CC) $(LDFLAGS) funtable.o -o funtable.pure \
		$(LLIB) $(LIBS)

funimage.pure:	lib funimage.o
		purify $(CC) $(LDFLAGS) funimage.o -o funimage.pure \
		$(LLIB) $(LIBS)

funhist.pure:	lib funhist.o
		purify $(CC) $(LDFLAGS) funhist.o -o funhist.pure \
		$(LLIB) $(LIBS)

funjoin.pure:	lib funjoin.o
		purify $(CC) $(LDFLAGS) funjoin.o -o funjoin.pure \
		$(LLIB) $(LIBS)

funmerge.pure:	lib funmerge.o
		purify $(CC) $(LDFLAGS) funmerge.o -o funmerge.pure \
		$(LLIB) $(LIBS)

funcalc.pure:	lib funcalc.o lex.calc.o
		purify $(CC) $(LDFLAGS) funcalc.o lex.calc.o \
		-o funcalc.pure $(LLIB) $(LIBS)

# DO NOT DELETE THIS LINE -- make depend depends on it.